index-SHZgHE2U.js 3.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665
  1. function Lae(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 o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).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 k_=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ul(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var BC={exports:{}},Tb={};var zU;function Iae(){if(zU)return Tb;zU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,s){var o=null;if(s!==void 0&&(o=""+s),i.key!==void 0&&(o=""+i.key),"key"in i){s={};for(var l in i)l!=="key"&&(s[l]=i[l])}else s=i;return i=s.ref,{$$typeof:t,type:r,key:o,ref:i!==void 0?i:null,props:s}}return Tb.Fragment=e,Tb.jsx=n,Tb.jsxs=n,Tb}var BU;function Fae(){return BU||(BU=1,BC.exports=Iae()),BC.exports}var a=Fae(),$C={exports:{}},yn={};var $U;function Uae(){if($U)return yn;$U=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"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),m=Symbol.iterator;function p(B){return B===null||typeof B!="object"?null:(B=m&&B[m]||B["@@iterator"],typeof B=="function"?B:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,y={};function v(B,W,se){this.props=B,this.context=W,this.refs=y,this.updater=se||x}v.prototype.isReactComponent={},v.prototype.setState=function(B,W){if(typeof B!="object"&&typeof B!="function"&&B!=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,B,W,"setState")},v.prototype.forceUpdate=function(B){this.updater.enqueueForceUpdate(this,B,"forceUpdate")};function S(){}S.prototype=v.prototype;function N(B,W,se){this.props=B,this.context=W,this.refs=y,this.updater=se||x}var C=N.prototype=new S;C.constructor=N,b(C,v.prototype),C.isPureReactComponent=!0;var T=Array.isArray;function k(){}var E={H:null,A:null,T:null,S:null},D=Object.prototype.hasOwnProperty;function A(B,W,se){var ne=se.ref;return{$$typeof:t,type:B,key:W,ref:ne!==void 0?ne:null,props:se}}function R(B,W){return A(B.type,W,B.props)}function F(B){return typeof B=="object"&&B!==null&&B.$$typeof===t}function O(B){var W={"=":"=0",":":"=2"};return"$"+B.replace(/[=:]/g,function(se){return W[se]})}var H=/\/+/g;function j(B,W){return typeof B=="object"&&B!==null&&B.key!=null?O(""+B.key):W.toString(36)}function G(B){switch(B.status){case"fulfilled":return B.value;case"rejected":throw B.reason;default:switch(typeof B.status=="string"?B.then(k,k):(B.status="pending",B.then(function(W){B.status==="pending"&&(B.status="fulfilled",B.value=W)},function(W){B.status==="pending"&&(B.status="rejected",B.reason=W)})),B.status){case"fulfilled":return B.value;case"rejected":throw B.reason}}throw B}function $(B,W,se,ne,ce){var fe=typeof B;(fe==="undefined"||fe==="boolean")&&(B=null);var ye=!1;if(B===null)ye=!0;else switch(fe){case"bigint":case"string":case"number":ye=!0;break;case"object":switch(B.$$typeof){case t:case e:ye=!0;break;case d:return ye=B._init,$(ye(B._payload),W,se,ne,ce)}}if(ye)return ce=ce(B),ye=ne===""?"."+j(B,0):ne,T(ce)?(se="",ye!=null&&(se=ye.replace(H,"$&/")+"/"),$(ce,W,se,"",function(Pe){return Pe})):ce!=null&&(F(ce)&&(ce=R(ce,se+(ce.key==null||B&&B.key===ce.key?"":(""+ce.key).replace(H,"$&/")+"/")+ye)),W.push(ce)),1;ye=0;var ge=ne===""?".":ne+":";if(T(B))for(var xe=0;xe<B.length;xe++)ne=B[xe],fe=ge+j(ne,xe),ye+=$(ne,W,se,fe,ce);else if(xe=p(B),typeof xe=="function")for(B=xe.call(B),xe=0;!(ne=B.next()).done;)ne=ne.value,fe=ge+j(ne,xe++),ye+=$(ne,W,se,fe,ce);else if(fe==="object"){if(typeof B.then=="function")return $(G(B),W,se,ne,ce);throw W=String(B),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(B).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.")}return ye}function q(B,W,se){if(B==null)return B;var ne=[],ce=0;return $(B,ne,"","",function(fe){return W.call(se,fe,ce++)}),ne}function Y(B){if(B._status===-1){var W=B._result;W=W(),W.then(function(se){(B._status===0||B._status===-1)&&(B._status=1,B._result=se)},function(se){(B._status===0||B._status===-1)&&(B._status=2,B._result=se)}),B._status===-1&&(B._status=0,B._result=W)}if(B._status===1)return B._result.default;throw B._result}var Z=typeof reportError=="function"?reportError:function(B){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var W=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof B=="object"&&B!==null&&typeof B.message=="string"?String(B.message):String(B),error:B});if(!window.dispatchEvent(W))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",B);return}console.error(B)},oe={map:q,forEach:function(B,W,se){q(B,function(){W.apply(this,arguments)},se)},count:function(B){var W=0;return q(B,function(){W++}),W},toArray:function(B){return q(B,function(W){return W})||[]},only:function(B){if(!F(B))throw Error("React.Children.only expected to receive a single React element child.");return B}};return yn.Activity=f,yn.Children=oe,yn.Component=v,yn.Fragment=n,yn.Profiler=i,yn.PureComponent=N,yn.StrictMode=r,yn.Suspense=c,yn.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=E,yn.__COMPILER_RUNTIME={__proto__:null,c:function(B){return E.H.useMemoCache(B)}},yn.cache=function(B){return function(){return B.apply(null,arguments)}},yn.cacheSignal=function(){return null},yn.cloneElement=function(B,W,se){if(B==null)throw Error("The argument must be a React element, but you passed "+B+".");var ne=b({},B.props),ce=B.key;if(W!=null)for(fe in W.key!==void 0&&(ce=""+W.key),W)!D.call(W,fe)||fe==="key"||fe==="__self"||fe==="__source"||fe==="ref"&&W.ref===void 0||(ne[fe]=W[fe]);var fe=arguments.length-2;if(fe===1)ne.children=se;else if(1<fe){for(var ye=Array(fe),ge=0;ge<fe;ge++)ye[ge]=arguments[ge+2];ne.children=ye}return A(B.type,ce,ne)},yn.createContext=function(B){return B={$$typeof:o,_currentValue:B,_currentValue2:B,_threadCount:0,Provider:null,Consumer:null},B.Provider=B,B.Consumer={$$typeof:s,_context:B},B},yn.createElement=function(B,W,se){var ne,ce={},fe=null;if(W!=null)for(ne in W.key!==void 0&&(fe=""+W.key),W)D.call(W,ne)&&ne!=="key"&&ne!=="__self"&&ne!=="__source"&&(ce[ne]=W[ne]);var ye=arguments.length-2;if(ye===1)ce.children=se;else if(1<ye){for(var ge=Array(ye),xe=0;xe<ye;xe++)ge[xe]=arguments[xe+2];ce.children=ge}if(B&&B.defaultProps)for(ne in ye=B.defaultProps,ye)ce[ne]===void 0&&(ce[ne]=ye[ne]);return A(B,fe,ce)},yn.createRef=function(){return{current:null}},yn.forwardRef=function(B){return{$$typeof:l,render:B}},yn.isValidElement=F,yn.lazy=function(B){return{$$typeof:d,_payload:{_status:-1,_result:B},_init:Y}},yn.memo=function(B,W){return{$$typeof:u,type:B,compare:W===void 0?null:W}},yn.startTransition=function(B){var W=E.T,se={};E.T=se;try{var ne=B(),ce=E.S;ce!==null&&ce(se,ne),typeof ne=="object"&&ne!==null&&typeof ne.then=="function"&&ne.then(k,Z)}catch(fe){Z(fe)}finally{W!==null&&se.types!==null&&(W.types=se.types),E.T=W}},yn.unstable_useCacheRefresh=function(){return E.H.useCacheRefresh()},yn.use=function(B){return E.H.use(B)},yn.useActionState=function(B,W,se){return E.H.useActionState(B,W,se)},yn.useCallback=function(B,W){return E.H.useCallback(B,W)},yn.useContext=function(B){return E.H.useContext(B)},yn.useDebugValue=function(){},yn.useDeferredValue=function(B,W){return E.H.useDeferredValue(B,W)},yn.useEffect=function(B,W){return E.H.useEffect(B,W)},yn.useEffectEvent=function(B){return E.H.useEffectEvent(B)},yn.useId=function(){return E.H.useId()},yn.useImperativeHandle=function(B,W,se){return E.H.useImperativeHandle(B,W,se)},yn.useInsertionEffect=function(B,W){return E.H.useInsertionEffect(B,W)},yn.useLayoutEffect=function(B,W){return E.H.useLayoutEffect(B,W)},yn.useMemo=function(B,W){return E.H.useMemo(B,W)},yn.useOptimistic=function(B,W){return E.H.useOptimistic(B,W)},yn.useReducer=function(B,W,se){return E.H.useReducer(B,W,se)},yn.useRef=function(B){return E.H.useRef(B)},yn.useState=function(B){return E.H.useState(B)},yn.useSyncExternalStore=function(B,W,se){return E.H.useSyncExternalStore(B,W,se)},yn.useTransition=function(){return E.H.useTransition()},yn.version="19.2.0",yn}var HU;function px(){return HU||(HU=1,$C.exports=Uae()),$C.exports}var w=px();const Kr=ul(w),zae=Lae({__proto__:null,default:Kr},[w]);var HC={exports:{}},Ab={},VC={exports:{}},GC={};var VU;function Bae(){return VU||(VU=1,(function(t){function e($,q){var Y=$.length;$.push(q);e:for(;0<Y;){var Z=Y-1>>>1,oe=$[Z];if(0<i(oe,q))$[Z]=q,$[Y]=oe,Y=Z;else break e}}function n($){return $.length===0?null:$[0]}function r($){if($.length===0)return null;var q=$[0],Y=$.pop();if(Y!==q){$[0]=Y;e:for(var Z=0,oe=$.length,B=oe>>>1;Z<B;){var W=2*(Z+1)-1,se=$[W],ne=W+1,ce=$[ne];if(0>i(se,Y))ne<oe&&0>i(ce,se)?($[Z]=ce,$[ne]=Y,Z=ne):($[Z]=se,$[W]=Y,Z=W);else if(ne<oe&&0>i(ce,Y))$[Z]=ce,$[ne]=Y,Z=ne;else break e}}return q}function i($,q){var Y=$.sortIndex-q.sortIndex;return Y!==0?Y:$.id-q.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 o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var c=[],u=[],d=1,f=null,m=3,p=!1,x=!1,b=!1,y=!1,v=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;function C($){for(var q=n(u);q!==null;){if(q.callback===null)r(u);else if(q.startTime<=$)r(u),q.sortIndex=q.expirationTime,e(c,q);else break;q=n(u)}}function T($){if(b=!1,C($),!x)if(n(c)!==null)x=!0,k||(k=!0,O());else{var q=n(u);q!==null&&G(T,q.startTime-$)}}var k=!1,E=-1,D=5,A=-1;function R(){return y?!0:!(t.unstable_now()-A<D)}function F(){if(y=!1,k){var $=t.unstable_now();A=$;var q=!0;try{e:{x=!1,b&&(b=!1,S(E),E=-1),p=!0;var Y=m;try{t:{for(C($),f=n(c);f!==null&&!(f.expirationTime>$&&R());){var Z=f.callback;if(typeof Z=="function"){f.callback=null,m=f.priorityLevel;var oe=Z(f.expirationTime<=$);if($=t.unstable_now(),typeof oe=="function"){f.callback=oe,C($),q=!0;break t}f===n(c)&&r(c),C($)}else r(c);f=n(c)}if(f!==null)q=!0;else{var B=n(u);B!==null&&G(T,B.startTime-$),q=!1}}break e}finally{f=null,m=Y,p=!1}q=void 0}}finally{q?O():k=!1}}}var O;if(typeof N=="function")O=function(){N(F)};else if(typeof MessageChannel<"u"){var H=new MessageChannel,j=H.port2;H.port1.onmessage=F,O=function(){j.postMessage(null)}}else O=function(){v(F,0)};function G($,q){E=v(function(){$(t.unstable_now())},q)}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($){$.callback=null},t.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):D=0<$?Math.floor(1e3/$):5},t.unstable_getCurrentPriorityLevel=function(){return m},t.unstable_next=function($){switch(m){case 1:case 2:case 3:var q=3;break;default:q=m}var Y=m;m=q;try{return $()}finally{m=Y}},t.unstable_requestPaint=function(){y=!0},t.unstable_runWithPriority=function($,q){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var Y=m;m=$;try{return q()}finally{m=Y}},t.unstable_scheduleCallback=function($,q,Y){var Z=t.unstable_now();switch(typeof Y=="object"&&Y!==null?(Y=Y.delay,Y=typeof Y=="number"&&0<Y?Z+Y:Z):Y=Z,$){case 1:var oe=-1;break;case 2:oe=250;break;case 5:oe=1073741823;break;case 4:oe=1e4;break;default:oe=5e3}return oe=Y+oe,$={id:d++,callback:q,priorityLevel:$,startTime:Y,expirationTime:oe,sortIndex:-1},Y>Z?($.sortIndex=Y,e(u,$),n(c)===null&&$===n(u)&&(b?(S(E),E=-1):b=!0,G(T,Y-Z))):($.sortIndex=oe,e(c,$),x||p||(x=!0,k||(k=!0,O()))),$},t.unstable_shouldYield=R,t.unstable_wrapCallback=function($){var q=m;return function(){var Y=m;m=q;try{return $.apply(this,arguments)}finally{m=Y}}}})(GC)),GC}var GU;function $ae(){return GU||(GU=1,VC.exports=Bae()),VC.exports}var qC={exports:{}},za={};var qU;function Hae(){if(qU)return za;qU=1;var t=px();function e(c){var u="https://react.dev/errors/"+c;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)u+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+c+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},i=Symbol.for("react.portal");function s(c,u,d){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:f==null?null:""+f,children:c,containerInfo:u,implementation:d}}var o=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(c,u){if(c==="font")return"";if(typeof u=="string")return u==="use-credentials"?u:""}return za.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,za.createPortal=function(c,u){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)throw Error(e(299));return s(c,u,null,d)},za.flushSync=function(c){var u=o.T,d=r.p;try{if(o.T=null,r.p=2,c)return c()}finally{o.T=u,r.p=d,r.d.f()}},za.preconnect=function(c,u){typeof c=="string"&&(u?(u=u.crossOrigin,u=typeof u=="string"?u==="use-credentials"?u:"":void 0):u=null,r.d.C(c,u))},za.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},za.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin),m=typeof u.integrity=="string"?u.integrity:void 0,p=typeof u.fetchPriority=="string"?u.fetchPriority:void 0;d==="style"?r.d.S(c,typeof u.precedence=="string"?u.precedence:void 0,{crossOrigin:f,integrity:m,fetchPriority:p}):d==="script"&&r.d.X(c,{crossOrigin:f,integrity:m,fetchPriority:p,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},za.preinitModule=function(c,u){if(typeof c=="string")if(typeof u=="object"&&u!==null){if(u.as==null||u.as==="script"){var d=l(u.as,u.crossOrigin);r.d.M(c,{crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0})}}else u==null&&r.d.M(c)},za.preload=function(c,u){if(typeof c=="string"&&typeof u=="object"&&u!==null&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin);r.d.L(c,d,{crossOrigin:f,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0,type:typeof u.type=="string"?u.type:void 0,fetchPriority:typeof u.fetchPriority=="string"?u.fetchPriority:void 0,referrerPolicy:typeof u.referrerPolicy=="string"?u.referrerPolicy:void 0,imageSrcSet:typeof u.imageSrcSet=="string"?u.imageSrcSet:void 0,imageSizes:typeof u.imageSizes=="string"?u.imageSizes:void 0,media:typeof u.media=="string"?u.media:void 0})}},za.preloadModule=function(c,u){if(typeof c=="string")if(u){var d=l(u.as,u.crossOrigin);r.d.m(c,{as:typeof u.as=="string"&&u.as!=="script"?u.as:void 0,crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0})}else r.d.m(c)},za.requestFormReset=function(c){r.d.r(c)},za.unstable_batchedUpdates=function(c,u){return c(u)},za.useFormState=function(c,u,d){return o.H.useFormState(c,u,d)},za.useFormStatus=function(){return o.H.useHostTransitionStatus()},za.version="19.2.0",za}var WU;function Nq(){if(WU)return qC.exports;WU=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(),qC.exports=Hae(),qC.exports}var KU;function Vae(){if(KU)return Ab;KU=1;var t=$ae(),e=px(),n=Nq();function r(h){var g="https://react.dev/errors/"+h;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)g+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+h+"; visit "+g+" 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 g=h,_=h;if(h.alternate)for(;g.return;)g=g.return;else{h=g;do g=h,(g.flags&4098)!==0&&(_=g.return),h=g.return;while(h)}return g.tag===3?_:null}function o(h){if(h.tag===13){var g=h.memoizedState;if(g===null&&(h=h.alternate,h!==null&&(g=h.memoizedState)),g!==null)return g.dehydrated}return null}function l(h){if(h.tag===31){var g=h.memoizedState;if(g===null&&(h=h.alternate,h!==null&&(g=h.memoizedState)),g!==null)return g.dehydrated}return null}function c(h){if(s(h)!==h)throw Error(r(188))}function u(h){var g=h.alternate;if(!g){if(g=s(h),g===null)throw Error(r(188));return g!==h?null:h}for(var _=h,M=g;;){var P=_.return;if(P===null)break;var I=P.alternate;if(I===null){if(M=P.return,M!==null){_=M;continue}break}if(P.child===I.child){for(I=P.child;I;){if(I===_)return c(P),h;if(I===M)return c(P),g;I=I.sibling}throw Error(r(188))}if(_.return!==M.return)_=P,M=I;else{for(var ee=!1,ve=P.child;ve;){if(ve===_){ee=!0,_=P,M=I;break}if(ve===M){ee=!0,M=P,_=I;break}ve=ve.sibling}if(!ee){for(ve=I.child;ve;){if(ve===_){ee=!0,_=I,M=P;break}if(ve===M){ee=!0,M=I,_=P;break}ve=ve.sibling}if(!ee)throw Error(r(189))}}if(_.alternate!==M)throw Error(r(190))}if(_.tag!==3)throw Error(r(188));return _.stateNode.current===_?h:g}function d(h){var g=h.tag;if(g===5||g===26||g===27||g===6)return h;for(h=h.child;h!==null;){if(g=d(h),g!==null)return g;h=h.sibling}return null}var f=Object.assign,m=Symbol.for("react.element"),p=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),N=Symbol.for("react.context"),C=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),A=Symbol.for("react.activity"),R=Symbol.for("react.memo_cache_sentinel"),F=Symbol.iterator;function O(h){return h===null||typeof h!="object"?null:(h=F&&h[F]||h["@@iterator"],typeof h=="function"?h:null)}var H=Symbol.for("react.client.reference");function j(h){if(h==null)return null;if(typeof h=="function")return h.$$typeof===H?null:h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case b:return"Fragment";case v:return"Profiler";case y:return"StrictMode";case T:return"Suspense";case k:return"SuspenseList";case A:return"Activity"}if(typeof h=="object")switch(h.$$typeof){case x:return"Portal";case N:return h.displayName||"Context";case S:return(h._context.displayName||"Context")+".Consumer";case C:var g=h.render;return h=h.displayName,h||(h=g.displayName||g.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case E:return g=h.displayName||null,g!==null?g:j(h.type)||"Memo";case D:g=h._payload,h=h._init;try{return j(h(g))}catch{}}return null}var G=Array.isArray,$=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,q=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y={pending:!1,data:null,method:null,action:null},Z=[],oe=-1;function B(h){return{current:h}}function W(h){0>oe||(h.current=Z[oe],Z[oe]=null,oe--)}function se(h,g){oe++,Z[oe]=h.current,h.current=g}var ne=B(null),ce=B(null),fe=B(null),ye=B(null);function ge(h,g){switch(se(fe,g),se(ce,h),se(ne,null),g.nodeType){case 9:case 11:h=(h=g.documentElement)&&(h=h.namespaceURI)?cU(h):0;break;default:if(h=g.tagName,g=g.namespaceURI)g=cU(g),h=uU(g,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}W(ne),se(ne,h)}function xe(){W(ne),W(ce),W(fe)}function Pe(h){h.memoizedState!==null&&se(ye,h);var g=ne.current,_=uU(g,h.type);g!==_&&(se(ce,h),se(ne,_))}function Ue(h){ce.current===h&&(W(ne),W(ce)),ye.current===h&&(W(ye),Nb._currentValue=Y)}var be,it;function U(h){if(be===void 0)try{throw Error()}catch(_){var g=_.stack.trim().match(/\n( *(at )?)/);be=g&&g[1]||"",it=-1<_.stack.indexOf(`
  2. at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
  3. `+be+h+it}var K=!1;function J(h,g){if(!h||K)return"";K=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var M={DetermineComponentFrameRoot:function(){try{if(g){var vt=function(){throw Error()};if(Object.defineProperty(vt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(vt,[])}catch(pt){var ot=pt}Reflect.construct(h,[],vt)}else{try{vt.call()}catch(pt){ot=pt}h.call(vt.prototype)}}else{try{throw Error()}catch(pt){ot=pt}(vt=h())&&typeof vt.catch=="function"&&vt.catch(function(){})}}catch(pt){if(pt&&ot&&typeof pt.stack=="string")return[pt.stack,ot.stack]}return[null,null]}};M.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var P=Object.getOwnPropertyDescriptor(M.DetermineComponentFrameRoot,"name");P&&P.configurable&&Object.defineProperty(M.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var I=M.DetermineComponentFrameRoot(),ee=I[0],ve=I[1];if(ee&&ve){var ze=ee.split(`
  4. `),rt=ve.split(`
  5. `);for(P=M=0;M<ze.length&&!ze[M].includes("DetermineComponentFrameRoot");)M++;for(;P<rt.length&&!rt[P].includes("DetermineComponentFrameRoot");)P++;if(M===ze.length||P===rt.length)for(M=ze.length-1,P=rt.length-1;1<=M&&0<=P&&ze[M]!==rt[P];)P--;for(;1<=M&&0<=P;M--,P--)if(ze[M]!==rt[P]){if(M!==1||P!==1)do if(M--,P--,0>P||ze[M]!==rt[P]){var gt=`
  6. `+ze[M].replace(" at new "," at ");return h.displayName&&gt.includes("<anonymous>")&&(gt=gt.replace("<anonymous>",h.displayName)),gt}while(1<=M&&0<=P);break}}}finally{K=!1,Error.prepareStackTrace=_}return(_=h?h.displayName||h.name:"")?U(_):""}function Q(h,g){switch(h.tag){case 26:case 27:case 5:return U(h.type);case 16:return U("Lazy");case 13:return h.child!==g&&g!==null?U("Suspense Fallback"):U("Suspense");case 19:return U("SuspenseList");case 0:case 15:return J(h.type,!1);case 11:return J(h.type.render,!1);case 1:return J(h.type,!0);case 31:return U("Activity");default:return""}}function z(h){try{var g="",_=null;do g+=Q(h,_),_=h,h=h.return;while(h);return g}catch(M){return`
  7. Error generating stack: `+M.message+`
  8. `+M.stack}}var re=Object.prototype.hasOwnProperty,Ee=t.unstable_scheduleCallback,_e=t.unstable_cancelCallback,Te=t.unstable_shouldYield,V=t.unstable_requestPaint,L=t.unstable_now,X=t.unstable_getCurrentPriorityLevel,te=t.unstable_ImmediatePriority,Me=t.unstable_UserBlockingPriority,ie=t.unstable_NormalPriority,De=t.unstable_LowPriority,Le=t.unstable_IdlePriority,$e=t.log,Ze=t.unstable_setDisableYieldValue,Ie=null,ae=null;function He(h){if(typeof $e=="function"&&Ze(h),ae&&typeof ae.setStrictMode=="function")try{ae.setStrictMode(Ie,h)}catch{}}var Se=Math.clz32?Math.clz32:we,Be=Math.log,ft=Math.LN2;function we(h){return h>>>=0,h===0?32:31-(Be(h)/ft|0)|0}var tt=256,ke=262144,We=4194304;function pe(h){var g=h&42;if(g!==0)return g;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 Ce(h,g,_){var M=h.pendingLanes;if(M===0)return 0;var P=0,I=h.suspendedLanes,ee=h.pingedLanes;h=h.warmLanes;var ve=M&134217727;return ve!==0?(M=ve&~I,M!==0?P=pe(M):(ee&=ve,ee!==0?P=pe(ee):_||(_=ve&~h,_!==0&&(P=pe(_))))):(ve=M&~I,ve!==0?P=pe(ve):ee!==0?P=pe(ee):_||(_=M&~h,_!==0&&(P=pe(_)))),P===0?0:g!==0&&g!==P&&(g&I)===0&&(I=P&-P,_=g&-g,I>=_||I===32&&(_&4194048)!==0)?g:P}function de(h,g){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&g)===0}function Ve(h,g){switch(h){case 1:case 2:case 4:case 8:case 64:return g+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 g+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 yt(){var h=We;return We<<=1,(We&62914560)===0&&(We=4194304),h}function ut(h){for(var g=[],_=0;31>_;_++)g.push(h);return g}function It(h,g){h.pendingLanes|=g,g!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function Ft(h,g,_,M,P,I){var ee=h.pendingLanes;h.pendingLanes=_,h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0,h.expiredLanes&=_,h.entangledLanes&=_,h.errorRecoveryDisabledLanes&=_,h.shellSuspendCounter=0;var ve=h.entanglements,ze=h.expirationTimes,rt=h.hiddenUpdates;for(_=ee&~_;0<_;){var gt=31-Se(_),vt=1<<gt;ve[gt]=0,ze[gt]=-1;var ot=rt[gt];if(ot!==null)for(rt[gt]=null,gt=0;gt<ot.length;gt++){var pt=ot[gt];pt!==null&&(pt.lane&=-536870913)}_&=~vt}M!==0&&vn(h,M,0),I!==0&&P===0&&h.tag!==0&&(h.suspendedLanes|=I&~(ee&~g))}function vn(h,g,_){h.pendingLanes|=g,h.suspendedLanes&=~g;var M=31-Se(g);h.entangledLanes|=g,h.entanglements[M]=h.entanglements[M]|1073741824|_&261930}function Kt(h,g){var _=h.entangledLanes|=g;for(h=h.entanglements;_;){var M=31-Se(_),P=1<<M;P&g|h[M]&g&&(h[M]|=g),_&=~P}}function cr(h,g){var _=g&-g;return _=(_&42)!==0?1:dr(_),(_&(h.suspendedLanes|g))!==0?0:_}function dr(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 Jn(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function ln(){var h=q.p;return h!==0?h:(h=window.event,h===void 0?32:RU(h.type))}function Gn(h,g){var _=q.p;try{return q.p=h,g()}finally{q.p=_}}var nr=Math.random().toString(36).slice(2),er="__reactFiber$"+nr,bn="__reactProps$"+nr,xi="__reactContainer$"+nr,Ia="__reactEvents$"+nr,Ae="__reactListeners$"+nr,Xe="__reactHandles$"+nr,Je="__reactResources$"+nr,dt="__reactMarker$"+nr;function st(h){delete h[er],delete h[bn],delete h[Ia],delete h[Ae],delete h[Xe]}function jt(h){var g=h[er];if(g)return g;for(var _=h.parentNode;_;){if(g=_[xi]||_[er]){if(_=g.alternate,g.child!==null||_!==null&&_.child!==null)for(h=xU(h);h!==null;){if(_=h[er])return _;h=xU(h)}return g}h=_,_=h.parentNode}return null}function he(h){if(h=h[er]||h[xi]){var g=h.tag;if(g===5||g===6||g===13||g===31||g===26||g===27||g===3)return h}return null}function me(h){var g=h.tag;if(g===5||g===26||g===27||g===6)return h.stateNode;throw Error(r(33))}function Fe(h){var g=h[Je];return g||(g=h[Je]={hoistableStyles:new Map,hoistableScripts:new Map}),g}function Oe(h){h[dt]=!0}var je=new Set,ht={};function Nt(h,g){Ct(h,g),Ct(h+"Capture",g)}function Ct(h,g){for(ht[h]=g,h=0;h<g.length;h++)je.add(g[h])}var At=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Lt={},Rt={};function Mt(h){return re.call(Rt,h)?!0:re.call(Lt,h)?!1:At.test(h)?Rt[h]=!0:(Lt[h]=!0,!1)}function Zt(h,g,_){if(Mt(g))if(_===null)h.removeAttribute(g);else{switch(typeof _){case"undefined":case"function":case"symbol":h.removeAttribute(g);return;case"boolean":var M=g.toLowerCase().slice(0,5);if(M!=="data-"&&M!=="aria-"){h.removeAttribute(g);return}}h.setAttribute(g,""+_)}}function $t(h,g,_){if(_===null)h.removeAttribute(g);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(g);return}h.setAttribute(g,""+_)}}function un(h,g,_,M){if(M===null)h.removeAttribute(_);else{switch(typeof M){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(_);return}h.setAttributeNS(g,_,""+M)}}function _n(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function Mn(h){var g=h.type;return(h=h.nodeName)&&h.toLowerCase()==="input"&&(g==="checkbox"||g==="radio")}function Ht(h,g,_){var M=Object.getOwnPropertyDescriptor(h.constructor.prototype,g);if(!h.hasOwnProperty(g)&&typeof M<"u"&&typeof M.get=="function"&&typeof M.set=="function"){var P=M.get,I=M.set;return Object.defineProperty(h,g,{configurable:!0,get:function(){return P.call(this)},set:function(ee){_=""+ee,I.call(this,ee)}}),Object.defineProperty(h,g,{enumerable:M.enumerable}),{getValue:function(){return _},setValue:function(ee){_=""+ee},stopTracking:function(){h._valueTracker=null,delete h[g]}}}}function Xt(h){if(!h._valueTracker){var g=Mn(h)?"checked":"value";h._valueTracker=Ht(h,g,""+h[g])}}function tn(h){if(!h)return!1;var g=h._valueTracker;if(!g)return!0;var _=g.getValue(),M="";return h&&(M=Mn(h)?h.checked?"true":"false":h.value),h=M,h!==_?(g.setValue(h),!0):!1}function cn(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 Ur=/[\n"\\]/g;function qn(h){return h.replace(Ur,function(g){return"\\"+g.charCodeAt(0).toString(16)+" "})}function Qe(h,g,_,M,P,I,ee,ve){h.name="",ee!=null&&typeof ee!="function"&&typeof ee!="symbol"&&typeof ee!="boolean"?h.type=ee:h.removeAttribute("type"),g!=null?ee==="number"?(g===0&&h.value===""||h.value!=g)&&(h.value=""+_n(g)):h.value!==""+_n(g)&&(h.value=""+_n(g)):ee!=="submit"&&ee!=="reset"||h.removeAttribute("value"),g!=null?qt(h,ee,_n(g)):_!=null?qt(h,ee,_n(_)):M!=null&&h.removeAttribute("value"),P==null&&I!=null&&(h.defaultChecked=!!I),P!=null&&(h.checked=P&&typeof P!="function"&&typeof P!="symbol"),ve!=null&&typeof ve!="function"&&typeof ve!="symbol"&&typeof ve!="boolean"?h.name=""+_n(ve):h.removeAttribute("name")}function Tt(h,g,_,M,P,I,ee,ve){if(I!=null&&typeof I!="function"&&typeof I!="symbol"&&typeof I!="boolean"&&(h.type=I),g!=null||_!=null){if(!(I!=="submit"&&I!=="reset"||g!=null)){Xt(h);return}_=_!=null?""+_n(_):"",g=g!=null?""+_n(g):_,ve||g===h.value||(h.value=g),h.defaultValue=g}M=M??P,M=typeof M!="function"&&typeof M!="symbol"&&!!M,h.checked=ve?h.checked:!!M,h.defaultChecked=!!M,ee!=null&&typeof ee!="function"&&typeof ee!="symbol"&&typeof ee!="boolean"&&(h.name=ee),Xt(h)}function qt(h,g,_){g==="number"&&cn(h.ownerDocument)===h||h.defaultValue===""+_||(h.defaultValue=""+_)}function xt(h,g,_,M){if(h=h.options,g){g={};for(var P=0;P<_.length;P++)g["$"+_[P]]=!0;for(_=0;_<h.length;_++)P=g.hasOwnProperty("$"+h[_].value),h[_].selected!==P&&(h[_].selected=P),P&&M&&(h[_].defaultSelected=!0)}else{for(_=""+_n(_),g=null,P=0;P<h.length;P++){if(h[P].value===_){h[P].selected=!0,M&&(h[P].defaultSelected=!0);return}g!==null||h[P].disabled||(g=h[P])}g!==null&&(g.selected=!0)}}function nn(h,g,_){if(g!=null&&(g=""+_n(g),g!==h.value&&(h.value=g),_==null)){h.defaultValue!==g&&(h.defaultValue=g);return}h.defaultValue=_!=null?""+_n(_):""}function gn(h,g,_,M){if(g==null){if(M!=null){if(_!=null)throw Error(r(92));if(G(M)){if(1<M.length)throw Error(r(93));M=M[0]}_=M}_==null&&(_=""),g=_}_=_n(g),h.defaultValue=_,M=h.textContent,M===_&&M!==""&&M!==null&&(h.value=M),Xt(h)}function tr(h,g){if(g){var _=h.firstChild;if(_&&_===h.lastChild&&_.nodeType===3){_.nodeValue=g;return}}h.textContent=g}var br=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 Fa(h,g,_){var M=g.indexOf("--")===0;_==null||typeof _=="boolean"||_===""?M?h.setProperty(g,""):g==="float"?h.cssFloat="":h[g]="":M?h.setProperty(g,_):typeof _!="number"||_===0||br.has(g)?g==="float"?h.cssFloat=_:h[g]=(""+_).trim():h[g]=_+"px"}function sn(h,g,_){if(g!=null&&typeof g!="object")throw Error(r(62));if(h=h.style,_!=null){for(var M in _)!_.hasOwnProperty(M)||g!=null&&g.hasOwnProperty(M)||(M.indexOf("--")===0?h.setProperty(M,""):M==="float"?h.cssFloat="":h[M]="");for(var P in g)M=g[P],g.hasOwnProperty(P)&&_[P]!==M&&Fa(h,P,M)}else for(var I in g)g.hasOwnProperty(I)&&Fa(h,I,g[I])}function Sn(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 ns=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"]]),So=/^[\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 aa(h){return So.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function rs(){}var fl=null;function is(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var si=null,Ua=null;function $l(h){var g=he(h);if(g&&(h=g.stateNode)){var _=h[bn]||null;e:switch(h=g.stateNode,g.type){case"input":if(Qe(h,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),g=_.name,_.type==="radio"&&g!=null){for(_=h;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+qn(""+g)+'"][type="radio"]'),g=0;g<_.length;g++){var M=_[g];if(M!==h&&M.form===h.form){var P=M[bn]||null;if(!P)throw Error(r(90));Qe(M,P.value,P.defaultValue,P.defaultValue,P.checked,P.defaultChecked,P.type,P.name)}}for(g=0;g<_.length;g++)M=_[g],M.form===h.form&&tn(M)}break e;case"textarea":nn(h,_.value,_.defaultValue);break e;case"select":g=_.value,g!=null&&xt(h,!!_.multiple,g,!1)}}}var Bi=!1;function Ux(h,g,_){if(Bi)return h(g,_);Bi=!0;try{var M=h(g);return M}finally{if(Bi=!1,(si!==null||Ua!==null)&&(l_(),si&&(g=si,h=Ua,Ua=si=null,$l(g),h)))for(g=0;g<h.length;g++)$l(h[g])}}function No(h,g){var _=h.stateNode;if(_===null)return null;var M=_[bn]||null;if(M===null)return null;_=M[g];e:switch(g){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(M=!M.disabled)||(h=h.type,M=!(h==="button"||h==="input"||h==="select"||h==="textarea")),h=!M;break e;default:h=!1}if(h)return null;if(_&&typeof _!="function")throw Error(r(231,g,typeof _));return _}var ml=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),zx=!1;if(ml)try{var Hh={};Object.defineProperty(Hh,"passive",{get:function(){zx=!0}}),window.addEventListener("test",Hh,Hh),window.removeEventListener("test",Hh,Hh)}catch{zx=!1}var Hl=null,Bx=null,Pm=null;function Rm(){if(Pm)return Pm;var h,g=Bx,_=g.length,M,P="value"in Hl?Hl.value:Hl.textContent,I=P.length;for(h=0;h<_&&g[h]===P[h];h++);var ee=_-h;for(M=1;M<=ee&&g[_-M]===P[I-M];M++);return Pm=P.slice(h,1<M?1-M:void 0)}function Vh(h){var g=h.keyCode;return"charCode"in h?(h=h.charCode,h===0&&g===13&&(h=13)):h=g,h===10&&(h=13),32<=h||h===13?h:0}function Yu(){return!0}function Ac(){return!1}function sa(h){function g(_,M,P,I,ee){this._reactName=_,this._targetInst=P,this.type=M,this.nativeEvent=I,this.target=ee,this.currentTarget=null;for(var ve in h)h.hasOwnProperty(ve)&&(_=h[ve],this[ve]=_?_(I):I[ve]);return this.isDefaultPrevented=(I.defaultPrevented!=null?I.defaultPrevented:I.returnValue===!1)?Yu:Ac,this.isPropagationStopped=Ac,this}return f(g.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=Yu)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=Yu)},persist:function(){},isPersistent:Yu}),g}var pl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Vl=sa(pl),gl=f({},pl,{view:0,detail:0}),Dm=sa(gl),Om,Lm,Qu,hn=f({},gl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Vx,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!==Qu&&(Qu&&h.type==="mousemove"?(Om=h.screenX-Qu.screenX,Lm=h.screenY-Qu.screenY):Lm=Om=0,Qu=h),Om)},movementY:function(h){return"movementY"in h?h.movementY:Lm}}),Nv=sa(hn),$x=f({},hn,{dataTransfer:0}),Mv=sa($x),Hx=f({},gl,{relatedTarget:0}),Im=sa(Hx),qM=f({},pl,{animationName:0,elapsedTime:0,pseudoElement:0}),Ev=sa(qM),le=f({},pl,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),_t=sa(le),Dn=f({},pl,{data:0}),Wn=sa(Dn),Mo={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Zu={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"},as={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ss(h){var g=this.nativeEvent;return g.getModifierState?g.getModifierState(h):(h=as[h])?!!g[h]:!1}function Vx(){return ss}var f5=f({},gl,{key:function(h){if(h.key){var g=Mo[h.key]||h.key;if(g!=="Unidentified")return g}return h.type==="keypress"?(h=Vh(h),h===13?"Enter":String.fromCharCode(h)):h.type==="keydown"||h.type==="keyup"?Zu[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Vx,charCode:function(h){return h.type==="keypress"?Vh(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?Vh(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),Kre=sa(f5),Xre=f({},hn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),m5=sa(Xre),Yre=f({},gl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Vx}),Qre=sa(Yre),Zre=f({},pl,{propertyName:0,elapsedTime:0,pseudoElement:0}),Jre=sa(Zre),eie=f({},hn,{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}),tie=sa(eie),nie=f({},pl,{newState:0,oldState:0}),rie=sa(nie),iie=[9,13,27,32],WM=ml&&"CompositionEvent"in window,Gx=null;ml&&"documentMode"in document&&(Gx=document.documentMode);var aie=ml&&"TextEvent"in window&&!Gx,p5=ml&&(!WM||Gx&&8<Gx&&11>=Gx),g5=" ",x5=!1;function b5(h,g){switch(h){case"keyup":return iie.indexOf(g.keyCode)!==-1;case"keydown":return g.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function y5(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var Fm=!1;function sie(h,g){switch(h){case"compositionend":return y5(g);case"keypress":return g.which!==32?null:(x5=!0,g5);case"textInput":return h=g.data,h===g5&&x5?null:h;default:return null}}function oie(h,g){if(Fm)return h==="compositionend"||!WM&&b5(h,g)?(h=Rm(),Pm=Bx=Hl=null,Fm=!1,h):null;switch(h){case"paste":return null;case"keypress":if(!(g.ctrlKey||g.altKey||g.metaKey)||g.ctrlKey&&g.altKey){if(g.char&&1<g.char.length)return g.char;if(g.which)return String.fromCharCode(g.which)}return null;case"compositionend":return p5&&g.locale!=="ko"?null:g.data;default:return null}}var lie={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 v5(h){var g=h&&h.nodeName&&h.nodeName.toLowerCase();return g==="input"?!!lie[h.type]:g==="textarea"}function _5(h,g,_,M){si?Ua?Ua.push(M):Ua=[M]:si=M,g=p_(g,"onChange"),0<g.length&&(_=new Vl("onChange","change",null,_,M),h.push({event:_,listeners:g}))}var qx=null,Wx=null;function cie(h){rU(h,0)}function Cv(h){var g=me(h);if(tn(g))return h}function w5(h,g){if(h==="change")return g}var S5=!1;if(ml){var KM;if(ml){var XM="oninput"in document;if(!XM){var N5=document.createElement("div");N5.setAttribute("oninput","return;"),XM=typeof N5.oninput=="function"}KM=XM}else KM=!1;S5=KM&&(!document.documentMode||9<document.documentMode)}function M5(){qx&&(qx.detachEvent("onpropertychange",E5),Wx=qx=null)}function E5(h){if(h.propertyName==="value"&&Cv(Wx)){var g=[];_5(g,Wx,h,is(h)),Ux(cie,g)}}function uie(h,g,_){h==="focusin"?(M5(),qx=g,Wx=_,qx.attachEvent("onpropertychange",E5)):h==="focusout"&&M5()}function die(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return Cv(Wx)}function hie(h,g){if(h==="click")return Cv(g)}function fie(h,g){if(h==="input"||h==="change")return Cv(g)}function mie(h,g){return h===g&&(h!==0||1/h===1/g)||h!==h&&g!==g}var Xs=typeof Object.is=="function"?Object.is:mie;function Kx(h,g){if(Xs(h,g))return!0;if(typeof h!="object"||h===null||typeof g!="object"||g===null)return!1;var _=Object.keys(h),M=Object.keys(g);if(_.length!==M.length)return!1;for(M=0;M<_.length;M++){var P=_[M];if(!re.call(g,P)||!Xs(h[P],g[P]))return!1}return!0}function C5(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function T5(h,g){var _=C5(h);h=0;for(var M;_;){if(_.nodeType===3){if(M=h+_.textContent.length,h<=g&&M>=g)return{node:_,offset:g-h};h=M}e:{for(;_;){if(_.nextSibling){_=_.nextSibling;break e}_=_.parentNode}_=void 0}_=C5(_)}}function A5(h,g){return h&&g?h===g?!0:h&&h.nodeType===3?!1:g&&g.nodeType===3?A5(h,g.parentNode):"contains"in h?h.contains(g):h.compareDocumentPosition?!!(h.compareDocumentPosition(g)&16):!1:!1}function k5(h){h=h!=null&&h.ownerDocument!=null&&h.ownerDocument.defaultView!=null?h.ownerDocument.defaultView:window;for(var g=cn(h.document);g instanceof h.HTMLIFrameElement;){try{var _=typeof g.contentWindow.location.href=="string"}catch{_=!1}if(_)h=g.contentWindow;else break;g=cn(h.document)}return g}function YM(h){var g=h&&h.nodeName&&h.nodeName.toLowerCase();return g&&(g==="input"&&(h.type==="text"||h.type==="search"||h.type==="tel"||h.type==="url"||h.type==="password")||g==="textarea"||h.contentEditable==="true")}var pie=ml&&"documentMode"in document&&11>=document.documentMode,Um=null,QM=null,Xx=null,ZM=!1;function j5(h,g,_){var M=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;ZM||Um==null||Um!==cn(M)||(M=Um,"selectionStart"in M&&YM(M)?M={start:M.selectionStart,end:M.selectionEnd}:(M=(M.ownerDocument&&M.ownerDocument.defaultView||window).getSelection(),M={anchorNode:M.anchorNode,anchorOffset:M.anchorOffset,focusNode:M.focusNode,focusOffset:M.focusOffset}),Xx&&Kx(Xx,M)||(Xx=M,M=p_(QM,"onSelect"),0<M.length&&(g=new Vl("onSelect","select",null,g,_),h.push({event:g,listeners:M}),g.target=Um)))}function Gh(h,g){var _={};return _[h.toLowerCase()]=g.toLowerCase(),_["Webkit"+h]="webkit"+g,_["Moz"+h]="moz"+g,_}var zm={animationend:Gh("Animation","AnimationEnd"),animationiteration:Gh("Animation","AnimationIteration"),animationstart:Gh("Animation","AnimationStart"),transitionrun:Gh("Transition","TransitionRun"),transitionstart:Gh("Transition","TransitionStart"),transitioncancel:Gh("Transition","TransitionCancel"),transitionend:Gh("Transition","TransitionEnd")},JM={},P5={};ml&&(P5=document.createElement("div").style,"AnimationEvent"in window||(delete zm.animationend.animation,delete zm.animationiteration.animation,delete zm.animationstart.animation),"TransitionEvent"in window||delete zm.transitionend.transition);function qh(h){if(JM[h])return JM[h];if(!zm[h])return h;var g=zm[h],_;for(_ in g)if(g.hasOwnProperty(_)&&_ in P5)return JM[h]=g[_];return h}var R5=qh("animationend"),D5=qh("animationiteration"),O5=qh("animationstart"),gie=qh("transitionrun"),xie=qh("transitionstart"),bie=qh("transitioncancel"),L5=qh("transitionend"),I5=new Map,eE="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(" ");eE.push("scrollEnd");function xl(h,g){I5.set(h,g),Nt(g,[h])}var Tv=typeof reportError=="function"?reportError:function(h){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var g=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(g))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",h);return}console.error(h)},Eo=[],Bm=0,tE=0;function Av(){for(var h=Bm,g=tE=Bm=0;g<h;){var _=Eo[g];Eo[g++]=null;var M=Eo[g];Eo[g++]=null;var P=Eo[g];Eo[g++]=null;var I=Eo[g];if(Eo[g++]=null,M!==null&&P!==null){var ee=M.pending;ee===null?P.next=P:(P.next=ee.next,ee.next=P),M.pending=P}I!==0&&F5(_,P,I)}}function kv(h,g,_,M){Eo[Bm++]=h,Eo[Bm++]=g,Eo[Bm++]=_,Eo[Bm++]=M,tE|=M,h.lanes|=M,h=h.alternate,h!==null&&(h.lanes|=M)}function nE(h,g,_,M){return kv(h,g,_,M),jv(h)}function Wh(h,g){return kv(h,null,null,g),jv(h)}function F5(h,g,_){h.lanes|=_;var M=h.alternate;M!==null&&(M.lanes|=_);for(var P=!1,I=h.return;I!==null;)I.childLanes|=_,M=I.alternate,M!==null&&(M.childLanes|=_),I.tag===22&&(h=I.stateNode,h===null||h._visibility&1||(P=!0)),h=I,I=I.return;return h.tag===3?(I=h.stateNode,P&&g!==null&&(P=31-Se(_),h=I.hiddenUpdates,M=h[P],M===null?h[P]=[g]:M.push(g),g.lane=_|536870912),I):null}function jv(h){if(50<xb)throw xb=0,dC=null,Error(r(185));for(var g=h.return;g!==null;)h=g,g=h.return;return h.tag===3?h.stateNode:null}var $m={};function yie(h,g,_,M){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=g,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=M,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ys(h,g,_,M){return new yie(h,g,_,M)}function rE(h){return h=h.prototype,!(!h||!h.isReactComponent)}function kc(h,g){var _=h.alternate;return _===null?(_=Ys(h.tag,g,h.key,h.mode),_.elementType=h.elementType,_.type=h.type,_.stateNode=h.stateNode,_.alternate=h,h.alternate=_):(_.pendingProps=g,_.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,g=h.dependencies,_.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext},_.sibling=h.sibling,_.index=h.index,_.ref=h.ref,_.refCleanup=h.refCleanup,_}function U5(h,g){h.flags&=65011714;var _=h.alternate;return _===null?(h.childLanes=0,h.lanes=g,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,g=_.dependencies,h.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext}),h}function Pv(h,g,_,M,P,I){var ee=0;if(M=h,typeof h=="function")rE(h)&&(ee=1);else if(typeof h=="string")ee=Nae(h,_,ne.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case A:return h=Ys(31,_,g,P),h.elementType=A,h.lanes=I,h;case b:return Kh(_.children,P,I,g);case y:ee=8,P|=24;break;case v:return h=Ys(12,_,g,P|2),h.elementType=v,h.lanes=I,h;case T:return h=Ys(13,_,g,P),h.elementType=T,h.lanes=I,h;case k:return h=Ys(19,_,g,P),h.elementType=k,h.lanes=I,h;default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case N:ee=10;break e;case S:ee=9;break e;case C:ee=11;break e;case E:ee=14;break e;case D:ee=16,M=null;break e}ee=29,_=Error(r(130,h===null?"null":typeof h,"")),M=null}return g=Ys(ee,_,g,P),g.elementType=h,g.type=M,g.lanes=I,g}function Kh(h,g,_,M){return h=Ys(7,h,M,g),h.lanes=_,h}function iE(h,g,_){return h=Ys(6,h,null,g),h.lanes=_,h}function z5(h){var g=Ys(18,null,null,0);return g.stateNode=h,g}function aE(h,g,_){return g=Ys(4,h.children!==null?h.children:[],h.key,g),g.lanes=_,g.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},g}var B5=new WeakMap;function Co(h,g){if(typeof h=="object"&&h!==null){var _=B5.get(h);return _!==void 0?_:(g={value:h,source:g,stack:z(g)},B5.set(h,g),g)}return{value:h,source:g,stack:z(g)}}var Hm=[],Vm=0,Rv=null,Yx=0,To=[],Ao=0,Ju=null,Gl=1,ql="";function jc(h,g){Hm[Vm++]=Yx,Hm[Vm++]=Rv,Rv=h,Yx=g}function $5(h,g,_){To[Ao++]=Gl,To[Ao++]=ql,To[Ao++]=Ju,Ju=h;var M=Gl;h=ql;var P=32-Se(M)-1;M&=~(1<<P),_+=1;var I=32-Se(g)+P;if(30<I){var ee=P-P%5;I=(M&(1<<ee)-1).toString(32),M>>=ee,P-=ee,Gl=1<<32-Se(g)+P|_<<P|M,ql=I+h}else Gl=1<<I|_<<P|M,ql=h}function sE(h){h.return!==null&&(jc(h,1),$5(h,1,0))}function oE(h){for(;h===Rv;)Rv=Hm[--Vm],Hm[Vm]=null,Yx=Hm[--Vm],Hm[Vm]=null;for(;h===Ju;)Ju=To[--Ao],To[Ao]=null,ql=To[--Ao],To[Ao]=null,Gl=To[--Ao],To[Ao]=null}function H5(h,g){To[Ao++]=Gl,To[Ao++]=ql,To[Ao++]=Ju,Gl=g.id,ql=g.overflow,Ju=h}var _a=null,zr=null,Kn=!1,ed=null,ko=!1,lE=Error(r(519));function td(h){var g=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Qx(Co(g,h)),lE}function V5(h){var g=h.stateNode,_=h.type,M=h.memoizedProps;switch(g[er]=h,g[bn]=M,_){case"dialog":Fn("cancel",g),Fn("close",g);break;case"iframe":case"object":case"embed":Fn("load",g);break;case"video":case"audio":for(_=0;_<yb.length;_++)Fn(yb[_],g);break;case"source":Fn("error",g);break;case"img":case"image":case"link":Fn("error",g),Fn("load",g);break;case"details":Fn("toggle",g);break;case"input":Fn("invalid",g),Tt(g,M.value,M.defaultValue,M.checked,M.defaultChecked,M.type,M.name,!0);break;case"select":Fn("invalid",g);break;case"textarea":Fn("invalid",g),gn(g,M.value,M.defaultValue,M.children)}_=M.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||g.textContent===""+_||M.suppressHydrationWarning===!0||oU(g.textContent,_)?(M.popover!=null&&(Fn("beforetoggle",g),Fn("toggle",g)),M.onScroll!=null&&Fn("scroll",g),M.onScrollEnd!=null&&Fn("scrollend",g),M.onClick!=null&&(g.onclick=rs),g=!0):g=!1,g||td(h,!0)}function G5(h){for(_a=h.return;_a;)switch(_a.tag){case 5:case 31:case 13:ko=!1;return;case 27:case 3:ko=!0;return;default:_a=_a.return}}function Gm(h){if(h!==_a)return!1;if(!Kn)return G5(h),Kn=!0,!1;var g=h.tag,_;if((_=g!==3&&g!==27)&&((_=g===5)&&(_=h.type,_=!(_!=="form"&&_!=="button")||EC(h.type,h.memoizedProps)),_=!_),_&&zr&&td(h),G5(h),g===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));zr=gU(h)}else if(g===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));zr=gU(h)}else g===27?(g=zr,pd(h.type)?(h=jC,jC=null,zr=h):zr=g):zr=_a?Po(h.stateNode.nextSibling):null;return!0}function Xh(){zr=_a=null,Kn=!1}function cE(){var h=ed;return h!==null&&(ks===null?ks=h:ks.push.apply(ks,h),ed=null),h}function Qx(h){ed===null?ed=[h]:ed.push(h)}var uE=B(null),Yh=null,Pc=null;function nd(h,g,_){se(uE,g._currentValue),g._currentValue=_}function Rc(h){h._currentValue=uE.current,W(uE)}function dE(h,g,_){for(;h!==null;){var M=h.alternate;if((h.childLanes&g)!==g?(h.childLanes|=g,M!==null&&(M.childLanes|=g)):M!==null&&(M.childLanes&g)!==g&&(M.childLanes|=g),h===_)break;h=h.return}}function hE(h,g,_,M){var P=h.child;for(P!==null&&(P.return=h);P!==null;){var I=P.dependencies;if(I!==null){var ee=P.child;I=I.firstContext;e:for(;I!==null;){var ve=I;I=P;for(var ze=0;ze<g.length;ze++)if(ve.context===g[ze]){I.lanes|=_,ve=I.alternate,ve!==null&&(ve.lanes|=_),dE(I.return,_,h),M||(ee=null);break e}I=ve.next}}else if(P.tag===18){if(ee=P.return,ee===null)throw Error(r(341));ee.lanes|=_,I=ee.alternate,I!==null&&(I.lanes|=_),dE(ee,_,h),ee=null}else ee=P.child;if(ee!==null)ee.return=P;else for(ee=P;ee!==null;){if(ee===h){ee=null;break}if(P=ee.sibling,P!==null){P.return=ee.return,ee=P;break}ee=ee.return}P=ee}}function qm(h,g,_,M){h=null;for(var P=g,I=!1;P!==null;){if(!I){if((P.flags&524288)!==0)I=!0;else if((P.flags&262144)!==0)break}if(P.tag===10){var ee=P.alternate;if(ee===null)throw Error(r(387));if(ee=ee.memoizedProps,ee!==null){var ve=P.type;Xs(P.pendingProps.value,ee.value)||(h!==null?h.push(ve):h=[ve])}}else if(P===ye.current){if(ee=P.alternate,ee===null)throw Error(r(387));ee.memoizedState.memoizedState!==P.memoizedState.memoizedState&&(h!==null?h.push(Nb):h=[Nb])}P=P.return}h!==null&&hE(g,h,_,M),g.flags|=262144}function Dv(h){for(h=h.firstContext;h!==null;){if(!Xs(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function Qh(h){Yh=h,Pc=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function wa(h){return q5(Yh,h)}function Ov(h,g){return Yh===null&&Qh(h),q5(h,g)}function q5(h,g){var _=g._currentValue;if(g={context:g,memoizedValue:_,next:null},Pc===null){if(h===null)throw Error(r(308));Pc=g,h.dependencies={lanes:0,firstContext:g},h.flags|=524288}else Pc=Pc.next=g;return _}var vie=typeof AbortController<"u"?AbortController:function(){var h=[],g=this.signal={aborted:!1,addEventListener:function(_,M){h.push(M)}};this.abort=function(){g.aborted=!0,h.forEach(function(_){return _()})}},_ie=t.unstable_scheduleCallback,wie=t.unstable_NormalPriority,Ni={$$typeof:N,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function fE(){return{controller:new vie,data:new Map,refCount:0}}function Zx(h){h.refCount--,h.refCount===0&&_ie(wie,function(){h.controller.abort()})}var Jx=null,mE=0,Wm=0,Km=null;function Sie(h,g){if(Jx===null){var _=Jx=[];mE=0,Wm=xC(),Km={status:"pending",value:void 0,then:function(M){_.push(M)}}}return mE++,g.then(W5,W5),g}function W5(){if(--mE===0&&Jx!==null){Km!==null&&(Km.status="fulfilled");var h=Jx;Jx=null,Wm=0,Km=null;for(var g=0;g<h.length;g++)(0,h[g])()}}function Nie(h,g){var _=[],M={status:"pending",value:null,reason:null,then:function(P){_.push(P)}};return h.then(function(){M.status="fulfilled",M.value=g;for(var P=0;P<_.length;P++)(0,_[P])(g)},function(P){for(M.status="rejected",M.reason=P,P=0;P<_.length;P++)(0,_[P])(void 0)}),M}var K5=$.S;$.S=function(h,g){jF=L(),typeof g=="object"&&g!==null&&typeof g.then=="function"&&Sie(h,g),K5!==null&&K5(h,g)};var Zh=B(null);function pE(){var h=Zh.current;return h!==null?h:jr.pooledCache}function Lv(h,g){g===null?se(Zh,Zh.current):se(Zh,g.pool)}function X5(){var h=pE();return h===null?null:{parent:Ni._currentValue,pool:h}}var Xm=Error(r(460)),gE=Error(r(474)),Iv=Error(r(542)),Fv={then:function(){}};function Y5(h){return h=h.status,h==="fulfilled"||h==="rejected"}function Q5(h,g,_){switch(_=h[_],_===void 0?h.push(g):_!==g&&(g.then(rs,rs),g=_),g.status){case"fulfilled":return g.value;case"rejected":throw h=g.reason,J5(h),h;default:if(typeof g.status=="string")g.then(rs,rs);else{if(h=jr,h!==null&&100<h.shellSuspendCounter)throw Error(r(482));h=g,h.status="pending",h.then(function(M){if(g.status==="pending"){var P=g;P.status="fulfilled",P.value=M}},function(M){if(g.status==="pending"){var P=g;P.status="rejected",P.reason=M}})}switch(g.status){case"fulfilled":return g.value;case"rejected":throw h=g.reason,J5(h),h}throw ef=g,Xm}}function Jh(h){try{var g=h._init;return g(h._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(ef=_,Xm):_}}var ef=null;function Z5(){if(ef===null)throw Error(r(459));var h=ef;return ef=null,h}function J5(h){if(h===Xm||h===Iv)throw Error(r(483))}var Ym=null,eb=0;function Uv(h){var g=eb;return eb+=1,Ym===null&&(Ym=[]),Q5(Ym,h,g)}function tb(h,g){g=g.props.ref,h.ref=g!==void 0?g:null}function zv(h,g){throw g.$$typeof===m?Error(r(525)):(h=Object.prototype.toString.call(g),Error(r(31,h==="[object Object]"?"object with keys {"+Object.keys(g).join(", ")+"}":h)))}function eI(h){function g(Ye,Ge){if(h){var nt=Ye.deletions;nt===null?(Ye.deletions=[Ge],Ye.flags|=16):nt.push(Ge)}}function _(Ye,Ge){if(!h)return null;for(;Ge!==null;)g(Ye,Ge),Ge=Ge.sibling;return null}function M(Ye){for(var Ge=new Map;Ye!==null;)Ye.key!==null?Ge.set(Ye.key,Ye):Ge.set(Ye.index,Ye),Ye=Ye.sibling;return Ge}function P(Ye,Ge){return Ye=kc(Ye,Ge),Ye.index=0,Ye.sibling=null,Ye}function I(Ye,Ge,nt){return Ye.index=nt,h?(nt=Ye.alternate,nt!==null?(nt=nt.index,nt<Ge?(Ye.flags|=67108866,Ge):nt):(Ye.flags|=67108866,Ge)):(Ye.flags|=1048576,Ge)}function ee(Ye){return h&&Ye.alternate===null&&(Ye.flags|=67108866),Ye}function ve(Ye,Ge,nt,bt){return Ge===null||Ge.tag!==6?(Ge=iE(nt,Ye.mode,bt),Ge.return=Ye,Ge):(Ge=P(Ge,nt),Ge.return=Ye,Ge)}function ze(Ye,Ge,nt,bt){var Yt=nt.type;return Yt===b?gt(Ye,Ge,nt.props.children,bt,nt.key):Ge!==null&&(Ge.elementType===Yt||typeof Yt=="object"&&Yt!==null&&Yt.$$typeof===D&&Jh(Yt)===Ge.type)?(Ge=P(Ge,nt.props),tb(Ge,nt),Ge.return=Ye,Ge):(Ge=Pv(nt.type,nt.key,nt.props,null,Ye.mode,bt),tb(Ge,nt),Ge.return=Ye,Ge)}function rt(Ye,Ge,nt,bt){return Ge===null||Ge.tag!==4||Ge.stateNode.containerInfo!==nt.containerInfo||Ge.stateNode.implementation!==nt.implementation?(Ge=aE(nt,Ye.mode,bt),Ge.return=Ye,Ge):(Ge=P(Ge,nt.children||[]),Ge.return=Ye,Ge)}function gt(Ye,Ge,nt,bt,Yt){return Ge===null||Ge.tag!==7?(Ge=Kh(nt,Ye.mode,bt,Yt),Ge.return=Ye,Ge):(Ge=P(Ge,nt),Ge.return=Ye,Ge)}function vt(Ye,Ge,nt){if(typeof Ge=="string"&&Ge!==""||typeof Ge=="number"||typeof Ge=="bigint")return Ge=iE(""+Ge,Ye.mode,nt),Ge.return=Ye,Ge;if(typeof Ge=="object"&&Ge!==null){switch(Ge.$$typeof){case p:return nt=Pv(Ge.type,Ge.key,Ge.props,null,Ye.mode,nt),tb(nt,Ge),nt.return=Ye,nt;case x:return Ge=aE(Ge,Ye.mode,nt),Ge.return=Ye,Ge;case D:return Ge=Jh(Ge),vt(Ye,Ge,nt)}if(G(Ge)||O(Ge))return Ge=Kh(Ge,Ye.mode,nt,null),Ge.return=Ye,Ge;if(typeof Ge.then=="function")return vt(Ye,Uv(Ge),nt);if(Ge.$$typeof===N)return vt(Ye,Ov(Ye,Ge),nt);zv(Ye,Ge)}return null}function ot(Ye,Ge,nt,bt){var Yt=Ge!==null?Ge.key:null;if(typeof nt=="string"&&nt!==""||typeof nt=="number"||typeof nt=="bigint")return Yt!==null?null:ve(Ye,Ge,""+nt,bt);if(typeof nt=="object"&&nt!==null){switch(nt.$$typeof){case p:return nt.key===Yt?ze(Ye,Ge,nt,bt):null;case x:return nt.key===Yt?rt(Ye,Ge,nt,bt):null;case D:return nt=Jh(nt),ot(Ye,Ge,nt,bt)}if(G(nt)||O(nt))return Yt!==null?null:gt(Ye,Ge,nt,bt,null);if(typeof nt.then=="function")return ot(Ye,Ge,Uv(nt),bt);if(nt.$$typeof===N)return ot(Ye,Ge,Ov(Ye,nt),bt);zv(Ye,nt)}return null}function pt(Ye,Ge,nt,bt,Yt){if(typeof bt=="string"&&bt!==""||typeof bt=="number"||typeof bt=="bigint")return Ye=Ye.get(nt)||null,ve(Ge,Ye,""+bt,Yt);if(typeof bt=="object"&&bt!==null){switch(bt.$$typeof){case p:return Ye=Ye.get(bt.key===null?nt:bt.key)||null,ze(Ge,Ye,bt,Yt);case x:return Ye=Ye.get(bt.key===null?nt:bt.key)||null,rt(Ge,Ye,bt,Yt);case D:return bt=Jh(bt),pt(Ye,Ge,nt,bt,Yt)}if(G(bt)||O(bt))return Ye=Ye.get(nt)||null,gt(Ge,Ye,bt,Yt,null);if(typeof bt.then=="function")return pt(Ye,Ge,nt,Uv(bt),Yt);if(bt.$$typeof===N)return pt(Ye,Ge,nt,Ov(Ge,bt),Yt);zv(Ge,bt)}return null}function Gt(Ye,Ge,nt,bt){for(var Yt=null,rr=null,Wt=Ge,Nn=Ge=0,$n=null;Wt!==null&&Nn<nt.length;Nn++){Wt.index>Nn?($n=Wt,Wt=null):$n=Wt.sibling;var ir=ot(Ye,Wt,nt[Nn],bt);if(ir===null){Wt===null&&(Wt=$n);break}h&&Wt&&ir.alternate===null&&g(Ye,Wt),Ge=I(ir,Ge,Nn),rr===null?Yt=ir:rr.sibling=ir,rr=ir,Wt=$n}if(Nn===nt.length)return _(Ye,Wt),Kn&&jc(Ye,Nn),Yt;if(Wt===null){for(;Nn<nt.length;Nn++)Wt=vt(Ye,nt[Nn],bt),Wt!==null&&(Ge=I(Wt,Ge,Nn),rr===null?Yt=Wt:rr.sibling=Wt,rr=Wt);return Kn&&jc(Ye,Nn),Yt}for(Wt=M(Wt);Nn<nt.length;Nn++)$n=pt(Wt,Ye,Nn,nt[Nn],bt),$n!==null&&(h&&$n.alternate!==null&&Wt.delete($n.key===null?Nn:$n.key),Ge=I($n,Ge,Nn),rr===null?Yt=$n:rr.sibling=$n,rr=$n);return h&&Wt.forEach(function(vd){return g(Ye,vd)}),Kn&&jc(Ye,Nn),Yt}function rn(Ye,Ge,nt,bt){if(nt==null)throw Error(r(151));for(var Yt=null,rr=null,Wt=Ge,Nn=Ge=0,$n=null,ir=nt.next();Wt!==null&&!ir.done;Nn++,ir=nt.next()){Wt.index>Nn?($n=Wt,Wt=null):$n=Wt.sibling;var vd=ot(Ye,Wt,ir.value,bt);if(vd===null){Wt===null&&(Wt=$n);break}h&&Wt&&vd.alternate===null&&g(Ye,Wt),Ge=I(vd,Ge,Nn),rr===null?Yt=vd:rr.sibling=vd,rr=vd,Wt=$n}if(ir.done)return _(Ye,Wt),Kn&&jc(Ye,Nn),Yt;if(Wt===null){for(;!ir.done;Nn++,ir=nt.next())ir=vt(Ye,ir.value,bt),ir!==null&&(Ge=I(ir,Ge,Nn),rr===null?Yt=ir:rr.sibling=ir,rr=ir);return Kn&&jc(Ye,Nn),Yt}for(Wt=M(Wt);!ir.done;Nn++,ir=nt.next())ir=pt(Wt,Ye,Nn,ir.value,bt),ir!==null&&(h&&ir.alternate!==null&&Wt.delete(ir.key===null?Nn:ir.key),Ge=I(ir,Ge,Nn),rr===null?Yt=ir:rr.sibling=ir,rr=ir);return h&&Wt.forEach(function(Oae){return g(Ye,Oae)}),Kn&&jc(Ye,Nn),Yt}function _r(Ye,Ge,nt,bt){if(typeof nt=="object"&&nt!==null&&nt.type===b&&nt.key===null&&(nt=nt.props.children),typeof nt=="object"&&nt!==null){switch(nt.$$typeof){case p:e:{for(var Yt=nt.key;Ge!==null;){if(Ge.key===Yt){if(Yt=nt.type,Yt===b){if(Ge.tag===7){_(Ye,Ge.sibling),bt=P(Ge,nt.props.children),bt.return=Ye,Ye=bt;break e}}else if(Ge.elementType===Yt||typeof Yt=="object"&&Yt!==null&&Yt.$$typeof===D&&Jh(Yt)===Ge.type){_(Ye,Ge.sibling),bt=P(Ge,nt.props),tb(bt,nt),bt.return=Ye,Ye=bt;break e}_(Ye,Ge);break}else g(Ye,Ge);Ge=Ge.sibling}nt.type===b?(bt=Kh(nt.props.children,Ye.mode,bt,nt.key),bt.return=Ye,Ye=bt):(bt=Pv(nt.type,nt.key,nt.props,null,Ye.mode,bt),tb(bt,nt),bt.return=Ye,Ye=bt)}return ee(Ye);case x:e:{for(Yt=nt.key;Ge!==null;){if(Ge.key===Yt)if(Ge.tag===4&&Ge.stateNode.containerInfo===nt.containerInfo&&Ge.stateNode.implementation===nt.implementation){_(Ye,Ge.sibling),bt=P(Ge,nt.children||[]),bt.return=Ye,Ye=bt;break e}else{_(Ye,Ge);break}else g(Ye,Ge);Ge=Ge.sibling}bt=aE(nt,Ye.mode,bt),bt.return=Ye,Ye=bt}return ee(Ye);case D:return nt=Jh(nt),_r(Ye,Ge,nt,bt)}if(G(nt))return Gt(Ye,Ge,nt,bt);if(O(nt)){if(Yt=O(nt),typeof Yt!="function")throw Error(r(150));return nt=Yt.call(nt),rn(Ye,Ge,nt,bt)}if(typeof nt.then=="function")return _r(Ye,Ge,Uv(nt),bt);if(nt.$$typeof===N)return _r(Ye,Ge,Ov(Ye,nt),bt);zv(Ye,nt)}return typeof nt=="string"&&nt!==""||typeof nt=="number"||typeof nt=="bigint"?(nt=""+nt,Ge!==null&&Ge.tag===6?(_(Ye,Ge.sibling),bt=P(Ge,nt),bt.return=Ye,Ye=bt):(_(Ye,Ge),bt=iE(nt,Ye.mode,bt),bt.return=Ye,Ye=bt),ee(Ye)):_(Ye,Ge)}return function(Ye,Ge,nt,bt){try{eb=0;var Yt=_r(Ye,Ge,nt,bt);return Ym=null,Yt}catch(Wt){if(Wt===Xm||Wt===Iv)throw Wt;var rr=Ys(29,Wt,null,Ye.mode);return rr.lanes=bt,rr.return=Ye,rr}finally{}}}var tf=eI(!0),tI=eI(!1),rd=!1;function xE(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function bE(h,g){h=h.updateQueue,g.updateQueue===h&&(g.updateQueue={baseState:h.baseState,firstBaseUpdate:h.firstBaseUpdate,lastBaseUpdate:h.lastBaseUpdate,shared:h.shared,callbacks:null})}function id(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function ad(h,g,_){var M=h.updateQueue;if(M===null)return null;if(M=M.shared,(or&2)!==0){var P=M.pending;return P===null?g.next=g:(g.next=P.next,P.next=g),M.pending=g,g=jv(h),F5(h,null,_),g}return kv(h,M,g,_),jv(h)}function nb(h,g,_){if(g=g.updateQueue,g!==null&&(g=g.shared,(_&4194048)!==0)){var M=g.lanes;M&=h.pendingLanes,_|=M,g.lanes=_,Kt(h,_)}}function yE(h,g){var _=h.updateQueue,M=h.alternate;if(M!==null&&(M=M.updateQueue,_===M)){var P=null,I=null;if(_=_.firstBaseUpdate,_!==null){do{var ee={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};I===null?P=I=ee:I=I.next=ee,_=_.next}while(_!==null);I===null?P=I=g:I=I.next=g}else P=I=g;_={baseState:M.baseState,firstBaseUpdate:P,lastBaseUpdate:I,shared:M.shared,callbacks:M.callbacks},h.updateQueue=_;return}h=_.lastBaseUpdate,h===null?_.firstBaseUpdate=g:h.next=g,_.lastBaseUpdate=g}var vE=!1;function rb(){if(vE){var h=Km;if(h!==null)throw h}}function ib(h,g,_,M){vE=!1;var P=h.updateQueue;rd=!1;var I=P.firstBaseUpdate,ee=P.lastBaseUpdate,ve=P.shared.pending;if(ve!==null){P.shared.pending=null;var ze=ve,rt=ze.next;ze.next=null,ee===null?I=rt:ee.next=rt,ee=ze;var gt=h.alternate;gt!==null&&(gt=gt.updateQueue,ve=gt.lastBaseUpdate,ve!==ee&&(ve===null?gt.firstBaseUpdate=rt:ve.next=rt,gt.lastBaseUpdate=ze))}if(I!==null){var vt=P.baseState;ee=0,gt=rt=ze=null,ve=I;do{var ot=ve.lane&-536870913,pt=ot!==ve.lane;if(pt?(Bn&ot)===ot:(M&ot)===ot){ot!==0&&ot===Wm&&(vE=!0),gt!==null&&(gt=gt.next={lane:0,tag:ve.tag,payload:ve.payload,callback:null,next:null});e:{var Gt=h,rn=ve;ot=g;var _r=_;switch(rn.tag){case 1:if(Gt=rn.payload,typeof Gt=="function"){vt=Gt.call(_r,vt,ot);break e}vt=Gt;break e;case 3:Gt.flags=Gt.flags&-65537|128;case 0:if(Gt=rn.payload,ot=typeof Gt=="function"?Gt.call(_r,vt,ot):Gt,ot==null)break e;vt=f({},vt,ot);break e;case 2:rd=!0}}ot=ve.callback,ot!==null&&(h.flags|=64,pt&&(h.flags|=8192),pt=P.callbacks,pt===null?P.callbacks=[ot]:pt.push(ot))}else pt={lane:ot,tag:ve.tag,payload:ve.payload,callback:ve.callback,next:null},gt===null?(rt=gt=pt,ze=vt):gt=gt.next=pt,ee|=ot;if(ve=ve.next,ve===null){if(ve=P.shared.pending,ve===null)break;pt=ve,ve=pt.next,pt.next=null,P.lastBaseUpdate=pt,P.shared.pending=null}}while(!0);gt===null&&(ze=vt),P.baseState=ze,P.firstBaseUpdate=rt,P.lastBaseUpdate=gt,I===null&&(P.shared.lanes=0),ud|=ee,h.lanes=ee,h.memoizedState=vt}}function nI(h,g){if(typeof h!="function")throw Error(r(191,h));h.call(g)}function rI(h,g){var _=h.callbacks;if(_!==null)for(h.callbacks=null,h=0;h<_.length;h++)nI(_[h],g)}var Qm=B(null),Bv=B(0);function iI(h,g){h=$c,se(Bv,h),se(Qm,g),$c=h|g.baseLanes}function _E(){se(Bv,$c),se(Qm,Qm.current)}function wE(){$c=Bv.current,W(Qm),W(Bv)}var Qs=B(null),jo=null;function sd(h){var g=h.alternate;se(bi,bi.current&1),se(Qs,h),jo===null&&(g===null||Qm.current!==null||g.memoizedState!==null)&&(jo=h)}function SE(h){se(bi,bi.current),se(Qs,h),jo===null&&(jo=h)}function aI(h){h.tag===22?(se(bi,bi.current),se(Qs,h),jo===null&&(jo=h)):od()}function od(){se(bi,bi.current),se(Qs,Qs.current)}function Zs(h){W(Qs),jo===h&&(jo=null),W(bi)}var bi=B(0);function $v(h){for(var g=h;g!==null;){if(g.tag===13){var _=g.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||AC(_)||kC(_)))return g}else if(g.tag===19&&(g.memoizedProps.revealOrder==="forwards"||g.memoizedProps.revealOrder==="backwards"||g.memoizedProps.revealOrder==="unstable_legacy-backwards"||g.memoizedProps.revealOrder==="together")){if((g.flags&128)!==0)return g}else if(g.child!==null){g.child.return=g,g=g.child;continue}if(g===h)break;for(;g.sibling===null;){if(g.return===null||g.return===h)return null;g=g.return}g.sibling.return=g.return,g=g.sibling}return null}var Dc=0,wn=null,yr=null,Mi=null,Hv=!1,Zm=!1,nf=!1,Vv=0,ab=0,Jm=null,Mie=0;function oi(){throw Error(r(321))}function NE(h,g){if(g===null)return!1;for(var _=0;_<g.length&&_<h.length;_++)if(!Xs(h[_],g[_]))return!1;return!0}function ME(h,g,_,M,P,I){return Dc=I,wn=g,g.memoizedState=null,g.updateQueue=null,g.lanes=0,$.H=h===null||h.memoizedState===null?$I:zE,nf=!1,I=_(M,P),nf=!1,Zm&&(I=oI(g,_,M,P)),sI(h),I}function sI(h){$.H=lb;var g=yr!==null&&yr.next!==null;if(Dc=0,Mi=yr=wn=null,Hv=!1,ab=0,Jm=null,g)throw Error(r(300));h===null||Ei||(h=h.dependencies,h!==null&&Dv(h)&&(Ei=!0))}function oI(h,g,_,M){wn=h;var P=0;do{if(Zm&&(Jm=null),ab=0,Zm=!1,25<=P)throw Error(r(301));if(P+=1,Mi=yr=null,h.updateQueue!=null){var I=h.updateQueue;I.lastEffect=null,I.events=null,I.stores=null,I.memoCache!=null&&(I.memoCache.index=0)}$.H=HI,I=g(_,M)}while(Zm);return I}function Eie(){var h=$.H,g=h.useState()[0];return g=typeof g.then=="function"?sb(g):g,h=h.useState()[0],(yr!==null?yr.memoizedState:null)!==h&&(wn.flags|=1024),g}function EE(){var h=Vv!==0;return Vv=0,h}function CE(h,g,_){g.updateQueue=h.updateQueue,g.flags&=-2053,h.lanes&=~_}function TE(h){if(Hv){for(h=h.memoizedState;h!==null;){var g=h.queue;g!==null&&(g.pending=null),h=h.next}Hv=!1}Dc=0,Mi=yr=wn=null,Zm=!1,ab=Vv=0,Jm=null}function ls(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Mi===null?wn.memoizedState=Mi=h:Mi=Mi.next=h,Mi}function yi(){if(yr===null){var h=wn.alternate;h=h!==null?h.memoizedState:null}else h=yr.next;var g=Mi===null?wn.memoizedState:Mi.next;if(g!==null)Mi=g,yr=h;else{if(h===null)throw wn.alternate===null?Error(r(467)):Error(r(310));yr=h,h={memoizedState:yr.memoizedState,baseState:yr.baseState,baseQueue:yr.baseQueue,queue:yr.queue,next:null},Mi===null?wn.memoizedState=Mi=h:Mi=Mi.next=h}return Mi}function Gv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function sb(h){var g=ab;return ab+=1,Jm===null&&(Jm=[]),h=Q5(Jm,h,g),g=wn,(Mi===null?g.memoizedState:Mi.next)===null&&(g=g.alternate,$.H=g===null||g.memoizedState===null?$I:zE),h}function qv(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return sb(h);if(h.$$typeof===N)return wa(h)}throw Error(r(438,String(h)))}function AE(h){var g=null,_=wn.updateQueue;if(_!==null&&(g=_.memoCache),g==null){var M=wn.alternate;M!==null&&(M=M.updateQueue,M!==null&&(M=M.memoCache,M!=null&&(g={data:M.data.map(function(P){return P.slice()}),index:0})))}if(g==null&&(g={data:[],index:0}),_===null&&(_=Gv(),wn.updateQueue=_),_.memoCache=g,_=g.data[g.index],_===void 0)for(_=g.data[g.index]=Array(h),M=0;M<h;M++)_[M]=R;return g.index++,_}function Oc(h,g){return typeof g=="function"?g(h):g}function Wv(h){var g=yi();return kE(g,yr,h)}function kE(h,g,_){var M=h.queue;if(M===null)throw Error(r(311));M.lastRenderedReducer=_;var P=h.baseQueue,I=M.pending;if(I!==null){if(P!==null){var ee=P.next;P.next=I.next,I.next=ee}g.baseQueue=P=I,M.pending=null}if(I=h.baseState,P===null)h.memoizedState=I;else{g=P.next;var ve=ee=null,ze=null,rt=g,gt=!1;do{var vt=rt.lane&-536870913;if(vt!==rt.lane?(Bn&vt)===vt:(Dc&vt)===vt){var ot=rt.revertLane;if(ot===0)ze!==null&&(ze=ze.next={lane:0,revertLane:0,gesture:null,action:rt.action,hasEagerState:rt.hasEagerState,eagerState:rt.eagerState,next:null}),vt===Wm&&(gt=!0);else if((Dc&ot)===ot){rt=rt.next,ot===Wm&&(gt=!0);continue}else vt={lane:0,revertLane:rt.revertLane,gesture:null,action:rt.action,hasEagerState:rt.hasEagerState,eagerState:rt.eagerState,next:null},ze===null?(ve=ze=vt,ee=I):ze=ze.next=vt,wn.lanes|=ot,ud|=ot;vt=rt.action,nf&&_(I,vt),I=rt.hasEagerState?rt.eagerState:_(I,vt)}else ot={lane:vt,revertLane:rt.revertLane,gesture:rt.gesture,action:rt.action,hasEagerState:rt.hasEagerState,eagerState:rt.eagerState,next:null},ze===null?(ve=ze=ot,ee=I):ze=ze.next=ot,wn.lanes|=vt,ud|=vt;rt=rt.next}while(rt!==null&&rt!==g);if(ze===null?ee=I:ze.next=ve,!Xs(I,h.memoizedState)&&(Ei=!0,gt&&(_=Km,_!==null)))throw _;h.memoizedState=I,h.baseState=ee,h.baseQueue=ze,M.lastRenderedState=I}return P===null&&(M.lanes=0),[h.memoizedState,M.dispatch]}function jE(h){var g=yi(),_=g.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=h;var M=_.dispatch,P=_.pending,I=g.memoizedState;if(P!==null){_.pending=null;var ee=P=P.next;do I=h(I,ee.action),ee=ee.next;while(ee!==P);Xs(I,g.memoizedState)||(Ei=!0),g.memoizedState=I,g.baseQueue===null&&(g.baseState=I),_.lastRenderedState=I}return[I,M]}function lI(h,g,_){var M=wn,P=yi(),I=Kn;if(I){if(_===void 0)throw Error(r(407));_=_()}else _=g();var ee=!Xs((yr||P).memoizedState,_);if(ee&&(P.memoizedState=_,Ei=!0),P=P.queue,DE(dI.bind(null,M,P,h),[h]),P.getSnapshot!==g||ee||Mi!==null&&Mi.memoizedState.tag&1){if(M.flags|=2048,ep(9,{destroy:void 0},uI.bind(null,M,P,_,g),null),jr===null)throw Error(r(349));I||(Dc&127)!==0||cI(M,g,_)}return _}function cI(h,g,_){h.flags|=16384,h={getSnapshot:g,value:_},g=wn.updateQueue,g===null?(g=Gv(),wn.updateQueue=g,g.stores=[h]):(_=g.stores,_===null?g.stores=[h]:_.push(h))}function uI(h,g,_,M){g.value=_,g.getSnapshot=M,hI(g)&&fI(h)}function dI(h,g,_){return _(function(){hI(g)&&fI(h)})}function hI(h){var g=h.getSnapshot;h=h.value;try{var _=g();return!Xs(h,_)}catch{return!0}}function fI(h){var g=Wh(h,2);g!==null&&js(g,h,2)}function PE(h){var g=ls();if(typeof h=="function"){var _=h;if(h=_(),nf){He(!0);try{_()}finally{He(!1)}}}return g.memoizedState=g.baseState=h,g.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Oc,lastRenderedState:h},g}function mI(h,g,_,M){return h.baseState=_,kE(h,yr,typeof M=="function"?M:Oc)}function Cie(h,g,_,M,P){if(Yv(h))throw Error(r(485));if(h=g.action,h!==null){var I={payload:P,action:h,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(ee){I.listeners.push(ee)}};$.T!==null?_(!0):I.isTransition=!1,M(I),_=g.pending,_===null?(I.next=g.pending=I,pI(g,I)):(I.next=_.next,g.pending=_.next=I)}}function pI(h,g){var _=g.action,M=g.payload,P=h.state;if(g.isTransition){var I=$.T,ee={};$.T=ee;try{var ve=_(P,M),ze=$.S;ze!==null&&ze(ee,ve),gI(h,g,ve)}catch(rt){RE(h,g,rt)}finally{I!==null&&ee.types!==null&&(I.types=ee.types),$.T=I}}else try{I=_(P,M),gI(h,g,I)}catch(rt){RE(h,g,rt)}}function gI(h,g,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(M){xI(h,g,M)},function(M){return RE(h,g,M)}):xI(h,g,_)}function xI(h,g,_){g.status="fulfilled",g.value=_,bI(g),h.state=_,g=h.pending,g!==null&&(_=g.next,_===g?h.pending=null:(_=_.next,g.next=_,pI(h,_)))}function RE(h,g,_){var M=h.pending;if(h.pending=null,M!==null){M=M.next;do g.status="rejected",g.reason=_,bI(g),g=g.next;while(g!==M)}h.action=null}function bI(h){h=h.listeners;for(var g=0;g<h.length;g++)(0,h[g])()}function yI(h,g){return g}function vI(h,g){if(Kn){var _=jr.formState;if(_!==null){e:{var M=wn;if(Kn){if(zr){t:{for(var P=zr,I=ko;P.nodeType!==8;){if(!I){P=null;break t}if(P=Po(P.nextSibling),P===null){P=null;break t}}I=P.data,P=I==="F!"||I==="F"?P:null}if(P){zr=Po(P.nextSibling),M=P.data==="F!";break e}}td(M)}M=!1}M&&(g=_[0])}}return _=ls(),_.memoizedState=_.baseState=g,M={pending:null,lanes:0,dispatch:null,lastRenderedReducer:yI,lastRenderedState:g},_.queue=M,_=UI.bind(null,wn,M),M.dispatch=_,M=PE(!1),I=UE.bind(null,wn,!1,M.queue),M=ls(),P={state:g,dispatch:null,action:h,pending:null},M.queue=P,_=Cie.bind(null,wn,P,I,_),P.dispatch=_,M.memoizedState=h,[g,_,!1]}function _I(h){var g=yi();return wI(g,yr,h)}function wI(h,g,_){if(g=kE(h,g,yI)[0],h=Wv(Oc)[0],typeof g=="object"&&g!==null&&typeof g.then=="function")try{var M=sb(g)}catch(ee){throw ee===Xm?Iv:ee}else M=g;g=yi();var P=g.queue,I=P.dispatch;return _!==g.memoizedState&&(wn.flags|=2048,ep(9,{destroy:void 0},Tie.bind(null,P,_),null)),[M,I,h]}function Tie(h,g){h.action=g}function SI(h){var g=yi(),_=yr;if(_!==null)return wI(g,_,h);yi(),g=g.memoizedState,_=yi();var M=_.queue.dispatch;return _.memoizedState=h,[g,M,!1]}function ep(h,g,_,M){return h={tag:h,create:_,deps:M,inst:g,next:null},g=wn.updateQueue,g===null&&(g=Gv(),wn.updateQueue=g),_=g.lastEffect,_===null?g.lastEffect=h.next=h:(M=_.next,_.next=h,h.next=M,g.lastEffect=h),h}function NI(){return yi().memoizedState}function Kv(h,g,_,M){var P=ls();wn.flags|=h,P.memoizedState=ep(1|g,{destroy:void 0},_,M===void 0?null:M)}function Xv(h,g,_,M){var P=yi();M=M===void 0?null:M;var I=P.memoizedState.inst;yr!==null&&M!==null&&NE(M,yr.memoizedState.deps)?P.memoizedState=ep(g,I,_,M):(wn.flags|=h,P.memoizedState=ep(1|g,I,_,M))}function MI(h,g){Kv(8390656,8,h,g)}function DE(h,g){Xv(2048,8,h,g)}function Aie(h){wn.flags|=4;var g=wn.updateQueue;if(g===null)g=Gv(),wn.updateQueue=g,g.events=[h];else{var _=g.events;_===null?g.events=[h]:_.push(h)}}function EI(h){var g=yi().memoizedState;return Aie({ref:g,nextImpl:h}),function(){if((or&2)!==0)throw Error(r(440));return g.impl.apply(void 0,arguments)}}function CI(h,g){return Xv(4,2,h,g)}function TI(h,g){return Xv(4,4,h,g)}function AI(h,g){if(typeof g=="function"){h=h();var _=g(h);return function(){typeof _=="function"?_():g(null)}}if(g!=null)return h=h(),g.current=h,function(){g.current=null}}function kI(h,g,_){_=_!=null?_.concat([h]):null,Xv(4,4,AI.bind(null,g,h),_)}function OE(){}function jI(h,g){var _=yi();g=g===void 0?null:g;var M=_.memoizedState;return g!==null&&NE(g,M[1])?M[0]:(_.memoizedState=[h,g],h)}function PI(h,g){var _=yi();g=g===void 0?null:g;var M=_.memoizedState;if(g!==null&&NE(g,M[1]))return M[0];if(M=h(),nf){He(!0);try{h()}finally{He(!1)}}return _.memoizedState=[M,g],M}function LE(h,g,_){return _===void 0||(Dc&1073741824)!==0&&(Bn&261930)===0?h.memoizedState=g:(h.memoizedState=_,h=RF(),wn.lanes|=h,ud|=h,_)}function RI(h,g,_,M){return Xs(_,g)?_:Qm.current!==null?(h=LE(h,_,M),Xs(h,g)||(Ei=!0),h):(Dc&42)===0||(Dc&1073741824)!==0&&(Bn&261930)===0?(Ei=!0,h.memoizedState=_):(h=RF(),wn.lanes|=h,ud|=h,g)}function DI(h,g,_,M,P){var I=q.p;q.p=I!==0&&8>I?I:8;var ee=$.T,ve={};$.T=ve,UE(h,!1,g,_);try{var ze=P(),rt=$.S;if(rt!==null&&rt(ve,ze),ze!==null&&typeof ze=="object"&&typeof ze.then=="function"){var gt=Nie(ze,M);ob(h,g,gt,to(h))}else ob(h,g,M,to(h))}catch(vt){ob(h,g,{then:function(){},status:"rejected",reason:vt},to())}finally{q.p=I,ee!==null&&ve.types!==null&&(ee.types=ve.types),$.T=ee}}function kie(){}function IE(h,g,_,M){if(h.tag!==5)throw Error(r(476));var P=OI(h).queue;DI(h,P,g,Y,_===null?kie:function(){return LI(h),_(M)})}function OI(h){var g=h.memoizedState;if(g!==null)return g;g={memoizedState:Y,baseState:Y,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Oc,lastRenderedState:Y},next:null};var _={};return g.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Oc,lastRenderedState:_},next:null},h.memoizedState=g,h=h.alternate,h!==null&&(h.memoizedState=g),g}function LI(h){var g=OI(h);g.next===null&&(g=h.alternate.memoizedState),ob(h,g.next.queue,{},to())}function FE(){return wa(Nb)}function II(){return yi().memoizedState}function FI(){return yi().memoizedState}function jie(h){for(var g=h.return;g!==null;){switch(g.tag){case 24:case 3:var _=to();h=id(_);var M=ad(g,h,_);M!==null&&(js(M,g,_),nb(M,g,_)),g={cache:fE()},h.payload=g;return}g=g.return}}function Pie(h,g,_){var M=to();_={lane:M,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},Yv(h)?zI(g,_):(_=nE(h,g,_,M),_!==null&&(js(_,h,M),BI(_,g,M)))}function UI(h,g,_){var M=to();ob(h,g,_,M)}function ob(h,g,_,M){var P={lane:M,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(Yv(h))zI(g,P);else{var I=h.alternate;if(h.lanes===0&&(I===null||I.lanes===0)&&(I=g.lastRenderedReducer,I!==null))try{var ee=g.lastRenderedState,ve=I(ee,_);if(P.hasEagerState=!0,P.eagerState=ve,Xs(ve,ee))return kv(h,g,P,0),jr===null&&Av(),!1}catch{}finally{}if(_=nE(h,g,P,M),_!==null)return js(_,h,M),BI(_,g,M),!0}return!1}function UE(h,g,_,M){if(M={lane:2,revertLane:xC(),gesture:null,action:M,hasEagerState:!1,eagerState:null,next:null},Yv(h)){if(g)throw Error(r(479))}else g=nE(h,_,M,2),g!==null&&js(g,h,2)}function Yv(h){var g=h.alternate;return h===wn||g!==null&&g===wn}function zI(h,g){Zm=Hv=!0;var _=h.pending;_===null?g.next=g:(g.next=_.next,_.next=g),h.pending=g}function BI(h,g,_){if((_&4194048)!==0){var M=g.lanes;M&=h.pendingLanes,_|=M,g.lanes=_,Kt(h,_)}}var lb={readContext:wa,use:qv,useCallback:oi,useContext:oi,useEffect:oi,useImperativeHandle:oi,useLayoutEffect:oi,useInsertionEffect:oi,useMemo:oi,useReducer:oi,useRef:oi,useState:oi,useDebugValue:oi,useDeferredValue:oi,useTransition:oi,useSyncExternalStore:oi,useId:oi,useHostTransitionStatus:oi,useFormState:oi,useActionState:oi,useOptimistic:oi,useMemoCache:oi,useCacheRefresh:oi};lb.useEffectEvent=oi;var $I={readContext:wa,use:qv,useCallback:function(h,g){return ls().memoizedState=[h,g===void 0?null:g],h},useContext:wa,useEffect:MI,useImperativeHandle:function(h,g,_){_=_!=null?_.concat([h]):null,Kv(4194308,4,AI.bind(null,g,h),_)},useLayoutEffect:function(h,g){return Kv(4194308,4,h,g)},useInsertionEffect:function(h,g){Kv(4,2,h,g)},useMemo:function(h,g){var _=ls();g=g===void 0?null:g;var M=h();if(nf){He(!0);try{h()}finally{He(!1)}}return _.memoizedState=[M,g],M},useReducer:function(h,g,_){var M=ls();if(_!==void 0){var P=_(g);if(nf){He(!0);try{_(g)}finally{He(!1)}}}else P=g;return M.memoizedState=M.baseState=P,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:h,lastRenderedState:P},M.queue=h,h=h.dispatch=Pie.bind(null,wn,h),[M.memoizedState,h]},useRef:function(h){var g=ls();return h={current:h},g.memoizedState=h},useState:function(h){h=PE(h);var g=h.queue,_=UI.bind(null,wn,g);return g.dispatch=_,[h.memoizedState,_]},useDebugValue:OE,useDeferredValue:function(h,g){var _=ls();return LE(_,h,g)},useTransition:function(){var h=PE(!1);return h=DI.bind(null,wn,h.queue,!0,!1),ls().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,g,_){var M=wn,P=ls();if(Kn){if(_===void 0)throw Error(r(407));_=_()}else{if(_=g(),jr===null)throw Error(r(349));(Bn&127)!==0||cI(M,g,_)}P.memoizedState=_;var I={value:_,getSnapshot:g};return P.queue=I,MI(dI.bind(null,M,I,h),[h]),M.flags|=2048,ep(9,{destroy:void 0},uI.bind(null,M,I,_,g),null),_},useId:function(){var h=ls(),g=jr.identifierPrefix;if(Kn){var _=ql,M=Gl;_=(M&~(1<<32-Se(M)-1)).toString(32)+_,g="_"+g+"R_"+_,_=Vv++,0<_&&(g+="H"+_.toString(32)),g+="_"}else _=Mie++,g="_"+g+"r_"+_.toString(32)+"_";return h.memoizedState=g},useHostTransitionStatus:FE,useFormState:vI,useActionState:vI,useOptimistic:function(h){var g=ls();g.memoizedState=g.baseState=h;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return g.queue=_,g=UE.bind(null,wn,!0,_),_.dispatch=g,[h,g]},useMemoCache:AE,useCacheRefresh:function(){return ls().memoizedState=jie.bind(null,wn)},useEffectEvent:function(h){var g=ls(),_={impl:h};return g.memoizedState=_,function(){if((or&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},zE={readContext:wa,use:qv,useCallback:jI,useContext:wa,useEffect:DE,useImperativeHandle:kI,useInsertionEffect:CI,useLayoutEffect:TI,useMemo:PI,useReducer:Wv,useRef:NI,useState:function(){return Wv(Oc)},useDebugValue:OE,useDeferredValue:function(h,g){var _=yi();return RI(_,yr.memoizedState,h,g)},useTransition:function(){var h=Wv(Oc)[0],g=yi().memoizedState;return[typeof h=="boolean"?h:sb(h),g]},useSyncExternalStore:lI,useId:II,useHostTransitionStatus:FE,useFormState:_I,useActionState:_I,useOptimistic:function(h,g){var _=yi();return mI(_,yr,h,g)},useMemoCache:AE,useCacheRefresh:FI};zE.useEffectEvent=EI;var HI={readContext:wa,use:qv,useCallback:jI,useContext:wa,useEffect:DE,useImperativeHandle:kI,useInsertionEffect:CI,useLayoutEffect:TI,useMemo:PI,useReducer:jE,useRef:NI,useState:function(){return jE(Oc)},useDebugValue:OE,useDeferredValue:function(h,g){var _=yi();return yr===null?LE(_,h,g):RI(_,yr.memoizedState,h,g)},useTransition:function(){var h=jE(Oc)[0],g=yi().memoizedState;return[typeof h=="boolean"?h:sb(h),g]},useSyncExternalStore:lI,useId:II,useHostTransitionStatus:FE,useFormState:SI,useActionState:SI,useOptimistic:function(h,g){var _=yi();return yr!==null?mI(_,yr,h,g):(_.baseState=h,[h,_.queue.dispatch])},useMemoCache:AE,useCacheRefresh:FI};HI.useEffectEvent=EI;function BE(h,g,_,M){g=h.memoizedState,_=_(M,g),_=_==null?g:f({},g,_),h.memoizedState=_,h.lanes===0&&(h.updateQueue.baseState=_)}var $E={enqueueSetState:function(h,g,_){h=h._reactInternals;var M=to(),P=id(M);P.payload=g,_!=null&&(P.callback=_),g=ad(h,P,M),g!==null&&(js(g,h,M),nb(g,h,M))},enqueueReplaceState:function(h,g,_){h=h._reactInternals;var M=to(),P=id(M);P.tag=1,P.payload=g,_!=null&&(P.callback=_),g=ad(h,P,M),g!==null&&(js(g,h,M),nb(g,h,M))},enqueueForceUpdate:function(h,g){h=h._reactInternals;var _=to(),M=id(_);M.tag=2,g!=null&&(M.callback=g),g=ad(h,M,_),g!==null&&(js(g,h,_),nb(g,h,_))}};function VI(h,g,_,M,P,I,ee){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(M,I,ee):g.prototype&&g.prototype.isPureReactComponent?!Kx(_,M)||!Kx(P,I):!0}function GI(h,g,_,M){h=g.state,typeof g.componentWillReceiveProps=="function"&&g.componentWillReceiveProps(_,M),typeof g.UNSAFE_componentWillReceiveProps=="function"&&g.UNSAFE_componentWillReceiveProps(_,M),g.state!==h&&$E.enqueueReplaceState(g,g.state,null)}function rf(h,g){var _=g;if("ref"in g){_={};for(var M in g)M!=="ref"&&(_[M]=g[M])}if(h=h.defaultProps){_===g&&(_=f({},_));for(var P in h)_[P]===void 0&&(_[P]=h[P])}return _}function qI(h){Tv(h)}function WI(h){console.error(h)}function KI(h){Tv(h)}function Qv(h,g){try{var _=h.onUncaughtError;_(g.value,{componentStack:g.stack})}catch(M){setTimeout(function(){throw M})}}function XI(h,g,_){try{var M=h.onCaughtError;M(_.value,{componentStack:_.stack,errorBoundary:g.tag===1?g.stateNode:null})}catch(P){setTimeout(function(){throw P})}}function HE(h,g,_){return _=id(_),_.tag=3,_.payload={element:null},_.callback=function(){Qv(h,g)},_}function YI(h){return h=id(h),h.tag=3,h}function QI(h,g,_,M){var P=_.type.getDerivedStateFromError;if(typeof P=="function"){var I=M.value;h.payload=function(){return P(I)},h.callback=function(){XI(g,_,M)}}var ee=_.stateNode;ee!==null&&typeof ee.componentDidCatch=="function"&&(h.callback=function(){XI(g,_,M),typeof P!="function"&&(dd===null?dd=new Set([this]):dd.add(this));var ve=M.stack;this.componentDidCatch(M.value,{componentStack:ve!==null?ve:""})})}function Rie(h,g,_,M,P){if(_.flags|=32768,M!==null&&typeof M=="object"&&typeof M.then=="function"){if(g=_.alternate,g!==null&&qm(g,_,P,!0),_=Qs.current,_!==null){switch(_.tag){case 31:case 13:return jo===null?c_():_.alternate===null&&li===0&&(li=3),_.flags&=-257,_.flags|=65536,_.lanes=P,M===Fv?_.flags|=16384:(g=_.updateQueue,g===null?_.updateQueue=new Set([M]):g.add(M),mC(h,M,P)),!1;case 22:return _.flags|=65536,M===Fv?_.flags|=16384:(g=_.updateQueue,g===null?(g={transitions:null,markerInstances:null,retryQueue:new Set([M])},_.updateQueue=g):(_=g.retryQueue,_===null?g.retryQueue=new Set([M]):_.add(M)),mC(h,M,P)),!1}throw Error(r(435,_.tag))}return mC(h,M,P),c_(),!1}if(Kn)return g=Qs.current,g!==null?((g.flags&65536)===0&&(g.flags|=256),g.flags|=65536,g.lanes=P,M!==lE&&(h=Error(r(422),{cause:M}),Qx(Co(h,_)))):(M!==lE&&(g=Error(r(423),{cause:M}),Qx(Co(g,_))),h=h.current.alternate,h.flags|=65536,P&=-P,h.lanes|=P,M=Co(M,_),P=HE(h.stateNode,M,P),yE(h,P),li!==4&&(li=2)),!1;var I=Error(r(520),{cause:M});if(I=Co(I,_),gb===null?gb=[I]:gb.push(I),li!==4&&(li=2),g===null)return!0;M=Co(M,_),_=g;do{switch(_.tag){case 3:return _.flags|=65536,h=P&-P,_.lanes|=h,h=HE(_.stateNode,M,h),yE(_,h),!1;case 1:if(g=_.type,I=_.stateNode,(_.flags&128)===0&&(typeof g.getDerivedStateFromError=="function"||I!==null&&typeof I.componentDidCatch=="function"&&(dd===null||!dd.has(I))))return _.flags|=65536,P&=-P,_.lanes|=P,P=YI(P),QI(P,h,_,M),yE(_,P),!1}_=_.return}while(_!==null);return!1}var VE=Error(r(461)),Ei=!1;function Sa(h,g,_,M){g.child=h===null?tI(g,null,_,M):tf(g,h.child,_,M)}function ZI(h,g,_,M,P){_=_.render;var I=g.ref;if("ref"in M){var ee={};for(var ve in M)ve!=="ref"&&(ee[ve]=M[ve])}else ee=M;return Qh(g),M=ME(h,g,_,ee,I,P),ve=EE(),h!==null&&!Ei?(CE(h,g,P),Lc(h,g,P)):(Kn&&ve&&sE(g),g.flags|=1,Sa(h,g,M,P),g.child)}function JI(h,g,_,M,P){if(h===null){var I=_.type;return typeof I=="function"&&!rE(I)&&I.defaultProps===void 0&&_.compare===null?(g.tag=15,g.type=I,eF(h,g,I,M,P)):(h=Pv(_.type,null,M,g,g.mode,P),h.ref=g.ref,h.return=g,g.child=h)}if(I=h.child,!ZE(h,P)){var ee=I.memoizedProps;if(_=_.compare,_=_!==null?_:Kx,_(ee,M)&&h.ref===g.ref)return Lc(h,g,P)}return g.flags|=1,h=kc(I,M),h.ref=g.ref,h.return=g,g.child=h}function eF(h,g,_,M,P){if(h!==null){var I=h.memoizedProps;if(Kx(I,M)&&h.ref===g.ref)if(Ei=!1,g.pendingProps=M=I,ZE(h,P))(h.flags&131072)!==0&&(Ei=!0);else return g.lanes=h.lanes,Lc(h,g,P)}return GE(h,g,_,M,P)}function tF(h,g,_,M){var P=M.children,I=h!==null?h.memoizedState:null;if(h===null&&g.stateNode===null&&(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),M.mode==="hidden"){if((g.flags&128)!==0){if(I=I!==null?I.baseLanes|_:_,h!==null){for(M=g.child=h.child,P=0;M!==null;)P=P|M.lanes|M.childLanes,M=M.sibling;M=P&~I}else M=0,g.child=null;return nF(h,g,I,_,M)}if((_&536870912)!==0)g.memoizedState={baseLanes:0,cachePool:null},h!==null&&Lv(g,I!==null?I.cachePool:null),I!==null?iI(g,I):_E(),aI(g);else return M=g.lanes=536870912,nF(h,g,I!==null?I.baseLanes|_:_,_,M)}else I!==null?(Lv(g,I.cachePool),iI(g,I),od(),g.memoizedState=null):(h!==null&&Lv(g,null),_E(),od());return Sa(h,g,P,_),g.child}function cb(h,g){return h!==null&&h.tag===22||g.stateNode!==null||(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.sibling}function nF(h,g,_,M,P){var I=pE();return I=I===null?null:{parent:Ni._currentValue,pool:I},g.memoizedState={baseLanes:_,cachePool:I},h!==null&&Lv(g,null),_E(),aI(g),h!==null&&qm(h,g,M,!0),g.childLanes=P,null}function Zv(h,g){return g=e_({mode:g.mode,children:g.children},h.mode),g.ref=h.ref,h.child=g,g.return=h,g}function rF(h,g,_){return tf(g,h.child,null,_),h=Zv(g,g.pendingProps),h.flags|=2,Zs(g),g.memoizedState=null,h}function Die(h,g,_){var M=g.pendingProps,P=(g.flags&128)!==0;if(g.flags&=-129,h===null){if(Kn){if(M.mode==="hidden")return h=Zv(g,M),g.lanes=536870912,cb(null,h);if(SE(g),(h=zr)?(h=pU(h,ko),h=h!==null&&h.data==="&"?h:null,h!==null&&(g.memoizedState={dehydrated:h,treeContext:Ju!==null?{id:Gl,overflow:ql}:null,retryLane:536870912,hydrationErrors:null},_=z5(h),_.return=g,g.child=_,_a=g,zr=null)):h=null,h===null)throw td(g);return g.lanes=536870912,null}return Zv(g,M)}var I=h.memoizedState;if(I!==null){var ee=I.dehydrated;if(SE(g),P)if(g.flags&256)g.flags&=-257,g=rF(h,g,_);else if(g.memoizedState!==null)g.child=h.child,g.flags|=128,g=null;else throw Error(r(558));else if(Ei||qm(h,g,_,!1),P=(_&h.childLanes)!==0,Ei||P){if(M=jr,M!==null&&(ee=cr(M,_),ee!==0&&ee!==I.retryLane))throw I.retryLane=ee,Wh(h,ee),js(M,h,ee),VE;c_(),g=rF(h,g,_)}else h=I.treeContext,zr=Po(ee.nextSibling),_a=g,Kn=!0,ed=null,ko=!1,h!==null&&H5(g,h),g=Zv(g,M),g.flags|=4096;return g}return h=kc(h.child,{mode:M.mode,children:M.children}),h.ref=g.ref,g.child=h,h.return=g,h}function Jv(h,g){var _=g.ref;if(_===null)h!==null&&h.ref!==null&&(g.flags|=4194816);else{if(typeof _!="function"&&typeof _!="object")throw Error(r(284));(h===null||h.ref!==_)&&(g.flags|=4194816)}}function GE(h,g,_,M,P){return Qh(g),_=ME(h,g,_,M,void 0,P),M=EE(),h!==null&&!Ei?(CE(h,g,P),Lc(h,g,P)):(Kn&&M&&sE(g),g.flags|=1,Sa(h,g,_,P),g.child)}function iF(h,g,_,M,P,I){return Qh(g),g.updateQueue=null,_=oI(g,M,_,P),sI(h),M=EE(),h!==null&&!Ei?(CE(h,g,I),Lc(h,g,I)):(Kn&&M&&sE(g),g.flags|=1,Sa(h,g,_,I),g.child)}function aF(h,g,_,M,P){if(Qh(g),g.stateNode===null){var I=$m,ee=_.contextType;typeof ee=="object"&&ee!==null&&(I=wa(ee)),I=new _(M,I),g.memoizedState=I.state!==null&&I.state!==void 0?I.state:null,I.updater=$E,g.stateNode=I,I._reactInternals=g,I=g.stateNode,I.props=M,I.state=g.memoizedState,I.refs={},xE(g),ee=_.contextType,I.context=typeof ee=="object"&&ee!==null?wa(ee):$m,I.state=g.memoizedState,ee=_.getDerivedStateFromProps,typeof ee=="function"&&(BE(g,_,ee,M),I.state=g.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof I.getSnapshotBeforeUpdate=="function"||typeof I.UNSAFE_componentWillMount!="function"&&typeof I.componentWillMount!="function"||(ee=I.state,typeof I.componentWillMount=="function"&&I.componentWillMount(),typeof I.UNSAFE_componentWillMount=="function"&&I.UNSAFE_componentWillMount(),ee!==I.state&&$E.enqueueReplaceState(I,I.state,null),ib(g,M,I,P),rb(),I.state=g.memoizedState),typeof I.componentDidMount=="function"&&(g.flags|=4194308),M=!0}else if(h===null){I=g.stateNode;var ve=g.memoizedProps,ze=rf(_,ve);I.props=ze;var rt=I.context,gt=_.contextType;ee=$m,typeof gt=="object"&&gt!==null&&(ee=wa(gt));var vt=_.getDerivedStateFromProps;gt=typeof vt=="function"||typeof I.getSnapshotBeforeUpdate=="function",ve=g.pendingProps!==ve,gt||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(ve||rt!==ee)&&GI(g,I,M,ee),rd=!1;var ot=g.memoizedState;I.state=ot,ib(g,M,I,P),rb(),rt=g.memoizedState,ve||ot!==rt||rd?(typeof vt=="function"&&(BE(g,_,vt,M),rt=g.memoizedState),(ze=rd||VI(g,_,ze,M,ot,rt,ee))?(gt||typeof I.UNSAFE_componentWillMount!="function"&&typeof I.componentWillMount!="function"||(typeof I.componentWillMount=="function"&&I.componentWillMount(),typeof I.UNSAFE_componentWillMount=="function"&&I.UNSAFE_componentWillMount()),typeof I.componentDidMount=="function"&&(g.flags|=4194308)):(typeof I.componentDidMount=="function"&&(g.flags|=4194308),g.memoizedProps=M,g.memoizedState=rt),I.props=M,I.state=rt,I.context=ee,M=ze):(typeof I.componentDidMount=="function"&&(g.flags|=4194308),M=!1)}else{I=g.stateNode,bE(h,g),ee=g.memoizedProps,gt=rf(_,ee),I.props=gt,vt=g.pendingProps,ot=I.context,rt=_.contextType,ze=$m,typeof rt=="object"&&rt!==null&&(ze=wa(rt)),ve=_.getDerivedStateFromProps,(rt=typeof ve=="function"||typeof I.getSnapshotBeforeUpdate=="function")||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(ee!==vt||ot!==ze)&&GI(g,I,M,ze),rd=!1,ot=g.memoizedState,I.state=ot,ib(g,M,I,P),rb();var pt=g.memoizedState;ee!==vt||ot!==pt||rd||h!==null&&h.dependencies!==null&&Dv(h.dependencies)?(typeof ve=="function"&&(BE(g,_,ve,M),pt=g.memoizedState),(gt=rd||VI(g,_,gt,M,ot,pt,ze)||h!==null&&h.dependencies!==null&&Dv(h.dependencies))?(rt||typeof I.UNSAFE_componentWillUpdate!="function"&&typeof I.componentWillUpdate!="function"||(typeof I.componentWillUpdate=="function"&&I.componentWillUpdate(M,pt,ze),typeof I.UNSAFE_componentWillUpdate=="function"&&I.UNSAFE_componentWillUpdate(M,pt,ze)),typeof I.componentDidUpdate=="function"&&(g.flags|=4),typeof I.getSnapshotBeforeUpdate=="function"&&(g.flags|=1024)):(typeof I.componentDidUpdate!="function"||ee===h.memoizedProps&&ot===h.memoizedState||(g.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||ee===h.memoizedProps&&ot===h.memoizedState||(g.flags|=1024),g.memoizedProps=M,g.memoizedState=pt),I.props=M,I.state=pt,I.context=ze,M=gt):(typeof I.componentDidUpdate!="function"||ee===h.memoizedProps&&ot===h.memoizedState||(g.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||ee===h.memoizedProps&&ot===h.memoizedState||(g.flags|=1024),M=!1)}return I=M,Jv(h,g),M=(g.flags&128)!==0,I||M?(I=g.stateNode,_=M&&typeof _.getDerivedStateFromError!="function"?null:I.render(),g.flags|=1,h!==null&&M?(g.child=tf(g,h.child,null,P),g.child=tf(g,null,_,P)):Sa(h,g,_,P),g.memoizedState=I.state,h=g.child):h=Lc(h,g,P),h}function sF(h,g,_,M){return Xh(),g.flags|=256,Sa(h,g,_,M),g.child}var qE={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function WE(h){return{baseLanes:h,cachePool:X5()}}function KE(h,g,_){return h=h!==null?h.childLanes&~_:0,g&&(h|=eo),h}function oF(h,g,_){var M=g.pendingProps,P=!1,I=(g.flags&128)!==0,ee;if((ee=I)||(ee=h!==null&&h.memoizedState===null?!1:(bi.current&2)!==0),ee&&(P=!0,g.flags&=-129),ee=(g.flags&32)!==0,g.flags&=-33,h===null){if(Kn){if(P?sd(g):od(),(h=zr)?(h=pU(h,ko),h=h!==null&&h.data!=="&"?h:null,h!==null&&(g.memoizedState={dehydrated:h,treeContext:Ju!==null?{id:Gl,overflow:ql}:null,retryLane:536870912,hydrationErrors:null},_=z5(h),_.return=g,g.child=_,_a=g,zr=null)):h=null,h===null)throw td(g);return kC(h)?g.lanes=32:g.lanes=536870912,null}var ve=M.children;return M=M.fallback,P?(od(),P=g.mode,ve=e_({mode:"hidden",children:ve},P),M=Kh(M,P,_,null),ve.return=g,M.return=g,ve.sibling=M,g.child=ve,M=g.child,M.memoizedState=WE(_),M.childLanes=KE(h,ee,_),g.memoizedState=qE,cb(null,M)):(sd(g),XE(g,ve))}var ze=h.memoizedState;if(ze!==null&&(ve=ze.dehydrated,ve!==null)){if(I)g.flags&256?(sd(g),g.flags&=-257,g=YE(h,g,_)):g.memoizedState!==null?(od(),g.child=h.child,g.flags|=128,g=null):(od(),ve=M.fallback,P=g.mode,M=e_({mode:"visible",children:M.children},P),ve=Kh(ve,P,_,null),ve.flags|=2,M.return=g,ve.return=g,M.sibling=ve,g.child=M,tf(g,h.child,null,_),M=g.child,M.memoizedState=WE(_),M.childLanes=KE(h,ee,_),g.memoizedState=qE,g=cb(null,M));else if(sd(g),kC(ve)){if(ee=ve.nextSibling&&ve.nextSibling.dataset,ee)var rt=ee.dgst;ee=rt,M=Error(r(419)),M.stack="",M.digest=ee,Qx({value:M,source:null,stack:null}),g=YE(h,g,_)}else if(Ei||qm(h,g,_,!1),ee=(_&h.childLanes)!==0,Ei||ee){if(ee=jr,ee!==null&&(M=cr(ee,_),M!==0&&M!==ze.retryLane))throw ze.retryLane=M,Wh(h,M),js(ee,h,M),VE;AC(ve)||c_(),g=YE(h,g,_)}else AC(ve)?(g.flags|=192,g.child=h.child,g=null):(h=ze.treeContext,zr=Po(ve.nextSibling),_a=g,Kn=!0,ed=null,ko=!1,h!==null&&H5(g,h),g=XE(g,M.children),g.flags|=4096);return g}return P?(od(),ve=M.fallback,P=g.mode,ze=h.child,rt=ze.sibling,M=kc(ze,{mode:"hidden",children:M.children}),M.subtreeFlags=ze.subtreeFlags&65011712,rt!==null?ve=kc(rt,ve):(ve=Kh(ve,P,_,null),ve.flags|=2),ve.return=g,M.return=g,M.sibling=ve,g.child=M,cb(null,M),M=g.child,ve=h.child.memoizedState,ve===null?ve=WE(_):(P=ve.cachePool,P!==null?(ze=Ni._currentValue,P=P.parent!==ze?{parent:ze,pool:ze}:P):P=X5(),ve={baseLanes:ve.baseLanes|_,cachePool:P}),M.memoizedState=ve,M.childLanes=KE(h,ee,_),g.memoizedState=qE,cb(h.child,M)):(sd(g),_=h.child,h=_.sibling,_=kc(_,{mode:"visible",children:M.children}),_.return=g,_.sibling=null,h!==null&&(ee=g.deletions,ee===null?(g.deletions=[h],g.flags|=16):ee.push(h)),g.child=_,g.memoizedState=null,_)}function XE(h,g){return g=e_({mode:"visible",children:g},h.mode),g.return=h,h.child=g}function e_(h,g){return h=Ys(22,h,null,g),h.lanes=0,h}function YE(h,g,_){return tf(g,h.child,null,_),h=XE(g,g.pendingProps.children),h.flags|=2,g.memoizedState=null,h}function lF(h,g,_){h.lanes|=g;var M=h.alternate;M!==null&&(M.lanes|=g),dE(h.return,g,_)}function QE(h,g,_,M,P,I){var ee=h.memoizedState;ee===null?h.memoizedState={isBackwards:g,rendering:null,renderingStartTime:0,last:M,tail:_,tailMode:P,treeForkCount:I}:(ee.isBackwards=g,ee.rendering=null,ee.renderingStartTime=0,ee.last=M,ee.tail=_,ee.tailMode=P,ee.treeForkCount=I)}function cF(h,g,_){var M=g.pendingProps,P=M.revealOrder,I=M.tail;M=M.children;var ee=bi.current,ve=(ee&2)!==0;if(ve?(ee=ee&1|2,g.flags|=128):ee&=1,se(bi,ee),Sa(h,g,M,_),M=Kn?Yx:0,!ve&&h!==null&&(h.flags&128)!==0)e:for(h=g.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&lF(h,_,g);else if(h.tag===19)lF(h,_,g);else if(h.child!==null){h.child.return=h,h=h.child;continue}if(h===g)break e;for(;h.sibling===null;){if(h.return===null||h.return===g)break e;h=h.return}h.sibling.return=h.return,h=h.sibling}switch(P){case"forwards":for(_=g.child,P=null;_!==null;)h=_.alternate,h!==null&&$v(h)===null&&(P=_),_=_.sibling;_=P,_===null?(P=g.child,g.child=null):(P=_.sibling,_.sibling=null),QE(g,!1,P,_,I,M);break;case"backwards":case"unstable_legacy-backwards":for(_=null,P=g.child,g.child=null;P!==null;){if(h=P.alternate,h!==null&&$v(h)===null){g.child=P;break}h=P.sibling,P.sibling=_,_=P,P=h}QE(g,!0,_,null,I,M);break;case"together":QE(g,!1,null,null,void 0,M);break;default:g.memoizedState=null}return g.child}function Lc(h,g,_){if(h!==null&&(g.dependencies=h.dependencies),ud|=g.lanes,(_&g.childLanes)===0)if(h!==null){if(qm(h,g,_,!1),(_&g.childLanes)===0)return null}else return null;if(h!==null&&g.child!==h.child)throw Error(r(153));if(g.child!==null){for(h=g.child,_=kc(h,h.pendingProps),g.child=_,_.return=g;h.sibling!==null;)h=h.sibling,_=_.sibling=kc(h,h.pendingProps),_.return=g;_.sibling=null}return g.child}function ZE(h,g){return(h.lanes&g)!==0?!0:(h=h.dependencies,!!(h!==null&&Dv(h)))}function Oie(h,g,_){switch(g.tag){case 3:ge(g,g.stateNode.containerInfo),nd(g,Ni,h.memoizedState.cache),Xh();break;case 27:case 5:Pe(g);break;case 4:ge(g,g.stateNode.containerInfo);break;case 10:nd(g,g.type,g.memoizedProps.value);break;case 31:if(g.memoizedState!==null)return g.flags|=128,SE(g),null;break;case 13:var M=g.memoizedState;if(M!==null)return M.dehydrated!==null?(sd(g),g.flags|=128,null):(_&g.child.childLanes)!==0?oF(h,g,_):(sd(g),h=Lc(h,g,_),h!==null?h.sibling:null);sd(g);break;case 19:var P=(h.flags&128)!==0;if(M=(_&g.childLanes)!==0,M||(qm(h,g,_,!1),M=(_&g.childLanes)!==0),P){if(M)return cF(h,g,_);g.flags|=128}if(P=g.memoizedState,P!==null&&(P.rendering=null,P.tail=null,P.lastEffect=null),se(bi,bi.current),M)break;return null;case 22:return g.lanes=0,tF(h,g,_,g.pendingProps);case 24:nd(g,Ni,h.memoizedState.cache)}return Lc(h,g,_)}function uF(h,g,_){if(h!==null)if(h.memoizedProps!==g.pendingProps)Ei=!0;else{if(!ZE(h,_)&&(g.flags&128)===0)return Ei=!1,Oie(h,g,_);Ei=(h.flags&131072)!==0}else Ei=!1,Kn&&(g.flags&1048576)!==0&&$5(g,Yx,g.index);switch(g.lanes=0,g.tag){case 16:e:{var M=g.pendingProps;if(h=Jh(g.elementType),g.type=h,typeof h=="function")rE(h)?(M=rf(h,M),g.tag=1,g=aF(null,g,h,M,_)):(g.tag=0,g=GE(null,g,h,M,_));else{if(h!=null){var P=h.$$typeof;if(P===C){g.tag=11,g=ZI(null,g,h,M,_);break e}else if(P===E){g.tag=14,g=JI(null,g,h,M,_);break e}}throw g=j(h)||h,Error(r(306,g,""))}}return g;case 0:return GE(h,g,g.type,g.pendingProps,_);case 1:return M=g.type,P=rf(M,g.pendingProps),aF(h,g,M,P,_);case 3:e:{if(ge(g,g.stateNode.containerInfo),h===null)throw Error(r(387));M=g.pendingProps;var I=g.memoizedState;P=I.element,bE(h,g),ib(g,M,null,_);var ee=g.memoizedState;if(M=ee.cache,nd(g,Ni,M),M!==I.cache&&hE(g,[Ni],_,!0),rb(),M=ee.element,I.isDehydrated)if(I={element:M,isDehydrated:!1,cache:ee.cache},g.updateQueue.baseState=I,g.memoizedState=I,g.flags&256){g=sF(h,g,M,_);break e}else if(M!==P){P=Co(Error(r(424)),g),Qx(P),g=sF(h,g,M,_);break e}else{switch(h=g.stateNode.containerInfo,h.nodeType){case 9:h=h.body;break;default:h=h.nodeName==="HTML"?h.ownerDocument.body:h}for(zr=Po(h.firstChild),_a=g,Kn=!0,ed=null,ko=!0,_=tI(g,null,M,_),g.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling}else{if(Xh(),M===P){g=Lc(h,g,_);break e}Sa(h,g,M,_)}g=g.child}return g;case 26:return Jv(h,g),h===null?(_=_U(g.type,null,g.pendingProps,null))?g.memoizedState=_:Kn||(_=g.type,h=g.pendingProps,M=g_(fe.current).createElement(_),M[er]=g,M[bn]=h,Na(M,_,h),Oe(M),g.stateNode=M):g.memoizedState=_U(g.type,h.memoizedProps,g.pendingProps,h.memoizedState),null;case 27:return Pe(g),h===null&&Kn&&(M=g.stateNode=bU(g.type,g.pendingProps,fe.current),_a=g,ko=!0,P=zr,pd(g.type)?(jC=P,zr=Po(M.firstChild)):zr=P),Sa(h,g,g.pendingProps.children,_),Jv(h,g),h===null&&(g.flags|=4194304),g.child;case 5:return h===null&&Kn&&((P=M=zr)&&(M=dae(M,g.type,g.pendingProps,ko),M!==null?(g.stateNode=M,_a=g,zr=Po(M.firstChild),ko=!1,P=!0):P=!1),P||td(g)),Pe(g),P=g.type,I=g.pendingProps,ee=h!==null?h.memoizedProps:null,M=I.children,EC(P,I)?M=null:ee!==null&&EC(P,ee)&&(g.flags|=32),g.memoizedState!==null&&(P=ME(h,g,Eie,null,null,_),Nb._currentValue=P),Jv(h,g),Sa(h,g,M,_),g.child;case 6:return h===null&&Kn&&((h=_=zr)&&(_=hae(_,g.pendingProps,ko),_!==null?(g.stateNode=_,_a=g,zr=null,h=!0):h=!1),h||td(g)),null;case 13:return oF(h,g,_);case 4:return ge(g,g.stateNode.containerInfo),M=g.pendingProps,h===null?g.child=tf(g,null,M,_):Sa(h,g,M,_),g.child;case 11:return ZI(h,g,g.type,g.pendingProps,_);case 7:return Sa(h,g,g.pendingProps,_),g.child;case 8:return Sa(h,g,g.pendingProps.children,_),g.child;case 12:return Sa(h,g,g.pendingProps.children,_),g.child;case 10:return M=g.pendingProps,nd(g,g.type,M.value),Sa(h,g,M.children,_),g.child;case 9:return P=g.type._context,M=g.pendingProps.children,Qh(g),P=wa(P),M=M(P),g.flags|=1,Sa(h,g,M,_),g.child;case 14:return JI(h,g,g.type,g.pendingProps,_);case 15:return eF(h,g,g.type,g.pendingProps,_);case 19:return cF(h,g,_);case 31:return Die(h,g,_);case 22:return tF(h,g,_,g.pendingProps);case 24:return Qh(g),M=wa(Ni),h===null?(P=pE(),P===null&&(P=jr,I=fE(),P.pooledCache=I,I.refCount++,I!==null&&(P.pooledCacheLanes|=_),P=I),g.memoizedState={parent:M,cache:P},xE(g),nd(g,Ni,P)):((h.lanes&_)!==0&&(bE(h,g),ib(g,null,null,_),rb()),P=h.memoizedState,I=g.memoizedState,P.parent!==M?(P={parent:M,cache:M},g.memoizedState=P,g.lanes===0&&(g.memoizedState=g.updateQueue.baseState=P),nd(g,Ni,M)):(M=I.cache,nd(g,Ni,M),M!==P.cache&&hE(g,[Ni],_,!0))),Sa(h,g,g.pendingProps.children,_),g.child;case 29:throw g.pendingProps}throw Error(r(156,g.tag))}function Ic(h){h.flags|=4}function JE(h,g,_,M,P){if((g=(h.mode&32)!==0)&&(g=!1),g){if(h.flags|=16777216,(P&335544128)===P)if(h.stateNode.complete)h.flags|=8192;else if(IF())h.flags|=8192;else throw ef=Fv,gE}else h.flags&=-16777217}function dF(h,g){if(g.type!=="stylesheet"||(g.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!EU(g))if(IF())h.flags|=8192;else throw ef=Fv,gE}function t_(h,g){g!==null&&(h.flags|=4),h.flags&16384&&(g=h.tag!==22?yt():536870912,h.lanes|=g,ip|=g)}function ub(h,g){if(!Kn)switch(h.tailMode){case"hidden":g=h.tail;for(var _=null;g!==null;)g.alternate!==null&&(_=g),g=g.sibling;_===null?h.tail=null:_.sibling=null;break;case"collapsed":_=h.tail;for(var M=null;_!==null;)_.alternate!==null&&(M=_),_=_.sibling;M===null?g||h.tail===null?h.tail=null:h.tail.sibling=null:M.sibling=null}}function Br(h){var g=h.alternate!==null&&h.alternate.child===h.child,_=0,M=0;if(g)for(var P=h.child;P!==null;)_|=P.lanes|P.childLanes,M|=P.subtreeFlags&65011712,M|=P.flags&65011712,P.return=h,P=P.sibling;else for(P=h.child;P!==null;)_|=P.lanes|P.childLanes,M|=P.subtreeFlags,M|=P.flags,P.return=h,P=P.sibling;return h.subtreeFlags|=M,h.childLanes=_,g}function Lie(h,g,_){var M=g.pendingProps;switch(oE(g),g.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Br(g),null;case 1:return Br(g),null;case 3:return _=g.stateNode,M=null,h!==null&&(M=h.memoizedState.cache),g.memoizedState.cache!==M&&(g.flags|=2048),Rc(Ni),xe(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(h===null||h.child===null)&&(Gm(g)?Ic(g):h===null||h.memoizedState.isDehydrated&&(g.flags&256)===0||(g.flags|=1024,cE())),Br(g),null;case 26:var P=g.type,I=g.memoizedState;return h===null?(Ic(g),I!==null?(Br(g),dF(g,I)):(Br(g),JE(g,P,null,M,_))):I?I!==h.memoizedState?(Ic(g),Br(g),dF(g,I)):(Br(g),g.flags&=-16777217):(h=h.memoizedProps,h!==M&&Ic(g),Br(g),JE(g,P,h,M,_)),null;case 27:if(Ue(g),_=fe.current,P=g.type,h!==null&&g.stateNode!=null)h.memoizedProps!==M&&Ic(g);else{if(!M){if(g.stateNode===null)throw Error(r(166));return Br(g),null}h=ne.current,Gm(g)?V5(g):(h=bU(P,M,_),g.stateNode=h,Ic(g))}return Br(g),null;case 5:if(Ue(g),P=g.type,h!==null&&g.stateNode!=null)h.memoizedProps!==M&&Ic(g);else{if(!M){if(g.stateNode===null)throw Error(r(166));return Br(g),null}if(I=ne.current,Gm(g))V5(g);else{var ee=g_(fe.current);switch(I){case 1:I=ee.createElementNS("http://www.w3.org/2000/svg",P);break;case 2:I=ee.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;default:switch(P){case"svg":I=ee.createElementNS("http://www.w3.org/2000/svg",P);break;case"math":I=ee.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;case"script":I=ee.createElement("div"),I.innerHTML="<script><\/script>",I=I.removeChild(I.firstChild);break;case"select":I=typeof M.is=="string"?ee.createElement("select",{is:M.is}):ee.createElement("select"),M.multiple?I.multiple=!0:M.size&&(I.size=M.size);break;default:I=typeof M.is=="string"?ee.createElement(P,{is:M.is}):ee.createElement(P)}}I[er]=g,I[bn]=M;e:for(ee=g.child;ee!==null;){if(ee.tag===5||ee.tag===6)I.appendChild(ee.stateNode);else if(ee.tag!==4&&ee.tag!==27&&ee.child!==null){ee.child.return=ee,ee=ee.child;continue}if(ee===g)break e;for(;ee.sibling===null;){if(ee.return===null||ee.return===g)break e;ee=ee.return}ee.sibling.return=ee.return,ee=ee.sibling}g.stateNode=I;e:switch(Na(I,P,M),P){case"button":case"input":case"select":case"textarea":M=!!M.autoFocus;break e;case"img":M=!0;break e;default:M=!1}M&&Ic(g)}}return Br(g),JE(g,g.type,h===null?null:h.memoizedProps,g.pendingProps,_),null;case 6:if(h&&g.stateNode!=null)h.memoizedProps!==M&&Ic(g);else{if(typeof M!="string"&&g.stateNode===null)throw Error(r(166));if(h=fe.current,Gm(g)){if(h=g.stateNode,_=g.memoizedProps,M=null,P=_a,P!==null)switch(P.tag){case 27:case 5:M=P.memoizedProps}h[er]=g,h=!!(h.nodeValue===_||M!==null&&M.suppressHydrationWarning===!0||oU(h.nodeValue,_)),h||td(g,!0)}else h=g_(h).createTextNode(M),h[er]=g,g.stateNode=h}return Br(g),null;case 31:if(_=g.memoizedState,h===null||h.memoizedState!==null){if(M=Gm(g),_!==null){if(h===null){if(!M)throw Error(r(318));if(h=g.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(557));h[er]=g}else Xh(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Br(g),h=!1}else _=cE(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=_),h=!0;if(!h)return g.flags&256?(Zs(g),g):(Zs(g),null);if((g.flags&128)!==0)throw Error(r(558))}return Br(g),null;case 13:if(M=g.memoizedState,h===null||h.memoizedState!==null&&h.memoizedState.dehydrated!==null){if(P=Gm(g),M!==null&&M.dehydrated!==null){if(h===null){if(!P)throw Error(r(318));if(P=g.memoizedState,P=P!==null?P.dehydrated:null,!P)throw Error(r(317));P[er]=g}else Xh(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Br(g),P=!1}else P=cE(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=P),P=!0;if(!P)return g.flags&256?(Zs(g),g):(Zs(g),null)}return Zs(g),(g.flags&128)!==0?(g.lanes=_,g):(_=M!==null,h=h!==null&&h.memoizedState!==null,_&&(M=g.child,P=null,M.alternate!==null&&M.alternate.memoizedState!==null&&M.alternate.memoizedState.cachePool!==null&&(P=M.alternate.memoizedState.cachePool.pool),I=null,M.memoizedState!==null&&M.memoizedState.cachePool!==null&&(I=M.memoizedState.cachePool.pool),I!==P&&(M.flags|=2048)),_!==h&&_&&(g.child.flags|=8192),t_(g,g.updateQueue),Br(g),null);case 4:return xe(),h===null&&_C(g.stateNode.containerInfo),Br(g),null;case 10:return Rc(g.type),Br(g),null;case 19:if(W(bi),M=g.memoizedState,M===null)return Br(g),null;if(P=(g.flags&128)!==0,I=M.rendering,I===null)if(P)ub(M,!1);else{if(li!==0||h!==null&&(h.flags&128)!==0)for(h=g.child;h!==null;){if(I=$v(h),I!==null){for(g.flags|=128,ub(M,!1),h=I.updateQueue,g.updateQueue=h,t_(g,h),g.subtreeFlags=0,h=_,_=g.child;_!==null;)U5(_,h),_=_.sibling;return se(bi,bi.current&1|2),Kn&&jc(g,M.treeForkCount),g.child}h=h.sibling}M.tail!==null&&L()>s_&&(g.flags|=128,P=!0,ub(M,!1),g.lanes=4194304)}else{if(!P)if(h=$v(I),h!==null){if(g.flags|=128,P=!0,h=h.updateQueue,g.updateQueue=h,t_(g,h),ub(M,!0),M.tail===null&&M.tailMode==="hidden"&&!I.alternate&&!Kn)return Br(g),null}else 2*L()-M.renderingStartTime>s_&&_!==536870912&&(g.flags|=128,P=!0,ub(M,!1),g.lanes=4194304);M.isBackwards?(I.sibling=g.child,g.child=I):(h=M.last,h!==null?h.sibling=I:g.child=I,M.last=I)}return M.tail!==null?(h=M.tail,M.rendering=h,M.tail=h.sibling,M.renderingStartTime=L(),h.sibling=null,_=bi.current,se(bi,P?_&1|2:_&1),Kn&&jc(g,M.treeForkCount),h):(Br(g),null);case 22:case 23:return Zs(g),wE(),M=g.memoizedState!==null,h!==null?h.memoizedState!==null!==M&&(g.flags|=8192):M&&(g.flags|=8192),M?(_&536870912)!==0&&(g.flags&128)===0&&(Br(g),g.subtreeFlags&6&&(g.flags|=8192)):Br(g),_=g.updateQueue,_!==null&&t_(g,_.retryQueue),_=null,h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),M=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(M=g.memoizedState.cachePool.pool),M!==_&&(g.flags|=2048),h!==null&&W(Zh),null;case 24:return _=null,h!==null&&(_=h.memoizedState.cache),g.memoizedState.cache!==_&&(g.flags|=2048),Rc(Ni),Br(g),null;case 25:return null;case 30:return null}throw Error(r(156,g.tag))}function Iie(h,g){switch(oE(g),g.tag){case 1:return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 3:return Rc(Ni),xe(),h=g.flags,(h&65536)!==0&&(h&128)===0?(g.flags=h&-65537|128,g):null;case 26:case 27:case 5:return Ue(g),null;case 31:if(g.memoizedState!==null){if(Zs(g),g.alternate===null)throw Error(r(340));Xh()}return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 13:if(Zs(g),h=g.memoizedState,h!==null&&h.dehydrated!==null){if(g.alternate===null)throw Error(r(340));Xh()}return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 19:return W(bi),null;case 4:return xe(),null;case 10:return Rc(g.type),null;case 22:case 23:return Zs(g),wE(),h!==null&&W(Zh),h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 24:return Rc(Ni),null;case 25:return null;default:return null}}function hF(h,g){switch(oE(g),g.tag){case 3:Rc(Ni),xe();break;case 26:case 27:case 5:Ue(g);break;case 4:xe();break;case 31:g.memoizedState!==null&&Zs(g);break;case 13:Zs(g);break;case 19:W(bi);break;case 10:Rc(g.type);break;case 22:case 23:Zs(g),wE(),h!==null&&W(Zh);break;case 24:Rc(Ni)}}function db(h,g){try{var _=g.updateQueue,M=_!==null?_.lastEffect:null;if(M!==null){var P=M.next;_=P;do{if((_.tag&h)===h){M=void 0;var I=_.create,ee=_.inst;M=I(),ee.destroy=M}_=_.next}while(_!==P)}}catch(ve){fr(g,g.return,ve)}}function ld(h,g,_){try{var M=g.updateQueue,P=M!==null?M.lastEffect:null;if(P!==null){var I=P.next;M=I;do{if((M.tag&h)===h){var ee=M.inst,ve=ee.destroy;if(ve!==void 0){ee.destroy=void 0,P=g;var ze=_,rt=ve;try{rt()}catch(gt){fr(P,ze,gt)}}}M=M.next}while(M!==I)}}catch(gt){fr(g,g.return,gt)}}function fF(h){var g=h.updateQueue;if(g!==null){var _=h.stateNode;try{rI(g,_)}catch(M){fr(h,h.return,M)}}}function mF(h,g,_){_.props=rf(h.type,h.memoizedProps),_.state=h.memoizedState;try{_.componentWillUnmount()}catch(M){fr(h,g,M)}}function hb(h,g){try{var _=h.ref;if(_!==null){switch(h.tag){case 26:case 27:case 5:var M=h.stateNode;break;case 30:M=h.stateNode;break;default:M=h.stateNode}typeof _=="function"?h.refCleanup=_(M):_.current=M}}catch(P){fr(h,g,P)}}function Wl(h,g){var _=h.ref,M=h.refCleanup;if(_!==null)if(typeof M=="function")try{M()}catch(P){fr(h,g,P)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(P){fr(h,g,P)}else _.current=null}function pF(h){var g=h.type,_=h.memoizedProps,M=h.stateNode;try{e:switch(g){case"button":case"input":case"select":case"textarea":_.autoFocus&&M.focus();break e;case"img":_.src?M.src=_.src:_.srcSet&&(M.srcset=_.srcSet)}}catch(P){fr(h,h.return,P)}}function eC(h,g,_){try{var M=h.stateNode;aae(M,h.type,_,g),M[bn]=g}catch(P){fr(h,h.return,P)}}function gF(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&pd(h.type)||h.tag===4}function tC(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||gF(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&&pd(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 nC(h,g,_){var M=h.tag;if(M===5||M===6)h=h.stateNode,g?(_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_).insertBefore(h,g):(g=_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_,g.appendChild(h),_=_._reactRootContainer,_!=null||g.onclick!==null||(g.onclick=rs));else if(M!==4&&(M===27&&pd(h.type)&&(_=h.stateNode,g=null),h=h.child,h!==null))for(nC(h,g,_),h=h.sibling;h!==null;)nC(h,g,_),h=h.sibling}function n_(h,g,_){var M=h.tag;if(M===5||M===6)h=h.stateNode,g?_.insertBefore(h,g):_.appendChild(h);else if(M!==4&&(M===27&&pd(h.type)&&(_=h.stateNode),h=h.child,h!==null))for(n_(h,g,_),h=h.sibling;h!==null;)n_(h,g,_),h=h.sibling}function xF(h){var g=h.stateNode,_=h.memoizedProps;try{for(var M=h.type,P=g.attributes;P.length;)g.removeAttributeNode(P[0]);Na(g,M,_),g[er]=h,g[bn]=_}catch(I){fr(h,h.return,I)}}var Fc=!1,Ci=!1,rC=!1,bF=typeof WeakSet=="function"?WeakSet:Set,oa=null;function Fie(h,g){if(h=h.containerInfo,NC=S_,h=k5(h),YM(h)){if("selectionStart"in h)var _={start:h.selectionStart,end:h.selectionEnd};else e:{_=(_=h.ownerDocument)&&_.defaultView||window;var M=_.getSelection&&_.getSelection();if(M&&M.rangeCount!==0){_=M.anchorNode;var P=M.anchorOffset,I=M.focusNode;M=M.focusOffset;try{_.nodeType,I.nodeType}catch{_=null;break e}var ee=0,ve=-1,ze=-1,rt=0,gt=0,vt=h,ot=null;t:for(;;){for(var pt;vt!==_||P!==0&&vt.nodeType!==3||(ve=ee+P),vt!==I||M!==0&&vt.nodeType!==3||(ze=ee+M),vt.nodeType===3&&(ee+=vt.nodeValue.length),(pt=vt.firstChild)!==null;)ot=vt,vt=pt;for(;;){if(vt===h)break t;if(ot===_&&++rt===P&&(ve=ee),ot===I&&++gt===M&&(ze=ee),(pt=vt.nextSibling)!==null)break;vt=ot,ot=vt.parentNode}vt=pt}_=ve===-1||ze===-1?null:{start:ve,end:ze}}else _=null}_=_||{start:0,end:0}}else _=null;for(MC={focusedElem:h,selectionRange:_},S_=!1,oa=g;oa!==null;)if(g=oa,h=g.child,(g.subtreeFlags&1028)!==0&&h!==null)h.return=g,oa=h;else for(;oa!==null;){switch(g=oa,I=g.alternate,h=g.flags,g.tag){case 0:if((h&4)!==0&&(h=g.updateQueue,h=h!==null?h.events:null,h!==null))for(_=0;_<h.length;_++)P=h[_],P.ref.impl=P.nextImpl;break;case 11:case 15:break;case 1:if((h&1024)!==0&&I!==null){h=void 0,_=g,P=I.memoizedProps,I=I.memoizedState,M=_.stateNode;try{var Gt=rf(_.type,P);h=M.getSnapshotBeforeUpdate(Gt,I),M.__reactInternalSnapshotBeforeUpdate=h}catch(rn){fr(_,_.return,rn)}}break;case 3:if((h&1024)!==0){if(h=g.stateNode.containerInfo,_=h.nodeType,_===9)TC(h);else if(_===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":TC(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=g.sibling,h!==null){h.return=g.return,oa=h;break}oa=g.return}}function yF(h,g,_){var M=_.flags;switch(_.tag){case 0:case 11:case 15:zc(h,_),M&4&&db(5,_);break;case 1:if(zc(h,_),M&4)if(h=_.stateNode,g===null)try{h.componentDidMount()}catch(ee){fr(_,_.return,ee)}else{var P=rf(_.type,g.memoizedProps);g=g.memoizedState;try{h.componentDidUpdate(P,g,h.__reactInternalSnapshotBeforeUpdate)}catch(ee){fr(_,_.return,ee)}}M&64&&fF(_),M&512&&hb(_,_.return);break;case 3:if(zc(h,_),M&64&&(h=_.updateQueue,h!==null)){if(g=null,_.child!==null)switch(_.child.tag){case 27:case 5:g=_.child.stateNode;break;case 1:g=_.child.stateNode}try{rI(h,g)}catch(ee){fr(_,_.return,ee)}}break;case 27:g===null&&M&4&&xF(_);case 26:case 5:zc(h,_),g===null&&M&4&&pF(_),M&512&&hb(_,_.return);break;case 12:zc(h,_);break;case 31:zc(h,_),M&4&&wF(h,_);break;case 13:zc(h,_),M&4&&SF(h,_),M&64&&(h=_.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(_=Wie.bind(null,_),fae(h,_))));break;case 22:if(M=_.memoizedState!==null||Fc,!M){g=g!==null&&g.memoizedState!==null||Ci,P=Fc;var I=Ci;Fc=M,(Ci=g)&&!I?Bc(h,_,(_.subtreeFlags&8772)!==0):zc(h,_),Fc=P,Ci=I}break;case 30:break;default:zc(h,_)}}function vF(h){var g=h.alternate;g!==null&&(h.alternate=null,vF(g)),h.child=null,h.deletions=null,h.sibling=null,h.tag===5&&(g=h.stateNode,g!==null&&st(g)),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 qr=null,Cs=!1;function Uc(h,g,_){for(_=_.child;_!==null;)_F(h,g,_),_=_.sibling}function _F(h,g,_){if(ae&&typeof ae.onCommitFiberUnmount=="function")try{ae.onCommitFiberUnmount(Ie,_)}catch{}switch(_.tag){case 26:Ci||Wl(_,g),Uc(h,g,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:Ci||Wl(_,g);var M=qr,P=Cs;pd(_.type)&&(qr=_.stateNode,Cs=!1),Uc(h,g,_),_b(_.stateNode),qr=M,Cs=P;break;case 5:Ci||Wl(_,g);case 6:if(M=qr,P=Cs,qr=null,Uc(h,g,_),qr=M,Cs=P,qr!==null)if(Cs)try{(qr.nodeType===9?qr.body:qr.nodeName==="HTML"?qr.ownerDocument.body:qr).removeChild(_.stateNode)}catch(I){fr(_,g,I)}else try{qr.removeChild(_.stateNode)}catch(I){fr(_,g,I)}break;case 18:qr!==null&&(Cs?(h=qr,fU(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,_.stateNode),hp(h)):fU(qr,_.stateNode));break;case 4:M=qr,P=Cs,qr=_.stateNode.containerInfo,Cs=!0,Uc(h,g,_),qr=M,Cs=P;break;case 0:case 11:case 14:case 15:ld(2,_,g),Ci||ld(4,_,g),Uc(h,g,_);break;case 1:Ci||(Wl(_,g),M=_.stateNode,typeof M.componentWillUnmount=="function"&&mF(_,g,M)),Uc(h,g,_);break;case 21:Uc(h,g,_);break;case 22:Ci=(M=Ci)||_.memoizedState!==null,Uc(h,g,_),Ci=M;break;default:Uc(h,g,_)}}function wF(h,g){if(g.memoizedState===null&&(h=g.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{hp(h)}catch(_){fr(g,g.return,_)}}}function SF(h,g){if(g.memoizedState===null&&(h=g.alternate,h!==null&&(h=h.memoizedState,h!==null&&(h=h.dehydrated,h!==null))))try{hp(h)}catch(_){fr(g,g.return,_)}}function Uie(h){switch(h.tag){case 31:case 13:case 19:var g=h.stateNode;return g===null&&(g=h.stateNode=new bF),g;case 22:return h=h.stateNode,g=h._retryCache,g===null&&(g=h._retryCache=new bF),g;default:throw Error(r(435,h.tag))}}function r_(h,g){var _=Uie(h);g.forEach(function(M){if(!_.has(M)){_.add(M);var P=Kie.bind(null,h,M);M.then(P,P)}})}function Ts(h,g){var _=g.deletions;if(_!==null)for(var M=0;M<_.length;M++){var P=_[M],I=h,ee=g,ve=ee;e:for(;ve!==null;){switch(ve.tag){case 27:if(pd(ve.type)){qr=ve.stateNode,Cs=!1;break e}break;case 5:qr=ve.stateNode,Cs=!1;break e;case 3:case 4:qr=ve.stateNode.containerInfo,Cs=!0;break e}ve=ve.return}if(qr===null)throw Error(r(160));_F(I,ee,P),qr=null,Cs=!1,I=P.alternate,I!==null&&(I.return=null),P.return=null}if(g.subtreeFlags&13886)for(g=g.child;g!==null;)NF(g,h),g=g.sibling}var bl=null;function NF(h,g){var _=h.alternate,M=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:Ts(g,h),As(h),M&4&&(ld(3,h,h.return),db(3,h),ld(5,h,h.return));break;case 1:Ts(g,h),As(h),M&512&&(Ci||_===null||Wl(_,_.return)),M&64&&Fc&&(h=h.updateQueue,h!==null&&(M=h.callbacks,M!==null&&(_=h.shared.hiddenCallbacks,h.shared.hiddenCallbacks=_===null?M:_.concat(M))));break;case 26:var P=bl;if(Ts(g,h),As(h),M&512&&(Ci||_===null||Wl(_,_.return)),M&4){var I=_!==null?_.memoizedState:null;if(M=h.memoizedState,_===null)if(M===null)if(h.stateNode===null){e:{M=h.type,_=h.memoizedProps,P=P.ownerDocument||P;t:switch(M){case"title":I=P.getElementsByTagName("title")[0],(!I||I[dt]||I[er]||I.namespaceURI==="http://www.w3.org/2000/svg"||I.hasAttribute("itemprop"))&&(I=P.createElement(M),P.head.insertBefore(I,P.querySelector("head > title"))),Na(I,M,_),I[er]=h,Oe(I),M=I;break e;case"link":var ee=NU("link","href",P).get(M+(_.href||""));if(ee){for(var ve=0;ve<ee.length;ve++)if(I=ee[ve],I.getAttribute("href")===(_.href==null||_.href===""?null:_.href)&&I.getAttribute("rel")===(_.rel==null?null:_.rel)&&I.getAttribute("title")===(_.title==null?null:_.title)&&I.getAttribute("crossorigin")===(_.crossOrigin==null?null:_.crossOrigin)){ee.splice(ve,1);break t}}I=P.createElement(M),Na(I,M,_),P.head.appendChild(I);break;case"meta":if(ee=NU("meta","content",P).get(M+(_.content||""))){for(ve=0;ve<ee.length;ve++)if(I=ee[ve],I.getAttribute("content")===(_.content==null?null:""+_.content)&&I.getAttribute("name")===(_.name==null?null:_.name)&&I.getAttribute("property")===(_.property==null?null:_.property)&&I.getAttribute("http-equiv")===(_.httpEquiv==null?null:_.httpEquiv)&&I.getAttribute("charset")===(_.charSet==null?null:_.charSet)){ee.splice(ve,1);break t}}I=P.createElement(M),Na(I,M,_),P.head.appendChild(I);break;default:throw Error(r(468,M))}I[er]=h,Oe(I),M=I}h.stateNode=M}else MU(P,h.type,h.stateNode);else h.stateNode=SU(P,M,h.memoizedProps);else I!==M?(I===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):I.count--,M===null?MU(P,h.type,h.stateNode):SU(P,M,h.memoizedProps)):M===null&&h.stateNode!==null&&eC(h,h.memoizedProps,_.memoizedProps)}break;case 27:Ts(g,h),As(h),M&512&&(Ci||_===null||Wl(_,_.return)),_!==null&&M&4&&eC(h,h.memoizedProps,_.memoizedProps);break;case 5:if(Ts(g,h),As(h),M&512&&(Ci||_===null||Wl(_,_.return)),h.flags&32){P=h.stateNode;try{tr(P,"")}catch(Gt){fr(h,h.return,Gt)}}M&4&&h.stateNode!=null&&(P=h.memoizedProps,eC(h,P,_!==null?_.memoizedProps:P)),M&1024&&(rC=!0);break;case 6:if(Ts(g,h),As(h),M&4){if(h.stateNode===null)throw Error(r(162));M=h.memoizedProps,_=h.stateNode;try{_.nodeValue=M}catch(Gt){fr(h,h.return,Gt)}}break;case 3:if(y_=null,P=bl,bl=x_(g.containerInfo),Ts(g,h),bl=P,As(h),M&4&&_!==null&&_.memoizedState.isDehydrated)try{hp(g.containerInfo)}catch(Gt){fr(h,h.return,Gt)}rC&&(rC=!1,MF(h));break;case 4:M=bl,bl=x_(h.stateNode.containerInfo),Ts(g,h),As(h),bl=M;break;case 12:Ts(g,h),As(h);break;case 31:Ts(g,h),As(h),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,r_(h,M)));break;case 13:Ts(g,h),As(h),h.child.flags&8192&&h.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(a_=L()),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,r_(h,M)));break;case 22:P=h.memoizedState!==null;var ze=_!==null&&_.memoizedState!==null,rt=Fc,gt=Ci;if(Fc=rt||P,Ci=gt||ze,Ts(g,h),Ci=gt,Fc=rt,As(h),M&8192)e:for(g=h.stateNode,g._visibility=P?g._visibility&-2:g._visibility|1,P&&(_===null||ze||Fc||Ci||af(h)),_=null,g=h;;){if(g.tag===5||g.tag===26){if(_===null){ze=_=g;try{if(I=ze.stateNode,P)ee=I.style,typeof ee.setProperty=="function"?ee.setProperty("display","none","important"):ee.display="none";else{ve=ze.stateNode;var vt=ze.memoizedProps.style,ot=vt!=null&&vt.hasOwnProperty("display")?vt.display:null;ve.style.display=ot==null||typeof ot=="boolean"?"":(""+ot).trim()}}catch(Gt){fr(ze,ze.return,Gt)}}}else if(g.tag===6){if(_===null){ze=g;try{ze.stateNode.nodeValue=P?"":ze.memoizedProps}catch(Gt){fr(ze,ze.return,Gt)}}}else if(g.tag===18){if(_===null){ze=g;try{var pt=ze.stateNode;P?mU(pt,!0):mU(ze.stateNode,!1)}catch(Gt){fr(ze,ze.return,Gt)}}}else if((g.tag!==22&&g.tag!==23||g.memoizedState===null||g===h)&&g.child!==null){g.child.return=g,g=g.child;continue}if(g===h)break e;for(;g.sibling===null;){if(g.return===null||g.return===h)break e;_===g&&(_=null),g=g.return}_===g&&(_=null),g.sibling.return=g.return,g=g.sibling}M&4&&(M=h.updateQueue,M!==null&&(_=M.retryQueue,_!==null&&(M.retryQueue=null,r_(h,_))));break;case 19:Ts(g,h),As(h),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,r_(h,M)));break;case 30:break;case 21:break;default:Ts(g,h),As(h)}}function As(h){var g=h.flags;if(g&2){try{for(var _,M=h.return;M!==null;){if(gF(M)){_=M;break}M=M.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var P=_.stateNode,I=tC(h);n_(h,I,P);break;case 5:var ee=_.stateNode;_.flags&32&&(tr(ee,""),_.flags&=-33);var ve=tC(h);n_(h,ve,ee);break;case 3:case 4:var ze=_.stateNode.containerInfo,rt=tC(h);nC(h,rt,ze);break;default:throw Error(r(161))}}catch(gt){fr(h,h.return,gt)}h.flags&=-3}g&4096&&(h.flags&=-4097)}function MF(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var g=h;MF(g),g.tag===5&&g.flags&1024&&g.stateNode.reset(),h=h.sibling}}function zc(h,g){if(g.subtreeFlags&8772)for(g=g.child;g!==null;)yF(h,g.alternate,g),g=g.sibling}function af(h){for(h=h.child;h!==null;){var g=h;switch(g.tag){case 0:case 11:case 14:case 15:ld(4,g,g.return),af(g);break;case 1:Wl(g,g.return);var _=g.stateNode;typeof _.componentWillUnmount=="function"&&mF(g,g.return,_),af(g);break;case 27:_b(g.stateNode);case 26:case 5:Wl(g,g.return),af(g);break;case 22:g.memoizedState===null&&af(g);break;case 30:af(g);break;default:af(g)}h=h.sibling}}function Bc(h,g,_){for(_=_&&(g.subtreeFlags&8772)!==0,g=g.child;g!==null;){var M=g.alternate,P=h,I=g,ee=I.flags;switch(I.tag){case 0:case 11:case 15:Bc(P,I,_),db(4,I);break;case 1:if(Bc(P,I,_),M=I,P=M.stateNode,typeof P.componentDidMount=="function")try{P.componentDidMount()}catch(rt){fr(M,M.return,rt)}if(M=I,P=M.updateQueue,P!==null){var ve=M.stateNode;try{var ze=P.shared.hiddenCallbacks;if(ze!==null)for(P.shared.hiddenCallbacks=null,P=0;P<ze.length;P++)nI(ze[P],ve)}catch(rt){fr(M,M.return,rt)}}_&&ee&64&&fF(I),hb(I,I.return);break;case 27:xF(I);case 26:case 5:Bc(P,I,_),_&&M===null&&ee&4&&pF(I),hb(I,I.return);break;case 12:Bc(P,I,_);break;case 31:Bc(P,I,_),_&&ee&4&&wF(P,I);break;case 13:Bc(P,I,_),_&&ee&4&&SF(P,I);break;case 22:I.memoizedState===null&&Bc(P,I,_),hb(I,I.return);break;case 30:break;default:Bc(P,I,_)}g=g.sibling}}function iC(h,g){var _=null;h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),h=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(h=g.memoizedState.cachePool.pool),h!==_&&(h!=null&&h.refCount++,_!=null&&Zx(_))}function aC(h,g){h=null,g.alternate!==null&&(h=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==h&&(g.refCount++,h!=null&&Zx(h))}function yl(h,g,_,M){if(g.subtreeFlags&10256)for(g=g.child;g!==null;)EF(h,g,_,M),g=g.sibling}function EF(h,g,_,M){var P=g.flags;switch(g.tag){case 0:case 11:case 15:yl(h,g,_,M),P&2048&&db(9,g);break;case 1:yl(h,g,_,M);break;case 3:yl(h,g,_,M),P&2048&&(h=null,g.alternate!==null&&(h=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==h&&(g.refCount++,h!=null&&Zx(h)));break;case 12:if(P&2048){yl(h,g,_,M),h=g.stateNode;try{var I=g.memoizedProps,ee=I.id,ve=I.onPostCommit;typeof ve=="function"&&ve(ee,g.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(ze){fr(g,g.return,ze)}}else yl(h,g,_,M);break;case 31:yl(h,g,_,M);break;case 13:yl(h,g,_,M);break;case 23:break;case 22:I=g.stateNode,ee=g.alternate,g.memoizedState!==null?I._visibility&2?yl(h,g,_,M):fb(h,g):I._visibility&2?yl(h,g,_,M):(I._visibility|=2,tp(h,g,_,M,(g.subtreeFlags&10256)!==0||!1)),P&2048&&iC(ee,g);break;case 24:yl(h,g,_,M),P&2048&&aC(g.alternate,g);break;default:yl(h,g,_,M)}}function tp(h,g,_,M,P){for(P=P&&((g.subtreeFlags&10256)!==0||!1),g=g.child;g!==null;){var I=h,ee=g,ve=_,ze=M,rt=ee.flags;switch(ee.tag){case 0:case 11:case 15:tp(I,ee,ve,ze,P),db(8,ee);break;case 23:break;case 22:var gt=ee.stateNode;ee.memoizedState!==null?gt._visibility&2?tp(I,ee,ve,ze,P):fb(I,ee):(gt._visibility|=2,tp(I,ee,ve,ze,P)),P&&rt&2048&&iC(ee.alternate,ee);break;case 24:tp(I,ee,ve,ze,P),P&&rt&2048&&aC(ee.alternate,ee);break;default:tp(I,ee,ve,ze,P)}g=g.sibling}}function fb(h,g){if(g.subtreeFlags&10256)for(g=g.child;g!==null;){var _=h,M=g,P=M.flags;switch(M.tag){case 22:fb(_,M),P&2048&&iC(M.alternate,M);break;case 24:fb(_,M),P&2048&&aC(M.alternate,M);break;default:fb(_,M)}g=g.sibling}}var mb=8192;function np(h,g,_){if(h.subtreeFlags&mb)for(h=h.child;h!==null;)CF(h,g,_),h=h.sibling}function CF(h,g,_){switch(h.tag){case 26:np(h,g,_),h.flags&mb&&h.memoizedState!==null&&Mae(_,bl,h.memoizedState,h.memoizedProps);break;case 5:np(h,g,_);break;case 3:case 4:var M=bl;bl=x_(h.stateNode.containerInfo),np(h,g,_),bl=M;break;case 22:h.memoizedState===null&&(M=h.alternate,M!==null&&M.memoizedState!==null?(M=mb,mb=16777216,np(h,g,_),mb=M):np(h,g,_));break;default:np(h,g,_)}}function TF(h){var g=h.alternate;if(g!==null&&(h=g.child,h!==null)){g.child=null;do g=h.sibling,h.sibling=null,h=g;while(h!==null)}}function pb(h){var g=h.deletions;if((h.flags&16)!==0){if(g!==null)for(var _=0;_<g.length;_++){var M=g[_];oa=M,kF(M,h)}TF(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)AF(h),h=h.sibling}function AF(h){switch(h.tag){case 0:case 11:case 15:pb(h),h.flags&2048&&ld(9,h,h.return);break;case 3:pb(h);break;case 12:pb(h);break;case 22:var g=h.stateNode;h.memoizedState!==null&&g._visibility&2&&(h.return===null||h.return.tag!==13)?(g._visibility&=-3,i_(h)):pb(h);break;default:pb(h)}}function i_(h){var g=h.deletions;if((h.flags&16)!==0){if(g!==null)for(var _=0;_<g.length;_++){var M=g[_];oa=M,kF(M,h)}TF(h)}for(h=h.child;h!==null;){switch(g=h,g.tag){case 0:case 11:case 15:ld(8,g,g.return),i_(g);break;case 22:_=g.stateNode,_._visibility&2&&(_._visibility&=-3,i_(g));break;default:i_(g)}h=h.sibling}}function kF(h,g){for(;oa!==null;){var _=oa;switch(_.tag){case 0:case 11:case 15:ld(8,_,g);break;case 23:case 22:if(_.memoizedState!==null&&_.memoizedState.cachePool!==null){var M=_.memoizedState.cachePool.pool;M!=null&&M.refCount++}break;case 24:Zx(_.memoizedState.cache)}if(M=_.child,M!==null)M.return=_,oa=M;else e:for(_=h;oa!==null;){M=oa;var P=M.sibling,I=M.return;if(vF(M),M===_){oa=null;break e}if(P!==null){P.return=I,oa=P;break e}oa=I}}}var zie={getCacheForType:function(h){var g=wa(Ni),_=g.data.get(h);return _===void 0&&(_=h(),g.data.set(h,_)),_},cacheSignal:function(){return wa(Ni).controller.signal}},Bie=typeof WeakMap=="function"?WeakMap:Map,or=0,jr=null,In=null,Bn=0,hr=0,Js=null,cd=!1,rp=!1,sC=!1,$c=0,li=0,ud=0,sf=0,oC=0,eo=0,ip=0,gb=null,ks=null,lC=!1,a_=0,jF=0,s_=1/0,o_=null,dd=null,$i=0,hd=null,ap=null,Hc=0,cC=0,uC=null,PF=null,xb=0,dC=null;function to(){return(or&2)!==0&&Bn!==0?Bn&-Bn:$.T!==null?xC():ln()}function RF(){if(eo===0)if((Bn&536870912)===0||Kn){var h=ke;ke<<=1,(ke&3932160)===0&&(ke=262144),eo=h}else eo=536870912;return h=Qs.current,h!==null&&(h.flags|=32),eo}function js(h,g,_){(h===jr&&(hr===2||hr===9)||h.cancelPendingCommit!==null)&&(sp(h,0),fd(h,Bn,eo,!1)),It(h,_),((or&2)===0||h!==jr)&&(h===jr&&((or&2)===0&&(sf|=_),li===4&&fd(h,Bn,eo,!1)),Kl(h))}function DF(h,g,_){if((or&6)!==0)throw Error(r(327));var M=!_&&(g&127)===0&&(g&h.expiredLanes)===0||de(h,g),P=M?Vie(h,g):fC(h,g,!0),I=M;do{if(P===0){rp&&!M&&fd(h,g,0,!1);break}else{if(_=h.current.alternate,I&&!$ie(_)){P=fC(h,g,!1),I=!1;continue}if(P===2){if(I=g,h.errorRecoveryDisabledLanes&I)var ee=0;else ee=h.pendingLanes&-536870913,ee=ee!==0?ee:ee&536870912?536870912:0;if(ee!==0){g=ee;e:{var ve=h;P=gb;var ze=ve.current.memoizedState.isDehydrated;if(ze&&(sp(ve,ee).flags|=256),ee=fC(ve,ee,!1),ee!==2){if(sC&&!ze){ve.errorRecoveryDisabledLanes|=I,sf|=I,P=4;break e}I=ks,ks=P,I!==null&&(ks===null?ks=I:ks.push.apply(ks,I))}P=ee}if(I=!1,P!==2)continue}}if(P===1){sp(h,0),fd(h,g,0,!0);break}e:{switch(M=h,I=P,I){case 0:case 1:throw Error(r(345));case 4:if((g&4194048)!==g)break;case 6:fd(M,g,eo,!cd);break e;case 2:ks=null;break;case 3:case 5:break;default:throw Error(r(329))}if((g&62914560)===g&&(P=a_+300-L(),10<P)){if(fd(M,g,eo,!cd),Ce(M,0,!0)!==0)break e;Hc=g,M.timeoutHandle=dU(OF.bind(null,M,_,ks,o_,lC,g,eo,sf,ip,cd,I,"Throttled",-0,0),P);break e}OF(M,_,ks,o_,lC,g,eo,sf,ip,cd,I,null,-0,0)}}break}while(!0);Kl(h)}function OF(h,g,_,M,P,I,ee,ve,ze,rt,gt,vt,ot,pt){if(h.timeoutHandle=-1,vt=g.subtreeFlags,vt&8192||(vt&16785408)===16785408){vt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:rs},CF(g,I,vt);var Gt=(I&62914560)===I?a_-L():(I&4194048)===I?jF-L():0;if(Gt=Eae(vt,Gt),Gt!==null){Hc=I,h.cancelPendingCommit=Gt(HF.bind(null,h,g,I,_,M,P,ee,ve,ze,gt,vt,null,ot,pt)),fd(h,I,ee,!rt);return}}HF(h,g,I,_,M,P,ee,ve,ze)}function $ie(h){for(var g=h;;){var _=g.tag;if((_===0||_===11||_===15)&&g.flags&16384&&(_=g.updateQueue,_!==null&&(_=_.stores,_!==null)))for(var M=0;M<_.length;M++){var P=_[M],I=P.getSnapshot;P=P.value;try{if(!Xs(I(),P))return!1}catch{return!1}}if(_=g.child,g.subtreeFlags&16384&&_!==null)_.return=g,g=_;else{if(g===h)break;for(;g.sibling===null;){if(g.return===null||g.return===h)return!0;g=g.return}g.sibling.return=g.return,g=g.sibling}}return!0}function fd(h,g,_,M){g&=~oC,g&=~sf,h.suspendedLanes|=g,h.pingedLanes&=~g,M&&(h.warmLanes|=g),M=h.expirationTimes;for(var P=g;0<P;){var I=31-Se(P),ee=1<<I;M[I]=-1,P&=~ee}_!==0&&vn(h,_,g)}function l_(){return(or&6)===0?(bb(0),!1):!0}function hC(){if(In!==null){if(hr===0)var h=In.return;else h=In,Pc=Yh=null,TE(h),Ym=null,eb=0,h=In;for(;h!==null;)hF(h.alternate,h),h=h.return;In=null}}function sp(h,g){var _=h.timeoutHandle;_!==-1&&(h.timeoutHandle=-1,lae(_)),_=h.cancelPendingCommit,_!==null&&(h.cancelPendingCommit=null,_()),Hc=0,hC(),jr=h,In=_=kc(h.current,null),Bn=g,hr=0,Js=null,cd=!1,rp=de(h,g),sC=!1,ip=eo=oC=sf=ud=li=0,ks=gb=null,lC=!1,(g&8)!==0&&(g|=g&32);var M=h.entangledLanes;if(M!==0)for(h=h.entanglements,M&=g;0<M;){var P=31-Se(M),I=1<<P;g|=h[P],M&=~I}return $c=g,Av(),_}function LF(h,g){wn=null,$.H=lb,g===Xm||g===Iv?(g=Z5(),hr=3):g===gE?(g=Z5(),hr=4):hr=g===VE?8:g!==null&&typeof g=="object"&&typeof g.then=="function"?6:1,Js=g,In===null&&(li=1,Qv(h,Co(g,h.current)))}function IF(){var h=Qs.current;return h===null?!0:(Bn&4194048)===Bn?jo===null:(Bn&62914560)===Bn||(Bn&536870912)!==0?h===jo:!1}function FF(){var h=$.H;return $.H=lb,h===null?lb:h}function UF(){var h=$.A;return $.A=zie,h}function c_(){li=4,cd||(Bn&4194048)!==Bn&&Qs.current!==null||(rp=!0),(ud&134217727)===0&&(sf&134217727)===0||jr===null||fd(jr,Bn,eo,!1)}function fC(h,g,_){var M=or;or|=2;var P=FF(),I=UF();(jr!==h||Bn!==g)&&(o_=null,sp(h,g)),g=!1;var ee=li;e:do try{if(hr!==0&&In!==null){var ve=In,ze=Js;switch(hr){case 8:hC(),ee=6;break e;case 3:case 2:case 9:case 6:Qs.current===null&&(g=!0);var rt=hr;if(hr=0,Js=null,op(h,ve,ze,rt),_&&rp){ee=0;break e}break;default:rt=hr,hr=0,Js=null,op(h,ve,ze,rt)}}Hie(),ee=li;break}catch(gt){LF(h,gt)}while(!0);return g&&h.shellSuspendCounter++,Pc=Yh=null,or=M,$.H=P,$.A=I,In===null&&(jr=null,Bn=0,Av()),ee}function Hie(){for(;In!==null;)zF(In)}function Vie(h,g){var _=or;or|=2;var M=FF(),P=UF();jr!==h||Bn!==g?(o_=null,s_=L()+500,sp(h,g)):rp=de(h,g);e:do try{if(hr!==0&&In!==null){g=In;var I=Js;t:switch(hr){case 1:hr=0,Js=null,op(h,g,I,1);break;case 2:case 9:if(Y5(I)){hr=0,Js=null,BF(g);break}g=function(){hr!==2&&hr!==9||jr!==h||(hr=7),Kl(h)},I.then(g,g);break e;case 3:hr=7;break e;case 4:hr=5;break e;case 7:Y5(I)?(hr=0,Js=null,BF(g)):(hr=0,Js=null,op(h,g,I,7));break;case 5:var ee=null;switch(In.tag){case 26:ee=In.memoizedState;case 5:case 27:var ve=In;if(ee?EU(ee):ve.stateNode.complete){hr=0,Js=null;var ze=ve.sibling;if(ze!==null)In=ze;else{var rt=ve.return;rt!==null?(In=rt,u_(rt)):In=null}break t}}hr=0,Js=null,op(h,g,I,5);break;case 6:hr=0,Js=null,op(h,g,I,6);break;case 8:hC(),li=6;break e;default:throw Error(r(462))}}Gie();break}catch(gt){LF(h,gt)}while(!0);return Pc=Yh=null,$.H=M,$.A=P,or=_,In!==null?0:(jr=null,Bn=0,Av(),li)}function Gie(){for(;In!==null&&!Te();)zF(In)}function zF(h){var g=uF(h.alternate,h,$c);h.memoizedProps=h.pendingProps,g===null?u_(h):In=g}function BF(h){var g=h,_=g.alternate;switch(g.tag){case 15:case 0:g=iF(_,g,g.pendingProps,g.type,void 0,Bn);break;case 11:g=iF(_,g,g.pendingProps,g.type.render,g.ref,Bn);break;case 5:TE(g);default:hF(_,g),g=In=U5(g,$c),g=uF(_,g,$c)}h.memoizedProps=h.pendingProps,g===null?u_(h):In=g}function op(h,g,_,M){Pc=Yh=null,TE(g),Ym=null,eb=0;var P=g.return;try{if(Rie(h,P,g,_,Bn)){li=1,Qv(h,Co(_,h.current)),In=null;return}}catch(I){if(P!==null)throw In=P,I;li=1,Qv(h,Co(_,h.current)),In=null;return}g.flags&32768?(Kn||M===1?h=!0:rp||(Bn&536870912)!==0?h=!1:(cd=h=!0,(M===2||M===9||M===3||M===6)&&(M=Qs.current,M!==null&&M.tag===13&&(M.flags|=16384))),$F(g,h)):u_(g)}function u_(h){var g=h;do{if((g.flags&32768)!==0){$F(g,cd);return}h=g.return;var _=Lie(g.alternate,g,$c);if(_!==null){In=_;return}if(g=g.sibling,g!==null){In=g;return}In=g=h}while(g!==null);li===0&&(li=5)}function $F(h,g){do{var _=Iie(h.alternate,h);if(_!==null){_.flags&=32767,In=_;return}if(_=h.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!g&&(h=h.sibling,h!==null)){In=h;return}In=h=_}while(h!==null);li=6,In=null}function HF(h,g,_,M,P,I,ee,ve,ze){h.cancelPendingCommit=null;do d_();while($i!==0);if((or&6)!==0)throw Error(r(327));if(g!==null){if(g===h.current)throw Error(r(177));if(I=g.lanes|g.childLanes,I|=tE,Ft(h,_,I,ee,ve,ze),h===jr&&(In=jr=null,Bn=0),ap=g,hd=h,Hc=_,cC=I,uC=P,PF=M,(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,Xie(ie,function(){return KF(),null})):(h.callbackNode=null,h.callbackPriority=0),M=(g.flags&13878)!==0,(g.subtreeFlags&13878)!==0||M){M=$.T,$.T=null,P=q.p,q.p=2,ee=or,or|=4;try{Fie(h,g,_)}finally{or=ee,q.p=P,$.T=M}}$i=1,VF(),GF(),qF()}}function VF(){if($i===1){$i=0;var h=hd,g=ap,_=(g.flags&13878)!==0;if((g.subtreeFlags&13878)!==0||_){_=$.T,$.T=null;var M=q.p;q.p=2;var P=or;or|=4;try{NF(g,h);var I=MC,ee=k5(h.containerInfo),ve=I.focusedElem,ze=I.selectionRange;if(ee!==ve&&ve&&ve.ownerDocument&&A5(ve.ownerDocument.documentElement,ve)){if(ze!==null&&YM(ve)){var rt=ze.start,gt=ze.end;if(gt===void 0&&(gt=rt),"selectionStart"in ve)ve.selectionStart=rt,ve.selectionEnd=Math.min(gt,ve.value.length);else{var vt=ve.ownerDocument||document,ot=vt&&vt.defaultView||window;if(ot.getSelection){var pt=ot.getSelection(),Gt=ve.textContent.length,rn=Math.min(ze.start,Gt),_r=ze.end===void 0?rn:Math.min(ze.end,Gt);!pt.extend&&rn>_r&&(ee=_r,_r=rn,rn=ee);var Ye=T5(ve,rn),Ge=T5(ve,_r);if(Ye&&Ge&&(pt.rangeCount!==1||pt.anchorNode!==Ye.node||pt.anchorOffset!==Ye.offset||pt.focusNode!==Ge.node||pt.focusOffset!==Ge.offset)){var nt=vt.createRange();nt.setStart(Ye.node,Ye.offset),pt.removeAllRanges(),rn>_r?(pt.addRange(nt),pt.extend(Ge.node,Ge.offset)):(nt.setEnd(Ge.node,Ge.offset),pt.addRange(nt))}}}}for(vt=[],pt=ve;pt=pt.parentNode;)pt.nodeType===1&&vt.push({element:pt,left:pt.scrollLeft,top:pt.scrollTop});for(typeof ve.focus=="function"&&ve.focus(),ve=0;ve<vt.length;ve++){var bt=vt[ve];bt.element.scrollLeft=bt.left,bt.element.scrollTop=bt.top}}S_=!!NC,MC=NC=null}finally{or=P,q.p=M,$.T=_}}h.current=g,$i=2}}function GF(){if($i===2){$i=0;var h=hd,g=ap,_=(g.flags&8772)!==0;if((g.subtreeFlags&8772)!==0||_){_=$.T,$.T=null;var M=q.p;q.p=2;var P=or;or|=4;try{yF(h,g.alternate,g)}finally{or=P,q.p=M,$.T=_}}$i=3}}function qF(){if($i===4||$i===3){$i=0,V();var h=hd,g=ap,_=Hc,M=PF;(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?$i=5:($i=0,ap=hd=null,WF(h,h.pendingLanes));var P=h.pendingLanes;if(P===0&&(dd=null),Jn(_),g=g.stateNode,ae&&typeof ae.onCommitFiberRoot=="function")try{ae.onCommitFiberRoot(Ie,g,void 0,(g.current.flags&128)===128)}catch{}if(M!==null){g=$.T,P=q.p,q.p=2,$.T=null;try{for(var I=h.onRecoverableError,ee=0;ee<M.length;ee++){var ve=M[ee];I(ve.value,{componentStack:ve.stack})}}finally{$.T=g,q.p=P}}(Hc&3)!==0&&d_(),Kl(h),P=h.pendingLanes,(_&261930)!==0&&(P&42)!==0?h===dC?xb++:(xb=0,dC=h):xb=0,bb(0)}}function WF(h,g){(h.pooledCacheLanes&=g)===0&&(g=h.pooledCache,g!=null&&(h.pooledCache=null,Zx(g)))}function d_(){return VF(),GF(),qF(),KF()}function KF(){if($i!==5)return!1;var h=hd,g=cC;cC=0;var _=Jn(Hc),M=$.T,P=q.p;try{q.p=32>_?32:_,$.T=null,_=uC,uC=null;var I=hd,ee=Hc;if($i=0,ap=hd=null,Hc=0,(or&6)!==0)throw Error(r(331));var ve=or;if(or|=4,AF(I.current),EF(I,I.current,ee,_),or=ve,bb(0,!1),ae&&typeof ae.onPostCommitFiberRoot=="function")try{ae.onPostCommitFiberRoot(Ie,I)}catch{}return!0}finally{q.p=P,$.T=M,WF(h,g)}}function XF(h,g,_){g=Co(_,g),g=HE(h.stateNode,g,2),h=ad(h,g,2),h!==null&&(It(h,2),Kl(h))}function fr(h,g,_){if(h.tag===3)XF(h,h,_);else for(;g!==null;){if(g.tag===3){XF(g,h,_);break}else if(g.tag===1){var M=g.stateNode;if(typeof g.type.getDerivedStateFromError=="function"||typeof M.componentDidCatch=="function"&&(dd===null||!dd.has(M))){h=Co(_,h),_=YI(2),M=ad(g,_,2),M!==null&&(QI(_,M,g,h),It(M,2),Kl(M));break}}g=g.return}}function mC(h,g,_){var M=h.pingCache;if(M===null){M=h.pingCache=new Bie;var P=new Set;M.set(g,P)}else P=M.get(g),P===void 0&&(P=new Set,M.set(g,P));P.has(_)||(sC=!0,P.add(_),h=qie.bind(null,h,g,_),g.then(h,h))}function qie(h,g,_){var M=h.pingCache;M!==null&&M.delete(g),h.pingedLanes|=h.suspendedLanes&_,h.warmLanes&=~_,jr===h&&(Bn&_)===_&&(li===4||li===3&&(Bn&62914560)===Bn&&300>L()-a_?(or&2)===0&&sp(h,0):oC|=_,ip===Bn&&(ip=0)),Kl(h)}function YF(h,g){g===0&&(g=yt()),h=Wh(h,g),h!==null&&(It(h,g),Kl(h))}function Wie(h){var g=h.memoizedState,_=0;g!==null&&(_=g.retryLane),YF(h,_)}function Kie(h,g){var _=0;switch(h.tag){case 31:case 13:var M=h.stateNode,P=h.memoizedState;P!==null&&(_=P.retryLane);break;case 19:M=h.stateNode;break;case 22:M=h.stateNode._retryCache;break;default:throw Error(r(314))}M!==null&&M.delete(g),YF(h,_)}function Xie(h,g){return Ee(h,g)}var h_=null,lp=null,pC=!1,f_=!1,gC=!1,md=0;function Kl(h){h!==lp&&h.next===null&&(lp===null?h_=lp=h:lp=lp.next=h),f_=!0,pC||(pC=!0,Qie())}function bb(h,g){if(!gC&&f_){gC=!0;do for(var _=!1,M=h_;M!==null;){if(h!==0){var P=M.pendingLanes;if(P===0)var I=0;else{var ee=M.suspendedLanes,ve=M.pingedLanes;I=(1<<31-Se(42|h)+1)-1,I&=P&~(ee&~ve),I=I&201326741?I&201326741|1:I?I|2:0}I!==0&&(_=!0,eU(M,I))}else I=Bn,I=Ce(M,M===jr?I:0,M.cancelPendingCommit!==null||M.timeoutHandle!==-1),(I&3)===0||de(M,I)||(_=!0,eU(M,I));M=M.next}while(_);gC=!1}}function Yie(){QF()}function QF(){f_=pC=!1;var h=0;md!==0&&oae()&&(h=md);for(var g=L(),_=null,M=h_;M!==null;){var P=M.next,I=ZF(M,g);I===0?(M.next=null,_===null?h_=P:_.next=P,P===null&&(lp=_)):(_=M,(h!==0||(I&3)!==0)&&(f_=!0)),M=P}$i!==0&&$i!==5||bb(h),md!==0&&(md=0)}function ZF(h,g){for(var _=h.suspendedLanes,M=h.pingedLanes,P=h.expirationTimes,I=h.pendingLanes&-62914561;0<I;){var ee=31-Se(I),ve=1<<ee,ze=P[ee];ze===-1?((ve&_)===0||(ve&M)!==0)&&(P[ee]=Ve(ve,g)):ze<=g&&(h.expiredLanes|=ve),I&=~ve}if(g=jr,_=Bn,_=Ce(h,h===g?_:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),M=h.callbackNode,_===0||h===g&&(hr===2||hr===9)||h.cancelPendingCommit!==null)return M!==null&&M!==null&&_e(M),h.callbackNode=null,h.callbackPriority=0;if((_&3)===0||de(h,_)){if(g=_&-_,g===h.callbackPriority)return g;switch(M!==null&&_e(M),Jn(_)){case 2:case 8:_=Me;break;case 32:_=ie;break;case 268435456:_=Le;break;default:_=ie}return M=JF.bind(null,h),_=Ee(_,M),h.callbackPriority=g,h.callbackNode=_,g}return M!==null&&M!==null&&_e(M),h.callbackPriority=2,h.callbackNode=null,2}function JF(h,g){if($i!==0&&$i!==5)return h.callbackNode=null,h.callbackPriority=0,null;var _=h.callbackNode;if(d_()&&h.callbackNode!==_)return null;var M=Bn;return M=Ce(h,h===jr?M:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),M===0?null:(DF(h,M,g),ZF(h,L()),h.callbackNode!=null&&h.callbackNode===_?JF.bind(null,h):null)}function eU(h,g){if(d_())return null;DF(h,g,!0)}function Qie(){cae(function(){(or&6)!==0?Ee(te,Yie):QF()})}function xC(){if(md===0){var h=Wm;h===0&&(h=tt,tt<<=1,(tt&261888)===0&&(tt=256)),md=h}return md}function tU(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:aa(""+h)}function nU(h,g){var _=g.ownerDocument.createElement("input");return _.name=g.name,_.value=g.value,h.id&&_.setAttribute("form",h.id),g.parentNode.insertBefore(_,g),h=new FormData(h),_.parentNode.removeChild(_),h}function Zie(h,g,_,M,P){if(g==="submit"&&_&&_.stateNode===P){var I=tU((P[bn]||null).action),ee=M.submitter;ee&&(g=(g=ee[bn]||null)?tU(g.formAction):ee.getAttribute("formAction"),g!==null&&(I=g,ee=null));var ve=new Vl("action","action",null,M,P);h.push({event:ve,listeners:[{instance:null,listener:function(){if(M.defaultPrevented){if(md!==0){var ze=ee?nU(P,ee):new FormData(P);IE(_,{pending:!0,data:ze,method:P.method,action:I},null,ze)}}else typeof I=="function"&&(ve.preventDefault(),ze=ee?nU(P,ee):new FormData(P),IE(_,{pending:!0,data:ze,method:P.method,action:I},I,ze))},currentTarget:P}]})}}for(var bC=0;bC<eE.length;bC++){var yC=eE[bC],Jie=yC.toLowerCase(),eae=yC[0].toUpperCase()+yC.slice(1);xl(Jie,"on"+eae)}xl(R5,"onAnimationEnd"),xl(D5,"onAnimationIteration"),xl(O5,"onAnimationStart"),xl("dblclick","onDoubleClick"),xl("focusin","onFocus"),xl("focusout","onBlur"),xl(gie,"onTransitionRun"),xl(xie,"onTransitionStart"),xl(bie,"onTransitionCancel"),xl(L5,"onTransitionEnd"),Ct("onMouseEnter",["mouseout","mouseover"]),Ct("onMouseLeave",["mouseout","mouseover"]),Ct("onPointerEnter",["pointerout","pointerover"]),Ct("onPointerLeave",["pointerout","pointerover"]),Nt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Nt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Nt("onBeforeInput",["compositionend","keypress","textInput","paste"]),Nt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Nt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Nt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var yb="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(" "),tae=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(yb));function rU(h,g){g=(g&4)!==0;for(var _=0;_<h.length;_++){var M=h[_],P=M.event;M=M.listeners;e:{var I=void 0;if(g)for(var ee=M.length-1;0<=ee;ee--){var ve=M[ee],ze=ve.instance,rt=ve.currentTarget;if(ve=ve.listener,ze!==I&&P.isPropagationStopped())break e;I=ve,P.currentTarget=rt;try{I(P)}catch(gt){Tv(gt)}P.currentTarget=null,I=ze}else for(ee=0;ee<M.length;ee++){if(ve=M[ee],ze=ve.instance,rt=ve.currentTarget,ve=ve.listener,ze!==I&&P.isPropagationStopped())break e;I=ve,P.currentTarget=rt;try{I(P)}catch(gt){Tv(gt)}P.currentTarget=null,I=ze}}}}function Fn(h,g){var _=g[Ia];_===void 0&&(_=g[Ia]=new Set);var M=h+"__bubble";_.has(M)||(iU(g,h,2,!1),_.add(M))}function vC(h,g,_){var M=0;g&&(M|=4),iU(_,h,M,g)}var m_="_reactListening"+Math.random().toString(36).slice(2);function _C(h){if(!h[m_]){h[m_]=!0,je.forEach(function(_){_!=="selectionchange"&&(tae.has(_)||vC(_,!1,h),vC(_,!0,h))});var g=h.nodeType===9?h:h.ownerDocument;g===null||g[m_]||(g[m_]=!0,vC("selectionchange",!1,g))}}function iU(h,g,_,M){switch(RU(g)){case 2:var P=Aae;break;case 8:P=kae;break;default:P=LC}_=P.bind(null,g,_,h),P=void 0,!zx||g!=="touchstart"&&g!=="touchmove"&&g!=="wheel"||(P=!0),M?P!==void 0?h.addEventListener(g,_,{capture:!0,passive:P}):h.addEventListener(g,_,!0):P!==void 0?h.addEventListener(g,_,{passive:P}):h.addEventListener(g,_,!1)}function wC(h,g,_,M,P){var I=M;if((g&1)===0&&(g&2)===0&&M!==null)e:for(;;){if(M===null)return;var ee=M.tag;if(ee===3||ee===4){var ve=M.stateNode.containerInfo;if(ve===P)break;if(ee===4)for(ee=M.return;ee!==null;){var ze=ee.tag;if((ze===3||ze===4)&&ee.stateNode.containerInfo===P)return;ee=ee.return}for(;ve!==null;){if(ee=jt(ve),ee===null)return;if(ze=ee.tag,ze===5||ze===6||ze===26||ze===27){M=I=ee;continue e}ve=ve.parentNode}}M=M.return}Ux(function(){var rt=I,gt=is(_),vt=[];e:{var ot=I5.get(h);if(ot!==void 0){var pt=Vl,Gt=h;switch(h){case"keypress":if(Vh(_)===0)break e;case"keydown":case"keyup":pt=Kre;break;case"focusin":Gt="focus",pt=Im;break;case"focusout":Gt="blur",pt=Im;break;case"beforeblur":case"afterblur":pt=Im;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":pt=Nv;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":pt=Mv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":pt=Qre;break;case R5:case D5:case O5:pt=Ev;break;case L5:pt=Jre;break;case"scroll":case"scrollend":pt=Dm;break;case"wheel":pt=tie;break;case"copy":case"cut":case"paste":pt=_t;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":pt=m5;break;case"toggle":case"beforetoggle":pt=rie}var rn=(g&4)!==0,_r=!rn&&(h==="scroll"||h==="scrollend"),Ye=rn?ot!==null?ot+"Capture":null:ot;rn=[];for(var Ge=rt,nt;Ge!==null;){var bt=Ge;if(nt=bt.stateNode,bt=bt.tag,bt!==5&&bt!==26&&bt!==27||nt===null||Ye===null||(bt=No(Ge,Ye),bt!=null&&rn.push(vb(Ge,bt,nt))),_r)break;Ge=Ge.return}0<rn.length&&(ot=new pt(ot,Gt,null,_,gt),vt.push({event:ot,listeners:rn}))}}if((g&7)===0){e:{if(ot=h==="mouseover"||h==="pointerover",pt=h==="mouseout"||h==="pointerout",ot&&_!==fl&&(Gt=_.relatedTarget||_.fromElement)&&(jt(Gt)||Gt[xi]))break e;if((pt||ot)&&(ot=gt.window===gt?gt:(ot=gt.ownerDocument)?ot.defaultView||ot.parentWindow:window,pt?(Gt=_.relatedTarget||_.toElement,pt=rt,Gt=Gt?jt(Gt):null,Gt!==null&&(_r=s(Gt),rn=Gt.tag,Gt!==_r||rn!==5&&rn!==27&&rn!==6)&&(Gt=null)):(pt=null,Gt=rt),pt!==Gt)){if(rn=Nv,bt="onMouseLeave",Ye="onMouseEnter",Ge="mouse",(h==="pointerout"||h==="pointerover")&&(rn=m5,bt="onPointerLeave",Ye="onPointerEnter",Ge="pointer"),_r=pt==null?ot:me(pt),nt=Gt==null?ot:me(Gt),ot=new rn(bt,Ge+"leave",pt,_,gt),ot.target=_r,ot.relatedTarget=nt,bt=null,jt(gt)===rt&&(rn=new rn(Ye,Ge+"enter",Gt,_,gt),rn.target=nt,rn.relatedTarget=_r,bt=rn),_r=bt,pt&&Gt)t:{for(rn=nae,Ye=pt,Ge=Gt,nt=0,bt=Ye;bt;bt=rn(bt))nt++;bt=0;for(var Yt=Ge;Yt;Yt=rn(Yt))bt++;for(;0<nt-bt;)Ye=rn(Ye),nt--;for(;0<bt-nt;)Ge=rn(Ge),bt--;for(;nt--;){if(Ye===Ge||Ge!==null&&Ye===Ge.alternate){rn=Ye;break t}Ye=rn(Ye),Ge=rn(Ge)}rn=null}else rn=null;pt!==null&&aU(vt,ot,pt,rn,!1),Gt!==null&&_r!==null&&aU(vt,_r,Gt,rn,!0)}}e:{if(ot=rt?me(rt):window,pt=ot.nodeName&&ot.nodeName.toLowerCase(),pt==="select"||pt==="input"&&ot.type==="file")var rr=w5;else if(v5(ot))if(S5)rr=fie;else{rr=die;var Wt=uie}else pt=ot.nodeName,!pt||pt.toLowerCase()!=="input"||ot.type!=="checkbox"&&ot.type!=="radio"?rt&&Sn(rt.elementType)&&(rr=w5):rr=hie;if(rr&&(rr=rr(h,rt))){_5(vt,rr,_,gt);break e}Wt&&Wt(h,ot,rt),h==="focusout"&&rt&&ot.type==="number"&&rt.memoizedProps.value!=null&&qt(ot,"number",ot.value)}switch(Wt=rt?me(rt):window,h){case"focusin":(v5(Wt)||Wt.contentEditable==="true")&&(Um=Wt,QM=rt,Xx=null);break;case"focusout":Xx=QM=Um=null;break;case"mousedown":ZM=!0;break;case"contextmenu":case"mouseup":case"dragend":ZM=!1,j5(vt,_,gt);break;case"selectionchange":if(pie)break;case"keydown":case"keyup":j5(vt,_,gt)}var Nn;if(WM)e:{switch(h){case"compositionstart":var $n="onCompositionStart";break e;case"compositionend":$n="onCompositionEnd";break e;case"compositionupdate":$n="onCompositionUpdate";break e}$n=void 0}else Fm?b5(h,_)&&($n="onCompositionEnd"):h==="keydown"&&_.keyCode===229&&($n="onCompositionStart");$n&&(p5&&_.locale!=="ko"&&(Fm||$n!=="onCompositionStart"?$n==="onCompositionEnd"&&Fm&&(Nn=Rm()):(Hl=gt,Bx="value"in Hl?Hl.value:Hl.textContent,Fm=!0)),Wt=p_(rt,$n),0<Wt.length&&($n=new Wn($n,h,null,_,gt),vt.push({event:$n,listeners:Wt}),Nn?$n.data=Nn:(Nn=y5(_),Nn!==null&&($n.data=Nn)))),(Nn=aie?sie(h,_):oie(h,_))&&($n=p_(rt,"onBeforeInput"),0<$n.length&&(Wt=new Wn("onBeforeInput","beforeinput",null,_,gt),vt.push({event:Wt,listeners:$n}),Wt.data=Nn)),Zie(vt,h,rt,_,gt)}rU(vt,g)})}function vb(h,g,_){return{instance:h,listener:g,currentTarget:_}}function p_(h,g){for(var _=g+"Capture",M=[];h!==null;){var P=h,I=P.stateNode;if(P=P.tag,P!==5&&P!==26&&P!==27||I===null||(P=No(h,_),P!=null&&M.unshift(vb(h,P,I)),P=No(h,g),P!=null&&M.push(vb(h,P,I))),h.tag===3)return M;h=h.return}return[]}function nae(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function aU(h,g,_,M,P){for(var I=g._reactName,ee=[];_!==null&&_!==M;){var ve=_,ze=ve.alternate,rt=ve.stateNode;if(ve=ve.tag,ze!==null&&ze===M)break;ve!==5&&ve!==26&&ve!==27||rt===null||(ze=rt,P?(rt=No(_,I),rt!=null&&ee.unshift(vb(_,rt,ze))):P||(rt=No(_,I),rt!=null&&ee.push(vb(_,rt,ze)))),_=_.return}ee.length!==0&&h.push({event:g,listeners:ee})}var rae=/\r\n?/g,iae=/\u0000|\uFFFD/g;function sU(h){return(typeof h=="string"?h:""+h).replace(rae,`
  9. `).replace(iae,"")}function oU(h,g){return g=sU(g),sU(h)===g}function vr(h,g,_,M,P,I){switch(_){case"children":typeof M=="string"?g==="body"||g==="textarea"&&M===""||tr(h,M):(typeof M=="number"||typeof M=="bigint")&&g!=="body"&&tr(h,""+M);break;case"className":$t(h,"class",M);break;case"tabIndex":$t(h,"tabindex",M);break;case"dir":case"role":case"viewBox":case"width":case"height":$t(h,_,M);break;case"style":sn(h,M,I);break;case"data":if(g!=="object"){$t(h,"data",M);break}case"src":case"href":if(M===""&&(g!=="a"||_!=="href")){h.removeAttribute(_);break}if(M==null||typeof M=="function"||typeof M=="symbol"||typeof M=="boolean"){h.removeAttribute(_);break}M=aa(""+M),h.setAttribute(_,M);break;case"action":case"formAction":if(typeof M=="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 I=="function"&&(_==="formAction"?(g!=="input"&&vr(h,g,"name",P.name,P,null),vr(h,g,"formEncType",P.formEncType,P,null),vr(h,g,"formMethod",P.formMethod,P,null),vr(h,g,"formTarget",P.formTarget,P,null)):(vr(h,g,"encType",P.encType,P,null),vr(h,g,"method",P.method,P,null),vr(h,g,"target",P.target,P,null)));if(M==null||typeof M=="symbol"||typeof M=="boolean"){h.removeAttribute(_);break}M=aa(""+M),h.setAttribute(_,M);break;case"onClick":M!=null&&(h.onclick=rs);break;case"onScroll":M!=null&&Fn("scroll",h);break;case"onScrollEnd":M!=null&&Fn("scrollend",h);break;case"dangerouslySetInnerHTML":if(M!=null){if(typeof M!="object"||!("__html"in M))throw Error(r(61));if(_=M.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"multiple":h.multiple=M&&typeof M!="function"&&typeof M!="symbol";break;case"muted":h.muted=M&&typeof M!="function"&&typeof M!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(M==null||typeof M=="function"||typeof M=="boolean"||typeof M=="symbol"){h.removeAttribute("xlink:href");break}_=aa(""+M),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":M!=null&&typeof M!="function"&&typeof M!="symbol"?h.setAttribute(_,""+M):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":M&&typeof M!="function"&&typeof M!="symbol"?h.setAttribute(_,""):h.removeAttribute(_);break;case"capture":case"download":M===!0?h.setAttribute(_,""):M!==!1&&M!=null&&typeof M!="function"&&typeof M!="symbol"?h.setAttribute(_,M):h.removeAttribute(_);break;case"cols":case"rows":case"size":case"span":M!=null&&typeof M!="function"&&typeof M!="symbol"&&!isNaN(M)&&1<=M?h.setAttribute(_,M):h.removeAttribute(_);break;case"rowSpan":case"start":M==null||typeof M=="function"||typeof M=="symbol"||isNaN(M)?h.removeAttribute(_):h.setAttribute(_,M);break;case"popover":Fn("beforetoggle",h),Fn("toggle",h),Zt(h,"popover",M);break;case"xlinkActuate":un(h,"http://www.w3.org/1999/xlink","xlink:actuate",M);break;case"xlinkArcrole":un(h,"http://www.w3.org/1999/xlink","xlink:arcrole",M);break;case"xlinkRole":un(h,"http://www.w3.org/1999/xlink","xlink:role",M);break;case"xlinkShow":un(h,"http://www.w3.org/1999/xlink","xlink:show",M);break;case"xlinkTitle":un(h,"http://www.w3.org/1999/xlink","xlink:title",M);break;case"xlinkType":un(h,"http://www.w3.org/1999/xlink","xlink:type",M);break;case"xmlBase":un(h,"http://www.w3.org/XML/1998/namespace","xml:base",M);break;case"xmlLang":un(h,"http://www.w3.org/XML/1998/namespace","xml:lang",M);break;case"xmlSpace":un(h,"http://www.w3.org/XML/1998/namespace","xml:space",M);break;case"is":Zt(h,"is",M);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=ns.get(_)||_,Zt(h,_,M))}}function SC(h,g,_,M,P,I){switch(_){case"style":sn(h,M,I);break;case"dangerouslySetInnerHTML":if(M!=null){if(typeof M!="object"||!("__html"in M))throw Error(r(61));if(_=M.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"children":typeof M=="string"?tr(h,M):(typeof M=="number"||typeof M=="bigint")&&tr(h,""+M);break;case"onScroll":M!=null&&Fn("scroll",h);break;case"onScrollEnd":M!=null&&Fn("scrollend",h);break;case"onClick":M!=null&&(h.onclick=rs);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ht.hasOwnProperty(_))e:{if(_[0]==="o"&&_[1]==="n"&&(P=_.endsWith("Capture"),g=_.slice(2,P?_.length-7:void 0),I=h[bn]||null,I=I!=null?I[_]:null,typeof I=="function"&&h.removeEventListener(g,I,P),typeof M=="function")){typeof I!="function"&&I!==null&&(_ in h?h[_]=null:h.hasAttribute(_)&&h.removeAttribute(_)),h.addEventListener(g,M,P);break e}_ in h?h[_]=M:M===!0?h.setAttribute(_,""):Zt(h,_,M)}}}function Na(h,g,_){switch(g){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Fn("error",h),Fn("load",h);var M=!1,P=!1,I;for(I in _)if(_.hasOwnProperty(I)){var ee=_[I];if(ee!=null)switch(I){case"src":M=!0;break;case"srcSet":P=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:vr(h,g,I,ee,_,null)}}P&&vr(h,g,"srcSet",_.srcSet,_,null),M&&vr(h,g,"src",_.src,_,null);return;case"input":Fn("invalid",h);var ve=I=ee=P=null,ze=null,rt=null;for(M in _)if(_.hasOwnProperty(M)){var gt=_[M];if(gt!=null)switch(M){case"name":P=gt;break;case"type":ee=gt;break;case"checked":ze=gt;break;case"defaultChecked":rt=gt;break;case"value":I=gt;break;case"defaultValue":ve=gt;break;case"children":case"dangerouslySetInnerHTML":if(gt!=null)throw Error(r(137,g));break;default:vr(h,g,M,gt,_,null)}}Tt(h,I,ve,ze,rt,ee,P,!1);return;case"select":Fn("invalid",h),M=ee=I=null;for(P in _)if(_.hasOwnProperty(P)&&(ve=_[P],ve!=null))switch(P){case"value":I=ve;break;case"defaultValue":ee=ve;break;case"multiple":M=ve;default:vr(h,g,P,ve,_,null)}g=I,_=ee,h.multiple=!!M,g!=null?xt(h,!!M,g,!1):_!=null&&xt(h,!!M,_,!0);return;case"textarea":Fn("invalid",h),I=P=M=null;for(ee in _)if(_.hasOwnProperty(ee)&&(ve=_[ee],ve!=null))switch(ee){case"value":M=ve;break;case"defaultValue":P=ve;break;case"children":I=ve;break;case"dangerouslySetInnerHTML":if(ve!=null)throw Error(r(91));break;default:vr(h,g,ee,ve,_,null)}gn(h,M,P,I);return;case"option":for(ze in _)if(_.hasOwnProperty(ze)&&(M=_[ze],M!=null))switch(ze){case"selected":h.selected=M&&typeof M!="function"&&typeof M!="symbol";break;default:vr(h,g,ze,M,_,null)}return;case"dialog":Fn("beforetoggle",h),Fn("toggle",h),Fn("cancel",h),Fn("close",h);break;case"iframe":case"object":Fn("load",h);break;case"video":case"audio":for(M=0;M<yb.length;M++)Fn(yb[M],h);break;case"image":Fn("error",h),Fn("load",h);break;case"details":Fn("toggle",h);break;case"embed":case"source":case"link":Fn("error",h),Fn("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(rt in _)if(_.hasOwnProperty(rt)&&(M=_[rt],M!=null))switch(rt){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:vr(h,g,rt,M,_,null)}return;default:if(Sn(g)){for(gt in _)_.hasOwnProperty(gt)&&(M=_[gt],M!==void 0&&SC(h,g,gt,M,_,void 0));return}}for(ve in _)_.hasOwnProperty(ve)&&(M=_[ve],M!=null&&vr(h,g,ve,M,_,null))}function aae(h,g,_,M){switch(g){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var P=null,I=null,ee=null,ve=null,ze=null,rt=null,gt=null;for(pt in _){var vt=_[pt];if(_.hasOwnProperty(pt)&&vt!=null)switch(pt){case"checked":break;case"value":break;case"defaultValue":ze=vt;default:M.hasOwnProperty(pt)||vr(h,g,pt,null,M,vt)}}for(var ot in M){var pt=M[ot];if(vt=_[ot],M.hasOwnProperty(ot)&&(pt!=null||vt!=null))switch(ot){case"type":I=pt;break;case"name":P=pt;break;case"checked":rt=pt;break;case"defaultChecked":gt=pt;break;case"value":ee=pt;break;case"defaultValue":ve=pt;break;case"children":case"dangerouslySetInnerHTML":if(pt!=null)throw Error(r(137,g));break;default:pt!==vt&&vr(h,g,ot,pt,M,vt)}}Qe(h,ee,ve,ze,rt,gt,I,P);return;case"select":pt=ee=ve=ot=null;for(I in _)if(ze=_[I],_.hasOwnProperty(I)&&ze!=null)switch(I){case"value":break;case"multiple":pt=ze;default:M.hasOwnProperty(I)||vr(h,g,I,null,M,ze)}for(P in M)if(I=M[P],ze=_[P],M.hasOwnProperty(P)&&(I!=null||ze!=null))switch(P){case"value":ot=I;break;case"defaultValue":ve=I;break;case"multiple":ee=I;default:I!==ze&&vr(h,g,P,I,M,ze)}g=ve,_=ee,M=pt,ot!=null?xt(h,!!_,ot,!1):!!M!=!!_&&(g!=null?xt(h,!!_,g,!0):xt(h,!!_,_?[]:"",!1));return;case"textarea":pt=ot=null;for(ve in _)if(P=_[ve],_.hasOwnProperty(ve)&&P!=null&&!M.hasOwnProperty(ve))switch(ve){case"value":break;case"children":break;default:vr(h,g,ve,null,M,P)}for(ee in M)if(P=M[ee],I=_[ee],M.hasOwnProperty(ee)&&(P!=null||I!=null))switch(ee){case"value":ot=P;break;case"defaultValue":pt=P;break;case"children":break;case"dangerouslySetInnerHTML":if(P!=null)throw Error(r(91));break;default:P!==I&&vr(h,g,ee,P,M,I)}nn(h,ot,pt);return;case"option":for(var Gt in _)if(ot=_[Gt],_.hasOwnProperty(Gt)&&ot!=null&&!M.hasOwnProperty(Gt))switch(Gt){case"selected":h.selected=!1;break;default:vr(h,g,Gt,null,M,ot)}for(ze in M)if(ot=M[ze],pt=_[ze],M.hasOwnProperty(ze)&&ot!==pt&&(ot!=null||pt!=null))switch(ze){case"selected":h.selected=ot&&typeof ot!="function"&&typeof ot!="symbol";break;default:vr(h,g,ze,ot,M,pt)}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 rn in _)ot=_[rn],_.hasOwnProperty(rn)&&ot!=null&&!M.hasOwnProperty(rn)&&vr(h,g,rn,null,M,ot);for(rt in M)if(ot=M[rt],pt=_[rt],M.hasOwnProperty(rt)&&ot!==pt&&(ot!=null||pt!=null))switch(rt){case"children":case"dangerouslySetInnerHTML":if(ot!=null)throw Error(r(137,g));break;default:vr(h,g,rt,ot,M,pt)}return;default:if(Sn(g)){for(var _r in _)ot=_[_r],_.hasOwnProperty(_r)&&ot!==void 0&&!M.hasOwnProperty(_r)&&SC(h,g,_r,void 0,M,ot);for(gt in M)ot=M[gt],pt=_[gt],!M.hasOwnProperty(gt)||ot===pt||ot===void 0&&pt===void 0||SC(h,g,gt,ot,M,pt);return}}for(var Ye in _)ot=_[Ye],_.hasOwnProperty(Ye)&&ot!=null&&!M.hasOwnProperty(Ye)&&vr(h,g,Ye,null,M,ot);for(vt in M)ot=M[vt],pt=_[vt],!M.hasOwnProperty(vt)||ot===pt||ot==null&&pt==null||vr(h,g,vt,ot,M,pt)}function lU(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function sae(){if(typeof performance.getEntriesByType=="function"){for(var h=0,g=0,_=performance.getEntriesByType("resource"),M=0;M<_.length;M++){var P=_[M],I=P.transferSize,ee=P.initiatorType,ve=P.duration;if(I&&ve&&lU(ee)){for(ee=0,ve=P.responseEnd,M+=1;M<_.length;M++){var ze=_[M],rt=ze.startTime;if(rt>ve)break;var gt=ze.transferSize,vt=ze.initiatorType;gt&&lU(vt)&&(ze=ze.responseEnd,ee+=gt*(ze<ve?1:(ve-rt)/(ze-rt)))}if(--M,g+=8*(I+ee)/(P.duration/1e3),h++,10<h)break}}if(0<h)return g/h/1e6}return navigator.connection&&(h=navigator.connection.downlink,typeof h=="number")?h:5}var NC=null,MC=null;function g_(h){return h.nodeType===9?h:h.ownerDocument}function cU(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 uU(h,g){if(h===0)switch(g){case"svg":return 1;case"math":return 2;default:return 0}return h===1&&g==="foreignObject"?0:h}function EC(h,g){return h==="textarea"||h==="noscript"||typeof g.children=="string"||typeof g.children=="number"||typeof g.children=="bigint"||typeof g.dangerouslySetInnerHTML=="object"&&g.dangerouslySetInnerHTML!==null&&g.dangerouslySetInnerHTML.__html!=null}var CC=null;function oae(){var h=window.event;return h&&h.type==="popstate"?h===CC?!1:(CC=h,!0):(CC=null,!1)}var dU=typeof setTimeout=="function"?setTimeout:void 0,lae=typeof clearTimeout=="function"?clearTimeout:void 0,hU=typeof Promise=="function"?Promise:void 0,cae=typeof queueMicrotask=="function"?queueMicrotask:typeof hU<"u"?function(h){return hU.resolve(null).then(h).catch(uae)}:dU;function uae(h){setTimeout(function(){throw h})}function pd(h){return h==="head"}function fU(h,g){var _=g,M=0;do{var P=_.nextSibling;if(h.removeChild(_),P&&P.nodeType===8)if(_=P.data,_==="/$"||_==="/&"){if(M===0){h.removeChild(P),hp(g);return}M--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")M++;else if(_==="html")_b(h.ownerDocument.documentElement);else if(_==="head"){_=h.ownerDocument.head,_b(_);for(var I=_.firstChild;I;){var ee=I.nextSibling,ve=I.nodeName;I[dt]||ve==="SCRIPT"||ve==="STYLE"||ve==="LINK"&&I.rel.toLowerCase()==="stylesheet"||_.removeChild(I),I=ee}}else _==="body"&&_b(h.ownerDocument.body);_=P}while(_);hp(g)}function mU(h,g){var _=h;h=0;do{var M=_.nextSibling;if(_.nodeType===1?g?(_._stashedDisplay=_.style.display,_.style.display="none"):(_.style.display=_._stashedDisplay||"",_.getAttribute("style")===""&&_.removeAttribute("style")):_.nodeType===3&&(g?(_._stashedText=_.nodeValue,_.nodeValue=""):_.nodeValue=_._stashedText||""),M&&M.nodeType===8)if(_=M.data,_==="/$"){if(h===0)break;h--}else _!=="$"&&_!=="$?"&&_!=="$~"&&_!=="$!"||h++;_=M}while(_)}function TC(h){var g=h.firstChild;for(g&&g.nodeType===10&&(g=g.nextSibling);g;){var _=g;switch(g=g.nextSibling,_.nodeName){case"HTML":case"HEAD":case"BODY":TC(_),st(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}h.removeChild(_)}}function dae(h,g,_,M){for(;h.nodeType===1;){var P=_;if(h.nodeName.toLowerCase()!==g.toLowerCase()){if(!M&&(h.nodeName!=="INPUT"||h.type!=="hidden"))break}else if(M){if(!h[dt])switch(g){case"meta":if(!h.hasAttribute("itemprop"))break;return h;case"link":if(I=h.getAttribute("rel"),I==="stylesheet"&&h.hasAttribute("data-precedence"))break;if(I!==P.rel||h.getAttribute("href")!==(P.href==null||P.href===""?null:P.href)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin)||h.getAttribute("title")!==(P.title==null?null:P.title))break;return h;case"style":if(h.hasAttribute("data-precedence"))break;return h;case"script":if(I=h.getAttribute("src"),(I!==(P.src==null?null:P.src)||h.getAttribute("type")!==(P.type==null?null:P.type)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin))&&I&&h.hasAttribute("async")&&!h.hasAttribute("itemprop"))break;return h;default:return h}}else if(g==="input"&&h.type==="hidden"){var I=P.name==null?null:""+P.name;if(P.type==="hidden"&&h.getAttribute("name")===I)return h}else return h;if(h=Po(h.nextSibling),h===null)break}return null}function hae(h,g,_){if(g==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!_||(h=Po(h.nextSibling),h===null))return null;return h}function pU(h,g){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!g||(h=Po(h.nextSibling),h===null))return null;return h}function AC(h){return h.data==="$?"||h.data==="$~"}function kC(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function fae(h,g){var _=h.ownerDocument;if(h.data==="$~")h._reactRetry=g;else if(h.data!=="$?"||_.readyState!=="loading")g();else{var M=function(){g(),_.removeEventListener("DOMContentLoaded",M)};_.addEventListener("DOMContentLoaded",M),h._reactRetry=M}}function Po(h){for(;h!=null;h=h.nextSibling){var g=h.nodeType;if(g===1||g===3)break;if(g===8){if(g=h.data,g==="$"||g==="$!"||g==="$?"||g==="$~"||g==="&"||g==="F!"||g==="F")break;if(g==="/$"||g==="/&")return null}}return h}var jC=null;function gU(h){h=h.nextSibling;for(var g=0;h;){if(h.nodeType===8){var _=h.data;if(_==="/$"||_==="/&"){if(g===0)return Po(h.nextSibling);g--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||g++}h=h.nextSibling}return null}function xU(h){h=h.previousSibling;for(var g=0;h;){if(h.nodeType===8){var _=h.data;if(_==="$"||_==="$!"||_==="$?"||_==="$~"||_==="&"){if(g===0)return h;g--}else _!=="/$"&&_!=="/&"||g++}h=h.previousSibling}return null}function bU(h,g,_){switch(g=g_(_),h){case"html":if(h=g.documentElement,!h)throw Error(r(452));return h;case"head":if(h=g.head,!h)throw Error(r(453));return h;case"body":if(h=g.body,!h)throw Error(r(454));return h;default:throw Error(r(451))}}function _b(h){for(var g=h.attributes;g.length;)h.removeAttributeNode(g[0]);st(h)}var Ro=new Map,yU=new Set;function x_(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var Vc=q.d;q.d={f:mae,r:pae,D:gae,C:xae,L:bae,m:yae,X:_ae,S:vae,M:wae};function mae(){var h=Vc.f(),g=l_();return h||g}function pae(h){var g=he(h);g!==null&&g.tag===5&&g.type==="form"?LI(g):Vc.r(h)}var cp=typeof document>"u"?null:document;function vU(h,g,_){var M=cp;if(M&&typeof g=="string"&&g){var P=qn(g);P='link[rel="'+h+'"][href="'+P+'"]',typeof _=="string"&&(P+='[crossorigin="'+_+'"]'),yU.has(P)||(yU.add(P),h={rel:h,crossOrigin:_,href:g},M.querySelector(P)===null&&(g=M.createElement("link"),Na(g,"link",h),Oe(g),M.head.appendChild(g)))}}function gae(h){Vc.D(h),vU("dns-prefetch",h,null)}function xae(h,g){Vc.C(h,g),vU("preconnect",h,g)}function bae(h,g,_){Vc.L(h,g,_);var M=cp;if(M&&h&&g){var P='link[rel="preload"][as="'+qn(g)+'"]';g==="image"&&_&&_.imageSrcSet?(P+='[imagesrcset="'+qn(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(P+='[imagesizes="'+qn(_.imageSizes)+'"]')):P+='[href="'+qn(h)+'"]';var I=P;switch(g){case"style":I=up(h);break;case"script":I=dp(h)}Ro.has(I)||(h=f({rel:"preload",href:g==="image"&&_&&_.imageSrcSet?void 0:h,as:g},_),Ro.set(I,h),M.querySelector(P)!==null||g==="style"&&M.querySelector(wb(I))||g==="script"&&M.querySelector(Sb(I))||(g=M.createElement("link"),Na(g,"link",h),Oe(g),M.head.appendChild(g)))}}function yae(h,g){Vc.m(h,g);var _=cp;if(_&&h){var M=g&&typeof g.as=="string"?g.as:"script",P='link[rel="modulepreload"][as="'+qn(M)+'"][href="'+qn(h)+'"]',I=P;switch(M){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":I=dp(h)}if(!Ro.has(I)&&(h=f({rel:"modulepreload",href:h},g),Ro.set(I,h),_.querySelector(P)===null)){switch(M){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(Sb(I)))return}M=_.createElement("link"),Na(M,"link",h),Oe(M),_.head.appendChild(M)}}}function vae(h,g,_){Vc.S(h,g,_);var M=cp;if(M&&h){var P=Fe(M).hoistableStyles,I=up(h);g=g||"default";var ee=P.get(I);if(!ee){var ve={loading:0,preload:null};if(ee=M.querySelector(wb(I)))ve.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":g},_),(_=Ro.get(I))&&PC(h,_);var ze=ee=M.createElement("link");Oe(ze),Na(ze,"link",h),ze._p=new Promise(function(rt,gt){ze.onload=rt,ze.onerror=gt}),ze.addEventListener("load",function(){ve.loading|=1}),ze.addEventListener("error",function(){ve.loading|=2}),ve.loading|=4,b_(ee,g,M)}ee={type:"stylesheet",instance:ee,count:1,state:ve},P.set(I,ee)}}}function _ae(h,g){Vc.X(h,g);var _=cp;if(_&&h){var M=Fe(_).hoistableScripts,P=dp(h),I=M.get(P);I||(I=_.querySelector(Sb(P)),I||(h=f({src:h,async:!0},g),(g=Ro.get(P))&&RC(h,g),I=_.createElement("script"),Oe(I),Na(I,"link",h),_.head.appendChild(I)),I={type:"script",instance:I,count:1,state:null},M.set(P,I))}}function wae(h,g){Vc.M(h,g);var _=cp;if(_&&h){var M=Fe(_).hoistableScripts,P=dp(h),I=M.get(P);I||(I=_.querySelector(Sb(P)),I||(h=f({src:h,async:!0,type:"module"},g),(g=Ro.get(P))&&RC(h,g),I=_.createElement("script"),Oe(I),Na(I,"link",h),_.head.appendChild(I)),I={type:"script",instance:I,count:1,state:null},M.set(P,I))}}function _U(h,g,_,M){var P=(P=fe.current)?x_(P):null;if(!P)throw Error(r(446));switch(h){case"meta":case"title":return null;case"style":return typeof _.precedence=="string"&&typeof _.href=="string"?(g=up(_.href),_=Fe(P).hoistableStyles,M=_.get(g),M||(M={type:"style",instance:null,count:0,state:null},_.set(g,M)),M):{type:"void",instance:null,count:0,state:null};case"link":if(_.rel==="stylesheet"&&typeof _.href=="string"&&typeof _.precedence=="string"){h=up(_.href);var I=Fe(P).hoistableStyles,ee=I.get(h);if(ee||(P=P.ownerDocument||P,ee={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},I.set(h,ee),(I=P.querySelector(wb(h)))&&!I._p&&(ee.instance=I,ee.state.loading=5),Ro.has(h)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},Ro.set(h,_),I||Sae(P,h,_,ee.state))),g&&M===null)throw Error(r(528,""));return ee}if(g&&M!==null)throw Error(r(529,""));return null;case"script":return g=_.async,_=_.src,typeof _=="string"&&g&&typeof g!="function"&&typeof g!="symbol"?(g=dp(_),_=Fe(P).hoistableScripts,M=_.get(g),M||(M={type:"script",instance:null,count:0,state:null},_.set(g,M)),M):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,h))}}function up(h){return'href="'+qn(h)+'"'}function wb(h){return'link[rel="stylesheet"]['+h+"]"}function wU(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function Sae(h,g,_,M){h.querySelector('link[rel="preload"][as="style"]['+g+"]")?M.loading=1:(g=h.createElement("link"),M.preload=g,g.addEventListener("load",function(){return M.loading|=1}),g.addEventListener("error",function(){return M.loading|=2}),Na(g,"link",_),Oe(g),h.head.appendChild(g))}function dp(h){return'[src="'+qn(h)+'"]'}function Sb(h){return"script[async]"+h}function SU(h,g,_){if(g.count++,g.instance===null)switch(g.type){case"style":var M=h.querySelector('style[data-href~="'+qn(_.href)+'"]');if(M)return g.instance=M,Oe(M),M;var P=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return M=(h.ownerDocument||h).createElement("style"),Oe(M),Na(M,"style",P),b_(M,_.precedence,h),g.instance=M;case"stylesheet":P=up(_.href);var I=h.querySelector(wb(P));if(I)return g.state.loading|=4,g.instance=I,Oe(I),I;M=wU(_),(P=Ro.get(P))&&PC(M,P),I=(h.ownerDocument||h).createElement("link"),Oe(I);var ee=I;return ee._p=new Promise(function(ve,ze){ee.onload=ve,ee.onerror=ze}),Na(I,"link",M),g.state.loading|=4,b_(I,_.precedence,h),g.instance=I;case"script":return I=dp(_.src),(P=h.querySelector(Sb(I)))?(g.instance=P,Oe(P),P):(M=_,(P=Ro.get(I))&&(M=f({},_),RC(M,P)),h=h.ownerDocument||h,P=h.createElement("script"),Oe(P),Na(P,"link",M),h.head.appendChild(P),g.instance=P);case"void":return null;default:throw Error(r(443,g.type))}else g.type==="stylesheet"&&(g.state.loading&4)===0&&(M=g.instance,g.state.loading|=4,b_(M,_.precedence,h));return g.instance}function b_(h,g,_){for(var M=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),P=M.length?M[M.length-1]:null,I=P,ee=0;ee<M.length;ee++){var ve=M[ee];if(ve.dataset.precedence===g)I=ve;else if(I!==P)break}I?I.parentNode.insertBefore(h,I.nextSibling):(g=_.nodeType===9?_.head:_,g.insertBefore(h,g.firstChild))}function PC(h,g){h.crossOrigin==null&&(h.crossOrigin=g.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=g.referrerPolicy),h.title==null&&(h.title=g.title)}function RC(h,g){h.crossOrigin==null&&(h.crossOrigin=g.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=g.referrerPolicy),h.integrity==null&&(h.integrity=g.integrity)}var y_=null;function NU(h,g,_){if(y_===null){var M=new Map,P=y_=new Map;P.set(_,M)}else P=y_,M=P.get(_),M||(M=new Map,P.set(_,M));if(M.has(h))return M;for(M.set(h,null),_=_.getElementsByTagName(h),P=0;P<_.length;P++){var I=_[P];if(!(I[dt]||I[er]||h==="link"&&I.getAttribute("rel")==="stylesheet")&&I.namespaceURI!=="http://www.w3.org/2000/svg"){var ee=I.getAttribute(g)||"";ee=h+ee;var ve=M.get(ee);ve?ve.push(I):M.set(ee,[I])}}return M}function MU(h,g,_){h=h.ownerDocument||h,h.head.insertBefore(_,g==="title"?h.querySelector("head > title"):null)}function Nae(h,g,_){if(_===1||g.itemProp!=null)return!1;switch(h){case"meta":case"title":return!0;case"style":if(typeof g.precedence!="string"||typeof g.href!="string"||g.href==="")break;return!0;case"link":if(typeof g.rel!="string"||typeof g.href!="string"||g.href===""||g.onLoad||g.onError)break;switch(g.rel){case"stylesheet":return h=g.disabled,typeof g.precedence=="string"&&h==null;default:return!0}case"script":if(g.async&&typeof g.async!="function"&&typeof g.async!="symbol"&&!g.onLoad&&!g.onError&&g.src&&typeof g.src=="string")return!0}return!1}function EU(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function Mae(h,g,_,M){if(_.type==="stylesheet"&&(typeof M.media!="string"||matchMedia(M.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var P=up(M.href),I=g.querySelector(wb(P));if(I){g=I._p,g!==null&&typeof g=="object"&&typeof g.then=="function"&&(h.count++,h=v_.bind(h),g.then(h,h)),_.state.loading|=4,_.instance=I,Oe(I);return}I=g.ownerDocument||g,M=wU(M),(P=Ro.get(P))&&PC(M,P),I=I.createElement("link"),Oe(I);var ee=I;ee._p=new Promise(function(ve,ze){ee.onload=ve,ee.onerror=ze}),Na(I,"link",M),_.instance=I}h.stylesheets===null&&(h.stylesheets=new Map),h.stylesheets.set(_,g),(g=_.state.preload)&&(_.state.loading&3)===0&&(h.count++,_=v_.bind(h),g.addEventListener("load",_),g.addEventListener("error",_))}}var DC=0;function Eae(h,g){return h.stylesheets&&h.count===0&&w_(h,h.stylesheets),0<h.count||0<h.imgCount?function(_){var M=setTimeout(function(){if(h.stylesheets&&w_(h,h.stylesheets),h.unsuspend){var I=h.unsuspend;h.unsuspend=null,I()}},6e4+g);0<h.imgBytes&&DC===0&&(DC=62500*sae());var P=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&w_(h,h.stylesheets),h.unsuspend)){var I=h.unsuspend;h.unsuspend=null,I()}},(h.imgBytes>DC?50:800)+g);return h.unsuspend=_,function(){h.unsuspend=null,clearTimeout(M),clearTimeout(P)}}:null}function v_(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)w_(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var __=null;function w_(h,g){h.stylesheets=null,h.unsuspend!==null&&(h.count++,__=new Map,g.forEach(Cae,h),__=null,v_.call(h))}function Cae(h,g){if(!(g.state.loading&4)){var _=__.get(h);if(_)var M=_.get(null);else{_=new Map,__.set(h,_);for(var P=h.querySelectorAll("link[data-precedence],style[data-precedence]"),I=0;I<P.length;I++){var ee=P[I];(ee.nodeName==="LINK"||ee.getAttribute("media")!=="not all")&&(_.set(ee.dataset.precedence,ee),M=ee)}M&&_.set(null,M)}P=g.instance,ee=P.getAttribute("data-precedence"),I=_.get(ee)||M,I===M&&_.set(null,P),_.set(ee,P),this.count++,M=v_.bind(this),P.addEventListener("load",M),P.addEventListener("error",M),I?I.parentNode.insertBefore(P,I.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(P,h.firstChild)),g.state.loading|=4}}var Nb={$$typeof:N,Provider:null,Consumer:null,_currentValue:Y,_currentValue2:Y,_threadCount:0};function Tae(h,g,_,M,P,I,ee,ve,ze){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=ut(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ut(0),this.hiddenUpdates=ut(null),this.identifierPrefix=M,this.onUncaughtError=P,this.onCaughtError=I,this.onRecoverableError=ee,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=ze,this.incompleteTransitions=new Map}function CU(h,g,_,M,P,I,ee,ve,ze,rt,gt,vt){return h=new Tae(h,g,_,ee,ze,rt,gt,vt,ve),g=1,I===!0&&(g|=24),I=Ys(3,null,null,g),h.current=I,I.stateNode=h,g=fE(),g.refCount++,h.pooledCache=g,g.refCount++,I.memoizedState={element:M,isDehydrated:_,cache:g},xE(I),h}function TU(h){return h?(h=$m,h):$m}function AU(h,g,_,M,P,I){P=TU(P),M.context===null?M.context=P:M.pendingContext=P,M=id(g),M.payload={element:_},I=I===void 0?null:I,I!==null&&(M.callback=I),_=ad(h,M,g),_!==null&&(js(_,h,g),nb(_,h,g))}function kU(h,g){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_<g?_:g}}function OC(h,g){kU(h,g),(h=h.alternate)&&kU(h,g)}function jU(h){if(h.tag===13||h.tag===31){var g=Wh(h,67108864);g!==null&&js(g,h,67108864),OC(h,67108864)}}function PU(h){if(h.tag===13||h.tag===31){var g=to();g=dr(g);var _=Wh(h,g);_!==null&&js(_,h,g),OC(h,g)}}var S_=!0;function Aae(h,g,_,M){var P=$.T;$.T=null;var I=q.p;try{q.p=2,LC(h,g,_,M)}finally{q.p=I,$.T=P}}function kae(h,g,_,M){var P=$.T;$.T=null;var I=q.p;try{q.p=8,LC(h,g,_,M)}finally{q.p=I,$.T=P}}function LC(h,g,_,M){if(S_){var P=IC(M);if(P===null)wC(h,g,M,N_,_),DU(h,M);else if(Pae(P,h,g,_,M))M.stopPropagation();else if(DU(h,M),g&4&&-1<jae.indexOf(h)){for(;P!==null;){var I=he(P);if(I!==null)switch(I.tag){case 3:if(I=I.stateNode,I.current.memoizedState.isDehydrated){var ee=pe(I.pendingLanes);if(ee!==0){var ve=I;for(ve.pendingLanes|=2,ve.entangledLanes|=2;ee;){var ze=1<<31-Se(ee);ve.entanglements[1]|=ze,ee&=~ze}Kl(I),(or&6)===0&&(s_=L()+500,bb(0))}}break;case 31:case 13:ve=Wh(I,2),ve!==null&&js(ve,I,2),l_(),OC(I,2)}if(I=IC(M),I===null&&wC(h,g,M,N_,_),I===P)break;P=I}P!==null&&M.stopPropagation()}else wC(h,g,M,null,_)}}function IC(h){return h=is(h),FC(h)}var N_=null;function FC(h){if(N_=null,h=jt(h),h!==null){var g=s(h);if(g===null)h=null;else{var _=g.tag;if(_===13){if(h=o(g),h!==null)return h;h=null}else if(_===31){if(h=l(g),h!==null)return h;h=null}else if(_===3){if(g.stateNode.current.memoizedState.isDehydrated)return g.tag===3?g.stateNode.containerInfo:null;h=null}else g!==h&&(h=null)}}return N_=h,null}function RU(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(X()){case te:return 2;case Me:return 8;case ie:case De:return 32;case Le:return 268435456;default:return 32}default:return 32}}var UC=!1,gd=null,xd=null,bd=null,Mb=new Map,Eb=new Map,yd=[],jae="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 DU(h,g){switch(h){case"focusin":case"focusout":gd=null;break;case"dragenter":case"dragleave":xd=null;break;case"mouseover":case"mouseout":bd=null;break;case"pointerover":case"pointerout":Mb.delete(g.pointerId);break;case"gotpointercapture":case"lostpointercapture":Eb.delete(g.pointerId)}}function Cb(h,g,_,M,P,I){return h===null||h.nativeEvent!==I?(h={blockedOn:g,domEventName:_,eventSystemFlags:M,nativeEvent:I,targetContainers:[P]},g!==null&&(g=he(g),g!==null&&jU(g)),h):(h.eventSystemFlags|=M,g=h.targetContainers,P!==null&&g.indexOf(P)===-1&&g.push(P),h)}function Pae(h,g,_,M,P){switch(g){case"focusin":return gd=Cb(gd,h,g,_,M,P),!0;case"dragenter":return xd=Cb(xd,h,g,_,M,P),!0;case"mouseover":return bd=Cb(bd,h,g,_,M,P),!0;case"pointerover":var I=P.pointerId;return Mb.set(I,Cb(Mb.get(I)||null,h,g,_,M,P)),!0;case"gotpointercapture":return I=P.pointerId,Eb.set(I,Cb(Eb.get(I)||null,h,g,_,M,P)),!0}return!1}function OU(h){var g=jt(h.target);if(g!==null){var _=s(g);if(_!==null){if(g=_.tag,g===13){if(g=o(_),g!==null){h.blockedOn=g,Gn(h.priority,function(){PU(_)});return}}else if(g===31){if(g=l(_),g!==null){h.blockedOn=g,Gn(h.priority,function(){PU(_)});return}}else if(g===3&&_.stateNode.current.memoizedState.isDehydrated){h.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}h.blockedOn=null}function M_(h){if(h.blockedOn!==null)return!1;for(var g=h.targetContainers;0<g.length;){var _=IC(h.nativeEvent);if(_===null){_=h.nativeEvent;var M=new _.constructor(_.type,_);fl=M,_.target.dispatchEvent(M),fl=null}else return g=he(_),g!==null&&jU(g),h.blockedOn=_,!1;g.shift()}return!0}function LU(h,g,_){M_(h)&&_.delete(g)}function Rae(){UC=!1,gd!==null&&M_(gd)&&(gd=null),xd!==null&&M_(xd)&&(xd=null),bd!==null&&M_(bd)&&(bd=null),Mb.forEach(LU),Eb.forEach(LU)}function E_(h,g){h.blockedOn===g&&(h.blockedOn=null,UC||(UC=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Rae)))}var C_=null;function IU(h){C_!==h&&(C_=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){C_===h&&(C_=null);for(var g=0;g<h.length;g+=3){var _=h[g],M=h[g+1],P=h[g+2];if(typeof M!="function"){if(FC(M||_)===null)continue;break}var I=he(_);I!==null&&(h.splice(g,3),g-=3,IE(I,{pending:!0,data:P,method:_.method,action:M},M,P))}}))}function hp(h){function g(ze){return E_(ze,h)}gd!==null&&E_(gd,h),xd!==null&&E_(xd,h),bd!==null&&E_(bd,h),Mb.forEach(g),Eb.forEach(g);for(var _=0;_<yd.length;_++){var M=yd[_];M.blockedOn===h&&(M.blockedOn=null)}for(;0<yd.length&&(_=yd[0],_.blockedOn===null);)OU(_),_.blockedOn===null&&yd.shift();if(_=(h.ownerDocument||h).$$reactFormReplay,_!=null)for(M=0;M<_.length;M+=3){var P=_[M],I=_[M+1],ee=P[bn]||null;if(typeof I=="function")ee||IU(_);else if(ee){var ve=null;if(I&&I.hasAttribute("formAction")){if(P=I,ee=I[bn]||null)ve=ee.formAction;else if(FC(P)!==null)continue}else ve=ee.action;typeof ve=="function"?_[M+1]=ve:(_.splice(M,3),M-=3),IU(_)}}}function FU(){function h(I){I.canIntercept&&I.info==="react-transition"&&I.intercept({handler:function(){return new Promise(function(ee){return P=ee})},focusReset:"manual",scroll:"manual"})}function g(){P!==null&&(P(),P=null),M||setTimeout(_,20)}function _(){if(!M&&!navigation.transition){var I=navigation.currentEntry;I&&I.url!=null&&navigation.navigate(I.url,{state:I.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var M=!1,P=null;return navigation.addEventListener("navigate",h),navigation.addEventListener("navigatesuccess",g),navigation.addEventListener("navigateerror",g),setTimeout(_,100),function(){M=!0,navigation.removeEventListener("navigate",h),navigation.removeEventListener("navigatesuccess",g),navigation.removeEventListener("navigateerror",g),P!==null&&(P(),P=null)}}}function zC(h){this._internalRoot=h}T_.prototype.render=zC.prototype.render=function(h){var g=this._internalRoot;if(g===null)throw Error(r(409));var _=g.current,M=to();AU(_,M,h,g,null,null)},T_.prototype.unmount=zC.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var g=h.containerInfo;AU(h.current,2,null,h,null,null),l_(),g[xi]=null}};function T_(h){this._internalRoot=h}T_.prototype.unstable_scheduleHydration=function(h){if(h){var g=ln();h={blockedOn:null,target:h,priority:g};for(var _=0;_<yd.length&&g!==0&&g<yd[_].priority;_++);yd.splice(_,0,h),_===0&&OU(h)}};var UU=e.version;if(UU!=="19.2.0")throw Error(r(527,UU,"19.2.0"));q.findDOMNode=function(h){var g=h._reactInternals;if(g===void 0)throw typeof h.render=="function"?Error(r(188)):(h=Object.keys(h).join(","),Error(r(268,h)));return h=u(g),h=h!==null?d(h):null,h=h===null?null:h.stateNode,h};var Dae={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:$,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var A_=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!A_.isDisabled&&A_.supportsFiber)try{Ie=A_.inject(Dae),ae=A_}catch{}}return Ab.createRoot=function(h,g){if(!i(h))throw Error(r(299));var _=!1,M="",P=qI,I=WI,ee=KI;return g!=null&&(g.unstable_strictMode===!0&&(_=!0),g.identifierPrefix!==void 0&&(M=g.identifierPrefix),g.onUncaughtError!==void 0&&(P=g.onUncaughtError),g.onCaughtError!==void 0&&(I=g.onCaughtError),g.onRecoverableError!==void 0&&(ee=g.onRecoverableError)),g=CU(h,1,!1,null,null,_,M,null,P,I,ee,FU),h[xi]=g.current,_C(h),new zC(g)},Ab.hydrateRoot=function(h,g,_){if(!i(h))throw Error(r(299));var M=!1,P="",I=qI,ee=WI,ve=KI,ze=null;return _!=null&&(_.unstable_strictMode===!0&&(M=!0),_.identifierPrefix!==void 0&&(P=_.identifierPrefix),_.onUncaughtError!==void 0&&(I=_.onUncaughtError),_.onCaughtError!==void 0&&(ee=_.onCaughtError),_.onRecoverableError!==void 0&&(ve=_.onRecoverableError),_.formState!==void 0&&(ze=_.formState)),g=CU(h,1,!0,g,_??null,M,P,ze,I,ee,ve,FU),g.context=TU(null),_=g.current,M=to(),M=dr(M),P=id(M),P.callback=null,ad(_,P,M),_=M,g.current.lanes=_,It(g,_),Kl(g),h[xi]=g.current,_C(h),new T_(g)},Ab.version="19.2.0",Ab}var XU;function Gae(){if(XU)return HC.exports;XU=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(),HC.exports=Vae(),HC.exports}var qae=Gae();const fn=t=>typeof t=="string",kb=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},YU=t=>t==null?"":""+t,Wae=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Kae=/###/g,QU=t=>t&&t.indexOf("###")>-1?t.replace(Kae,"."):t,ZU=t=>!t||fn(t),x0=(t,e,n)=>{const r=fn(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(ZU(t))return{};const s=QU(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return ZU(t)?{}:{obj:t,k:QU(r[i])}},JU=(t,e,n)=>{const{obj:r,k:i}=x0(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let s=e[e.length-1],o=e.slice(0,e.length-1),l=x0(t,o,Object);for(;l.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),l=x0(t,o,Object),l?.obj&&typeof l.obj[`${l.k}.${s}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${s}`]=n},Xae=(t,e,n,r)=>{const{obj:i,k:s}=x0(t,e,Object);i[s]=i[s]||[],i[s].push(n)},z1=(t,e)=>{const{obj:n,k:r}=x0(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Yae=(t,e,n)=>{const r=z1(t,n);return r!==void 0?r:z1(e,n)},Mq=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?fn(t[r])||t[r]instanceof String||fn(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):Mq(t[r],e[r],n):t[r]=e[r]);return t},fp=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Qae={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const Zae=t=>fn(t)?t.replace(/[&<>"'\/]/g,e=>Qae[e]):t;class Jae{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 ese=[" ",",","?","!",";"],tse=new Jae(20),nse=(t,e,n)=>{e=e||"",n=n||"";const r=ese.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=tse.getRegExp(`(${r.map(o=>o==="?"?"\\?":o).join("|")})`);let s=!i.test(t);if(!s){const o=t.indexOf(n);o>0&&!i.test(t.substring(0,o))&&(s=!0)}return s},Qj=(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 o,l="";for(let c=s;c<r.length;++c)if(c!==s&&(l+=n),l+=r[c],o=i[l],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&c<r.length-1)continue;s+=c-s+1;break}i=o}return i},B0=t=>t?.replace("_","-"),rse={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 B1{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||rse,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:(fn(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new B1(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new B1(this.logger,e)}}var oc=new B1;let nN=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 o=0;o<s;o++)i(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,s])=>{for(let o=0;o<s;o++)i.apply(i,[e,...n])})}};class ez extends nN{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,o=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;e.indexOf(".")>-1?l=e.split("."):(l=[e,n],r&&(Array.isArray(r)?l.push(...r):fn(r)&&s?l.push(...r.split(s)):l.push(r)));const c=z1(this.data,l);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=l[0],n=l[1],r=l.slice(2).join(".")),c||!o||!fn(r)?c:Qj(this.data?.[e]?.[n],r,s)}addResource(e,n,r,i,s={silent:!1}){const o=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let l=[e,n];r&&(l=l.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(l=e.split("."),i=n,n=l[1]),this.addNamespaces(n),JU(this.data,l,i),s.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const s in r)(fn(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,o={silent:!1,skipCopy:!1}){let l=[e,n];e.indexOf(".")>-1&&(l=e.split("."),i=r,r=n,n=l[1]),this.addNamespaces(n);let c=z1(this.data,l)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?Mq(c,r,s):c={...c,...r},JU(this.data,l,c),o.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 Eq={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 Cq=Symbol("i18next/PATH_KEY");function ise(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===Cq?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function Zj(t,e){const{[Cq]:n}=t(ise());return n.join(e?.keySeparator??".")}const tz={},WC=t=>!fn(t)&&typeof t!="boolean"&&typeof t!="number";class $1 extends nN{constructor(e,n={}){super(),Wae(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=oc.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=WC(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 o=r&&e.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!nse(e,r,i);if(o&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:fn(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:fn(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=Zj(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const s=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:l,namespaces:c}=this.extractFromKey(e[e.length-1],i),u=c[c.length-1];let d=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;d===void 0&&(d=":");const f=i.lng||this.language,m=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return m?s?{res:`${u}${d}${l}`,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${d}${l}`:s?{res:l,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:l;const p=this.resolve(e,i);let x=p?.res;const b=p?.usedKey||l,y=p?.exactUsedKey||l,v=["[object Number]","[object Function]","[object RegExp]"],S=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,N=!this.i18nFormat||this.i18nFormat.handleAsObject,C=i.count!==void 0&&!fn(i.count),T=$1.hasDefaultValue(i),k=C?this.pluralResolver.getSuffix(f,i.count,i):"",E=i.ordinal&&C?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",D=C&&!i.ordinal&&i.count===0,A=D&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${k}`]||i[`defaultValue${E}`]||i.defaultValue;let R=x;N&&!x&&T&&(R=A);const F=WC(R),O=Object.prototype.toString.apply(R);if(N&&R&&F&&v.indexOf(O)<0&&!(fn(S)&&Array.isArray(R))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const H=this.options.returnedObjectHandler?this.options.returnedObjectHandler(b,R,{...i,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return s?(p.res=H,p.usedParams=this.getUsedParamsDetails(i),p):H}if(o){const H=Array.isArray(R),j=H?[]:{},G=H?y:b;for(const $ in R)if(Object.prototype.hasOwnProperty.call(R,$)){const q=`${G}${o}${$}`;T&&!x?j[$]=this.translate(q,{...i,defaultValue:WC(A)?A[$]:void 0,joinArrays:!1,ns:c}):j[$]=this.translate(q,{...i,joinArrays:!1,ns:c}),j[$]===q&&(j[$]=R[$])}x=j}}else if(N&&fn(S)&&Array.isArray(x))x=x.join(S),x&&(x=this.extendTranslation(x,e,i,r));else{let H=!1,j=!1;!this.isValidLookup(x)&&T&&(H=!0,x=A),this.isValidLookup(x)||(j=!0,x=l);const $=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&j?void 0:x,q=T&&A!==x&&this.options.updateMissing;if(j||H||q){if(this.logger.log(q?"updateKey":"missingKey",f,u,l,q?A:x),o){const B=this.resolve(l,{...i,keySeparator:!1});B&&B.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 Y=[];const Z=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Z&&Z[0])for(let B=0;B<Z.length;B++)Y.push(Z[B]);else this.options.saveMissingTo==="all"?Y=this.languageUtils.toResolveHierarchy(i.lng||this.language):Y.push(i.lng||this.language);const oe=(B,W,se)=>{const ne=T&&se!==x?se:$;this.options.missingKeyHandler?this.options.missingKeyHandler(B,u,W,ne,q,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(B,u,W,ne,q,i),this.emit("missingKey",B,u,W,x)};this.options.saveMissing&&(this.options.saveMissingPlurals&&C?Y.forEach(B=>{const W=this.pluralResolver.getSuffixes(B,i);D&&i[`defaultValue${this.options.pluralSeparator}zero`]&&W.indexOf(`${this.options.pluralSeparator}zero`)<0&&W.push(`${this.options.pluralSeparator}zero`),W.forEach(se=>{oe([B],l+se,i[`defaultValue${se}`]||A)})}):oe(Y,l,A))}x=this.extendTranslation(x,e,i,p,r),j&&x===l&&this.options.appendNamespaceToMissingKey&&(x=`${u}${d}${l}`),(j||H)&&this.options.parseMissingKeyHandler&&(x=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${l}`:l,H?x:void 0,i))}return s?(p.res=x,p.usedParams=this.getUsedParamsDetails(i),p):x}extendTranslation(e,n,r,i,s){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=fn(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let u;if(c){const f=e.match(this.interpolator.nestingRegexp);u=f&&f.length}let d=r.replace&&!fn(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),e=this.interpolator.interpolate(e,d,r.lng||this.language||i.usedLng,r),c){const f=e.match(this.interpolator.nestingRegexp),m=f&&f.length;u<m&&(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 o=r.postProcess||this.options.postProcess,l=fn(o)?[o]:o;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=Eq.handle(l,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,n={}){let r,i,s,o,l;return fn(e)&&(e=[e]),e.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),d=u.key;i=d;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const m=n.count!==void 0&&!fn(n.count),p=m&&!n.ordinal&&n.count===0,x=n.context!==void 0&&(fn(n.context)||typeof n.context=="number")&&n.context!=="",b=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(y=>{this.isValidLookup(r)||(l=y,!tz[`${b[0]}-${y}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(tz[`${b[0]}-${y}`]=!0,this.logger.warn(`key "${i}" for languages "${b.join(", ")}" won't get resolved as namespace "${l}" 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!!!")),b.forEach(v=>{if(this.isValidLookup(r))return;o=v;const S=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(S,d,v,y,n);else{let C;m&&(C=this.pluralResolver.getSuffix(v,n.count,n));const T=`${this.options.pluralSeparator}zero`,k=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(n.ordinal&&C.indexOf(k)===0&&S.push(d+C.replace(k,this.options.pluralSeparator)),S.push(d+C),p&&S.push(d+T)),x){const E=`${d}${this.options.contextSeparator||"_"}${n.context}`;S.push(E),m&&(n.ordinal&&C.indexOf(k)===0&&S.push(E+C.replace(k,this.options.pluralSeparator)),S.push(E+C),p&&S.push(E+T))}}let N;for(;N=S.pop();)this.isValidLookup(r)||(s=N,r=this.getResource(v,y,N,n))}))})}),{res:r,usedKey:i,exactUsedKey:s,usedLng:o,usedNS:l}}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&&!fn(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 nz{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=oc.create("languageUtils")}getScriptPartFromCode(e){if(e=B0(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=B0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(fn(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(o=>{if(o===s)return o;if(!(o.indexOf("-")<0&&s.indexOf("-")<0)&&(o.indexOf("-")>0&&s.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===s||o.indexOf(s)===0&&s.length>1))return o})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),fn(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=o=>{o&&(this.isSupportedCode(o)?i.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return fn(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))):fn(e)&&s(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&s(this.formatLanguageCode(o))}),i}}const rz={zero:0,one:1,two:2,few:3,many:4,other:5},iz={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class ase{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=oc.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=B0(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 o;try{o=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),iz;if(!e.match(/-|_/))return iz;const c=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(c,n)}return this.pluralRulesCache[s]=o,o}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)=>rz[i]-rz[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 az=(t,e,n,r=".",i=!0)=>{let s=Yae(t,e,n);return!s&&i&&fn(n)&&(s=Qj(t,n,r),s===void 0&&(s=Qj(e,n,r))),s},KC=t=>t.replace(/\$/g,"$$$$");class sse{constructor(e={}){this.logger=oc.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:o,suffix:l,suffixEscaped:c,formatSeparator:u,unescapeSuffix:d,unescapePrefix:f,nestingPrefix:m,nestingPrefixEscaped:p,nestingSuffix:x,nestingSuffixEscaped:b,nestingOptionsSeparator:y,maxReplaces:v,alwaysFormat:S}=e.interpolation;this.escape=n!==void 0?n:Zae,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?fp(s):o||"{{",this.suffix=l?fp(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=m?fp(m):p||fp("$t("),this.nestingSuffix=x?fp(x):b||fp(")"),this.nestingOptionsSeparator=y||",",this.maxReplaces=v||1e3,this.alwaysFormat=S!==void 0?S:!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,o,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=p=>{if(p.indexOf(this.formatSeparator)<0){const v=az(n,c,p,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(v,void 0,r,{...i,...n,interpolationkey:p}):v}const x=p.split(this.formatSeparator),b=x.shift().trim(),y=x.join(this.formatSeparator).trim();return this.format(az(n,c,b,this.options.keySeparator,this.options.ignoreJSONStructure),y,r,{...i,...n,interpolationkey:b})};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:p=>KC(p)},{regex:this.regexp,safeValue:p=>this.escapeValue?KC(this.escape(p)):KC(p)}].forEach(p=>{for(l=0;s=p.regex.exec(e);){const x=s[1].trim();if(o=u(x),o===void 0)if(typeof d=="function"){const y=d(e,s,i);o=fn(y)?y:""}else if(i&&Object.prototype.hasOwnProperty.call(i,x))o="";else if(f){o=s[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),o="";else!fn(o)&&!this.useRawValueToEscape&&(o=YU(o));const b=p.safeValue(o);if(e=e.replace(s[0],b),f?(p.regex.lastIndex+=o.length,p.regex.lastIndex-=s[0].length):p.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,s,o;const l=(c,u)=>{const d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const f=c.split(new RegExp(`${d}[ ]*{`));let m=`{${f[1]}`;c=f[0],m=this.interpolate(m,o);const p=m.match(/'/g),x=m.match(/"/g);((p?.length??0)%2===0&&!x||x.length%2!==0)&&(m=m.replace(/'/g,'"'));try{o=JSON.parse(m),u&&(o={...u,...o})}catch(b){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,b),`${c}${d}${m}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,c};for(;i=this.nestingRegexp.exec(e);){let c=[];o={...r},o=o.replace&&!fn(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;const u=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(u!==-1&&(c=i[1].slice(u).split(this.formatSeparator).map(d=>d.trim()).filter(Boolean),i[1]=i[1].slice(0,u)),s=n(l.call(this,i[1].trim(),o),o),s&&i[0]===e&&!fn(s))return s;fn(s)||(s=YU(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),c.length&&(s=c.reduce((d,f)=>this.format(d,f,r.lng,{...r,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}const ose=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(o=>{if(o){const[l,...c]=o.split(":"),u=c.join(":").trim().replace(/^'+|'+$/g,""),d=l.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}},sz=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 o=r+JSON.stringify(s);let l=e[o];return l||(l=t(B0(r),i),e[o]=l),l(n)}},lse=t=>(e,n,r)=>t(B0(n),r)(e);class cse{constructor(e={}){this.logger=oc.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?sz:lse;this.formats={number:r((i,s)=>{const o=new Intl.NumberFormat(i,{...s});return l=>o.format(l)}),currency:r((i,s)=>{const o=new Intl.NumberFormat(i,{...s,style:"currency"});return l=>o.format(l)}),datetime:r((i,s)=>{const o=new Intl.DateTimeFormat(i,{...s});return l=>o.format(l)}),relativetime:r((i,s)=>{const o=new Intl.RelativeTimeFormat(i,{...s});return l=>o.format(l,s.range||"day")}),list:r((i,s)=>{const o=new Intl.ListFormat(i,{...s});return l=>o.format(l)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=sz(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(l=>l.indexOf(")")>-1)){const l=s.findIndex(c=>c.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,l)].join(this.formatSeparator)}return s.reduce((l,c)=>{const{formatName:u,formatOptions:d}=ose(c);if(this.formats[u]){let f=l;try{const m=i?.formatParams?.[i.interpolationkey]||{},p=m.locale||m.lng||i.locale||i.lng||r;f=this.formats[u](l,p,{...d,...i,...m})}catch(m){this.logger.warn(m)}return f}else this.logger.warn(`there was no format function for ${u}`);return l},e)}}const use=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class dse extends nN{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=oc.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={},o={},l={},c={};return e.forEach(u=>{let d=!0;n.forEach(f=>{const m=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?o[m]===void 0&&(o[m]=!0):(this.state[m]=1,d=!1,o[m]===void 0&&(o[m]=!0),s[m]===void 0&&(s[m]=!0),c[f]===void 0&&(c[f]=!0)))}),d||(l[u]=!0)}),(Object.keys(s).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(s),pending:Object.keys(o),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(e,n,r){const i=e.split("|"),s=i[0],o=i[1];n&&this.emit("failedLoading",s,o,n),!n&&r&&this.store.addResourceBundle(s,o,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const l={};this.queue.forEach(c=>{Xae(c.loaded,[s],o),use(c,e),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{l[u]||(l[u]={});const d=c.loaded[u];d.length&&d.forEach(f=>{l[u][f]===void 0&&(l[u][f]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(e,n,r,i=0,s=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:s,callback:o});return}this.readingCalls++;const l=(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,o)},s);return}o(u,d)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const u=c(e,n);u&&typeof u.then=="function"?u.then(d=>l(null,d)).catch(l):l(null,u)}catch(u){l(u)}return}return c(e,n,l)}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();fn(e)&&(e=this.languageUtils.toResolveHierarchy(e)),fn(n)&&(n=[n]);const s=this.queueLoad(e,n,r,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.toLoad.forEach(o=>{this.loadOne(o)})}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,(o,l)=>{o&&this.logger.warn(`${n}loading namespace ${s} for language ${i} failed`,o),!o&&l&&this.logger.log(`${n}loaded namespace ${s} for language ${i}`,l),this.loaded(e,o,l)})}saveMissing(e,n,r,i,s,o={},l=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const c={...o,isUpdate:s},u=this.backend.create.bind(this.backend);if(u.length<6)try{let d;u.length===5?d=u(e,n,r,i,c):d=u(e,n,r,i),d&&typeof d.then=="function"?d.then(f=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}else u(e,n,r,i,l,c)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const oz=()=>({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]),fn(t[1])&&(e.defaultValue=t[1]),fn(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}),lz=t=>(fn(t.ns)&&(t.ns=[t.ns]),fn(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),fn(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),j_=()=>{},hse=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class b0 extends nN{constructor(e={},n){if(super(),this.options=lz(e),this.services={},this.logger=oc,this.modules={external:[]},hse(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&&(fn(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=oz();this.options={...r,...this.options,...lz(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?oc.init(i(this.modules.logger),this.options):oc.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=cse;const d=new nz(this.options);this.store=new ez(this.options.resources,this.options);const f=this.services;f.logger=oc,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new ase(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 sse(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new dse(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(p,...x)=>{this.emit(p,...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 $1(this.services,this.options),this.translator.on("*",(p,...x)=>{this.emit(p,...x)}),this.modules.external.forEach(p=>{p.init&&p.init(this)})}if(this.format=this.options.interpolation.format,n||(n=j_),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 l=kb(),c=()=>{const u=(d,f)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(f),n(d,f)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),l}loadResources(e,n=j_){let r=n;const i=fn(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=[],o=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(u=>{u!=="cimode"&&s.indexOf(u)<0&&s.push(u)})};i?o(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>o(c)),this.options.preload?.forEach?.(l=>o(l)),this.services.backendConnector.load(s,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(e,n,r){const i=kb();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=j_),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"&&Eq.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=kb();this.emit("languageChanging",e);const i=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},s=(l,c)=>{c?this.isLanguageChangingTo===e&&(i(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,r.resolve((...u)=>this.t(...u)),n&&n(l,(...u)=>this.t(...u))},o=l=>{!e&&!l&&this.services.languageDetector&&(l=[]);const c=fn(l)?l:l&&l[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(fn(l)?[l]:l);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?o(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e),r}getFixedT(e,n,r){const i=(s,o,...l)=>{let c;typeof o!="object"?c=this.options.overloadTranslationOptionHandler([s,o].concat(l)):c={...o},c.lng=c.lng||i.lng,c.lngs=c.lngs||i.lngs,c.ns=c.ns||i.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||r||i.keyPrefix);const u=this.options.keySeparator||".";let d;return c.keyPrefix&&Array.isArray(s)?d=s.map(f=>(typeof f=="function"&&(f=Zj(f,{...this.options,...o})),`${c.keyPrefix}${u}${f}`)):(typeof s=="function"&&(s=Zj(s,{...this.options,...o})),d=c.keyPrefix?`${c.keyPrefix}${u}${s}`:s),this.t(d,c)};return fn(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 o=(l,c)=>{const u=this.services.backendConnector.state[`${l}|${c}`];return u===-1||u===0||u===2};if(n.precheck){const l=n.precheck(this,o);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(r,e)&&(!i||o(s,e)))}loadNamespaces(e,n){const r=kb();return this.options.ns?(fn(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=kb();fn(e)&&(e=[e]);const i=this.options.preload||[],s=e.filter(o=>i.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return s.length?(this.options.preload=i.concat(s),this.loadResources(o=>{r.resolve(),n&&n(o)}),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 nz(oz());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 b0(e,n);return r.createInstance=b0.createInstance,r}cloneInstance(e={},n=j_){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new b0(i);if((e.debug!==void 0||e.prefix!==void 0)&&(s.logger=s.logger.clone(e)),["store","services","language"].forEach(l=>{s[l]=this[l]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},r){const l=Object.keys(this.store.data).reduce((c,u)=>(c[u]={...this.store.data[u]},c[u]=Object.keys(c[u]).reduce((d,f)=>(d[f]={...c[u][f]},d),c[u]),c),{});s.store=new ez(l,i),s.services.resourceStore=s.store}return s.translator=new $1(s.services,i),s.translator.on("*",(l,...c)=>{s.emit(l,...c)}),s.init(i,n),s.translator.options=i,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Es=b0.createInstance();Es.createInstance;Es.dir;Es.init;Es.loadResources;Es.reloadResources;Es.use;Es.changeLanguage;Es.getFixedT;Es.t;Es.exists;Es.setDefaultNamespace;Es.hasLoadedNamespace;Es.loadNamespaces;Es.loadLanguages;const fse=(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);em(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},cz={},Tq=(t,e,n,r)=>{em(n)&&cz[n]||(em(n)&&(cz[n]=new Date),fse(t,e,n,r))},Aq=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},Jj=(t,e,n)=>{t.loadNamespaces(e,Aq(t,n))},uz=(t,e,n,r)=>{if(em(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return Jj(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,Aq(t,r))},mse=(t,e,n={})=>!e.languages||!e.languages.length?(Tq(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}}),em=t=>typeof t=="string",pse=t=>typeof t=="object"&&t!==null,gse=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,xse={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},bse=t=>xse[t],yse=t=>t.replace(gse,bse);let e3={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:yse};const vse=(t={})=>{e3={...e3,...t}},_se=()=>e3;let kq;const wse=t=>{kq=t},Sse=()=>kq,Nse={type:"3rdParty",init(t){vse(t.options.react),wse(t)}},Mse=w.createContext();class Ese{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var XC={exports:{}},YC={};var dz;function Cse(){if(dz)return YC;dz=1;var t=px();function e(f,m){return f===m&&(f!==0||1/f===1/m)||f!==f&&m!==m}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,s=t.useLayoutEffect,o=t.useDebugValue;function l(f,m){var p=m(),x=r({inst:{value:p,getSnapshot:m}}),b=x[0].inst,y=x[1];return s(function(){b.value=p,b.getSnapshot=m,c(b)&&y({inst:b})},[f,p,m]),i(function(){return c(b)&&y({inst:b}),f(function(){c(b)&&y({inst:b})})},[f]),o(p),p}function c(f){var m=f.getSnapshot;f=f.value;try{var p=m();return!n(f,p)}catch{return!0}}function u(f,m){return m()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:l;return YC.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,YC}var hz;function jq(){return hz||(hz=1,XC.exports=Cse()),XC.exports}var mD=jq();const Tse=(t,e)=>em(e)?e:pse(e)&&em(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,Ase={t:Tse,ready:!1},kse=()=>()=>{},Oy=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=w.useContext(Mse)||{},s=n||r||Sse();s&&!s.reportNamespaces&&(s.reportNamespaces=new Ese),s||Tq(s,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=w.useMemo(()=>({..._se(),...s?.options?.react,...e}),[s,e]),{useSuspense:l,keyPrefix:c}=o,u=i||s?.options?.defaultNS,d=em(u)?[u]:u||["translation"],f=w.useMemo(()=>d,d);s?.reportNamespaces?.addUsedNamespaces?.(f);const m=w.useRef(0),p=w.useCallback(A=>{if(!s)return kse;const{bindI18n:R,bindI18nStore:F}=o,O=()=>{m.current+=1,A()};return R&&s.on(R,O),F&&s.store.on(F,O),()=>{R&&R.split(" ").forEach(H=>s.off(H,O)),F&&F.split(" ").forEach(H=>s.store.off(H,O))}},[s,o]),x=w.useRef(),b=w.useCallback(()=>{if(!s)return Ase;const A=!!(s.isInitialized||s.initializedStoreOnce)&&f.every(G=>mse(G,s,o)),R=e.lng||s.language,F=m.current,O=x.current;if(O&&O.ready===A&&O.lng===R&&O.keyPrefix===c&&O.revision===F)return O;const j={t:s.getFixedT(R,o.nsMode==="fallback"?f:f[0],c),ready:A,lng:R,keyPrefix:c,revision:F};return x.current=j,j},[s,f,c,o,e.lng]),[y,v]=w.useState(0),{t:S,ready:N}=mD.useSyncExternalStore(p,b,b);w.useEffect(()=>{if(s&&!N&&!l){const A=()=>v(R=>R+1);e.lng?uz(s,e.lng,f,A):Jj(s,f,A)}},[s,e.lng,f,N,l,y]);const C=s||{},T=w.useRef(null),k=w.useRef(),E=A=>{const R=Object.getOwnPropertyDescriptors(A);R.__original&&delete R.__original;const F=Object.create(Object.getPrototypeOf(A),R);if(!Object.prototype.hasOwnProperty.call(F,"__original"))try{Object.defineProperty(F,"__original",{value:A,writable:!1,enumerable:!1,configurable:!1})}catch{}return F},D=w.useMemo(()=>{const A=C,R=A?.language;let F=A;A&&(T.current&&T.current.__original===A?k.current!==R?(F=E(A),T.current=F,k.current=R):F=T.current:(F=E(A),T.current=F,k.current=R));const O=[S,F,N];return O.t=S,O.i18n=F,O.ready=N,O},[S,C,N,C.resolvedLanguage,C.language,C.languages]);if(s&&l&&!N)throw new Promise(A=>{const R=()=>A();e.lng?uz(s,e.lng,f,R):Jj(s,f,R)});return D},{slice:jse,forEach:Pse}=[];function Rse(t){return Pse.call(jse.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function Dse(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 fz=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Ose=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 o=r.maxAge-0;if(Number.isNaN(o))throw new Error("maxAge should be a Number");s+=`; Max-Age=${Math.floor(o)}`}if(r.domain){if(!fz.test(r.domain))throw new TypeError("option domain is invalid");s+=`; Domain=${r.domain}`}if(r.path){if(!fz.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},mz={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=Ose(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 Lse={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return mz.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:s}=e;n&&typeof document<"u"&&mz.create(n,t,r,i,s)}},Ise={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 o=0;o<s.length;o++){const l=s[o].indexOf("=");l>0&&s[o].substring(0,l)===e&&(n=s[o].substring(l+1))}}return n}},Fse={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 o=s.split("&");for(let l=0;l<o.length;l++){const c=o[l].indexOf("=");c>0&&o[l].substring(0,c)===e&&(r=o[l].substring(c+1))}}if(r)return r;if(!r&&n>-1){const o=i.match(/\/([a-zA-Z-]*)/g);return Array.isArray(o)?o[typeof n=="number"?n:0]?.replace("/",""):void 0}}}return r}};let mp=null;const pz=()=>{if(mp!==null)return mp;try{if(mp=typeof window<"u"&&window.localStorage!==null,!mp)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{mp=!1}return mp};var Use={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&pz())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&pz()&&window.localStorage.setItem(n,t)}};let pp=null;const gz=()=>{if(pp!==null)return pp;try{if(pp=typeof window<"u"&&window.sessionStorage!==null,!pp)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{pp=!1}return pp};var zse={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&gz())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&gz()&&window.sessionStorage.setItem(n,t)}},Bse={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}},$se={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}},Hse={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}},Vse={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 Pq=!1;try{document.cookie,Pq=!0}catch{}const Rq=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];Pq||Rq.splice(1,1);const Gse=()=>({order:Rq,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class Dq{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=Rse(n,this.options||{},Gse()),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(Lse),this.addDetector(Ise),this.addDetector(Use),this.addDetector(zse),this.addDetector(Bse),this.addDetector($se),this.addDetector(Hse),this.addDetector(Vse),this.addDetector(Fse)}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&&!Dse(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)}))}}Dq.type="languageDetector";const qse={nav:{printers:"Printers",archives:"Archives",queue:"Queue",stats:"Statistics",profiles:"Profiles",maintenance:"Maintenance",projects:"Projects",files:"File Manager",settings:"Settings",system:"System",collapseSidebar:"Collapse sidebar",expandSidebar:"Expand sidebar",update:"Update",updateAvailable:"Update available: v{{version}}",viewOnGithub:"View on GitHub",keyboardShortcuts:"Keyboard shortcuts (?)",switchToLight:"Switch to light mode",switchToDark:"Switch to dark mode"},common:{save:"Save",cancel:"Cancel",delete:"Delete",edit:"Edit",add:"Add",close:"Close",confirm:"Confirm",loading:"Loading...",error:"Error",success:"Success",warning:"Warning",enabled:"Enabled",disabled:"Disabled",yes:"Yes",no:"No",on:"On",off:"Off",all:"All",none:"None",search:"Search",filter:"Filter",sort:"Sort",refresh:"Refresh",download:"Download",upload:"Upload",actions:"Actions",status:"Status",name:"Name",description:"Description",date:"Date",time:"Time",hours:"hours",minutes:"minutes",seconds:"seconds",noPrinters:"No printers configured",noData:"No data available",required:"Required",optional:"Optional"},printers:{title:"Printers",addPrinter:"Add Printer",editPrinter:"Edit Printer",deletePrinter:"Delete Printer",printerName:"Printer Name",serialNumber:"Serial Number",ipAddress:"IP Address",accessCode:"Access Code",model:"Model",nozzleCount:"Nozzle Count",autoArchive:"Auto Archive",status:{idle:"Idle",printing:"Printing",paused:"Paused",offline:"Offline",error:"Error",finished:"Finished",unknown:"Unknown"},temperatures:{nozzle:"Nozzle",bed:"Bed",chamber:"Chamber"},progress:"{{percent}}% complete",timeRemaining:"{{time}} remaining",deleteConfirm:'Are you sure you want to delete "{{name}}"?',maintenanceOk:"Maintenance OK",maintenanceWarning:"{{count}} warning",maintenanceWarning_plural:"{{count}} warnings",maintenanceDue:"{{count}} due",maintenanceDue_plural:"{{count}} due"},archives:{title:"Print Archives",searchPlaceholder:"Search archives...",filterByPrinter:"Filter by printer",filterByStatus:"Filter by status",sortBy:"Sort by",sortNewest:"Newest first",sortOldest:"Oldest first",sortName:"Name",sortDuration:"Duration",noArchives:"No archives found",printTime:"Print Time",filamentUsed:"Filament Used",cost:"Cost",reprint:"Reprint",preview:"Preview",deleteArchive:"Delete Archive",deleteConfirm:"Are you sure you want to delete this archive?",favorite:"Favorite",unfavorite:"Remove from favorites",viewDetails:"View Details",status:{completed:"Completed",failed:"Failed",stopped:"Stopped"}},queue:{title:"Print Queue",addToQueue:"Add to Queue",clearQueue:"Clear Queue",emptyQueue:"Queue is empty",position:"Position",scheduledTime:"Scheduled Time",moveUp:"Move Up",moveDown:"Move Down",remove:"Remove",startNow:"Start Now",status:{pending:"Pending",printing:"Printing",completed:"Completed",failed:"Failed",cancelled:"Cancelled"}},stats:{title:"Statistics",overview:"Overview",totalPrints:"Total Prints",successRate:"Success Rate",totalPrintTime:"Total Print Time",totalFilament:"Total Filament Used",totalCost:"Total Cost",averagePrintTime:"Average Print Time",printsPerDay:"Prints per Day",byPrinter:"By Printer",byMaterial:"By Material",byMonth:"By Month",last7Days:"Last 7 Days",last30Days:"Last 30 Days",last90Days:"Last 90 Days",allTime:"All Time"},profiles:{title:"Filament Profiles",addProfile:"Add Profile",editProfile:"Edit Profile",deleteProfile:"Delete Profile",material:"Material",brand:"Brand",color:"Color",diameter:"Diameter",density:"Density",costPerKg:"Cost per kg",spoolWeight:"Spool Weight",noProfiles:"No profiles configured",deleteConfirm:"Are you sure you want to delete this profile?"},maintenance:{title:"Maintenance",overview:"Overview",allOk:"All maintenance up to date",dueCount:"{{count}} item due",dueCount_plural:"{{count}} items due",warningCount:"{{count}} warning",warningCount_plural:"{{count}} warnings",totalPrintTime:"Total Print Time",nextMaintenance:"Next Maintenance",nothingDue:"Nothing due",tasks:"Tasks",lastPerformed:"Last performed",interval:"Interval",hoursRemaining:"{{hours}}h remaining",hoursOverdue:"{{hours}}h overdue",markDone:"Mark as Done",performMaintenance:"Perform Maintenance",history:"History",noHistory:"No maintenance history",editPrintHours:"Edit Print Hours",currentHours:"Current Hours",types:{lubricateRails:"Lubricate Linear Rails",cleanNozzle:"Clean Nozzle/Hotend",checkBelts:"Check Belt Tension",cleanBuildPlate:"Clean Build Plate",checkExtruder:"Check Extruder Gears",checkCooling:"Check Cooling Fans",generalInspection:"General Inspection"}},settings:{title:"Settings",general:"General",appearance:"Appearance",notifications:"Notifications",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Language",languageDescription:"Select your preferred language",theme:"Theme",themeLight:"Light",themeDark:"Dark",themeSystem:"System",defaultView:"Default View",defaultViewDescription:"Page to show when opening the app",checkForUpdates:"Check for Updates",autoUpdate:"Auto Update",currentVersion:"Current Version",latestVersion:"Latest Version",upToDate:"You are up to date",updateAvailable:"Update available",notificationLanguage:"Notification Language",notificationLanguageDescription:"Language for push notifications",notificationProviders:"Notification Providers",addProvider:"Add Provider",editProvider:"Edit Provider",providerType:"Provider Type",testNotification:"Test Notification",testSuccess:"Test notification sent successfully",testFailed:"Failed to send test notification",quietHours:"Quiet Hours",quietHoursDescription:"Do not disturb during these hours",quietHoursStart:"Start",quietHoursEnd:"End",events:{title:"Notification Events",printStart:"Print Started",printComplete:"Print Completed",printFailed:"Print Failed",printStopped:"Print Stopped",printProgress:"Progress Milestones",printProgressDescription:"Notify at 25%, 50%, 75%",printerOffline:"Printer Offline",printerError:"Printer Error",filamentLow:"Low Filament",maintenanceDue:"Maintenance Due",maintenanceDueDescription:"Notify when maintenance is needed"},smartPlug:{title:"Smart Plugs",add:"Add Smart Plug",edit:"Edit Smart Plug",name:"Name",ipAddress:"IP Address",linkedPrinter:"Linked Printer",autoOn:"Auto Power On",autoOnDescription:"Turn on when print starts",autoOff:"Auto Power Off",autoOffDescription:"Turn off after print completes",offDelay:"Off Delay",offDelayMinutes:"Minutes after print",offDelayTemp:"When nozzle below temperature",currentState:"Current State",turnOn:"Turn On",turnOff:"Turn Off"},spoolmanEnabled:"Enable Spoolman Integration",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Connected",spoolmanDisconnected:"Disconnected"},notification:{printStarted:{title:"Print Started",body:"{{printer}}: {{filename}} has started printing"},printCompleted:{title:"Print Completed",body:"{{printer}}: {{filename}} completed successfully"},printFailed:{title:"Print Failed",body:"{{printer}}: {{filename}} has failed"},printStopped:{title:"Print Stopped",body:"{{printer}}: {{filename}} was stopped"},printProgress:{title:"Print Progress",body:"{{printer}}: {{filename}} is {{percent}}% complete"},printerOffline:{title:"Printer Offline",body:"{{printer}} is offline"},printerError:{title:"Printer Error",body:"{{printer}}: {{error}}"},filamentLow:{title:"Low Filament",body:"{{printer}}: Filament is running low"},maintenanceDue:{title:"Maintenance Due",body:"{{printer}}: {{items}} need attention"}},errors:{generic:"Something went wrong",networkError:"Network error. Please check your connection.",notFound:"Not found",unauthorized:"Unauthorized",serverError:"Server error",validationError:"Please check your input",printerConnectionFailed:"Failed to connect to printer",saveFailed:"Failed to save changes",deleteFailed:"Failed to delete",loadFailed:"Failed to load data"},confirm:{delete:"Are you sure you want to delete this?",unsavedChanges:"You have unsaved changes. Are you sure you want to leave?",clearQueue:"Are you sure you want to clear the queue?"}},Wse={nav:{printers:"Drucker",archives:"Archiv",queue:"Warteschlange",stats:"Statistiken",profiles:"Profile",maintenance:"Wartung",projects:"Projekte",files:"Dateimanager",settings:"Einstellungen",system:"System",collapseSidebar:"Seitenleiste einklappen",expandSidebar:"Seitenleiste ausklappen",update:"Update",updateAvailable:"Update verfügbar: v{{version}}",viewOnGithub:"Auf GitHub ansehen",keyboardShortcuts:"Tastaturkürzel (?)",switchToLight:"Zum hellen Modus wechseln",switchToDark:"Zum dunklen Modus wechseln"},common:{save:"Speichern",cancel:"Abbrechen",delete:"Löschen",edit:"Bearbeiten",add:"Hinzufügen",close:"Schließen",confirm:"Bestätigen",loading:"Lädt...",error:"Fehler",success:"Erfolg",warning:"Warnung",enabled:"Aktiviert",disabled:"Deaktiviert",yes:"Ja",no:"Nein",on:"An",off:"Aus",all:"Alle",none:"Keine",search:"Suchen",filter:"Filtern",sort:"Sortieren",refresh:"Aktualisieren",download:"Herunterladen",upload:"Hochladen",actions:"Aktionen",status:"Status",name:"Name",description:"Beschreibung",date:"Datum",time:"Zeit",hours:"Stunden",minutes:"Minuten",seconds:"Sekunden",noPrinters:"Keine Drucker konfiguriert",noData:"Keine Daten verfügbar",required:"Erforderlich",optional:"Optional"},printers:{title:"Drucker",addPrinter:"Drucker hinzufügen",editPrinter:"Drucker bearbeiten",deletePrinter:"Drucker löschen",printerName:"Druckername",serialNumber:"Seriennummer",ipAddress:"IP-Adresse",accessCode:"Zugangscode",model:"Modell",nozzleCount:"Düsenanzahl",autoArchive:"Automatische Archivierung",status:{idle:"Bereit",printing:"Druckt",paused:"Pausiert",offline:"Offline",error:"Fehler",finished:"Fertig",unknown:"Unbekannt"},temperatures:{nozzle:"Düse",bed:"Druckbett",chamber:"Kammer"},progress:"{{percent}}% abgeschlossen",timeRemaining:"Noch {{time}}",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',maintenanceOk:"Wartung OK",maintenanceWarning:"{{count}} Warnung",maintenanceWarning_plural:"{{count}} Warnungen",maintenanceDue:"{{count}} fällig",maintenanceDue_plural:"{{count}} fällig"},archives:{title:"Druckarchiv",searchPlaceholder:"Archiv durchsuchen...",filterByPrinter:"Nach Drucker filtern",filterByStatus:"Nach Status filtern",sortBy:"Sortieren nach",sortNewest:"Neueste zuerst",sortOldest:"Älteste zuerst",sortName:"Name",sortDuration:"Dauer",noArchives:"Keine Archive gefunden",printTime:"Druckzeit",filamentUsed:"Verbrauchtes Filament",cost:"Kosten",reprint:"Erneut drucken",preview:"Vorschau",deleteArchive:"Archiv löschen",deleteConfirm:"Möchten Sie dieses Archiv wirklich löschen?",favorite:"Favorit",unfavorite:"Aus Favoriten entfernen",viewDetails:"Details anzeigen",status:{completed:"Abgeschlossen",failed:"Fehlgeschlagen",stopped:"Gestoppt"}},queue:{title:"Druckwarteschlange",addToQueue:"Zur Warteschlange hinzufügen",clearQueue:"Warteschlange leeren",emptyQueue:"Warteschlange ist leer",position:"Position",scheduledTime:"Geplante Zeit",moveUp:"Nach oben",moveDown:"Nach unten",remove:"Entfernen",startNow:"Jetzt starten",status:{pending:"Ausstehend",printing:"Druckt",completed:"Abgeschlossen",failed:"Fehlgeschlagen",cancelled:"Abgebrochen"}},stats:{title:"Statistiken",overview:"Übersicht",totalPrints:"Gesamtdrucke",successRate:"Erfolgsrate",totalPrintTime:"Gesamtdruckzeit",totalFilament:"Gesamtverbrauch Filament",totalCost:"Gesamtkosten",averagePrintTime:"Durchschnittliche Druckzeit",printsPerDay:"Drucke pro Tag",byPrinter:"Nach Drucker",byMaterial:"Nach Material",byMonth:"Nach Monat",last7Days:"Letzte 7 Tage",last30Days:"Letzte 30 Tage",last90Days:"Letzte 90 Tage",allTime:"Gesamt"},profiles:{title:"Filament-Profile",addProfile:"Profil hinzufügen",editProfile:"Profil bearbeiten",deleteProfile:"Profil löschen",material:"Material",brand:"Marke",color:"Farbe",diameter:"Durchmesser",density:"Dichte",costPerKg:"Kosten pro kg",spoolWeight:"Spulengewicht",noProfiles:"Keine Profile konfiguriert",deleteConfirm:"Möchten Sie dieses Profil wirklich löschen?"},maintenance:{title:"Wartung",overview:"Übersicht",allOk:"Alle Wartungen aktuell",dueCount:"{{count}} Aufgabe fällig",dueCount_plural:"{{count}} Aufgaben fällig",warningCount:"{{count}} Warnung",warningCount_plural:"{{count}} Warnungen",totalPrintTime:"Gesamtdruckzeit",nextMaintenance:"Nächste Wartung",nothingDue:"Nichts fällig",tasks:"Aufgaben",lastPerformed:"Zuletzt durchgeführt",interval:"Intervall",hoursRemaining:"{{hours}}h verbleibend",hoursOverdue:"{{hours}}h überfällig",markDone:"Als erledigt markieren",performMaintenance:"Wartung durchführen",history:"Verlauf",noHistory:"Kein Wartungsverlauf",editPrintHours:"Druckstunden bearbeiten",currentHours:"Aktuelle Stunden",types:{lubricateRails:"Linearschienen schmieren",cleanNozzle:"Düse/Hotend reinigen",checkBelts:"Riemenspannung prüfen",cleanBuildPlate:"Druckbett reinigen",checkExtruder:"Extruderzahnräder prüfen",checkCooling:"Kühlungslüfter prüfen",generalInspection:"Allgemeine Inspektion"}},settings:{title:"Einstellungen",general:"Allgemein",appearance:"Erscheinungsbild",notifications:"Benachrichtigungen",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Sprache",languageDescription:"Wählen Sie Ihre bevorzugte Sprache",theme:"Design",themeLight:"Hell",themeDark:"Dunkel",themeSystem:"System",defaultView:"Standardansicht",defaultViewDescription:"Seite, die beim Öffnen der App angezeigt wird",checkForUpdates:"Nach Updates suchen",autoUpdate:"Automatische Updates",currentVersion:"Aktuelle Version",latestVersion:"Neueste Version",upToDate:"Sie sind auf dem neuesten Stand",updateAvailable:"Update verfügbar",notificationLanguage:"Benachrichtigungssprache",notificationLanguageDescription:"Sprache für Push-Benachrichtigungen",notificationProviders:"Benachrichtigungsanbieter",addProvider:"Anbieter hinzufügen",editProvider:"Anbieter bearbeiten",providerType:"Anbietertyp",testNotification:"Testbenachrichtigung",testSuccess:"Testbenachrichtigung erfolgreich gesendet",testFailed:"Testbenachrichtigung konnte nicht gesendet werden",quietHours:"Ruhezeiten",quietHoursDescription:"Keine Störungen während dieser Zeiten",quietHoursStart:"Beginn",quietHoursEnd:"Ende",events:{title:"Benachrichtigungsereignisse",printStart:"Druck gestartet",printComplete:"Druck abgeschlossen",printFailed:"Druck fehlgeschlagen",printStopped:"Druck gestoppt",printProgress:"Fortschrittsmeldungen",printProgressDescription:"Bei 25%, 50%, 75% benachrichtigen",printerOffline:"Drucker offline",printerError:"Druckerfehler",filamentLow:"Filament niedrig",maintenanceDue:"Wartung fällig",maintenanceDueDescription:"Benachrichtigen, wenn Wartung erforderlich"},smartPlug:{title:"Smart Plugs",add:"Smart Plug hinzufügen",edit:"Smart Plug bearbeiten",name:"Name",ipAddress:"IP-Adresse",linkedPrinter:"Verknüpfter Drucker",autoOn:"Automatisch einschalten",autoOnDescription:"Einschalten beim Druckstart",autoOff:"Automatisch ausschalten",autoOffDescription:"Ausschalten nach Druckende",offDelay:"Ausschaltverzögerung",offDelayMinutes:"Minuten nach Druck",offDelayTemp:"Wenn Düse unter Temperatur",currentState:"Aktueller Status",turnOn:"Einschalten",turnOff:"Ausschalten"},spoolmanEnabled:"Spoolman-Integration aktivieren",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Verbunden",spoolmanDisconnected:"Nicht verbunden"},notification:{printStarted:{title:"Druck gestartet",body:"{{printer}}: {{filename}} wird gedruckt"},printCompleted:{title:"Druck abgeschlossen",body:"{{printer}}: {{filename}} erfolgreich abgeschlossen"},printFailed:{title:"Druck fehlgeschlagen",body:"{{printer}}: {{filename}} ist fehlgeschlagen"},printStopped:{title:"Druck gestoppt",body:"{{printer}}: {{filename}} wurde gestoppt"},printProgress:{title:"Druckfortschritt",body:"{{printer}}: {{filename}} ist zu {{percent}}% abgeschlossen"},printerOffline:{title:"Drucker offline",body:"{{printer}} ist offline"},printerError:{title:"Druckerfehler",body:"{{printer}}: {{error}}"},filamentLow:{title:"Filament niedrig",body:"{{printer}}: Filament geht zur Neige"},maintenanceDue:{title:"Wartung fällig",body:"{{printer}}: {{items}} benötigen Aufmerksamkeit"}},errors:{generic:"Etwas ist schiefgelaufen",networkError:"Netzwerkfehler. Bitte überprüfen Sie Ihre Verbindung.",notFound:"Nicht gefunden",unauthorized:"Nicht autorisiert",serverError:"Serverfehler",validationError:"Bitte überprüfen Sie Ihre Eingabe",printerConnectionFailed:"Verbindung zum Drucker fehlgeschlagen",saveFailed:"Speichern fehlgeschlagen",deleteFailed:"Löschen fehlgeschlagen",loadFailed:"Laden der Daten fehlgeschlagen"},confirm:{delete:"Möchten Sie dies wirklich löschen?",unsavedChanges:"Sie haben ungespeicherte Änderungen. Möchten Sie wirklich verlassen?",clearQueue:"Möchten Sie die Warteschlange wirklich leeren?"}},Kse={en:{translation:qse},de:{translation:Wse}};Es.use(Dq).use(Nse).init({resources:Kse,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const xz=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var bz="popstate";function Xse(t={}){function e(r,i){let{pathname:s,search:o,hash:l}=r.location;return t3("",{pathname:s,search:o,hash:l},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:$0(i)}return Qse(e,n,null,t)}function Zr(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function yo(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Yse(){return Math.random().toString(36).substring(2,10)}function yz(t,e){return{usr:t.state,key:t.key,idx:e}}function t3(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?gx(e):e,state:n,key:e&&e.key||r||Yse()}}function $0({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 gx(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 Qse(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:s=!1}=r,o=i.history,l="POP",c=null,u=d();u==null&&(u=0,o.replaceState({...o.state,idx:u},""));function d(){return(o.state||{idx:null}).idx}function f(){l="POP";let y=d(),v=y==null?null:y-u;u=y,c&&c({action:l,location:b.location,delta:v})}function m(y,v){l="PUSH";let S=t3(b.location,y,v);u=d()+1;let N=yz(S,u),C=b.createHref(S);try{o.pushState(N,"",C)}catch(T){if(T instanceof DOMException&&T.name==="DataCloneError")throw T;i.location.assign(C)}s&&c&&c({action:l,location:b.location,delta:1})}function p(y,v){l="REPLACE";let S=t3(b.location,y,v);u=d();let N=yz(S,u),C=b.createHref(S);o.replaceState(N,"",C),s&&c&&c({action:l,location:b.location,delta:0})}function x(y){return Zse(y)}let b={get action(){return l},get location(){return t(i,o)},listen(y){if(c)throw new Error("A history only accepts one active listener");return i.addEventListener(bz,f),c=y,()=>{i.removeEventListener(bz,f),c=null}},createHref(y){return e(i,y)},createURL:x,encodeLocation(y){let v=x(y);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:m,replace:p,go(y){return o.go(y)}};return b}function Zse(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Zr(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:$0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function Oq(t,e,n="/"){return Jse(t,e,n,!1)}function Jse(t,e,n,r){let i=typeof e=="string"?gx(e):e,s=Pu(i.pathname||"/",n);if(s==null)return null;let o=Lq(t);eoe(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let u=doe(s);l=coe(o[c],u,r)}return l}function Lq(t,e=[],n=[],r="",i=!1){let s=(o,l,c=i,u)=>{let d={relativePath:u===void 0?o.path||"":u,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(r)&&c)return;Zr(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=Su([r,d.relativePath]),m=n.concat(d);o.children&&o.children.length>0&&(Zr(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),Lq(o.children,e,m,f,c)),!(o.path==null&&!o.index)&&e.push({path:f,score:ooe(f,o.index),routesMeta:m})};return t.forEach((o,l)=>{if(o.path===""||!o.path?.includes("?"))s(o,l);else for(let c of Iq(o.path))s(o,l,!0,c)}),e}function Iq(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 o=Iq(r.join("/")),l=[];return l.push(...o.map(c=>c===""?s:[s,c].join("/"))),i&&l.push(...o),l.map(c=>t.startsWith("/")&&c===""?"/":c)}function eoe(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:loe(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var toe=/^:[\w-]+$/,noe=3,roe=2,ioe=1,aoe=10,soe=-2,vz=t=>t==="*";function ooe(t,e){let n=t.split("/"),r=n.length;return n.some(vz)&&(r+=soe),e&&(r+=roe),n.filter(i=>!vz(i)).reduce((i,s)=>i+(toe.test(s)?noe:s===""?ioe:aoe),r)}function loe(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 coe(t,e,n=!1){let{routesMeta:r}=t,i={},s="/",o=[];for(let l=0;l<r.length;++l){let c=r[l],u=l===r.length-1,d=s==="/"?e:e.slice(s.length)||"/",f=H1({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),m=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=H1({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),o.push({params:i,pathname:Su([s,f.pathname]),pathnameBase:poe(Su([s,f.pathnameBase])),route:m}),f.pathnameBase!=="/"&&(s=Su([s,f.pathnameBase]))}return o}function H1(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=uoe(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let s=i[0],o=s.replace(/(.)\/+$/,"$1"),l=i.slice(1);return{params:r.reduce((u,{paramName:d,isOptional:f},m)=>{if(d==="*"){let x=l[m]||"";o=s.slice(0,s.length-x.length).replace(/(.)\/+$/,"$1")}const p=l[m];return f&&!p?u[d]=void 0:u[d]=(p||"").replace(/%2F/g,"/"),u},{}),pathname:s,pathnameBase:o,pattern:t}}function uoe(t,e=!1,n=!0){yo(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,(o,l,c)=>(r.push({paramName:l,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(r.push({paramName:"*"}),i+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":t!==""&&t!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,e?void 0:"i"),r]}function doe(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return yo(!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 Pu(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 Fq=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,hoe=t=>Fq.test(t);function foe(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?gx(t):t,s;if(n)if(hoe(n))s=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),yo(!1,`Pathnames cannot have embedded double slashes - normalizing ${o} -> ${n}`)}n.startsWith("/")?s=_z(n.substring(1),"/"):s=_z(n,e)}else s=e;return{pathname:s,search:goe(r),hash:xoe(i)}}function _z(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 QC(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 moe(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function pD(t){let e=moe(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function gD(t,e,n,r=!1){let i;typeof t=="string"?i=gx(t):(i={...t},Zr(!i.pathname||!i.pathname.includes("?"),QC("?","pathname","search",i)),Zr(!i.pathname||!i.pathname.includes("#"),QC("#","pathname","hash",i)),Zr(!i.search||!i.search.includes("#"),QC("#","search","hash",i)));let s=t===""||i.pathname==="",o=s?"/":i.pathname,l;if(o==null)l=n;else{let f=e.length-1;if(!r&&o.startsWith("..")){let m=o.split("/");for(;m[0]==="..";)m.shift(),f-=1;i.pathname=m.join("/")}l=f>=0?e[f]:"/"}let c=foe(i,l),u=o&&o!=="/"&&o.endsWith("/"),d=(s||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var Su=t=>t.join("/").replace(/\/\/+/g,"/"),poe=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),goe=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,xoe=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,boe=class{constructor(t,e,n,r=!1){this.status=t,this.statusText=e||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function yoe(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function voe(t){return t.map(e=>e.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Uq=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function zq(t,e){let n=t;if(typeof n!="string"||!Fq.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Uq)try{let s=new URL(window.location.href),o=n.startsWith("//")?new URL(s.protocol+n):new URL(n),l=Pu(o.pathname,e);o.origin===s.origin&&l!=null?n=l+o.search+o.hash:i=!0}catch{yo(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Bq=["POST","PUT","PATCH","DELETE"];new Set(Bq);var _oe=["GET",...Bq];new Set(_oe);var xx=w.createContext(null);xx.displayName="DataRouter";var rN=w.createContext(null);rN.displayName="DataRouterState";var woe=w.createContext(!1),$q=w.createContext({isTransitioning:!1});$q.displayName="ViewTransition";var Soe=w.createContext(new Map);Soe.displayName="Fetchers";var Noe=w.createContext(null);Noe.displayName="Await";var wo=w.createContext(null);wo.displayName="Navigation";var Ly=w.createContext(null);Ly.displayName="Location";var dl=w.createContext({outlet:null,matches:[],isDataRoute:!1});dl.displayName="Route";var xD=w.createContext(null);xD.displayName="RouteError";var Hq="REACT_ROUTER_ERROR",Moe="REDIRECT",Eoe="ROUTE_ERROR_RESPONSE";function Coe(t){if(t.startsWith(`${Hq}:${Moe}:{`))try{let e=JSON.parse(t.slice(28));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.location=="string"&&typeof e.reloadDocument=="boolean"&&typeof e.replace=="boolean")return e}catch{}}function Toe(t){if(t.startsWith(`${Hq}:${Eoe}:{`))try{let e=JSON.parse(t.slice(40));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string")return new boe(e.status,e.statusText,e.data)}catch{}}function Aoe(t,{relative:e}={}){Zr(bx(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=w.useContext(wo),{hash:i,pathname:s,search:o}=Iy(t,{relative:e}),l=s;return n!=="/"&&(l=s==="/"?n:Su([n,s])),r.createHref({pathname:l,search:o,hash:i})}function bx(){return w.useContext(Ly)!=null}function Nc(){return Zr(bx(),"useLocation() may be used only in the context of a <Router> component."),w.useContext(Ly).location}var Vq="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Gq(t){w.useContext(wo).static||w.useLayoutEffect(t)}function Mc(){let{isDataRoute:t}=w.useContext(dl);return t?Voe():koe()}function koe(){Zr(bx(),"useNavigate() may be used only in the context of a <Router> component.");let t=w.useContext(xx),{basename:e,navigator:n}=w.useContext(wo),{matches:r}=w.useContext(dl),{pathname:i}=Nc(),s=JSON.stringify(pD(r)),o=w.useRef(!1);return Gq(()=>{o.current=!0}),w.useCallback((c,u={})=>{if(yo(o.current,Vq),!o.current)return;if(typeof c=="number"){n.go(c);return}let d=gD(c,JSON.parse(s),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:Su([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,s,i,t])}var joe=w.createContext(null);function Poe(t){let e=w.useContext(dl).outlet;return w.useMemo(()=>e&&w.createElement(joe.Provider,{value:t},e),[e,t])}function iN(){let{matches:t}=w.useContext(dl),e=t[t.length-1];return e?e.params:{}}function Iy(t,{relative:e}={}){let{matches:n}=w.useContext(dl),{pathname:r}=Nc(),i=JSON.stringify(pD(n));return w.useMemo(()=>gD(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function Roe(t,e){return qq(t,e)}function qq(t,e,n,r,i){Zr(bx(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:s}=w.useContext(wo),{matches:o}=w.useContext(dl),l=o[o.length-1],c=l?l.params:{},u=l?l.pathname:"/",d=l?l.pathnameBase:"/",f=l&&l.route;{let S=f&&f.path||"";Kq(u,!f||S.endsWith("*")||S.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${S}">) 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.
  10. Please change the parent <Route path="${S}"> to <Route path="${S==="/"?"*":`${S}/*`}">.`)}let m=Nc(),p;if(e){let S=typeof e=="string"?gx(e):e;Zr(d==="/"||S.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 "${S.pathname}" was given in the \`location\` prop.`),p=S}else p=m;let x=p.pathname||"/",b=x;if(d!=="/"){let S=d.replace(/^\//,"").split("/");b="/"+x.replace(/^\//,"").split("/").slice(S.length).join("/")}let y=Oq(t,{pathname:b});yo(f||y!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),yo(y==null||y[y.length-1].route.element!==void 0||y[y.length-1].route.Component!==void 0||y[y.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.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 v=Foe(y&&y.map(S=>Object.assign({},S,{params:Object.assign({},c,S.params),pathname:Su([d,s.encodeLocation?s.encodeLocation(S.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?d:Su([d,s.encodeLocation?s.encodeLocation(S.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathnameBase])})),o,n,r,i);return e&&v?w.createElement(Ly.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...p},navigationType:"POP"}},v):v}function Doe(){let t=Hoe(),e=yoe(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},o=null;return console.error("Error handled by React Router default ErrorBoundary:",t),o=w.createElement(w.Fragment,null,w.createElement("p",null,"💿 Hey developer 👋"),w.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",w.createElement("code",{style:s},"ErrorBoundary")," or"," ",w.createElement("code",{style:s},"errorElement")," prop on your route.")),w.createElement(w.Fragment,null,w.createElement("h2",null,"Unexpected Application Error!"),w.createElement("h3",{style:{fontStyle:"italic"}},e),n?w.createElement("pre",{style:i},n):null,o)}var Ooe=w.createElement(Doe,null),Wq=class extends w.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(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const n=Toe(t.digest);n&&(t=n)}let e=t!==void 0?w.createElement(dl.Provider,{value:this.props.routeContext},w.createElement(xD.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?w.createElement(Loe,{error:t},e):e}};Wq.contextType=woe;var ZC=new WeakMap;function Loe({children:t,error:e}){let{basename:n}=w.useContext(wo);if(typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){let r=Coe(e.digest);if(r){let i=ZC.get(e);if(i)throw i;let s=zq(r.location,n);if(Uq&&!ZC.get(e))if(s.isExternal||r.reloadDocument)window.location.href=s.absoluteURL||s.to;else{const o=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(s.to,{replace:r.replace}));throw ZC.set(e,o),o}return w.createElement("meta",{httpEquiv:"refresh",content:`0;url=${s.absoluteURL||s.to}`})}}return t}function Ioe({routeContext:t,match:e,children:n}){let r=w.useContext(xx);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),w.createElement(dl.Provider,{value:t},n)}function Foe(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,o=n?.errors;if(o!=null){let d=s.findIndex(f=>f.route.id&&o?.[f.route.id]!==void 0);Zr(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),s=s.slice(0,Math.min(s.length,d+1))}let l=!1,c=-1;if(n)for(let d=0;d<s.length;d++){let f=s[d];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(c=d),f.route.id){let{loaderData:m,errors:p}=n,x=f.route.loader&&!m.hasOwnProperty(f.route.id)&&(!p||p[f.route.id]===void 0);if(f.route.lazy||x){l=!0,c>=0?s=s.slice(0,c+1):s=[s[0]];break}}}let u=n&&r?(d,f)=>{r(d,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:voe(n.matches),errorInfo:f})}:void 0;return s.reduceRight((d,f,m)=>{let p,x=!1,b=null,y=null;n&&(p=o&&f.route.id?o[f.route.id]:void 0,b=f.route.errorElement||Ooe,l&&(c<0&&m===0?(Kq("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,y=null):c===m&&(x=!0,y=f.route.hydrateFallbackElement||null)));let v=e.concat(s.slice(0,m+1)),S=()=>{let N;return p?N=b:x?N=y:f.route.Component?N=w.createElement(f.route.Component,null):f.route.element?N=f.route.element:N=d,w.createElement(Ioe,{match:f,routeContext:{outlet:d,matches:v,isDataRoute:n!=null},children:N})};return n&&(f.route.ErrorBoundary||f.route.errorElement||m===0)?w.createElement(Wq,{location:n.location,revalidation:n.revalidation,component:b,error:p,children:S(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:u}):S()},null)}function bD(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Uoe(t){let e=w.useContext(xx);return Zr(e,bD(t)),e}function zoe(t){let e=w.useContext(rN);return Zr(e,bD(t)),e}function Boe(t){let e=w.useContext(dl);return Zr(e,bD(t)),e}function yD(t){let e=Boe(t),n=e.matches[e.matches.length-1];return Zr(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function $oe(){return yD("useRouteId")}function Hoe(){let t=w.useContext(xD),e=zoe("useRouteError"),n=yD("useRouteError");return t!==void 0?t:e.errors?.[n]}function Voe(){let{router:t}=Uoe("useNavigate"),e=yD("useNavigate"),n=w.useRef(!1);return Gq(()=>{n.current=!0}),w.useCallback(async(i,s={})=>{yo(n.current,Vq),n.current&&(typeof i=="number"?await t.navigate(i):await t.navigate(i,{fromRouteId:e,...s}))},[t,e])}var wz={};function Kq(t,e,n){!e&&!wz[t]&&(wz[t]=!0,yo(!1,n))}w.memo(Goe);function Goe({routes:t,future:e,state:n,onError:r}){return qq(t,void 0,n,r,e)}function Ig({to:t,replace:e,state:n,relative:r}){Zr(bx(),"<Navigate> may be used only in the context of a <Router> component.");let{static:i}=w.useContext(wo);yo(!i,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:s}=w.useContext(dl),{pathname:o}=Nc(),l=Mc(),c=gD(t,pD(s),o,r==="path"),u=JSON.stringify(c);return w.useEffect(()=>{l(JSON.parse(u),{replace:e,state:n,relative:r})},[l,u,r,e,n]),null}function qoe(t){return Poe(t.context)}function ki(t){Zr(!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 Woe({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:s=!1,unstable_useTransitions:o}){Zr(!bx(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=t.replace(/^\/*/,"/"),c=w.useMemo(()=>({basename:l,navigator:i,static:s,unstable_useTransitions:o,future:{}}),[l,i,s,o]);typeof n=="string"&&(n=gx(n));let{pathname:u="/",search:d="",hash:f="",state:m=null,key:p="default"}=n,x=w.useMemo(()=>{let b=Pu(u,l);return b==null?null:{location:{pathname:b,search:d,hash:f,state:m,key:p},navigationType:r}},[l,u,d,f,m,p,r]);return yo(x!=null,`<Router basename="${l}"> is not able to match the URL "${u}${d}${f}" because it does not start with the basename, so the <Router> won't render anything.`),x==null?null:w.createElement(wo.Provider,{value:c},w.createElement(Ly.Provider,{children:e,value:x}))}function Koe({children:t,location:e}){return Roe(n3(t),e)}function n3(t,e=[]){let n=[];return w.Children.forEach(t,(r,i)=>{if(!w.isValidElement(r))return;let s=[...e,i];if(r.type===w.Fragment){n.push.apply(n,n3(r.props.children,s));return}Zr(r.type===ki,`[${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>`),Zr(!r.props.index||!r.props.children,"An index route cannot have child routes.");let o={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&&(o.children=n3(r.props.children,s)),n.push(o)}),n}var m1="get",p1="application/x-www-form-urlencoded";function aN(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function Xoe(t){return aN(t)&&t.tagName.toLowerCase()==="button"}function Yoe(t){return aN(t)&&t.tagName.toLowerCase()==="form"}function Qoe(t){return aN(t)&&t.tagName.toLowerCase()==="input"}function Zoe(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Joe(t,e){return t.button===0&&(!e||e==="_self")&&!Zoe(t)}function r3(t=""){return new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((e,n)=>{let r=t[n];return e.concat(Array.isArray(r)?r.map(i=>[n,i]):[[n,r]])},[]))}function ele(t,e){let n=r3(t);return e&&e.forEach((r,i)=>{n.has(i)||e.getAll(i).forEach(s=>{n.append(i,s)})}),n}var P_=null;function tle(){if(P_===null)try{new FormData(document.createElement("form"),0),P_=!1}catch{P_=!0}return P_}var nle=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function JC(t){return t!=null&&!nle.has(t)?(yo(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${p1}"`),null):t}function rle(t,e){let n,r,i,s,o;if(Yoe(t)){let l=t.getAttribute("action");r=l?Pu(l,e):null,n=t.getAttribute("method")||m1,i=JC(t.getAttribute("enctype"))||p1,s=new FormData(t)}else if(Xoe(t)||Qoe(t)&&(t.type==="submit"||t.type==="image")){let l=t.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=t.getAttribute("formaction")||l.getAttribute("action");if(r=c?Pu(c,e):null,n=t.getAttribute("formmethod")||l.getAttribute("method")||m1,i=JC(t.getAttribute("formenctype"))||JC(l.getAttribute("enctype"))||p1,s=new FormData(l,t),!tle()){let{name:u,type:d,value:f}=t;if(d==="image"){let m=u?`${u}.`:"";s.append(`${m}x`,"0"),s.append(`${m}y`,"0")}else u&&s.append(u,f)}}else{if(aN(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=m1,r=null,i=p1,o=t}return s&&i==="text/plain"&&(o=s,s=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:s,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function vD(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function ile(t,e,n,r){let i=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return n?i.pathname.endsWith("/")?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname==="/"?i.pathname=`_root.${r}`:e&&Pu(i.pathname,e)==="/"?i.pathname=`${e.replace(/\/$/,"")}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,"")}.${r}`,i}async function ale(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 sle(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 ole(t,e,n){let r=await Promise.all(t.map(async i=>{let s=e.routes[i.route.id];if(s){let o=await ale(s,n);return o.links?o.links():[]}return[]}));return dle(r.flat(1).filter(sle).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function Sz(t,e,n,r,i,s){let o=(c,u)=>n[u]?c.route.id!==n[u].route.id:!0,l=(c,u)=>n[u].pathname!==c.pathname||n[u].route.path?.endsWith("*")&&n[u].params["*"]!==c.params["*"];return s==="assets"?e.filter((c,u)=>o(c,u)||l(c,u)):s==="data"?e.filter((c,u)=>{let d=r.routes[c.route.id];if(!d||!d.hasLoader)return!1;if(o(c,u)||l(c,u))return!0;if(c.route.shouldRevalidate){let f=c.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(t,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof f=="boolean")return f}return!0}):[]}function lle(t,e,{includeHydrateFallback:n}={}){return cle(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 cle(t){return[...new Set(t)]}function ule(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function dle(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let s=JSON.stringify(ule(i));return n.has(s)||(n.add(s),r.push({key:s,link:i})),r},[])}function Xq(){let t=w.useContext(xx);return vD(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function hle(){let t=w.useContext(rN);return vD(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var _D=w.createContext(void 0);_D.displayName="FrameworkContext";function Yq(){let t=w.useContext(_D);return vD(t,"You must render this element inside a <HydratedRouter> element"),t}function fle(t,e){let n=w.useContext(_D),[r,i]=w.useState(!1),[s,o]=w.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=e,m=w.useRef(null);w.useEffect(()=>{if(t==="render"&&o(!0),t==="viewport"){let b=v=>{v.forEach(S=>{o(S.isIntersecting)})},y=new IntersectionObserver(b,{threshold:.5});return m.current&&y.observe(m.current),()=>{y.disconnect()}}},[t]),w.useEffect(()=>{if(r){let b=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(b)}}},[r]);let p=()=>{i(!0)},x=()=>{i(!1),o(!1)};return n?t!=="intent"?[s,m,{}]:[s,m,{onFocus:jb(l,p),onBlur:jb(c,x),onMouseEnter:jb(u,p),onMouseLeave:jb(d,x),onTouchStart:jb(f,p)}]:[!1,m,{}]}function jb(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function mle({page:t,...e}){let{router:n}=Xq(),r=w.useMemo(()=>Oq(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?w.createElement(gle,{page:t,matches:r,...e}):null}function ple(t){let{manifest:e,routeModules:n}=Yq(),[r,i]=w.useState([]);return w.useEffect(()=>{let s=!1;return ole(t,e,n).then(o=>{s||i(o)}),()=>{s=!0}},[t,e,n]),r}function gle({page:t,matches:e,...n}){let r=Nc(),{future:i,manifest:s,routeModules:o}=Yq(),{basename:l}=Xq(),{loaderData:c,matches:u}=hle(),d=w.useMemo(()=>Sz(t,e,u,s,r,"data"),[t,e,u,s,r]),f=w.useMemo(()=>Sz(t,e,u,s,r,"assets"),[t,e,u,s,r]),m=w.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let b=new Set,y=!1;if(e.forEach(S=>{let N=s.routes[S.route.id];!N||!N.hasLoader||(!d.some(C=>C.route.id===S.route.id)&&S.route.id in c&&o[S.route.id]?.shouldRevalidate||N.hasClientLoader?y=!0:b.add(S.route.id))}),b.size===0)return[];let v=ile(t,l,i.unstable_trailingSlashAwareDataRequests,"data");return y&&b.size>0&&v.searchParams.set("_routes",e.filter(S=>b.has(S.route.id)).map(S=>S.route.id).join(",")),[v.pathname+v.search]},[l,i.unstable_trailingSlashAwareDataRequests,c,r,s,d,e,t,o]),p=w.useMemo(()=>lle(f,s),[f,s]),x=ple(f);return w.createElement(w.Fragment,null,m.map(b=>w.createElement("link",{key:b,rel:"prefetch",as:"fetch",href:b,...n})),p.map(b=>w.createElement("link",{key:b,rel:"modulepreload",href:b,...n})),x.map(({key:b,link:y})=>w.createElement("link",{key:b,nonce:n.nonce,...y})))}function xle(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var ble=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{ble&&(window.__reactRouterVersion="7.12.0")}catch{}function yle({basename:t,children:e,unstable_useTransitions:n,window:r}){let i=w.useRef();i.current==null&&(i.current=Xse({window:r,v5Compat:!0}));let s=i.current,[o,l]=w.useState({action:s.action,location:s.location}),c=w.useCallback(u=>{n===!1?l(u):w.startTransition(()=>l(u))},[n]);return w.useLayoutEffect(()=>s.listen(c),[s,c]),w.createElement(Woe,{basename:t,children:e,location:o.location,navigationType:o.action,navigator:s,unstable_useTransitions:n})}var Qq=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Os=w.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:s,replace:o,state:l,target:c,to:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:m,...p},x){let{basename:b,unstable_useTransitions:y}=w.useContext(wo),v=typeof u=="string"&&Qq.test(u),S=zq(u,b);u=S.to;let N=Aoe(u,{relative:i}),[C,T,k]=fle(r,p),E=wle(u,{replace:o,state:l,target:c,preventScrollReset:d,relative:i,viewTransition:f,unstable_defaultShouldRevalidate:m,unstable_useTransitions:y});function D(R){e&&e(R),R.defaultPrevented||E(R)}let A=w.createElement("a",{...p,...k,href:S.absoluteURL||N,onClick:S.isExternal||s?e:D,ref:xle(x,T),target:c,"data-discover":!v&&n==="render"?"true":void 0});return C&&!v?w.createElement(w.Fragment,null,A,w.createElement(mle,{page:N})):A});Os.displayName="Link";var r0=w.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:s,to:o,viewTransition:l,children:c,...u},d){let f=Iy(o,{relative:u.relative}),m=Nc(),p=w.useContext(rN),{navigator:x,basename:b}=w.useContext(wo),y=p!=null&&Cle(f)&&l===!0,v=x.encodeLocation?x.encodeLocation(f).pathname:f.pathname,S=m.pathname,N=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;n||(S=S.toLowerCase(),N=N?N.toLowerCase():null,v=v.toLowerCase()),N&&b&&(N=Pu(N,b)||N);const C=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let T=S===v||!i&&S.startsWith(v)&&S.charAt(C)==="/",k=N!=null&&(N===v||!i&&N.startsWith(v)&&N.charAt(v.length)==="/"),E={isActive:T,isPending:k,isTransitioning:y},D=T?e:void 0,A;typeof r=="function"?A=r(E):A=[r,T?"active":null,k?"pending":null,y?"transitioning":null].filter(Boolean).join(" ");let R=typeof s=="function"?s(E):s;return w.createElement(Os,{...u,"aria-current":D,className:A,ref:d,style:R,to:o,viewTransition:l},typeof c=="function"?c(E):c)});r0.displayName="NavLink";var vle=w.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:s,method:o=m1,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:m,...p},x)=>{let{unstable_useTransitions:b}=w.useContext(wo),y=Mle(),v=Ele(l,{relative:u}),S=o.toLowerCase()==="get"?"get":"post",N=typeof l=="string"&&Qq.test(l),C=T=>{if(c&&c(T),T.defaultPrevented)return;T.preventDefault();let k=T.nativeEvent.submitter,E=k?.getAttribute("formmethod")||o,D=()=>y(k||T.currentTarget,{fetcherKey:e,method:E,navigate:n,replace:i,state:s,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:m});b&&n!==!1?w.startTransition(()=>D()):D()};return w.createElement("form",{ref:x,method:S,action:v,onSubmit:r?c:C,...p,"data-discover":!N&&t==="render"?"true":void 0})});vle.displayName="Form";function _le(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Zq(t){let e=w.useContext(xx);return Zr(e,_le(t)),e}function wle(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:s,viewTransition:o,unstable_defaultShouldRevalidate:l,unstable_useTransitions:c}={}){let u=Mc(),d=Nc(),f=Iy(t,{relative:s});return w.useCallback(m=>{if(Joe(m,e)){m.preventDefault();let p=n!==void 0?n:$0(d)===$0(f),x=()=>u(t,{replace:p,state:r,preventScrollReset:i,relative:s,viewTransition:o,unstable_defaultShouldRevalidate:l});c?w.startTransition(()=>x()):x()}},[d,u,f,n,r,e,t,i,s,o,l,c])}function wD(t){yo(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let e=w.useRef(r3(t)),n=w.useRef(!1),r=Nc(),i=w.useMemo(()=>ele(r.search,n.current?null:e.current),[r.search]),s=Mc(),o=w.useCallback((l,c)=>{const u=r3(typeof l=="function"?l(new URLSearchParams(i)):l);n.current=!0,s("?"+u,c)},[s,i]);return[i,o]}var Sle=0,Nle=()=>`__${String(++Sle)}__`;function Mle(){let{router:t}=Zq("useSubmit"),{basename:e}=w.useContext(wo),n=$oe(),r=t.fetch,i=t.navigate;return w.useCallback(async(s,o={})=>{let{action:l,method:c,encType:u,formData:d,body:f}=rle(s,e);if(o.navigate===!1){let m=o.fetcherKey||Nle();await r(m,n,o.action||l,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:f,formMethod:o.method||c,formEncType:o.encType||u,flushSync:o.flushSync})}else await i(o.action||l,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:f,formMethod:o.method||c,formEncType:o.encType||u,replace:o.replace,state:o.state,fromRouteId:n,flushSync:o.flushSync,viewTransition:o.viewTransition})},[r,i,e,n])}function Ele(t,{relative:e}={}){let{basename:n}=w.useContext(wo),r=w.useContext(dl);Zr(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),s={...Iy(t||".",{relative:e})},o=Nc();if(t==null){s.search=o.search;let l=new URLSearchParams(s.search),c=l.getAll("index");if(c.some(d=>d==="")){l.delete("index"),c.filter(f=>f).forEach(f=>l.append("index",f));let d=l.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:Su([n,s.pathname])),$0(s)}function Cle(t,{relative:e}={}){let n=w.useContext($q);Zr(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Zq("useViewTransitionState"),i=Iy(t,{relative:e});if(!n.isTransitioning)return!1;let s=Pu(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Pu(n.nextLocation.pathname,r)||n.nextLocation.pathname;return H1(i.pathname,o)!=null||H1(i.pathname,s)!=null}var pu=Nq();const Tle=ul(pu);var Mm=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(){}},Ale={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},kle=class{#t=Ale;#e=!1;setTimeoutProvider(t){this.#t=t}setTimeout(t,e){return this.#t.setTimeout(t,e)}clearTimeout(t){this.#t.clearTimeout(t)}setInterval(t,e){return this.#t.setInterval(t,e)}clearInterval(t){this.#t.clearInterval(t)}},jf=new kle;function jle(t){setTimeout(t,0)}var tm=typeof window>"u"||"Deno"in globalThis;function Ka(){}function Ple(t,e){return typeof t=="function"?t(e):t}function i3(t){return typeof t=="number"&&t>=0&&t!==1/0}function Jq(t,e){return Math.max(t+(e||0)-Date.now(),0)}function nh(t,e){return typeof t=="function"?t(e):t}function $o(t,e){return typeof t=="function"?t(e):t}function Nz(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:o,stale:l}=t;if(o){if(r){if(e.queryHash!==SD(o,e.options))return!1}else if(!H0(e.queryKey,o))return!1}if(n!=="all"){const c=e.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||i&&i!==e.state.fetchStatus||s&&!s(e))}function Mz(t,e){const{exact:n,status:r,predicate:i,mutationKey:s}=t;if(s){if(!e.options.mutationKey)return!1;if(n){if(nm(e.options.mutationKey)!==nm(s))return!1}else if(!H0(e.options.mutationKey,s))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function SD(t,e){return(e?.queryKeyHashFn||nm)(t)}function nm(t){return JSON.stringify(t,(e,n)=>a3(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function H0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>H0(t[n],e[n])):!1}var Rle=Object.prototype.hasOwnProperty;function ND(t,e){if(t===e)return t;const n=Ez(t)&&Ez(e);if(!n&&!(a3(t)&&a3(e)))return e;const i=(n?t:Object.keys(t)).length,s=n?e:Object.keys(e),o=s.length,l=n?new Array(o):{};let c=0;for(let u=0;u<o;u++){const d=n?u:s[u],f=t[d],m=e[d];if(f===m){l[d]=f,(n?u<i:Rle.call(t,d))&&c++;continue}if(f===null||m===null||typeof f!="object"||typeof m!="object"){l[d]=m;continue}const p=ND(f,m);l[d]=p,p===f&&c++}return i===o&&c===i?t:l}function V0(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 Ez(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function a3(t){if(!Cz(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!Cz(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Cz(t){return Object.prototype.toString.call(t)==="[object Object]"}function Dle(t){return new Promise(e=>{jf.setTimeout(e,t)})}function s3(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?ND(t,e):e}function Ole(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function Lle(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var MD=Symbol();function eW(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===MD?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function tW(t,e){return typeof t=="function"?t(...e):!!t}var Ile=class extends Mm{#t;#e;#n;constructor(){super(),this.#n=t=>{if(!tm&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#n=t,this.#e?.(),this.#e=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#t!==t&&(this.#t=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},ED=new Ile;function o3(){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 Fle=jle;function Ule(){let t=[],e=0,n=l=>{l()},r=l=>{l()},i=Fle;const s=l=>{e?t.push(l):i(()=>{n(l)})},o=()=>{const l=t;t=[],l.length&&i(()=>{r(()=>{l.forEach(c=>{n(c)})})})};return{batch:l=>{let c;e++;try{c=l()}finally{e--,e||o()}return c},batchCalls:l=>(...c)=>{s(()=>{l(...c)})},schedule:s,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{i=l}}}var fi=Ule(),zle=class extends Mm{#t=!0;#e;#n;constructor(){super(),this.#n=t=>{if(!tm&&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.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#n=t,this.#e?.(),this.#e=t(this.setOnline.bind(this))}setOnline(t){this.#t!==t&&(this.#t=t,this.listeners.forEach(n=>{n(t)}))}isOnline(){return this.#t}},V1=new zle;function Ble(t){return Math.min(1e3*2**t,3e4)}function nW(t){return(t??"online")==="online"?V1.isOnline():!0}var l3=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function rW(t){let e=!1,n=0,r;const i=o3(),s=()=>i.status!=="pending",o=b=>{if(!s()){const y=new l3(b);m(y),t.onCancel?.(y)}},l=()=>{e=!0},c=()=>{e=!1},u=()=>ED.isFocused()&&(t.networkMode==="always"||V1.isOnline())&&t.canRun(),d=()=>nW(t.networkMode)&&t.canRun(),f=b=>{s()||(r?.(),i.resolve(b))},m=b=>{s()||(r?.(),i.reject(b))},p=()=>new Promise(b=>{r=y=>{(s()||u())&&b(y)},t.onPause?.()}).then(()=>{r=void 0,s()||t.onContinue?.()}),x=()=>{if(s())return;let b;const y=n===0?t.initialPromise:void 0;try{b=y??t.fn()}catch(v){b=Promise.reject(v)}Promise.resolve(b).then(f).catch(v=>{if(s())return;const S=t.retry??(tm?0:3),N=t.retryDelay??Ble,C=typeof N=="function"?N(n,v):N,T=S===!0||typeof S=="number"&&n<S||typeof S=="function"&&S(n,v);if(e||!T){m(v);return}n++,t.onFail?.(n,v),Dle(C).then(()=>u()?void 0:p()).then(()=>{e?m(v):x()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?x():p().then(x),i)}}var iW=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),i3(this.gcTime)&&(this.#t=jf.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(tm?1/0:300*1e3))}clearGcTimeout(){this.#t&&(jf.clearTimeout(this.#t),this.#t=void 0)}},$le=class extends iW{#t;#e;#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.#t=Az(this.options),this.state=t.state??this.#t,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=Az(this.options);e.data!==void 0&&(this.setState(Tz(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=s3(this.state.data,t,this.options);return this.#s({data:n,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),n}setState(t,e){this.#s({type:"setState",state:t,setStateOptions:e})}cancel(t){const e=this.#r?.promise;return this.#r?.cancel(t),e?e.then(Ka).catch(Ka):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(t=>$o(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===MD||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>nh(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:!Jq(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 l=this.observers.find(c=>c.options.queryFn);l&&this.setOptions(l.options)}const n=new AbortController,r=l=>{Object.defineProperty(l,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{const l=eW(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(l,u,this):l(u)},o=(()=>{const l={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(l),l})();this.options.behavior?.onFetch(o,this),this.#e=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#s({type:"fetch",meta:o.fetchOptions?.meta}),this.#r=rW({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:l=>{l instanceof l3&&l.revert&&this.setState({...this.#e,fetchStatus:"idle"}),n.abort()},onFail:(l,c)=>{this.#s({type:"failed",failureCount:l,error:c})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{const l=await this.#r.start();if(l===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(l),this.#n.config.onSuccess?.(l,this),this.#n.config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof l3){if(l.silent)return this.#r.promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw this.#s({type:"error",error:l}),this.#n.config.onError?.(l,this),this.#n.config.onSettled?.(this.state.data,l,this),l}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,...aW(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...Tz(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#e=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),fi.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function aW(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:nW(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function Tz(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Az(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 CD=class extends Mm{constructor(t,e){super(),this.options=e,this.#t=t,this.#s=null,this.#o=o3(),this.bindMethods(),this.setOptions(e)}#t;#e=void 0;#n=void 0;#i=void 0;#r;#a;#o;#s;#f;#d;#h;#c;#u;#l;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),kz(this.#e,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return c3(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return c3(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#v(),this.#_(),this.#e.removeObserver(this)}setOptions(t){const e=this.options,n=this.#e;if(this.options=this.#t.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof $o(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#w(),this.#e.setOptions(this.options),e._defaulted&&!V0(this.options,e)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&jz(this.#e,n,this.options,e)&&this.#m(),this.updateResult(),r&&(this.#e!==n||$o(this.options.enabled,this.#e)!==$o(e.enabled,this.#e)||nh(this.options.staleTime,this.#e)!==nh(e.staleTime,this.#e))&&this.#g();const i=this.#x();r&&(this.#e!==n||$o(this.options.enabled,this.#e)!==$o(e.enabled,this.#e)||i!==this.#l)&&this.#b(i)}getOptimisticResult(t){const e=this.#t.getQueryCache().build(this.#t,t),n=this.createResult(e,t);return Vle(this,n)&&(this.#i=n,this.#a=this.options,this.#r=this.#e.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.#e}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#t.defaultQueryOptions(t),n=this.#t.getQueryCache().build(this.#t,e);return n.fetch().then(()=>this.createResult(n,e))}fetch(t){return this.#m({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#i))}#m(t){this.#w();let e=this.#e.fetch(this.options,t);return t?.throwOnError||(e=e.catch(Ka)),e}#g(){this.#v();const t=nh(this.options.staleTime,this.#e);if(tm||this.#i.isStale||!i3(t))return;const n=Jq(this.#i.dataUpdatedAt,t)+1;this.#c=jf.setTimeout(()=>{this.#i.isStale||this.updateResult()},n)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#b(t){this.#_(),this.#l=t,!(tm||$o(this.options.enabled,this.#e)===!1||!i3(this.#l)||this.#l===0)&&(this.#u=jf.setInterval(()=>{(this.options.refetchIntervalInBackground||ED.isFocused())&&this.#m()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){this.#c&&(jf.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(jf.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const n=this.#e,r=this.options,i=this.#i,s=this.#r,o=this.#a,c=t!==n?t.state:this.#n,{state:u}=t;let d={...u},f=!1,m;if(e._optimisticResults){const D=this.hasListeners(),A=!D&&kz(t,e),R=D&&jz(t,n,e,r);(A||R)&&(d={...d,...aW(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:p,errorUpdatedAt:x,status:b}=d;m=d.data;let y=!1;if(e.placeholderData!==void 0&&m===void 0&&b==="pending"){let D;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(D=i.data,y=!0):D=typeof e.placeholderData=="function"?e.placeholderData(this.#h?.state.data,this.#h):e.placeholderData,D!==void 0&&(b="success",m=s3(i?.data,D,e),f=!0)}if(e.select&&m!==void 0&&!y)if(i&&m===s?.data&&e.select===this.#f)m=this.#d;else try{this.#f=e.select,m=e.select(m),m=s3(i?.data,m,e),this.#d=m,this.#s=null}catch(D){this.#s=D}this.#s&&(p=this.#s,m=this.#d,x=Date.now(),b="error");const v=d.fetchStatus==="fetching",S=b==="pending",N=b==="error",C=S&&v,T=m!==void 0,E={status:b,fetchStatus:d.fetchStatus,isPending:S,isSuccess:b==="success",isError:N,isInitialLoading:C,isLoading:C,data:m,dataUpdatedAt:d.dataUpdatedAt,error:p,errorUpdatedAt:x,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:v,isRefetching:v&&!S,isLoadingError:N&&!T,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:N&&T,isStale:TD(t,e),refetch:this.refetch,promise:this.#o,isEnabled:$o(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const D=F=>{E.status==="error"?F.reject(E.error):E.data!==void 0&&F.resolve(E.data)},A=()=>{const F=this.#o=E.promise=o3();D(F)},R=this.#o;switch(R.status){case"pending":t.queryHash===n.queryHash&&D(R);break;case"fulfilled":(E.status==="error"||E.data!==R.value)&&A();break;case"rejected":(E.status!=="error"||E.error!==R.reason)&&A();break}}return E}updateResult(){const t=this.#i,e=this.createResult(this.#e,this.options);if(this.#r=this.#e.state,this.#a=this.options,this.#r.data!==void 0&&(this.#h=this.#e),V0(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(o=>{const l=o;return this.#i[l]!==t[l]&&s.has(l)})};this.#S({listeners:n()})}#w(){const t=this.#t.getQueryCache().build(this.#t,this.options);if(t===this.#e)return;const e=this.#e;this.#e=t,this.#n=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#S(t){fi.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function Hle(t,e){return $o(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function kz(t,e){return Hle(t,e)||t.state.data!==void 0&&c3(t,e,e.refetchOnMount)}function c3(t,e,n){if($o(e.enabled,t)!==!1&&nh(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&TD(t,e)}return!1}function jz(t,e,n,r){return(t!==e||$o(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&TD(t,n)}function TD(t,e){return $o(e.enabled,t)!==!1&&t.isStaleByTime(nh(e.staleTime,t))}function Vle(t,e){return!V0(t.getCurrentResult(),e)}function Pz(t){return{onFetch:(e,n)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,s=e.state.data?.pages||[],o=e.state.data?.pageParams||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let d=!1;const f=x=>{Object.defineProperty(x,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},m=eW(e.options,e.fetchOptions),p=async(x,b,y)=>{if(d)return Promise.reject();if(b==null&&x.pages.length)return Promise.resolve(x);const S=(()=>{const k={client:e.client,queryKey:e.queryKey,pageParam:b,direction:y?"backward":"forward",meta:e.options.meta};return f(k),k})(),N=await m(S),{maxPages:C}=e.options,T=y?Lle:Ole;return{pages:T(x.pages,N,C),pageParams:T(x.pageParams,b,C)}};if(i&&s.length){const x=i==="backward",b=x?Gle:Rz,y={pages:s,pageParams:o},v=b(r,y);l=await p(y,v,x)}else{const x=t??s.length;do{const b=c===0?o[0]??r.initialPageParam:Rz(r,l);if(c>0&&b==null)break;l=await p(l,b),c++}while(c<x)}return l};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 Rz(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 Gle(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var qle=class extends iW{#t;#e;#n;#i;constructor(t){super(),this.#t=t.client,this.mutationId=t.mutationId,this.#n=t.mutationCache,this.#e=[],this.state=t.state||sW(),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.#e.includes(t)||(this.#e.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#e=this.#e.filter(e=>e!==t),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#e.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.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#i=rW({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(s,o)=>{this.#r({type:"failed",failureCount:s,error:o})},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 o=await this.options.onMutate?.(t,n);o!==this.state.context&&this.#r({type:"pending",context:o,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),fi.batch(()=>{this.#e.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function sW(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Wle=class extends Mm{constructor(t={}){super(),this.config=t,this.#t=new Set,this.#e=new Map,this.#n=0}#t;#e;#n;build(t,e,n){const r=new qle({client:t,mutationCache:this,mutationId:++this.#n,options:t.defaultMutationOptions(e),state:n});return this.add(r),r}add(t){this.#t.add(t);const e=R_(t);if(typeof e=="string"){const n=this.#e.get(e);n?n.push(t):this.#e.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#t.delete(t)){const e=R_(t);if(typeof e=="string"){const n=this.#e.get(e);if(n)if(n.length>1){const r=n.indexOf(t);r!==-1&&n.splice(r,1)}else n[0]===t&&this.#e.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=R_(t);if(typeof e=="string"){const r=this.#e.get(e)?.find(i=>i.state.status==="pending");return!r||r===t}else return!0}runNext(t){const e=R_(t);return typeof e=="string"?this.#e.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){fi.batch(()=>{this.#t.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(t){const e={exact:!0,...t};return this.getAll().find(n=>Mz(e,n))}findAll(t={}){return this.getAll().filter(e=>Mz(t,e))}notify(t){fi.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return fi.batch(()=>Promise.all(t.map(e=>e.continue().catch(Ka))))}};function R_(t){return t.options.scope?.id}var Kle=class extends Mm{#t;#e=void 0;#n;#i;constructor(e,n){super(),this.#t=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.#t.defaultMutationOptions(e),V0(this.options,n)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&nm(n.mutationKey)!==nm(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.#e}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.#t.getMutationCache().build(this.#t,this.options),this.#n.addObserver(this),this.#n.execute(e)}#r(){const e=this.#n?.state??sW();this.#e={...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){fi.batch(()=>{if(this.#i&&this.hasListeners()){const n=this.#e.variables,r=this.#e.context,i={client:this.#t,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.#e)})})}};function Dz(t,e){const n=new Set(e);return t.filter(r=>!n.has(r))}function Xle(t,e,n){const r=t.slice(0);return r[e]=n,r}var Yle=class extends Mm{#t;#e;#n;#i;#r;#a;#o;#s;#f=[];constructor(t,e,n){super(),this.#t=t,this.#i=n,this.#n=[],this.#r=[],this.#e=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#r.forEach(t=>{t.subscribe(e=>{this.#u(t,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#r.forEach(t=>{t.destroy()})}setQueries(t,e){this.#n=t,this.#i=e,fi.batch(()=>{const n=this.#r,r=this.#c(this.#n);this.#f=r,r.forEach(d=>d.observer.setOptions(d.defaultedQueryOptions));const i=r.map(d=>d.observer),s=i.map(d=>d.getCurrentResult()),o=n.length!==i.length,l=i.some((d,f)=>d!==n[f]),c=o||l,u=c?!0:s.some((d,f)=>{const m=this.#e[f];return!m||!V0(d,m)});!c&&!u||(c&&(this.#r=i),this.#e=s,this.hasListeners()&&(c&&(Dz(n,i).forEach(d=>{d.destroy()}),Dz(i,n).forEach(d=>{d.subscribe(f=>{this.#u(d,f)})})),this.#l()))})}getCurrentResult(){return this.#e}getQueries(){return this.#r.map(t=>t.getCurrentQuery())}getObservers(){return this.#r}getOptimisticResult(t,e){const n=this.#c(t),r=n.map(i=>i.observer.getOptimisticResult(i.defaultedQueryOptions));return[r,i=>this.#h(i??r,e),()=>this.#d(r,n)]}#d(t,e){return e.map((n,r)=>{const i=t[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,s=>{e.forEach(o=>{o.observer.trackProp(s)})})})}#h(t,e){return e?((!this.#a||this.#e!==this.#s||e!==this.#o)&&(this.#o=e,this.#s=this.#e,this.#a=ND(this.#a,e(t))),this.#a):t}#c(t){const e=new Map;this.#r.forEach(r=>{const i=r.options.queryHash;if(!i)return;const s=e.get(i);s?s.push(r):e.set(i,[r])});const n=[];return t.forEach(r=>{const i=this.#t.defaultQueryOptions(r),o=e.get(i.queryHash)?.shift()??new CD(this.#t,i);n.push({defaultedQueryOptions:i,observer:o})}),n}#u(t,e){const n=this.#r.indexOf(t);n!==-1&&(this.#e=Xle(this.#e,n,e),this.#l())}#l(){if(this.hasListeners()){const t=this.#a,e=this.#d(this.#e,this.#f),n=this.#h(e,this.#i?.combine);t!==n&&fi.batch(()=>{this.listeners.forEach(r=>{r(this.#e)})})}}},Qle=class extends Mm{constructor(t={}){super(),this.config=t,this.#t=new Map}#t;build(t,e,n){const r=e.queryKey,i=e.queryHash??SD(r,e);let s=this.get(i);return s||(s=new $le({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(s)),s}add(t){this.#t.has(t.queryHash)||(this.#t.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#t.get(t.queryHash);e&&(t.destroy(),e===t&&this.#t.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){fi.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#t.get(t)}getAll(){return[...this.#t.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(n=>Nz(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>Nz(t,n)):e}notify(t){fi.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){fi.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){fi.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Zle=class{#t;#e;#n;#i;#r;#a;#o;#s;constructor(t={}){this.#t=t.queryCache||new Qle,this.#e=t.mutationCache||new Wle,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=ED.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#s=V1.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(t){return this.#t.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#e.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#t.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=this.#t.build(this,e),r=n.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(nh(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return this.#t.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.#t.get(r.queryHash)?.state.data,o=Ple(e,s);if(o!==void 0)return this.#t.build(this,r).setData(o,{...n,manual:!0})}setQueriesData(t,e,n){return fi.batch(()=>this.#t.findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,n)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#t.get(e.queryHash)?.state}removeQueries(t){const e=this.#t;fi.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#t;return fi.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=fi.batch(()=>this.#t.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(Ka).catch(Ka)}invalidateQueries(t,e={}){return fi.batch(()=>(this.#t.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=fi.batch(()=>this.#t.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let s=i.fetch(void 0,n);return n.throwOnError||(s=s.catch(Ka)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(Ka)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#t.build(this,e);return n.isStaleByTime(nh(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Ka).catch(Ka)}fetchInfiniteQuery(t){return t.behavior=Pz(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Ka).catch(Ka)}ensureInfiniteQueryData(t){return t.behavior=Pz(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return V1.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#n}setDefaultOptions(t){this.#n=t}setQueryDefaults(t,e){this.#i.set(nm(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{H0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(nm(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{H0(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=SD(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===MD&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#n.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}},oW=w.createContext(void 0),on=t=>{const e=w.useContext(oW);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Jle=({client:t,children:e})=>(w.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),a.jsx(oW.Provider,{value:t,children:e})),lW=w.createContext(!1),cW=()=>w.useContext(lW);lW.Provider;function ece(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var tce=w.createContext(ece()),uW=()=>w.useContext(tce),dW=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},hW=t=>{w.useEffect(()=>{t.clearReset()},[t])},fW=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||tW(n,[t.error,r])),mW=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))}},pW=(t,e)=>t.isLoading&&t.isFetching&&!e,u3=(t,e)=>t?.suspense&&e.isPending,G1=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function gW({queries:t,...e},n){const r=on(),i=cW(),s=uW(),o=w.useMemo(()=>t.map(b=>{const y=r.defaultQueryOptions(b);return y._optimisticResults=i?"isRestoring":"optimistic",y}),[t,r,i]);o.forEach(b=>{mW(b),dW(b,s)}),hW(s);const[l]=w.useState(()=>new Yle(r,o,e)),[c,u,d]=l.getOptimisticResult(o,e.combine),f=!i&&e.subscribed!==!1;w.useSyncExternalStore(w.useCallback(b=>f?l.subscribe(fi.batchCalls(b)):Ka,[l,f]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),w.useEffect(()=>{l.setQueries(o,e)},[o,e,l]);const p=c.some((b,y)=>u3(o[y],b))?c.flatMap((b,y)=>{const v=o[y];if(v){const S=new CD(r,v);if(u3(v,b))return G1(v,S,s);pW(b,i)&&G1(v,S,s)}return[]}):[];if(p.length>0)throw Promise.all(p);const x=c.find((b,y)=>{const v=o[y];return v&&fW({result:b,errorResetBoundary:s,throwOnError:v.throwOnError,query:r.getQueryCache().get(v.queryHash),suspense:v.suspense})});if(x?.error)throw x.error;return u(d())}function nce(t,e,n){const r=cW(),i=uW(),s=on(),o=s.defaultQueryOptions(t);s.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?"isRestoring":"optimistic",mW(o),dW(o,i),hW(i);const l=!s.getQueryCache().get(o.queryHash),[c]=w.useState(()=>new e(s,o)),u=c.getOptimisticResult(o),d=!r&&t.subscribed!==!1;if(w.useSyncExternalStore(w.useCallback(f=>{const m=d?c.subscribe(fi.batchCalls(f)):Ka;return c.updateResult(),m},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),w.useEffect(()=>{c.setOptions(o)},[o,c]),u3(o,u))throw G1(o,c,i);if(fW({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw u.error;return s.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!tm&&pW(u,r)&&(l?G1(o,c,i):s.getQueryCache().get(o.queryHash)?.promise)?.catch(Ka).finally(()=>{c.updateResult()}),o.notifyOnChangeProps?u:c.trackResult(u)}function at(t,e){return nce(t,CD)}function mt(t,e){const n=on(),[r]=w.useState(()=>new Kle(n,t));w.useEffect(()=>{r.setOptions(t)},[r,t]);const i=w.useSyncExternalStore(w.useCallback(o=>r.subscribe(fi.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=w.useCallback((o,l)=>{r.mutate(o,l).catch(Ka)},[r]);if(i.error&&tW(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:s,mutateAsync:i.mutate}}const rce=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ice=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Oz=t=>{const e=ice(t);return e.charAt(0).toUpperCase()+e.slice(1)},xW=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),ace=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var sce={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 oce=w.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:s,iconNode:o,...l},c)=>w.createElement("svg",{ref:c,...sce,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:xW("lucide",i),...!s&&!ace(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,d])=>w.createElement(u,d)),...Array.isArray(s)?s:[s]]));const Ke=(t,e)=>{const n=w.forwardRef(({className:r,...i},s)=>w.createElement(oce,{ref:s,iconNode:e,className:xW(`lucide-${rce(Oz(t))}`,`lucide-${t}`,r),...i}));return n.displayName=Oz(t),n};const lce=[["path",{d:"M18 17.5a2.5 2.5 0 1 1-4 2.03V12",key:"yd12zl"}],["path",{d:"M6 12H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"larmp2"}],["path",{d:"M6 8h12",key:"6g4wlu"}],["path",{d:"M6.6 15.572A2 2 0 1 0 10 17v-5",key:"1x1kqn"}]],cce=Ke("air-vent",lce);const uce=[["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"}]],fo=Ke("archive",uce);const dce=[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]],hce=Ke("arrow-down-wide-narrow",dce);const fce=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],G0=Ke("arrow-down",fce);const mce=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],pce=Ke("arrow-left",mce);const gce=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],d3=Ke("arrow-right",gce);const xce=[["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"}]],bW=Ke("arrow-up-down",xce);const bce=[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]],yce=Ke("arrow-up-narrow-wide",bce);const vce=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Fg=Ke("arrow-up",vce);const _ce=[["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"}]],_g=Ke("bell",_ce);const wce=[["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"}]],Sce=Ke("bold",wce);const Nce=[["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"}]],Mce=Ke("book",Nce);const Ece=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],Cce=Ke("bookmark",Ece);const Tce=[["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"}]],Pi=Ke("box",Tce);const Ace=[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]],yW=Ke("briefcase",Ace);const kce=[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]],sN=Ke("bug",kce);const jce=[["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"}]],Pce=Ke("cable",jce);const Rce=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]],Dce=Ke("calculator",Rce);const Oce=[["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"}]],Lce=Ke("calendar-days",Oce);const Ice=[["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"}]],ti=Ke("calendar",Ice);const Fce=[["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"}]],Ug=Ke("camera",Fce);const Uce=[["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"}]],zce=Ke("chart-column",Uce);const Bce=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Wi=Ke("check",Bce);const $ce=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Xr=Ke("chevron-down",$ce);const Hce=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],vs=Ke("chevron-right",Hce);const Vce=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],gh=Ke("chevron-left",Vce);const Gce=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],xh=Ke("chevron-up",Gce);const qce=[["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"}]],Ii=Ke("circle-alert",qce);const Wce=[["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"}]],eT=Ke("circle-arrow-up",Wce);const Kce=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Tr=Ke("circle-check-big",Kce);const Xce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],oN=Ke("circle-check",Xce);const Yce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Qce=Ke("circle-dot",Yce);const Zce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Jce=Ke("circle-question-mark",Zce);const eue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],tue=Ke("circle-stop",eue);const nue=[["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"}]],qi=Ke("circle-x",nue);const rue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],h3=Ke("circle",rue);const iue=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Qn=Ke("clock",iue);const aue=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],lN=Ke("cloud",aue);const sue=[["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"}]],oue=Ke("code-xml",sue);const lue=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],vW=Ke("code",lue);const cue=[["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"}]],uue=Ke("coffee",cue);const due=[["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"}]],hue=Ke("cog",due);const fue=[["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"}]],mue=Ke("compass",fue);const pue=[["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"}]],Ll=Ke("copy",pue);const gue=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],D_=Ke("cpu",gue);const xue=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]],bue=Ke("cylinder",xue);const yue=[["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"}]],Nu=Ke("database",yue);const vue=[["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"}]],f3=Ke("dollar-sign",vue);const _ue=[["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"}]],pi=Ke("download",_ue);const wue=[["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"}]],AD=Ke("droplet",wue);const Sue=[["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"}]],kD=Ke("droplets",Sue);const Nue=[["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"}]],rh=Ke("ellipsis-vertical",Nue);const Mue=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],tT=Ke("equal",Mue);const Eue=[["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"}]],Yr=Ke("external-link",Eue);const Cue=[["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"}]],cN=Ke("eye-off",Cue);const Tue=[["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"}]],Ru=Ke("eye",Tue);const Aue=[["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"}]],_W=Ke("fan",Aue);const kue=[["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"}]],zf=Ke("file-box",kue);const jue=[["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"}]],q1=Ke("file-code",jue);const Pue=[["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"}]],Rue=Ke("file-exclamation-point",Pue);const Due=[["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"}]],W1=Ke("file-spreadsheet",Due);const Oue=[["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"}]],fs=Ke("file-text",Oue);const Lue=[["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"}]],uN=Ke("file",Lue);const Iue=[["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"}]],ih=Ke("film",Iue);const Fue=[["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"}]],Uue=Ke("flame",Fue);const zue=[["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"}]],Qa=Ke("folder-kanban",zue);const Bue=[["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"}]],Il=Ke("folder-open",Bue);const $ue=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["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"}]],Hue=Ke("folder-plus",$ue);const Vue=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],Gue=Ke("folder-tree",Vue);const que=[["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"}]],wW=Ke("folder",que);const Wue=[["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"}],["rect",{width:"10",height:"8",x:"7",y:"8",rx:"1",key:"vys8me"}]],Kue=Ke("fullscreen",Wue);const Xue=[["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"}]],dN=Ke("funnel",Xue);const Yue=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],hN=Ke("gauge",Yue);const Que=[["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"}]],Zue=Ke("gift",Que);const Jue=[["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"}]],wg=Ke("git-compare",Jue);const ede=[["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"}]],m3=Ke("github",ede);const tde=[["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"}]],ah=Ke("globe",tde);const nde=[["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"}]],zg=Ke("grip-vertical",nde);const rde=[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]],SW=Ke("hand",rde);const ide=[["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"}]],fN=Ke("hard-drive",ide);const ade=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],sde=Ke("hash",ade);const ode=[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3",key:"1xhozi"}]],lde=Ke("headphones",ode);const cde=[["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"}]],ude=Ke("heart",cde);const dde=[["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"}]],q0=Ke("history",dde);const hde=[["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"}]],mN=Ke("house",hde);const fde=[["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"}]],Du=Ke("image",fde);const mde=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Qo=Ke("info",mde);const pde=[["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"}]],gde=Ke("italic",pde);const xde=[["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"}]],Ho=Ke("key",xde);const bde=[["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"}]],p3=Ke("keyboard",bde);const yde=[["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"}]],xs=Ke("layers",yde);const vde=[["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"}]],pN=Ke("layout-grid",vde);const _de=[["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"}]],wde=Ke("link-2-off",_de);const Sde=[["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"}]],dc=Ke("link-2",Sde);const Nde=[["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"}]],Fy=Ke("link",Nde);const Mde=[["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"}]],NW=Ke("list-ordered",Mde);const Ede=[["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"}]],g3=Ke("list-todo",Ede);const Cde=[["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"}]],gN=Ke("list",Cde);const Tde=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ct=Ke("loader-circle",Tde);const Ade=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]],nT=Ke("lock-open",Ade);const kde=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],rT=Ke("lock",kde);const jde=[["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"}]],Lz=Ke("log-in",jde);const Pde=[["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"}]],x3=Ke("log-out",Pde);const Rde=[["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"}]],Dde=Ke("mail",Rde);const Ode=[["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"}]],Lde=Ke("map",Ode);const Ide=[["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"}]],MW=Ke("maximize-2",Ide);const Fde=[["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"}]],Ude=Ke("maximize",Fde);const zde=[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]],Bde=Ke("memory-stick",zde);const $de=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],Hde=Ke("menu",$de);const Vde=[["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"}]],EW=Ke("minimize-2",Vde);const Gde=[["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"}]],CW=Ke("minimize",Gde);const qde=[["path",{d:"M5 12h14",key:"1ays0h"}]],b3=Ke("minus",qde);const Wde=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],Kde=Ke("monitor",Wde);const Xde=[["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"}]],K1=Ke("moon",Xde);const Yde=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],Qde=Ke("move-right",Yde);const Zde=[["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"}]],y3=Ke("music",Zde);const Jde=[["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"}]],pc=Ke("package",Jde);const ehe=[["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"}]],TW=Ke("palette",ehe);const the=[["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"}]],jD=Ke("pause",the);const nhe=[["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"}]],rm=Ke("pen-line",nhe);const rhe=[["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"}]],hg=Ke("pen",rhe);const ihe=[["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"}]],Ki=Ke("pencil",ihe);const ahe=[["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"}]],she=Ke("phone",ahe);const ohe=[["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"}]],Us=Ke("play",ohe);const lhe=[["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"}]],el=Ke("plug",lhe);const che=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],lr=Ke("plus",che);const uhe=[["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"}]],xN=Ke("power-off",uhe);const dhe=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Vu=Ke("power",dhe);const hhe=[["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"}]],Ir=Ke("printer",hhe);const fhe=[["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"}]],AW=Ke("qr-code",fhe);const mhe=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],PD=Ke("radio",mhe);const phe=[["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"}]],Pr=Ke("refresh-cw",phe);const ghe=[["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"}]],Dh=Ke("rotate-ccw",ghe);const xhe=[["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"}]],bhe=Ke("ruler",xhe);const yhe=[["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"}]],ms=Ke("save",yhe);const vhe=[["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"}]],X1=Ke("scan-search",vhe);const _he=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],whe=Ke("scissors",_he);const She=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],pa=Ke("search",She);const Nhe=[["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"}]],RD=Ke("send",Nhe);const Mhe=[["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"}]],yf=Ke("server",Mhe);const Ehe=[["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"}]],bh=Ke("settings-2",Ehe);const Che=[["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"}]],bN=Ke("settings",Che);const The=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],iT=Ke("shield",The);const Ahe=[["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"}]],kW=Ke("shopping-cart",Ahe);const khe=[["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"}]],jhe=Ke("signal",khe);const Phe=[["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"}]],Rhe=Ke("skip-back",Phe);const Dhe=[["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"}]],DD=Ke("skip-forward",Dhe);const Ohe=[["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"}]],Iz=Ke("sliders-vertical",Ohe);const Lhe=[["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"}]],W0=Ke("sparkles",Lhe);const Ihe=[["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"}]],Vs=Ke("square-check-big",Ihe);const Fhe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}]],Uhe=Ke("square-minus",Fhe);const zhe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],il=Ke("square",zhe);const Bhe=[["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"}]],im=Ke("star",Bhe);const $he=[["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"}]],jW=Ke("sticky-note",$he);const Hhe=[["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"}]],Fz=Ke("sun",Hhe);const Vhe=[["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"}]],yh=Ke("tag",Vhe);const Ghe=[["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"}]],PW=Ke("target",Ghe);const qhe=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],RW=Ke("terminal",qhe);const Whe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Khe=Ke("text-align-center",Whe);const Xhe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Yhe=Ke("text-align-end",Xhe);const Qhe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],Zhe=Ke("text-align-start",Qhe);const Jhe=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],yN=Ke("thermometer",Jhe);const efe=[["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"}]],gu=Ke("timer",efe);const tfe=[["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"}]],an=Ke("trash-2",tfe);const nfe=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],DW=Ke("trending-down",nfe);const rfe=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],v3=Ke("trending-up",rfe);const ife=[["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"}]],jn=Ke("triangle-alert",ife);const afe=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],sfe=Ke("underline",afe);const ofe=[["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"}]],OD=Ke("unlink",ofe);const lfe=[["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"}]],Oa=Ke("upload",lfe);const cfe=[["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"}]],am=Ke("user",cfe);const ufe=[["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"}]],fg=Ke("users",ufe);const dfe=[["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"}]],LD=Ke("video",dfe);const hfe=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],ffe=Ke("volume-2",hfe);const mfe=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]],pfe=Ke("volume-x",mfe);const gfe=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],xfe=Ke("wand-sparkles",gfe);const bfe=[["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"}]],sm=Ke("wifi-off",bfe);const yfe=[["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"}]],Sg=Ke("wifi",yfe);const vfe=[["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"}]],OW=Ke("wind",vfe);const _fe=[["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"}]],om=Ke("wrench",_fe);const wfe=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Dt=Ke("x",wfe);const Sfe=[["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"}]],ID=Ke("zoom-in",Sfe);const Nfe=[["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"}]],vh=Ke("zap",Nfe);const Mfe=[["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"}]],FD=Ke("zoom-out",Mfe),dn="/api/v1";let Sr=localStorage.getItem("auth_token");function i0(t){Sr=t,t?localStorage.setItem("auth_token",t):localStorage.removeItem("auth_token")}function Uz(){return Sr}async function Re(t,e={}){const n={"Content-Type":"application/json",...e.headers};Sr&&(n.Authorization=`Bearer ${Sr}`);const r=await fetch(`${dn}${t}`,{...e,cache:"no-store",headers:n});if(!r.ok){r.status===401&&i0(null);const o=(await r.json().catch(()=>({}))).detail,l=typeof o=="string"?o:o?JSON.stringify(o):`HTTP ${r.status}`;throw new Error(l)}const i=r.headers.get("content-length");if(!(r.status===204||i==="0"))return await r.json()}const ue={getAuthStatus:()=>Re("/auth/status"),setupAuth:t=>Re("/auth/setup",{method:"POST",body:JSON.stringify(t)}),login:t=>Re("/auth/login",{method:"POST",body:JSON.stringify(t)}),logout:()=>Re("/auth/logout",{method:"POST"}),getCurrentUser:()=>Re("/auth/me"),disableAuth:()=>Re("/auth/disable",{method:"POST"}),getUsers:()=>Re("/users/"),getUser:t=>Re(`/users/${t}`),createUser:t=>Re("/users/",{method:"POST",body:JSON.stringify(t)}),updateUser:(t,e)=>Re(`/users/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteUser:(t,e=!1)=>Re(`/users/${t}?delete_items=${e}`,{method:"DELETE"}),getUserItemsCount:t=>Re(`/users/${t}/items-count`),changePassword:(t,e)=>Re("/users/me/change-password",{method:"POST",body:JSON.stringify({current_password:t,new_password:e})}),getPermissions:()=>Re("/groups/permissions"),getGroups:()=>Re("/groups/"),getGroup:t=>Re(`/groups/${t}`),createGroup:t=>Re("/groups/",{method:"POST",body:JSON.stringify(t)}),updateGroup:(t,e)=>Re(`/groups/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteGroup:t=>Re(`/groups/${t}`,{method:"DELETE"}),addUserToGroup:(t,e)=>Re(`/groups/${t}/users/${e}`,{method:"POST"}),removeUserFromGroup:(t,e)=>Re(`/groups/${t}/users/${e}`,{method:"DELETE"}),getPrinters:()=>Re("/printers/"),getPrinter:t=>Re(`/printers/${t}`),createPrinter:t=>Re("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>Re(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>Re(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getPrinterStatus:t=>Re(`/printers/${t}/status`),refreshPrinterStatus:t=>Re(`/printers/${t}/refresh-status`,{method:"POST"}),connectPrinter:t=>Re(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>Re(`/printers/${t}/disconnect`,{method:"POST"}),testExternalCamera:(t,e,n)=>Re(`/printers/${t}/camera/external/test?url=${encodeURIComponent(e)}&camera_type=${encodeURIComponent(n)}`,{method:"POST"}),stopPrint:t=>Re(`/printers/${t}/print/stop`,{method:"POST"}),pausePrint:t=>Re(`/printers/${t}/print/pause`,{method:"POST"}),resumePrint:t=>Re(`/printers/${t}/print/resume`,{method:"POST"}),getCurrentPrintUser:t=>Re(`/printers/${t}/current-print-user`),setChamberLight:(t,e)=>Re(`/printers/${t}/chamber-light?on=${e}`,{method:"POST"}),getPrintableObjects:t=>Re(`/printers/${t}/print/objects`),skipObjects:(t,e)=>Re(`/printers/${t}/print/skip-objects`,{method:"POST",body:JSON.stringify(e)}),refreshAmsSlot:(t,e,n)=>Re(`/printers/${t}/ams/${e}/slot/${n}/refresh`,{method:"POST"}),enableMQTTLogging:t=>Re(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>Re(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>Re(`/printers/${t}/logging`),clearMQTTLogs:t=>Re(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>Re(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${dn}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,getPrinterFileGcodeUrl:(t,e)=>`${dn}/printers/${t}/files/gcode?path=${encodeURIComponent(e)}`,getPrinterFilePlates:(t,e)=>Re(`/printers/${t}/files/plates?path=${encodeURIComponent(e)}`),getPrinterFilePlateThumbnail:(t,e,n)=>`${dn}/printers/${t}/files/plate-thumbnail/${e}?path=${encodeURIComponent(n)}`,downloadPrinterFilesAsZip:async(t,e)=>{const n=await fetch(`${dn}/printers/${t}/files/download-zip`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:e})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.detail||`HTTP ${n.status}`)}return n.blob()},deletePrinterFile:(t,e)=>Re(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>Re(`/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)),Re(`/archives/?${i}`)},getArchive:t=>Re(`/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)),Re(`/archives/search?${n}`)},rebuildSearchIndex:()=>Re("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>Re(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>Re(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>Re(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>Re("/archives/stats"),getTags:()=>Re("/archives/tags"),renameTag:(t,e)=>Re(`/archives/tags/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({new_name:e})}),deleteTag:t=>Re(`/archives/tags/${encodeURIComponent(t)}`,{method:"DELETE"}),recalculateCosts:()=>Re("/archives/recalculate-costs",{method:"POST"}),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)),Re(`/archives/analysis/failures?${e}`)},compareArchives:t=>Re(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>Re(`/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(`${dn}/archives/export?${e}`);if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(o.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 o=r.match(/filename="?([^"]+)"?/);o&&(i=o[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(`${dn}/archives/stats/export?${e}`);if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(o.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 o=r.match(/filename="?([^"]+)"?/);o&&(i=o[1])}return{blob:await n.blob(),filename:i}},getArchiveDuplicates:t=>Re(`/archives/${t}/duplicates`),backfillContentHashes:()=>Re("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${dn}/archives/${t}/thumbnail?v=${Date.now()}`,getArchivePlateThumbnail:(t,e)=>`${dn}/archives/${t}/plate-thumbnail/${e}`,getArchiveDownload:t=>`${dn}/archives/${t}/download`,getArchiveGcode:t=>`${dn}/archives/${t}/gcode`,getArchivePlatePreview:t=>`${dn}/archives/${t}/plate-preview`,getArchiveTimelapse:t=>`${dn}/archives/${t}/timelapse?v=${Date.now()}`,scanArchiveTimelapse:t=>Re(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>Re(`/archives/${t}/timelapse/select?filename=${encodeURIComponent(e)}`,{method:"POST"}),uploadArchiveTimelapse:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};Sr&&(r.Authorization=`Bearer ${Sr}`);const i=await fetch(`${dn}/archives/${t}/timelapse/upload`,{method:"POST",headers:r,body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},getTimelapseInfo:t=>Re(`/archives/${t}/timelapse/info`),getTimelapseThumbnails:(t,e=10)=>Re(`/archives/${t}/timelapse/thumbnails?count=${e}`),processTimelapse:async(t,e,n)=>{const r=new FormData;r.append("trim_start",String(e.trimStart??0)),e.trimEnd!==void 0&&r.append("trim_end",String(e.trimEnd)),r.append("speed",String(e.speed??1)),r.append("save_mode",e.saveMode),e.outputFilename&&r.append("output_filename",e.outputFilename),n&&r.append("audio",n);const i={};Sr&&(i.Authorization=`Bearer ${Sr}`);const s=await fetch(`${dn}/archives/${t}/timelapse/process`,{method:"POST",headers:i,body:r});if(!s.ok){const o=await s.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${s.status}`)}return s.json()},getArchivePhotoUrl:(t,e)=>`${dn}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};Sr&&(r.Authorization=`Bearer ${Sr}`);const i=await fetch(`${dn}/archives/${t}/photos`,{headers: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()},deleteArchivePhoto:(t,e)=>Re(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${dn}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${dn}/archives/${t}/source/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,uploadSource3mf:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};Sr&&(r.Authorization=`Bearer ${Sr}`);const i=await fetch(`${dn}/archives/${t}/source`,{method:"POST",headers:r,body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},deleteSource3mf:t=>Re(`/archives/${t}/source`,{method:"DELETE"}),getF3dDownloadUrl:t=>`${dn}/archives/${t}/f3d`,uploadF3d:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};Sr&&(r.Authorization=`Bearer ${Sr}`);const i=await fetch(`${dn}/archives/${t}/f3d`,{method:"POST",headers:r,body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},deleteF3d:t=>Re(`/archives/${t}/f3d`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${dn}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>Re(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>Re(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>Re(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${dn}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${dn}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,getArchivePlates:t=>Re(`/archives/${t}/plates`),getArchiveFilamentRequirements:(t,e)=>Re(`/archives/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),reprintArchive:(t,e,n)=>Re(`/archives/${t}/reprint?printer_id=${e}`,{method:"POST",headers:n?{"Content-Type":"application/json"}:void 0,body:n?JSON.stringify(n):void 0}),uploadArchive:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`${dn}/archives/upload?printer_id=${e}`:`${dn}/archives/upload`,i={};Sr&&(i.Authorization=`Bearer ${Sr}`);const s=await fetch(r,{method:"POST",headers:i,body:n});if(!s.ok){const o=await s.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${s.status}`)}return s.json()},uploadArchivesBulk:async(t,e)=>{const n=new FormData;t.forEach(o=>n.append("files",o));const r=e?`${dn}/archives/upload-bulk?printer_id=${e}`:`${dn}/archives/upload-bulk`,i={};Sr&&(i.Authorization=`Bearer ${Sr}`);const s=await fetch(r,{method:"POST",headers:i,body:n});if(!s.ok){const o=await s.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${s.status}`)}return s.json()},getSettings:()=>Re("/settings/"),updateSettings:t=>Re("/settings/",{method:"PUT",body:JSON.stringify(t)}),getMQTTStatus:()=>Re("/settings/mqtt/status"),resetSettings:()=>Re("/settings/reset",{method:"POST"}),exportBackup:async()=>{const t=`${dn}/settings/backup`,e=await fetch(t);if(!e.ok){const s=await e.text();throw new Error(s||`Backup failed with status ${e.status}`)}const n=e.headers.get("Content-Disposition");let r="bambuddy-backup.zip";if(n){const s=n.match(/filename=([^;]+)/);s&&(r=s[1].trim())}return{blob:await e.blob(),filename:r}},importBackup:async t=>{const e=new FormData;e.append("file",t);const n=`${dn}/settings/restore`,r={};return Sr&&(r.Authorization=`Bearer ${Sr}`),(await fetch(n,{method:"POST",headers:r,body:e})).json()},checkFfmpeg:()=>Re("/settings/check-ffmpeg"),getCloudStatus:()=>Re("/cloud/status"),cloudLogin:(t,e,n="global")=>Re("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>Re("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>Re("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>Re("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>Re(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>Re(`/cloud/settings/${t}`),createCloudSetting:t=>Re("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>Re(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>Re(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>Re("/cloud/devices"),getCloudFields:t=>Re(`/cloud/fields/${t}`),getAllCloudFields:()=>Re("/cloud/fields"),getFilamentInfo:t=>Re("/cloud/filament-info",{method:"POST",body:JSON.stringify(t)}),getSmartPlugs:()=>Re("/smart-plugs/"),getSmartPlug:t=>Re(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>Re(`/smart-plugs/by-printer/${t}`),getScriptPlugsByPrinter:t=>Re(`/smart-plugs/by-printer/${t}/scripts`),createSmartPlug:t=>Re("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>Re(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>Re(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>Re(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>Re(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>Re("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),startTasmotaScan:()=>fetch(`${dn}/smart-plugs/discover/scan`,{method:"POST"}).then(t=>t.ok?t.json():t.json().then(e=>{throw new Error(e.detail||`HTTP ${t.status}`)})),getTasmotaScanStatus:()=>Re("/smart-plugs/discover/status"),stopTasmotaScan:()=>fetch(`${dn}/smart-plugs/discover/stop`,{method:"POST"}).then(t=>t.ok?t.json():t.json().then(e=>{throw new Error(e.detail||`HTTP ${t.status}`)})),getDiscoveredTasmotaDevices:()=>Re("/smart-plugs/discover/devices"),testHAConnection:(t,e)=>Re("/smart-plugs/ha/test-connection",{method:"POST",body:JSON.stringify({url:t,token:e})}),getHAEntities:t=>{const e=t?`?search=${encodeURIComponent(t)}`:"";return Re(`/smart-plugs/ha/entities${e}`)},getHASensorEntities:()=>Re("/smart-plugs/ha/sensors"),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),Re(`/queue/?${n}`)},getQueueItem:t=>Re(`/queue/${t}`),addToQueue:t=>Re("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>Re(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>Re(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>Re("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>Re(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>Re(`/queue/${t}/stop`,{method:"POST"}),startQueueItem:t=>Re(`/queue/${t}/start`,{method:"POST"}),bulkUpdateQueue:t=>Re("/queue/bulk",{method:"PATCH",body:JSON.stringify(t)}),getKProfiles:(t,e="0.4")=>Re(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>Re(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>Re(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>Re(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>Re(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>Re(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>Re(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>Re(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>Re(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>Re(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>Re(`/printers/${t}/slot-presets/${e}/${n}`,{method:"DELETE"}),configureAmsSlot:(t,e,n,r)=>{const i=new URLSearchParams({tray_info_idx:r.tray_info_idx,tray_type:r.tray_type,tray_sub_brands:r.tray_sub_brands,tray_color:r.tray_color,nozzle_temp_min:r.nozzle_temp_min.toString(),nozzle_temp_max:r.nozzle_temp_max.toString(),cali_idx:r.cali_idx.toString(),nozzle_diameter:r.nozzle_diameter});return r.setting_id&&i.set("setting_id",r.setting_id),r.kprofile_filament_id&&i.set("kprofile_filament_id",r.kprofile_filament_id),r.kprofile_setting_id&&i.set("kprofile_setting_id",r.kprofile_setting_id),r.k_value!==void 0&&r.k_value>0&&i.set("k_value",r.k_value.toString()),Re(`/printers/${t}/slots/${e}/${n}/configure?${i}`,{method:"POST"})},resetAmsSlot:(t,e,n)=>Re(`/printers/${t}/ams/${e}/tray/${n}/reset`,{method:"POST"}),listFilaments:()=>Re("/filaments/"),getFilament:t=>Re(`/filaments/${t}`),getFilamentsByType:t=>Re(`/filaments/by-type/${t}`),getNotificationProviders:()=>Re("/notifications/"),getNotificationProvider:t=>Re(`/notifications/${t}`),createNotificationProvider:t=>Re("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>Re(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>Re(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>Re(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>Re("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>Re("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>Re("/notification-templates"),getNotificationTemplate:t=>Re(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>Re(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>Re(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>Re("/notification-templates/variables"),previewTemplate:t=>Re("/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)),Re(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>Re(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>Re(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>Re("/spoolman/status"),connectSpoolman:()=>Re("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>Re("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>Re(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>Re("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>Re("/spoolman/spools"),getSpoolmanFilaments:()=>Re("/spoolman/filaments"),getUnlinkedSpools:()=>Re("/spoolman/spools/unlinked"),linkSpool:(t,e)=>Re(`/spoolman/spools/${t}/link`,{method:"POST",body:JSON.stringify({tray_uuid:e})}),getVersion:()=>Re("/updates/version"),checkForUpdates:()=>Re("/updates/check"),applyUpdate:()=>Re("/updates/apply",{method:"POST"}),getUpdateStatus:()=>Re("/updates/status"),getMaintenanceTypes:()=>Re("/maintenance/types"),createMaintenanceType:t=>Re("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>Re(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>Re(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>Re("/maintenance/overview"),getPrinterMaintenance:t=>Re(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>Re(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>Re(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>Re(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>Re("/maintenance/summary"),setPrinterHours:(t,e)=>Re(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>Re(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>Re(`/maintenance/items/${t}`,{method:"DELETE"}),getCameraStreamUrl:(t,e=10)=>`${dn}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${dn}/printers/${t}/camera/snapshot`,testCameraConnection:t=>Re(`/printers/${t}/camera/test`),checkPlateEmpty:(t,e)=>{const n=new URLSearchParams;return n.set("use_external",String(e?.useExternal??!1)),n.set("include_debug_image",String(e?.includeDebugImage??!1)),Re(`/printers/${t}/camera/check-plate?${n.toString()}`)},getPlateDetectionStatus:t=>Re(`/printers/${t}/camera/plate-detection/status`),calibratePlateDetection:(t,e)=>{const n=new URLSearchParams;return e?.label&&n.set("label",e.label),n.set("use_external",String(e?.useExternal??!1)),Re(`/printers/${t}/camera/plate-detection/calibrate?${n.toString()}`,{method:"POST"})},deletePlateCalibration:t=>Re(`/printers/${t}/camera/plate-detection/calibrate`,{method:"DELETE"}),getPlateReferences:t=>Re(`/printers/${t}/camera/plate-detection/references`),getPlateReferenceThumbnailUrl:(t,e)=>`${dn}/printers/${t}/camera/plate-detection/references/${e}/thumbnail`,updatePlateReferenceLabel:(t,e,n)=>{const r=new URLSearchParams;return r.set("label",n),Re(`/printers/${t}/camera/plate-detection/references/${e}?${r.toString()}`,{method:"PUT"})},deletePlateReference:(t,e)=>Re(`/printers/${t}/camera/plate-detection/references/${e}`,{method:"DELETE"}),getExternalLinks:()=>Re("/external-links/"),getExternalLink:t=>Re(`/external-links/${t}`),createExternalLink:t=>Re("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>Re(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>Re(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>Re("/external-links/reorder",{method:"PUT",body:JSON.stringify({ids:t})}),uploadExternalLinkIcon:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};Sr&&(r.Authorization=`Bearer ${Sr}`);const i=await fetch(`${dn}/external-links/${t}/icon`,{method:"POST",headers:r,body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},deleteExternalLinkIcon:t=>Re(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${dn}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),Re(`/projects/?${e}`)},getProject:t=>Re(`/projects/${t}`),createProject:t=>Re("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>Re(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>Re(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>Re(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>Re(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>Re(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>Re(`/projects/${t}/add-queue`,{method:"POST",body:JSON.stringify({queue_item_ids:e})}),uploadProjectAttachment:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};Sr&&(r.Authorization=`Bearer ${Sr}`);const i=await fetch(`${dn}/projects/${t}/attachments`,{method:"POST",headers:r,body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},getProjectAttachmentUrl:(t,e)=>`${dn}/projects/${t}/attachments/${encodeURIComponent(e)}`,deleteProjectAttachment:(t,e)=>Re(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>Re(`/projects/${t}/bom`),createBOMItem:(t,e)=>Re(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>Re(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>Re(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>Re("/projects/templates/"),createTemplateFromProject:t=>Re(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>Re(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>Re(`/projects/${t}/timeline?limit=${e}`),exportProjectJson:t=>Re(`/projects/${t}/export?format=json`),importProject:t=>Re("/projects/import",{method:"POST",body:JSON.stringify(t)}),getAPIKeys:()=>Re("/api-keys/"),createAPIKey:t=>Re("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>Re(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>Re(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>Re(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>Re("/system/info"),getLibraryFolders:()=>Re("/library/folders"),createLibraryFolder:t=>Re("/library/folders",{method:"POST",body:JSON.stringify(t)}),updateLibraryFolder:(t,e)=>Re(`/library/folders/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFolder:t=>Re(`/library/folders/${t}`,{method:"DELETE"}),getLibraryFoldersByProject:t=>Re(`/library/folders/by-project/${t}`),getLibraryFoldersByArchive:t=>Re(`/library/folders/by-archive/${t}`),getLibraryFiles:(t,e=!0)=>{const n=new URLSearchParams;return t!=null&&n.set("folder_id",String(t)),n.set("include_root",String(e)),Re(`/library/files?${n}`)},getLibraryFile:t=>Re(`/library/files/${t}`),uploadLibraryFile:async(t,e,n=!0)=>{const r=new FormData;r.append("file",t);const i=new URLSearchParams;e&&i.set("folder_id",String(e)),i.set("generate_stl_thumbnails",String(n));const s={};Sr&&(s.Authorization=`Bearer ${Sr}`);const o=await fetch(`${dn}/library/files?${i}`,{method:"POST",headers:s,body:r});if(!o.ok){const l=await o.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${o.status}`)}return o.json()},extractZipFile:async(t,e,n=!0,r=!1,i=!0)=>{const s=new FormData;s.append("file",t);const o=new URLSearchParams;e&&o.set("folder_id",String(e)),o.set("preserve_structure",String(n)),o.set("create_folder_from_zip",String(r)),o.set("generate_stl_thumbnails",String(i));const l={};Sr&&(l.Authorization=`Bearer ${Sr}`);const c=await fetch(`${dn}/library/files/extract-zip?${o}`,{method:"POST",headers:l,body:s});if(!c.ok){const u=await c.json().catch(()=>({}));throw new Error(u.detail||`HTTP ${c.status}`)}return c.json()},updateLibraryFile:(t,e)=>Re(`/library/files/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFile:t=>Re(`/library/files/${t}`,{method:"DELETE"}),getLibraryFileDownloadUrl:t=>`${dn}/library/files/${t}/download`,getLibraryFileThumbnailUrl:t=>`${dn}/library/files/${t}/thumbnail`,getLibraryFilePlateThumbnail:(t,e)=>`${dn}/library/files/${t}/plate-thumbnail/${e}`,getLibraryFileGcodeUrl:t=>`${dn}/library/files/${t}/gcode`,moveLibraryFiles:(t,e)=>Re("/library/files/move",{method:"POST",body:JSON.stringify({file_ids:t,folder_id:e})}),bulkDeleteLibrary:(t,e)=>Re("/library/bulk-delete",{method:"POST",body:JSON.stringify({file_ids:t,folder_ids:e})}),getLibraryStats:()=>Re("/library/stats"),batchGenerateStlThumbnails:t=>Re("/library/generate-stl-thumbnails",{method:"POST",body:JSON.stringify(t)}),addLibraryFilesToQueue:t=>Re("/library/files/add-to-queue",{method:"POST",body:JSON.stringify({file_ids:t})}),printLibraryFile:(t,e,n)=>Re(`/library/files/${t}/print?printer_id=${e}`,{method:"POST",body:n?JSON.stringify(n):void 0}),getLibraryFilePlates:t=>Re(`/library/files/${t}/plates`),getLibraryFileFilamentRequirements:(t,e)=>Re(`/library/files/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),getGitHubBackupConfig:()=>Re("/github-backup/config"),saveGitHubBackupConfig:t=>Re("/github-backup/config",{method:"POST",body:JSON.stringify(t)}),updateGitHubBackupConfig:t=>Re("/github-backup/config",{method:"PATCH",body:JSON.stringify(t)}),deleteGitHubBackupConfig:()=>Re("/github-backup/config",{method:"DELETE"}),testGitHubConnection:(t,e)=>Re(`/github-backup/test?repo_url=${encodeURIComponent(t)}&token=${encodeURIComponent(e)}`,{method:"POST"}),testGitHubStoredConnection:()=>Re("/github-backup/test-stored",{method:"POST"}),triggerGitHubBackup:()=>Re("/github-backup/run",{method:"POST"}),getGitHubBackupStatus:()=>Re("/github-backup/status"),getGitHubBackupLogs:(t=50)=>Re(`/github-backup/logs?limit=${t}`),clearGitHubBackupLogs:(t=10)=>Re(`/github-backup/logs?keep_last=${t}`,{method:"DELETE"})},Xl={getInfo:()=>Re("/discovery/info"),getStatus:()=>Re("/discovery/status"),startDiscovery:(t=10)=>Re(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>Re("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>Re("/discovery/printers"),startSubnetScan:(t,e=1)=>Re("/discovery/scan",{method:"POST",body:JSON.stringify({subnet:t,timeout:e})}),getScanStatus:()=>Re("/discovery/scan/status"),stopSubnetScan:()=>Re("/discovery/scan/stop",{method:"POST"})},g1={getSettings:()=>Re("/settings/virtual-printer"),getModels:()=>Re("/settings/virtual-printer/models"),updateSettings:t=>{const e=new URLSearchParams;return t.enabled!==void 0&&e.set("enabled",String(t.enabled)),t.access_code!==void 0&&e.set("access_code",t.access_code),t.mode!==void 0&&e.set("mode",t.mode),t.model!==void 0&&e.set("model",t.model),Re(`/settings/virtual-printer?${e.toString()}`,{method:"PUT"})}},ig={list:()=>Re("/pending-uploads/"),getCount:()=>Re("/pending-uploads/count"),get:t=>Re(`/pending-uploads/${t}`),archive:(t,e)=>Re(`/pending-uploads/${t}/archive`,{method:"POST",body:JSON.stringify(e||{})}),discard:t=>Re(`/pending-uploads/${t}`,{method:"DELETE"}),archiveAll:()=>Re("/pending-uploads/archive-all",{method:"POST"}),discardAll:()=>Re("/pending-uploads/discard-all",{method:"DELETE"})},x1={checkUpdates:()=>Re("/firmware/updates"),checkPrinterUpdate:t=>Re(`/firmware/updates/${t}`),prepareUpload:t=>Re(`/firmware/updates/${t}/prepare`),startUpload:t=>Re(`/firmware/updates/${t}/upload`,{method:"POST"}),getUploadStatus:t=>Re(`/firmware/updates/${t}/upload/status`)},Ng={getDebugLoggingState:()=>Re("/support/debug-logging"),setDebugLogging:t=>Re("/support/debug-logging",{method:"POST",body:JSON.stringify({enabled:t})}),downloadSupportBundle:async()=>{const t=await fetch(`${dn}/support/bundle`);if(!t.ok){const l=await t.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${t.status}`)}const n=t.headers.get("Content-Disposition")?.match(/filename=(.+)/),r=n?n[1]:"bambuddy-support.zip",i=await t.blob(),s=window.URL.createObjectURL(i),o=document.createElement("a");o.href=s,o.download=r,document.body.appendChild(o),o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(s)},getLogs:t=>{const e=new URLSearchParams;t?.limit&&e.set("limit",t.limit.toString()),t?.level&&e.set("level",t.level),t?.search&&e.set("search",t.search);const n=e.toString();return Re(`/support/logs${n?`?${n}`:""}`)},clearLogs:()=>Re("/support/logs",{method:"DELETE"})},LW=w.createContext(void 0);function Efe({children:t}){const[e,n]=w.useState(()=>{const E=localStorage.getItem("theme-mode"),D=localStorage.getItem("theme");return E||D||"dark"}),[r,i]=w.useState(()=>localStorage.getItem("dark-style")||"classic"),[s,o]=w.useState(()=>localStorage.getItem("dark-background")||"neutral"),[l,c]=w.useState(()=>localStorage.getItem("dark-accent")||"green"),[u,d]=w.useState(()=>localStorage.getItem("light-style")||"classic"),[f,m]=w.useState(()=>localStorage.getItem("light-background")||"neutral"),[p,x]=w.useState(()=>localStorage.getItem("light-accent")||"green");w.useEffect(()=>{ue.getSettings().then(E=>{E.dark_style&&(i(E.dark_style),localStorage.setItem("dark-style",E.dark_style)),E.dark_background&&(o(E.dark_background),localStorage.setItem("dark-background",E.dark_background)),E.dark_accent&&(c(E.dark_accent),localStorage.setItem("dark-accent",E.dark_accent)),E.light_style&&(d(E.light_style),localStorage.setItem("light-style",E.light_style)),E.light_background&&(m(E.light_background),localStorage.setItem("light-background",E.light_background)),E.light_accent&&(x(E.light_accent),localStorage.setItem("light-accent",E.light_accent))}).catch(()=>{})},[]),w.useEffect(()=>{const E=document.documentElement;E.classList.remove("dark","style-classic","style-glow","style-vibrant","bg-neutral","bg-warm","bg-cool","bg-oled","bg-slate","bg-forest","accent-green","accent-teal","accent-blue","accent-orange","accent-purple","accent-red"),e==="dark"?(E.classList.add("dark"),E.classList.add(`style-${r}`),E.classList.add(`bg-${s}`),E.classList.add(`accent-${l}`)):(E.classList.add(`style-${u}`),E.classList.add(`bg-${f}`),E.classList.add(`accent-${p}`)),localStorage.setItem("theme-mode",e),localStorage.removeItem("theme")},[e,r,s,l,u,f,p]);const b=()=>n(E=>E==="dark"?"light":"dark"),y=E=>n(E),v=E=>{i(E),localStorage.setItem("dark-style",E),ue.updateSettings({dark_style:E}).catch(()=>{})},S=E=>{o(E),localStorage.setItem("dark-background",E),ue.updateSettings({dark_background:E}).catch(()=>{})},N=E=>{c(E),localStorage.setItem("dark-accent",E),ue.updateSettings({dark_accent:E}).catch(()=>{})},C=E=>{d(E),localStorage.setItem("light-style",E),ue.updateSettings({light_style:E}).catch(()=>{})},T=E=>{m(E),localStorage.setItem("light-background",E),ue.updateSettings({light_background:E}).catch(()=>{})},k=E=>{x(E),localStorage.setItem("light-accent",E),ue.updateSettings({light_accent:E}).catch(()=>{})};return a.jsx(LW.Provider,{value:{mode:e,darkStyle:r,darkBackground:s,darkAccent:l,lightStyle:u,lightBackground:f,lightAccent:p,toggleMode:b,setMode:y,setDarkStyle:v,setDarkBackground:S,setDarkAccent:N,setLightStyle:C,setLightBackground:T,setLightAccent:k},children:t})}function Oh(){const t=w.useContext(LW);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}function wt({children:t,className:e="",onClick:n,onContextMenu:r,...i}){return a.jsx("div",{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary card-shadow ${e}`,onClick:n,onContextMenu:r,...i,children:t})}function Hn({children:t,className:e=""}){return a.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function St({children:t,className:e=""}){return a.jsx("div",{className:`p-6 ${e}`,children:t})}function Cfe(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 zz({children:t}){return a.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 Tfe({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=Oy(),i=Cfe(n,e,r);return w.useEffect(()=>{const s=o=>{o.key==="Escape"&&t()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[t]),a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:a.jsx(wt,{className:"w-full max-w-md",onClick:s=>s.stopPropagation(),children:a.jsxs(St,{className:"p-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(p3,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:i.map(s=>a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:s.category}),a.jsx("div",{className:"space-y-2",children:s.items.map(o=>a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"text-white text-sm flex items-center gap-1.5",children:[o.description,o.isExternal&&a.jsx(Yr,{className:"w-3 h-3 text-bambu-gray"})]}),a.jsx("div",{className:"flex gap-1",children:o.keys.map(l=>a.jsx(zz,{children:l},l))})]},o.description))})]},s.category))}),a.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:a.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",a.jsx(zz,{children:"Esc"})," or click outside to close"]})})]})})})}function Ne({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",o={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"},l={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 a.jsx("button",{className:`${s} ${o[t]} ${l[e]} ${n}`,...i,children:r})}function Yn({title:t,message:e,confirmText:n="Confirm",cancelText:r="Cancel",variant:i="default",isLoading:s=!1,loadingText:o,onConfirm:l,onCancel:c}){w.useEffect(()=>{const f=m=>{m.key==="Escape"&&!s&&c()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[c,s]);const d={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 a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:s?void 0:c,children:a.jsx(wt,{className:"w-full max-w-md",onClick:f=>f.stopPropagation(),children:a.jsxs(St,{className:"p-6",children:[a.jsxs("div",{className:"flex items-start gap-4",children:[a.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${d.icon}`,children:a.jsx(jn,{className:"w-6 h-6"})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),a.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),a.jsxs("div",{className:"flex gap-3 mt-6",children:[a.jsx(Ne,{variant:"secondary",onClick:c,className:"flex-1",disabled:s,children:r}),a.jsx(Ne,{onClick:l,className:`flex-1 ${d.button}`,disabled:s,children:s?a.jsxs(a.Fragment,{children:[a.jsx(ct,{className:"w-4 h-4 mr-2 animate-spin"}),o||"Processing..."]}):n})]})]})})})}function Afe({plug:t}){const e=on(),[n,r]=w.useState(null),{data:i,isLoading:s}=at({queryKey:["smart-plug-status",t.id],queryFn:()=>ue.getSmartPlugStatus(t.id),refetchInterval:1e4}),o=mt({mutationFn:p=>ue.controlSmartPlug(t.id,p),onSuccess:()=>{e.invalidateQueries({queryKey:["smart-plug-status",t.id]})}}),l=i?.state==="ON",c=t.plug_type==="mqtt"&&i?.energy?.power!==null&&i?.energy?.power!==void 0,u=(i?.reachable??!1)||c,d=o.isPending,f=t.plug_type==="mqtt",m=()=>{n&&(o.mutate(n),r(null))};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-between py-2 px-3 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`p-1.5 rounded ${f?u?"bg-teal-500/20":"bg-red-500/20":u?l?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:f?a.jsx(PD,{className:`w-4 h-4 ${u?"text-teal-400":"text-red-400"}`}):a.jsx(el,{className:`w-4 h-4 ${u?l?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white font-medium",children:t.name}),a.jsx("div",{className:"flex items-center gap-1 text-xs",children:s?a.jsx(ct,{className:"w-3 h-3 text-bambu-gray animate-spin"}):f?u?a.jsxs(a.Fragment,{children:[a.jsx(vh,{className:"w-3 h-3 text-teal-400"}),a.jsxs("span",{className:"text-teal-400",children:[Math.round(i?.energy?.power??0),"W"]}),a.jsx("span",{className:"text-bambu-gray mx-1",children:"|"}),a.jsx(Ru,{className:"w-3 h-3 text-bambu-gray"}),a.jsx("span",{className:"text-bambu-gray",children:"Monitor"})]}):a.jsxs(a.Fragment,{children:[a.jsx(sm,{className:"w-3 h-3 text-status-error"}),a.jsx("span",{className:"text-status-error",children:"Waiting"})]}):u?a.jsxs(a.Fragment,{children:[a.jsx(Sg,{className:"w-3 h-3 text-status-ok"}),a.jsx("span",{className:l?"text-status-ok":"text-bambu-gray",children:i?.state||"Unknown"}),i?.energy?.power!==null&&i?.energy?.power!==void 0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-bambu-gray mx-1",children:"|"}),a.jsx(vh,{className:"w-3 h-3 text-yellow-400"}),a.jsxs("span",{className:"text-yellow-400",children:[Math.round(i.energy.power),"W"]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx(sm,{className:"w-3 h-3 text-status-error"}),a.jsx("span",{className:"text-status-error",children:"Offline"})]})})]})]}),!f&&a.jsxs("div",{className:"flex gap-1",children:[a.jsx("button",{onClick:()=>r("on"),disabled:!u||d,className:`p-1.5 rounded transition-colors ${l?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,title:"Turn On",children:d?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(Vu,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>r("off"),disabled:!u||d,className:`p-1.5 rounded transition-colors ${!l&&u?"bg-bambu-dark-tertiary text-white":"bg-bambu-dark text-bambu-gray hover:text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,title:"Turn Off",children:d?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(xN,{className:"w-4 h-4"})})]})]}),n&&a.jsx(Yn,{title:`Turn ${n==="on"?"On":"Off"} Smart Plug`,message:`Are you sure you want to turn ${n==="on"?"on":"off"} "${t.name}"?`,confirmText:n==="on"?"Turn On":"Turn Off",variant:n==="off"?"warning":"default",onConfirm:m,onCancel:()=>r(null)})]})}function Bz({onClose:t}){const{data:e,isLoading:n}=at({queryKey:["smart-plugs"],queryFn:ue.getSmartPlugs}),r=e?.filter(i=>i.show_in_switchbar)||[];return a.jsxs("div",{className:"absolute bottom-full left-0 mb-2 w-72 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-xl z-50",onMouseLeave:t,children:[a.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary",children:a.jsxs("h3",{className:"text-sm font-semibold text-white flex items-center gap-2",children:[a.jsx(el,{className:"w-4 h-4 text-bambu-green"}),"Smart Switches"]})}),a.jsx("div",{className:"p-2 max-h-80 overflow-y-auto",children:n?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(ct,{className:"w-6 h-6 text-bambu-gray animate-spin"})}):r.length===0?a.jsxs("div",{className:"text-center py-6 px-4",children:[a.jsx(el,{className:"w-8 h-8 text-bambu-gray mx-auto mb-2"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"No switches in switchbar"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:'Enable "Show in Switchbar" in Settings > Smart Plugs'})]}):a.jsx("div",{className:"space-y-1",children:r.map(i=>a.jsx(Afe,{plug:i},i.id))})})]})}const IW=[{name:"globe",icon:ah},{name:"link",icon:Fy},{name:"external-link",icon:Yr},{name:"book",icon:Mce},{name:"file-text",icon:fs},{name:"home",icon:mN},{name:"star",icon:im},{name:"heart",icon:ude},{name:"bookmark",icon:Cce},{name:"shopping-cart",icon:kW},{name:"music",icon:y3},{name:"video",icon:LD},{name:"image",icon:Du},{name:"camera",icon:Ug},{name:"map",icon:Lde},{name:"compass",icon:mue},{name:"coffee",icon:uue},{name:"gift",icon:Zue},{name:"wrench",icon:om},{name:"zap",icon:vh},{name:"cloud",icon:lN},{name:"database",icon:Nu},{name:"folder",icon:wW},{name:"mail",icon:Dde},{name:"phone",icon:she},{name:"user",icon:am},{name:"users",icon:fg},{name:"server",icon:yf},{name:"terminal",icon:RW},{name:"code",icon:vW}];function vN(t){return IW.find(n=>n.name===t)?.icon||Fy}function kfe({value:t,onChange:e}){const[n,r]=w.useState(!1),i=vN(t);return a.jsxs("div",{className:"relative",children:[a.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:[a.jsx(i,{className:"w-5 h-5"}),a.jsx("span",{className:"text-sm text-bambu-gray flex-1 text-left",children:t})]}),n&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>r(!1)}),a.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:a.jsx("div",{className:"grid grid-cols-5 gap-1 p-2",children:IW.map(({name:s,icon:o})=>a.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:a.jsx(o,{className:"w-5 h-5"})},s))})})]})]})}const $z=768;function UD(){const[t,e]=w.useState(()=>typeof window<"u"?window.innerWidth<$z:!1);return w.useEffect(()=>{const n=window.matchMedia(`(max-width: ${$z-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const FW=w.createContext(void 0);function jfe({children:t}){const[e,n]=w.useState(null),[r,i]=w.useState(!1),[s,o]=w.useState(!1),[l,c]=w.useState(!0),u=w.useRef(!1),d=w.useRef(!0),f=async()=>{try{const k=await ue.getAuthStatus();if(!d.current)return;if(i(k.auth_enabled),o(k.requires_setup),k.auth_enabled)if(Uz())try{const D=await ue.getCurrentUser();if(!d.current)return;n(D)}catch{if(i0(null),!d.current)return;n(null)}else n(null);else n(null)}catch{if(!d.current)return;i(!1),n(null)}finally{d.current&&c(!1)}};w.useEffect(()=>(d.current=!0,f(),()=>{d.current=!1}),[]),w.useEffect(()=>{if(!l&&s&&!r){const k=window.location.pathname;k!=="/setup"&&!k.startsWith("/camera/")&&!u.current&&(u.current=!0,window.location.href="/setup")}else s||(u.current=!1)},[l,s,r]);const m=async(k,E)=>{const D=await ue.login({username:k,password:E});i0(D.access_token),n(D.user)},p=()=>{i0(null),n(null),ue.logout().catch(()=>{}),window.location.href="/login"},x=async()=>{if(r&&Uz())try{const k=await ue.getCurrentUser();d.current&&n(k)}catch{i0(null),d.current&&n(null)}},b=async()=>{await f()},y=w.useMemo(()=>new Set(e?.permissions??[]),[e?.permissions]),v=w.useMemo(()=>r?e?.is_admin??!1:!0,[r,e?.is_admin]),S=w.useCallback(k=>!r||v?!0:y.has(k),[r,v,y]),N=w.useCallback((...k)=>!r||v?!0:k.some(E=>y.has(E)),[r,v,y]),C=w.useCallback((...k)=>!r||v?!0:k.every(E=>y.has(E)),[r,v,y]),T=w.useCallback((k,E,D)=>{if(!r||v)return!0;const A=`${k}:${E}_all`,R=`${k}:${E}_own`;return y.has(A)?!0:y.has(R)?D==null?!1:D===e?.id:!1},[r,v,y,e?.id]);return a.jsx(FW.Provider,{value:{user:e,authEnabled:r,requiresSetup:s,loading:l,isAdmin:v,login:m,logout:p,refreshUser:x,refreshAuth:b,hasPermission:S,hasAnyPermission:N,hasAllPermissions:C,canModify:T},children:t})}function Si(){const t=w.useContext(FW);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}const UW=w.createContext(void 0);function Vn(){const t=w.useContext(UW);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const Pfe={success:a.jsx(Tr,{className:"w-5 h-5 text-green-400"}),error:a.jsx(qi,{className:"w-5 h-5 text-red-400"}),warning:a.jsx(Ii,{className:"w-5 h-5 text-yellow-400"}),info:a.jsx(Qo,{className:"w-5 h-5 text-blue-400"}),loading:a.jsx(ct,{className:"w-5 h-5 text-bambu-green animate-spin"})},Rfe={success:"bg-green-500/10 border-green-500/30",error:"bg-red-500/10 border-red-500/30",warning:"bg-yellow-500/10 border-yellow-500/30",info:"bg-blue-500/10 border-blue-500/30",loading:"bg-bambu-green/10 border-bambu-green/30"};function Dfe({children:t}){const[e,n]=w.useState([]),r=w.useCallback((o,l="success")=>{const c=Math.random().toString(36).substr(2,9);n(u=>[...u,{id:c,message:o,type:l}]),setTimeout(()=>{n(u=>u.filter(d=>d.id!==c))},3e3)},[]),i=w.useCallback((o,l,c="info")=>{n(u=>u.find(f=>f.id===o)?u.map(f=>f.id===o?{...f,message:l,type:c,persistent:!0}:f):[...u,{id:o,message:l,type:c,persistent:!0}])},[]),s=w.useCallback(o=>{n(l=>l.filter(c=>c.id!==o))},[]);return a.jsxs(UW.Provider,{value:{showToast:r,showPersistentToast:i,dismissToast:s},children:[t,a.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(o=>a.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${Rfe[o.type]}`,children:[Pfe[o.type],a.jsx("span",{className:"text-white text-sm",children:o.message}),a.jsx("button",{onClick:()=>s(o.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:a.jsx(Dt,{className:"w-4 h-4"})})]},o.id))})]})}const K0=[{id:"printers",to:"/",icon:Ir,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:fo,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:ti,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:zce,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:lN,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:om,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:Qa,labelKey:"nav.projects"},{id:"files",to:"/files",icon:Il,labelKey:"nav.files"},{id:"settings",to:"/settings",icon:bN,labelKey:"nav.settings"}];function Ofe(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return K0.map(e=>e.id)}return K0.map(e=>e.id)}function Lfe(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function aT(t){return t.startsWith("ext-")}function zW(){return localStorage.getItem("defaultView")||"/"}function Ife(t){localStorage.setItem("defaultView",t)}function Ffe(){const t=Mc(),e=Nc(),{mode:n,toggleMode:r}=Oh(),{t:i}=Oy(),s=UD(),{user:o,authEnabled:l,logout:c,hasPermission:u}=Si(),{showToast:d}=Vn(),[f,m]=w.useState(!1),[p,x]=w.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[b,y]=w.useState(!1),[v,S]=w.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[N,C]=w.useState(!1),[T,k]=w.useState(!1),[E,D]=w.useState(!1),[A,R]=w.useState(Ofe),[F,O]=w.useState(null),[H,j]=w.useState(null),G=w.useRef(!1),[$,q]=w.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),[Y,Z]=w.useState(null),{data:oe}=at({queryKey:["version"],queryFn:ue.getVersion,staleTime:1/0}),{data:B}=at({queryKey:["settings"],queryFn:ue.getSettings,staleTime:300*1e3}),{data:W}=at({queryKey:["updateCheck"],queryFn:ue.checkForUpdates,enabled:B?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:se}=at({queryKey:["external-links"],queryFn:ue.getExternalLinks}),{data:ne}=at({queryKey:["smart-plugs"],queryFn:ue.getSmartPlugs,staleTime:30*1e3}),ce=ne?.some(L=>L.show_in_switchbar)??!1,{data:fe}=at({queryKey:["debugLogging"],queryFn:Ng.getDebugLoggingState,staleTime:60*1e3,refetchInterval:60*1e3}),{data:ye}=at({queryKey:["queue","pending"],queryFn:()=>ue.getQueue(void 0,"pending"),staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),ge=ye?.length??0,{data:xe}=at({queryKey:["pending-uploads","count"],queryFn:ig.getCount,staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),Pe=xe?.count??0,[Ue,be]=w.useState(null);w.useEffect(()=>{if(!fe?.enabled||!fe.enabled_at){be(null);return}const L=new Date(fe.enabled_at).getTime(),X=()=>{be(Math.floor((Date.now()-L)/1e3))};X();const te=setInterval(X,1e3);return()=>clearInterval(te)},[fe?.enabled,fe?.enabled_at]);const it=w.useMemo(()=>new Map(K0.map(L=>[L.id,L])),[]),U=w.useMemo(()=>new Map((se||[]).map(L=>[`ext-${L.id}`,L])),[se]),K=(()=>{const L=[],X=new Set,te=l&&o?.role==="user";for(const Me of A)te&&Me==="settings"||(it.has(Me)||U.has(Me))&&(L.push(Me),X.add(Me));for(const Me of K0)te&&Me.id==="settings"||X.has(Me.id)||(L.push(Me.id),X.add(Me.id));for(const Me of se||[]){const ie=`ext-${Me.id}`;X.has(ie)||(L.push(ie),X.add(ie))}return L})(),J=(L,X)=>{O(X),L.dataTransfer.effectAllowed="move",L.dataTransfer.setData("text/plain",X)},Q=(L,X)=>{L.preventDefault(),L.dataTransfer.dropEffect="move",j(X)},z=()=>{j(null)},re=(L,X)=>{if(L.preventDefault(),F===null||F===X){O(null),j(null);return}const te=[...K],Me=te.indexOf(F),ie=te.indexOf(X);if(Me===-1||ie===-1){O(null),j(null);return}te.splice(Me,1),te.splice(ie,0,F),R(te),Lfe(te),O(null),j(null)},Ee=()=>{O(null),j(null)},_e=W?.update_available&&W.latest_version&&W.latest_version!==$,Te=()=>{W?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",W.latest_version),q(W.latest_version))};w.useEffect(()=>{if(!G.current&&e.pathname==="/"){const L=zW();L!=="/"&&(G.current=!0,t(L,{replace:!0}))}},[e.pathname,t]),w.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(v))},[v]),w.useEffect(()=>{s&&C(!1)},[e.pathname,s]),w.useEffect(()=>{const L=X=>{const te=X.detail;Z({printer_id:te.printer_id,printer_name:te.printer_name,message:te.message})};return window.addEventListener("plate-not-empty",L),()=>window.removeEventListener("plate-not-empty",L)},[]);const V=w.useCallback(L=>{const X=L.target;if(!(X.tagName==="INPUT"||X.tagName==="TEXTAREA"||X.isContentEditable)&&!L.metaKey&&!L.ctrlKey&&!L.altKey){const te=parseInt(L.key);if(te>=1&&te<=K.length&&te<=9){const Me=K[te-1];if(L.preventDefault(),aT(Me)){const ie=Me.replace("ext-","");t(`/external/${ie}`)}else{const ie=it.get(Me);ie&&t(ie.to)}return}switch(L.key){case"?":L.preventDefault(),k(!0);break;case"Escape":k(!1);break}}},[t,K,it]);return w.useEffect(()=>(document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)),[V]),a.jsxs("div",{className:"flex min-h-screen",children:[s&&a.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:[a.jsx("button",{onClick:()=>C(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:a.jsx(Hde,{className:"w-6 h-6 text-white"})}),a.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-8 ml-3"})]}),s&&N&&a.jsx("div",{className:"fixed inset-0 bg-black/60 z-40 transition-opacity",onClick:()=>C(!1)}),a.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 ${N?"translate-x-0":"-translate-x-full"}`:`fixed inset-y-0 left-0 z-30 ${v?"w-64":"w-16"}`}`,children:[a.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${s||v?"p-4":"p-2"}`,children:a.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:s||v?"h-16 w-auto":"h-8 w-8 object-cover object-left"})}),a.jsx("nav",{className:"flex-1 p-2",children:a.jsx("ul",{className:"space-y-2",children:K.map(L=>{if(aT(L)){const te=U.get(L);if(!te)return null;const Me=te.custom_icon?null:vN(te.icon);return a.jsx("li",{draggable:!0,onDragStart:ie=>J(ie,L),onDragOver:ie=>Q(ie,L),onDragLeave:z,onDrop:ie=>re(ie,L),onDragEnd:Ee,className:`relative ${F===L?"opacity-50":""} ${H===L&&F!==L?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:a.jsxs(r0,{to:`/external/${te.id}`,className:({isActive:ie})=>`flex items-center ${s||v?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${ie?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!s&&!v?te.name:void 0,children:[v&&!s&&a.jsx(zg,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),te.custom_icon?a.jsx("img",{src:`/api/v1/external-links/${te.id}/icon`,alt:"",className:`w-5 h-5 flex-shrink-0 ${n==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):Me&&a.jsx(Me,{className:"w-5 h-5 flex-shrink-0"}),(s||v)&&a.jsx("span",{children:te.name})]})},L)}else{const te=it.get(L);if(!te)return null;const{to:Me,icon:ie,labelKey:De}=te,Le=L==="queue"&&ge>0,$e=L==="archives"&&Pe>0,Ze=Le?ge:$e?Pe:0,Ie=Le||$e;return a.jsx("li",{draggable:!0,onDragStart:ae=>J(ae,L),onDragOver:ae=>Q(ae,L),onDragLeave:z,onDrop:ae=>re(ae,L),onDragEnd:Ee,className:`relative ${F===L?"opacity-50":""} ${H===L&&F!==L?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:a.jsxs(r0,{to:Me,className:({isActive:ae})=>`flex items-center ${s||v?"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&&!v?i(De):void 0,children:[v&&!s&&a.jsx(zg,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),a.jsxs("div",{className:"relative",children:[a.jsx(ie,{className:"w-5 h-5 flex-shrink-0"}),Ie&&a.jsx("span",{className:`absolute -top-1.5 -right-1.5 min-w-[18px] h-[18px] px-1 flex items-center justify-center text-[10px] font-bold rounded-full ${$e?"bg-blue-500 text-white":"bg-yellow-500 text-black"}`,children:Ze>99?"99+":Ze})]}),(s||v)&&a.jsx("span",{children:i(De)})]})},L)}})})}),!s&&a.jsx("button",{onClick:()=>S(!v),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(v?"nav.collapseSidebar":"nav.expandSidebar"),children:v?a.jsx(gh,{className:"w-5 h-5"}):a.jsx(vs,{className:"w-5 h-5"})}),a.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:s||v?a.jsxs("div",{className:"flex flex-col gap-2 px-2",children:[a.jsxs("div",{className:"flex items-center justify-center gap-1",children:[ce&&a.jsxs("div",{className:"relative",children:[a.jsx("button",{onMouseEnter:()=>D(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${E?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:a.jsx(el,{className:"w-5 h-5"})}),E&&a.jsx(Bz,{onClose:()=>D(!1)})]}),u("system:read")?a.jsx(r0,{to:"/system",className:({isActive:L})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${L?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:a.jsx(Qo,{className:"w-5 h-5"})}):a.jsx("span",{className:"p-2 rounded-lg text-bambu-gray/50 cursor-not-allowed",title:"You do not have permission to view system information",children:a.jsx(Qo,{className:"w-5 h-5"})}),a.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:a.jsx(m3,{className:"w-5 h-5"})}),a.jsx("button",{onClick:()=>k(!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:a.jsx(p3,{className:"w-5 h-5"})}),a.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"?a.jsx(Fz,{className:"w-5 h-5"}):a.jsx(K1,{className:"w-5 h-5"})}),l&&o&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>m(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:"Change Password",children:a.jsx(Ho,{className:"w-5 h-5"})}),a.jsx("button",{onClick:c,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.logout",{defaultValue:"Logout"}),children:a.jsx(x3,{className:"w-5 h-5"})})]})]}),a.jsxs("div",{className:"flex items-center justify-center gap-2",children:[a.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",oe?.version||"..."]}),W?.update_available&&a.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:W.latest_version}),children:[a.jsx(eT,{className:"w-4 h-4"}),a.jsx("span",{children:i("nav.update")})]})]})]}):a.jsxs("div",{className:"flex flex-col items-center gap-1",children:[W?.update_available&&a.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:W.latest_version}),children:a.jsx(eT,{className:"w-5 h-5"})}),ce&&a.jsxs("div",{className:"relative",children:[a.jsx("button",{onMouseEnter:()=>D(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${E?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:a.jsx(el,{className:"w-5 h-5"})}),E&&a.jsx(Bz,{onClose:()=>D(!1)})]}),u("system:read")?a.jsx(r0,{to:"/system",className:({isActive:L})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${L?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:a.jsx(Qo,{className:"w-5 h-5"})}):a.jsx("span",{className:"p-2 rounded-lg text-bambu-gray/50 cursor-not-allowed",title:"You do not have permission to view system information",children:a.jsx(Qo,{className:"w-5 h-5"})}),a.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:a.jsx(m3,{className:"w-5 h-5"})}),a.jsx("button",{onClick:()=>k(!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:a.jsx(p3,{className:"w-5 h-5"})}),a.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"?a.jsx(Fz,{className:"w-5 h-5"}):a.jsx(K1,{className:"w-5 h-5"})}),l&&o&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>m(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:"Change Password",children:a.jsx(Ho,{className:"w-5 h-5"})}),a.jsx("button",{onClick:c,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.logout",{defaultValue:"Logout"}),children:a.jsx(x3,{className:"w-5 h-5"})})]})]})})]}),a.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto transition-all duration-300 ${s?"mt-14":v?"ml-64":"ml-16"}`,children:[fe?.enabled&&a.jsx("div",{className:"bg-amber-500/20 border-b border-amber-500/30 px-4 py-2 flex items-center justify-between",children:a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(sN,{className:"w-4 h-4 text-amber-500 animate-pulse"}),a.jsxs("span",{className:"text-amber-200",children:[i("support.debugLoggingActive",{defaultValue:"Debug logging is active"}),Ue!==null&&a.jsxs("span",{className:"text-amber-300/70 ml-2",children:["(",Math.floor(Ue/60),"m ",Ue%60,"s)"]})]}),a.jsx("button",{onClick:()=>t("/system"),className:"text-amber-400 hover:text-amber-300 font-medium underline ml-2",children:i("support.manageLogs",{defaultValue:"Manage"})})]})}),_e&&a.jsxs("div",{className:"bg-bambu-green/20 border-b border-bambu-green/30 px-4 py-2 flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(eT,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{children:i("nav.updateAvailableBanner",{version:W?.latest_version,defaultValue:`Version ${W?.latest_version} is available!`})}),a.jsx("button",{onClick:()=>t("/settings"),className:"text-bambu-green hover:text-bambu-green/80 font-medium underline",children:i("nav.viewUpdate",{defaultValue:"View update"})})]}),a.jsx("button",{onClick:Te,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:a.jsx(Dt,{className:"w-4 h-4"})})]}),a.jsx(qoe,{})]}),T&&a.jsx(Tfe,{onClose:()=>k(!1),sidebarItems:K.map(L=>{if(aT(L)){const X=U.get(L);return X?{type:"external",label:X.name}:null}else{const X=it.get(L);return X?{type:"nav",label:X.labelKey,labelKey:X.labelKey}:null}}).filter(Boolean)}),Y&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[100] p-4",children:a.jsx("div",{className:"bg-bambu-dark-secondary border-2 border-yellow-500 rounded-xl shadow-2xl max-w-md w-full animate-in fade-in zoom-in duration-200",children:a.jsxs("div",{className:"p-6 text-center",children:[a.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-yellow-500/20 flex items-center justify-center",children:a.jsx("svg",{className:"w-10 h-10 text-yellow-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),a.jsx("h2",{className:"text-xl font-bold text-yellow-400 mb-2",children:"Print Paused!"}),a.jsx("p",{className:"text-lg text-white mb-2",children:Y.printer_name}),a.jsx("p",{className:"text-bambu-gray mb-6",children:"Objects detected on build plate. The print has been automatically paused. Please clear the plate and resume the print."}),a.jsx("button",{onClick:()=>Z(null),className:"w-full py-3 px-6 bg-yellow-500 hover:bg-yellow-600 text-black font-semibold rounded-lg transition-colors",children:"I Understand"})]})})}),f&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>{m(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsxs(wt,{className:"w-full max-w-md",onClick:L=>L.stopPropagation(),children:[a.jsx(Hn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ho,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Change Password"})]}),a.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>{m(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsx(Dt,{className:"w-5 h-5"})})]})}),a.jsxs(St,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Current Password"}),a.jsx("input",{type:"password",value:p.currentPassword,onChange:L=>x({...p,currentPassword:L.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter current password",autoComplete:"current-password"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"New Password"}),a.jsx("input",{type:"password",value:p.newPassword,onChange:L=>x({...p,newPassword:L.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter new password (min 6 characters)",autoComplete:"new-password",minLength:6})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Confirm New Password"}),a.jsx("input",{type:"password",value:p.confirmPassword,onChange:L=>x({...p,confirmPassword:L.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${p.confirmPassword&&p.newPassword!==p.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:"Confirm new password",autoComplete:"new-password",minLength:6}),p.confirmPassword&&p.newPassword!==p.confirmPassword&&a.jsx("p",{className:"text-red-400 text-xs mt-1",children:"Passwords do not match"})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Ne,{variant:"secondary",onClick:()=>{m(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})},children:"Cancel"}),a.jsx(Ne,{onClick:async()=>{if(p.newPassword!==p.confirmPassword){d("Passwords do not match","error");return}if(p.newPassword.length<6){d("Password must be at least 6 characters","error");return}y(!0);try{await ue.changePassword(p.currentPassword,p.newPassword),d("Password changed successfully","success"),m(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})}catch(L){const X=L instanceof Error?L.message:"Failed to change password";d(X,"error")}finally{y(!1)}},disabled:b||!p.currentPassword||!p.newPassword||p.newPassword!==p.confirmPassword||p.newPassword.length<6,children:b?a.jsxs(a.Fragment,{children:[a.jsx(ct,{className:"w-4 h-4 animate-spin"}),"Changing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Ho,{className:"w-4 h-4"}),"Change Password"]})})]})]})]})})]})}function y0(t,e="system"){return e==="12h"?t.hour12=!0:e==="24h"&&(t.hour12=!1),t}function Ri(t){return t?t.endsWith("Z")||/[+-]\d{2}:\d{2}$/.test(t)?new Date(t):new Date(t+"Z"):null}function Bg(t,e){const n=Ri(t);if(!n)return"";const r={year:"numeric",month:"short",day:"numeric"};return n.toLocaleDateString(void 0,e??r)}function $g(t,e="system",n){const r=Ri(t);if(!r)return"";const s=y0(n??{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},e);return r.toLocaleString(void 0,s)}function Ufe(t,e="system",n){const i=y0({...{hour:"2-digit",minute:"2-digit"},...n},e);return t.toLocaleTimeString([],i)}const zD="181",Mg={ROTATE:0,DOLLY:1,PAN:2},mg={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},zfe=0,Hz=1,Bfe=2,BW=1,$fe=2,ou=3,_h=0,zs=1,ic=2,Mu=0,Eg=1,Vz=2,Gz=3,qz=4,Hfe=5,Nf=100,Vfe=101,Gfe=102,qfe=103,Wfe=104,Kfe=200,Xfe=201,Yfe=202,Qfe=203,_3=204,w3=205,Zfe=206,Jfe=207,eme=208,tme=209,nme=210,rme=211,ime=212,ame=213,sme=214,S3=0,N3=1,M3=2,Hg=3,E3=4,C3=5,T3=6,A3=7,BD=0,ome=1,lme=2,sh=0,cme=1,ume=2,dme=3,hme=4,fme=5,mme=6,pme=7,$W=300,Vg=301,Gg=302,k3=303,j3=304,_N=306,P3=1e3,xu=1001,R3=1002,mo=1003,gme=1004,O_=1005,Zo=1006,sT=1007,Pf=1008,gc=1009,HW=1010,VW=1011,X0=1012,$D=1013,lm=1014,bu=1015,yx=1016,HD=1017,VD=1018,Y0=1020,GW=35902,qW=35899,WW=1021,KW=1022,Pl=1023,Q0=1026,Z0=1027,XW=1028,GD=1029,qD=1030,WD=1031,KD=1033,b1=33776,y1=33777,v1=33778,_1=33779,D3=35840,O3=35841,L3=35842,I3=35843,F3=36196,U3=37492,z3=37496,B3=37808,$3=37809,H3=37810,V3=37811,G3=37812,q3=37813,W3=37814,K3=37815,X3=37816,Y3=37817,Q3=37818,Z3=37819,J3=37820,eP=37821,tP=36492,nP=36494,rP=36495,iP=36283,aP=36284,sP=36285,oP=36286,xme=3200,bme=3201,YW=0,yme=1,qd="",so="srgb",qg="srgb-linear",Y1="linear",Nr="srgb",gp=7680,Wz=519,vme=512,_me=513,wme=514,QW=515,Sme=516,Nme=517,Mme=518,Eme=519,Kz=35044,Xz="300 es",lc=2e3,Q1=2001;function ZW(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function Z1(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Cme(){const t=Z1("canvas");return t.style.display="block",t}const Yz={};function Qz(...t){const e="THREE."+t.shift();console.log(e,...t)}function mn(...t){const e="THREE."+t.shift();console.warn(e,...t)}function _i(...t){const e="THREE."+t.shift();console.error(e,...t)}function J0(...t){const e=t.join(" ");e in Yz||(Yz[e]=!0,mn(...t))}function Tme(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 Em=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,o=i.length;s<o;s++)i[s].call(this,e);e.target=null}}};const Ba=["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"],w1=Math.PI/180,lP=180/Math.PI;function Uy(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Ba[t&255]+Ba[t>>8&255]+Ba[t>>16&255]+Ba[t>>24&255]+"-"+Ba[e&255]+Ba[e>>8&255]+"-"+Ba[e>>16&15|64]+Ba[e>>24&255]+"-"+Ba[n&63|128]+Ba[n>>8&255]+"-"+Ba[n>>16&255]+Ba[n>>24&255]+Ba[r&255]+Ba[r>>8&255]+Ba[r>>16&255]+Ba[r>>24&255]).toLowerCase()}function Un(t,e,n){return Math.max(e,Math.min(n,t))}function Ame(t,e){return(t%e+e)%e}function oT(t,e,n){return(1-n)*t+n*e}function Pb(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 Ps(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 kme={DEG2RAD:w1};let An=class JW{constructor(e=0,n=0){JW.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=Un(this.x,e.x,n.x),this.y=Un(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=Un(this.x,e,n),this.y=Un(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Un(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(Un(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,o=this.y-e.y;return this.x=s*r-o*i+e.x,this.y=s*i+o*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},cm=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,o,l){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3],m=s[o+0],p=s[o+1],x=s[o+2],b=s[o+3];if(l<=0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(l>=1){e[n+0]=m,e[n+1]=p,e[n+2]=x,e[n+3]=b;return}if(f!==b||c!==m||u!==p||d!==x){let y=c*m+u*p+d*x+f*b;y<0&&(m=-m,p=-p,x=-x,b=-b,y=-y);let v=1-l;if(y<.9995){const S=Math.acos(y),N=Math.sin(S);v=Math.sin(v*S)/N,l=Math.sin(l*S)/N,c=c*v+m*l,u=u*v+p*l,d=d*v+x*l,f=f*v+b*l}else{c=c*v+m*l,u=u*v+p*l,d=d*v+x*l,f=f*v+b*l;const S=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=S,u*=S,d*=S,f*=S}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,s,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=s[o],m=s[o+1],p=s[o+2],x=s[o+3];return e[n]=l*x+d*f+c*p-u*m,e[n+1]=c*x+d*m+u*f-l*p,e[n+2]=u*x+d*p+l*m-c*f,e[n+3]=d*x-l*f-c*m-u*p,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,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(s/2),m=c(r/2),p=c(i/2),x=c(s/2);switch(o){case"XYZ":this._x=m*d*f+u*p*x,this._y=u*p*f-m*d*x,this._z=u*d*x+m*p*f,this._w=u*d*f-m*p*x;break;case"YXZ":this._x=m*d*f+u*p*x,this._y=u*p*f-m*d*x,this._z=u*d*x-m*p*f,this._w=u*d*f+m*p*x;break;case"ZXY":this._x=m*d*f-u*p*x,this._y=u*p*f+m*d*x,this._z=u*d*x+m*p*f,this._w=u*d*f-m*p*x;break;case"ZYX":this._x=m*d*f-u*p*x,this._y=u*p*f+m*d*x,this._z=u*d*x-m*p*f,this._w=u*d*f+m*p*x;break;case"YZX":this._x=m*d*f+u*p*x,this._y=u*p*f+m*d*x,this._z=u*d*x-m*p*f,this._w=u*d*f-m*p*x;break;case"XZY":this._x=m*d*f-u*p*x,this._y=u*p*f-m*d*x,this._z=u*d*x+m*p*f,this._w=u*d*f+m*p*x;break;default:mn("Quaternion: .setFromEuler() encountered an unknown order: "+o)}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],o=n[1],l=n[5],c=n[9],u=n[2],d=n[6],f=n[10],m=r+l+f;if(m>0){const p=.5/Math.sqrt(m+1);this._w=.25/p,this._x=(d-c)*p,this._y=(s-u)*p,this._z=(o-i)*p}else if(r>l&&r>f){const p=2*Math.sqrt(1+r-l-f);this._w=(d-c)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(s+u)/p}else if(l>f){const p=2*Math.sqrt(1+l-r-f);this._w=(s-u)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+f-r-l);this._w=(o-i)/p,this._x=(s+u)/p,this._y=(c+d)/p,this._z=.25*p}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(Un(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,o=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+o*l+i*u-s*c,this._y=i*d+o*c+s*l-r*u,this._z=s*d+o*u+r*c-i*l,this._w=o*d-r*l-i*c-s*u,this._onChangeCallback(),this}slerp(e,n){if(n<=0)return this;if(n>=1)return this.copy(e);let r=e._x,i=e._y,s=e._z,o=e._w,l=this.dot(e);l<0&&(r=-r,i=-i,s=-s,o=-o,l=-l);let c=1-n;if(l<.9995){const u=Math.acos(l),d=Math.sin(u);c=Math.sin(c*u)/d,n=Math.sin(n*u)/d,this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+s*n,this._w=this._w*c+o*n,this._onChangeCallback()}else this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+s*n,this._w=this._w*c+o*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}},lt=class eK{constructor(e=0,n=0,r=0){eK.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(Zz.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(Zz.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,o=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])*o,this.y=(s[1]*n+s[5]*r+s[9]*i+s[13])*o,this.z=(s[2]*n+s[6]*r+s[10]*i+s[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,s=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-s*i),f=2*(s*r-o*n);return this.x=n+c*u+o*f-l*d,this.y=r+c*d+l*u-s*f,this.z=i+c*f+s*d-o*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=Un(this.x,e.x,n.x),this.y=Un(this.y,e.y,n.y),this.z=Un(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=Un(this.x,e,n),this.y=Un(this.y,e,n),this.z=Un(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Un(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,o=n.x,l=n.y,c=n.z;return this.x=i*c-s*l,this.y=s*o-r*c,this.z=r*l-i*o,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 lT.copy(this).projectOnVector(e),this.sub(lT)}reflect(e){return this.sub(lT.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(Un(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 lT=new lt,Zz=new cm;let Pn=class tK{constructor(e,n,r,i,s,o,l,c,u){tK.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,o,l,c,u)}set(e,n,r,i,s,o,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=s,d[5]=c,d[6]=r,d[7]=o,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,o=r[0],l=r[3],c=r[6],u=r[1],d=r[4],f=r[7],m=r[2],p=r[5],x=r[8],b=i[0],y=i[3],v=i[6],S=i[1],N=i[4],C=i[7],T=i[2],k=i[5],E=i[8];return s[0]=o*b+l*S+c*T,s[3]=o*y+l*N+c*k,s[6]=o*v+l*C+c*E,s[1]=u*b+d*S+f*T,s[4]=u*y+d*N+f*k,s[7]=u*v+d*C+f*E,s[2]=m*b+p*S+x*T,s[5]=m*y+p*N+x*k,s[8]=m*v+p*C+x*E,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],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8];return n*o*d-n*l*u-r*s*d+r*l*c+i*s*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=d*o-l*u,m=l*c-d*s,p=u*s-o*c,x=n*f+r*m+i*p;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const b=1/x;return e[0]=f*b,e[1]=(i*u-d*r)*b,e[2]=(l*r-i*o)*b,e[3]=m*b,e[4]=(d*n-i*c)*b,e[5]=(i*s-l*n)*b,e[6]=p*b,e[7]=(r*c-u*n)*b,e[8]=(o*n-r*s)*b,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,o,l){const c=Math.cos(s),u=Math.sin(s);return this.set(r*c,r*u,-r*(c*o+u*l)+o+e,-i*u,i*c,-i*(-u*o+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply(cT.makeScale(e,n)),this}rotate(e){return this.premultiply(cT.makeRotation(-e)),this}translate(e,n){return this.premultiply(cT.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 cT=new Pn,Jz=new Pn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),eB=new Pn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function jme(){const t={enabled:!0,workingColorSpace:qg,spaces:{},convert:function(i,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===Nr&&(i.r=Eu(i.r),i.g=Eu(i.g),i.b=Eu(i.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===Nr&&(i.r=Cg(i.r),i.g=Cg(i.g),i.b=Cg(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===qd?Y1: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,o){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].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 J0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return J0("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({[qg]:{primaries:e,whitePoint:r,transfer:Y1,toXYZ:Jz,fromXYZ:eB,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:so},outputColorSpaceConfig:{drawingBufferColorSpace:so}},[so]:{primaries:e,whitePoint:r,transfer:Nr,toXYZ:Jz,fromXYZ:eB,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:so}}}),t}const ar=jme();function Eu(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Cg(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let xp,Pme=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{xp===void 0&&(xp=Z1("canvas")),xp.width=e.width,xp.height=e.height;const i=xp.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=xp}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=Z1("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 o=0;o<s.length;o++)s[o]=Eu(s[o]/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(Eu(n[r]/255)*255):n[r]=Eu(n[r]);return{data:n,width:e.width,height:e.height}}else return mn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Rme=0,XD=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Rme++}),this.uuid=Uy(),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 o=0,l=i.length;o<l;o++)i[o].isDataTexture?s.push(uT(i[o].image)):s.push(uT(i[o]))}else s=uT(i);r.url=s}return n||(e.images[this.uuid]=r),r}};function uT(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?Pme.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(mn("Texture: Unable to serialize Texture."),{})}let Dme=0;const dT=new lt;let zl=class S1 extends Em{constructor(e=S1.DEFAULT_IMAGE,n=S1.DEFAULT_MAPPING,r=xu,i=xu,s=Zo,o=Pf,l=Pl,c=gc,u=S1.DEFAULT_ANISOTROPY,d=qd){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Dme++}),this.uuid=Uy(),this.name="",this.source=new XD(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=u,this.format=l,this.internalFormat=null,this.type=c,this.offset=new An(0,0),this.repeat=new An(1,1),this.center=new An(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Pn,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(dT).x}get height(){return this.source.getSize(dT).y}get depth(){return this.source.getSize(dT).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){mn(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){mn(`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!==$W)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case P3:e.x=e.x-Math.floor(e.x);break;case xu:e.x=e.x<0?0:1;break;case R3: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 P3:e.y=e.y-Math.floor(e.y);break;case xu:e.y=e.y<0?0:1;break;case R3: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++}};zl.DEFAULT_IMAGE=null;zl.DEFAULT_MAPPING=$W;zl.DEFAULT_ANISOTROPY=1;let Di=class nK{constructor(e=0,n=0,r=0,i=1){nK.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,o=e.elements;return this.x=o[0]*n+o[4]*r+o[8]*i+o[12]*s,this.y=o[1]*n+o[5]*r+o[9]*i+o[13]*s,this.z=o[2]*n+o[6]*r+o[10]*i+o[14]*s,this.w=o[3]*n+o[7]*r+o[11]*i+o[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,s;const c=e.elements,u=c[0],d=c[4],f=c[8],m=c[1],p=c[5],x=c[9],b=c[2],y=c[6],v=c[10];if(Math.abs(d-m)<.01&&Math.abs(f-b)<.01&&Math.abs(x-y)<.01){if(Math.abs(d+m)<.1&&Math.abs(f+b)<.1&&Math.abs(x+y)<.1&&Math.abs(u+p+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const N=(u+1)/2,C=(p+1)/2,T=(v+1)/2,k=(d+m)/4,E=(f+b)/4,D=(x+y)/4;return N>C&&N>T?N<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(N),i=k/r,s=E/r):C>T?C<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(C),r=k/i,s=D/i):T<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(T),r=E/s,i=D/s),this.set(r,i,s,n),this}let S=Math.sqrt((y-x)*(y-x)+(f-b)*(f-b)+(m-d)*(m-d));return Math.abs(S)<.001&&(S=1),this.x=(y-x)/S,this.y=(f-b)/S,this.z=(m-d)/S,this.w=Math.acos((u+p+v-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=Un(this.x,e.x,n.x),this.y=Un(this.y,e.y,n.y),this.z=Un(this.z,e.z,n.z),this.w=Un(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=Un(this.x,e,n),this.y=Un(this.y,e,n),this.z=Un(this.z,e,n),this.w=Un(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Un(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}},Ome=class extends Em{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Zo,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 Di(0,0,e,n),this.scissorTest=!1,this.viewport=new Di(0,0,e,n);const i={width:e,height:n,depth:r.depth},s=new zl(i);this.textures=[];const o=r.count;for(let l=0;l<o;l++)this.textures[l]=s.clone(),this.textures[l].isRenderTargetTexture=!0,this.textures[l].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:Zo,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 XD(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"})}},um=class extends Ome{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},rK=class extends zl{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=mo,this.minFilter=mo,this.wrapR=xu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Lme=class extends zl{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=mo,this.minFilter=mo,this.wrapR=xu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},oh=class{constructor(e=new lt(1/0,1/0,1/0),n=new lt(-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(vl.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(vl.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=vl.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 o=0,l=s.count;o<l;o++)e.isMesh===!0?e.getVertexPosition(o,vl):vl.fromBufferAttribute(s,o),vl.applyMatrix4(e.matrixWorld),this.expandByPoint(vl);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),L_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),L_.copy(r.boundingBox)),L_.applyMatrix4(e.matrixWorld),this.union(L_)}const i=e.children;for(let s=0,o=i.length;s<o;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,vl),vl.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(Rb),I_.subVectors(this.max,Rb),bp.subVectors(e.a,Rb),yp.subVectors(e.b,Rb),vp.subVectors(e.c,Rb),_d.subVectors(yp,bp),wd.subVectors(vp,yp),of.subVectors(bp,vp);let n=[0,-_d.z,_d.y,0,-wd.z,wd.y,0,-of.z,of.y,_d.z,0,-_d.x,wd.z,0,-wd.x,of.z,0,-of.x,-_d.y,_d.x,0,-wd.y,wd.x,0,-of.y,of.x,0];return!hT(n,bp,yp,vp,I_)||(n=[1,0,0,0,1,0,0,0,1],!hT(n,bp,yp,vp,I_))?!1:(F_.crossVectors(_d,wd),n=[F_.x,F_.y,F_.z],hT(n,bp,yp,vp,I_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,vl).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(vl).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:(Gc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Gc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Gc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Gc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Gc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Gc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Gc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Gc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Gc),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 Gc=[new lt,new lt,new lt,new lt,new lt,new lt,new lt,new lt],vl=new lt,L_=new oh,bp=new lt,yp=new lt,vp=new lt,_d=new lt,wd=new lt,of=new lt,Rb=new lt,I_=new lt,F_=new lt,lf=new lt;function hT(t,e,n,r,i){for(let s=0,o=t.length-3;s<=o;s+=3){lf.fromArray(t,s);const l=i.x*Math.abs(lf.x)+i.y*Math.abs(lf.y)+i.z*Math.abs(lf.z),c=e.dot(lf),u=n.dot(lf),d=r.dot(lf);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const Ime=new oh,Db=new lt,fT=new lt;let wN=class{constructor(e=new lt,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):Ime.setFromPoints(e).getCenter(r);let i=0;for(let s=0,o=e.length;s<o;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;Db.subVectors(e,this.center);const n=Db.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Db,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):(fT.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Db.copy(e.center).add(fT)),this.expandByPoint(Db.copy(e.center).sub(fT))),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 qc=new lt,mT=new lt,U_=new lt,Sd=new lt,pT=new lt,z_=new lt,gT=new lt;let YD=class{constructor(e=new lt,n=new lt(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,qc)),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=qc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(qc.copy(this.origin).addScaledVector(this.direction,n),qc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){mT.copy(e).add(n).multiplyScalar(.5),U_.copy(n).sub(e).normalize(),Sd.copy(this.origin).sub(mT);const s=e.distanceTo(n)*.5,o=-this.direction.dot(U_),l=Sd.dot(this.direction),c=-Sd.dot(U_),u=Sd.lengthSq(),d=Math.abs(1-o*o);let f,m,p,x;if(d>0)if(f=o*c-l,m=o*l-c,x=s*d,f>=0)if(m>=-x)if(m<=x){const b=1/d;f*=b,m*=b,p=f*(f+o*m+2*l)+m*(o*f+m+2*c)+u}else m=s,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m=-s,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m<=-x?(f=Math.max(0,-(-o*s+l)),m=f>0?-s:Math.min(Math.max(-s,-c),s),p=-f*f+m*(m+2*c)+u):m<=x?(f=0,m=Math.min(Math.max(-s,-c),s),p=m*(m+2*c)+u):(f=Math.max(0,-(o*s+l)),m=f>0?s:Math.min(Math.max(-s,-c),s),p=-f*f+m*(m+2*c)+u);else m=o>0?-s:s,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(mT).addScaledVector(U_,m),p}intersectSphere(e,n){qc.subVectors(e.center,this.origin);const r=qc.dot(this.direction),i=qc.dot(qc)-r*r,s=e.radius*e.radius;if(i>s)return null;const o=Math.sqrt(s-i),l=r-o,c=r+o;return c<0?null:l<0?this.at(c,n):this.at(l,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,o,l,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,m=this.origin;return u>=0?(r=(e.min.x-m.x)*u,i=(e.max.x-m.x)*u):(r=(e.max.x-m.x)*u,i=(e.min.x-m.x)*u),d>=0?(s=(e.min.y-m.y)*d,o=(e.max.y-m.y)*d):(s=(e.max.y-m.y)*d,o=(e.min.y-m.y)*d),r>o||s>i||((s>r||isNaN(r))&&(r=s),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-m.z)*f,c=(e.max.z-m.z)*f):(l=(e.max.z-m.z)*f,c=(e.min.z-m.z)*f),r>c||l>i)||((l>r||r!==r)&&(r=l),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,qc)!==null}intersectTriangle(e,n,r,i,s){pT.subVectors(n,e),z_.subVectors(r,e),gT.crossVectors(pT,z_);let o=this.direction.dot(gT),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;Sd.subVectors(this.origin,e);const c=l*this.direction.dot(z_.crossVectors(Sd,z_));if(c<0)return null;const u=l*this.direction.dot(pT.cross(Sd));if(u<0||c+u>o)return null;const d=-l*Sd.dot(gT);return d<0?null:this.at(d/o,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)}},Fi=class cP{constructor(e,n,r,i,s,o,l,c,u,d,f,m,p,x,b,y){cP.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,o,l,c,u,d,f,m,p,x,b,y)}set(e,n,r,i,s,o,l,c,u,d,f,m,p,x,b,y){const v=this.elements;return v[0]=e,v[4]=n,v[8]=r,v[12]=i,v[1]=s,v[5]=o,v[9]=l,v[13]=c,v[2]=u,v[6]=d,v[10]=f,v[14]=m,v[3]=p,v[7]=x,v[11]=b,v[15]=y,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new cP().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/_p.setFromMatrixColumn(e,0).length(),s=1/_p.setFromMatrixColumn(e,1).length(),o=1/_p.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]*o,n[9]=r[9]*o,n[10]=r[10]*o,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,o=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(s),f=Math.sin(s);if(e.order==="XYZ"){const m=o*d,p=o*f,x=l*d,b=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+x*u,n[5]=m-b*u,n[9]=-l*c,n[2]=b-m*u,n[6]=x+p*u,n[10]=o*c}else if(e.order==="YXZ"){const m=c*d,p=c*f,x=u*d,b=u*f;n[0]=m+b*l,n[4]=x*l-p,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=p*l-x,n[6]=b+m*l,n[10]=o*c}else if(e.order==="ZXY"){const m=c*d,p=c*f,x=u*d,b=u*f;n[0]=m-b*l,n[4]=-o*f,n[8]=x+p*l,n[1]=p+x*l,n[5]=o*d,n[9]=b-m*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const m=o*d,p=o*f,x=l*d,b=l*f;n[0]=c*d,n[4]=x*u-p,n[8]=m*u+b,n[1]=c*f,n[5]=b*u+m,n[9]=p*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const m=o*c,p=o*u,x=l*c,b=l*u;n[0]=c*d,n[4]=b-m*f,n[8]=x*f+p,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=p*f+x,n[10]=m-b*f}else if(e.order==="XZY"){const m=o*c,p=o*u,x=l*c,b=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=m*f+b,n[5]=o*d,n[9]=p*f-x,n[2]=x*f-p,n[6]=l*d,n[10]=b*f+m}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(Fme,e,Ume)}lookAt(e,n,r){const i=this.elements;return no.subVectors(e,n),no.lengthSq()===0&&(no.z=1),no.normalize(),Nd.crossVectors(r,no),Nd.lengthSq()===0&&(Math.abs(r.z)===1?no.x+=1e-4:no.z+=1e-4,no.normalize(),Nd.crossVectors(r,no)),Nd.normalize(),B_.crossVectors(no,Nd),i[0]=Nd.x,i[4]=B_.x,i[8]=no.x,i[1]=Nd.y,i[5]=B_.y,i[9]=no.y,i[2]=Nd.z,i[6]=B_.z,i[10]=no.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,o=r[0],l=r[4],c=r[8],u=r[12],d=r[1],f=r[5],m=r[9],p=r[13],x=r[2],b=r[6],y=r[10],v=r[14],S=r[3],N=r[7],C=r[11],T=r[15],k=i[0],E=i[4],D=i[8],A=i[12],R=i[1],F=i[5],O=i[9],H=i[13],j=i[2],G=i[6],$=i[10],q=i[14],Y=i[3],Z=i[7],oe=i[11],B=i[15];return s[0]=o*k+l*R+c*j+u*Y,s[4]=o*E+l*F+c*G+u*Z,s[8]=o*D+l*O+c*$+u*oe,s[12]=o*A+l*H+c*q+u*B,s[1]=d*k+f*R+m*j+p*Y,s[5]=d*E+f*F+m*G+p*Z,s[9]=d*D+f*O+m*$+p*oe,s[13]=d*A+f*H+m*q+p*B,s[2]=x*k+b*R+y*j+v*Y,s[6]=x*E+b*F+y*G+v*Z,s[10]=x*D+b*O+y*$+v*oe,s[14]=x*A+b*H+y*q+v*B,s[3]=S*k+N*R+C*j+T*Y,s[7]=S*E+N*F+C*G+T*Z,s[11]=S*D+N*O+C*$+T*oe,s[15]=S*A+N*H+C*q+T*B,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],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],m=e[10],p=e[14],x=e[3],b=e[7],y=e[11],v=e[15];return x*(+s*c*f-i*u*f-s*l*m+r*u*m+i*l*p-r*c*p)+b*(+n*c*p-n*u*m+s*o*m-i*o*p+i*u*d-s*c*d)+y*(+n*u*f-n*l*p-s*o*f+r*o*p+s*l*d-r*u*d)+v*(-i*l*d-n*c*f+n*l*m+i*o*f-r*o*m+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9],m=e[10],p=e[11],x=e[12],b=e[13],y=e[14],v=e[15],S=f*y*u-b*m*u+b*c*p-l*y*p-f*c*v+l*m*v,N=x*m*u-d*y*u-x*c*p+o*y*p+d*c*v-o*m*v,C=d*b*u-x*f*u+x*l*p-o*b*p-d*l*v+o*f*v,T=x*f*c-d*b*c-x*l*m+o*b*m+d*l*y-o*f*y,k=n*S+r*N+i*C+s*T;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const E=1/k;return e[0]=S*E,e[1]=(b*m*s-f*y*s-b*i*p+r*y*p+f*i*v-r*m*v)*E,e[2]=(l*y*s-b*c*s+b*i*u-r*y*u-l*i*v+r*c*v)*E,e[3]=(f*c*s-l*m*s-f*i*u+r*m*u+l*i*p-r*c*p)*E,e[4]=N*E,e[5]=(d*y*s-x*m*s+x*i*p-n*y*p-d*i*v+n*m*v)*E,e[6]=(x*c*s-o*y*s-x*i*u+n*y*u+o*i*v-n*c*v)*E,e[7]=(o*m*s-d*c*s+d*i*u-n*m*u-o*i*p+n*c*p)*E,e[8]=C*E,e[9]=(x*f*s-d*b*s-x*r*p+n*b*p+d*r*v-n*f*v)*E,e[10]=(o*b*s-x*l*s+x*r*u-n*b*u-o*r*v+n*l*v)*E,e[11]=(d*l*s-o*f*s-d*r*u+n*f*u+o*r*p-n*l*p)*E,e[12]=T*E,e[13]=(d*b*i-x*f*i+x*r*m-n*b*m-d*r*y+n*f*y)*E,e[14]=(x*l*i-o*b*i-x*r*c+n*b*c+o*r*y-n*l*y)*E,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*m+n*l*m)*E,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,o=e.x,l=e.y,c=e.z,u=s*o,d=s*l;return this.set(u*o+r,u*l-i*c,u*c+i*l,0,u*l+i*c,d*l+r,d*c-i*o,0,u*c-i*l,d*c+i*o,s*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,s,o){return this.set(1,r,s,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,s=n._x,o=n._y,l=n._z,c=n._w,u=s+s,d=o+o,f=l+l,m=s*u,p=s*d,x=s*f,b=o*d,y=o*f,v=l*f,S=c*u,N=c*d,C=c*f,T=r.x,k=r.y,E=r.z;return i[0]=(1-(b+v))*T,i[1]=(p+C)*T,i[2]=(x-N)*T,i[3]=0,i[4]=(p-C)*k,i[5]=(1-(m+v))*k,i[6]=(y+S)*k,i[7]=0,i[8]=(x+N)*E,i[9]=(y-S)*E,i[10]=(1-(m+b))*E,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=_p.set(i[0],i[1],i[2]).length();const o=_p.set(i[4],i[5],i[6]).length(),l=_p.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],_l.copy(this);const u=1/s,d=1/o,f=1/l;return _l.elements[0]*=u,_l.elements[1]*=u,_l.elements[2]*=u,_l.elements[4]*=d,_l.elements[5]*=d,_l.elements[6]*=d,_l.elements[8]*=f,_l.elements[9]*=f,_l.elements[10]*=f,n.setFromRotationMatrix(_l),r.x=s,r.y=o,r.z=l,this}makePerspective(e,n,r,i,s,o,l=lc,c=!1){const u=this.elements,d=2*s/(n-e),f=2*s/(r-i),m=(n+e)/(n-e),p=(r+i)/(r-i);let x,b;if(c)x=s/(o-s),b=o*s/(o-s);else if(l===lc)x=-(o+s)/(o-s),b=-2*o*s/(o-s);else if(l===Q1)x=-o/(o-s),b=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=m,u[12]=0,u[1]=0,u[5]=f,u[9]=p,u[13]=0,u[2]=0,u[6]=0,u[10]=x,u[14]=b,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,s,o,l=lc,c=!1){const u=this.elements,d=2/(n-e),f=2/(r-i),m=-(n+e)/(n-e),p=-(r+i)/(r-i);let x,b;if(c)x=1/(o-s),b=o/(o-s);else if(l===lc)x=-2/(o-s),b=-(o+s)/(o-s);else if(l===Q1)x=-1/(o-s),b=-s/(o-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=0,u[12]=m,u[1]=0,u[5]=f,u[9]=0,u[13]=p,u[2]=0,u[6]=0,u[10]=x,u[14]=b,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 _p=new lt,_l=new Fi,Fme=new lt(0,0,0),Ume=new lt(1,1,1),Nd=new lt,B_=new lt,no=new lt,tB=new Fi,nB=new cm;let wh=class iK{constructor(e=0,n=0,r=0,i=iK.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],o=i[4],l=i[8],c=i[1],u=i[5],d=i[9],f=i[2],m=i[6],p=i[10];switch(n){case"XYZ":this._y=Math.asin(Un(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(m,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Un(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,p),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(Un(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Un(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(m,p),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(Un(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(l,p));break;case"XZY":this._z=Math.asin(-Un(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(m,u),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-d,p),this._y=0);break;default:mn("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return tB.makeRotationFromQuaternion(e),this.setFromRotationMatrix(tB,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return nB.setFromEuler(this),this.setFromQuaternion(nB,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}};wh.DEFAULT_ORDER="XYZ";let aK=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}},zme=0;const rB=new lt,wp=new cm,Wc=new Fi,$_=new lt,Ob=new lt,Bme=new lt,$me=new cm,iB=new lt(1,0,0),aB=new lt(0,1,0),sB=new lt(0,0,1),oB={type:"added"},Hme={type:"removed"},Sp={type:"childadded",child:null},xT={type:"childremoved",child:null};let vo=class N1 extends Em{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:zme++}),this.uuid=Uy(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=N1.DEFAULT_UP.clone();const e=new lt,n=new wh,r=new cm,i=new lt(1,1,1);function s(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(s),r._onChange(o),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 Fi},normalMatrix:{value:new Pn}}),this.matrix=new Fi,this.matrixWorld=new Fi,this.matrixAutoUpdate=N1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=N1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new aK,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 wp.setFromAxisAngle(e,n),this.quaternion.multiply(wp),this}rotateOnWorldAxis(e,n){return wp.setFromAxisAngle(e,n),this.quaternion.premultiply(wp),this}rotateX(e){return this.rotateOnAxis(iB,e)}rotateY(e){return this.rotateOnAxis(aB,e)}rotateZ(e){return this.rotateOnAxis(sB,e)}translateOnAxis(e,n){return rB.copy(e).applyQuaternion(this.quaternion),this.position.add(rB.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(iB,e)}translateY(e){return this.translateOnAxis(aB,e)}translateZ(e){return this.translateOnAxis(sB,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Wc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?$_.copy(e):$_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Ob.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Wc.lookAt(Ob,$_,this.up):Wc.lookAt($_,Ob,this.up),this.quaternion.setFromRotationMatrix(Wc),i&&(Wc.extractRotation(i.matrixWorld),wp.setFromRotationMatrix(Wc),this.quaternion.premultiply(wp.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(_i("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(oB),Sp.child=e,this.dispatchEvent(Sp),Sp.child=null):_i("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(Hme),xT.child=e,this.dispatchEvent(xT),xT.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),Wc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Wc.multiply(e.parent.matrixWorld)),e.applyMatrix4(Wc),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(oB),Sp.child=e,this.dispatchEvent(Sp),Sp.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 o=this.children[r].getObjectByProperty(e,n);if(o!==void 0)return o}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let s=0,o=i.length;s<o;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(Ob,e,Bme),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ob,$me,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,o=i.length;s<o;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(l=>({...l,boundingBox:l.boundingBox?l.boundingBox.toJSON():void 0,boundingSphere:l.boundingSphere?l.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(l=>({...l})),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(l,c){return l[c.uuid]===void 0&&(l[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const c=l.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];s(e.shapes,f)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let c=0,u=this.material.length;c<u;c++)l.push(s(e.materials,this.material[c]));i.material=l}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let l=0;l<this.children.length;l++)i.children.push(this.children[l].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let l=0;l<this.animations.length;l++){const c=this.animations[l];i.animations.push(s(e.animations,c))}}if(n){const l=o(e.geometries),c=o(e.materials),u=o(e.textures),d=o(e.images),f=o(e.shapes),m=o(e.skeletons),p=o(e.animations),x=o(e.nodes);l.length>0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),m.length>0&&(r.skeletons=m),p.length>0&&(r.animations=p),x.length>0&&(r.nodes=x)}return r.object=i,r;function o(l){const c=[];for(const u in l){const d=l[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}};vo.DEFAULT_UP=new lt(0,1,0);vo.DEFAULT_MATRIX_AUTO_UPDATE=!0;vo.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const wl=new lt,Kc=new lt,bT=new lt,Xc=new lt,Np=new lt,Mp=new lt,lB=new lt,yT=new lt,vT=new lt,_T=new lt,wT=new Di,ST=new Di,NT=new Di;let Lb=class ag{constructor(e=new lt,n=new lt,r=new lt){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),wl.subVectors(e,n),i.cross(wl);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){wl.subVectors(i,n),Kc.subVectors(r,n),bT.subVectors(e,n);const o=wl.dot(wl),l=wl.dot(Kc),c=wl.dot(bT),u=Kc.dot(Kc),d=Kc.dot(bT),f=o*u-l*l;if(f===0)return s.set(0,0,0),null;const m=1/f,p=(u*c-l*d)*m,x=(o*d-l*c)*m;return s.set(1-p-x,x,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Xc)===null?!1:Xc.x>=0&&Xc.y>=0&&Xc.x+Xc.y<=1}static getInterpolation(e,n,r,i,s,o,l,c){return this.getBarycoord(e,n,r,i,Xc)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,Xc.x),c.addScaledVector(o,Xc.y),c.addScaledVector(l,Xc.z),c)}static getInterpolatedAttribute(e,n,r,i,s,o){return wT.setScalar(0),ST.setScalar(0),NT.setScalar(0),wT.fromBufferAttribute(e,n),ST.fromBufferAttribute(e,r),NT.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(wT,s.x),o.addScaledVector(ST,s.y),o.addScaledVector(NT,s.z),o}static isFrontFacing(e,n,r,i){return wl.subVectors(r,n),Kc.subVectors(e,n),wl.cross(Kc).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 wl.subVectors(this.c,this.b),Kc.subVectors(this.a,this.b),wl.cross(Kc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ag.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return ag.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,s){return ag.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return ag.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ag.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 o,l;Np.subVectors(i,r),Mp.subVectors(s,r),yT.subVectors(e,r);const c=Np.dot(yT),u=Mp.dot(yT);if(c<=0&&u<=0)return n.copy(r);vT.subVectors(e,i);const d=Np.dot(vT),f=Mp.dot(vT);if(d>=0&&f<=d)return n.copy(i);const m=c*f-d*u;if(m<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(Np,o);_T.subVectors(e,s);const p=Np.dot(_T),x=Mp.dot(_T);if(x>=0&&p<=x)return n.copy(s);const b=p*u-c*x;if(b<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(Mp,l);const y=d*x-p*f;if(y<=0&&f-d>=0&&p-x>=0)return lB.subVectors(s,i),l=(f-d)/(f-d+(p-x)),n.copy(i).addScaledVector(lB,l);const v=1/(y+b+m);return o=b*v,l=m*v,n.copy(r).addScaledVector(Np,o).addScaledVector(Mp,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const sK={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Md={h:0,s:0,l:0},H_={h:0,s:0,l:0};function MT(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 Rn=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=so){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ar.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=ar.workingColorSpace){return this.r=e,this.g=n,this.b=r,ar.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=ar.workingColorSpace){if(e=Ame(e,1),n=Un(n,0,1),r=Un(r,0,1),n===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+n):r+n-r*n,o=2*r-s;this.r=MT(o,s,e+1/3),this.g=MT(o,s,e),this.b=MT(o,s,e-1/3)}return ar.colorSpaceToWorking(this,i),this}setStyle(e,n=so){function r(s){s!==void 0&&parseFloat(s)<1&&mn("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const o=i[1],l=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))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(l))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(l))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,n);break;default:mn("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,n);if(o===6)return this.setHex(parseInt(s,16),n);mn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=so){const r=sK[e.toLowerCase()];return r!==void 0?this.setHex(r,n):mn("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=Eu(e.r),this.g=Eu(e.g),this.b=Eu(e.b),this}copyLinearToSRGB(e){return this.r=Cg(e.r),this.g=Cg(e.g),this.b=Cg(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=so){return ar.workingToColorSpace($a.copy(this),e),Math.round(Un($a.r*255,0,255))*65536+Math.round(Un($a.g*255,0,255))*256+Math.round(Un($a.b*255,0,255))}getHexString(e=so){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=ar.workingColorSpace){ar.workingToColorSpace($a.copy(this),n);const r=$a.r,i=$a.g,s=$a.b,o=Math.max(r,i,s),l=Math.min(r,i,s);let c,u;const d=(l+o)/2;if(l===o)c=0,u=0;else{const f=o-l;switch(u=d<=.5?f/(o+l):f/(2-o-l),o){case r:c=(i-s)/f+(i<s?6:0);break;case i:c=(s-r)/f+2;break;case s:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=ar.workingColorSpace){return ar.workingToColorSpace($a.copy(this),n),e.r=$a.r,e.g=$a.g,e.b=$a.b,e}getStyle(e=so){ar.workingToColorSpace($a.copy(this),e);const n=$a.r,r=$a.g,i=$a.b;return e!==so?`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(Md),this.setHSL(Md.h+e,Md.s+n,Md.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(Md),e.getHSL(H_);const r=oT(Md.h,H_.h,n),i=oT(Md.s,H_.s,n),s=oT(Md.l,H_.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 $a=new Rn;Rn.NAMES=sK;let Vme=0,vx=class extends Em{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Vme++}),this.uuid=Uy(),this.name="",this.type="Material",this.blending=Eg,this.side=_h,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=_3,this.blendDst=w3,this.blendEquation=Nf,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Rn(0,0,0),this.blendAlpha=0,this.depthFunc=Hg,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Wz,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=gp,this.stencilZFail=gp,this.stencilZPass=gp,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){mn(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){mn(`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!==Eg&&(r.blending=this.blending),this.side!==_h&&(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!==_3&&(r.blendSrc=this.blendSrc),this.blendDst!==w3&&(r.blendDst=this.blendDst),this.blendEquation!==Nf&&(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!==Hg&&(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!==Wz&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==gp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==gp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==gp&&(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 o=[];for(const l in s){const c=s[l];delete c.metadata,o.push(c)}return o}if(n){const s=i(e.textures),o=i(e.images);s.length>0&&(r.textures=s),o.length>0&&(r.images=o)}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++}},QD=class extends vx{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Rn(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 wh,this.combine=BD,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 Ti=new lt,V_=new An;let Gme=0,bs=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:Gme++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=Kz,this.updateRanges=[],this.gpuType=bu,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++)V_.fromBufferAttribute(this,n),V_.applyMatrix3(e),this.setXY(n,V_.x,V_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Ti.fromBufferAttribute(this,n),Ti.applyMatrix3(e),this.setXYZ(n,Ti.x,Ti.y,Ti.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Ti.fromBufferAttribute(this,n),Ti.applyMatrix4(e),this.setXYZ(n,Ti.x,Ti.y,Ti.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Ti.fromBufferAttribute(this,n),Ti.applyNormalMatrix(e),this.setXYZ(n,Ti.x,Ti.y,Ti.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Ti.fromBufferAttribute(this,n),Ti.transformDirection(e),this.setXYZ(n,Ti.x,Ti.y,Ti.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=Pb(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Ps(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Pb(n,this.array)),n}setX(e,n){return this.normalized&&(n=Ps(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Pb(n,this.array)),n}setY(e,n){return this.normalized&&(n=Ps(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=Pb(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Ps(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=Pb(n,this.array)),n}setW(e,n){return this.normalized&&(n=Ps(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Ps(n,this.array),r=Ps(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=Ps(n,this.array),r=Ps(r,this.array),i=Ps(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=Ps(n,this.array),r=Ps(r,this.array),i=Ps(i,this.array),s=Ps(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!==Kz&&(e.usage=this.usage),e}},oK=class extends bs{constructor(e,n,r){super(new Uint16Array(e),n,r)}},lK=class extends bs{constructor(e,n,r){super(new Uint32Array(e),n,r)}},po=class extends bs{constructor(e,n,r){super(new Float32Array(e),n,r)}},qme=0;const Do=new Fi,ET=new vo,Ep=new lt,ro=new oh,Ib=new oh,la=new lt;let al=class cK extends Em{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:qme++}),this.uuid=Uy(),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(ZW(e)?lK:oK)(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 Pn().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 Do.makeRotationFromQuaternion(e),this.applyMatrix4(Do),this}rotateX(e){return Do.makeRotationX(e),this.applyMatrix4(Do),this}rotateY(e){return Do.makeRotationY(e),this.applyMatrix4(Do),this}rotateZ(e){return Do.makeRotationZ(e),this.applyMatrix4(Do),this}translate(e,n,r){return Do.makeTranslation(e,n,r),this.applyMatrix4(Do),this}scale(e,n,r){return Do.makeScale(e,n,r),this.applyMatrix4(Do),this}lookAt(e){return ET.lookAt(e),ET.updateMatrix(),this.applyMatrix4(ET.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ep).negate(),this.translate(Ep.x,Ep.y,Ep.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 o=e[i];r.push(o.x,o.y,o.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&&mn("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 oh);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){_i("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new lt(-1/0,-1/0,-1/0),new lt(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];ro.setFromBufferAttribute(s),this.morphTargetsRelative?(la.addVectors(this.boundingBox.min,ro.min),this.boundingBox.expandByPoint(la),la.addVectors(this.boundingBox.max,ro.max),this.boundingBox.expandByPoint(la)):(this.boundingBox.expandByPoint(ro.min),this.boundingBox.expandByPoint(ro.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&_i('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 wN);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){_i("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new lt,1/0);return}if(e){const r=this.boundingSphere.center;if(ro.setFromBufferAttribute(e),n)for(let s=0,o=n.length;s<o;s++){const l=n[s];Ib.setFromBufferAttribute(l),this.morphTargetsRelative?(la.addVectors(ro.min,Ib.min),ro.expandByPoint(la),la.addVectors(ro.max,Ib.max),ro.expandByPoint(la)):(ro.expandByPoint(Ib.min),ro.expandByPoint(Ib.max))}ro.getCenter(r);let i=0;for(let s=0,o=e.count;s<o;s++)la.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(la));if(n)for(let s=0,o=n.length;s<o;s++){const l=n[s],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)la.fromBufferAttribute(l,u),c&&(Ep.fromBufferAttribute(e,u),la.add(Ep)),i=Math.max(i,r.distanceToSquared(la))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&_i('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){_i("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 bs(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),l=[],c=[];for(let D=0;D<r.count;D++)l[D]=new lt,c[D]=new lt;const u=new lt,d=new lt,f=new lt,m=new An,p=new An,x=new An,b=new lt,y=new lt;function v(D,A,R){u.fromBufferAttribute(r,D),d.fromBufferAttribute(r,A),f.fromBufferAttribute(r,R),m.fromBufferAttribute(s,D),p.fromBufferAttribute(s,A),x.fromBufferAttribute(s,R),d.sub(u),f.sub(u),p.sub(m),x.sub(m);const F=1/(p.x*x.y-x.x*p.y);isFinite(F)&&(b.copy(d).multiplyScalar(x.y).addScaledVector(f,-p.y).multiplyScalar(F),y.copy(f).multiplyScalar(p.x).addScaledVector(d,-x.x).multiplyScalar(F),l[D].add(b),l[A].add(b),l[R].add(b),c[D].add(y),c[A].add(y),c[R].add(y))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let D=0,A=S.length;D<A;++D){const R=S[D],F=R.start,O=R.count;for(let H=F,j=F+O;H<j;H+=3)v(e.getX(H+0),e.getX(H+1),e.getX(H+2))}const N=new lt,C=new lt,T=new lt,k=new lt;function E(D){T.fromBufferAttribute(i,D),k.copy(T);const A=l[D];N.copy(A),N.sub(T.multiplyScalar(T.dot(A))).normalize(),C.crossVectors(k,A);const F=C.dot(c[D])<0?-1:1;o.setXYZW(D,N.x,N.y,N.z,F)}for(let D=0,A=S.length;D<A;++D){const R=S[D],F=R.start,O=R.count;for(let H=F,j=F+O;H<j;H+=3)E(e.getX(H+0)),E(e.getX(H+1)),E(e.getX(H+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 bs(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let m=0,p=r.count;m<p;m++)r.setXYZ(m,0,0,0);const i=new lt,s=new lt,o=new lt,l=new lt,c=new lt,u=new lt,d=new lt,f=new lt;if(e)for(let m=0,p=e.count;m<p;m+=3){const x=e.getX(m+0),b=e.getX(m+1),y=e.getX(m+2);i.fromBufferAttribute(n,x),s.fromBufferAttribute(n,b),o.fromBufferAttribute(n,y),d.subVectors(o,s),f.subVectors(i,s),d.cross(f),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,b),u.fromBufferAttribute(r,y),l.add(d),c.add(d),u.add(d),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(b,c.x,c.y,c.z),r.setXYZ(y,u.x,u.y,u.z)}else for(let m=0,p=n.count;m<p;m+=3)i.fromBufferAttribute(n,m+0),s.fromBufferAttribute(n,m+1),o.fromBufferAttribute(n,m+2),d.subVectors(o,s),f.subVectors(i,s),d.cross(f),r.setXYZ(m+0,d.x,d.y,d.z),r.setXYZ(m+1,d.x,d.y,d.z),r.setXYZ(m+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++)la.fromBufferAttribute(e,n),la.normalize(),e.setXYZ(n,la.x,la.y,la.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,m=new u.constructor(c.length*d);let p=0,x=0;for(let b=0,y=c.length;b<y;b++){l.isInterleavedBufferAttribute?p=c[b]*l.data.stride+l.offset:p=c[b]*d;for(let v=0;v<d;v++)m[x++]=u[p++]}return new bs(m,d,f)}if(this.index===null)return mn("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new cK,r=this.index.array,i=this.attributes;for(const l in i){const c=i[l],u=e(c,r);n.setAttribute(l,u)}const s=this.morphAttributes;for(const l in s){const c=[],u=s[l];for(let d=0,f=u.length;d<f;d++){const m=u[d],p=e(m,r);c.push(p)}n.morphAttributes[l]=c}n.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let l=0,c=o.length;l<c;l++){const u=o[l];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let s=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,m=u.length;f<m;f++){const p=u[f];d.push(p.toJSON(e.data))}d.length>0&&(i[c]=d,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere=l.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 m=0,p=f.length;m<p;m++)d.push(f[m].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let u=0,d=o.length;u<d;u++){const f=o[u];this.addGroup(f.start,f.count,f.materialIndex)}const l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};const cB=new Fi,cf=new YD,G_=new wN,uB=new lt,q_=new lt,W_=new lt,K_=new lt,CT=new lt,X_=new lt,dB=new lt,Y_=new lt;let sl=class extends vo{constructor(e=new al,n=new QD){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,o=i.length;s<o;s++){const l=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=s}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,o=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(s&&l){X_.set(0,0,0);for(let c=0,u=s.length;c<u;c++){const d=l[c],f=s[c];d!==0&&(CT.fromBufferAttribute(f,e),o?X_.addScaledVector(CT,d):X_.addScaledVector(CT.sub(n),d))}n.add(X_)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),G_.copy(r.boundingSphere),G_.applyMatrix4(s),cf.copy(e.ray).recast(e.near),!(G_.containsPoint(cf.origin)===!1&&(cf.intersectSphere(G_,uB)===null||cf.origin.distanceToSquared(uB)>(e.far-e.near)**2))&&(cB.copy(s).invert(),cf.copy(e.ray).applyMatrix4(cB),!(r.boundingBox!==null&&cf.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,cf)))}_computeIntersections(e,n,r){let i;const s=this.geometry,o=this.material,l=s.index,c=s.attributes.position,u=s.attributes.uv,d=s.attributes.uv1,f=s.attributes.normal,m=s.groups,p=s.drawRange;if(l!==null)if(Array.isArray(o))for(let x=0,b=m.length;x<b;x++){const y=m[x],v=o[y.materialIndex],S=Math.max(y.start,p.start),N=Math.min(l.count,Math.min(y.start+y.count,p.start+p.count));for(let C=S,T=N;C<T;C+=3){const k=l.getX(C),E=l.getX(C+1),D=l.getX(C+2);i=Q_(this,v,e,r,u,d,f,k,E,D),i&&(i.faceIndex=Math.floor(C/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),b=Math.min(l.count,p.start+p.count);for(let y=x,v=b;y<v;y+=3){const S=l.getX(y),N=l.getX(y+1),C=l.getX(y+2);i=Q_(this,o,e,r,u,d,f,S,N,C),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,b=m.length;x<b;x++){const y=m[x],v=o[y.materialIndex],S=Math.max(y.start,p.start),N=Math.min(c.count,Math.min(y.start+y.count,p.start+p.count));for(let C=S,T=N;C<T;C+=3){const k=C,E=C+1,D=C+2;i=Q_(this,v,e,r,u,d,f,k,E,D),i&&(i.faceIndex=Math.floor(C/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),b=Math.min(c.count,p.start+p.count);for(let y=x,v=b;y<v;y+=3){const S=y,N=y+1,C=y+2;i=Q_(this,o,e,r,u,d,f,S,N,C),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}}};function Wme(t,e,n,r,i,s,o,l){let c;if(e.side===zs?c=r.intersectTriangle(o,s,i,!0,l):c=r.intersectTriangle(i,s,o,e.side===_h,l),c===null)return null;Y_.copy(l),Y_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(Y_);return u<n.near||u>n.far?null:{distance:u,point:Y_.clone(),object:t}}function Q_(t,e,n,r,i,s,o,l,c,u){t.getVertexPosition(l,q_),t.getVertexPosition(c,W_),t.getVertexPosition(u,K_);const d=Wme(t,e,n,r,q_,W_,K_,dB);if(d){const f=new lt;Lb.getBarycoord(dB,q_,W_,K_,f),i&&(d.uv=Lb.getInterpolatedAttribute(i,l,c,u,f,new An)),s&&(d.uv1=Lb.getInterpolatedAttribute(s,l,c,u,f,new An)),o&&(d.normal=Lb.getInterpolatedAttribute(o,l,c,u,f,new lt),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const m={a:l,b:c,c:u,normal:new lt,materialIndex:0};Lb.getNormal(q_,W_,K_,m.normal),d.face=m,d.barycoord=f}return d}let ZD=class uK extends al{constructor(e=1,n=1,r=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:s,depthSegments:o};const l=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const c=[],u=[],d=[],f=[];let m=0,p=0;x("z","y","x",-1,-1,r,n,e,o,s,0),x("z","y","x",1,-1,r,n,-e,o,s,1),x("x","z","y",1,1,e,r,n,i,o,2),x("x","z","y",1,-1,e,r,-n,i,o,3),x("x","y","z",1,-1,e,n,r,i,s,4),x("x","y","z",-1,-1,e,n,-r,i,s,5),this.setIndex(c),this.setAttribute("position",new po(u,3)),this.setAttribute("normal",new po(d,3)),this.setAttribute("uv",new po(f,2));function x(b,y,v,S,N,C,T,k,E,D,A){const R=C/E,F=T/D,O=C/2,H=T/2,j=k/2,G=E+1,$=D+1;let q=0,Y=0;const Z=new lt;for(let oe=0;oe<$;oe++){const B=oe*F-H;for(let W=0;W<G;W++){const se=W*R-O;Z[b]=se*S,Z[y]=B*N,Z[v]=j,u.push(Z.x,Z.y,Z.z),Z[b]=0,Z[y]=0,Z[v]=k>0?1:-1,d.push(Z.x,Z.y,Z.z),f.push(W/E),f.push(1-oe/D),q+=1}}for(let oe=0;oe<D;oe++)for(let B=0;B<E;B++){const W=m+B+G*oe,se=m+B+G*(oe+1),ne=m+(B+1)+G*(oe+1),ce=m+(B+1)+G*oe;c.push(W,se,ce),c.push(se,ne,ce),Y+=6}l.addGroup(p,Y,A),p+=Y,m+=q}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new uK(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Wg(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?(mn("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 us(t){const e={};for(let n=0;n<t.length;n++){const r=Wg(t[n]);for(const i in r)e[i]=r[i]}return e}function Kme(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function dK(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:ar.workingColorSpace}const Xme={clone:Wg,merge:us};var Yme=`void main() {
  11. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  12. }`,Qme=`void main() {
  13. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  14. }`;let Ou=class extends vx{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Yme,this.fragmentShader=Qme,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=Wg(e.uniforms),this.uniformsGroups=Kme(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 o=this.uniforms[i].value;o&&o.isTexture?n.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?n.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?n.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?n.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?n.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?n.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?n.uniforms[i]={type:"m4",value:o.toArray()}:n.uniforms[i]={value:o}}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}},hK=class extends vo{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Fi,this.projectionMatrix=new Fi,this.projectionMatrixInverse=new Fi,this.coordinateSystem=lc,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 Ed=new lt,hB=new An,fB=new An;let qo=class extends hK{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=lP*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(w1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return lP*2*Math.atan(Math.tan(w1*.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){Ed.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Ed.x,Ed.y).multiplyScalar(-e/Ed.z),Ed.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(Ed.x,Ed.y).multiplyScalar(-e/Ed.z)}getViewSize(e,n){return this.getViewBounds(e,hB,fB),n.subVectors(fB,hB)}setViewOffset(e,n,r,i,s,o){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=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(w1*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,s=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,u=o.fullHeight;s+=o.offsetX*i/c,n-=o.offsetY*r/u,i*=o.width/c,r*=o.height/u}const l=this.filmOffset;l!==0&&(s+=e*l/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 Cp=-90,Tp=1;let Zme=class extends vo{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new qo(Cp,Tp,e,n);i.layers=this.layers,this.add(i);const s=new qo(Cp,Tp,e,n);s.layers=this.layers,this.add(s);const o=new qo(Cp,Tp,e,n);o.layers=this.layers,this.add(o);const l=new qo(Cp,Tp,e,n);l.layers=this.layers,this.add(l);const c=new qo(Cp,Tp,e,n);c.layers=this.layers,this.add(c);const u=new qo(Cp,Tp,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,s,o,l,c]=n;for(const u of n)this.remove(u);if(e===lc)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),o.up.set(0,0,1),o.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Q1)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),o.up.set(0,0,-1),o.lookAt(0,-1,0),l.up.set(0,-1,0),l.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,o,l,c,u,d]=this.children,f=e.getRenderTarget(),m=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const b=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,s),e.setRenderTarget(r,1,i),e.render(n,o),e.setRenderTarget(r,2,i),e.render(n,l),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=b,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,m,p),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}},fK=class extends zl{constructor(e=[],n=Vg,r,i,s,o,l,c,u,d){super(e,n,r,i,s,o,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Jme=class extends um{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 fK(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:`
  15. varying vec3 vWorldDirection;
  16. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  17. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  18. }
  19. void main() {
  20. vWorldDirection = transformDirection( position, modelMatrix );
  21. #include <begin_vertex>
  22. #include <project_vertex>
  23. }
  24. `,fragmentShader:`
  25. uniform sampler2D tEquirect;
  26. varying vec3 vWorldDirection;
  27. #include <common>
  28. void main() {
  29. vec3 direction = normalize( vWorldDirection );
  30. vec2 sampleUV = equirectUv( direction );
  31. gl_FragColor = texture2D( tEquirect, sampleUV );
  32. }
  33. `},i=new ZD(5,5,5),s=new Ou({name:"CubemapFromEquirect",uniforms:Wg(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:zs,blending:Mu});s.uniforms.tEquirect.value=n;const o=new sl(i,s),l=n.minFilter;return n.minFilter===Pf&&(n.minFilter=Zo),new Zme(1,10,this).update(e,o),n.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,n=!0,r=!0,i=!0){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(n,r,i);e.setRenderTarget(s)}},pg=class extends vo{constructor(){super(),this.isGroup=!0,this.type="Group"}};const epe={type:"move"};let TT=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new pg,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 pg,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new lt,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new lt),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new pg,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new lt,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new lt),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,o=null;const l=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){o=!0;for(const b of e.hand.values()){const y=n.getJointPose(b,r),v=this._getHandJoint(u,b);y!==null&&(v.matrix.fromArray(y.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=y.radius),v.visible=y!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],m=d.position.distanceTo(f.position),p=.02,x=.005;u.inputState.pinching&&m>p+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&m<=p-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=n.getPose(e.gripSpace,r),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(epe)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=s!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new pg;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},tpe=class extends vo{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 wh,this.environmentIntensity=1,this.environmentRotation=new wh,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}},npe=class extends zl{constructor(e=null,n=1,r=1,i,s,o,l,c,u=mo,d=mo,f,m){super(null,o,l,c,u,d,i,s,f,m),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const AT=new lt,rpe=new lt,ipe=new Pn;let Fd=class{constructor(e=new lt(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=AT.subVectors(r,n).cross(rpe.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(AT),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||ipe.getNormalMatrix(e),i=this.coplanarPoint(AT).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 uf=new wN,ape=new An(.5,.5),Z_=new lt;let JD=class{constructor(e=new Fd,n=new Fd,r=new Fd,i=new Fd,s=new Fd,o=new Fd){this.planes=[e,n,r,i,s,o]}set(e,n,r,i,s,o){const l=this.planes;return l[0].copy(e),l[1].copy(n),l[2].copy(r),l[3].copy(i),l[4].copy(s),l[5].copy(o),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=lc,r=!1){const i=this.planes,s=e.elements,o=s[0],l=s[1],c=s[2],u=s[3],d=s[4],f=s[5],m=s[6],p=s[7],x=s[8],b=s[9],y=s[10],v=s[11],S=s[12],N=s[13],C=s[14],T=s[15];if(i[0].setComponents(u-o,p-d,v-x,T-S).normalize(),i[1].setComponents(u+o,p+d,v+x,T+S).normalize(),i[2].setComponents(u+l,p+f,v+b,T+N).normalize(),i[3].setComponents(u-l,p-f,v-b,T-N).normalize(),r)i[4].setComponents(c,m,y,C).normalize(),i[5].setComponents(u-c,p-m,v-y,T-C).normalize();else if(i[4].setComponents(u-c,p-m,v-y,T-C).normalize(),n===lc)i[5].setComponents(u+c,p+m,v+y,T+C).normalize();else if(n===Q1)i[5].setComponents(c,m,y,C).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(),uf.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),uf.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(uf)}intersectsSprite(e){uf.center.set(0,0,0);const n=ape.distanceTo(e.center);return uf.radius=.7071067811865476+n,uf.applyMatrix4(e.matrixWorld),this.intersectsSphere(uf)}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(Z_.x=i.normal.x>0?e.max.x:e.min.x,Z_.y=i.normal.y>0?e.max.y:e.min.y,Z_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Z_)<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)}},mK=class extends vx{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Rn(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 J1=new lt,eS=new lt,mB=new Fi,Fb=new YD,J_=new wN,kT=new lt,pB=new lt;let spe=class extends vo{constructor(e=new al,n=new mK){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++)J1.fromBufferAttribute(n,i-1),eS.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=J1.distanceTo(eS);e.setAttribute("lineDistance",new po(r,1))}else mn("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,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),J_.copy(r.boundingSphere),J_.applyMatrix4(i),J_.radius+=s,e.ray.intersectsSphere(J_)===!1)return;mB.copy(i).invert(),Fb.copy(e.ray).applyMatrix4(mB);const l=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=this.isLineSegments?2:1,d=r.index,m=r.attributes.position;if(d!==null){const p=Math.max(0,o.start),x=Math.min(d.count,o.start+o.count);for(let b=p,y=x-1;b<y;b+=u){const v=d.getX(b),S=d.getX(b+1),N=ew(this,e,Fb,c,v,S,b);N&&n.push(N)}if(this.isLineLoop){const b=d.getX(x-1),y=d.getX(p),v=ew(this,e,Fb,c,b,y,x-1);v&&n.push(v)}}else{const p=Math.max(0,o.start),x=Math.min(m.count,o.start+o.count);for(let b=p,y=x-1;b<y;b+=u){const v=ew(this,e,Fb,c,b,b+1,b);v&&n.push(v)}if(this.isLineLoop){const b=ew(this,e,Fb,c,x-1,p,x-1);b&&n.push(b)}}}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,o=i.length;s<o;s++){const l=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=s}}}}};function ew(t,e,n,r,i,s,o){const l=t.geometry.attributes.position;if(J1.fromBufferAttribute(l,i),eS.fromBufferAttribute(l,s),n.distanceSqToSegment(J1,eS,kT,pB)>r)return;kT.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(kT);if(!(u<e.near||u>e.far))return{distance:u,point:pB.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const gB=new lt,xB=new lt;let ope=class extends spe{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)gB.fromBufferAttribute(n,i),xB.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+gB.distanceTo(xB);e.setAttribute("lineDistance",new po(r,1))}else mn("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},pK=class extends zl{constructor(e,n,r=lm,i,s,o,l=mo,c=mo,u,d=Q0,f=1){if(d!==Q0&&d!==Z0)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const m={width:e,height:n,depth:f};super(m,i,s,o,l,c,d,r,u),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new XD(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 gK extends zl{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let e4=class xK extends al{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,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,m=n/c,p=[],x=[],b=[],y=[];for(let v=0;v<d;v++){const S=v*m-o;for(let N=0;N<u;N++){const C=N*f-s;x.push(C,-S,0),b.push(0,0,1),y.push(N/l),y.push(1-v/c)}}for(let v=0;v<c;v++)for(let S=0;S<l;S++){const N=S+u*v,C=S+u*(v+1),T=S+1+u*(v+1),k=S+1+u*v;p.push(N,C,k),p.push(C,T,k)}this.setIndex(p),this.setAttribute("position",new po(x,3)),this.setAttribute("normal",new po(b,3)),this.setAttribute("uv",new po(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new xK(e.width,e.height,e.widthSegments,e.heightSegments)}};class bK extends vx{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Rn(16777215),this.specular=new Rn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Rn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=YW,this.normalScale=new An(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new wh,this.combine=BD,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 lpe=class extends vx{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=xme,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}},cpe=class extends vx{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 bB={enabled:!1,files:{},add:function(t,e){this.enabled!==!1&&(this.files[t]=e)},get:function(t){if(this.enabled!==!1)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};class upe{constructor(e,n,r){const i=this;let s=!1,o=0,l=0,c;const u=[];this.onStart=void 0,this.onLoad=e,this.onProgress=n,this.onError=r,this._abortController=null,this.itemStart=function(d){l++,s===!1&&i.onStart!==void 0&&i.onStart(d,o,l),s=!0},this.itemEnd=function(d){o++,i.onProgress!==void 0&&i.onProgress(d,o,l),o===l&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(d){i.onError!==void 0&&i.onError(d)},this.resolveURL=function(d){return c?c(d):d},this.setURLModifier=function(d){return c=d,this},this.addHandler=function(d,f){return u.push(d,f),this},this.removeHandler=function(d){const f=u.indexOf(d);return f!==-1&&u.splice(f,2),this},this.getHandler=function(d){for(let f=0,m=u.length;f<m;f+=2){const p=u[f],x=u[f+1];if(p.global&&(p.lastIndex=0),p.test(d))return x}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const dpe=new upe;class t4{constructor(e){this.manager=e!==void 0?e:dpe,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,n){const r=this;return new Promise(function(i,s){r.load(e,i,n,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}t4.DEFAULT_MATERIAL_NAME="__DEFAULT";const Yc={};class hpe extends Error{constructor(e,n){super(e),this.response=n}}class fpe extends t4{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,n,r,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=bB.get(`file:${e}`);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{n&&n(s),this.manager.itemEnd(e)},0),s;if(Yc[e]!==void 0){Yc[e].push({onLoad:n,onProgress:r,onError:i});return}Yc[e]=[],Yc[e].push({onLoad:n,onProgress:r,onError:i});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),l=this.mimeType,c=this.responseType;fetch(o).then(u=>{if(u.status===200||u.status===0){if(u.status===0&&mn("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||u.body===void 0||u.body.getReader===void 0)return u;const d=Yc[e],f=u.body.getReader(),m=u.headers.get("X-File-Size")||u.headers.get("Content-Length"),p=m?parseInt(m):0,x=p!==0;let b=0;const y=new ReadableStream({start(v){S();function S(){f.read().then(({done:N,value:C})=>{if(N)v.close();else{b+=C.byteLength;const T=new ProgressEvent("progress",{lengthComputable:x,loaded:b,total:p});for(let k=0,E=d.length;k<E;k++){const D=d[k];D.onProgress&&D.onProgress(T)}v.enqueue(C),S()}},N=>{v.error(N)})}}});return new Response(y)}else throw new hpe(`fetch for "${u.url}" responded with ${u.status}: ${u.statusText}`,u)}).then(u=>{switch(c){case"arraybuffer":return u.arrayBuffer();case"blob":return u.blob();case"document":return u.text().then(d=>new DOMParser().parseFromString(d,l));case"json":return u.json();default:if(l==="")return u.text();{const f=/charset="?([^;"\s]*)"?/i.exec(l),m=f&&f[1]?f[1].toLowerCase():void 0,p=new TextDecoder(m);return u.arrayBuffer().then(x=>p.decode(x))}}}).then(u=>{bB.add(`file:${e}`,u);const d=Yc[e];delete Yc[e];for(let f=0,m=d.length;f<m;f++){const p=d[f];p.onLoad&&p.onLoad(u)}}).catch(u=>{const d=Yc[e];if(d===void 0)throw this.manager.itemError(e),u;delete Yc[e];for(let f=0,m=d.length;f<m;f++){const p=d[f];p.onError&&p.onError(u)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let yK=class extends vo{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Rn(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 jT=new Fi,yB=new lt,vB=new lt;let mpe=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new An(512,512),this.mapType=gc,this.map=null,this.mapPass=null,this.matrix=new Fi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new JD,this._frameExtents=new An(1,1),this._viewportCount=1,this._viewports=[new Di(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;yB.setFromMatrixPosition(e.matrixWorld),n.position.copy(yB),vB.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(vB),n.updateMatrixWorld(),jT.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(jT,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(jT)}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}},vK=class extends hK{constructor(e=-1,n=1,r=1,i=-1,s=.1,o=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=o,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,o){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=o,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,o=r+e,l=i+n,c=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=u*this.view.offsetX,o=s+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(s,o,l,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}};class ppe extends mpe{constructor(){super(new vK(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class _B extends yK{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(vo.DEFAULT_UP),this.updateMatrix(),this.target=new vo,this.shadow=new ppe}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let gpe=class extends yK{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},xpe=class extends qo{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},wB=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=Un(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(Un(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class bpe extends ope{constructor(e=10,n=10,r=4473924,i=8947848){r=new Rn(r),i=new Rn(i);const s=n/2,o=e/n,l=e/2,c=[],u=[];for(let m=0,p=0,x=-l;m<=n;m++,x+=o){c.push(-l,0,x,l,0,x),c.push(x,0,-l,x,0,l);const b=m===s?r:i;b.toArray(u,p),p+=3,b.toArray(u,p),p+=3,b.toArray(u,p),p+=3,b.toArray(u,p),p+=3}const d=new al;d.setAttribute("position",new po(c,3)),d.setAttribute("color",new po(u,3));const f=new mK({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class ype extends Em{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){mn("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function SB(t,e,n,r){const i=vpe(r);switch(n){case WW:return t*e;case XW:return t*e/i.components*i.byteLength;case GD:return t*e/i.components*i.byteLength;case qD:return t*e*2/i.components*i.byteLength;case WD:return t*e*2/i.components*i.byteLength;case KW:return t*e*3/i.components*i.byteLength;case Pl:return t*e*4/i.components*i.byteLength;case KD:return t*e*4/i.components*i.byteLength;case b1:case y1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case v1:case _1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case O3:case I3:return Math.max(t,16)*Math.max(e,8)/4;case D3:case L3:return Math.max(t,8)*Math.max(e,8)/2;case F3:case U3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case z3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case B3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case $3:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case H3:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case V3:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case G3:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case q3:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case W3:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case K3:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case X3:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case Y3:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case Q3:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case Z3:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case J3:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case eP:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case tP:case nP:case rP:return Math.ceil(t/4)*Math.ceil(e/4)*16;case iP:case aP:return Math.ceil(t/4)*Math.ceil(e/4)*8;case sP:case oP:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function vpe(t){switch(t){case gc:case HW:return{byteLength:1,components:1};case X0:case VW:case yx:return{byteLength:2,components:1};case HD:case VD:return{byteLength:2,components:4};case lm:case $D:case bu:return{byteLength:4,components:1};case GW:case qW:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:zD}}));typeof window<"u"&&(window.__THREE__?mn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=zD);function _K(){let t=null,e=!1,n=null,r=null;function i(s,o){n(s,o),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 _pe(t){const e=new WeakMap;function n(l,c){const u=l.array,d=l.usage,f=u.byteLength,m=t.createBuffer();t.bindBuffer(c,m),t.bufferData(c,u,d),l.onUploadCallback();let p;if(u instanceof Float32Array)p=t.FLOAT;else if(typeof Float16Array<"u"&&u instanceof Float16Array)p=t.HALF_FLOAT;else if(u instanceof Uint16Array)l.isFloat16BufferAttribute?p=t.HALF_FLOAT:p=t.UNSIGNED_SHORT;else if(u instanceof Int16Array)p=t.SHORT;else if(u instanceof Uint32Array)p=t.UNSIGNED_INT;else if(u instanceof Int32Array)p=t.INT;else if(u instanceof Int8Array)p=t.BYTE;else if(u instanceof Uint8Array)p=t.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)p=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:m,type:p,bytesPerElement:u.BYTES_PER_ELEMENT,version:l.version,size:f}}function r(l,c,u){const d=c.array,f=c.updateRanges;if(t.bindBuffer(u,l),f.length===0)t.bufferSubData(u,0,d);else{f.sort((p,x)=>p.start-x.start);let m=0;for(let p=1;p<f.length;p++){const x=f[m],b=f[p];b.start<=x.start+x.count+1?x.count=Math.max(x.count,b.start+b.count-x.start):(++m,f[m]=b)}f.length=m+1;for(let p=0,x=f.length;p<x;p++){const b=f[p];t.bufferSubData(u,b.start*d.BYTES_PER_ELEMENT,d,b.start,b.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(l){return l.isInterleavedBufferAttribute&&(l=l.data),e.get(l)}function s(l){l.isInterleavedBufferAttribute&&(l=l.data);const c=e.get(l);c&&(t.deleteBuffer(c.buffer),e.delete(l))}function o(l,c){if(l.isInterleavedBufferAttribute&&(l=l.data),l.isGLBufferAttribute){const d=e.get(l);(!d||d.version<l.version)&&e.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}const u=e.get(l);if(u===void 0)e.set(l,n(l,c));else if(u.version<l.version){if(u.size!==l.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,l,c),u.version=l.version}}return{get:i,remove:s,update:o}}var wpe=`#ifdef USE_ALPHAHASH
  34. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  35. #endif`,Spe=`#ifdef USE_ALPHAHASH
  36. const float ALPHA_HASH_SCALE = 0.05;
  37. float hash2D( vec2 value ) {
  38. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  39. }
  40. float hash3D( vec3 value ) {
  41. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  42. }
  43. float getAlphaHashThreshold( vec3 position ) {
  44. float maxDeriv = max(
  45. length( dFdx( position.xyz ) ),
  46. length( dFdy( position.xyz ) )
  47. );
  48. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  49. vec2 pixScales = vec2(
  50. exp2( floor( log2( pixScale ) ) ),
  51. exp2( ceil( log2( pixScale ) ) )
  52. );
  53. vec2 alpha = vec2(
  54. hash3D( floor( pixScales.x * position.xyz ) ),
  55. hash3D( floor( pixScales.y * position.xyz ) )
  56. );
  57. float lerpFactor = fract( log2( pixScale ) );
  58. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  59. float a = min( lerpFactor, 1.0 - lerpFactor );
  60. vec3 cases = vec3(
  61. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  62. ( x - 0.5 * a ) / ( 1.0 - a ),
  63. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  64. );
  65. float threshold = ( x < ( 1.0 - a ) )
  66. ? ( ( x < a ) ? cases.x : cases.y )
  67. : cases.z;
  68. return clamp( threshold , 1.0e-6, 1.0 );
  69. }
  70. #endif`,Npe=`#ifdef USE_ALPHAMAP
  71. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  72. #endif`,Mpe=`#ifdef USE_ALPHAMAP
  73. uniform sampler2D alphaMap;
  74. #endif`,Epe=`#ifdef USE_ALPHATEST
  75. #ifdef ALPHA_TO_COVERAGE
  76. diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
  77. if ( diffuseColor.a == 0.0 ) discard;
  78. #else
  79. if ( diffuseColor.a < alphaTest ) discard;
  80. #endif
  81. #endif`,Cpe=`#ifdef USE_ALPHATEST
  82. uniform float alphaTest;
  83. #endif`,Tpe=`#ifdef USE_AOMAP
  84. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  85. reflectedLight.indirectDiffuse *= ambientOcclusion;
  86. #if defined( USE_CLEARCOAT )
  87. clearcoatSpecularIndirect *= ambientOcclusion;
  88. #endif
  89. #if defined( USE_SHEEN )
  90. sheenSpecularIndirect *= ambientOcclusion;
  91. #endif
  92. #if defined( USE_ENVMAP ) && defined( STANDARD )
  93. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  94. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  95. #endif
  96. #endif`,Ape=`#ifdef USE_AOMAP
  97. uniform sampler2D aoMap;
  98. uniform float aoMapIntensity;
  99. #endif`,kpe=`#ifdef USE_BATCHING
  100. #if ! defined( GL_ANGLE_multi_draw )
  101. #define gl_DrawID _gl_DrawID
  102. uniform int _gl_DrawID;
  103. #endif
  104. uniform highp sampler2D batchingTexture;
  105. uniform highp usampler2D batchingIdTexture;
  106. mat4 getBatchingMatrix( const in float i ) {
  107. int size = textureSize( batchingTexture, 0 ).x;
  108. int j = int( i ) * 4;
  109. int x = j % size;
  110. int y = j / size;
  111. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  112. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  113. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  114. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  115. return mat4( v1, v2, v3, v4 );
  116. }
  117. float getIndirectIndex( const in int i ) {
  118. int size = textureSize( batchingIdTexture, 0 ).x;
  119. int x = i % size;
  120. int y = i / size;
  121. return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
  122. }
  123. #endif
  124. #ifdef USE_BATCHING_COLOR
  125. uniform sampler2D batchingColorTexture;
  126. vec3 getBatchingColor( const in float i ) {
  127. int size = textureSize( batchingColorTexture, 0 ).x;
  128. int j = int( i );
  129. int x = j % size;
  130. int y = j / size;
  131. return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
  132. }
  133. #endif`,jpe=`#ifdef USE_BATCHING
  134. mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
  135. #endif`,Ppe=`vec3 transformed = vec3( position );
  136. #ifdef USE_ALPHAHASH
  137. vPosition = vec3( position );
  138. #endif`,Rpe=`vec3 objectNormal = vec3( normal );
  139. #ifdef USE_TANGENT
  140. vec3 objectTangent = vec3( tangent.xyz );
  141. #endif`,Dpe=`float G_BlinnPhong_Implicit( ) {
  142. return 0.25;
  143. }
  144. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  145. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  146. }
  147. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  148. vec3 halfDir = normalize( lightDir + viewDir );
  149. float dotNH = saturate( dot( normal, halfDir ) );
  150. float dotVH = saturate( dot( viewDir, halfDir ) );
  151. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  152. float G = G_BlinnPhong_Implicit( );
  153. float D = D_BlinnPhong( shininess, dotNH );
  154. return F * ( G * D );
  155. } // validated`,Ope=`#ifdef USE_IRIDESCENCE
  156. const mat3 XYZ_TO_REC709 = mat3(
  157. 3.2404542, -0.9692660, 0.0556434,
  158. -1.5371385, 1.8760108, -0.2040259,
  159. -0.4985314, 0.0415560, 1.0572252
  160. );
  161. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  162. vec3 sqrtF0 = sqrt( fresnel0 );
  163. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  164. }
  165. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  166. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  167. }
  168. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  169. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  170. }
  171. vec3 evalSensitivity( float OPD, vec3 shift ) {
  172. float phase = 2.0 * PI * OPD * 1.0e-9;
  173. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  174. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  175. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  176. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  177. 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 ) );
  178. xyz /= 1.0685e-7;
  179. vec3 rgb = XYZ_TO_REC709 * xyz;
  180. return rgb;
  181. }
  182. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  183. vec3 I;
  184. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  185. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  186. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  187. if ( cosTheta2Sq < 0.0 ) {
  188. return vec3( 1.0 );
  189. }
  190. float cosTheta2 = sqrt( cosTheta2Sq );
  191. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  192. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  193. float T121 = 1.0 - R12;
  194. float phi12 = 0.0;
  195. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  196. float phi21 = PI - phi12;
  197. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  198. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  199. vec3 phi23 = vec3( 0.0 );
  200. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  201. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  202. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  203. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  204. vec3 phi = vec3( phi21 ) + phi23;
  205. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  206. vec3 r123 = sqrt( R123 );
  207. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  208. vec3 C0 = R12 + Rs;
  209. I = C0;
  210. vec3 Cm = Rs - T121;
  211. for ( int m = 1; m <= 2; ++ m ) {
  212. Cm *= r123;
  213. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  214. I += Cm * Sm;
  215. }
  216. return max( I, vec3( 0.0 ) );
  217. }
  218. #endif`,Lpe=`#ifdef USE_BUMPMAP
  219. uniform sampler2D bumpMap;
  220. uniform float bumpScale;
  221. vec2 dHdxy_fwd() {
  222. vec2 dSTdx = dFdx( vBumpMapUv );
  223. vec2 dSTdy = dFdy( vBumpMapUv );
  224. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  225. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  226. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  227. return vec2( dBx, dBy );
  228. }
  229. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  230. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  231. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  232. vec3 vN = surf_norm;
  233. vec3 R1 = cross( vSigmaY, vN );
  234. vec3 R2 = cross( vN, vSigmaX );
  235. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  236. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  237. return normalize( abs( fDet ) * surf_norm - vGrad );
  238. }
  239. #endif`,Ipe=`#if NUM_CLIPPING_PLANES > 0
  240. vec4 plane;
  241. #ifdef ALPHA_TO_COVERAGE
  242. float distanceToPlane, distanceGradient;
  243. float clipOpacity = 1.0;
  244. #pragma unroll_loop_start
  245. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  246. plane = clippingPlanes[ i ];
  247. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  248. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  249. clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  250. if ( clipOpacity == 0.0 ) discard;
  251. }
  252. #pragma unroll_loop_end
  253. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  254. float unionClipOpacity = 1.0;
  255. #pragma unroll_loop_start
  256. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  257. plane = clippingPlanes[ i ];
  258. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  259. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  260. unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  261. }
  262. #pragma unroll_loop_end
  263. clipOpacity *= 1.0 - unionClipOpacity;
  264. #endif
  265. diffuseColor.a *= clipOpacity;
  266. if ( diffuseColor.a == 0.0 ) discard;
  267. #else
  268. #pragma unroll_loop_start
  269. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  270. plane = clippingPlanes[ i ];
  271. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  272. }
  273. #pragma unroll_loop_end
  274. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  275. bool clipped = true;
  276. #pragma unroll_loop_start
  277. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  278. plane = clippingPlanes[ i ];
  279. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  280. }
  281. #pragma unroll_loop_end
  282. if ( clipped ) discard;
  283. #endif
  284. #endif
  285. #endif`,Fpe=`#if NUM_CLIPPING_PLANES > 0
  286. varying vec3 vClipPosition;
  287. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  288. #endif`,Upe=`#if NUM_CLIPPING_PLANES > 0
  289. varying vec3 vClipPosition;
  290. #endif`,zpe=`#if NUM_CLIPPING_PLANES > 0
  291. vClipPosition = - mvPosition.xyz;
  292. #endif`,Bpe=`#if defined( USE_COLOR_ALPHA )
  293. diffuseColor *= vColor;
  294. #elif defined( USE_COLOR )
  295. diffuseColor.rgb *= vColor;
  296. #endif`,$pe=`#if defined( USE_COLOR_ALPHA )
  297. varying vec4 vColor;
  298. #elif defined( USE_COLOR )
  299. varying vec3 vColor;
  300. #endif`,Hpe=`#if defined( USE_COLOR_ALPHA )
  301. varying vec4 vColor;
  302. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  303. varying vec3 vColor;
  304. #endif`,Vpe=`#if defined( USE_COLOR_ALPHA )
  305. vColor = vec4( 1.0 );
  306. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  307. vColor = vec3( 1.0 );
  308. #endif
  309. #ifdef USE_COLOR
  310. vColor *= color;
  311. #endif
  312. #ifdef USE_INSTANCING_COLOR
  313. vColor.xyz *= instanceColor.xyz;
  314. #endif
  315. #ifdef USE_BATCHING_COLOR
  316. vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
  317. vColor.xyz *= batchingColor.xyz;
  318. #endif`,Gpe=`#define PI 3.141592653589793
  319. #define PI2 6.283185307179586
  320. #define PI_HALF 1.5707963267948966
  321. #define RECIPROCAL_PI 0.3183098861837907
  322. #define RECIPROCAL_PI2 0.15915494309189535
  323. #define EPSILON 1e-6
  324. #ifndef saturate
  325. #define saturate( a ) clamp( a, 0.0, 1.0 )
  326. #endif
  327. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  328. float pow2( const in float x ) { return x*x; }
  329. vec3 pow2( const in vec3 x ) { return x*x; }
  330. float pow3( const in float x ) { return x*x*x; }
  331. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  332. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  333. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  334. highp float rand( const in vec2 uv ) {
  335. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  336. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  337. return fract( sin( sn ) * c );
  338. }
  339. #ifdef HIGH_PRECISION
  340. float precisionSafeLength( vec3 v ) { return length( v ); }
  341. #else
  342. float precisionSafeLength( vec3 v ) {
  343. float maxComponent = max3( abs( v ) );
  344. return length( v / maxComponent ) * maxComponent;
  345. }
  346. #endif
  347. struct IncidentLight {
  348. vec3 color;
  349. vec3 direction;
  350. bool visible;
  351. };
  352. struct ReflectedLight {
  353. vec3 directDiffuse;
  354. vec3 directSpecular;
  355. vec3 indirectDiffuse;
  356. vec3 indirectSpecular;
  357. };
  358. #ifdef USE_ALPHAHASH
  359. varying vec3 vPosition;
  360. #endif
  361. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  362. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  363. }
  364. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  365. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  366. }
  367. bool isPerspectiveMatrix( mat4 m ) {
  368. return m[ 2 ][ 3 ] == - 1.0;
  369. }
  370. vec2 equirectUv( in vec3 dir ) {
  371. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  372. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  373. return vec2( u, v );
  374. }
  375. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  376. return RECIPROCAL_PI * diffuseColor;
  377. }
  378. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  379. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  380. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  381. }
  382. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  383. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  384. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  385. } // validated`,qpe=`#ifdef ENVMAP_TYPE_CUBE_UV
  386. #define cubeUV_minMipLevel 4.0
  387. #define cubeUV_minTileSize 16.0
  388. float getFace( vec3 direction ) {
  389. vec3 absDirection = abs( direction );
  390. float face = - 1.0;
  391. if ( absDirection.x > absDirection.z ) {
  392. if ( absDirection.x > absDirection.y )
  393. face = direction.x > 0.0 ? 0.0 : 3.0;
  394. else
  395. face = direction.y > 0.0 ? 1.0 : 4.0;
  396. } else {
  397. if ( absDirection.z > absDirection.y )
  398. face = direction.z > 0.0 ? 2.0 : 5.0;
  399. else
  400. face = direction.y > 0.0 ? 1.0 : 4.0;
  401. }
  402. return face;
  403. }
  404. vec2 getUV( vec3 direction, float face ) {
  405. vec2 uv;
  406. if ( face == 0.0 ) {
  407. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  408. } else if ( face == 1.0 ) {
  409. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  410. } else if ( face == 2.0 ) {
  411. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  412. } else if ( face == 3.0 ) {
  413. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  414. } else if ( face == 4.0 ) {
  415. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  416. } else {
  417. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  418. }
  419. return 0.5 * ( uv + 1.0 );
  420. }
  421. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  422. float face = getFace( direction );
  423. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  424. mipInt = max( mipInt, cubeUV_minMipLevel );
  425. float faceSize = exp2( mipInt );
  426. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  427. if ( face > 2.0 ) {
  428. uv.y += faceSize;
  429. face -= 3.0;
  430. }
  431. uv.x += face * faceSize;
  432. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  433. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  434. uv.x *= CUBEUV_TEXEL_WIDTH;
  435. uv.y *= CUBEUV_TEXEL_HEIGHT;
  436. #ifdef texture2DGradEXT
  437. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  438. #else
  439. return texture2D( envMap, uv ).rgb;
  440. #endif
  441. }
  442. #define cubeUV_r0 1.0
  443. #define cubeUV_m0 - 2.0
  444. #define cubeUV_r1 0.8
  445. #define cubeUV_m1 - 1.0
  446. #define cubeUV_r4 0.4
  447. #define cubeUV_m4 2.0
  448. #define cubeUV_r5 0.305
  449. #define cubeUV_m5 3.0
  450. #define cubeUV_r6 0.21
  451. #define cubeUV_m6 4.0
  452. float roughnessToMip( float roughness ) {
  453. float mip = 0.0;
  454. if ( roughness >= cubeUV_r1 ) {
  455. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  456. } else if ( roughness >= cubeUV_r4 ) {
  457. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  458. } else if ( roughness >= cubeUV_r5 ) {
  459. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  460. } else if ( roughness >= cubeUV_r6 ) {
  461. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  462. } else {
  463. mip = - 2.0 * log2( 1.16 * roughness ); }
  464. return mip;
  465. }
  466. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  467. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  468. float mipF = fract( mip );
  469. float mipInt = floor( mip );
  470. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  471. if ( mipF == 0.0 ) {
  472. return vec4( color0, 1.0 );
  473. } else {
  474. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  475. return vec4( mix( color0, color1, mipF ), 1.0 );
  476. }
  477. }
  478. #endif`,Wpe=`vec3 transformedNormal = objectNormal;
  479. #ifdef USE_TANGENT
  480. vec3 transformedTangent = objectTangent;
  481. #endif
  482. #ifdef USE_BATCHING
  483. mat3 bm = mat3( batchingMatrix );
  484. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  485. transformedNormal = bm * transformedNormal;
  486. #ifdef USE_TANGENT
  487. transformedTangent = bm * transformedTangent;
  488. #endif
  489. #endif
  490. #ifdef USE_INSTANCING
  491. mat3 im = mat3( instanceMatrix );
  492. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  493. transformedNormal = im * transformedNormal;
  494. #ifdef USE_TANGENT
  495. transformedTangent = im * transformedTangent;
  496. #endif
  497. #endif
  498. transformedNormal = normalMatrix * transformedNormal;
  499. #ifdef FLIP_SIDED
  500. transformedNormal = - transformedNormal;
  501. #endif
  502. #ifdef USE_TANGENT
  503. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  504. #ifdef FLIP_SIDED
  505. transformedTangent = - transformedTangent;
  506. #endif
  507. #endif`,Kpe=`#ifdef USE_DISPLACEMENTMAP
  508. uniform sampler2D displacementMap;
  509. uniform float displacementScale;
  510. uniform float displacementBias;
  511. #endif`,Xpe=`#ifdef USE_DISPLACEMENTMAP
  512. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  513. #endif`,Ype=`#ifdef USE_EMISSIVEMAP
  514. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  515. #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
  516. emissiveColor = sRGBTransferEOTF( emissiveColor );
  517. #endif
  518. totalEmissiveRadiance *= emissiveColor.rgb;
  519. #endif`,Qpe=`#ifdef USE_EMISSIVEMAP
  520. uniform sampler2D emissiveMap;
  521. #endif`,Zpe="gl_FragColor = linearToOutputTexel( gl_FragColor );",Jpe=`vec4 LinearTransferOETF( in vec4 value ) {
  522. return value;
  523. }
  524. vec4 sRGBTransferEOTF( in vec4 value ) {
  525. 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 );
  526. }
  527. vec4 sRGBTransferOETF( in vec4 value ) {
  528. 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 );
  529. }`,ege=`#ifdef USE_ENVMAP
  530. #ifdef ENV_WORLDPOS
  531. vec3 cameraToFrag;
  532. if ( isOrthographic ) {
  533. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  534. } else {
  535. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  536. }
  537. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  538. #ifdef ENVMAP_MODE_REFLECTION
  539. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  540. #else
  541. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  542. #endif
  543. #else
  544. vec3 reflectVec = vReflect;
  545. #endif
  546. #ifdef ENVMAP_TYPE_CUBE
  547. vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  548. #else
  549. vec4 envColor = vec4( 0.0 );
  550. #endif
  551. #ifdef ENVMAP_BLENDING_MULTIPLY
  552. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  553. #elif defined( ENVMAP_BLENDING_MIX )
  554. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  555. #elif defined( ENVMAP_BLENDING_ADD )
  556. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  557. #endif
  558. #endif`,tge=`#ifdef USE_ENVMAP
  559. uniform float envMapIntensity;
  560. uniform float flipEnvMap;
  561. uniform mat3 envMapRotation;
  562. #ifdef ENVMAP_TYPE_CUBE
  563. uniform samplerCube envMap;
  564. #else
  565. uniform sampler2D envMap;
  566. #endif
  567. #endif`,nge=`#ifdef USE_ENVMAP
  568. uniform float reflectivity;
  569. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  570. #define ENV_WORLDPOS
  571. #endif
  572. #ifdef ENV_WORLDPOS
  573. varying vec3 vWorldPosition;
  574. uniform float refractionRatio;
  575. #else
  576. varying vec3 vReflect;
  577. #endif
  578. #endif`,rge=`#ifdef USE_ENVMAP
  579. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  580. #define ENV_WORLDPOS
  581. #endif
  582. #ifdef ENV_WORLDPOS
  583. varying vec3 vWorldPosition;
  584. #else
  585. varying vec3 vReflect;
  586. uniform float refractionRatio;
  587. #endif
  588. #endif`,ige=`#ifdef USE_ENVMAP
  589. #ifdef ENV_WORLDPOS
  590. vWorldPosition = worldPosition.xyz;
  591. #else
  592. vec3 cameraToVertex;
  593. if ( isOrthographic ) {
  594. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  595. } else {
  596. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  597. }
  598. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  599. #ifdef ENVMAP_MODE_REFLECTION
  600. vReflect = reflect( cameraToVertex, worldNormal );
  601. #else
  602. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  603. #endif
  604. #endif
  605. #endif`,age=`#ifdef USE_FOG
  606. vFogDepth = - mvPosition.z;
  607. #endif`,sge=`#ifdef USE_FOG
  608. varying float vFogDepth;
  609. #endif`,oge=`#ifdef USE_FOG
  610. #ifdef FOG_EXP2
  611. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  612. #else
  613. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  614. #endif
  615. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  616. #endif`,lge=`#ifdef USE_FOG
  617. uniform vec3 fogColor;
  618. varying float vFogDepth;
  619. #ifdef FOG_EXP2
  620. uniform float fogDensity;
  621. #else
  622. uniform float fogNear;
  623. uniform float fogFar;
  624. #endif
  625. #endif`,cge=`#ifdef USE_GRADIENTMAP
  626. uniform sampler2D gradientMap;
  627. #endif
  628. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  629. float dotNL = dot( normal, lightDirection );
  630. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  631. #ifdef USE_GRADIENTMAP
  632. return vec3( texture2D( gradientMap, coord ).r );
  633. #else
  634. vec2 fw = fwidth( coord ) * 0.5;
  635. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  636. #endif
  637. }`,uge=`#ifdef USE_LIGHTMAP
  638. uniform sampler2D lightMap;
  639. uniform float lightMapIntensity;
  640. #endif`,dge=`LambertMaterial material;
  641. material.diffuseColor = diffuseColor.rgb;
  642. material.specularStrength = specularStrength;`,hge=`varying vec3 vViewPosition;
  643. struct LambertMaterial {
  644. vec3 diffuseColor;
  645. float specularStrength;
  646. };
  647. 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 ) {
  648. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  649. vec3 irradiance = dotNL * directLight.color;
  650. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  651. }
  652. 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 ) {
  653. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  654. }
  655. #define RE_Direct RE_Direct_Lambert
  656. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,fge=`uniform bool receiveShadow;
  657. uniform vec3 ambientLightColor;
  658. #if defined( USE_LIGHT_PROBES )
  659. uniform vec3 lightProbe[ 9 ];
  660. #endif
  661. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  662. float x = normal.x, y = normal.y, z = normal.z;
  663. vec3 result = shCoefficients[ 0 ] * 0.886227;
  664. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  665. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  666. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  667. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  668. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  669. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  670. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  671. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  672. return result;
  673. }
  674. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  675. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  676. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  677. return irradiance;
  678. }
  679. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  680. vec3 irradiance = ambientLightColor;
  681. return irradiance;
  682. }
  683. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  684. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  685. if ( cutoffDistance > 0.0 ) {
  686. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  687. }
  688. return distanceFalloff;
  689. }
  690. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  691. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  692. }
  693. #if NUM_DIR_LIGHTS > 0
  694. struct DirectionalLight {
  695. vec3 direction;
  696. vec3 color;
  697. };
  698. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  699. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  700. light.color = directionalLight.color;
  701. light.direction = directionalLight.direction;
  702. light.visible = true;
  703. }
  704. #endif
  705. #if NUM_POINT_LIGHTS > 0
  706. struct PointLight {
  707. vec3 position;
  708. vec3 color;
  709. float distance;
  710. float decay;
  711. };
  712. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  713. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  714. vec3 lVector = pointLight.position - geometryPosition;
  715. light.direction = normalize( lVector );
  716. float lightDistance = length( lVector );
  717. light.color = pointLight.color;
  718. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  719. light.visible = ( light.color != vec3( 0.0 ) );
  720. }
  721. #endif
  722. #if NUM_SPOT_LIGHTS > 0
  723. struct SpotLight {
  724. vec3 position;
  725. vec3 direction;
  726. vec3 color;
  727. float distance;
  728. float decay;
  729. float coneCos;
  730. float penumbraCos;
  731. };
  732. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  733. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  734. vec3 lVector = spotLight.position - geometryPosition;
  735. light.direction = normalize( lVector );
  736. float angleCos = dot( light.direction, spotLight.direction );
  737. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  738. if ( spotAttenuation > 0.0 ) {
  739. float lightDistance = length( lVector );
  740. light.color = spotLight.color * spotAttenuation;
  741. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  742. light.visible = ( light.color != vec3( 0.0 ) );
  743. } else {
  744. light.color = vec3( 0.0 );
  745. light.visible = false;
  746. }
  747. }
  748. #endif
  749. #if NUM_RECT_AREA_LIGHTS > 0
  750. struct RectAreaLight {
  751. vec3 color;
  752. vec3 position;
  753. vec3 halfWidth;
  754. vec3 halfHeight;
  755. };
  756. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  757. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  758. #endif
  759. #if NUM_HEMI_LIGHTS > 0
  760. struct HemisphereLight {
  761. vec3 direction;
  762. vec3 skyColor;
  763. vec3 groundColor;
  764. };
  765. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  766. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  767. float dotNL = dot( normal, hemiLight.direction );
  768. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  769. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  770. return irradiance;
  771. }
  772. #endif`,mge=`#ifdef USE_ENVMAP
  773. vec3 getIBLIrradiance( const in vec3 normal ) {
  774. #ifdef ENVMAP_TYPE_CUBE_UV
  775. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  776. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
  777. return PI * envMapColor.rgb * envMapIntensity;
  778. #else
  779. return vec3( 0.0 );
  780. #endif
  781. }
  782. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  783. #ifdef ENVMAP_TYPE_CUBE_UV
  784. vec3 reflectVec = reflect( - viewDir, normal );
  785. reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
  786. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  787. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
  788. return envMapColor.rgb * envMapIntensity;
  789. #else
  790. return vec3( 0.0 );
  791. #endif
  792. }
  793. #ifdef USE_ANISOTROPY
  794. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  795. #ifdef ENVMAP_TYPE_CUBE_UV
  796. vec3 bentNormal = cross( bitangent, viewDir );
  797. bentNormal = normalize( cross( bentNormal, bitangent ) );
  798. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  799. return getIBLRadiance( viewDir, bentNormal, roughness );
  800. #else
  801. return vec3( 0.0 );
  802. #endif
  803. }
  804. #endif
  805. #endif`,pge=`ToonMaterial material;
  806. material.diffuseColor = diffuseColor.rgb;`,gge=`varying vec3 vViewPosition;
  807. struct ToonMaterial {
  808. vec3 diffuseColor;
  809. };
  810. 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 ) {
  811. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  812. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  813. }
  814. 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 ) {
  815. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  816. }
  817. #define RE_Direct RE_Direct_Toon
  818. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,xge=`BlinnPhongMaterial material;
  819. material.diffuseColor = diffuseColor.rgb;
  820. material.specularColor = specular;
  821. material.specularShininess = shininess;
  822. material.specularStrength = specularStrength;`,bge=`varying vec3 vViewPosition;
  823. struct BlinnPhongMaterial {
  824. vec3 diffuseColor;
  825. vec3 specularColor;
  826. float specularShininess;
  827. float specularStrength;
  828. };
  829. 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 ) {
  830. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  831. vec3 irradiance = dotNL * directLight.color;
  832. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  833. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  834. }
  835. 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 ) {
  836. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  837. }
  838. #define RE_Direct RE_Direct_BlinnPhong
  839. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,yge=`PhysicalMaterial material;
  840. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  841. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  842. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  843. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  844. material.roughness = min( material.roughness, 1.0 );
  845. #ifdef IOR
  846. material.ior = ior;
  847. #ifdef USE_SPECULAR
  848. float specularIntensityFactor = specularIntensity;
  849. vec3 specularColorFactor = specularColor;
  850. #ifdef USE_SPECULAR_COLORMAP
  851. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  852. #endif
  853. #ifdef USE_SPECULAR_INTENSITYMAP
  854. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  855. #endif
  856. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  857. #else
  858. float specularIntensityFactor = 1.0;
  859. vec3 specularColorFactor = vec3( 1.0 );
  860. material.specularF90 = 1.0;
  861. #endif
  862. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  863. #else
  864. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  865. material.specularF90 = 1.0;
  866. #endif
  867. #ifdef USE_CLEARCOAT
  868. material.clearcoat = clearcoat;
  869. material.clearcoatRoughness = clearcoatRoughness;
  870. material.clearcoatF0 = vec3( 0.04 );
  871. material.clearcoatF90 = 1.0;
  872. #ifdef USE_CLEARCOATMAP
  873. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  874. #endif
  875. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  876. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  877. #endif
  878. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  879. material.clearcoatRoughness += geometryRoughness;
  880. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  881. #endif
  882. #ifdef USE_DISPERSION
  883. material.dispersion = dispersion;
  884. #endif
  885. #ifdef USE_IRIDESCENCE
  886. material.iridescence = iridescence;
  887. material.iridescenceIOR = iridescenceIOR;
  888. #ifdef USE_IRIDESCENCEMAP
  889. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  890. #endif
  891. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  892. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  893. #else
  894. material.iridescenceThickness = iridescenceThicknessMaximum;
  895. #endif
  896. #endif
  897. #ifdef USE_SHEEN
  898. material.sheenColor = sheenColor;
  899. #ifdef USE_SHEEN_COLORMAP
  900. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  901. #endif
  902. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  903. #ifdef USE_SHEEN_ROUGHNESSMAP
  904. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  905. #endif
  906. #endif
  907. #ifdef USE_ANISOTROPY
  908. #ifdef USE_ANISOTROPYMAP
  909. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  910. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  911. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  912. #else
  913. vec2 anisotropyV = anisotropyVector;
  914. #endif
  915. material.anisotropy = length( anisotropyV );
  916. if( material.anisotropy == 0.0 ) {
  917. anisotropyV = vec2( 1.0, 0.0 );
  918. } else {
  919. anisotropyV /= material.anisotropy;
  920. material.anisotropy = saturate( material.anisotropy );
  921. }
  922. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  923. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  924. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  925. #endif`,vge=`uniform sampler2D dfgLUT;
  926. struct PhysicalMaterial {
  927. vec3 diffuseColor;
  928. float roughness;
  929. vec3 specularColor;
  930. float specularF90;
  931. float dispersion;
  932. #ifdef USE_CLEARCOAT
  933. float clearcoat;
  934. float clearcoatRoughness;
  935. vec3 clearcoatF0;
  936. float clearcoatF90;
  937. #endif
  938. #ifdef USE_IRIDESCENCE
  939. float iridescence;
  940. float iridescenceIOR;
  941. float iridescenceThickness;
  942. vec3 iridescenceFresnel;
  943. vec3 iridescenceF0;
  944. #endif
  945. #ifdef USE_SHEEN
  946. vec3 sheenColor;
  947. float sheenRoughness;
  948. #endif
  949. #ifdef IOR
  950. float ior;
  951. #endif
  952. #ifdef USE_TRANSMISSION
  953. float transmission;
  954. float transmissionAlpha;
  955. float thickness;
  956. float attenuationDistance;
  957. vec3 attenuationColor;
  958. #endif
  959. #ifdef USE_ANISOTROPY
  960. float anisotropy;
  961. float alphaT;
  962. vec3 anisotropyT;
  963. vec3 anisotropyB;
  964. #endif
  965. };
  966. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  967. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  968. vec3 sheenSpecularDirect = vec3( 0.0 );
  969. vec3 sheenSpecularIndirect = vec3(0.0 );
  970. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  971. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  972. float x2 = x * x;
  973. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  974. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  975. }
  976. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  977. float a2 = pow2( alpha );
  978. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  979. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  980. return 0.5 / max( gv + gl, EPSILON );
  981. }
  982. float D_GGX( const in float alpha, const in float dotNH ) {
  983. float a2 = pow2( alpha );
  984. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  985. return RECIPROCAL_PI * a2 / pow2( denom );
  986. }
  987. #ifdef USE_ANISOTROPY
  988. 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 ) {
  989. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  990. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  991. float v = 0.5 / ( gv + gl );
  992. return saturate(v);
  993. }
  994. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  995. float a2 = alphaT * alphaB;
  996. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  997. highp float v2 = dot( v, v );
  998. float w2 = a2 / v2;
  999. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  1000. }
  1001. #endif
  1002. #ifdef USE_CLEARCOAT
  1003. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  1004. vec3 f0 = material.clearcoatF0;
  1005. float f90 = material.clearcoatF90;
  1006. float roughness = material.clearcoatRoughness;
  1007. float alpha = pow2( roughness );
  1008. vec3 halfDir = normalize( lightDir + viewDir );
  1009. float dotNL = saturate( dot( normal, lightDir ) );
  1010. float dotNV = saturate( dot( normal, viewDir ) );
  1011. float dotNH = saturate( dot( normal, halfDir ) );
  1012. float dotVH = saturate( dot( viewDir, halfDir ) );
  1013. vec3 F = F_Schlick( f0, f90, dotVH );
  1014. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1015. float D = D_GGX( alpha, dotNH );
  1016. return F * ( V * D );
  1017. }
  1018. #endif
  1019. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1020. vec3 f0 = material.specularColor;
  1021. float f90 = material.specularF90;
  1022. float roughness = material.roughness;
  1023. float alpha = pow2( roughness );
  1024. vec3 halfDir = normalize( lightDir + viewDir );
  1025. float dotNL = saturate( dot( normal, lightDir ) );
  1026. float dotNV = saturate( dot( normal, viewDir ) );
  1027. float dotNH = saturate( dot( normal, halfDir ) );
  1028. float dotVH = saturate( dot( viewDir, halfDir ) );
  1029. vec3 F = F_Schlick( f0, f90, dotVH );
  1030. #ifdef USE_IRIDESCENCE
  1031. F = mix( F, material.iridescenceFresnel, material.iridescence );
  1032. #endif
  1033. #ifdef USE_ANISOTROPY
  1034. float dotTL = dot( material.anisotropyT, lightDir );
  1035. float dotTV = dot( material.anisotropyT, viewDir );
  1036. float dotTH = dot( material.anisotropyT, halfDir );
  1037. float dotBL = dot( material.anisotropyB, lightDir );
  1038. float dotBV = dot( material.anisotropyB, viewDir );
  1039. float dotBH = dot( material.anisotropyB, halfDir );
  1040. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  1041. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  1042. #else
  1043. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1044. float D = D_GGX( alpha, dotNH );
  1045. #endif
  1046. return F * ( V * D );
  1047. }
  1048. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  1049. const float LUT_SIZE = 64.0;
  1050. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  1051. const float LUT_BIAS = 0.5 / LUT_SIZE;
  1052. float dotNV = saturate( dot( N, V ) );
  1053. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  1054. uv = uv * LUT_SCALE + LUT_BIAS;
  1055. return uv;
  1056. }
  1057. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  1058. float l = length( f );
  1059. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  1060. }
  1061. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  1062. float x = dot( v1, v2 );
  1063. float y = abs( x );
  1064. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  1065. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  1066. float v = a / b;
  1067. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  1068. return cross( v1, v2 ) * theta_sintheta;
  1069. }
  1070. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  1071. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  1072. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  1073. vec3 lightNormal = cross( v1, v2 );
  1074. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  1075. vec3 T1, T2;
  1076. T1 = normalize( V - N * dot( V, N ) );
  1077. T2 = - cross( N, T1 );
  1078. mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
  1079. vec3 coords[ 4 ];
  1080. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  1081. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  1082. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  1083. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  1084. coords[ 0 ] = normalize( coords[ 0 ] );
  1085. coords[ 1 ] = normalize( coords[ 1 ] );
  1086. coords[ 2 ] = normalize( coords[ 2 ] );
  1087. coords[ 3 ] = normalize( coords[ 3 ] );
  1088. vec3 vectorFormFactor = vec3( 0.0 );
  1089. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  1090. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  1091. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  1092. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  1093. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  1094. return vec3( result );
  1095. }
  1096. #if defined( USE_SHEEN )
  1097. float D_Charlie( float roughness, float dotNH ) {
  1098. float alpha = pow2( roughness );
  1099. float invAlpha = 1.0 / alpha;
  1100. float cos2h = dotNH * dotNH;
  1101. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  1102. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  1103. }
  1104. float V_Neubelt( float dotNV, float dotNL ) {
  1105. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  1106. }
  1107. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  1108. vec3 halfDir = normalize( lightDir + viewDir );
  1109. float dotNL = saturate( dot( normal, lightDir ) );
  1110. float dotNV = saturate( dot( normal, viewDir ) );
  1111. float dotNH = saturate( dot( normal, halfDir ) );
  1112. float D = D_Charlie( sheenRoughness, dotNH );
  1113. float V = V_Neubelt( dotNV, dotNL );
  1114. return sheenColor * ( D * V );
  1115. }
  1116. #endif
  1117. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1118. float dotNV = saturate( dot( normal, viewDir ) );
  1119. float r2 = roughness * roughness;
  1120. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  1121. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  1122. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  1123. return saturate( DG * RECIPROCAL_PI );
  1124. }
  1125. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1126. float dotNV = saturate( dot( normal, viewDir ) );
  1127. vec2 uv = vec2( roughness, dotNV );
  1128. return texture2D( dfgLUT, uv ).rg;
  1129. }
  1130. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  1131. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1132. return specularColor * fab.x + specularF90 * fab.y;
  1133. }
  1134. #ifdef USE_IRIDESCENCE
  1135. 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 ) {
  1136. #else
  1137. 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 ) {
  1138. #endif
  1139. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1140. #ifdef USE_IRIDESCENCE
  1141. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  1142. #else
  1143. vec3 Fr = specularColor;
  1144. #endif
  1145. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  1146. float Ess = fab.x + fab.y;
  1147. float Ems = 1.0 - Ess;
  1148. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  1149. singleScatter += FssEss;
  1150. multiScatter += Fms * Ems;
  1151. }
  1152. vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1153. vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
  1154. float dotNL = saturate( dot( normal, lightDir ) );
  1155. float dotNV = saturate( dot( normal, viewDir ) );
  1156. vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
  1157. vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
  1158. vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
  1159. vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
  1160. float Ess_V = dfgV.x + dfgV.y;
  1161. float Ess_L = dfgL.x + dfgL.y;
  1162. float Ems_V = 1.0 - Ess_V;
  1163. float Ems_L = 1.0 - Ess_L;
  1164. vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
  1165. vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
  1166. float compensationFactor = Ems_V * Ems_L;
  1167. vec3 multiScatter = Fms * compensationFactor;
  1168. return singleScatter + multiScatter;
  1169. }
  1170. #if NUM_RECT_AREA_LIGHTS > 0
  1171. 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 ) {
  1172. vec3 normal = geometryNormal;
  1173. vec3 viewDir = geometryViewDir;
  1174. vec3 position = geometryPosition;
  1175. vec3 lightPos = rectAreaLight.position;
  1176. vec3 halfWidth = rectAreaLight.halfWidth;
  1177. vec3 halfHeight = rectAreaLight.halfHeight;
  1178. vec3 lightColor = rectAreaLight.color;
  1179. float roughness = material.roughness;
  1180. vec3 rectCoords[ 4 ];
  1181. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  1182. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  1183. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  1184. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  1185. vec4 t1 = texture2D( ltc_1, uv );
  1186. vec4 t2 = texture2D( ltc_2, uv );
  1187. mat3 mInv = mat3(
  1188. vec3( t1.x, 0, t1.y ),
  1189. vec3( 0, 1, 0 ),
  1190. vec3( t1.z, 0, t1.w )
  1191. );
  1192. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  1193. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  1194. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  1195. }
  1196. #endif
  1197. 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 ) {
  1198. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  1199. vec3 irradiance = dotNL * directLight.color;
  1200. #ifdef USE_CLEARCOAT
  1201. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  1202. vec3 ccIrradiance = dotNLcc * directLight.color;
  1203. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  1204. #endif
  1205. #ifdef USE_SHEEN
  1206. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  1207. #endif
  1208. reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
  1209. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1210. }
  1211. 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 ) {
  1212. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1213. }
  1214. 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) {
  1215. #ifdef USE_CLEARCOAT
  1216. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  1217. #endif
  1218. #ifdef USE_SHEEN
  1219. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  1220. #endif
  1221. vec3 singleScattering = vec3( 0.0 );
  1222. vec3 multiScattering = vec3( 0.0 );
  1223. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  1224. #ifdef USE_IRIDESCENCE
  1225. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  1226. #else
  1227. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  1228. #endif
  1229. vec3 totalScattering = singleScattering + multiScattering;
  1230. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  1231. reflectedLight.indirectSpecular += radiance * singleScattering;
  1232. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  1233. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  1234. }
  1235. #define RE_Direct RE_Direct_Physical
  1236. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  1237. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  1238. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  1239. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  1240. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  1241. }`,_ge=`
  1242. vec3 geometryPosition = - vViewPosition;
  1243. vec3 geometryNormal = normal;
  1244. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  1245. vec3 geometryClearcoatNormal = vec3( 0.0 );
  1246. #ifdef USE_CLEARCOAT
  1247. geometryClearcoatNormal = clearcoatNormal;
  1248. #endif
  1249. #ifdef USE_IRIDESCENCE
  1250. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  1251. if ( material.iridescenceThickness == 0.0 ) {
  1252. material.iridescence = 0.0;
  1253. } else {
  1254. material.iridescence = saturate( material.iridescence );
  1255. }
  1256. if ( material.iridescence > 0.0 ) {
  1257. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  1258. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  1259. }
  1260. #endif
  1261. IncidentLight directLight;
  1262. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  1263. PointLight pointLight;
  1264. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  1265. PointLightShadow pointLightShadow;
  1266. #endif
  1267. #pragma unroll_loop_start
  1268. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  1269. pointLight = pointLights[ i ];
  1270. getPointLightInfo( pointLight, geometryPosition, directLight );
  1271. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  1272. pointLightShadow = pointLightShadows[ i ];
  1273. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  1274. #endif
  1275. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1276. }
  1277. #pragma unroll_loop_end
  1278. #endif
  1279. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  1280. SpotLight spotLight;
  1281. vec4 spotColor;
  1282. vec3 spotLightCoord;
  1283. bool inSpotLightMap;
  1284. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  1285. SpotLightShadow spotLightShadow;
  1286. #endif
  1287. #pragma unroll_loop_start
  1288. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  1289. spotLight = spotLights[ i ];
  1290. getSpotLightInfo( spotLight, geometryPosition, directLight );
  1291. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1292. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  1293. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1294. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  1295. #else
  1296. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1297. #endif
  1298. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  1299. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  1300. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  1301. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  1302. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  1303. #endif
  1304. #undef SPOT_LIGHT_MAP_INDEX
  1305. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1306. spotLightShadow = spotLightShadows[ i ];
  1307. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1308. #endif
  1309. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1310. }
  1311. #pragma unroll_loop_end
  1312. #endif
  1313. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  1314. DirectionalLight directionalLight;
  1315. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  1316. DirectionalLightShadow directionalLightShadow;
  1317. #endif
  1318. #pragma unroll_loop_start
  1319. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  1320. directionalLight = directionalLights[ i ];
  1321. getDirectionalLightInfo( directionalLight, directLight );
  1322. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  1323. directionalLightShadow = directionalLightShadows[ i ];
  1324. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1325. #endif
  1326. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1327. }
  1328. #pragma unroll_loop_end
  1329. #endif
  1330. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  1331. RectAreaLight rectAreaLight;
  1332. #pragma unroll_loop_start
  1333. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  1334. rectAreaLight = rectAreaLights[ i ];
  1335. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1336. }
  1337. #pragma unroll_loop_end
  1338. #endif
  1339. #if defined( RE_IndirectDiffuse )
  1340. vec3 iblIrradiance = vec3( 0.0 );
  1341. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  1342. #if defined( USE_LIGHT_PROBES )
  1343. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  1344. #endif
  1345. #if ( NUM_HEMI_LIGHTS > 0 )
  1346. #pragma unroll_loop_start
  1347. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  1348. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  1349. }
  1350. #pragma unroll_loop_end
  1351. #endif
  1352. #endif
  1353. #if defined( RE_IndirectSpecular )
  1354. vec3 radiance = vec3( 0.0 );
  1355. vec3 clearcoatRadiance = vec3( 0.0 );
  1356. #endif`,wge=`#if defined( RE_IndirectDiffuse )
  1357. #ifdef USE_LIGHTMAP
  1358. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  1359. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  1360. irradiance += lightMapIrradiance;
  1361. #endif
  1362. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  1363. iblIrradiance += getIBLIrradiance( geometryNormal );
  1364. #endif
  1365. #endif
  1366. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  1367. #ifdef USE_ANISOTROPY
  1368. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  1369. #else
  1370. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  1371. #endif
  1372. #ifdef USE_CLEARCOAT
  1373. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  1374. #endif
  1375. #endif`,Sge=`#if defined( RE_IndirectDiffuse )
  1376. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1377. #endif
  1378. #if defined( RE_IndirectSpecular )
  1379. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1380. #endif`,Nge=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1381. gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  1382. #endif`,Mge=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1383. uniform float logDepthBufFC;
  1384. varying float vFragDepth;
  1385. varying float vIsPerspective;
  1386. #endif`,Ege=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1387. varying float vFragDepth;
  1388. varying float vIsPerspective;
  1389. #endif`,Cge=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1390. vFragDepth = 1.0 + gl_Position.w;
  1391. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  1392. #endif`,Tge=`#ifdef USE_MAP
  1393. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  1394. #ifdef DECODE_VIDEO_TEXTURE
  1395. sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
  1396. #endif
  1397. diffuseColor *= sampledDiffuseColor;
  1398. #endif`,Age=`#ifdef USE_MAP
  1399. uniform sampler2D map;
  1400. #endif`,kge=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1401. #if defined( USE_POINTS_UV )
  1402. vec2 uv = vUv;
  1403. #else
  1404. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  1405. #endif
  1406. #endif
  1407. #ifdef USE_MAP
  1408. diffuseColor *= texture2D( map, uv );
  1409. #endif
  1410. #ifdef USE_ALPHAMAP
  1411. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  1412. #endif`,jge=`#if defined( USE_POINTS_UV )
  1413. varying vec2 vUv;
  1414. #else
  1415. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1416. uniform mat3 uvTransform;
  1417. #endif
  1418. #endif
  1419. #ifdef USE_MAP
  1420. uniform sampler2D map;
  1421. #endif
  1422. #ifdef USE_ALPHAMAP
  1423. uniform sampler2D alphaMap;
  1424. #endif`,Pge=`float metalnessFactor = metalness;
  1425. #ifdef USE_METALNESSMAP
  1426. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  1427. metalnessFactor *= texelMetalness.b;
  1428. #endif`,Rge=`#ifdef USE_METALNESSMAP
  1429. uniform sampler2D metalnessMap;
  1430. #endif`,Dge=`#ifdef USE_INSTANCING_MORPH
  1431. float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1432. float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
  1433. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1434. morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
  1435. }
  1436. #endif`,Oge=`#if defined( USE_MORPHCOLORS )
  1437. vColor *= morphTargetBaseInfluence;
  1438. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1439. #if defined( USE_COLOR_ALPHA )
  1440. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  1441. #elif defined( USE_COLOR )
  1442. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  1443. #endif
  1444. }
  1445. #endif`,Lge=`#ifdef USE_MORPHNORMALS
  1446. objectNormal *= morphTargetBaseInfluence;
  1447. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1448. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  1449. }
  1450. #endif`,Ige=`#ifdef USE_MORPHTARGETS
  1451. #ifndef USE_INSTANCING_MORPH
  1452. uniform float morphTargetBaseInfluence;
  1453. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1454. #endif
  1455. uniform sampler2DArray morphTargetsTexture;
  1456. uniform ivec2 morphTargetsTextureSize;
  1457. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  1458. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  1459. int y = texelIndex / morphTargetsTextureSize.x;
  1460. int x = texelIndex - y * morphTargetsTextureSize.x;
  1461. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  1462. return texelFetch( morphTargetsTexture, morphUV, 0 );
  1463. }
  1464. #endif`,Fge=`#ifdef USE_MORPHTARGETS
  1465. transformed *= morphTargetBaseInfluence;
  1466. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1467. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  1468. }
  1469. #endif`,Uge=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  1470. #ifdef FLAT_SHADED
  1471. vec3 fdx = dFdx( vViewPosition );
  1472. vec3 fdy = dFdy( vViewPosition );
  1473. vec3 normal = normalize( cross( fdx, fdy ) );
  1474. #else
  1475. vec3 normal = normalize( vNormal );
  1476. #ifdef DOUBLE_SIDED
  1477. normal *= faceDirection;
  1478. #endif
  1479. #endif
  1480. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  1481. #ifdef USE_TANGENT
  1482. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1483. #else
  1484. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  1485. #if defined( USE_NORMALMAP )
  1486. vNormalMapUv
  1487. #elif defined( USE_CLEARCOAT_NORMALMAP )
  1488. vClearcoatNormalMapUv
  1489. #else
  1490. vUv
  1491. #endif
  1492. );
  1493. #endif
  1494. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1495. tbn[0] *= faceDirection;
  1496. tbn[1] *= faceDirection;
  1497. #endif
  1498. #endif
  1499. #ifdef USE_CLEARCOAT_NORMALMAP
  1500. #ifdef USE_TANGENT
  1501. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1502. #else
  1503. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  1504. #endif
  1505. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1506. tbn2[0] *= faceDirection;
  1507. tbn2[1] *= faceDirection;
  1508. #endif
  1509. #endif
  1510. vec3 nonPerturbedNormal = normal;`,zge=`#ifdef USE_NORMALMAP_OBJECTSPACE
  1511. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1512. #ifdef FLIP_SIDED
  1513. normal = - normal;
  1514. #endif
  1515. #ifdef DOUBLE_SIDED
  1516. normal = normal * faceDirection;
  1517. #endif
  1518. normal = normalize( normalMatrix * normal );
  1519. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  1520. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1521. mapN.xy *= normalScale;
  1522. normal = normalize( tbn * mapN );
  1523. #elif defined( USE_BUMPMAP )
  1524. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  1525. #endif`,Bge=`#ifndef FLAT_SHADED
  1526. varying vec3 vNormal;
  1527. #ifdef USE_TANGENT
  1528. varying vec3 vTangent;
  1529. varying vec3 vBitangent;
  1530. #endif
  1531. #endif`,$ge=`#ifndef FLAT_SHADED
  1532. varying vec3 vNormal;
  1533. #ifdef USE_TANGENT
  1534. varying vec3 vTangent;
  1535. varying vec3 vBitangent;
  1536. #endif
  1537. #endif`,Hge=`#ifndef FLAT_SHADED
  1538. vNormal = normalize( transformedNormal );
  1539. #ifdef USE_TANGENT
  1540. vTangent = normalize( transformedTangent );
  1541. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  1542. #endif
  1543. #endif`,Vge=`#ifdef USE_NORMALMAP
  1544. uniform sampler2D normalMap;
  1545. uniform vec2 normalScale;
  1546. #endif
  1547. #ifdef USE_NORMALMAP_OBJECTSPACE
  1548. uniform mat3 normalMatrix;
  1549. #endif
  1550. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  1551. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  1552. vec3 q0 = dFdx( eye_pos.xyz );
  1553. vec3 q1 = dFdy( eye_pos.xyz );
  1554. vec2 st0 = dFdx( uv.st );
  1555. vec2 st1 = dFdy( uv.st );
  1556. vec3 N = surf_norm;
  1557. vec3 q1perp = cross( q1, N );
  1558. vec3 q0perp = cross( N, q0 );
  1559. vec3 T = q1perp * st0.x + q0perp * st1.x;
  1560. vec3 B = q1perp * st0.y + q0perp * st1.y;
  1561. float det = max( dot( T, T ), dot( B, B ) );
  1562. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  1563. return mat3( T * scale, B * scale, N );
  1564. }
  1565. #endif`,Gge=`#ifdef USE_CLEARCOAT
  1566. vec3 clearcoatNormal = nonPerturbedNormal;
  1567. #endif`,qge=`#ifdef USE_CLEARCOAT_NORMALMAP
  1568. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  1569. clearcoatMapN.xy *= clearcoatNormalScale;
  1570. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  1571. #endif`,Wge=`#ifdef USE_CLEARCOATMAP
  1572. uniform sampler2D clearcoatMap;
  1573. #endif
  1574. #ifdef USE_CLEARCOAT_NORMALMAP
  1575. uniform sampler2D clearcoatNormalMap;
  1576. uniform vec2 clearcoatNormalScale;
  1577. #endif
  1578. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  1579. uniform sampler2D clearcoatRoughnessMap;
  1580. #endif`,Kge=`#ifdef USE_IRIDESCENCEMAP
  1581. uniform sampler2D iridescenceMap;
  1582. #endif
  1583. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  1584. uniform sampler2D iridescenceThicknessMap;
  1585. #endif`,Xge=`#ifdef OPAQUE
  1586. diffuseColor.a = 1.0;
  1587. #endif
  1588. #ifdef USE_TRANSMISSION
  1589. diffuseColor.a *= material.transmissionAlpha;
  1590. #endif
  1591. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Yge=`vec3 packNormalToRGB( const in vec3 normal ) {
  1592. return normalize( normal ) * 0.5 + 0.5;
  1593. }
  1594. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  1595. return 2.0 * rgb.xyz - 1.0;
  1596. }
  1597. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
  1598. const float Inv255 = 1. / 255.;
  1599. const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
  1600. const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
  1601. const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
  1602. const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
  1603. vec4 packDepthToRGBA( const in float v ) {
  1604. if( v <= 0.0 )
  1605. return vec4( 0., 0., 0., 0. );
  1606. if( v >= 1.0 )
  1607. return vec4( 1., 1., 1., 1. );
  1608. float vuf;
  1609. float af = modf( v * PackFactors.a, vuf );
  1610. float bf = modf( vuf * ShiftRight8, vuf );
  1611. float gf = modf( vuf * ShiftRight8, vuf );
  1612. return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
  1613. }
  1614. vec3 packDepthToRGB( const in float v ) {
  1615. if( v <= 0.0 )
  1616. return vec3( 0., 0., 0. );
  1617. if( v >= 1.0 )
  1618. return vec3( 1., 1., 1. );
  1619. float vuf;
  1620. float bf = modf( v * PackFactors.b, vuf );
  1621. float gf = modf( vuf * ShiftRight8, vuf );
  1622. return vec3( vuf * Inv255, gf * PackUpscale, bf );
  1623. }
  1624. vec2 packDepthToRG( const in float v ) {
  1625. if( v <= 0.0 )
  1626. return vec2( 0., 0. );
  1627. if( v >= 1.0 )
  1628. return vec2( 1., 1. );
  1629. float vuf;
  1630. float gf = modf( v * 256., vuf );
  1631. return vec2( vuf * Inv255, gf );
  1632. }
  1633. float unpackRGBAToDepth( const in vec4 v ) {
  1634. return dot( v, UnpackFactors4 );
  1635. }
  1636. float unpackRGBToDepth( const in vec3 v ) {
  1637. return dot( v, UnpackFactors3 );
  1638. }
  1639. float unpackRGToDepth( const in vec2 v ) {
  1640. return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
  1641. }
  1642. vec4 pack2HalfToRGBA( const in vec2 v ) {
  1643. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  1644. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  1645. }
  1646. vec2 unpackRGBATo2Half( const in vec4 v ) {
  1647. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  1648. }
  1649. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  1650. return ( viewZ + near ) / ( near - far );
  1651. }
  1652. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1653. return depth * ( near - far ) - near;
  1654. }
  1655. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  1656. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  1657. }
  1658. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1659. return ( near * far ) / ( ( far - near ) * depth - far );
  1660. }`,Qge=`#ifdef PREMULTIPLIED_ALPHA
  1661. gl_FragColor.rgb *= gl_FragColor.a;
  1662. #endif`,Zge=`vec4 mvPosition = vec4( transformed, 1.0 );
  1663. #ifdef USE_BATCHING
  1664. mvPosition = batchingMatrix * mvPosition;
  1665. #endif
  1666. #ifdef USE_INSTANCING
  1667. mvPosition = instanceMatrix * mvPosition;
  1668. #endif
  1669. mvPosition = modelViewMatrix * mvPosition;
  1670. gl_Position = projectionMatrix * mvPosition;`,Jge=`#ifdef DITHERING
  1671. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  1672. #endif`,exe=`#ifdef DITHERING
  1673. vec3 dithering( vec3 color ) {
  1674. float grid_position = rand( gl_FragCoord.xy );
  1675. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  1676. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  1677. return color + dither_shift_RGB;
  1678. }
  1679. #endif`,txe=`float roughnessFactor = roughness;
  1680. #ifdef USE_ROUGHNESSMAP
  1681. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  1682. roughnessFactor *= texelRoughness.g;
  1683. #endif`,nxe=`#ifdef USE_ROUGHNESSMAP
  1684. uniform sampler2D roughnessMap;
  1685. #endif`,rxe=`#if NUM_SPOT_LIGHT_COORDS > 0
  1686. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1687. #endif
  1688. #if NUM_SPOT_LIGHT_MAPS > 0
  1689. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  1690. #endif
  1691. #ifdef USE_SHADOWMAP
  1692. #if NUM_DIR_LIGHT_SHADOWS > 0
  1693. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  1694. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1695. struct DirectionalLightShadow {
  1696. float shadowIntensity;
  1697. float shadowBias;
  1698. float shadowNormalBias;
  1699. float shadowRadius;
  1700. vec2 shadowMapSize;
  1701. };
  1702. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1703. #endif
  1704. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1705. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  1706. struct SpotLightShadow {
  1707. float shadowIntensity;
  1708. float shadowBias;
  1709. float shadowNormalBias;
  1710. float shadowRadius;
  1711. vec2 shadowMapSize;
  1712. };
  1713. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1714. #endif
  1715. #if NUM_POINT_LIGHT_SHADOWS > 0
  1716. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  1717. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1718. struct PointLightShadow {
  1719. float shadowIntensity;
  1720. float shadowBias;
  1721. float shadowNormalBias;
  1722. float shadowRadius;
  1723. vec2 shadowMapSize;
  1724. float shadowCameraNear;
  1725. float shadowCameraFar;
  1726. };
  1727. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1728. #endif
  1729. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  1730. float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
  1731. #ifdef USE_REVERSED_DEPTH_BUFFER
  1732. return step( depth, compare );
  1733. #else
  1734. return step( compare, depth );
  1735. #endif
  1736. }
  1737. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  1738. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  1739. }
  1740. float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
  1741. float occlusion = 1.0;
  1742. vec2 distribution = texture2DDistribution( shadow, uv );
  1743. #ifdef USE_REVERSED_DEPTH_BUFFER
  1744. float hard_shadow = step( distribution.x, compare );
  1745. #else
  1746. float hard_shadow = step( compare, distribution.x );
  1747. #endif
  1748. if ( hard_shadow != 1.0 ) {
  1749. float distance = compare - distribution.x;
  1750. float variance = max( 0.00000, distribution.y * distribution.y );
  1751. 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 );
  1752. }
  1753. return occlusion;
  1754. }
  1755. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1756. float shadow = 1.0;
  1757. shadowCoord.xyz /= shadowCoord.w;
  1758. shadowCoord.z += shadowBias;
  1759. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  1760. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  1761. if ( frustumTest ) {
  1762. #if defined( SHADOWMAP_TYPE_PCF )
  1763. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1764. float dx0 = - texelSize.x * shadowRadius;
  1765. float dy0 = - texelSize.y * shadowRadius;
  1766. float dx1 = + texelSize.x * shadowRadius;
  1767. float dy1 = + texelSize.y * shadowRadius;
  1768. float dx2 = dx0 / 2.0;
  1769. float dy2 = dy0 / 2.0;
  1770. float dx3 = dx1 / 2.0;
  1771. float dy3 = dy1 / 2.0;
  1772. shadow = (
  1773. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  1774. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  1775. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  1776. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  1777. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  1778. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  1779. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  1780. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  1781. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  1782. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  1783. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  1784. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  1785. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  1786. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  1787. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  1788. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  1789. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  1790. ) * ( 1.0 / 17.0 );
  1791. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  1792. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1793. float dx = texelSize.x;
  1794. float dy = texelSize.y;
  1795. vec2 uv = shadowCoord.xy;
  1796. vec2 f = fract( uv * shadowMapSize + 0.5 );
  1797. uv -= f * texelSize;
  1798. shadow = (
  1799. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  1800. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  1801. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  1802. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  1803. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  1804. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  1805. f.x ) +
  1806. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  1807. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  1808. f.x ) +
  1809. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  1810. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  1811. f.y ) +
  1812. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  1813. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  1814. f.y ) +
  1815. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  1816. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  1817. f.x ),
  1818. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  1819. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  1820. f.x ),
  1821. f.y )
  1822. ) * ( 1.0 / 9.0 );
  1823. #elif defined( SHADOWMAP_TYPE_VSM )
  1824. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  1825. #else
  1826. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  1827. #endif
  1828. }
  1829. return mix( 1.0, shadow, shadowIntensity );
  1830. }
  1831. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  1832. vec3 absV = abs( v );
  1833. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  1834. absV *= scaleToCube;
  1835. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  1836. vec2 planar = v.xy;
  1837. float almostATexel = 1.5 * texelSizeY;
  1838. float almostOne = 1.0 - almostATexel;
  1839. if ( absV.z >= almostOne ) {
  1840. if ( v.z > 0.0 )
  1841. planar.x = 4.0 - v.x;
  1842. } else if ( absV.x >= almostOne ) {
  1843. float signX = sign( v.x );
  1844. planar.x = v.z * signX + 2.0 * signX;
  1845. } else if ( absV.y >= almostOne ) {
  1846. float signY = sign( v.y );
  1847. planar.x = v.x + 2.0 * signY + 2.0;
  1848. planar.y = v.z * signY - 2.0;
  1849. }
  1850. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  1851. }
  1852. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  1853. float shadow = 1.0;
  1854. vec3 lightToPosition = shadowCoord.xyz;
  1855. float lightToPositionLength = length( lightToPosition );
  1856. if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
  1857. float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  1858. vec3 bd3D = normalize( lightToPosition );
  1859. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  1860. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  1861. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  1862. shadow = (
  1863. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  1864. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  1865. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  1866. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  1867. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  1868. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  1869. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  1870. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  1871. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  1872. ) * ( 1.0 / 9.0 );
  1873. #else
  1874. shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  1875. #endif
  1876. }
  1877. return mix( 1.0, shadow, shadowIntensity );
  1878. }
  1879. #endif`,ixe=`#if NUM_SPOT_LIGHT_COORDS > 0
  1880. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  1881. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1882. #endif
  1883. #ifdef USE_SHADOWMAP
  1884. #if NUM_DIR_LIGHT_SHADOWS > 0
  1885. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  1886. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1887. struct DirectionalLightShadow {
  1888. float shadowIntensity;
  1889. float shadowBias;
  1890. float shadowNormalBias;
  1891. float shadowRadius;
  1892. vec2 shadowMapSize;
  1893. };
  1894. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1895. #endif
  1896. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1897. struct SpotLightShadow {
  1898. float shadowIntensity;
  1899. float shadowBias;
  1900. float shadowNormalBias;
  1901. float shadowRadius;
  1902. vec2 shadowMapSize;
  1903. };
  1904. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1905. #endif
  1906. #if NUM_POINT_LIGHT_SHADOWS > 0
  1907. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  1908. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1909. struct PointLightShadow {
  1910. float shadowIntensity;
  1911. float shadowBias;
  1912. float shadowNormalBias;
  1913. float shadowRadius;
  1914. vec2 shadowMapSize;
  1915. float shadowCameraNear;
  1916. float shadowCameraFar;
  1917. };
  1918. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1919. #endif
  1920. #endif`,axe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  1921. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  1922. vec4 shadowWorldPosition;
  1923. #endif
  1924. #if defined( USE_SHADOWMAP )
  1925. #if NUM_DIR_LIGHT_SHADOWS > 0
  1926. #pragma unroll_loop_start
  1927. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1928. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  1929. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  1930. }
  1931. #pragma unroll_loop_end
  1932. #endif
  1933. #if NUM_POINT_LIGHT_SHADOWS > 0
  1934. #pragma unroll_loop_start
  1935. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1936. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  1937. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  1938. }
  1939. #pragma unroll_loop_end
  1940. #endif
  1941. #endif
  1942. #if NUM_SPOT_LIGHT_COORDS > 0
  1943. #pragma unroll_loop_start
  1944. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  1945. shadowWorldPosition = worldPosition;
  1946. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1947. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  1948. #endif
  1949. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  1950. }
  1951. #pragma unroll_loop_end
  1952. #endif`,sxe=`float getShadowMask() {
  1953. float shadow = 1.0;
  1954. #ifdef USE_SHADOWMAP
  1955. #if NUM_DIR_LIGHT_SHADOWS > 0
  1956. DirectionalLightShadow directionalLight;
  1957. #pragma unroll_loop_start
  1958. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1959. directionalLight = directionalLightShadows[ i ];
  1960. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1961. }
  1962. #pragma unroll_loop_end
  1963. #endif
  1964. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1965. SpotLightShadow spotLight;
  1966. #pragma unroll_loop_start
  1967. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  1968. spotLight = spotLightShadows[ i ];
  1969. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1970. }
  1971. #pragma unroll_loop_end
  1972. #endif
  1973. #if NUM_POINT_LIGHT_SHADOWS > 0
  1974. PointLightShadow pointLight;
  1975. #pragma unroll_loop_start
  1976. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1977. pointLight = pointLightShadows[ i ];
  1978. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  1979. }
  1980. #pragma unroll_loop_end
  1981. #endif
  1982. #endif
  1983. return shadow;
  1984. }`,oxe=`#ifdef USE_SKINNING
  1985. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  1986. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  1987. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  1988. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  1989. #endif`,lxe=`#ifdef USE_SKINNING
  1990. uniform mat4 bindMatrix;
  1991. uniform mat4 bindMatrixInverse;
  1992. uniform highp sampler2D boneTexture;
  1993. mat4 getBoneMatrix( const in float i ) {
  1994. int size = textureSize( boneTexture, 0 ).x;
  1995. int j = int( i ) * 4;
  1996. int x = j % size;
  1997. int y = j / size;
  1998. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  1999. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  2000. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  2001. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  2002. return mat4( v1, v2, v3, v4 );
  2003. }
  2004. #endif`,cxe=`#ifdef USE_SKINNING
  2005. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  2006. vec4 skinned = vec4( 0.0 );
  2007. skinned += boneMatX * skinVertex * skinWeight.x;
  2008. skinned += boneMatY * skinVertex * skinWeight.y;
  2009. skinned += boneMatZ * skinVertex * skinWeight.z;
  2010. skinned += boneMatW * skinVertex * skinWeight.w;
  2011. transformed = ( bindMatrixInverse * skinned ).xyz;
  2012. #endif`,uxe=`#ifdef USE_SKINNING
  2013. mat4 skinMatrix = mat4( 0.0 );
  2014. skinMatrix += skinWeight.x * boneMatX;
  2015. skinMatrix += skinWeight.y * boneMatY;
  2016. skinMatrix += skinWeight.z * boneMatZ;
  2017. skinMatrix += skinWeight.w * boneMatW;
  2018. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  2019. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  2020. #ifdef USE_TANGENT
  2021. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  2022. #endif
  2023. #endif`,dxe=`float specularStrength;
  2024. #ifdef USE_SPECULARMAP
  2025. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  2026. specularStrength = texelSpecular.r;
  2027. #else
  2028. specularStrength = 1.0;
  2029. #endif`,hxe=`#ifdef USE_SPECULARMAP
  2030. uniform sampler2D specularMap;
  2031. #endif`,fxe=`#if defined( TONE_MAPPING )
  2032. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  2033. #endif`,mxe=`#ifndef saturate
  2034. #define saturate( a ) clamp( a, 0.0, 1.0 )
  2035. #endif
  2036. uniform float toneMappingExposure;
  2037. vec3 LinearToneMapping( vec3 color ) {
  2038. return saturate( toneMappingExposure * color );
  2039. }
  2040. vec3 ReinhardToneMapping( vec3 color ) {
  2041. color *= toneMappingExposure;
  2042. return saturate( color / ( vec3( 1.0 ) + color ) );
  2043. }
  2044. vec3 CineonToneMapping( vec3 color ) {
  2045. color *= toneMappingExposure;
  2046. color = max( vec3( 0.0 ), color - 0.004 );
  2047. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  2048. }
  2049. vec3 RRTAndODTFit( vec3 v ) {
  2050. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  2051. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  2052. return a / b;
  2053. }
  2054. vec3 ACESFilmicToneMapping( vec3 color ) {
  2055. const mat3 ACESInputMat = mat3(
  2056. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  2057. vec3( 0.04823, 0.01566, 0.83777 )
  2058. );
  2059. const mat3 ACESOutputMat = mat3(
  2060. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  2061. vec3( -0.07367, -0.00605, 1.07602 )
  2062. );
  2063. color *= toneMappingExposure / 0.6;
  2064. color = ACESInputMat * color;
  2065. color = RRTAndODTFit( color );
  2066. color = ACESOutputMat * color;
  2067. return saturate( color );
  2068. }
  2069. const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
  2070. vec3( 1.6605, - 0.1246, - 0.0182 ),
  2071. vec3( - 0.5876, 1.1329, - 0.1006 ),
  2072. vec3( - 0.0728, - 0.0083, 1.1187 )
  2073. );
  2074. const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
  2075. vec3( 0.6274, 0.0691, 0.0164 ),
  2076. vec3( 0.3293, 0.9195, 0.0880 ),
  2077. vec3( 0.0433, 0.0113, 0.8956 )
  2078. );
  2079. vec3 agxDefaultContrastApprox( vec3 x ) {
  2080. vec3 x2 = x * x;
  2081. vec3 x4 = x2 * x2;
  2082. return + 15.5 * x4 * x2
  2083. - 40.14 * x4 * x
  2084. + 31.96 * x4
  2085. - 6.868 * x2 * x
  2086. + 0.4298 * x2
  2087. + 0.1191 * x
  2088. - 0.00232;
  2089. }
  2090. vec3 AgXToneMapping( vec3 color ) {
  2091. const mat3 AgXInsetMatrix = mat3(
  2092. vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
  2093. vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
  2094. vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
  2095. );
  2096. const mat3 AgXOutsetMatrix = mat3(
  2097. vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
  2098. vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
  2099. vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
  2100. );
  2101. const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
  2102. color *= toneMappingExposure;
  2103. color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
  2104. color = AgXInsetMatrix * color;
  2105. color = max( color, 1e-10 ); color = log2( color );
  2106. color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
  2107. color = clamp( color, 0.0, 1.0 );
  2108. color = agxDefaultContrastApprox( color );
  2109. color = AgXOutsetMatrix * color;
  2110. color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
  2111. color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
  2112. color = clamp( color, 0.0, 1.0 );
  2113. return color;
  2114. }
  2115. vec3 NeutralToneMapping( vec3 color ) {
  2116. const float StartCompression = 0.8 - 0.04;
  2117. const float Desaturation = 0.15;
  2118. color *= toneMappingExposure;
  2119. float x = min( color.r, min( color.g, color.b ) );
  2120. float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
  2121. color -= offset;
  2122. float peak = max( color.r, max( color.g, color.b ) );
  2123. if ( peak < StartCompression ) return color;
  2124. float d = 1. - StartCompression;
  2125. float newPeak = 1. - d * d / ( peak + d - StartCompression );
  2126. color *= newPeak / peak;
  2127. float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
  2128. return mix( color, vec3( newPeak ), g );
  2129. }
  2130. vec3 CustomToneMapping( vec3 color ) { return color; }`,pxe=`#ifdef USE_TRANSMISSION
  2131. material.transmission = transmission;
  2132. material.transmissionAlpha = 1.0;
  2133. material.thickness = thickness;
  2134. material.attenuationDistance = attenuationDistance;
  2135. material.attenuationColor = attenuationColor;
  2136. #ifdef USE_TRANSMISSIONMAP
  2137. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  2138. #endif
  2139. #ifdef USE_THICKNESSMAP
  2140. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  2141. #endif
  2142. vec3 pos = vWorldPosition;
  2143. vec3 v = normalize( cameraPosition - pos );
  2144. vec3 n = inverseTransformDirection( normal, viewMatrix );
  2145. vec4 transmitted = getIBLVolumeRefraction(
  2146. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  2147. pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
  2148. material.attenuationColor, material.attenuationDistance );
  2149. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  2150. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  2151. #endif`,gxe=`#ifdef USE_TRANSMISSION
  2152. uniform float transmission;
  2153. uniform float thickness;
  2154. uniform float attenuationDistance;
  2155. uniform vec3 attenuationColor;
  2156. #ifdef USE_TRANSMISSIONMAP
  2157. uniform sampler2D transmissionMap;
  2158. #endif
  2159. #ifdef USE_THICKNESSMAP
  2160. uniform sampler2D thicknessMap;
  2161. #endif
  2162. uniform vec2 transmissionSamplerSize;
  2163. uniform sampler2D transmissionSamplerMap;
  2164. uniform mat4 modelMatrix;
  2165. uniform mat4 projectionMatrix;
  2166. varying vec3 vWorldPosition;
  2167. float w0( float a ) {
  2168. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  2169. }
  2170. float w1( float a ) {
  2171. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  2172. }
  2173. float w2( float a ){
  2174. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  2175. }
  2176. float w3( float a ) {
  2177. return ( 1.0 / 6.0 ) * ( a * a * a );
  2178. }
  2179. float g0( float a ) {
  2180. return w0( a ) + w1( a );
  2181. }
  2182. float g1( float a ) {
  2183. return w2( a ) + w3( a );
  2184. }
  2185. float h0( float a ) {
  2186. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  2187. }
  2188. float h1( float a ) {
  2189. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  2190. }
  2191. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  2192. uv = uv * texelSize.zw + 0.5;
  2193. vec2 iuv = floor( uv );
  2194. vec2 fuv = fract( uv );
  2195. float g0x = g0( fuv.x );
  2196. float g1x = g1( fuv.x );
  2197. float h0x = h0( fuv.x );
  2198. float h1x = h1( fuv.x );
  2199. float h0y = h0( fuv.y );
  2200. float h1y = h1( fuv.y );
  2201. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2202. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2203. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2204. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2205. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  2206. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  2207. }
  2208. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  2209. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  2210. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  2211. vec2 fLodSizeInv = 1.0 / fLodSize;
  2212. vec2 cLodSizeInv = 1.0 / cLodSize;
  2213. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  2214. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  2215. return mix( fSample, cSample, fract( lod ) );
  2216. }
  2217. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  2218. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  2219. vec3 modelScale;
  2220. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  2221. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  2222. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  2223. return normalize( refractionVector ) * thickness * modelScale;
  2224. }
  2225. float applyIorToRoughness( const in float roughness, const in float ior ) {
  2226. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  2227. }
  2228. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  2229. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  2230. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  2231. }
  2232. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  2233. if ( isinf( attenuationDistance ) ) {
  2234. return vec3( 1.0 );
  2235. } else {
  2236. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  2237. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  2238. }
  2239. }
  2240. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  2241. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  2242. const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
  2243. const in vec3 attenuationColor, const in float attenuationDistance ) {
  2244. vec4 transmittedLight;
  2245. vec3 transmittance;
  2246. #ifdef USE_DISPERSION
  2247. float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
  2248. vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
  2249. for ( int i = 0; i < 3; i ++ ) {
  2250. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
  2251. vec3 refractedRayExit = position + transmissionRay;
  2252. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2253. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2254. refractionCoords += 1.0;
  2255. refractionCoords /= 2.0;
  2256. vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
  2257. transmittedLight[ i ] = transmissionSample[ i ];
  2258. transmittedLight.a += transmissionSample.a;
  2259. transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
  2260. }
  2261. transmittedLight.a /= 3.0;
  2262. #else
  2263. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  2264. vec3 refractedRayExit = position + transmissionRay;
  2265. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2266. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2267. refractionCoords += 1.0;
  2268. refractionCoords /= 2.0;
  2269. transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  2270. transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  2271. #endif
  2272. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  2273. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  2274. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  2275. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  2276. }
  2277. #endif`,xxe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2278. varying vec2 vUv;
  2279. #endif
  2280. #ifdef USE_MAP
  2281. varying vec2 vMapUv;
  2282. #endif
  2283. #ifdef USE_ALPHAMAP
  2284. varying vec2 vAlphaMapUv;
  2285. #endif
  2286. #ifdef USE_LIGHTMAP
  2287. varying vec2 vLightMapUv;
  2288. #endif
  2289. #ifdef USE_AOMAP
  2290. varying vec2 vAoMapUv;
  2291. #endif
  2292. #ifdef USE_BUMPMAP
  2293. varying vec2 vBumpMapUv;
  2294. #endif
  2295. #ifdef USE_NORMALMAP
  2296. varying vec2 vNormalMapUv;
  2297. #endif
  2298. #ifdef USE_EMISSIVEMAP
  2299. varying vec2 vEmissiveMapUv;
  2300. #endif
  2301. #ifdef USE_METALNESSMAP
  2302. varying vec2 vMetalnessMapUv;
  2303. #endif
  2304. #ifdef USE_ROUGHNESSMAP
  2305. varying vec2 vRoughnessMapUv;
  2306. #endif
  2307. #ifdef USE_ANISOTROPYMAP
  2308. varying vec2 vAnisotropyMapUv;
  2309. #endif
  2310. #ifdef USE_CLEARCOATMAP
  2311. varying vec2 vClearcoatMapUv;
  2312. #endif
  2313. #ifdef USE_CLEARCOAT_NORMALMAP
  2314. varying vec2 vClearcoatNormalMapUv;
  2315. #endif
  2316. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2317. varying vec2 vClearcoatRoughnessMapUv;
  2318. #endif
  2319. #ifdef USE_IRIDESCENCEMAP
  2320. varying vec2 vIridescenceMapUv;
  2321. #endif
  2322. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2323. varying vec2 vIridescenceThicknessMapUv;
  2324. #endif
  2325. #ifdef USE_SHEEN_COLORMAP
  2326. varying vec2 vSheenColorMapUv;
  2327. #endif
  2328. #ifdef USE_SHEEN_ROUGHNESSMAP
  2329. varying vec2 vSheenRoughnessMapUv;
  2330. #endif
  2331. #ifdef USE_SPECULARMAP
  2332. varying vec2 vSpecularMapUv;
  2333. #endif
  2334. #ifdef USE_SPECULAR_COLORMAP
  2335. varying vec2 vSpecularColorMapUv;
  2336. #endif
  2337. #ifdef USE_SPECULAR_INTENSITYMAP
  2338. varying vec2 vSpecularIntensityMapUv;
  2339. #endif
  2340. #ifdef USE_TRANSMISSIONMAP
  2341. uniform mat3 transmissionMapTransform;
  2342. varying vec2 vTransmissionMapUv;
  2343. #endif
  2344. #ifdef USE_THICKNESSMAP
  2345. uniform mat3 thicknessMapTransform;
  2346. varying vec2 vThicknessMapUv;
  2347. #endif`,bxe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2348. varying vec2 vUv;
  2349. #endif
  2350. #ifdef USE_MAP
  2351. uniform mat3 mapTransform;
  2352. varying vec2 vMapUv;
  2353. #endif
  2354. #ifdef USE_ALPHAMAP
  2355. uniform mat3 alphaMapTransform;
  2356. varying vec2 vAlphaMapUv;
  2357. #endif
  2358. #ifdef USE_LIGHTMAP
  2359. uniform mat3 lightMapTransform;
  2360. varying vec2 vLightMapUv;
  2361. #endif
  2362. #ifdef USE_AOMAP
  2363. uniform mat3 aoMapTransform;
  2364. varying vec2 vAoMapUv;
  2365. #endif
  2366. #ifdef USE_BUMPMAP
  2367. uniform mat3 bumpMapTransform;
  2368. varying vec2 vBumpMapUv;
  2369. #endif
  2370. #ifdef USE_NORMALMAP
  2371. uniform mat3 normalMapTransform;
  2372. varying vec2 vNormalMapUv;
  2373. #endif
  2374. #ifdef USE_DISPLACEMENTMAP
  2375. uniform mat3 displacementMapTransform;
  2376. varying vec2 vDisplacementMapUv;
  2377. #endif
  2378. #ifdef USE_EMISSIVEMAP
  2379. uniform mat3 emissiveMapTransform;
  2380. varying vec2 vEmissiveMapUv;
  2381. #endif
  2382. #ifdef USE_METALNESSMAP
  2383. uniform mat3 metalnessMapTransform;
  2384. varying vec2 vMetalnessMapUv;
  2385. #endif
  2386. #ifdef USE_ROUGHNESSMAP
  2387. uniform mat3 roughnessMapTransform;
  2388. varying vec2 vRoughnessMapUv;
  2389. #endif
  2390. #ifdef USE_ANISOTROPYMAP
  2391. uniform mat3 anisotropyMapTransform;
  2392. varying vec2 vAnisotropyMapUv;
  2393. #endif
  2394. #ifdef USE_CLEARCOATMAP
  2395. uniform mat3 clearcoatMapTransform;
  2396. varying vec2 vClearcoatMapUv;
  2397. #endif
  2398. #ifdef USE_CLEARCOAT_NORMALMAP
  2399. uniform mat3 clearcoatNormalMapTransform;
  2400. varying vec2 vClearcoatNormalMapUv;
  2401. #endif
  2402. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2403. uniform mat3 clearcoatRoughnessMapTransform;
  2404. varying vec2 vClearcoatRoughnessMapUv;
  2405. #endif
  2406. #ifdef USE_SHEEN_COLORMAP
  2407. uniform mat3 sheenColorMapTransform;
  2408. varying vec2 vSheenColorMapUv;
  2409. #endif
  2410. #ifdef USE_SHEEN_ROUGHNESSMAP
  2411. uniform mat3 sheenRoughnessMapTransform;
  2412. varying vec2 vSheenRoughnessMapUv;
  2413. #endif
  2414. #ifdef USE_IRIDESCENCEMAP
  2415. uniform mat3 iridescenceMapTransform;
  2416. varying vec2 vIridescenceMapUv;
  2417. #endif
  2418. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2419. uniform mat3 iridescenceThicknessMapTransform;
  2420. varying vec2 vIridescenceThicknessMapUv;
  2421. #endif
  2422. #ifdef USE_SPECULARMAP
  2423. uniform mat3 specularMapTransform;
  2424. varying vec2 vSpecularMapUv;
  2425. #endif
  2426. #ifdef USE_SPECULAR_COLORMAP
  2427. uniform mat3 specularColorMapTransform;
  2428. varying vec2 vSpecularColorMapUv;
  2429. #endif
  2430. #ifdef USE_SPECULAR_INTENSITYMAP
  2431. uniform mat3 specularIntensityMapTransform;
  2432. varying vec2 vSpecularIntensityMapUv;
  2433. #endif
  2434. #ifdef USE_TRANSMISSIONMAP
  2435. uniform mat3 transmissionMapTransform;
  2436. varying vec2 vTransmissionMapUv;
  2437. #endif
  2438. #ifdef USE_THICKNESSMAP
  2439. uniform mat3 thicknessMapTransform;
  2440. varying vec2 vThicknessMapUv;
  2441. #endif`,yxe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2442. vUv = vec3( uv, 1 ).xy;
  2443. #endif
  2444. #ifdef USE_MAP
  2445. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  2446. #endif
  2447. #ifdef USE_ALPHAMAP
  2448. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  2449. #endif
  2450. #ifdef USE_LIGHTMAP
  2451. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  2452. #endif
  2453. #ifdef USE_AOMAP
  2454. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  2455. #endif
  2456. #ifdef USE_BUMPMAP
  2457. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  2458. #endif
  2459. #ifdef USE_NORMALMAP
  2460. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  2461. #endif
  2462. #ifdef USE_DISPLACEMENTMAP
  2463. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  2464. #endif
  2465. #ifdef USE_EMISSIVEMAP
  2466. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  2467. #endif
  2468. #ifdef USE_METALNESSMAP
  2469. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  2470. #endif
  2471. #ifdef USE_ROUGHNESSMAP
  2472. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  2473. #endif
  2474. #ifdef USE_ANISOTROPYMAP
  2475. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  2476. #endif
  2477. #ifdef USE_CLEARCOATMAP
  2478. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  2479. #endif
  2480. #ifdef USE_CLEARCOAT_NORMALMAP
  2481. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  2482. #endif
  2483. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2484. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  2485. #endif
  2486. #ifdef USE_IRIDESCENCEMAP
  2487. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  2488. #endif
  2489. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2490. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  2491. #endif
  2492. #ifdef USE_SHEEN_COLORMAP
  2493. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  2494. #endif
  2495. #ifdef USE_SHEEN_ROUGHNESSMAP
  2496. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  2497. #endif
  2498. #ifdef USE_SPECULARMAP
  2499. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  2500. #endif
  2501. #ifdef USE_SPECULAR_COLORMAP
  2502. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  2503. #endif
  2504. #ifdef USE_SPECULAR_INTENSITYMAP
  2505. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  2506. #endif
  2507. #ifdef USE_TRANSMISSIONMAP
  2508. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  2509. #endif
  2510. #ifdef USE_THICKNESSMAP
  2511. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  2512. #endif`,vxe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  2513. vec4 worldPosition = vec4( transformed, 1.0 );
  2514. #ifdef USE_BATCHING
  2515. worldPosition = batchingMatrix * worldPosition;
  2516. #endif
  2517. #ifdef USE_INSTANCING
  2518. worldPosition = instanceMatrix * worldPosition;
  2519. #endif
  2520. worldPosition = modelMatrix * worldPosition;
  2521. #endif`;const _xe=`varying vec2 vUv;
  2522. uniform mat3 uvTransform;
  2523. void main() {
  2524. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  2525. gl_Position = vec4( position.xy, 1.0, 1.0 );
  2526. }`,wxe=`uniform sampler2D t2D;
  2527. uniform float backgroundIntensity;
  2528. varying vec2 vUv;
  2529. void main() {
  2530. vec4 texColor = texture2D( t2D, vUv );
  2531. #ifdef DECODE_VIDEO_TEXTURE
  2532. 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 );
  2533. #endif
  2534. texColor.rgb *= backgroundIntensity;
  2535. gl_FragColor = texColor;
  2536. #include <tonemapping_fragment>
  2537. #include <colorspace_fragment>
  2538. }`,Sxe=`varying vec3 vWorldDirection;
  2539. #include <common>
  2540. void main() {
  2541. vWorldDirection = transformDirection( position, modelMatrix );
  2542. #include <begin_vertex>
  2543. #include <project_vertex>
  2544. gl_Position.z = gl_Position.w;
  2545. }`,Nxe=`#ifdef ENVMAP_TYPE_CUBE
  2546. uniform samplerCube envMap;
  2547. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2548. uniform sampler2D envMap;
  2549. #endif
  2550. uniform float flipEnvMap;
  2551. uniform float backgroundBlurriness;
  2552. uniform float backgroundIntensity;
  2553. uniform mat3 backgroundRotation;
  2554. varying vec3 vWorldDirection;
  2555. #include <cube_uv_reflection_fragment>
  2556. void main() {
  2557. #ifdef ENVMAP_TYPE_CUBE
  2558. vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  2559. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2560. vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
  2561. #else
  2562. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  2563. #endif
  2564. texColor.rgb *= backgroundIntensity;
  2565. gl_FragColor = texColor;
  2566. #include <tonemapping_fragment>
  2567. #include <colorspace_fragment>
  2568. }`,Mxe=`varying vec3 vWorldDirection;
  2569. #include <common>
  2570. void main() {
  2571. vWorldDirection = transformDirection( position, modelMatrix );
  2572. #include <begin_vertex>
  2573. #include <project_vertex>
  2574. gl_Position.z = gl_Position.w;
  2575. }`,Exe=`uniform samplerCube tCube;
  2576. uniform float tFlip;
  2577. uniform float opacity;
  2578. varying vec3 vWorldDirection;
  2579. void main() {
  2580. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  2581. gl_FragColor = texColor;
  2582. gl_FragColor.a *= opacity;
  2583. #include <tonemapping_fragment>
  2584. #include <colorspace_fragment>
  2585. }`,Cxe=`#include <common>
  2586. #include <batching_pars_vertex>
  2587. #include <uv_pars_vertex>
  2588. #include <displacementmap_pars_vertex>
  2589. #include <morphtarget_pars_vertex>
  2590. #include <skinning_pars_vertex>
  2591. #include <logdepthbuf_pars_vertex>
  2592. #include <clipping_planes_pars_vertex>
  2593. varying vec2 vHighPrecisionZW;
  2594. void main() {
  2595. #include <uv_vertex>
  2596. #include <batching_vertex>
  2597. #include <skinbase_vertex>
  2598. #include <morphinstance_vertex>
  2599. #ifdef USE_DISPLACEMENTMAP
  2600. #include <beginnormal_vertex>
  2601. #include <morphnormal_vertex>
  2602. #include <skinnormal_vertex>
  2603. #endif
  2604. #include <begin_vertex>
  2605. #include <morphtarget_vertex>
  2606. #include <skinning_vertex>
  2607. #include <displacementmap_vertex>
  2608. #include <project_vertex>
  2609. #include <logdepthbuf_vertex>
  2610. #include <clipping_planes_vertex>
  2611. vHighPrecisionZW = gl_Position.zw;
  2612. }`,Txe=`#if DEPTH_PACKING == 3200
  2613. uniform float opacity;
  2614. #endif
  2615. #include <common>
  2616. #include <packing>
  2617. #include <uv_pars_fragment>
  2618. #include <map_pars_fragment>
  2619. #include <alphamap_pars_fragment>
  2620. #include <alphatest_pars_fragment>
  2621. #include <alphahash_pars_fragment>
  2622. #include <logdepthbuf_pars_fragment>
  2623. #include <clipping_planes_pars_fragment>
  2624. varying vec2 vHighPrecisionZW;
  2625. void main() {
  2626. vec4 diffuseColor = vec4( 1.0 );
  2627. #include <clipping_planes_fragment>
  2628. #if DEPTH_PACKING == 3200
  2629. diffuseColor.a = opacity;
  2630. #endif
  2631. #include <map_fragment>
  2632. #include <alphamap_fragment>
  2633. #include <alphatest_fragment>
  2634. #include <alphahash_fragment>
  2635. #include <logdepthbuf_fragment>
  2636. #ifdef USE_REVERSED_DEPTH_BUFFER
  2637. float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
  2638. #else
  2639. float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
  2640. #endif
  2641. #if DEPTH_PACKING == 3200
  2642. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  2643. #elif DEPTH_PACKING == 3201
  2644. gl_FragColor = packDepthToRGBA( fragCoordZ );
  2645. #elif DEPTH_PACKING == 3202
  2646. gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
  2647. #elif DEPTH_PACKING == 3203
  2648. gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
  2649. #endif
  2650. }`,Axe=`#define DISTANCE
  2651. varying vec3 vWorldPosition;
  2652. #include <common>
  2653. #include <batching_pars_vertex>
  2654. #include <uv_pars_vertex>
  2655. #include <displacementmap_pars_vertex>
  2656. #include <morphtarget_pars_vertex>
  2657. #include <skinning_pars_vertex>
  2658. #include <clipping_planes_pars_vertex>
  2659. void main() {
  2660. #include <uv_vertex>
  2661. #include <batching_vertex>
  2662. #include <skinbase_vertex>
  2663. #include <morphinstance_vertex>
  2664. #ifdef USE_DISPLACEMENTMAP
  2665. #include <beginnormal_vertex>
  2666. #include <morphnormal_vertex>
  2667. #include <skinnormal_vertex>
  2668. #endif
  2669. #include <begin_vertex>
  2670. #include <morphtarget_vertex>
  2671. #include <skinning_vertex>
  2672. #include <displacementmap_vertex>
  2673. #include <project_vertex>
  2674. #include <worldpos_vertex>
  2675. #include <clipping_planes_vertex>
  2676. vWorldPosition = worldPosition.xyz;
  2677. }`,kxe=`#define DISTANCE
  2678. uniform vec3 referencePosition;
  2679. uniform float nearDistance;
  2680. uniform float farDistance;
  2681. varying vec3 vWorldPosition;
  2682. #include <common>
  2683. #include <packing>
  2684. #include <uv_pars_fragment>
  2685. #include <map_pars_fragment>
  2686. #include <alphamap_pars_fragment>
  2687. #include <alphatest_pars_fragment>
  2688. #include <alphahash_pars_fragment>
  2689. #include <clipping_planes_pars_fragment>
  2690. void main () {
  2691. vec4 diffuseColor = vec4( 1.0 );
  2692. #include <clipping_planes_fragment>
  2693. #include <map_fragment>
  2694. #include <alphamap_fragment>
  2695. #include <alphatest_fragment>
  2696. #include <alphahash_fragment>
  2697. float dist = length( vWorldPosition - referencePosition );
  2698. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  2699. dist = saturate( dist );
  2700. gl_FragColor = packDepthToRGBA( dist );
  2701. }`,jxe=`varying vec3 vWorldDirection;
  2702. #include <common>
  2703. void main() {
  2704. vWorldDirection = transformDirection( position, modelMatrix );
  2705. #include <begin_vertex>
  2706. #include <project_vertex>
  2707. }`,Pxe=`uniform sampler2D tEquirect;
  2708. varying vec3 vWorldDirection;
  2709. #include <common>
  2710. void main() {
  2711. vec3 direction = normalize( vWorldDirection );
  2712. vec2 sampleUV = equirectUv( direction );
  2713. gl_FragColor = texture2D( tEquirect, sampleUV );
  2714. #include <tonemapping_fragment>
  2715. #include <colorspace_fragment>
  2716. }`,Rxe=`uniform float scale;
  2717. attribute float lineDistance;
  2718. varying float vLineDistance;
  2719. #include <common>
  2720. #include <uv_pars_vertex>
  2721. #include <color_pars_vertex>
  2722. #include <fog_pars_vertex>
  2723. #include <morphtarget_pars_vertex>
  2724. #include <logdepthbuf_pars_vertex>
  2725. #include <clipping_planes_pars_vertex>
  2726. void main() {
  2727. vLineDistance = scale * lineDistance;
  2728. #include <uv_vertex>
  2729. #include <color_vertex>
  2730. #include <morphinstance_vertex>
  2731. #include <morphcolor_vertex>
  2732. #include <begin_vertex>
  2733. #include <morphtarget_vertex>
  2734. #include <project_vertex>
  2735. #include <logdepthbuf_vertex>
  2736. #include <clipping_planes_vertex>
  2737. #include <fog_vertex>
  2738. }`,Dxe=`uniform vec3 diffuse;
  2739. uniform float opacity;
  2740. uniform float dashSize;
  2741. uniform float totalSize;
  2742. varying float vLineDistance;
  2743. #include <common>
  2744. #include <color_pars_fragment>
  2745. #include <uv_pars_fragment>
  2746. #include <map_pars_fragment>
  2747. #include <fog_pars_fragment>
  2748. #include <logdepthbuf_pars_fragment>
  2749. #include <clipping_planes_pars_fragment>
  2750. void main() {
  2751. vec4 diffuseColor = vec4( diffuse, opacity );
  2752. #include <clipping_planes_fragment>
  2753. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  2754. discard;
  2755. }
  2756. vec3 outgoingLight = vec3( 0.0 );
  2757. #include <logdepthbuf_fragment>
  2758. #include <map_fragment>
  2759. #include <color_fragment>
  2760. outgoingLight = diffuseColor.rgb;
  2761. #include <opaque_fragment>
  2762. #include <tonemapping_fragment>
  2763. #include <colorspace_fragment>
  2764. #include <fog_fragment>
  2765. #include <premultiplied_alpha_fragment>
  2766. }`,Oxe=`#include <common>
  2767. #include <batching_pars_vertex>
  2768. #include <uv_pars_vertex>
  2769. #include <envmap_pars_vertex>
  2770. #include <color_pars_vertex>
  2771. #include <fog_pars_vertex>
  2772. #include <morphtarget_pars_vertex>
  2773. #include <skinning_pars_vertex>
  2774. #include <logdepthbuf_pars_vertex>
  2775. #include <clipping_planes_pars_vertex>
  2776. void main() {
  2777. #include <uv_vertex>
  2778. #include <color_vertex>
  2779. #include <morphinstance_vertex>
  2780. #include <morphcolor_vertex>
  2781. #include <batching_vertex>
  2782. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  2783. #include <beginnormal_vertex>
  2784. #include <morphnormal_vertex>
  2785. #include <skinbase_vertex>
  2786. #include <skinnormal_vertex>
  2787. #include <defaultnormal_vertex>
  2788. #endif
  2789. #include <begin_vertex>
  2790. #include <morphtarget_vertex>
  2791. #include <skinning_vertex>
  2792. #include <project_vertex>
  2793. #include <logdepthbuf_vertex>
  2794. #include <clipping_planes_vertex>
  2795. #include <worldpos_vertex>
  2796. #include <envmap_vertex>
  2797. #include <fog_vertex>
  2798. }`,Lxe=`uniform vec3 diffuse;
  2799. uniform float opacity;
  2800. #ifndef FLAT_SHADED
  2801. varying vec3 vNormal;
  2802. #endif
  2803. #include <common>
  2804. #include <dithering_pars_fragment>
  2805. #include <color_pars_fragment>
  2806. #include <uv_pars_fragment>
  2807. #include <map_pars_fragment>
  2808. #include <alphamap_pars_fragment>
  2809. #include <alphatest_pars_fragment>
  2810. #include <alphahash_pars_fragment>
  2811. #include <aomap_pars_fragment>
  2812. #include <lightmap_pars_fragment>
  2813. #include <envmap_common_pars_fragment>
  2814. #include <envmap_pars_fragment>
  2815. #include <fog_pars_fragment>
  2816. #include <specularmap_pars_fragment>
  2817. #include <logdepthbuf_pars_fragment>
  2818. #include <clipping_planes_pars_fragment>
  2819. void main() {
  2820. vec4 diffuseColor = vec4( diffuse, opacity );
  2821. #include <clipping_planes_fragment>
  2822. #include <logdepthbuf_fragment>
  2823. #include <map_fragment>
  2824. #include <color_fragment>
  2825. #include <alphamap_fragment>
  2826. #include <alphatest_fragment>
  2827. #include <alphahash_fragment>
  2828. #include <specularmap_fragment>
  2829. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2830. #ifdef USE_LIGHTMAP
  2831. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  2832. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  2833. #else
  2834. reflectedLight.indirectDiffuse += vec3( 1.0 );
  2835. #endif
  2836. #include <aomap_fragment>
  2837. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  2838. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  2839. #include <envmap_fragment>
  2840. #include <opaque_fragment>
  2841. #include <tonemapping_fragment>
  2842. #include <colorspace_fragment>
  2843. #include <fog_fragment>
  2844. #include <premultiplied_alpha_fragment>
  2845. #include <dithering_fragment>
  2846. }`,Ixe=`#define LAMBERT
  2847. varying vec3 vViewPosition;
  2848. #include <common>
  2849. #include <batching_pars_vertex>
  2850. #include <uv_pars_vertex>
  2851. #include <displacementmap_pars_vertex>
  2852. #include <envmap_pars_vertex>
  2853. #include <color_pars_vertex>
  2854. #include <fog_pars_vertex>
  2855. #include <normal_pars_vertex>
  2856. #include <morphtarget_pars_vertex>
  2857. #include <skinning_pars_vertex>
  2858. #include <shadowmap_pars_vertex>
  2859. #include <logdepthbuf_pars_vertex>
  2860. #include <clipping_planes_pars_vertex>
  2861. void main() {
  2862. #include <uv_vertex>
  2863. #include <color_vertex>
  2864. #include <morphinstance_vertex>
  2865. #include <morphcolor_vertex>
  2866. #include <batching_vertex>
  2867. #include <beginnormal_vertex>
  2868. #include <morphnormal_vertex>
  2869. #include <skinbase_vertex>
  2870. #include <skinnormal_vertex>
  2871. #include <defaultnormal_vertex>
  2872. #include <normal_vertex>
  2873. #include <begin_vertex>
  2874. #include <morphtarget_vertex>
  2875. #include <skinning_vertex>
  2876. #include <displacementmap_vertex>
  2877. #include <project_vertex>
  2878. #include <logdepthbuf_vertex>
  2879. #include <clipping_planes_vertex>
  2880. vViewPosition = - mvPosition.xyz;
  2881. #include <worldpos_vertex>
  2882. #include <envmap_vertex>
  2883. #include <shadowmap_vertex>
  2884. #include <fog_vertex>
  2885. }`,Fxe=`#define LAMBERT
  2886. uniform vec3 diffuse;
  2887. uniform vec3 emissive;
  2888. uniform float opacity;
  2889. #include <common>
  2890. #include <packing>
  2891. #include <dithering_pars_fragment>
  2892. #include <color_pars_fragment>
  2893. #include <uv_pars_fragment>
  2894. #include <map_pars_fragment>
  2895. #include <alphamap_pars_fragment>
  2896. #include <alphatest_pars_fragment>
  2897. #include <alphahash_pars_fragment>
  2898. #include <aomap_pars_fragment>
  2899. #include <lightmap_pars_fragment>
  2900. #include <emissivemap_pars_fragment>
  2901. #include <envmap_common_pars_fragment>
  2902. #include <envmap_pars_fragment>
  2903. #include <fog_pars_fragment>
  2904. #include <bsdfs>
  2905. #include <lights_pars_begin>
  2906. #include <normal_pars_fragment>
  2907. #include <lights_lambert_pars_fragment>
  2908. #include <shadowmap_pars_fragment>
  2909. #include <bumpmap_pars_fragment>
  2910. #include <normalmap_pars_fragment>
  2911. #include <specularmap_pars_fragment>
  2912. #include <logdepthbuf_pars_fragment>
  2913. #include <clipping_planes_pars_fragment>
  2914. void main() {
  2915. vec4 diffuseColor = vec4( diffuse, opacity );
  2916. #include <clipping_planes_fragment>
  2917. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2918. vec3 totalEmissiveRadiance = emissive;
  2919. #include <logdepthbuf_fragment>
  2920. #include <map_fragment>
  2921. #include <color_fragment>
  2922. #include <alphamap_fragment>
  2923. #include <alphatest_fragment>
  2924. #include <alphahash_fragment>
  2925. #include <specularmap_fragment>
  2926. #include <normal_fragment_begin>
  2927. #include <normal_fragment_maps>
  2928. #include <emissivemap_fragment>
  2929. #include <lights_lambert_fragment>
  2930. #include <lights_fragment_begin>
  2931. #include <lights_fragment_maps>
  2932. #include <lights_fragment_end>
  2933. #include <aomap_fragment>
  2934. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  2935. #include <envmap_fragment>
  2936. #include <opaque_fragment>
  2937. #include <tonemapping_fragment>
  2938. #include <colorspace_fragment>
  2939. #include <fog_fragment>
  2940. #include <premultiplied_alpha_fragment>
  2941. #include <dithering_fragment>
  2942. }`,Uxe=`#define MATCAP
  2943. varying vec3 vViewPosition;
  2944. #include <common>
  2945. #include <batching_pars_vertex>
  2946. #include <uv_pars_vertex>
  2947. #include <color_pars_vertex>
  2948. #include <displacementmap_pars_vertex>
  2949. #include <fog_pars_vertex>
  2950. #include <normal_pars_vertex>
  2951. #include <morphtarget_pars_vertex>
  2952. #include <skinning_pars_vertex>
  2953. #include <logdepthbuf_pars_vertex>
  2954. #include <clipping_planes_pars_vertex>
  2955. void main() {
  2956. #include <uv_vertex>
  2957. #include <color_vertex>
  2958. #include <morphinstance_vertex>
  2959. #include <morphcolor_vertex>
  2960. #include <batching_vertex>
  2961. #include <beginnormal_vertex>
  2962. #include <morphnormal_vertex>
  2963. #include <skinbase_vertex>
  2964. #include <skinnormal_vertex>
  2965. #include <defaultnormal_vertex>
  2966. #include <normal_vertex>
  2967. #include <begin_vertex>
  2968. #include <morphtarget_vertex>
  2969. #include <skinning_vertex>
  2970. #include <displacementmap_vertex>
  2971. #include <project_vertex>
  2972. #include <logdepthbuf_vertex>
  2973. #include <clipping_planes_vertex>
  2974. #include <fog_vertex>
  2975. vViewPosition = - mvPosition.xyz;
  2976. }`,zxe=`#define MATCAP
  2977. uniform vec3 diffuse;
  2978. uniform float opacity;
  2979. uniform sampler2D matcap;
  2980. varying vec3 vViewPosition;
  2981. #include <common>
  2982. #include <dithering_pars_fragment>
  2983. #include <color_pars_fragment>
  2984. #include <uv_pars_fragment>
  2985. #include <map_pars_fragment>
  2986. #include <alphamap_pars_fragment>
  2987. #include <alphatest_pars_fragment>
  2988. #include <alphahash_pars_fragment>
  2989. #include <fog_pars_fragment>
  2990. #include <normal_pars_fragment>
  2991. #include <bumpmap_pars_fragment>
  2992. #include <normalmap_pars_fragment>
  2993. #include <logdepthbuf_pars_fragment>
  2994. #include <clipping_planes_pars_fragment>
  2995. void main() {
  2996. vec4 diffuseColor = vec4( diffuse, opacity );
  2997. #include <clipping_planes_fragment>
  2998. #include <logdepthbuf_fragment>
  2999. #include <map_fragment>
  3000. #include <color_fragment>
  3001. #include <alphamap_fragment>
  3002. #include <alphatest_fragment>
  3003. #include <alphahash_fragment>
  3004. #include <normal_fragment_begin>
  3005. #include <normal_fragment_maps>
  3006. vec3 viewDir = normalize( vViewPosition );
  3007. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  3008. vec3 y = cross( viewDir, x );
  3009. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  3010. #ifdef USE_MATCAP
  3011. vec4 matcapColor = texture2D( matcap, uv );
  3012. #else
  3013. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  3014. #endif
  3015. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  3016. #include <opaque_fragment>
  3017. #include <tonemapping_fragment>
  3018. #include <colorspace_fragment>
  3019. #include <fog_fragment>
  3020. #include <premultiplied_alpha_fragment>
  3021. #include <dithering_fragment>
  3022. }`,Bxe=`#define NORMAL
  3023. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3024. varying vec3 vViewPosition;
  3025. #endif
  3026. #include <common>
  3027. #include <batching_pars_vertex>
  3028. #include <uv_pars_vertex>
  3029. #include <displacementmap_pars_vertex>
  3030. #include <normal_pars_vertex>
  3031. #include <morphtarget_pars_vertex>
  3032. #include <skinning_pars_vertex>
  3033. #include <logdepthbuf_pars_vertex>
  3034. #include <clipping_planes_pars_vertex>
  3035. void main() {
  3036. #include <uv_vertex>
  3037. #include <batching_vertex>
  3038. #include <beginnormal_vertex>
  3039. #include <morphinstance_vertex>
  3040. #include <morphnormal_vertex>
  3041. #include <skinbase_vertex>
  3042. #include <skinnormal_vertex>
  3043. #include <defaultnormal_vertex>
  3044. #include <normal_vertex>
  3045. #include <begin_vertex>
  3046. #include <morphtarget_vertex>
  3047. #include <skinning_vertex>
  3048. #include <displacementmap_vertex>
  3049. #include <project_vertex>
  3050. #include <logdepthbuf_vertex>
  3051. #include <clipping_planes_vertex>
  3052. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3053. vViewPosition = - mvPosition.xyz;
  3054. #endif
  3055. }`,$xe=`#define NORMAL
  3056. uniform float opacity;
  3057. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3058. varying vec3 vViewPosition;
  3059. #endif
  3060. #include <packing>
  3061. #include <uv_pars_fragment>
  3062. #include <normal_pars_fragment>
  3063. #include <bumpmap_pars_fragment>
  3064. #include <normalmap_pars_fragment>
  3065. #include <logdepthbuf_pars_fragment>
  3066. #include <clipping_planes_pars_fragment>
  3067. void main() {
  3068. vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
  3069. #include <clipping_planes_fragment>
  3070. #include <logdepthbuf_fragment>
  3071. #include <normal_fragment_begin>
  3072. #include <normal_fragment_maps>
  3073. gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
  3074. #ifdef OPAQUE
  3075. gl_FragColor.a = 1.0;
  3076. #endif
  3077. }`,Hxe=`#define PHONG
  3078. varying vec3 vViewPosition;
  3079. #include <common>
  3080. #include <batching_pars_vertex>
  3081. #include <uv_pars_vertex>
  3082. #include <displacementmap_pars_vertex>
  3083. #include <envmap_pars_vertex>
  3084. #include <color_pars_vertex>
  3085. #include <fog_pars_vertex>
  3086. #include <normal_pars_vertex>
  3087. #include <morphtarget_pars_vertex>
  3088. #include <skinning_pars_vertex>
  3089. #include <shadowmap_pars_vertex>
  3090. #include <logdepthbuf_pars_vertex>
  3091. #include <clipping_planes_pars_vertex>
  3092. void main() {
  3093. #include <uv_vertex>
  3094. #include <color_vertex>
  3095. #include <morphcolor_vertex>
  3096. #include <batching_vertex>
  3097. #include <beginnormal_vertex>
  3098. #include <morphinstance_vertex>
  3099. #include <morphnormal_vertex>
  3100. #include <skinbase_vertex>
  3101. #include <skinnormal_vertex>
  3102. #include <defaultnormal_vertex>
  3103. #include <normal_vertex>
  3104. #include <begin_vertex>
  3105. #include <morphtarget_vertex>
  3106. #include <skinning_vertex>
  3107. #include <displacementmap_vertex>
  3108. #include <project_vertex>
  3109. #include <logdepthbuf_vertex>
  3110. #include <clipping_planes_vertex>
  3111. vViewPosition = - mvPosition.xyz;
  3112. #include <worldpos_vertex>
  3113. #include <envmap_vertex>
  3114. #include <shadowmap_vertex>
  3115. #include <fog_vertex>
  3116. }`,Vxe=`#define PHONG
  3117. uniform vec3 diffuse;
  3118. uniform vec3 emissive;
  3119. uniform vec3 specular;
  3120. uniform float shininess;
  3121. uniform float opacity;
  3122. #include <common>
  3123. #include <packing>
  3124. #include <dithering_pars_fragment>
  3125. #include <color_pars_fragment>
  3126. #include <uv_pars_fragment>
  3127. #include <map_pars_fragment>
  3128. #include <alphamap_pars_fragment>
  3129. #include <alphatest_pars_fragment>
  3130. #include <alphahash_pars_fragment>
  3131. #include <aomap_pars_fragment>
  3132. #include <lightmap_pars_fragment>
  3133. #include <emissivemap_pars_fragment>
  3134. #include <envmap_common_pars_fragment>
  3135. #include <envmap_pars_fragment>
  3136. #include <fog_pars_fragment>
  3137. #include <bsdfs>
  3138. #include <lights_pars_begin>
  3139. #include <normal_pars_fragment>
  3140. #include <lights_phong_pars_fragment>
  3141. #include <shadowmap_pars_fragment>
  3142. #include <bumpmap_pars_fragment>
  3143. #include <normalmap_pars_fragment>
  3144. #include <specularmap_pars_fragment>
  3145. #include <logdepthbuf_pars_fragment>
  3146. #include <clipping_planes_pars_fragment>
  3147. void main() {
  3148. vec4 diffuseColor = vec4( diffuse, opacity );
  3149. #include <clipping_planes_fragment>
  3150. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3151. vec3 totalEmissiveRadiance = emissive;
  3152. #include <logdepthbuf_fragment>
  3153. #include <map_fragment>
  3154. #include <color_fragment>
  3155. #include <alphamap_fragment>
  3156. #include <alphatest_fragment>
  3157. #include <alphahash_fragment>
  3158. #include <specularmap_fragment>
  3159. #include <normal_fragment_begin>
  3160. #include <normal_fragment_maps>
  3161. #include <emissivemap_fragment>
  3162. #include <lights_phong_fragment>
  3163. #include <lights_fragment_begin>
  3164. #include <lights_fragment_maps>
  3165. #include <lights_fragment_end>
  3166. #include <aomap_fragment>
  3167. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  3168. #include <envmap_fragment>
  3169. #include <opaque_fragment>
  3170. #include <tonemapping_fragment>
  3171. #include <colorspace_fragment>
  3172. #include <fog_fragment>
  3173. #include <premultiplied_alpha_fragment>
  3174. #include <dithering_fragment>
  3175. }`,Gxe=`#define STANDARD
  3176. varying vec3 vViewPosition;
  3177. #ifdef USE_TRANSMISSION
  3178. varying vec3 vWorldPosition;
  3179. #endif
  3180. #include <common>
  3181. #include <batching_pars_vertex>
  3182. #include <uv_pars_vertex>
  3183. #include <displacementmap_pars_vertex>
  3184. #include <color_pars_vertex>
  3185. #include <fog_pars_vertex>
  3186. #include <normal_pars_vertex>
  3187. #include <morphtarget_pars_vertex>
  3188. #include <skinning_pars_vertex>
  3189. #include <shadowmap_pars_vertex>
  3190. #include <logdepthbuf_pars_vertex>
  3191. #include <clipping_planes_pars_vertex>
  3192. void main() {
  3193. #include <uv_vertex>
  3194. #include <color_vertex>
  3195. #include <morphinstance_vertex>
  3196. #include <morphcolor_vertex>
  3197. #include <batching_vertex>
  3198. #include <beginnormal_vertex>
  3199. #include <morphnormal_vertex>
  3200. #include <skinbase_vertex>
  3201. #include <skinnormal_vertex>
  3202. #include <defaultnormal_vertex>
  3203. #include <normal_vertex>
  3204. #include <begin_vertex>
  3205. #include <morphtarget_vertex>
  3206. #include <skinning_vertex>
  3207. #include <displacementmap_vertex>
  3208. #include <project_vertex>
  3209. #include <logdepthbuf_vertex>
  3210. #include <clipping_planes_vertex>
  3211. vViewPosition = - mvPosition.xyz;
  3212. #include <worldpos_vertex>
  3213. #include <shadowmap_vertex>
  3214. #include <fog_vertex>
  3215. #ifdef USE_TRANSMISSION
  3216. vWorldPosition = worldPosition.xyz;
  3217. #endif
  3218. }`,qxe=`#define STANDARD
  3219. #ifdef PHYSICAL
  3220. #define IOR
  3221. #define USE_SPECULAR
  3222. #endif
  3223. uniform vec3 diffuse;
  3224. uniform vec3 emissive;
  3225. uniform float roughness;
  3226. uniform float metalness;
  3227. uniform float opacity;
  3228. #ifdef IOR
  3229. uniform float ior;
  3230. #endif
  3231. #ifdef USE_SPECULAR
  3232. uniform float specularIntensity;
  3233. uniform vec3 specularColor;
  3234. #ifdef USE_SPECULAR_COLORMAP
  3235. uniform sampler2D specularColorMap;
  3236. #endif
  3237. #ifdef USE_SPECULAR_INTENSITYMAP
  3238. uniform sampler2D specularIntensityMap;
  3239. #endif
  3240. #endif
  3241. #ifdef USE_CLEARCOAT
  3242. uniform float clearcoat;
  3243. uniform float clearcoatRoughness;
  3244. #endif
  3245. #ifdef USE_DISPERSION
  3246. uniform float dispersion;
  3247. #endif
  3248. #ifdef USE_IRIDESCENCE
  3249. uniform float iridescence;
  3250. uniform float iridescenceIOR;
  3251. uniform float iridescenceThicknessMinimum;
  3252. uniform float iridescenceThicknessMaximum;
  3253. #endif
  3254. #ifdef USE_SHEEN
  3255. uniform vec3 sheenColor;
  3256. uniform float sheenRoughness;
  3257. #ifdef USE_SHEEN_COLORMAP
  3258. uniform sampler2D sheenColorMap;
  3259. #endif
  3260. #ifdef USE_SHEEN_ROUGHNESSMAP
  3261. uniform sampler2D sheenRoughnessMap;
  3262. #endif
  3263. #endif
  3264. #ifdef USE_ANISOTROPY
  3265. uniform vec2 anisotropyVector;
  3266. #ifdef USE_ANISOTROPYMAP
  3267. uniform sampler2D anisotropyMap;
  3268. #endif
  3269. #endif
  3270. varying vec3 vViewPosition;
  3271. #include <common>
  3272. #include <packing>
  3273. #include <dithering_pars_fragment>
  3274. #include <color_pars_fragment>
  3275. #include <uv_pars_fragment>
  3276. #include <map_pars_fragment>
  3277. #include <alphamap_pars_fragment>
  3278. #include <alphatest_pars_fragment>
  3279. #include <alphahash_pars_fragment>
  3280. #include <aomap_pars_fragment>
  3281. #include <lightmap_pars_fragment>
  3282. #include <emissivemap_pars_fragment>
  3283. #include <iridescence_fragment>
  3284. #include <cube_uv_reflection_fragment>
  3285. #include <envmap_common_pars_fragment>
  3286. #include <envmap_physical_pars_fragment>
  3287. #include <fog_pars_fragment>
  3288. #include <lights_pars_begin>
  3289. #include <normal_pars_fragment>
  3290. #include <lights_physical_pars_fragment>
  3291. #include <transmission_pars_fragment>
  3292. #include <shadowmap_pars_fragment>
  3293. #include <bumpmap_pars_fragment>
  3294. #include <normalmap_pars_fragment>
  3295. #include <clearcoat_pars_fragment>
  3296. #include <iridescence_pars_fragment>
  3297. #include <roughnessmap_pars_fragment>
  3298. #include <metalnessmap_pars_fragment>
  3299. #include <logdepthbuf_pars_fragment>
  3300. #include <clipping_planes_pars_fragment>
  3301. void main() {
  3302. vec4 diffuseColor = vec4( diffuse, opacity );
  3303. #include <clipping_planes_fragment>
  3304. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3305. vec3 totalEmissiveRadiance = emissive;
  3306. #include <logdepthbuf_fragment>
  3307. #include <map_fragment>
  3308. #include <color_fragment>
  3309. #include <alphamap_fragment>
  3310. #include <alphatest_fragment>
  3311. #include <alphahash_fragment>
  3312. #include <roughnessmap_fragment>
  3313. #include <metalnessmap_fragment>
  3314. #include <normal_fragment_begin>
  3315. #include <normal_fragment_maps>
  3316. #include <clearcoat_normal_fragment_begin>
  3317. #include <clearcoat_normal_fragment_maps>
  3318. #include <emissivemap_fragment>
  3319. #include <lights_physical_fragment>
  3320. #include <lights_fragment_begin>
  3321. #include <lights_fragment_maps>
  3322. #include <lights_fragment_end>
  3323. #include <aomap_fragment>
  3324. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  3325. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  3326. #include <transmission_fragment>
  3327. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  3328. #ifdef USE_SHEEN
  3329. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  3330. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  3331. #endif
  3332. #ifdef USE_CLEARCOAT
  3333. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  3334. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  3335. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  3336. #endif
  3337. #include <opaque_fragment>
  3338. #include <tonemapping_fragment>
  3339. #include <colorspace_fragment>
  3340. #include <fog_fragment>
  3341. #include <premultiplied_alpha_fragment>
  3342. #include <dithering_fragment>
  3343. }`,Wxe=`#define TOON
  3344. varying vec3 vViewPosition;
  3345. #include <common>
  3346. #include <batching_pars_vertex>
  3347. #include <uv_pars_vertex>
  3348. #include <displacementmap_pars_vertex>
  3349. #include <color_pars_vertex>
  3350. #include <fog_pars_vertex>
  3351. #include <normal_pars_vertex>
  3352. #include <morphtarget_pars_vertex>
  3353. #include <skinning_pars_vertex>
  3354. #include <shadowmap_pars_vertex>
  3355. #include <logdepthbuf_pars_vertex>
  3356. #include <clipping_planes_pars_vertex>
  3357. void main() {
  3358. #include <uv_vertex>
  3359. #include <color_vertex>
  3360. #include <morphinstance_vertex>
  3361. #include <morphcolor_vertex>
  3362. #include <batching_vertex>
  3363. #include <beginnormal_vertex>
  3364. #include <morphnormal_vertex>
  3365. #include <skinbase_vertex>
  3366. #include <skinnormal_vertex>
  3367. #include <defaultnormal_vertex>
  3368. #include <normal_vertex>
  3369. #include <begin_vertex>
  3370. #include <morphtarget_vertex>
  3371. #include <skinning_vertex>
  3372. #include <displacementmap_vertex>
  3373. #include <project_vertex>
  3374. #include <logdepthbuf_vertex>
  3375. #include <clipping_planes_vertex>
  3376. vViewPosition = - mvPosition.xyz;
  3377. #include <worldpos_vertex>
  3378. #include <shadowmap_vertex>
  3379. #include <fog_vertex>
  3380. }`,Kxe=`#define TOON
  3381. uniform vec3 diffuse;
  3382. uniform vec3 emissive;
  3383. uniform float opacity;
  3384. #include <common>
  3385. #include <packing>
  3386. #include <dithering_pars_fragment>
  3387. #include <color_pars_fragment>
  3388. #include <uv_pars_fragment>
  3389. #include <map_pars_fragment>
  3390. #include <alphamap_pars_fragment>
  3391. #include <alphatest_pars_fragment>
  3392. #include <alphahash_pars_fragment>
  3393. #include <aomap_pars_fragment>
  3394. #include <lightmap_pars_fragment>
  3395. #include <emissivemap_pars_fragment>
  3396. #include <gradientmap_pars_fragment>
  3397. #include <fog_pars_fragment>
  3398. #include <bsdfs>
  3399. #include <lights_pars_begin>
  3400. #include <normal_pars_fragment>
  3401. #include <lights_toon_pars_fragment>
  3402. #include <shadowmap_pars_fragment>
  3403. #include <bumpmap_pars_fragment>
  3404. #include <normalmap_pars_fragment>
  3405. #include <logdepthbuf_pars_fragment>
  3406. #include <clipping_planes_pars_fragment>
  3407. void main() {
  3408. vec4 diffuseColor = vec4( diffuse, opacity );
  3409. #include <clipping_planes_fragment>
  3410. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3411. vec3 totalEmissiveRadiance = emissive;
  3412. #include <logdepthbuf_fragment>
  3413. #include <map_fragment>
  3414. #include <color_fragment>
  3415. #include <alphamap_fragment>
  3416. #include <alphatest_fragment>
  3417. #include <alphahash_fragment>
  3418. #include <normal_fragment_begin>
  3419. #include <normal_fragment_maps>
  3420. #include <emissivemap_fragment>
  3421. #include <lights_toon_fragment>
  3422. #include <lights_fragment_begin>
  3423. #include <lights_fragment_maps>
  3424. #include <lights_fragment_end>
  3425. #include <aomap_fragment>
  3426. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  3427. #include <opaque_fragment>
  3428. #include <tonemapping_fragment>
  3429. #include <colorspace_fragment>
  3430. #include <fog_fragment>
  3431. #include <premultiplied_alpha_fragment>
  3432. #include <dithering_fragment>
  3433. }`,Xxe=`uniform float size;
  3434. uniform float scale;
  3435. #include <common>
  3436. #include <color_pars_vertex>
  3437. #include <fog_pars_vertex>
  3438. #include <morphtarget_pars_vertex>
  3439. #include <logdepthbuf_pars_vertex>
  3440. #include <clipping_planes_pars_vertex>
  3441. #ifdef USE_POINTS_UV
  3442. varying vec2 vUv;
  3443. uniform mat3 uvTransform;
  3444. #endif
  3445. void main() {
  3446. #ifdef USE_POINTS_UV
  3447. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  3448. #endif
  3449. #include <color_vertex>
  3450. #include <morphinstance_vertex>
  3451. #include <morphcolor_vertex>
  3452. #include <begin_vertex>
  3453. #include <morphtarget_vertex>
  3454. #include <project_vertex>
  3455. gl_PointSize = size;
  3456. #ifdef USE_SIZEATTENUATION
  3457. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3458. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  3459. #endif
  3460. #include <logdepthbuf_vertex>
  3461. #include <clipping_planes_vertex>
  3462. #include <worldpos_vertex>
  3463. #include <fog_vertex>
  3464. }`,Yxe=`uniform vec3 diffuse;
  3465. uniform float opacity;
  3466. #include <common>
  3467. #include <color_pars_fragment>
  3468. #include <map_particle_pars_fragment>
  3469. #include <alphatest_pars_fragment>
  3470. #include <alphahash_pars_fragment>
  3471. #include <fog_pars_fragment>
  3472. #include <logdepthbuf_pars_fragment>
  3473. #include <clipping_planes_pars_fragment>
  3474. void main() {
  3475. vec4 diffuseColor = vec4( diffuse, opacity );
  3476. #include <clipping_planes_fragment>
  3477. vec3 outgoingLight = vec3( 0.0 );
  3478. #include <logdepthbuf_fragment>
  3479. #include <map_particle_fragment>
  3480. #include <color_fragment>
  3481. #include <alphatest_fragment>
  3482. #include <alphahash_fragment>
  3483. outgoingLight = diffuseColor.rgb;
  3484. #include <opaque_fragment>
  3485. #include <tonemapping_fragment>
  3486. #include <colorspace_fragment>
  3487. #include <fog_fragment>
  3488. #include <premultiplied_alpha_fragment>
  3489. }`,Qxe=`#include <common>
  3490. #include <batching_pars_vertex>
  3491. #include <fog_pars_vertex>
  3492. #include <morphtarget_pars_vertex>
  3493. #include <skinning_pars_vertex>
  3494. #include <logdepthbuf_pars_vertex>
  3495. #include <shadowmap_pars_vertex>
  3496. void main() {
  3497. #include <batching_vertex>
  3498. #include <beginnormal_vertex>
  3499. #include <morphinstance_vertex>
  3500. #include <morphnormal_vertex>
  3501. #include <skinbase_vertex>
  3502. #include <skinnormal_vertex>
  3503. #include <defaultnormal_vertex>
  3504. #include <begin_vertex>
  3505. #include <morphtarget_vertex>
  3506. #include <skinning_vertex>
  3507. #include <project_vertex>
  3508. #include <logdepthbuf_vertex>
  3509. #include <worldpos_vertex>
  3510. #include <shadowmap_vertex>
  3511. #include <fog_vertex>
  3512. }`,Zxe=`uniform vec3 color;
  3513. uniform float opacity;
  3514. #include <common>
  3515. #include <packing>
  3516. #include <fog_pars_fragment>
  3517. #include <bsdfs>
  3518. #include <lights_pars_begin>
  3519. #include <logdepthbuf_pars_fragment>
  3520. #include <shadowmap_pars_fragment>
  3521. #include <shadowmask_pars_fragment>
  3522. void main() {
  3523. #include <logdepthbuf_fragment>
  3524. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  3525. #include <tonemapping_fragment>
  3526. #include <colorspace_fragment>
  3527. #include <fog_fragment>
  3528. }`,Jxe=`uniform float rotation;
  3529. uniform vec2 center;
  3530. #include <common>
  3531. #include <uv_pars_vertex>
  3532. #include <fog_pars_vertex>
  3533. #include <logdepthbuf_pars_vertex>
  3534. #include <clipping_planes_pars_vertex>
  3535. void main() {
  3536. #include <uv_vertex>
  3537. vec4 mvPosition = modelViewMatrix[ 3 ];
  3538. vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
  3539. #ifndef USE_SIZEATTENUATION
  3540. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3541. if ( isPerspective ) scale *= - mvPosition.z;
  3542. #endif
  3543. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  3544. vec2 rotatedPosition;
  3545. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  3546. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  3547. mvPosition.xy += rotatedPosition;
  3548. gl_Position = projectionMatrix * mvPosition;
  3549. #include <logdepthbuf_vertex>
  3550. #include <clipping_planes_vertex>
  3551. #include <fog_vertex>
  3552. }`,ebe=`uniform vec3 diffuse;
  3553. uniform float opacity;
  3554. #include <common>
  3555. #include <uv_pars_fragment>
  3556. #include <map_pars_fragment>
  3557. #include <alphamap_pars_fragment>
  3558. #include <alphatest_pars_fragment>
  3559. #include <alphahash_pars_fragment>
  3560. #include <fog_pars_fragment>
  3561. #include <logdepthbuf_pars_fragment>
  3562. #include <clipping_planes_pars_fragment>
  3563. void main() {
  3564. vec4 diffuseColor = vec4( diffuse, opacity );
  3565. #include <clipping_planes_fragment>
  3566. vec3 outgoingLight = vec3( 0.0 );
  3567. #include <logdepthbuf_fragment>
  3568. #include <map_fragment>
  3569. #include <alphamap_fragment>
  3570. #include <alphatest_fragment>
  3571. #include <alphahash_fragment>
  3572. outgoingLight = diffuseColor.rgb;
  3573. #include <opaque_fragment>
  3574. #include <tonemapping_fragment>
  3575. #include <colorspace_fragment>
  3576. #include <fog_fragment>
  3577. }`,Cn={alphahash_fragment:wpe,alphahash_pars_fragment:Spe,alphamap_fragment:Npe,alphamap_pars_fragment:Mpe,alphatest_fragment:Epe,alphatest_pars_fragment:Cpe,aomap_fragment:Tpe,aomap_pars_fragment:Ape,batching_pars_vertex:kpe,batching_vertex:jpe,begin_vertex:Ppe,beginnormal_vertex:Rpe,bsdfs:Dpe,iridescence_fragment:Ope,bumpmap_pars_fragment:Lpe,clipping_planes_fragment:Ipe,clipping_planes_pars_fragment:Fpe,clipping_planes_pars_vertex:Upe,clipping_planes_vertex:zpe,color_fragment:Bpe,color_pars_fragment:$pe,color_pars_vertex:Hpe,color_vertex:Vpe,common:Gpe,cube_uv_reflection_fragment:qpe,defaultnormal_vertex:Wpe,displacementmap_pars_vertex:Kpe,displacementmap_vertex:Xpe,emissivemap_fragment:Ype,emissivemap_pars_fragment:Qpe,colorspace_fragment:Zpe,colorspace_pars_fragment:Jpe,envmap_fragment:ege,envmap_common_pars_fragment:tge,envmap_pars_fragment:nge,envmap_pars_vertex:rge,envmap_physical_pars_fragment:mge,envmap_vertex:ige,fog_vertex:age,fog_pars_vertex:sge,fog_fragment:oge,fog_pars_fragment:lge,gradientmap_pars_fragment:cge,lightmap_pars_fragment:uge,lights_lambert_fragment:dge,lights_lambert_pars_fragment:hge,lights_pars_begin:fge,lights_toon_fragment:pge,lights_toon_pars_fragment:gge,lights_phong_fragment:xge,lights_phong_pars_fragment:bge,lights_physical_fragment:yge,lights_physical_pars_fragment:vge,lights_fragment_begin:_ge,lights_fragment_maps:wge,lights_fragment_end:Sge,logdepthbuf_fragment:Nge,logdepthbuf_pars_fragment:Mge,logdepthbuf_pars_vertex:Ege,logdepthbuf_vertex:Cge,map_fragment:Tge,map_pars_fragment:Age,map_particle_fragment:kge,map_particle_pars_fragment:jge,metalnessmap_fragment:Pge,metalnessmap_pars_fragment:Rge,morphinstance_vertex:Dge,morphcolor_vertex:Oge,morphnormal_vertex:Lge,morphtarget_pars_vertex:Ige,morphtarget_vertex:Fge,normal_fragment_begin:Uge,normal_fragment_maps:zge,normal_pars_fragment:Bge,normal_pars_vertex:$ge,normal_vertex:Hge,normalmap_pars_fragment:Vge,clearcoat_normal_fragment_begin:Gge,clearcoat_normal_fragment_maps:qge,clearcoat_pars_fragment:Wge,iridescence_pars_fragment:Kge,opaque_fragment:Xge,packing:Yge,premultiplied_alpha_fragment:Qge,project_vertex:Zge,dithering_fragment:Jge,dithering_pars_fragment:exe,roughnessmap_fragment:txe,roughnessmap_pars_fragment:nxe,shadowmap_pars_fragment:rxe,shadowmap_pars_vertex:ixe,shadowmap_vertex:axe,shadowmask_pars_fragment:sxe,skinbase_vertex:oxe,skinning_pars_vertex:lxe,skinning_vertex:cxe,skinnormal_vertex:uxe,specularmap_fragment:dxe,specularmap_pars_fragment:hxe,tonemapping_fragment:fxe,tonemapping_pars_fragment:mxe,transmission_fragment:pxe,transmission_pars_fragment:gxe,uv_pars_fragment:xxe,uv_pars_vertex:bxe,uv_vertex:yxe,worldpos_vertex:vxe,background_vert:_xe,background_frag:wxe,backgroundCube_vert:Sxe,backgroundCube_frag:Nxe,cube_vert:Mxe,cube_frag:Exe,depth_vert:Cxe,depth_frag:Txe,distanceRGBA_vert:Axe,distanceRGBA_frag:kxe,equirect_vert:jxe,equirect_frag:Pxe,linedashed_vert:Rxe,linedashed_frag:Dxe,meshbasic_vert:Oxe,meshbasic_frag:Lxe,meshlambert_vert:Ixe,meshlambert_frag:Fxe,meshmatcap_vert:Uxe,meshmatcap_frag:zxe,meshnormal_vert:Bxe,meshnormal_frag:$xe,meshphong_vert:Hxe,meshphong_frag:Vxe,meshphysical_vert:Gxe,meshphysical_frag:qxe,meshtoon_vert:Wxe,meshtoon_frag:Kxe,points_vert:Xxe,points_frag:Yxe,shadow_vert:Qxe,shadow_frag:Zxe,sprite_vert:Jxe,sprite_frag:ebe},Ot={common:{diffuse:{value:new Rn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Pn},alphaMap:{value:null},alphaMapTransform:{value:new Pn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Pn}},envmap:{envMap:{value:null},envMapRotation:{value:new Pn},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 Pn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Pn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Pn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Pn},normalScale:{value:new An(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Pn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Pn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Pn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Pn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Rn(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 Rn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Pn},alphaTest:{value:0},uvTransform:{value:new Pn}},sprite:{diffuse:{value:new Rn(16777215)},opacity:{value:1},center:{value:new An(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Pn},alphaMap:{value:null},alphaMapTransform:{value:new Pn},alphaTest:{value:0}}},nc={basic:{uniforms:us([Ot.common,Ot.specularmap,Ot.envmap,Ot.aomap,Ot.lightmap,Ot.fog]),vertexShader:Cn.meshbasic_vert,fragmentShader:Cn.meshbasic_frag},lambert:{uniforms:us([Ot.common,Ot.specularmap,Ot.envmap,Ot.aomap,Ot.lightmap,Ot.emissivemap,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.fog,Ot.lights,{emissive:{value:new Rn(0)}}]),vertexShader:Cn.meshlambert_vert,fragmentShader:Cn.meshlambert_frag},phong:{uniforms:us([Ot.common,Ot.specularmap,Ot.envmap,Ot.aomap,Ot.lightmap,Ot.emissivemap,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.fog,Ot.lights,{emissive:{value:new Rn(0)},specular:{value:new Rn(1118481)},shininess:{value:30}}]),vertexShader:Cn.meshphong_vert,fragmentShader:Cn.meshphong_frag},standard:{uniforms:us([Ot.common,Ot.envmap,Ot.aomap,Ot.lightmap,Ot.emissivemap,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.roughnessmap,Ot.metalnessmap,Ot.fog,Ot.lights,{emissive:{value:new Rn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Cn.meshphysical_vert,fragmentShader:Cn.meshphysical_frag},toon:{uniforms:us([Ot.common,Ot.aomap,Ot.lightmap,Ot.emissivemap,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.gradientmap,Ot.fog,Ot.lights,{emissive:{value:new Rn(0)}}]),vertexShader:Cn.meshtoon_vert,fragmentShader:Cn.meshtoon_frag},matcap:{uniforms:us([Ot.common,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.fog,{matcap:{value:null}}]),vertexShader:Cn.meshmatcap_vert,fragmentShader:Cn.meshmatcap_frag},points:{uniforms:us([Ot.points,Ot.fog]),vertexShader:Cn.points_vert,fragmentShader:Cn.points_frag},dashed:{uniforms:us([Ot.common,Ot.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Cn.linedashed_vert,fragmentShader:Cn.linedashed_frag},depth:{uniforms:us([Ot.common,Ot.displacementmap]),vertexShader:Cn.depth_vert,fragmentShader:Cn.depth_frag},normal:{uniforms:us([Ot.common,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,{opacity:{value:1}}]),vertexShader:Cn.meshnormal_vert,fragmentShader:Cn.meshnormal_frag},sprite:{uniforms:us([Ot.sprite,Ot.fog]),vertexShader:Cn.sprite_vert,fragmentShader:Cn.sprite_frag},background:{uniforms:{uvTransform:{value:new Pn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Cn.background_vert,fragmentShader:Cn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Pn}},vertexShader:Cn.backgroundCube_vert,fragmentShader:Cn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Cn.cube_vert,fragmentShader:Cn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Cn.equirect_vert,fragmentShader:Cn.equirect_frag},distanceRGBA:{uniforms:us([Ot.common,Ot.displacementmap,{referencePosition:{value:new lt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Cn.distanceRGBA_vert,fragmentShader:Cn.distanceRGBA_frag},shadow:{uniforms:us([Ot.lights,Ot.fog,{color:{value:new Rn(0)},opacity:{value:1}}]),vertexShader:Cn.shadow_vert,fragmentShader:Cn.shadow_frag}};nc.physical={uniforms:us([nc.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Pn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Pn},clearcoatNormalScale:{value:new An(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Pn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Pn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Pn},sheen:{value:0},sheenColor:{value:new Rn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Pn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Pn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Pn},transmissionSamplerSize:{value:new An},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Pn},attenuationDistance:{value:0},attenuationColor:{value:new Rn(0)},specularColor:{value:new Rn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Pn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Pn},anisotropyVector:{value:new An},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Pn}}]),vertexShader:Cn.meshphysical_vert,fragmentShader:Cn.meshphysical_frag};const tw={r:0,b:0,g:0},df=new wh,tbe=new Fi;function nbe(t,e,n,r,i,s,o){const l=new Rn(0);let c=s===!0?0:1,u,d,f=null,m=0,p=null;function x(N){let C=N.isScene===!0?N.background:null;return C&&C.isTexture&&(C=(N.backgroundBlurriness>0?n:e).get(C)),C}function b(N){let C=!1;const T=x(N);T===null?v(l,c):T&&T.isColor&&(v(T,1),C=!0);const k=t.xr.getEnvironmentBlendMode();k==="additive"?r.buffers.color.setClear(0,0,0,1,o):k==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,o),(t.autoClear||C)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))}function y(N,C){const T=x(C);T&&(T.isCubeTexture||T.mapping===_N)?(d===void 0&&(d=new sl(new ZD(1,1,1),new Ou({name:"BackgroundCubeMaterial",uniforms:Wg(nc.backgroundCube.uniforms),vertexShader:nc.backgroundCube.vertexShader,fragmentShader:nc.backgroundCube.fragmentShader,side:zs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(k,E,D){this.matrixWorld.copyPosition(D.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),df.copy(C.backgroundRotation),df.x*=-1,df.y*=-1,df.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(df.y*=-1,df.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=C.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=C.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(tbe.makeRotationFromEuler(df)),d.material.toneMapped=ar.getTransfer(T.colorSpace)!==Nr,(f!==T||m!==T.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,f=T,m=T.version,p=t.toneMapping),d.layers.enableAll(),N.unshift(d,d.geometry,d.material,0,0,null)):T&&T.isTexture&&(u===void 0&&(u=new sl(new e4(2,2),new Ou({name:"BackgroundMaterial",uniforms:Wg(nc.background.uniforms),vertexShader:nc.background.vertexShader,fragmentShader:nc.background.fragmentShader,side:_h,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=C.backgroundIntensity,u.material.toneMapped=ar.getTransfer(T.colorSpace)!==Nr,T.matrixAutoUpdate===!0&&T.updateMatrix(),u.material.uniforms.uvTransform.value.copy(T.matrix),(f!==T||m!==T.version||p!==t.toneMapping)&&(u.material.needsUpdate=!0,f=T,m=T.version,p=t.toneMapping),u.layers.enableAll(),N.unshift(u,u.geometry,u.material,0,0,null))}function v(N,C){N.getRGB(tw,dK(t)),r.buffers.color.setClear(tw.r,tw.g,tw.b,C,o)}function S(){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 l},setClearColor:function(N,C=1){l.set(N),c=C,v(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(N){c=N,v(l,c)},render:b,addToRenderList:y,dispose:S}}function rbe(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=m(null);let s=i,o=!1;function l(R,F,O,H,j){let G=!1;const $=f(H,O,F);s!==$&&(s=$,u(s.object)),G=p(R,H,O,j),G&&x(R,H,O,j),j!==null&&e.update(j,t.ELEMENT_ARRAY_BUFFER),(G||o)&&(o=!1,C(R,F,O,H),j!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(j).buffer))}function c(){return t.createVertexArray()}function u(R){return t.bindVertexArray(R)}function d(R){return t.deleteVertexArray(R)}function f(R,F,O){const H=O.wireframe===!0;let j=r[R.id];j===void 0&&(j={},r[R.id]=j);let G=j[F.id];G===void 0&&(G={},j[F.id]=G);let $=G[H];return $===void 0&&($=m(c()),G[H]=$),$}function m(R){const F=[],O=[],H=[];for(let j=0;j<n;j++)F[j]=0,O[j]=0,H[j]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:O,attributeDivisors:H,object:R,attributes:{},index:null}}function p(R,F,O,H){const j=s.attributes,G=F.attributes;let $=0;const q=O.getAttributes();for(const Y in q)if(q[Y].location>=0){const oe=j[Y];let B=G[Y];if(B===void 0&&(Y==="instanceMatrix"&&R.instanceMatrix&&(B=R.instanceMatrix),Y==="instanceColor"&&R.instanceColor&&(B=R.instanceColor)),oe===void 0||oe.attribute!==B||B&&oe.data!==B.data)return!0;$++}return s.attributesNum!==$||s.index!==H}function x(R,F,O,H){const j={},G=F.attributes;let $=0;const q=O.getAttributes();for(const Y in q)if(q[Y].location>=0){let oe=G[Y];oe===void 0&&(Y==="instanceMatrix"&&R.instanceMatrix&&(oe=R.instanceMatrix),Y==="instanceColor"&&R.instanceColor&&(oe=R.instanceColor));const B={};B.attribute=oe,oe&&oe.data&&(B.data=oe.data),j[Y]=B,$++}s.attributes=j,s.attributesNum=$,s.index=H}function b(){const R=s.newAttributes;for(let F=0,O=R.length;F<O;F++)R[F]=0}function y(R){v(R,0)}function v(R,F){const O=s.newAttributes,H=s.enabledAttributes,j=s.attributeDivisors;O[R]=1,H[R]===0&&(t.enableVertexAttribArray(R),H[R]=1),j[R]!==F&&(t.vertexAttribDivisor(R,F),j[R]=F)}function S(){const R=s.newAttributes,F=s.enabledAttributes;for(let O=0,H=F.length;O<H;O++)F[O]!==R[O]&&(t.disableVertexAttribArray(O),F[O]=0)}function N(R,F,O,H,j,G,$){$===!0?t.vertexAttribIPointer(R,F,O,j,G):t.vertexAttribPointer(R,F,O,H,j,G)}function C(R,F,O,H){b();const j=H.attributes,G=O.getAttributes(),$=F.defaultAttributeValues;for(const q in G){const Y=G[q];if(Y.location>=0){let Z=j[q];if(Z===void 0&&(q==="instanceMatrix"&&R.instanceMatrix&&(Z=R.instanceMatrix),q==="instanceColor"&&R.instanceColor&&(Z=R.instanceColor)),Z!==void 0){const oe=Z.normalized,B=Z.itemSize,W=e.get(Z);if(W===void 0)continue;const se=W.buffer,ne=W.type,ce=W.bytesPerElement,fe=ne===t.INT||ne===t.UNSIGNED_INT||Z.gpuType===$D;if(Z.isInterleavedBufferAttribute){const ye=Z.data,ge=ye.stride,xe=Z.offset;if(ye.isInstancedInterleavedBuffer){for(let Pe=0;Pe<Y.locationSize;Pe++)v(Y.location+Pe,ye.meshPerAttribute);R.isInstancedMesh!==!0&&H._maxInstanceCount===void 0&&(H._maxInstanceCount=ye.meshPerAttribute*ye.count)}else for(let Pe=0;Pe<Y.locationSize;Pe++)y(Y.location+Pe);t.bindBuffer(t.ARRAY_BUFFER,se);for(let Pe=0;Pe<Y.locationSize;Pe++)N(Y.location+Pe,B/Y.locationSize,ne,oe,ge*ce,(xe+B/Y.locationSize*Pe)*ce,fe)}else{if(Z.isInstancedBufferAttribute){for(let ye=0;ye<Y.locationSize;ye++)v(Y.location+ye,Z.meshPerAttribute);R.isInstancedMesh!==!0&&H._maxInstanceCount===void 0&&(H._maxInstanceCount=Z.meshPerAttribute*Z.count)}else for(let ye=0;ye<Y.locationSize;ye++)y(Y.location+ye);t.bindBuffer(t.ARRAY_BUFFER,se);for(let ye=0;ye<Y.locationSize;ye++)N(Y.location+ye,B/Y.locationSize,ne,oe,B*ce,B/Y.locationSize*ye*ce,fe)}}else if($!==void 0){const oe=$[q];if(oe!==void 0)switch(oe.length){case 2:t.vertexAttrib2fv(Y.location,oe);break;case 3:t.vertexAttrib3fv(Y.location,oe);break;case 4:t.vertexAttrib4fv(Y.location,oe);break;default:t.vertexAttrib1fv(Y.location,oe)}}}}S()}function T(){D();for(const R in r){const F=r[R];for(const O in F){const H=F[O];for(const j in H)d(H[j].object),delete H[j];delete F[O]}delete r[R]}}function k(R){if(r[R.id]===void 0)return;const F=r[R.id];for(const O in F){const H=F[O];for(const j in H)d(H[j].object),delete H[j];delete F[O]}delete r[R.id]}function E(R){for(const F in r){const O=r[F];if(O[R.id]===void 0)continue;const H=O[R.id];for(const j in H)d(H[j].object),delete H[j];delete O[R.id]}}function D(){A(),o=!0,s!==i&&(s=i,u(s.object))}function A(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:l,reset:D,resetDefaultState:A,dispose:T,releaseStatesOfGeometry:k,releaseStatesOfProgram:E,initAttributes:b,enableAttribute:y,disableUnusedAttributes:S}}function ibe(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 o(u,d,f){f!==0&&(t.drawArraysInstanced(r,u,d,f),n.update(d,r,f))}function l(u,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,u,0,d,0,f);let p=0;for(let x=0;x<f;x++)p+=d[x];n.update(p,r,1)}function c(u,d,f,m){if(f===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let x=0;x<u.length;x++)o(u[x],d[x],m[x]);else{p.multiDrawArraysInstancedWEBGL(r,u,0,d,0,m,0,f);let x=0;for(let b=0;b<f;b++)x+=d[b]*m[b];n.update(x,r,1)}}this.setMode=i,this.render=s,this.renderInstances=o,this.renderMultiDraw=l,this.renderMultiDrawInstances=c}function abe(t,e,n,r){let i;function s(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const E=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(E.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(E){return!(E!==Pl&&r.convert(E)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function l(E){const D=E===yx&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(E!==gc&&r.convert(E)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&E!==bu&&!D)}function c(E){if(E==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";E="mediump"}return E==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let u=n.precision!==void 0?n.precision:"highp";const d=c(u);d!==u&&(mn("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const f=n.logarithmicDepthBuffer===!0,m=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),p=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),x=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),b=t.getParameter(t.MAX_TEXTURE_SIZE),y=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),v=t.getParameter(t.MAX_VERTEX_ATTRIBS),S=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),N=t.getParameter(t.MAX_VARYING_VECTORS),C=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),T=x>0,k=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:l,precision:u,logarithmicDepthBuffer:f,reversedDepthBuffer:m,maxTextures:p,maxVertexTextures:x,maxTextureSize:b,maxCubemapSize:y,maxAttributes:v,maxVertexUniforms:S,maxVaryings:N,maxFragmentUniforms:C,vertexTextures:T,maxSamples:k}}function sbe(t){const e=this;let n=null,r=0,i=!1,s=!1;const o=new Fd,l=new Pn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,m){const p=f.length!==0||m||r!==0||i;return i=m,r=f.length,p},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,m){n=d(f,m,0)},this.setState=function(f,m,p){const x=f.clippingPlanes,b=f.clipIntersection,y=f.clipShadows,v=t.get(f);if(!i||x===null||x.length===0||s&&!y)s?d(null):u();else{const S=s?0:r,N=S*4;let C=v.clippingState||null;c.value=C,C=d(x,m,N,p);for(let T=0;T!==N;++T)C[T]=n[T];v.clippingState=C,this.numIntersection=b?this.numPlanes:0,this.numPlanes+=S}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,m,p,x){const b=f!==null?f.length:0;let y=null;if(b!==0){if(y=c.value,x!==!0||y===null){const v=p+b*4,S=m.matrixWorldInverse;l.getNormalMatrix(S),(y===null||y.length<v)&&(y=new Float32Array(v));for(let N=0,C=p;N!==b;++N,C+=4)o.copy(f[N]).applyMatrix4(S,l),o.normal.toArray(y,C),y[C+3]=o.constant}c.value=y,c.needsUpdate=!0}return e.numPlanes=b,e.numIntersection=0,y}}function obe(t){let e=new WeakMap;function n(o,l){return l===k3?o.mapping=Vg:l===j3&&(o.mapping=Gg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===k3||l===j3)if(e.has(o)){const c=e.get(o).texture;return n(c,o.mapping)}else{const c=o.image;if(c&&c.height>0){const u=new Jme(c.height);return u.fromEquirectangularTexture(t,o),e.set(o,u),o.addEventListener("dispose",i),n(u.texture,o.mapping)}else return null}}return o}function i(o){const l=o.target;l.removeEventListener("dispose",i);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function s(){e=new WeakMap}return{get:r,dispose:s}}const Yd=4,NB=[.125,.215,.35,.446,.526,.582],Mf=20,lbe=256,Ub=new vK,MB=new Rn;let PT=null,RT=0,DT=0,OT=!1;const cbe=new lt;let EB=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:o=256,position:l=cbe}=s;PT=this._renderer.getRenderTarget(),RT=this._renderer.getActiveCubeFace(),DT=this._renderer.getActiveMipmapLevel(),OT=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,r,i,c,l),n>0&&this._blur(c,0,0,n),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=AB(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=TB(),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(PT,RT,DT),this._renderer.xr.enabled=OT,e.scissorTest=!1,Ap(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Vg||e.mapping===Gg?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),PT=this._renderer.getRenderTarget(),RT=this._renderer.getActiveCubeFace(),DT=this._renderer.getActiveMipmapLevel(),OT=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:Zo,minFilter:Zo,generateMipmaps:!1,type:yx,format:Pl,colorSpace:qg,depthBuffer:!1},i=CB(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=CB(e,n,r);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=ube(s)),this._blurMaterial=hbe(s,e,n),this._ggxMaterial=dbe(s,e,n)}return i}_compileMaterial(e){const n=new sl(new al,e);this._renderer.compile(n,Ub)}_sceneToCubeUV(e,n,r,i,s){const c=new qo(90,1,n,r),u=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,m=f.autoClear,p=f.toneMapping;f.getClearColor(MB),f.toneMapping=sh,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new sl(new ZD,new QD({name:"PMREM.Background",side:zs,depthWrite:!1,depthTest:!1})));const b=this._backgroundBox,y=b.material;let v=!1;const S=e.background;S?S.isColor&&(y.color.copy(S),e.background=null,v=!0):(y.color.copy(MB),v=!0);for(let N=0;N<6;N++){const C=N%3;C===0?(c.up.set(0,u[N],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+d[N],s.y,s.z)):C===1?(c.up.set(0,0,u[N]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+d[N],s.z)):(c.up.set(0,u[N],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+d[N]));const T=this._cubeSize;Ap(i,C*T,N>2?T:0,T,T),f.setRenderTarget(i),v&&f.render(b,c),f.render(e,c)}f.toneMapping=p,f.autoClear=m,e.background=S}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Vg||e.mapping===Gg;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=AB()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=TB());const s=i?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=s;const l=s.uniforms;l.envMap.value=e;const c=this._cubeSize;Ap(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,Ub)}_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,o=this._ggxMaterial,l=this._lodMeshes[r];l.material=o;const c=o.uniforms,u=r/(this._lodMeshes.length-1),d=n/(this._lodMeshes.length-1),f=Math.sqrt(u*u-d*d),m=.05+u*.95,p=f*m,{_lodMax:x}=this,b=this._sizeLods[r],y=3*b*(r>x-Yd?r-x+Yd:0),v=4*(this._cubeSize-b);c.envMap.value=e.texture,c.roughness.value=p,c.mipInt.value=x-n,Ap(s,y,v,3*b,2*b),i.setRenderTarget(s),i.render(l,Ub),c.envMap.value=s.texture,c.roughness.value=0,c.mipInt.value=x-r,Ap(e,y,v,3*b,2*b),i.setRenderTarget(e),i.render(l,Ub)}_blur(e,n,r,i,s){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",s),this._halfBlur(o,e,r,r,i,"longitudinal",s)}_halfBlur(e,n,r,i,s,o,l){const c=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&_i("blur direction must be either latitudinal or longitudinal!");const d=3,f=this._lodMeshes[i];f.material=u;const m=u.uniforms,p=this._sizeLods[r]-1,x=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*Mf-1),b=s/x,y=isFinite(s)?1+Math.floor(d*b):Mf;y>Mf&&mn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${Mf}`);const v=[];let S=0;for(let E=0;E<Mf;++E){const D=E/b,A=Math.exp(-D*D/2);v.push(A),E===0?S+=A:E<y&&(S+=2*A)}for(let E=0;E<v.length;E++)v[E]=v[E]/S;m.envMap.value=e.texture,m.samples.value=y,m.weights.value=v,m.latitudinal.value=o==="latitudinal",l&&(m.poleAxis.value=l);const{_lodMax:N}=this;m.dTheta.value=x,m.mipInt.value=N-r;const C=this._sizeLods[i],T=3*C*(i>N-Yd?i-N+Yd:0),k=4*(this._cubeSize-C);Ap(n,T,k,3*C,2*C),c.setRenderTarget(n),c.render(f,Ub)}};function ube(t){const e=[],n=[],r=[];let i=t;const s=t-Yd+1+NB.length;for(let o=0;o<s;o++){const l=Math.pow(2,i);e.push(l);let c=1/l;o>t-Yd?c=NB[o-t+Yd-1]:o===0&&(c=0),n.push(c);const u=1/(l-2),d=-u,f=1+u,m=[d,d,f,d,f,f,d,d,f,f,d,f],p=6,x=6,b=3,y=2,v=1,S=new Float32Array(b*x*p),N=new Float32Array(y*x*p),C=new Float32Array(v*x*p);for(let k=0;k<p;k++){const E=k%3*2/3-1,D=k>2?0:-1,A=[E,D,0,E+2/3,D,0,E+2/3,D+1,0,E,D,0,E+2/3,D+1,0,E,D+1,0];S.set(A,b*x*k),N.set(m,y*x*k);const R=[k,k,k,k,k,k];C.set(R,v*x*k)}const T=new al;T.setAttribute("position",new bs(S,b)),T.setAttribute("uv",new bs(N,y)),T.setAttribute("faceIndex",new bs(C,v)),r.push(new sl(T,null)),i>Yd&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function CB(t,e,n){const r=new um(t,e,n);return r.texture.mapping=_N,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Ap(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function dbe(t,e,n){return new Ou({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:lbe,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:SN(),fragmentShader:`
  3578. precision highp float;
  3579. precision highp int;
  3580. varying vec3 vOutputDirection;
  3581. uniform sampler2D envMap;
  3582. uniform float roughness;
  3583. uniform float mipInt;
  3584. #define ENVMAP_TYPE_CUBE_UV
  3585. #include <cube_uv_reflection_fragment>
  3586. #define PI 3.14159265359
  3587. // Van der Corput radical inverse
  3588. float radicalInverse_VdC(uint bits) {
  3589. bits = (bits << 16u) | (bits >> 16u);
  3590. bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
  3591. bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
  3592. bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
  3593. bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
  3594. return float(bits) * 2.3283064365386963e-10; // / 0x100000000
  3595. }
  3596. // Hammersley sequence
  3597. vec2 hammersley(uint i, uint N) {
  3598. return vec2(float(i) / float(N), radicalInverse_VdC(i));
  3599. }
  3600. // GGX VNDF importance sampling (Eric Heitz 2018)
  3601. // "Sampling the GGX Distribution of Visible Normals"
  3602. // https://jcgt.org/published/0007/04/01/
  3603. vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
  3604. float alpha = roughness * roughness;
  3605. // Section 3.2: Transform view direction to hemisphere configuration
  3606. vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
  3607. // Section 4.1: Orthonormal basis
  3608. float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
  3609. vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
  3610. vec3 T2 = cross(Vh, T1);
  3611. // Section 4.2: Parameterization of projected area
  3612. float r = sqrt(Xi.x);
  3613. float phi = 2.0 * PI * Xi.y;
  3614. float t1 = r * cos(phi);
  3615. float t2 = r * sin(phi);
  3616. float s = 0.5 * (1.0 + Vh.z);
  3617. t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
  3618. // Section 4.3: Reprojection onto hemisphere
  3619. vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
  3620. // Section 3.4: Transform back to ellipsoid configuration
  3621. return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
  3622. }
  3623. void main() {
  3624. vec3 N = normalize(vOutputDirection);
  3625. vec3 V = N; // Assume view direction equals normal for pre-filtering
  3626. vec3 prefilteredColor = vec3(0.0);
  3627. float totalWeight = 0.0;
  3628. // For very low roughness, just sample the environment directly
  3629. if (roughness < 0.001) {
  3630. gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
  3631. return;
  3632. }
  3633. // Tangent space basis for VNDF sampling
  3634. vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
  3635. vec3 tangent = normalize(cross(up, N));
  3636. vec3 bitangent = cross(N, tangent);
  3637. for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
  3638. vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
  3639. // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
  3640. vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
  3641. // Transform H back to world space
  3642. vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
  3643. vec3 L = normalize(2.0 * dot(V, H) * H - V);
  3644. float NdotL = max(dot(N, L), 0.0);
  3645. if(NdotL > 0.0) {
  3646. // Sample environment at fixed mip level
  3647. // VNDF importance sampling handles the distribution filtering
  3648. vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
  3649. // Weight by NdotL for the split-sum approximation
  3650. // VNDF PDF naturally accounts for the visible microfacet distribution
  3651. prefilteredColor += sampleColor * NdotL;
  3652. totalWeight += NdotL;
  3653. }
  3654. }
  3655. if (totalWeight > 0.0) {
  3656. prefilteredColor = prefilteredColor / totalWeight;
  3657. }
  3658. gl_FragColor = vec4(prefilteredColor, 1.0);
  3659. }
  3660. `,blending:Mu,depthTest:!1,depthWrite:!1})}function hbe(t,e,n){const r=new Float32Array(Mf),i=new lt(0,1,0);return new Ou({name:"SphericalGaussianBlur",defines:{n:Mf,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:SN(),fragmentShader:`
  3661. precision mediump float;
  3662. precision mediump int;
  3663. varying vec3 vOutputDirection;
  3664. uniform sampler2D envMap;
  3665. uniform int samples;
  3666. uniform float weights[ n ];
  3667. uniform bool latitudinal;
  3668. uniform float dTheta;
  3669. uniform float mipInt;
  3670. uniform vec3 poleAxis;
  3671. #define ENVMAP_TYPE_CUBE_UV
  3672. #include <cube_uv_reflection_fragment>
  3673. vec3 getSample( float theta, vec3 axis ) {
  3674. float cosTheta = cos( theta );
  3675. // Rodrigues' axis-angle rotation
  3676. vec3 sampleDirection = vOutputDirection * cosTheta
  3677. + cross( axis, vOutputDirection ) * sin( theta )
  3678. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  3679. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  3680. }
  3681. void main() {
  3682. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  3683. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  3684. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  3685. }
  3686. axis = normalize( axis );
  3687. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  3688. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  3689. for ( int i = 1; i < n; i++ ) {
  3690. if ( i >= samples ) {
  3691. break;
  3692. }
  3693. float theta = dTheta * float( i );
  3694. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  3695. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  3696. }
  3697. }
  3698. `,blending:Mu,depthTest:!1,depthWrite:!1})}function TB(){return new Ou({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:SN(),fragmentShader:`
  3699. precision mediump float;
  3700. precision mediump int;
  3701. varying vec3 vOutputDirection;
  3702. uniform sampler2D envMap;
  3703. #include <common>
  3704. void main() {
  3705. vec3 outputDirection = normalize( vOutputDirection );
  3706. vec2 uv = equirectUv( outputDirection );
  3707. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  3708. }
  3709. `,blending:Mu,depthTest:!1,depthWrite:!1})}function AB(){return new Ou({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:SN(),fragmentShader:`
  3710. precision mediump float;
  3711. precision mediump int;
  3712. uniform float flipEnvMap;
  3713. varying vec3 vOutputDirection;
  3714. uniform samplerCube envMap;
  3715. void main() {
  3716. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  3717. }
  3718. `,blending:Mu,depthTest:!1,depthWrite:!1})}function SN(){return`
  3719. precision mediump float;
  3720. precision mediump int;
  3721. attribute float faceIndex;
  3722. varying vec3 vOutputDirection;
  3723. // RH coordinate system; PMREM face-indexing convention
  3724. vec3 getDirection( vec2 uv, float face ) {
  3725. uv = 2.0 * uv - 1.0;
  3726. vec3 direction = vec3( uv, 1.0 );
  3727. if ( face == 0.0 ) {
  3728. direction = direction.zyx; // ( 1, v, u ) pos x
  3729. } else if ( face == 1.0 ) {
  3730. direction = direction.xzy;
  3731. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  3732. } else if ( face == 2.0 ) {
  3733. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  3734. } else if ( face == 3.0 ) {
  3735. direction = direction.zyx;
  3736. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  3737. } else if ( face == 4.0 ) {
  3738. direction = direction.xzy;
  3739. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  3740. } else if ( face == 5.0 ) {
  3741. direction.z *= -1.0; // ( u, v, -1 ) neg z
  3742. }
  3743. return direction;
  3744. }
  3745. void main() {
  3746. vOutputDirection = getDirection( uv, faceIndex );
  3747. gl_Position = vec4( position, 1.0 );
  3748. }
  3749. `}function fbe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===k3||c===j3,d=c===Vg||c===Gg;if(u||d){let f=e.get(l);const m=f!==void 0?f.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==m)return n===null&&(n=new EB(t)),f=u?n.fromEquirectangular(l,f):n.fromCubemap(l,f),f.texture.pmremVersion=l.pmremVersion,e.set(l,f),f.texture;if(f!==void 0)return f.texture;{const p=l.image;return u&&p&&p.height>0||d&&p&&i(p)?(n===null&&(n=new EB(t)),f=u?n.fromEquirectangular(l):n.fromCubemap(l),f.texture.pmremVersion=l.pmremVersion,e.set(l,f),l.addEventListener("dispose",s),f.texture):null}}}return l}function i(l){let c=0;const u=6;for(let d=0;d<u;d++)l[d]!==void 0&&c++;return c===u}function s(l){const c=l.target;c.removeEventListener("dispose",s);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function o(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function mbe(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&&J0("WebGLRenderer: "+r+" extension not supported."),i}}}function pbe(t,e,n,r){const i={},s=new WeakMap;function o(f){const m=f.target;m.index!==null&&e.remove(m.index);for(const x in m.attributes)e.remove(m.attributes[x]);m.removeEventListener("dispose",o),delete i[m.id];const p=s.get(m);p&&(e.remove(p),s.delete(m)),r.releaseStatesOfGeometry(m),m.isInstancedBufferGeometry===!0&&delete m._maxInstanceCount,n.memory.geometries--}function l(f,m){return i[m.id]===!0||(m.addEventListener("dispose",o),i[m.id]=!0,n.memory.geometries++),m}function c(f){const m=f.attributes;for(const p in m)e.update(m[p],t.ARRAY_BUFFER)}function u(f){const m=[],p=f.index,x=f.attributes.position;let b=0;if(p!==null){const S=p.array;b=p.version;for(let N=0,C=S.length;N<C;N+=3){const T=S[N+0],k=S[N+1],E=S[N+2];m.push(T,k,k,E,E,T)}}else if(x!==void 0){const S=x.array;b=x.version;for(let N=0,C=S.length/3-1;N<C;N+=3){const T=N+0,k=N+1,E=N+2;m.push(T,k,k,E,E,T)}}else return;const y=new(ZW(m)?lK:oK)(m,1);y.version=b;const v=s.get(f);v&&e.remove(v),s.set(f,y)}function d(f){const m=s.get(f);if(m){const p=f.index;p!==null&&m.version<p.version&&u(f)}else u(f);return s.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function gbe(t,e,n){let r;function i(m){r=m}let s,o;function l(m){s=m.type,o=m.bytesPerElement}function c(m,p){t.drawElements(r,p,s,m*o),n.update(p,r,1)}function u(m,p,x){x!==0&&(t.drawElementsInstanced(r,p,s,m*o,x),n.update(p,r,x))}function d(m,p,x){if(x===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,p,0,s,m,0,x);let y=0;for(let v=0;v<x;v++)y+=p[v];n.update(y,r,1)}function f(m,p,x,b){if(x===0)return;const y=e.get("WEBGL_multi_draw");if(y===null)for(let v=0;v<m.length;v++)u(m[v]/o,p[v],b[v]);else{y.multiDrawElementsInstancedWEBGL(r,p,0,s,m,0,b,0,x);let v=0;for(let S=0;S<x;S++)v+=p[S]*b[S];n.update(v,r,1)}}this.setMode=i,this.setIndex=l,this.render=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=f}function xbe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(s,o,l){switch(n.calls++,o){case t.TRIANGLES:n.triangles+=l*(s/3);break;case t.LINES:n.lines+=l*(s/2);break;case t.LINE_STRIP:n.lines+=l*(s-1);break;case t.LINE_LOOP:n.lines+=l*s;break;case t.POINTS:n.points+=l*s;break;default:_i("WebGLInfo: Unknown draw mode:",o);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 bbe(t,e,n){const r=new WeakMap,i=new Di;function s(o,l,c){const u=o.morphTargetInfluences,d=l.morphAttributes.position||l.morphAttributes.normal||l.morphAttributes.color,f=d!==void 0?d.length:0;let m=r.get(l);if(m===void 0||m.count!==f){let R=function(){D.dispose(),r.delete(l),l.removeEventListener("dispose",R)};var p=R;m!==void 0&&m.texture.dispose();const x=l.morphAttributes.position!==void 0,b=l.morphAttributes.normal!==void 0,y=l.morphAttributes.color!==void 0,v=l.morphAttributes.position||[],S=l.morphAttributes.normal||[],N=l.morphAttributes.color||[];let C=0;x===!0&&(C=1),b===!0&&(C=2),y===!0&&(C=3);let T=l.attributes.position.count*C,k=1;T>e.maxTextureSize&&(k=Math.ceil(T/e.maxTextureSize),T=e.maxTextureSize);const E=new Float32Array(T*k*4*f),D=new rK(E,T,k,f);D.type=bu,D.needsUpdate=!0;const A=C*4;for(let F=0;F<f;F++){const O=v[F],H=S[F],j=N[F],G=T*k*4*F;for(let $=0;$<O.count;$++){const q=$*A;x===!0&&(i.fromBufferAttribute(O,$),E[G+q+0]=i.x,E[G+q+1]=i.y,E[G+q+2]=i.z,E[G+q+3]=0),b===!0&&(i.fromBufferAttribute(H,$),E[G+q+4]=i.x,E[G+q+5]=i.y,E[G+q+6]=i.z,E[G+q+7]=0),y===!0&&(i.fromBufferAttribute(j,$),E[G+q+8]=i.x,E[G+q+9]=i.y,E[G+q+10]=i.z,E[G+q+11]=j.itemSize===4?i.w:1)}}m={count:f,texture:D,size:new An(T,k)},r.set(l,m),l.addEventListener("dispose",R)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(t,"morphTexture",o.morphTexture,n);else{let x=0;for(let y=0;y<u.length;y++)x+=u[y];const b=l.morphTargetsRelative?1:1-x;c.getUniforms().setValue(t,"morphTargetBaseInfluence",b),c.getUniforms().setValue(t,"morphTargetInfluences",u)}c.getUniforms().setValue(t,"morphTargetsTexture",m.texture,n),c.getUniforms().setValue(t,"morphTargetsTextureSize",m.size)}return{update:s}}function ybe(t,e,n,r){let i=new WeakMap;function s(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const m=c.skeleton;i.get(m)!==u&&(m.update(),i.set(m,u))}return f}function o(){i=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:s,dispose:o}}const wK=new zl,kB=new pK(1,1),SK=new rK,NK=new Lme,MK=new fK,jB=[],PB=[],RB=new Float32Array(16),DB=new Float32Array(9),OB=new Float32Array(4);function _x(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=jB[i];if(s===void 0&&(s=new Float32Array(i),jB[i]=s),e!==0){r.toArray(s,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(s,l)}return s}function Xi(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 Yi(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function NN(t,e){let n=PB[e];n===void 0&&(n=new Int32Array(e),PB[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function vbe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function _be(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(Xi(n,e))return;t.uniform2fv(this.addr,e),Yi(n,e)}}function wbe(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(Xi(n,e))return;t.uniform3fv(this.addr,e),Yi(n,e)}}function Sbe(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(Xi(n,e))return;t.uniform4fv(this.addr,e),Yi(n,e)}}function Nbe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Xi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Yi(n,e)}else{if(Xi(n,r))return;OB.set(r),t.uniformMatrix2fv(this.addr,!1,OB),Yi(n,r)}}function Mbe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Xi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Yi(n,e)}else{if(Xi(n,r))return;DB.set(r),t.uniformMatrix3fv(this.addr,!1,DB),Yi(n,r)}}function Ebe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Xi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Yi(n,e)}else{if(Xi(n,r))return;RB.set(r),t.uniformMatrix4fv(this.addr,!1,RB),Yi(n,r)}}function Cbe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function Tbe(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(Xi(n,e))return;t.uniform2iv(this.addr,e),Yi(n,e)}}function Abe(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(Xi(n,e))return;t.uniform3iv(this.addr,e),Yi(n,e)}}function kbe(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(Xi(n,e))return;t.uniform4iv(this.addr,e),Yi(n,e)}}function jbe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function Pbe(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(Xi(n,e))return;t.uniform2uiv(this.addr,e),Yi(n,e)}}function Rbe(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(Xi(n,e))return;t.uniform3uiv(this.addr,e),Yi(n,e)}}function Dbe(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(Xi(n,e))return;t.uniform4uiv(this.addr,e),Yi(n,e)}}function Obe(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?(kB.compareFunction=QW,s=kB):s=wK,n.setTexture2D(e||s,i)}function Lbe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||NK,i)}function Ibe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||MK,i)}function Fbe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||SK,i)}function Ube(t){switch(t){case 5126:return vbe;case 35664:return _be;case 35665:return wbe;case 35666:return Sbe;case 35674:return Nbe;case 35675:return Mbe;case 35676:return Ebe;case 5124:case 35670:return Cbe;case 35667:case 35671:return Tbe;case 35668:case 35672:return Abe;case 35669:case 35673:return kbe;case 5125:return jbe;case 36294:return Pbe;case 36295:return Rbe;case 36296:return Dbe;case 35678:case 36198:case 36298:case 36306:case 35682:return Obe;case 35679:case 36299:case 36307:return Lbe;case 35680:case 36300:case 36308:case 36293:return Ibe;case 36289:case 36303:case 36311:case 36292:return Fbe}}function zbe(t,e){t.uniform1fv(this.addr,e)}function Bbe(t,e){const n=_x(e,this.size,2);t.uniform2fv(this.addr,n)}function $be(t,e){const n=_x(e,this.size,3);t.uniform3fv(this.addr,n)}function Hbe(t,e){const n=_x(e,this.size,4);t.uniform4fv(this.addr,n)}function Vbe(t,e){const n=_x(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function Gbe(t,e){const n=_x(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function qbe(t,e){const n=_x(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function Wbe(t,e){t.uniform1iv(this.addr,e)}function Kbe(t,e){t.uniform2iv(this.addr,e)}function Xbe(t,e){t.uniform3iv(this.addr,e)}function Ybe(t,e){t.uniform4iv(this.addr,e)}function Qbe(t,e){t.uniform1uiv(this.addr,e)}function Zbe(t,e){t.uniform2uiv(this.addr,e)}function Jbe(t,e){t.uniform3uiv(this.addr,e)}function e0e(t,e){t.uniform4uiv(this.addr,e)}function t0e(t,e,n){const r=this.cache,i=e.length,s=NN(n,i);Xi(r,s)||(t.uniform1iv(this.addr,s),Yi(r,s));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||wK,s[o])}function n0e(t,e,n){const r=this.cache,i=e.length,s=NN(n,i);Xi(r,s)||(t.uniform1iv(this.addr,s),Yi(r,s));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||NK,s[o])}function r0e(t,e,n){const r=this.cache,i=e.length,s=NN(n,i);Xi(r,s)||(t.uniform1iv(this.addr,s),Yi(r,s));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||MK,s[o])}function i0e(t,e,n){const r=this.cache,i=e.length,s=NN(n,i);Xi(r,s)||(t.uniform1iv(this.addr,s),Yi(r,s));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||SK,s[o])}function a0e(t){switch(t){case 5126:return zbe;case 35664:return Bbe;case 35665:return $be;case 35666:return Hbe;case 35674:return Vbe;case 35675:return Gbe;case 35676:return qbe;case 5124:case 35670:return Wbe;case 35667:case 35671:return Kbe;case 35668:case 35672:return Xbe;case 35669:case 35673:return Ybe;case 5125:return Qbe;case 36294:return Zbe;case 36295:return Jbe;case 36296:return e0e;case 35678:case 36198:case 36298:case 36306:case 35682:return t0e;case 35679:case 36299:case 36307:return n0e;case 35680:case 36300:case 36308:case 36293:return r0e;case 36289:case 36303:case 36311:case 36292:return i0e}}let s0e=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=Ube(n.type)}},o0e=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=a0e(n.type)}},l0e=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let s=0,o=i.length;s!==o;++s){const l=i[s];l.setValue(e,n[l.id],r)}}};const LT=/(\w+)(\])?(\[|\.)?/g;function LB(t,e){t.seq.push(e),t.map[e.id]=e}function c0e(t,e,n){const r=t.name,i=r.length;for(LT.lastIndex=0;;){const s=LT.exec(r),o=LT.lastIndex;let l=s[1];const c=s[2]==="]",u=s[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){LB(n,u===void 0?new s0e(l,t,e):new o0e(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new l0e(l),LB(n,f)),n=f}}}let M1=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),o=e.getUniformLocation(n,s.name);c0e(s,o,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,o=n.length;s!==o;++s){const l=n[s],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,s=e.length;i!==s;++i){const o=e[i];o.id in n&&r.push(o)}return r}};function IB(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const u0e=37297;let d0e=0;function h0e(t,e){const n=t.split(`
  3750. `),r=[],i=Math.max(e-6,0),s=Math.min(e+6,n.length);for(let o=i;o<s;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
  3751. `)}const FB=new Pn;function f0e(t){ar._getMatrix(FB,ar.workingColorSpace,t);const e=`mat3( ${FB.elements.map(n=>n.toFixed(4))} )`;switch(ar.getTransfer(t)){case Y1:return[e,"LinearTransferOETF"];case Nr:return[e,"sRGBTransferOETF"];default:return mn("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function UB(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),s=(t.getShaderInfoLog(e)||"").trim();if(r&&s==="")return"";const o=/ERROR: 0:(\d+)/.exec(s);if(o){const l=parseInt(o[1]);return n.toUpperCase()+`
  3752. `+s+`
  3753. `+h0e(t.getShaderSource(e),l)}else return s}function m0e(t,e){const n=f0e(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
  3754. `)}function p0e(t,e){let n;switch(e){case cme:n="Linear";break;case ume:n="Reinhard";break;case dme:n="Cineon";break;case hme:n="ACESFilmic";break;case mme:n="AgX";break;case pme:n="Neutral";break;case fme:n="Custom";break;default:mn("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const nw=new lt;function g0e(){ar.getLuminanceCoefficients(nw);const t=nw.x.toFixed(4),e=nw.y.toFixed(4),n=nw.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
  3755. `)}function x0e(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(a0).join(`
  3756. `)}function b0e(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  3757. `)}function y0e(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const s=t.getActiveAttrib(e,i),o=s.name;let l=1;s.type===t.FLOAT_MAT2&&(l=2),s.type===t.FLOAT_MAT3&&(l=3),s.type===t.FLOAT_MAT4&&(l=4),n[o]={type:s.type,location:t.getAttribLocation(e,o),locationSize:l}}return n}function a0(t){return t!==""}function zB(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 BB(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const v0e=/^[ \t]*#include +<([\w\d./]+)>/gm;function uP(t){return t.replace(v0e,w0e)}const _0e=new Map;function w0e(t,e){let n=Cn[e];if(n===void 0){const r=_0e.get(e);if(r!==void 0)n=Cn[r],mn('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return uP(n)}const S0e=/#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 $B(t){return t.replace(S0e,N0e)}function N0e(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 HB(t){let e=`precision ${t.precision} float;
  3758. precision ${t.precision} int;
  3759. precision ${t.precision} sampler2D;
  3760. precision ${t.precision} samplerCube;
  3761. precision ${t.precision} sampler3D;
  3762. precision ${t.precision} sampler2DArray;
  3763. precision ${t.precision} sampler2DShadow;
  3764. precision ${t.precision} samplerCubeShadow;
  3765. precision ${t.precision} sampler2DArrayShadow;
  3766. precision ${t.precision} isampler2D;
  3767. precision ${t.precision} isampler3D;
  3768. precision ${t.precision} isamplerCube;
  3769. precision ${t.precision} isampler2DArray;
  3770. precision ${t.precision} usampler2D;
  3771. precision ${t.precision} usampler3D;
  3772. precision ${t.precision} usamplerCube;
  3773. precision ${t.precision} usampler2DArray;
  3774. `;return t.precision==="highp"?e+=`
  3775. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  3776. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  3777. #define LOW_PRECISION`),e}function M0e(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===BW?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===$fe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===ou&&(e="SHADOWMAP_TYPE_VSM"),e}function E0e(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Vg:case Gg:e="ENVMAP_TYPE_CUBE";break;case _N:e="ENVMAP_TYPE_CUBE_UV";break}return e}function C0e(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Gg:e="ENVMAP_MODE_REFRACTION";break}return e}function T0e(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case BD:e="ENVMAP_BLENDING_MULTIPLY";break;case ome:e="ENVMAP_BLENDING_MIX";break;case lme:e="ENVMAP_BLENDING_ADD";break}return e}function A0e(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 k0e(t,e,n,r){const i=t.getContext(),s=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=M0e(n),u=E0e(n),d=C0e(n),f=T0e(n),m=A0e(n),p=x0e(n),x=b0e(s),b=i.createProgram();let y,v,S=n.glslVersion?"#version "+n.glslVersion+`
  3778. `:"";n.isRawShaderMaterial?(y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(a0).join(`
  3779. `),y.length>0&&(y+=`
  3780. `),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(a0).join(`
  3781. `),v.length>0&&(v+=`
  3782. `)):(y=[HB(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  3783. `].filter(a0).join(`
  3784. `),v=[HB(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:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==sh?"#define TONE_MAPPING":"",n.toneMapping!==sh?Cn.tonemapping_pars_fragment:"",n.toneMapping!==sh?p0e("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Cn.colorspace_pars_fragment,m0e("linearToOutputTexel",n.outputColorSpace),g0e(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  3785. `].filter(a0).join(`
  3786. `)),o=uP(o),o=zB(o,n),o=BB(o,n),l=uP(l),l=zB(l,n),l=BB(l,n),o=$B(o),l=$B(l),n.isRawShaderMaterial!==!0&&(S=`#version 300 es
  3787. `,y=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
  3788. `)+`
  3789. `+y,v=["#define varying in",n.glslVersion===Xz?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Xz?"":"#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(`
  3790. `)+`
  3791. `+v);const N=S+y+o,C=S+v+l,T=IB(i,i.VERTEX_SHADER,N),k=IB(i,i.FRAGMENT_SHADER,C);i.attachShader(b,T),i.attachShader(b,k),n.index0AttributeName!==void 0?i.bindAttribLocation(b,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(b,0,"position"),i.linkProgram(b);function E(F){if(t.debug.checkShaderErrors){const O=i.getProgramInfoLog(b)||"",H=i.getShaderInfoLog(T)||"",j=i.getShaderInfoLog(k)||"",G=O.trim(),$=H.trim(),q=j.trim();let Y=!0,Z=!0;if(i.getProgramParameter(b,i.LINK_STATUS)===!1)if(Y=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,b,T,k);else{const oe=UB(i,T,"vertex"),B=UB(i,k,"fragment");_i("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(b,i.VALIDATE_STATUS)+`
  3792. Material Name: `+F.name+`
  3793. Material Type: `+F.type+`
  3794. Program Info Log: `+G+`
  3795. `+oe+`
  3796. `+B)}else G!==""?mn("WebGLProgram: Program Info Log:",G):($===""||q==="")&&(Z=!1);Z&&(F.diagnostics={runnable:Y,programLog:G,vertexShader:{log:$,prefix:y},fragmentShader:{log:q,prefix:v}})}i.deleteShader(T),i.deleteShader(k),D=new M1(i,b),A=y0e(i,b)}let D;this.getUniforms=function(){return D===void 0&&E(this),D};let A;this.getAttributes=function(){return A===void 0&&E(this),A};let R=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=i.getProgramParameter(b,u0e)),R},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(b),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=d0e++,this.cacheKey=e,this.usedTimes=1,this.program=b,this.vertexShader=T,this.fragmentShader=k,this}let j0e=0,P0e=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),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.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 R0e(e),n.set(e,r)),r}},R0e=class{constructor(e){this.id=j0e++,this.code=e,this.usedTimes=0}};function D0e(t,e,n,r,i,s,o){const l=new aK,c=new P0e,u=new Set,d=[],f=i.logarithmicDepthBuffer,m=i.vertexTextures;let p=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 b(A){return u.add(A),A===0?"uv":`uv${A}`}function y(A,R,F,O,H){const j=O.fog,G=H.geometry,$=A.isMeshStandardMaterial?O.environment:null,q=(A.isMeshStandardMaterial?n:e).get(A.envMap||$),Y=q&&q.mapping===_N?q.image.height:null,Z=x[A.type];A.precision!==null&&(p=i.getMaxPrecision(A.precision),p!==A.precision&&mn("WebGLProgram.getParameters:",A.precision,"not supported, using",p,"instead."));const oe=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,B=oe!==void 0?oe.length:0;let W=0;G.morphAttributes.position!==void 0&&(W=1),G.morphAttributes.normal!==void 0&&(W=2),G.morphAttributes.color!==void 0&&(W=3);let se,ne,ce,fe;if(Z){const ut=nc[Z];se=ut.vertexShader,ne=ut.fragmentShader}else se=A.vertexShader,ne=A.fragmentShader,c.update(A),ce=c.getVertexShaderID(A),fe=c.getFragmentShaderID(A);const ye=t.getRenderTarget(),ge=t.state.buffers.depth.getReversed(),xe=H.isInstancedMesh===!0,Pe=H.isBatchedMesh===!0,Ue=!!A.map,be=!!A.matcap,it=!!q,U=!!A.aoMap,K=!!A.lightMap,J=!!A.bumpMap,Q=!!A.normalMap,z=!!A.displacementMap,re=!!A.emissiveMap,Ee=!!A.metalnessMap,_e=!!A.roughnessMap,Te=A.anisotropy>0,V=A.clearcoat>0,L=A.dispersion>0,X=A.iridescence>0,te=A.sheen>0,Me=A.transmission>0,ie=Te&&!!A.anisotropyMap,De=V&&!!A.clearcoatMap,Le=V&&!!A.clearcoatNormalMap,$e=V&&!!A.clearcoatRoughnessMap,Ze=X&&!!A.iridescenceMap,Ie=X&&!!A.iridescenceThicknessMap,ae=te&&!!A.sheenColorMap,He=te&&!!A.sheenRoughnessMap,Se=!!A.specularMap,Be=!!A.specularColorMap,ft=!!A.specularIntensityMap,we=Me&&!!A.transmissionMap,tt=Me&&!!A.thicknessMap,ke=!!A.gradientMap,We=!!A.alphaMap,pe=A.alphaTest>0,Ce=!!A.alphaHash,de=!!A.extensions;let Ve=sh;A.toneMapped&&(ye===null||ye.isXRRenderTarget===!0)&&(Ve=t.toneMapping);const yt={shaderID:Z,shaderType:A.type,shaderName:A.name,vertexShader:se,fragmentShader:ne,defines:A.defines,customVertexShaderID:ce,customFragmentShaderID:fe,isRawShaderMaterial:A.isRawShaderMaterial===!0,glslVersion:A.glslVersion,precision:p,batching:Pe,batchingColor:Pe&&H._colorsTexture!==null,instancing:xe,instancingColor:xe&&H.instanceColor!==null,instancingMorph:xe&&H.morphTexture!==null,supportsVertexTextures:m,outputColorSpace:ye===null?t.outputColorSpace:ye.isXRRenderTarget===!0?ye.texture.colorSpace:qg,alphaToCoverage:!!A.alphaToCoverage,map:Ue,matcap:be,envMap:it,envMapMode:it&&q.mapping,envMapCubeUVHeight:Y,aoMap:U,lightMap:K,bumpMap:J,normalMap:Q,displacementMap:m&&z,emissiveMap:re,normalMapObjectSpace:Q&&A.normalMapType===yme,normalMapTangentSpace:Q&&A.normalMapType===YW,metalnessMap:Ee,roughnessMap:_e,anisotropy:Te,anisotropyMap:ie,clearcoat:V,clearcoatMap:De,clearcoatNormalMap:Le,clearcoatRoughnessMap:$e,dispersion:L,iridescence:X,iridescenceMap:Ze,iridescenceThicknessMap:Ie,sheen:te,sheenColorMap:ae,sheenRoughnessMap:He,specularMap:Se,specularColorMap:Be,specularIntensityMap:ft,transmission:Me,transmissionMap:we,thicknessMap:tt,gradientMap:ke,opaque:A.transparent===!1&&A.blending===Eg&&A.alphaToCoverage===!1,alphaMap:We,alphaTest:pe,alphaHash:Ce,combine:A.combine,mapUv:Ue&&b(A.map.channel),aoMapUv:U&&b(A.aoMap.channel),lightMapUv:K&&b(A.lightMap.channel),bumpMapUv:J&&b(A.bumpMap.channel),normalMapUv:Q&&b(A.normalMap.channel),displacementMapUv:z&&b(A.displacementMap.channel),emissiveMapUv:re&&b(A.emissiveMap.channel),metalnessMapUv:Ee&&b(A.metalnessMap.channel),roughnessMapUv:_e&&b(A.roughnessMap.channel),anisotropyMapUv:ie&&b(A.anisotropyMap.channel),clearcoatMapUv:De&&b(A.clearcoatMap.channel),clearcoatNormalMapUv:Le&&b(A.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:$e&&b(A.clearcoatRoughnessMap.channel),iridescenceMapUv:Ze&&b(A.iridescenceMap.channel),iridescenceThicknessMapUv:Ie&&b(A.iridescenceThicknessMap.channel),sheenColorMapUv:ae&&b(A.sheenColorMap.channel),sheenRoughnessMapUv:He&&b(A.sheenRoughnessMap.channel),specularMapUv:Se&&b(A.specularMap.channel),specularColorMapUv:Be&&b(A.specularColorMap.channel),specularIntensityMapUv:ft&&b(A.specularIntensityMap.channel),transmissionMapUv:we&&b(A.transmissionMap.channel),thicknessMapUv:tt&&b(A.thicknessMap.channel),alphaMapUv:We&&b(A.alphaMap.channel),vertexTangents:!!G.attributes.tangent&&(Q||Te),vertexColors:A.vertexColors,vertexAlphas:A.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,pointsUvs:H.isPoints===!0&&!!G.attributes.uv&&(Ue||We),fog:!!j,useFog:A.fog===!0,fogExp2:!!j&&j.isFogExp2,flatShading:A.flatShading===!0&&A.wireframe===!1,sizeAttenuation:A.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:ge,skinning:H.isSkinnedMesh===!0,morphTargets:G.morphAttributes.position!==void 0,morphNormals:G.morphAttributes.normal!==void 0,morphColors:G.morphAttributes.color!==void 0,morphTargetsCount:B,morphTextureStride:W,numDirLights:R.directional.length,numPointLights:R.point.length,numSpotLights:R.spot.length,numSpotLightMaps:R.spotLightMap.length,numRectAreaLights:R.rectArea.length,numHemiLights:R.hemi.length,numDirLightShadows:R.directionalShadowMap.length,numPointLightShadows:R.pointShadowMap.length,numSpotLightShadows:R.spotShadowMap.length,numSpotLightShadowsWithMaps:R.numSpotLightShadowsWithMaps,numLightProbes:R.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:A.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:Ve,decodeVideoTexture:Ue&&A.map.isVideoTexture===!0&&ar.getTransfer(A.map.colorSpace)===Nr,decodeVideoTextureEmissive:re&&A.emissiveMap.isVideoTexture===!0&&ar.getTransfer(A.emissiveMap.colorSpace)===Nr,premultipliedAlpha:A.premultipliedAlpha,doubleSided:A.side===ic,flipSided:A.side===zs,useDepthPacking:A.depthPacking>=0,depthPacking:A.depthPacking||0,index0AttributeName:A.index0AttributeName,extensionClipCullDistance:de&&A.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(de&&A.extensions.multiDraw===!0||Pe)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:A.customProgramCacheKey()};return yt.vertexUv1s=u.has(1),yt.vertexUv2s=u.has(2),yt.vertexUv3s=u.has(3),u.clear(),yt}function v(A){const R=[];if(A.shaderID?R.push(A.shaderID):(R.push(A.customVertexShaderID),R.push(A.customFragmentShaderID)),A.defines!==void 0)for(const F in A.defines)R.push(F),R.push(A.defines[F]);return A.isRawShaderMaterial===!1&&(S(R,A),N(R,A),R.push(t.outputColorSpace)),R.push(A.customProgramCacheKey),R.join()}function S(A,R){A.push(R.precision),A.push(R.outputColorSpace),A.push(R.envMapMode),A.push(R.envMapCubeUVHeight),A.push(R.mapUv),A.push(R.alphaMapUv),A.push(R.lightMapUv),A.push(R.aoMapUv),A.push(R.bumpMapUv),A.push(R.normalMapUv),A.push(R.displacementMapUv),A.push(R.emissiveMapUv),A.push(R.metalnessMapUv),A.push(R.roughnessMapUv),A.push(R.anisotropyMapUv),A.push(R.clearcoatMapUv),A.push(R.clearcoatNormalMapUv),A.push(R.clearcoatRoughnessMapUv),A.push(R.iridescenceMapUv),A.push(R.iridescenceThicknessMapUv),A.push(R.sheenColorMapUv),A.push(R.sheenRoughnessMapUv),A.push(R.specularMapUv),A.push(R.specularColorMapUv),A.push(R.specularIntensityMapUv),A.push(R.transmissionMapUv),A.push(R.thicknessMapUv),A.push(R.combine),A.push(R.fogExp2),A.push(R.sizeAttenuation),A.push(R.morphTargetsCount),A.push(R.morphAttributeCount),A.push(R.numDirLights),A.push(R.numPointLights),A.push(R.numSpotLights),A.push(R.numSpotLightMaps),A.push(R.numHemiLights),A.push(R.numRectAreaLights),A.push(R.numDirLightShadows),A.push(R.numPointLightShadows),A.push(R.numSpotLightShadows),A.push(R.numSpotLightShadowsWithMaps),A.push(R.numLightProbes),A.push(R.shadowMapType),A.push(R.toneMapping),A.push(R.numClippingPlanes),A.push(R.numClipIntersection),A.push(R.depthPacking)}function N(A,R){l.disableAll(),R.supportsVertexTextures&&l.enable(0),R.instancing&&l.enable(1),R.instancingColor&&l.enable(2),R.instancingMorph&&l.enable(3),R.matcap&&l.enable(4),R.envMap&&l.enable(5),R.normalMapObjectSpace&&l.enable(6),R.normalMapTangentSpace&&l.enable(7),R.clearcoat&&l.enable(8),R.iridescence&&l.enable(9),R.alphaTest&&l.enable(10),R.vertexColors&&l.enable(11),R.vertexAlphas&&l.enable(12),R.vertexUv1s&&l.enable(13),R.vertexUv2s&&l.enable(14),R.vertexUv3s&&l.enable(15),R.vertexTangents&&l.enable(16),R.anisotropy&&l.enable(17),R.alphaHash&&l.enable(18),R.batching&&l.enable(19),R.dispersion&&l.enable(20),R.batchingColor&&l.enable(21),R.gradientMap&&l.enable(22),A.push(l.mask),l.disableAll(),R.fog&&l.enable(0),R.useFog&&l.enable(1),R.flatShading&&l.enable(2),R.logarithmicDepthBuffer&&l.enable(3),R.reversedDepthBuffer&&l.enable(4),R.skinning&&l.enable(5),R.morphTargets&&l.enable(6),R.morphNormals&&l.enable(7),R.morphColors&&l.enable(8),R.premultipliedAlpha&&l.enable(9),R.shadowMapEnabled&&l.enable(10),R.doubleSided&&l.enable(11),R.flipSided&&l.enable(12),R.useDepthPacking&&l.enable(13),R.dithering&&l.enable(14),R.transmission&&l.enable(15),R.sheen&&l.enable(16),R.opaque&&l.enable(17),R.pointsUvs&&l.enable(18),R.decodeVideoTexture&&l.enable(19),R.decodeVideoTextureEmissive&&l.enable(20),R.alphaToCoverage&&l.enable(21),A.push(l.mask)}function C(A){const R=x[A.type];let F;if(R){const O=nc[R];F=Xme.clone(O.uniforms)}else F=A.uniforms;return F}function T(A,R){let F;for(let O=0,H=d.length;O<H;O++){const j=d[O];if(j.cacheKey===R){F=j,++F.usedTimes;break}}return F===void 0&&(F=new k0e(t,R,A,s),d.push(F)),F}function k(A){if(--A.usedTimes===0){const R=d.indexOf(A);d[R]=d[d.length-1],d.pop(),A.destroy()}}function E(A){c.remove(A)}function D(){c.dispose()}return{getParameters:y,getProgramCacheKey:v,getUniforms:C,acquireProgram:T,releaseProgram:k,releaseShaderCache:E,programs:d,dispose:D}}function O0e(){let t=new WeakMap;function e(o){return t.has(o)}function n(o){let l=t.get(o);return l===void 0&&(l={},t.set(o,l)),l}function r(o){t.delete(o)}function i(o,l,c){t.get(o)[l]=c}function s(){t=new WeakMap}return{has:e,get:n,remove:r,update:i,dispose:s}}function L0e(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 VB(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 GB(){const t=[];let e=0;const n=[],r=[],i=[];function s(){e=0,n.length=0,r.length=0,i.length=0}function o(f,m,p,x,b,y){let v=t[e];return v===void 0?(v={id:f.id,object:f,geometry:m,material:p,groupOrder:x,renderOrder:f.renderOrder,z:b,group:y},t[e]=v):(v.id=f.id,v.object=f,v.geometry=m,v.material=p,v.groupOrder=x,v.renderOrder=f.renderOrder,v.z=b,v.group=y),e++,v}function l(f,m,p,x,b,y){const v=o(f,m,p,x,b,y);p.transmission>0?r.push(v):p.transparent===!0?i.push(v):n.push(v)}function c(f,m,p,x,b,y){const v=o(f,m,p,x,b,y);p.transmission>0?r.unshift(v):p.transparent===!0?i.unshift(v):n.unshift(v)}function u(f,m){n.length>1&&n.sort(f||L0e),r.length>1&&r.sort(m||VB),i.length>1&&i.sort(m||VB)}function d(){for(let f=e,m=t.length;f<m;f++){const p=t[f];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:n,transmissive:r,transparent:i,init:s,push:l,unshift:c,finish:d,sort:u}}function I0e(){let t=new WeakMap;function e(r,i){const s=t.get(r);let o;return s===void 0?(o=new GB,t.set(r,[o])):i>=s.length?(o=new GB,s.push(o)):o=s[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function F0e(){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 lt,color:new Rn};break;case"SpotLight":n={position:new lt,direction:new lt,color:new Rn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new lt,color:new Rn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new lt,skyColor:new Rn,groundColor:new Rn};break;case"RectAreaLight":n={color:new Rn,position:new lt,halfWidth:new lt,halfHeight:new lt};break}return t[e.id]=n,n}}}function U0e(){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 An};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new An};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new An,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let z0e=0;function B0e(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function $0e(t){const e=new F0e,n=U0e(),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 lt);const i=new lt,s=new Fi,o=new Fi;function l(u){let d=0,f=0,m=0;for(let A=0;A<9;A++)r.probe[A].set(0,0,0);let p=0,x=0,b=0,y=0,v=0,S=0,N=0,C=0,T=0,k=0,E=0;u.sort(B0e);for(let A=0,R=u.length;A<R;A++){const F=u[A],O=F.color,H=F.intensity,j=F.distance,G=F.shadow&&F.shadow.map?F.shadow.map.texture:null;if(F.isAmbientLight)d+=O.r*H,f+=O.g*H,m+=O.b*H;else if(F.isLightProbe){for(let $=0;$<9;$++)r.probe[$].addScaledVector(F.sh.coefficients[$],H);E++}else if(F.isDirectionalLight){const $=e.get(F);if($.color.copy(F.color).multiplyScalar(F.intensity),F.castShadow){const q=F.shadow,Y=n.get(F);Y.shadowIntensity=q.intensity,Y.shadowBias=q.bias,Y.shadowNormalBias=q.normalBias,Y.shadowRadius=q.radius,Y.shadowMapSize=q.mapSize,r.directionalShadow[p]=Y,r.directionalShadowMap[p]=G,r.directionalShadowMatrix[p]=F.shadow.matrix,S++}r.directional[p]=$,p++}else if(F.isSpotLight){const $=e.get(F);$.position.setFromMatrixPosition(F.matrixWorld),$.color.copy(O).multiplyScalar(H),$.distance=j,$.coneCos=Math.cos(F.angle),$.penumbraCos=Math.cos(F.angle*(1-F.penumbra)),$.decay=F.decay,r.spot[b]=$;const q=F.shadow;if(F.map&&(r.spotLightMap[T]=F.map,T++,q.updateMatrices(F),F.castShadow&&k++),r.spotLightMatrix[b]=q.matrix,F.castShadow){const Y=n.get(F);Y.shadowIntensity=q.intensity,Y.shadowBias=q.bias,Y.shadowNormalBias=q.normalBias,Y.shadowRadius=q.radius,Y.shadowMapSize=q.mapSize,r.spotShadow[b]=Y,r.spotShadowMap[b]=G,C++}b++}else if(F.isRectAreaLight){const $=e.get(F);$.color.copy(O).multiplyScalar(H),$.halfWidth.set(F.width*.5,0,0),$.halfHeight.set(0,F.height*.5,0),r.rectArea[y]=$,y++}else if(F.isPointLight){const $=e.get(F);if($.color.copy(F.color).multiplyScalar(F.intensity),$.distance=F.distance,$.decay=F.decay,F.castShadow){const q=F.shadow,Y=n.get(F);Y.shadowIntensity=q.intensity,Y.shadowBias=q.bias,Y.shadowNormalBias=q.normalBias,Y.shadowRadius=q.radius,Y.shadowMapSize=q.mapSize,Y.shadowCameraNear=q.camera.near,Y.shadowCameraFar=q.camera.far,r.pointShadow[x]=Y,r.pointShadowMap[x]=G,r.pointShadowMatrix[x]=F.shadow.matrix,N++}r.point[x]=$,x++}else if(F.isHemisphereLight){const $=e.get(F);$.skyColor.copy(F.color).multiplyScalar(H),$.groundColor.copy(F.groundColor).multiplyScalar(H),r.hemi[v]=$,v++}}y>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Ot.LTC_FLOAT_1,r.rectAreaLTC2=Ot.LTC_FLOAT_2):(r.rectAreaLTC1=Ot.LTC_HALF_1,r.rectAreaLTC2=Ot.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=f,r.ambient[2]=m;const D=r.hash;(D.directionalLength!==p||D.pointLength!==x||D.spotLength!==b||D.rectAreaLength!==y||D.hemiLength!==v||D.numDirectionalShadows!==S||D.numPointShadows!==N||D.numSpotShadows!==C||D.numSpotMaps!==T||D.numLightProbes!==E)&&(r.directional.length=p,r.spot.length=b,r.rectArea.length=y,r.point.length=x,r.hemi.length=v,r.directionalShadow.length=S,r.directionalShadowMap.length=S,r.pointShadow.length=N,r.pointShadowMap.length=N,r.spotShadow.length=C,r.spotShadowMap.length=C,r.directionalShadowMatrix.length=S,r.pointShadowMatrix.length=N,r.spotLightMatrix.length=C+T-k,r.spotLightMap.length=T,r.numSpotLightShadowsWithMaps=k,r.numLightProbes=E,D.directionalLength=p,D.pointLength=x,D.spotLength=b,D.rectAreaLength=y,D.hemiLength=v,D.numDirectionalShadows=S,D.numPointShadows=N,D.numSpotShadows=C,D.numSpotMaps=T,D.numLightProbes=E,r.version=z0e++)}function c(u,d){let f=0,m=0,p=0,x=0,b=0;const y=d.matrixWorldInverse;for(let v=0,S=u.length;v<S;v++){const N=u[v];if(N.isDirectionalLight){const C=r.directional[f];C.direction.setFromMatrixPosition(N.matrixWorld),i.setFromMatrixPosition(N.target.matrixWorld),C.direction.sub(i),C.direction.transformDirection(y),f++}else if(N.isSpotLight){const C=r.spot[p];C.position.setFromMatrixPosition(N.matrixWorld),C.position.applyMatrix4(y),C.direction.setFromMatrixPosition(N.matrixWorld),i.setFromMatrixPosition(N.target.matrixWorld),C.direction.sub(i),C.direction.transformDirection(y),p++}else if(N.isRectAreaLight){const C=r.rectArea[x];C.position.setFromMatrixPosition(N.matrixWorld),C.position.applyMatrix4(y),o.identity(),s.copy(N.matrixWorld),s.premultiply(y),o.extractRotation(s),C.halfWidth.set(N.width*.5,0,0),C.halfHeight.set(0,N.height*.5,0),C.halfWidth.applyMatrix4(o),C.halfHeight.applyMatrix4(o),x++}else if(N.isPointLight){const C=r.point[m];C.position.setFromMatrixPosition(N.matrixWorld),C.position.applyMatrix4(y),m++}else if(N.isHemisphereLight){const C=r.hemi[b];C.direction.setFromMatrixPosition(N.matrixWorld),C.direction.transformDirection(y),b++}}}return{setup:l,setupView:c,state:r}}function qB(t){const e=new $0e(t),n=[],r=[];function i(d){u.camera=d,n.length=0,r.length=0}function s(d){n.push(d)}function o(d){r.push(d)}function l(){e.setup(n)}function c(d){e.setupView(n,d)}const u={lightsArray:n,shadowsArray:r,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:u,setupLights:l,setupLightsView:c,pushLight:s,pushShadow:o}}function H0e(t){let e=new WeakMap;function n(i,s=0){const o=e.get(i);let l;return o===void 0?(l=new qB(t),e.set(i,[l])):s>=o.length?(l=new qB(t),o.push(l)):l=o[s],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const V0e=`void main() {
  3797. gl_Position = vec4( position, 1.0 );
  3798. }`,G0e=`uniform sampler2D shadow_pass;
  3799. uniform vec2 resolution;
  3800. uniform float radius;
  3801. #include <packing>
  3802. void main() {
  3803. const float samples = float( VSM_SAMPLES );
  3804. float mean = 0.0;
  3805. float squared_mean = 0.0;
  3806. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  3807. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  3808. for ( float i = 0.0; i < samples; i ++ ) {
  3809. float uvOffset = uvStart + i * uvStride;
  3810. #ifdef HORIZONTAL_PASS
  3811. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  3812. mean += distribution.x;
  3813. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  3814. #else
  3815. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  3816. mean += depth;
  3817. squared_mean += depth * depth;
  3818. #endif
  3819. }
  3820. mean = mean / samples;
  3821. squared_mean = squared_mean / samples;
  3822. float std_dev = sqrt( squared_mean - mean * mean );
  3823. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  3824. }`;function q0e(t,e,n){let r=new JD;const i=new An,s=new An,o=new Di,l=new lpe({depthPacking:bme}),c=new cpe,u={},d=n.maxTextureSize,f={[_h]:zs,[zs]:_h,[ic]:ic},m=new Ou({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new An},radius:{value:4}},vertexShader:V0e,fragmentShader:G0e}),p=m.clone();p.defines.HORIZONTAL_PASS=1;const x=new al;x.setAttribute("position",new bs(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const b=new sl(x,m),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=BW;let v=this.type;this.render=function(k,E,D){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||k.length===0)return;const A=t.getRenderTarget(),R=t.getActiveCubeFace(),F=t.getActiveMipmapLevel(),O=t.state;O.setBlending(Mu),O.buffers.depth.getReversed()===!0?O.buffers.color.setClear(0,0,0,0):O.buffers.color.setClear(1,1,1,1),O.buffers.depth.setTest(!0),O.setScissorTest(!1);const H=v!==ou&&this.type===ou,j=v===ou&&this.type!==ou;for(let G=0,$=k.length;G<$;G++){const q=k[G],Y=q.shadow;if(Y===void 0){mn("WebGLShadowMap:",q,"has no shadow.");continue}if(Y.autoUpdate===!1&&Y.needsUpdate===!1)continue;i.copy(Y.mapSize);const Z=Y.getFrameExtents();if(i.multiply(Z),s.copy(Y.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/Z.x),i.x=s.x*Z.x,Y.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/Z.y),i.y=s.y*Z.y,Y.mapSize.y=s.y)),Y.map===null||H===!0||j===!0){const B=this.type!==ou?{minFilter:mo,magFilter:mo}:{};Y.map!==null&&Y.map.dispose(),Y.map=new um(i.x,i.y,B),Y.map.texture.name=q.name+".shadowMap",Y.camera.updateProjectionMatrix()}t.setRenderTarget(Y.map),t.clear();const oe=Y.getViewportCount();for(let B=0;B<oe;B++){const W=Y.getViewport(B);o.set(s.x*W.x,s.y*W.y,s.x*W.z,s.y*W.w),O.viewport(o),Y.updateMatrices(q,B),r=Y.getFrustum(),C(E,D,Y.camera,q,this.type)}Y.isPointLightShadow!==!0&&this.type===ou&&S(Y,D),Y.needsUpdate=!1}v=this.type,y.needsUpdate=!1,t.setRenderTarget(A,R,F)};function S(k,E){const D=e.update(b);m.defines.VSM_SAMPLES!==k.blurSamples&&(m.defines.VSM_SAMPLES=k.blurSamples,p.defines.VSM_SAMPLES=k.blurSamples,m.needsUpdate=!0,p.needsUpdate=!0),k.mapPass===null&&(k.mapPass=new um(i.x,i.y)),m.uniforms.shadow_pass.value=k.map.texture,m.uniforms.resolution.value=k.mapSize,m.uniforms.radius.value=k.radius,t.setRenderTarget(k.mapPass),t.clear(),t.renderBufferDirect(E,null,D,m,b,null),p.uniforms.shadow_pass.value=k.mapPass.texture,p.uniforms.resolution.value=k.mapSize,p.uniforms.radius.value=k.radius,t.setRenderTarget(k.map),t.clear(),t.renderBufferDirect(E,null,D,p,b,null)}function N(k,E,D,A){let R=null;const F=D.isPointLight===!0?k.customDistanceMaterial:k.customDepthMaterial;if(F!==void 0)R=F;else if(R=D.isPointLight===!0?c:l,t.localClippingEnabled&&E.clipShadows===!0&&Array.isArray(E.clippingPlanes)&&E.clippingPlanes.length!==0||E.displacementMap&&E.displacementScale!==0||E.alphaMap&&E.alphaTest>0||E.map&&E.alphaTest>0||E.alphaToCoverage===!0){const O=R.uuid,H=E.uuid;let j=u[O];j===void 0&&(j={},u[O]=j);let G=j[H];G===void 0&&(G=R.clone(),j[H]=G,E.addEventListener("dispose",T)),R=G}if(R.visible=E.visible,R.wireframe=E.wireframe,A===ou?R.side=E.shadowSide!==null?E.shadowSide:E.side:R.side=E.shadowSide!==null?E.shadowSide:f[E.side],R.alphaMap=E.alphaMap,R.alphaTest=E.alphaToCoverage===!0?.5:E.alphaTest,R.map=E.map,R.clipShadows=E.clipShadows,R.clippingPlanes=E.clippingPlanes,R.clipIntersection=E.clipIntersection,R.displacementMap=E.displacementMap,R.displacementScale=E.displacementScale,R.displacementBias=E.displacementBias,R.wireframeLinewidth=E.wireframeLinewidth,R.linewidth=E.linewidth,D.isPointLight===!0&&R.isMeshDistanceMaterial===!0){const O=t.properties.get(R);O.light=D}return R}function C(k,E,D,A,R){if(k.visible===!1)return;if(k.layers.test(E.layers)&&(k.isMesh||k.isLine||k.isPoints)&&(k.castShadow||k.receiveShadow&&R===ou)&&(!k.frustumCulled||r.intersectsObject(k))){k.modelViewMatrix.multiplyMatrices(D.matrixWorldInverse,k.matrixWorld);const H=e.update(k),j=k.material;if(Array.isArray(j)){const G=H.groups;for(let $=0,q=G.length;$<q;$++){const Y=G[$],Z=j[Y.materialIndex];if(Z&&Z.visible){const oe=N(k,Z,A,R);k.onBeforeShadow(t,k,E,D,H,oe,Y),t.renderBufferDirect(D,null,H,oe,k,Y),k.onAfterShadow(t,k,E,D,H,oe,Y)}}}else if(j.visible){const G=N(k,j,A,R);k.onBeforeShadow(t,k,E,D,H,G,null),t.renderBufferDirect(D,null,H,G,k,null),k.onAfterShadow(t,k,E,D,H,G,null)}}const O=k.children;for(let H=0,j=O.length;H<j;H++)C(O[H],E,D,A,R)}function T(k){k.target.removeEventListener("dispose",T);for(const D in u){const A=u[D],R=k.target.uuid;R in A&&(A[R].dispose(),delete A[R])}}}const W0e={[S3]:N3,[M3]:T3,[E3]:A3,[Hg]:C3,[N3]:S3,[T3]:M3,[A3]:E3,[C3]:Hg};function K0e(t,e){function n(){let we=!1;const tt=new Di;let ke=null;const We=new Di(0,0,0,0);return{setMask:function(pe){ke!==pe&&!we&&(t.colorMask(pe,pe,pe,pe),ke=pe)},setLocked:function(pe){we=pe},setClear:function(pe,Ce,de,Ve,yt){yt===!0&&(pe*=Ve,Ce*=Ve,de*=Ve),tt.set(pe,Ce,de,Ve),We.equals(tt)===!1&&(t.clearColor(pe,Ce,de,Ve),We.copy(tt))},reset:function(){we=!1,ke=null,We.set(-1,0,0,0)}}}function r(){let we=!1,tt=!1,ke=null,We=null,pe=null;return{setReversed:function(Ce){if(tt!==Ce){const de=e.get("EXT_clip_control");Ce?de.clipControlEXT(de.LOWER_LEFT_EXT,de.ZERO_TO_ONE_EXT):de.clipControlEXT(de.LOWER_LEFT_EXT,de.NEGATIVE_ONE_TO_ONE_EXT),tt=Ce;const Ve=pe;pe=null,this.setClear(Ve)}},getReversed:function(){return tt},setTest:function(Ce){Ce?ye(t.DEPTH_TEST):ge(t.DEPTH_TEST)},setMask:function(Ce){ke!==Ce&&!we&&(t.depthMask(Ce),ke=Ce)},setFunc:function(Ce){if(tt&&(Ce=W0e[Ce]),We!==Ce){switch(Ce){case S3:t.depthFunc(t.NEVER);break;case N3:t.depthFunc(t.ALWAYS);break;case M3:t.depthFunc(t.LESS);break;case Hg:t.depthFunc(t.LEQUAL);break;case E3:t.depthFunc(t.EQUAL);break;case C3:t.depthFunc(t.GEQUAL);break;case T3:t.depthFunc(t.GREATER);break;case A3:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}We=Ce}},setLocked:function(Ce){we=Ce},setClear:function(Ce){pe!==Ce&&(tt&&(Ce=1-Ce),t.clearDepth(Ce),pe=Ce)},reset:function(){we=!1,ke=null,We=null,pe=null,tt=!1}}}function i(){let we=!1,tt=null,ke=null,We=null,pe=null,Ce=null,de=null,Ve=null,yt=null;return{setTest:function(ut){we||(ut?ye(t.STENCIL_TEST):ge(t.STENCIL_TEST))},setMask:function(ut){tt!==ut&&!we&&(t.stencilMask(ut),tt=ut)},setFunc:function(ut,It,Ft){(ke!==ut||We!==It||pe!==Ft)&&(t.stencilFunc(ut,It,Ft),ke=ut,We=It,pe=Ft)},setOp:function(ut,It,Ft){(Ce!==ut||de!==It||Ve!==Ft)&&(t.stencilOp(ut,It,Ft),Ce=ut,de=It,Ve=Ft)},setLocked:function(ut){we=ut},setClear:function(ut){yt!==ut&&(t.clearStencil(ut),yt=ut)},reset:function(){we=!1,tt=null,ke=null,We=null,pe=null,Ce=null,de=null,Ve=null,yt=null}}}const s=new n,o=new r,l=new i,c=new WeakMap,u=new WeakMap;let d={},f={},m=new WeakMap,p=[],x=null,b=!1,y=null,v=null,S=null,N=null,C=null,T=null,k=null,E=new Rn(0,0,0),D=0,A=!1,R=null,F=null,O=null,H=null,j=null;const G=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let $=!1,q=0;const Y=t.getParameter(t.VERSION);Y.indexOf("WebGL")!==-1?(q=parseFloat(/^WebGL (\d)/.exec(Y)[1]),$=q>=1):Y.indexOf("OpenGL ES")!==-1&&(q=parseFloat(/^OpenGL ES (\d)/.exec(Y)[1]),$=q>=2);let Z=null,oe={};const B=t.getParameter(t.SCISSOR_BOX),W=t.getParameter(t.VIEWPORT),se=new Di().fromArray(B),ne=new Di().fromArray(W);function ce(we,tt,ke,We){const pe=new Uint8Array(4),Ce=t.createTexture();t.bindTexture(we,Ce),t.texParameteri(we,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(we,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let de=0;de<ke;de++)we===t.TEXTURE_3D||we===t.TEXTURE_2D_ARRAY?t.texImage3D(tt,0,t.RGBA,1,1,We,0,t.RGBA,t.UNSIGNED_BYTE,pe):t.texImage2D(tt+de,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,pe);return Ce}const fe={};fe[t.TEXTURE_2D]=ce(t.TEXTURE_2D,t.TEXTURE_2D,1),fe[t.TEXTURE_CUBE_MAP]=ce(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),fe[t.TEXTURE_2D_ARRAY]=ce(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),fe[t.TEXTURE_3D]=ce(t.TEXTURE_3D,t.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),l.setClear(0),ye(t.DEPTH_TEST),o.setFunc(Hg),J(!1),Q(Hz),ye(t.CULL_FACE),U(Mu);function ye(we){d[we]!==!0&&(t.enable(we),d[we]=!0)}function ge(we){d[we]!==!1&&(t.disable(we),d[we]=!1)}function xe(we,tt){return f[we]!==tt?(t.bindFramebuffer(we,tt),f[we]=tt,we===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=tt),we===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=tt),!0):!1}function Pe(we,tt){let ke=p,We=!1;if(we){ke=m.get(tt),ke===void 0&&(ke=[],m.set(tt,ke));const pe=we.textures;if(ke.length!==pe.length||ke[0]!==t.COLOR_ATTACHMENT0){for(let Ce=0,de=pe.length;Ce<de;Ce++)ke[Ce]=t.COLOR_ATTACHMENT0+Ce;ke.length=pe.length,We=!0}}else ke[0]!==t.BACK&&(ke[0]=t.BACK,We=!0);We&&t.drawBuffers(ke)}function Ue(we){return x!==we?(t.useProgram(we),x=we,!0):!1}const be={[Nf]:t.FUNC_ADD,[Vfe]:t.FUNC_SUBTRACT,[Gfe]:t.FUNC_REVERSE_SUBTRACT};be[qfe]=t.MIN,be[Wfe]=t.MAX;const it={[Kfe]:t.ZERO,[Xfe]:t.ONE,[Yfe]:t.SRC_COLOR,[_3]:t.SRC_ALPHA,[nme]:t.SRC_ALPHA_SATURATE,[eme]:t.DST_COLOR,[Zfe]:t.DST_ALPHA,[Qfe]:t.ONE_MINUS_SRC_COLOR,[w3]:t.ONE_MINUS_SRC_ALPHA,[tme]:t.ONE_MINUS_DST_COLOR,[Jfe]:t.ONE_MINUS_DST_ALPHA,[rme]:t.CONSTANT_COLOR,[ime]:t.ONE_MINUS_CONSTANT_COLOR,[ame]:t.CONSTANT_ALPHA,[sme]:t.ONE_MINUS_CONSTANT_ALPHA};function U(we,tt,ke,We,pe,Ce,de,Ve,yt,ut){if(we===Mu){b===!0&&(ge(t.BLEND),b=!1);return}if(b===!1&&(ye(t.BLEND),b=!0),we!==Hfe){if(we!==y||ut!==A){if((v!==Nf||C!==Nf)&&(t.blendEquation(t.FUNC_ADD),v=Nf,C=Nf),ut)switch(we){case Eg:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case Vz:t.blendFunc(t.ONE,t.ONE);break;case Gz:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case qz:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:_i("WebGLState: Invalid blending: ",we);break}else switch(we){case Eg:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case Vz:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case Gz:_i("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case qz:_i("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:_i("WebGLState: Invalid blending: ",we);break}S=null,N=null,T=null,k=null,E.set(0,0,0),D=0,y=we,A=ut}return}pe=pe||tt,Ce=Ce||ke,de=de||We,(tt!==v||pe!==C)&&(t.blendEquationSeparate(be[tt],be[pe]),v=tt,C=pe),(ke!==S||We!==N||Ce!==T||de!==k)&&(t.blendFuncSeparate(it[ke],it[We],it[Ce],it[de]),S=ke,N=We,T=Ce,k=de),(Ve.equals(E)===!1||yt!==D)&&(t.blendColor(Ve.r,Ve.g,Ve.b,yt),E.copy(Ve),D=yt),y=we,A=!1}function K(we,tt){we.side===ic?ge(t.CULL_FACE):ye(t.CULL_FACE);let ke=we.side===zs;tt&&(ke=!ke),J(ke),we.blending===Eg&&we.transparent===!1?U(Mu):U(we.blending,we.blendEquation,we.blendSrc,we.blendDst,we.blendEquationAlpha,we.blendSrcAlpha,we.blendDstAlpha,we.blendColor,we.blendAlpha,we.premultipliedAlpha),o.setFunc(we.depthFunc),o.setTest(we.depthTest),o.setMask(we.depthWrite),s.setMask(we.colorWrite);const We=we.stencilWrite;l.setTest(We),We&&(l.setMask(we.stencilWriteMask),l.setFunc(we.stencilFunc,we.stencilRef,we.stencilFuncMask),l.setOp(we.stencilFail,we.stencilZFail,we.stencilZPass)),re(we.polygonOffset,we.polygonOffsetFactor,we.polygonOffsetUnits),we.alphaToCoverage===!0?ye(t.SAMPLE_ALPHA_TO_COVERAGE):ge(t.SAMPLE_ALPHA_TO_COVERAGE)}function J(we){R!==we&&(we?t.frontFace(t.CW):t.frontFace(t.CCW),R=we)}function Q(we){we!==zfe?(ye(t.CULL_FACE),we!==F&&(we===Hz?t.cullFace(t.BACK):we===Bfe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):ge(t.CULL_FACE),F=we}function z(we){we!==O&&($&&t.lineWidth(we),O=we)}function re(we,tt,ke){we?(ye(t.POLYGON_OFFSET_FILL),(H!==tt||j!==ke)&&(t.polygonOffset(tt,ke),H=tt,j=ke)):ge(t.POLYGON_OFFSET_FILL)}function Ee(we){we?ye(t.SCISSOR_TEST):ge(t.SCISSOR_TEST)}function _e(we){we===void 0&&(we=t.TEXTURE0+G-1),Z!==we&&(t.activeTexture(we),Z=we)}function Te(we,tt,ke){ke===void 0&&(Z===null?ke=t.TEXTURE0+G-1:ke=Z);let We=oe[ke];We===void 0&&(We={type:void 0,texture:void 0},oe[ke]=We),(We.type!==we||We.texture!==tt)&&(Z!==ke&&(t.activeTexture(ke),Z=ke),t.bindTexture(we,tt||fe[we]),We.type=we,We.texture=tt)}function V(){const we=oe[Z];we!==void 0&&we.type!==void 0&&(t.bindTexture(we.type,null),we.type=void 0,we.texture=void 0)}function L(){try{t.compressedTexImage2D(...arguments)}catch(we){we("WebGLState:",we)}}function X(){try{t.compressedTexImage3D(...arguments)}catch(we){we("WebGLState:",we)}}function te(){try{t.texSubImage2D(...arguments)}catch(we){we("WebGLState:",we)}}function Me(){try{t.texSubImage3D(...arguments)}catch(we){we("WebGLState:",we)}}function ie(){try{t.compressedTexSubImage2D(...arguments)}catch(we){we("WebGLState:",we)}}function De(){try{t.compressedTexSubImage3D(...arguments)}catch(we){we("WebGLState:",we)}}function Le(){try{t.texStorage2D(...arguments)}catch(we){we("WebGLState:",we)}}function $e(){try{t.texStorage3D(...arguments)}catch(we){we("WebGLState:",we)}}function Ze(){try{t.texImage2D(...arguments)}catch(we){we("WebGLState:",we)}}function Ie(){try{t.texImage3D(...arguments)}catch(we){we("WebGLState:",we)}}function ae(we){se.equals(we)===!1&&(t.scissor(we.x,we.y,we.z,we.w),se.copy(we))}function He(we){ne.equals(we)===!1&&(t.viewport(we.x,we.y,we.z,we.w),ne.copy(we))}function Se(we,tt){let ke=u.get(tt);ke===void 0&&(ke=new WeakMap,u.set(tt,ke));let We=ke.get(we);We===void 0&&(We=t.getUniformBlockIndex(tt,we.name),ke.set(we,We))}function Be(we,tt){const We=u.get(tt).get(we);c.get(tt)!==We&&(t.uniformBlockBinding(tt,We,we.__bindingPointIndex),c.set(tt,We))}function ft(){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),o.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),d={},Z=null,oe={},f={},m=new WeakMap,p=[],x=null,b=!1,y=null,v=null,S=null,N=null,C=null,T=null,k=null,E=new Rn(0,0,0),D=0,A=!1,R=null,F=null,O=null,H=null,j=null,se.set(0,0,t.canvas.width,t.canvas.height),ne.set(0,0,t.canvas.width,t.canvas.height),s.reset(),o.reset(),l.reset()}return{buffers:{color:s,depth:o,stencil:l},enable:ye,disable:ge,bindFramebuffer:xe,drawBuffers:Pe,useProgram:Ue,setBlending:U,setMaterial:K,setFlipSided:J,setCullFace:Q,setLineWidth:z,setPolygonOffset:re,setScissorTest:Ee,activeTexture:_e,bindTexture:Te,unbindTexture:V,compressedTexImage2D:L,compressedTexImage3D:X,texImage2D:Ze,texImage3D:Ie,updateUBOMapping:Se,uniformBlockBinding:Be,texStorage2D:Le,texStorage3D:$e,texSubImage2D:te,texSubImage3D:Me,compressedTexSubImage2D:ie,compressedTexSubImage3D:De,scissor:ae,viewport:He,reset:ft}}function X0e(t,e,n,r,i,s,o){const l=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),u=new An,d=new WeakMap;let f;const m=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(V,L){return p?new OffscreenCanvas(V,L):Z1("canvas")}function b(V,L,X){let te=1;const Me=Te(V);if((Me.width>X||Me.height>X)&&(te=X/Math.max(Me.width,Me.height)),te<1)if(typeof HTMLImageElement<"u"&&V instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&V instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&V instanceof ImageBitmap||typeof VideoFrame<"u"&&V instanceof VideoFrame){const ie=Math.floor(te*Me.width),De=Math.floor(te*Me.height);f===void 0&&(f=x(ie,De));const Le=L?x(ie,De):f;return Le.width=ie,Le.height=De,Le.getContext("2d").drawImage(V,0,0,ie,De),mn("WebGLRenderer: Texture has been resized from ("+Me.width+"x"+Me.height+") to ("+ie+"x"+De+")."),Le}else return"data"in V&&mn("WebGLRenderer: Image in DataTexture is too big ("+Me.width+"x"+Me.height+")."),V;return V}function y(V){return V.generateMipmaps}function v(V){t.generateMipmap(V)}function S(V){return V.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:V.isWebGL3DRenderTarget?t.TEXTURE_3D:V.isWebGLArrayRenderTarget||V.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function N(V,L,X,te,Me=!1){if(V!==null){if(t[V]!==void 0)return t[V];mn("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+V+"'")}let ie=L;if(L===t.RED&&(X===t.FLOAT&&(ie=t.R32F),X===t.HALF_FLOAT&&(ie=t.R16F),X===t.UNSIGNED_BYTE&&(ie=t.R8)),L===t.RED_INTEGER&&(X===t.UNSIGNED_BYTE&&(ie=t.R8UI),X===t.UNSIGNED_SHORT&&(ie=t.R16UI),X===t.UNSIGNED_INT&&(ie=t.R32UI),X===t.BYTE&&(ie=t.R8I),X===t.SHORT&&(ie=t.R16I),X===t.INT&&(ie=t.R32I)),L===t.RG&&(X===t.FLOAT&&(ie=t.RG32F),X===t.HALF_FLOAT&&(ie=t.RG16F),X===t.UNSIGNED_BYTE&&(ie=t.RG8)),L===t.RG_INTEGER&&(X===t.UNSIGNED_BYTE&&(ie=t.RG8UI),X===t.UNSIGNED_SHORT&&(ie=t.RG16UI),X===t.UNSIGNED_INT&&(ie=t.RG32UI),X===t.BYTE&&(ie=t.RG8I),X===t.SHORT&&(ie=t.RG16I),X===t.INT&&(ie=t.RG32I)),L===t.RGB_INTEGER&&(X===t.UNSIGNED_BYTE&&(ie=t.RGB8UI),X===t.UNSIGNED_SHORT&&(ie=t.RGB16UI),X===t.UNSIGNED_INT&&(ie=t.RGB32UI),X===t.BYTE&&(ie=t.RGB8I),X===t.SHORT&&(ie=t.RGB16I),X===t.INT&&(ie=t.RGB32I)),L===t.RGBA_INTEGER&&(X===t.UNSIGNED_BYTE&&(ie=t.RGBA8UI),X===t.UNSIGNED_SHORT&&(ie=t.RGBA16UI),X===t.UNSIGNED_INT&&(ie=t.RGBA32UI),X===t.BYTE&&(ie=t.RGBA8I),X===t.SHORT&&(ie=t.RGBA16I),X===t.INT&&(ie=t.RGBA32I)),L===t.RGB&&(X===t.UNSIGNED_INT_5_9_9_9_REV&&(ie=t.RGB9_E5),X===t.UNSIGNED_INT_10F_11F_11F_REV&&(ie=t.R11F_G11F_B10F)),L===t.RGBA){const De=Me?Y1:ar.getTransfer(te);X===t.FLOAT&&(ie=t.RGBA32F),X===t.HALF_FLOAT&&(ie=t.RGBA16F),X===t.UNSIGNED_BYTE&&(ie=De===Nr?t.SRGB8_ALPHA8:t.RGBA8),X===t.UNSIGNED_SHORT_4_4_4_4&&(ie=t.RGBA4),X===t.UNSIGNED_SHORT_5_5_5_1&&(ie=t.RGB5_A1)}return(ie===t.R16F||ie===t.R32F||ie===t.RG16F||ie===t.RG32F||ie===t.RGBA16F||ie===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ie}function C(V,L){let X;return V?L===null||L===lm||L===Y0?X=t.DEPTH24_STENCIL8:L===bu?X=t.DEPTH32F_STENCIL8:L===X0&&(X=t.DEPTH24_STENCIL8,mn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):L===null||L===lm||L===Y0?X=t.DEPTH_COMPONENT24:L===bu?X=t.DEPTH_COMPONENT32F:L===X0&&(X=t.DEPTH_COMPONENT16),X}function T(V,L){return y(V)===!0||V.isFramebufferTexture&&V.minFilter!==mo&&V.minFilter!==Zo?Math.log2(Math.max(L.width,L.height))+1:V.mipmaps!==void 0&&V.mipmaps.length>0?V.mipmaps.length:V.isCompressedTexture&&Array.isArray(V.image)?L.mipmaps.length:1}function k(V){const L=V.target;L.removeEventListener("dispose",k),D(L),L.isVideoTexture&&d.delete(L)}function E(V){const L=V.target;L.removeEventListener("dispose",E),R(L)}function D(V){const L=r.get(V);if(L.__webglInit===void 0)return;const X=V.source,te=m.get(X);if(te){const Me=te[L.__cacheKey];Me.usedTimes--,Me.usedTimes===0&&A(V),Object.keys(te).length===0&&m.delete(X)}r.remove(V)}function A(V){const L=r.get(V);t.deleteTexture(L.__webglTexture);const X=V.source,te=m.get(X);delete te[L.__cacheKey],o.memory.textures--}function R(V){const L=r.get(V);if(V.depthTexture&&(V.depthTexture.dispose(),r.remove(V.depthTexture)),V.isWebGLCubeRenderTarget)for(let te=0;te<6;te++){if(Array.isArray(L.__webglFramebuffer[te]))for(let Me=0;Me<L.__webglFramebuffer[te].length;Me++)t.deleteFramebuffer(L.__webglFramebuffer[te][Me]);else t.deleteFramebuffer(L.__webglFramebuffer[te]);L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer[te])}else{if(Array.isArray(L.__webglFramebuffer))for(let te=0;te<L.__webglFramebuffer.length;te++)t.deleteFramebuffer(L.__webglFramebuffer[te]);else t.deleteFramebuffer(L.__webglFramebuffer);if(L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer),L.__webglMultisampledFramebuffer&&t.deleteFramebuffer(L.__webglMultisampledFramebuffer),L.__webglColorRenderbuffer)for(let te=0;te<L.__webglColorRenderbuffer.length;te++)L.__webglColorRenderbuffer[te]&&t.deleteRenderbuffer(L.__webglColorRenderbuffer[te]);L.__webglDepthRenderbuffer&&t.deleteRenderbuffer(L.__webglDepthRenderbuffer)}const X=V.textures;for(let te=0,Me=X.length;te<Me;te++){const ie=r.get(X[te]);ie.__webglTexture&&(t.deleteTexture(ie.__webglTexture),o.memory.textures--),r.remove(X[te])}r.remove(V)}let F=0;function O(){F=0}function H(){const V=F;return V>=i.maxTextures&&mn("WebGLTextures: Trying to use "+V+" texture units while this GPU supports only "+i.maxTextures),F+=1,V}function j(V){const L=[];return L.push(V.wrapS),L.push(V.wrapT),L.push(V.wrapR||0),L.push(V.magFilter),L.push(V.minFilter),L.push(V.anisotropy),L.push(V.internalFormat),L.push(V.format),L.push(V.type),L.push(V.generateMipmaps),L.push(V.premultiplyAlpha),L.push(V.flipY),L.push(V.unpackAlignment),L.push(V.colorSpace),L.join()}function G(V,L){const X=r.get(V);if(V.isVideoTexture&&Ee(V),V.isRenderTargetTexture===!1&&V.isExternalTexture!==!0&&V.version>0&&X.__version!==V.version){const te=V.image;if(te===null)mn("WebGLRenderer: Texture marked for update but no image data found.");else if(te.complete===!1)mn("WebGLRenderer: Texture marked for update but image is incomplete");else{fe(X,V,L);return}}else V.isExternalTexture&&(X.__webglTexture=V.sourceTexture?V.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,X.__webglTexture,t.TEXTURE0+L)}function $(V,L){const X=r.get(V);if(V.isRenderTargetTexture===!1&&V.version>0&&X.__version!==V.version){fe(X,V,L);return}else V.isExternalTexture&&(X.__webglTexture=V.sourceTexture?V.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,X.__webglTexture,t.TEXTURE0+L)}function q(V,L){const X=r.get(V);if(V.isRenderTargetTexture===!1&&V.version>0&&X.__version!==V.version){fe(X,V,L);return}n.bindTexture(t.TEXTURE_3D,X.__webglTexture,t.TEXTURE0+L)}function Y(V,L){const X=r.get(V);if(V.version>0&&X.__version!==V.version){ye(X,V,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,X.__webglTexture,t.TEXTURE0+L)}const Z={[P3]:t.REPEAT,[xu]:t.CLAMP_TO_EDGE,[R3]:t.MIRRORED_REPEAT},oe={[mo]:t.NEAREST,[gme]:t.NEAREST_MIPMAP_NEAREST,[O_]:t.NEAREST_MIPMAP_LINEAR,[Zo]:t.LINEAR,[sT]:t.LINEAR_MIPMAP_NEAREST,[Pf]:t.LINEAR_MIPMAP_LINEAR},B={[vme]:t.NEVER,[Eme]:t.ALWAYS,[_me]:t.LESS,[QW]:t.LEQUAL,[wme]:t.EQUAL,[Mme]:t.GEQUAL,[Sme]:t.GREATER,[Nme]:t.NOTEQUAL};function W(V,L){if(L.type===bu&&e.has("OES_texture_float_linear")===!1&&(L.magFilter===Zo||L.magFilter===sT||L.magFilter===O_||L.magFilter===Pf||L.minFilter===Zo||L.minFilter===sT||L.minFilter===O_||L.minFilter===Pf)&&mn("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(V,t.TEXTURE_WRAP_S,Z[L.wrapS]),t.texParameteri(V,t.TEXTURE_WRAP_T,Z[L.wrapT]),(V===t.TEXTURE_3D||V===t.TEXTURE_2D_ARRAY)&&t.texParameteri(V,t.TEXTURE_WRAP_R,Z[L.wrapR]),t.texParameteri(V,t.TEXTURE_MAG_FILTER,oe[L.magFilter]),t.texParameteri(V,t.TEXTURE_MIN_FILTER,oe[L.minFilter]),L.compareFunction&&(t.texParameteri(V,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(V,t.TEXTURE_COMPARE_FUNC,B[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(L.magFilter===mo||L.minFilter!==O_&&L.minFilter!==Pf||L.type===bu&&e.has("OES_texture_float_linear")===!1)return;if(L.anisotropy>1||r.get(L).__currentAnisotropy){const X=e.get("EXT_texture_filter_anisotropic");t.texParameterf(V,X.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy}}}function se(V,L){let X=!1;V.__webglInit===void 0&&(V.__webglInit=!0,L.addEventListener("dispose",k));const te=L.source;let Me=m.get(te);Me===void 0&&(Me={},m.set(te,Me));const ie=j(L);if(ie!==V.__cacheKey){Me[ie]===void 0&&(Me[ie]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,X=!0),Me[ie].usedTimes++;const De=Me[V.__cacheKey];De!==void 0&&(Me[V.__cacheKey].usedTimes--,De.usedTimes===0&&A(L)),V.__cacheKey=ie,V.__webglTexture=Me[ie].texture}return X}function ne(V,L,X){return Math.floor(Math.floor(V/X)/L)}function ce(V,L,X,te){const ie=V.updateRanges;if(ie.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,L.width,L.height,X,te,L.data);else{ie.sort((Ie,ae)=>Ie.start-ae.start);let De=0;for(let Ie=1;Ie<ie.length;Ie++){const ae=ie[De],He=ie[Ie],Se=ae.start+ae.count,Be=ne(He.start,L.width,4),ft=ne(ae.start,L.width,4);He.start<=Se+1&&Be===ft&&ne(He.start+He.count-1,L.width,4)===Be?ae.count=Math.max(ae.count,He.start+He.count-ae.start):(++De,ie[De]=He)}ie.length=De+1;const Le=t.getParameter(t.UNPACK_ROW_LENGTH),$e=t.getParameter(t.UNPACK_SKIP_PIXELS),Ze=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,L.width);for(let Ie=0,ae=ie.length;Ie<ae;Ie++){const He=ie[Ie],Se=Math.floor(He.start/4),Be=Math.ceil(He.count/4),ft=Se%L.width,we=Math.floor(Se/L.width),tt=Be,ke=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,ft),t.pixelStorei(t.UNPACK_SKIP_ROWS,we),n.texSubImage2D(t.TEXTURE_2D,0,ft,we,tt,ke,X,te,L.data)}V.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Le),t.pixelStorei(t.UNPACK_SKIP_PIXELS,$e),t.pixelStorei(t.UNPACK_SKIP_ROWS,Ze)}}function fe(V,L,X){let te=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(te=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(te=t.TEXTURE_3D);const Me=se(V,L),ie=L.source;n.bindTexture(te,V.__webglTexture,t.TEXTURE0+X);const De=r.get(ie);if(ie.version!==De.__version||Me===!0){n.activeTexture(t.TEXTURE0+X);const Le=ar.getPrimaries(ar.workingColorSpace),$e=L.colorSpace===qd?null:ar.getPrimaries(L.colorSpace),Ze=L.colorSpace===qd||Le===$e?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ze);let Ie=b(L.image,!1,i.maxTextureSize);Ie=_e(L,Ie);const ae=s.convert(L.format,L.colorSpace),He=s.convert(L.type);let Se=N(L.internalFormat,ae,He,L.colorSpace,L.isVideoTexture);W(te,L);let Be;const ft=L.mipmaps,we=L.isVideoTexture!==!0,tt=De.__version===void 0||Me===!0,ke=ie.dataReady,We=T(L,Ie);if(L.isDepthTexture)Se=C(L.format===Z0,L.type),tt&&(we?n.texStorage2D(t.TEXTURE_2D,1,Se,Ie.width,Ie.height):n.texImage2D(t.TEXTURE_2D,0,Se,Ie.width,Ie.height,0,ae,He,null));else if(L.isDataTexture)if(ft.length>0){we&&tt&&n.texStorage2D(t.TEXTURE_2D,We,Se,ft[0].width,ft[0].height);for(let pe=0,Ce=ft.length;pe<Ce;pe++)Be=ft[pe],we?ke&&n.texSubImage2D(t.TEXTURE_2D,pe,0,0,Be.width,Be.height,ae,He,Be.data):n.texImage2D(t.TEXTURE_2D,pe,Se,Be.width,Be.height,0,ae,He,Be.data);L.generateMipmaps=!1}else we?(tt&&n.texStorage2D(t.TEXTURE_2D,We,Se,Ie.width,Ie.height),ke&&ce(L,Ie,ae,He)):n.texImage2D(t.TEXTURE_2D,0,Se,Ie.width,Ie.height,0,ae,He,Ie.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){we&&tt&&n.texStorage3D(t.TEXTURE_2D_ARRAY,We,Se,ft[0].width,ft[0].height,Ie.depth);for(let pe=0,Ce=ft.length;pe<Ce;pe++)if(Be=ft[pe],L.format!==Pl)if(ae!==null)if(we){if(ke)if(L.layerUpdates.size>0){const de=SB(Be.width,Be.height,L.format,L.type);for(const Ve of L.layerUpdates){const yt=Be.data.subarray(Ve*de/Be.data.BYTES_PER_ELEMENT,(Ve+1)*de/Be.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,pe,0,0,Ve,Be.width,Be.height,1,ae,yt)}L.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,pe,0,0,0,Be.width,Be.height,Ie.depth,ae,Be.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,pe,Se,Be.width,Be.height,Ie.depth,0,Be.data,0,0);else mn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else we?ke&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,pe,0,0,0,Be.width,Be.height,Ie.depth,ae,He,Be.data):n.texImage3D(t.TEXTURE_2D_ARRAY,pe,Se,Be.width,Be.height,Ie.depth,0,ae,He,Be.data)}else{we&&tt&&n.texStorage2D(t.TEXTURE_2D,We,Se,ft[0].width,ft[0].height);for(let pe=0,Ce=ft.length;pe<Ce;pe++)Be=ft[pe],L.format!==Pl?ae!==null?we?ke&&n.compressedTexSubImage2D(t.TEXTURE_2D,pe,0,0,Be.width,Be.height,ae,Be.data):n.compressedTexImage2D(t.TEXTURE_2D,pe,Se,Be.width,Be.height,0,Be.data):mn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):we?ke&&n.texSubImage2D(t.TEXTURE_2D,pe,0,0,Be.width,Be.height,ae,He,Be.data):n.texImage2D(t.TEXTURE_2D,pe,Se,Be.width,Be.height,0,ae,He,Be.data)}else if(L.isDataArrayTexture)if(we){if(tt&&n.texStorage3D(t.TEXTURE_2D_ARRAY,We,Se,Ie.width,Ie.height,Ie.depth),ke)if(L.layerUpdates.size>0){const pe=SB(Ie.width,Ie.height,L.format,L.type);for(const Ce of L.layerUpdates){const de=Ie.data.subarray(Ce*pe/Ie.data.BYTES_PER_ELEMENT,(Ce+1)*pe/Ie.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,Ce,Ie.width,Ie.height,1,ae,He,de)}L.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,Ie.width,Ie.height,Ie.depth,ae,He,Ie.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,Se,Ie.width,Ie.height,Ie.depth,0,ae,He,Ie.data);else if(L.isData3DTexture)we?(tt&&n.texStorage3D(t.TEXTURE_3D,We,Se,Ie.width,Ie.height,Ie.depth),ke&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,Ie.width,Ie.height,Ie.depth,ae,He,Ie.data)):n.texImage3D(t.TEXTURE_3D,0,Se,Ie.width,Ie.height,Ie.depth,0,ae,He,Ie.data);else if(L.isFramebufferTexture){if(tt)if(we)n.texStorage2D(t.TEXTURE_2D,We,Se,Ie.width,Ie.height);else{let pe=Ie.width,Ce=Ie.height;for(let de=0;de<We;de++)n.texImage2D(t.TEXTURE_2D,de,Se,pe,Ce,0,ae,He,null),pe>>=1,Ce>>=1}}else if(ft.length>0){if(we&&tt){const pe=Te(ft[0]);n.texStorage2D(t.TEXTURE_2D,We,Se,pe.width,pe.height)}for(let pe=0,Ce=ft.length;pe<Ce;pe++)Be=ft[pe],we?ke&&n.texSubImage2D(t.TEXTURE_2D,pe,0,0,ae,He,Be):n.texImage2D(t.TEXTURE_2D,pe,Se,ae,He,Be);L.generateMipmaps=!1}else if(we){if(tt){const pe=Te(Ie);n.texStorage2D(t.TEXTURE_2D,We,Se,pe.width,pe.height)}ke&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,ae,He,Ie)}else n.texImage2D(t.TEXTURE_2D,0,Se,ae,He,Ie);y(L)&&v(te),De.__version=ie.version,L.onUpdate&&L.onUpdate(L)}V.__version=L.version}function ye(V,L,X){if(L.image.length!==6)return;const te=se(V,L),Me=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,V.__webglTexture,t.TEXTURE0+X);const ie=r.get(Me);if(Me.version!==ie.__version||te===!0){n.activeTexture(t.TEXTURE0+X);const De=ar.getPrimaries(ar.workingColorSpace),Le=L.colorSpace===qd?null:ar.getPrimaries(L.colorSpace),$e=L.colorSpace===qd||De===Le?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,$e);const Ze=L.isCompressedTexture||L.image[0].isCompressedTexture,Ie=L.image[0]&&L.image[0].isDataTexture,ae=[];for(let Ce=0;Ce<6;Ce++)!Ze&&!Ie?ae[Ce]=b(L.image[Ce],!0,i.maxCubemapSize):ae[Ce]=Ie?L.image[Ce].image:L.image[Ce],ae[Ce]=_e(L,ae[Ce]);const He=ae[0],Se=s.convert(L.format,L.colorSpace),Be=s.convert(L.type),ft=N(L.internalFormat,Se,Be,L.colorSpace),we=L.isVideoTexture!==!0,tt=ie.__version===void 0||te===!0,ke=Me.dataReady;let We=T(L,He);W(t.TEXTURE_CUBE_MAP,L);let pe;if(Ze){we&&tt&&n.texStorage2D(t.TEXTURE_CUBE_MAP,We,ft,He.width,He.height);for(let Ce=0;Ce<6;Ce++){pe=ae[Ce].mipmaps;for(let de=0;de<pe.length;de++){const Ve=pe[de];L.format!==Pl?Se!==null?we?ke&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,de,0,0,Ve.width,Ve.height,Se,Ve.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,de,ft,Ve.width,Ve.height,0,Ve.data):mn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):we?ke&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,de,0,0,Ve.width,Ve.height,Se,Be,Ve.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,de,ft,Ve.width,Ve.height,0,Se,Be,Ve.data)}}}else{if(pe=L.mipmaps,we&&tt){pe.length>0&&We++;const Ce=Te(ae[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,We,ft,Ce.width,Ce.height)}for(let Ce=0;Ce<6;Ce++)if(Ie){we?ke&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,0,0,ae[Ce].width,ae[Ce].height,Se,Be,ae[Ce].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,ft,ae[Ce].width,ae[Ce].height,0,Se,Be,ae[Ce].data);for(let de=0;de<pe.length;de++){const yt=pe[de].image[Ce].image;we?ke&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,de+1,0,0,yt.width,yt.height,Se,Be,yt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,de+1,ft,yt.width,yt.height,0,Se,Be,yt.data)}}else{we?ke&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,0,0,Se,Be,ae[Ce]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,ft,Se,Be,ae[Ce]);for(let de=0;de<pe.length;de++){const Ve=pe[de];we?ke&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,de+1,0,0,Se,Be,Ve.image[Ce]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,de+1,ft,Se,Be,Ve.image[Ce])}}}y(L)&&v(t.TEXTURE_CUBE_MAP),ie.__version=Me.version,L.onUpdate&&L.onUpdate(L)}V.__version=L.version}function ge(V,L,X,te,Me,ie){const De=s.convert(X.format,X.colorSpace),Le=s.convert(X.type),$e=N(X.internalFormat,De,Le,X.colorSpace),Ze=r.get(L),Ie=r.get(X);if(Ie.__renderTarget=L,!Ze.__hasExternalTextures){const ae=Math.max(1,L.width>>ie),He=Math.max(1,L.height>>ie);Me===t.TEXTURE_3D||Me===t.TEXTURE_2D_ARRAY?n.texImage3D(Me,ie,$e,ae,He,L.depth,0,De,Le,null):n.texImage2D(Me,ie,$e,ae,He,0,De,Le,null)}n.bindFramebuffer(t.FRAMEBUFFER,V),re(L)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,te,Me,Ie.__webglTexture,0,z(L)):(Me===t.TEXTURE_2D||Me>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&Me<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,te,Me,Ie.__webglTexture,ie),n.bindFramebuffer(t.FRAMEBUFFER,null)}function xe(V,L,X){if(t.bindRenderbuffer(t.RENDERBUFFER,V),L.depthBuffer){const te=L.depthTexture,Me=te&&te.isDepthTexture?te.type:null,ie=C(L.stencilBuffer,Me),De=L.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Le=z(L);re(L)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Le,ie,L.width,L.height):X?t.renderbufferStorageMultisample(t.RENDERBUFFER,Le,ie,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,ie,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,De,t.RENDERBUFFER,V)}else{const te=L.textures;for(let Me=0;Me<te.length;Me++){const ie=te[Me],De=s.convert(ie.format,ie.colorSpace),Le=s.convert(ie.type),$e=N(ie.internalFormat,De,Le,ie.colorSpace),Ze=z(L);X&&re(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ze,$e,L.width,L.height):re(L)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ze,$e,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,$e,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Pe(V,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,V),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const te=r.get(L.depthTexture);te.__renderTarget=L,(!te.__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),G(L.depthTexture,0);const Me=te.__webglTexture,ie=z(L);if(L.depthTexture.format===Q0)re(L)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,Me,0,ie):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,Me,0);else if(L.depthTexture.format===Z0)re(L)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,Me,0,ie):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,Me,0);else throw new Error("Unknown depthTexture format")}function Ue(V){const L=r.get(V),X=V.isWebGLCubeRenderTarget===!0;if(L.__boundDepthTexture!==V.depthTexture){const te=V.depthTexture;if(L.__depthDisposeCallback&&L.__depthDisposeCallback(),te){const Me=()=>{delete L.__boundDepthTexture,delete L.__depthDisposeCallback,te.removeEventListener("dispose",Me)};te.addEventListener("dispose",Me),L.__depthDisposeCallback=Me}L.__boundDepthTexture=te}if(V.depthTexture&&!L.__autoAllocateDepthBuffer){if(X)throw new Error("target.depthTexture not supported in Cube render targets");const te=V.texture.mipmaps;te&&te.length>0?Pe(L.__webglFramebuffer[0],V):Pe(L.__webglFramebuffer,V)}else if(X){L.__webglDepthbuffer=[];for(let te=0;te<6;te++)if(n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[te]),L.__webglDepthbuffer[te]===void 0)L.__webglDepthbuffer[te]=t.createRenderbuffer(),xe(L.__webglDepthbuffer[te],V,!1);else{const Me=V.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ie=L.__webglDepthbuffer[te];t.bindRenderbuffer(t.RENDERBUFFER,ie),t.framebufferRenderbuffer(t.FRAMEBUFFER,Me,t.RENDERBUFFER,ie)}}else{const te=V.texture.mipmaps;if(te&&te.length>0?n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer===void 0)L.__webglDepthbuffer=t.createRenderbuffer(),xe(L.__webglDepthbuffer,V,!1);else{const Me=V.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ie=L.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,ie),t.framebufferRenderbuffer(t.FRAMEBUFFER,Me,t.RENDERBUFFER,ie)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function be(V,L,X){const te=r.get(V);L!==void 0&&ge(te.__webglFramebuffer,V,V.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),X!==void 0&&Ue(V)}function it(V){const L=V.texture,X=r.get(V),te=r.get(L);V.addEventListener("dispose",E);const Me=V.textures,ie=V.isWebGLCubeRenderTarget===!0,De=Me.length>1;if(De||(te.__webglTexture===void 0&&(te.__webglTexture=t.createTexture()),te.__version=L.version,o.memory.textures++),ie){X.__webglFramebuffer=[];for(let Le=0;Le<6;Le++)if(L.mipmaps&&L.mipmaps.length>0){X.__webglFramebuffer[Le]=[];for(let $e=0;$e<L.mipmaps.length;$e++)X.__webglFramebuffer[Le][$e]=t.createFramebuffer()}else X.__webglFramebuffer[Le]=t.createFramebuffer()}else{if(L.mipmaps&&L.mipmaps.length>0){X.__webglFramebuffer=[];for(let Le=0;Le<L.mipmaps.length;Le++)X.__webglFramebuffer[Le]=t.createFramebuffer()}else X.__webglFramebuffer=t.createFramebuffer();if(De)for(let Le=0,$e=Me.length;Le<$e;Le++){const Ze=r.get(Me[Le]);Ze.__webglTexture===void 0&&(Ze.__webglTexture=t.createTexture(),o.memory.textures++)}if(V.samples>0&&re(V)===!1){X.__webglMultisampledFramebuffer=t.createFramebuffer(),X.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,X.__webglMultisampledFramebuffer);for(let Le=0;Le<Me.length;Le++){const $e=Me[Le];X.__webglColorRenderbuffer[Le]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,X.__webglColorRenderbuffer[Le]);const Ze=s.convert($e.format,$e.colorSpace),Ie=s.convert($e.type),ae=N($e.internalFormat,Ze,Ie,$e.colorSpace,V.isXRRenderTarget===!0),He=z(V);t.renderbufferStorageMultisample(t.RENDERBUFFER,He,ae,V.width,V.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Le,t.RENDERBUFFER,X.__webglColorRenderbuffer[Le])}t.bindRenderbuffer(t.RENDERBUFFER,null),V.depthBuffer&&(X.__webglDepthRenderbuffer=t.createRenderbuffer(),xe(X.__webglDepthRenderbuffer,V,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ie){n.bindTexture(t.TEXTURE_CUBE_MAP,te.__webglTexture),W(t.TEXTURE_CUBE_MAP,L);for(let Le=0;Le<6;Le++)if(L.mipmaps&&L.mipmaps.length>0)for(let $e=0;$e<L.mipmaps.length;$e++)ge(X.__webglFramebuffer[Le][$e],V,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Le,$e);else ge(X.__webglFramebuffer[Le],V,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Le,0);y(L)&&v(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(De){for(let Le=0,$e=Me.length;Le<$e;Le++){const Ze=Me[Le],Ie=r.get(Ze);let ae=t.TEXTURE_2D;(V.isWebGL3DRenderTarget||V.isWebGLArrayRenderTarget)&&(ae=V.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(ae,Ie.__webglTexture),W(ae,Ze),ge(X.__webglFramebuffer,V,Ze,t.COLOR_ATTACHMENT0+Le,ae,0),y(Ze)&&v(ae)}n.unbindTexture()}else{let Le=t.TEXTURE_2D;if((V.isWebGL3DRenderTarget||V.isWebGLArrayRenderTarget)&&(Le=V.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Le,te.__webglTexture),W(Le,L),L.mipmaps&&L.mipmaps.length>0)for(let $e=0;$e<L.mipmaps.length;$e++)ge(X.__webglFramebuffer[$e],V,L,t.COLOR_ATTACHMENT0,Le,$e);else ge(X.__webglFramebuffer,V,L,t.COLOR_ATTACHMENT0,Le,0);y(L)&&v(Le),n.unbindTexture()}V.depthBuffer&&Ue(V)}function U(V){const L=V.textures;for(let X=0,te=L.length;X<te;X++){const Me=L[X];if(y(Me)){const ie=S(V),De=r.get(Me).__webglTexture;n.bindTexture(ie,De),v(ie),n.unbindTexture()}}}const K=[],J=[];function Q(V){if(V.samples>0){if(re(V)===!1){const L=V.textures,X=V.width,te=V.height;let Me=t.COLOR_BUFFER_BIT;const ie=V.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,De=r.get(V),Le=L.length>1;if(Le)for(let Ze=0;Ze<L.length;Ze++)n.bindFramebuffer(t.FRAMEBUFFER,De.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ze,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,De.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ze,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,De.__webglMultisampledFramebuffer);const $e=V.texture.mipmaps;$e&&$e.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,De.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,De.__webglFramebuffer);for(let Ze=0;Ze<L.length;Ze++){if(V.resolveDepthBuffer&&(V.depthBuffer&&(Me|=t.DEPTH_BUFFER_BIT),V.stencilBuffer&&V.resolveStencilBuffer&&(Me|=t.STENCIL_BUFFER_BIT)),Le){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,De.__webglColorRenderbuffer[Ze]);const Ie=r.get(L[Ze]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Ie,0)}t.blitFramebuffer(0,0,X,te,0,0,X,te,Me,t.NEAREST),c===!0&&(K.length=0,J.length=0,K.push(t.COLOR_ATTACHMENT0+Ze),V.depthBuffer&&V.resolveDepthBuffer===!1&&(K.push(ie),J.push(ie),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,J)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,K))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Le)for(let Ze=0;Ze<L.length;Ze++){n.bindFramebuffer(t.FRAMEBUFFER,De.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ze,t.RENDERBUFFER,De.__webglColorRenderbuffer[Ze]);const Ie=r.get(L[Ze]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,De.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ze,t.TEXTURE_2D,Ie,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,De.__webglMultisampledFramebuffer)}else if(V.depthBuffer&&V.resolveDepthBuffer===!1&&c){const L=V.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[L])}}}function z(V){return Math.min(i.maxSamples,V.samples)}function re(V){const L=r.get(V);return V.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Ee(V){const L=o.render.frame;d.get(V)!==L&&(d.set(V,L),V.update())}function _e(V,L){const X=V.colorSpace,te=V.format,Me=V.type;return V.isCompressedTexture===!0||V.isVideoTexture===!0||X!==qg&&X!==qd&&(ar.getTransfer(X)===Nr?(te!==Pl||Me!==gc)&&mn("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):_i("WebGLTextures: Unsupported texture color space:",X)),L}function Te(V){return typeof HTMLImageElement<"u"&&V instanceof HTMLImageElement?(u.width=V.naturalWidth||V.width,u.height=V.naturalHeight||V.height):typeof VideoFrame<"u"&&V instanceof VideoFrame?(u.width=V.displayWidth,u.height=V.displayHeight):(u.width=V.width,u.height=V.height),u}this.allocateTextureUnit=H,this.resetTextureUnits=O,this.setTexture2D=G,this.setTexture2DArray=$,this.setTexture3D=q,this.setTextureCube=Y,this.rebindTextures=be,this.setupRenderTarget=it,this.updateRenderTargetMipmap=U,this.updateMultisampleRenderTarget=Q,this.setupDepthRenderbuffer=Ue,this.setupFrameBufferTexture=ge,this.useMultisampledRTT=re}function Y0e(t,e){function n(r,i=qd){let s;const o=ar.getTransfer(i);if(r===gc)return t.UNSIGNED_BYTE;if(r===HD)return t.UNSIGNED_SHORT_4_4_4_4;if(r===VD)return t.UNSIGNED_SHORT_5_5_5_1;if(r===GW)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===qW)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===HW)return t.BYTE;if(r===VW)return t.SHORT;if(r===X0)return t.UNSIGNED_SHORT;if(r===$D)return t.INT;if(r===lm)return t.UNSIGNED_INT;if(r===bu)return t.FLOAT;if(r===yx)return t.HALF_FLOAT;if(r===WW)return t.ALPHA;if(r===KW)return t.RGB;if(r===Pl)return t.RGBA;if(r===Q0)return t.DEPTH_COMPONENT;if(r===Z0)return t.DEPTH_STENCIL;if(r===XW)return t.RED;if(r===GD)return t.RED_INTEGER;if(r===qD)return t.RG;if(r===WD)return t.RG_INTEGER;if(r===KD)return t.RGBA_INTEGER;if(r===b1||r===y1||r===v1||r===_1)if(o===Nr)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(r===b1)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===y1)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===v1)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===_1)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(r===b1)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===y1)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===v1)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===_1)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===D3||r===O3||r===L3||r===I3)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(r===D3)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===O3)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===L3)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===I3)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===F3||r===U3||r===z3)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(r===F3||r===U3)return o===Nr?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(r===z3)return o===Nr?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===B3||r===$3||r===H3||r===V3||r===G3||r===q3||r===W3||r===K3||r===X3||r===Y3||r===Q3||r===Z3||r===J3||r===eP)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(r===B3)return o===Nr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===$3)return o===Nr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===H3)return o===Nr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===V3)return o===Nr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===G3)return o===Nr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===q3)return o===Nr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===W3)return o===Nr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===K3)return o===Nr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===X3)return o===Nr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===Y3)return o===Nr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===Q3)return o===Nr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===Z3)return o===Nr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===J3)return o===Nr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===eP)return o===Nr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===tP||r===nP||r===rP)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(r===tP)return o===Nr?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===nP)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===rP)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===iP||r===aP||r===sP||r===oP)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(r===iP)return s.COMPRESSED_RED_RGTC1_EXT;if(r===aP)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===sP)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===oP)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===Y0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const Q0e=`
  3825. void main() {
  3826. gl_Position = vec4( position, 1.0 );
  3827. }`,Z0e=`
  3828. uniform sampler2DArray depthColor;
  3829. uniform float depthWidth;
  3830. uniform float depthHeight;
  3831. void main() {
  3832. vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
  3833. if ( coord.x >= 1.0 ) {
  3834. gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
  3835. } else {
  3836. gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
  3837. }
  3838. }`;class J0e{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new gK(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 Ou({vertexShader:Q0e,fragmentShader:Z0e,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new sl(new e4(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let eye=class extends Em{constructor(e,n){super();const r=this;let i=null,s=1,o=null,l="local-floor",c=1,u=null,d=null,f=null,m=null,p=null,x=null;const b=typeof XRWebGLBinding<"u",y=new J0e,v={},S=n.getContextAttributes();let N=null,C=null;const T=[],k=[],E=new An;let D=null;const A=new qo;A.viewport=new Di;const R=new qo;R.viewport=new Di;const F=[A,R],O=new xpe;let H=null,j=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(fe){let ye=T[fe];return ye===void 0&&(ye=new TT,T[fe]=ye),ye.getTargetRaySpace()},this.getControllerGrip=function(fe){let ye=T[fe];return ye===void 0&&(ye=new TT,T[fe]=ye),ye.getGripSpace()},this.getHand=function(fe){let ye=T[fe];return ye===void 0&&(ye=new TT,T[fe]=ye),ye.getHandSpace()};function G(fe){const ye=k.indexOf(fe.inputSource);if(ye===-1)return;const ge=T[ye];ge!==void 0&&(ge.update(fe.inputSource,fe.frame,u||o),ge.dispatchEvent({type:fe.type,data:fe.inputSource}))}function $(){i.removeEventListener("select",G),i.removeEventListener("selectstart",G),i.removeEventListener("selectend",G),i.removeEventListener("squeeze",G),i.removeEventListener("squeezestart",G),i.removeEventListener("squeezeend",G),i.removeEventListener("end",$),i.removeEventListener("inputsourceschange",q);for(let fe=0;fe<T.length;fe++){const ye=k[fe];ye!==null&&(k[fe]=null,T[fe].disconnect(ye))}H=null,j=null,y.reset();for(const fe in v)delete v[fe];e.setRenderTarget(N),p=null,m=null,f=null,i=null,C=null,ce.stop(),r.isPresenting=!1,e.setPixelRatio(D),e.setSize(E.width,E.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(fe){s=fe,r.isPresenting===!0&&mn("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(fe){l=fe,r.isPresenting===!0&&mn("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(fe){u=fe},this.getBaseLayer=function(){return m!==null?m:p},this.getBinding=function(){return f===null&&b&&(f=new XRWebGLBinding(i,n)),f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(fe){if(i=fe,i!==null){if(N=e.getRenderTarget(),i.addEventListener("select",G),i.addEventListener("selectstart",G),i.addEventListener("selectend",G),i.addEventListener("squeeze",G),i.addEventListener("squeezestart",G),i.addEventListener("squeezeend",G),i.addEventListener("end",$),i.addEventListener("inputsourceschange",q),S.xrCompatible!==!0&&await n.makeXRCompatible(),D=e.getPixelRatio(),e.getSize(E),b&&"createProjectionLayer"in XRWebGLBinding.prototype){let ge=null,xe=null,Pe=null;S.depth&&(Pe=S.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ge=S.stencil?Z0:Q0,xe=S.stencil?Y0:lm);const Ue={colorFormat:n.RGBA8,depthFormat:Pe,scaleFactor:s};f=this.getBinding(),m=f.createProjectionLayer(Ue),i.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),C=new um(m.textureWidth,m.textureHeight,{format:Pl,type:gc,depthTexture:new pK(m.textureWidth,m.textureHeight,xe,void 0,void 0,void 0,void 0,void 0,void 0,ge),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}else{const ge={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(i,n,ge),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),C=new um(p.framebufferWidth,p.framebufferHeight,{format:Pl,type:gc,colorSpace:e.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}C.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),ce.setContext(i),ce.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return y.getDepthTexture()};function q(fe){for(let ye=0;ye<fe.removed.length;ye++){const ge=fe.removed[ye],xe=k.indexOf(ge);xe>=0&&(k[xe]=null,T[xe].disconnect(ge))}for(let ye=0;ye<fe.added.length;ye++){const ge=fe.added[ye];let xe=k.indexOf(ge);if(xe===-1){for(let Ue=0;Ue<T.length;Ue++)if(Ue>=k.length){k.push(ge),xe=Ue;break}else if(k[Ue]===null){k[Ue]=ge,xe=Ue;break}if(xe===-1)break}const Pe=T[xe];Pe&&Pe.connect(ge)}}const Y=new lt,Z=new lt;function oe(fe,ye,ge){Y.setFromMatrixPosition(ye.matrixWorld),Z.setFromMatrixPosition(ge.matrixWorld);const xe=Y.distanceTo(Z),Pe=ye.projectionMatrix.elements,Ue=ge.projectionMatrix.elements,be=Pe[14]/(Pe[10]-1),it=Pe[14]/(Pe[10]+1),U=(Pe[9]+1)/Pe[5],K=(Pe[9]-1)/Pe[5],J=(Pe[8]-1)/Pe[0],Q=(Ue[8]+1)/Ue[0],z=be*J,re=be*Q,Ee=xe/(-J+Q),_e=Ee*-J;if(ye.matrixWorld.decompose(fe.position,fe.quaternion,fe.scale),fe.translateX(_e),fe.translateZ(Ee),fe.matrixWorld.compose(fe.position,fe.quaternion,fe.scale),fe.matrixWorldInverse.copy(fe.matrixWorld).invert(),Pe[10]===-1)fe.projectionMatrix.copy(ye.projectionMatrix),fe.projectionMatrixInverse.copy(ye.projectionMatrixInverse);else{const Te=be+Ee,V=it+Ee,L=z-_e,X=re+(xe-_e),te=U*it/V*Te,Me=K*it/V*Te;fe.projectionMatrix.makePerspective(L,X,te,Me,Te,V),fe.projectionMatrixInverse.copy(fe.projectionMatrix).invert()}}function B(fe,ye){ye===null?fe.matrixWorld.copy(fe.matrix):fe.matrixWorld.multiplyMatrices(ye.matrixWorld,fe.matrix),fe.matrixWorldInverse.copy(fe.matrixWorld).invert()}this.updateCamera=function(fe){if(i===null)return;let ye=fe.near,ge=fe.far;y.texture!==null&&(y.depthNear>0&&(ye=y.depthNear),y.depthFar>0&&(ge=y.depthFar)),O.near=R.near=A.near=ye,O.far=R.far=A.far=ge,(H!==O.near||j!==O.far)&&(i.updateRenderState({depthNear:O.near,depthFar:O.far}),H=O.near,j=O.far),O.layers.mask=fe.layers.mask|6,A.layers.mask=O.layers.mask&3,R.layers.mask=O.layers.mask&5;const xe=fe.parent,Pe=O.cameras;B(O,xe);for(let Ue=0;Ue<Pe.length;Ue++)B(Pe[Ue],xe);Pe.length===2?oe(O,A,R):O.projectionMatrix.copy(A.projectionMatrix),W(fe,O,xe)};function W(fe,ye,ge){ge===null?fe.matrix.copy(ye.matrixWorld):(fe.matrix.copy(ge.matrixWorld),fe.matrix.invert(),fe.matrix.multiply(ye.matrixWorld)),fe.matrix.decompose(fe.position,fe.quaternion,fe.scale),fe.updateMatrixWorld(!0),fe.projectionMatrix.copy(ye.projectionMatrix),fe.projectionMatrixInverse.copy(ye.projectionMatrixInverse),fe.isPerspectiveCamera&&(fe.fov=lP*2*Math.atan(1/fe.projectionMatrix.elements[5]),fe.zoom=1)}this.getCamera=function(){return O},this.getFoveation=function(){if(!(m===null&&p===null))return c},this.setFoveation=function(fe){c=fe,m!==null&&(m.fixedFoveation=fe),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=fe)},this.hasDepthSensing=function(){return y.texture!==null},this.getDepthSensingMesh=function(){return y.getMesh(O)},this.getCameraTexture=function(fe){return v[fe]};let se=null;function ne(fe,ye){if(d=ye.getViewerPose(u||o),x=ye,d!==null){const ge=d.views;p!==null&&(e.setRenderTargetFramebuffer(C,p.framebuffer),e.setRenderTarget(C));let xe=!1;ge.length!==O.cameras.length&&(O.cameras.length=0,xe=!0);for(let it=0;it<ge.length;it++){const U=ge[it];let K=null;if(p!==null)K=p.getViewport(U);else{const Q=f.getViewSubImage(m,U);K=Q.viewport,it===0&&(e.setRenderTargetTextures(C,Q.colorTexture,Q.depthStencilTexture),e.setRenderTarget(C))}let J=F[it];J===void 0&&(J=new qo,J.layers.enable(it),J.viewport=new Di,F[it]=J),J.matrix.fromArray(U.transform.matrix),J.matrix.decompose(J.position,J.quaternion,J.scale),J.projectionMatrix.fromArray(U.projectionMatrix),J.projectionMatrixInverse.copy(J.projectionMatrix).invert(),J.viewport.set(K.x,K.y,K.width,K.height),it===0&&(O.matrix.copy(J.matrix),O.matrix.decompose(O.position,O.quaternion,O.scale)),xe===!0&&O.cameras.push(J)}const Pe=i.enabledFeatures;if(Pe&&Pe.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&b){f=r.getBinding();const it=f.getDepthInformation(ge[0]);it&&it.isValid&&it.texture&&y.init(it,i.renderState)}if(Pe&&Pe.includes("camera-access")&&b){e.state.unbindTexture(),f=r.getBinding();for(let it=0;it<ge.length;it++){const U=ge[it].camera;if(U){let K=v[U];K||(K=new gK,v[U]=K);const J=f.getCameraImage(U);K.sourceTexture=J}}}}for(let ge=0;ge<T.length;ge++){const xe=k[ge],Pe=T[ge];xe!==null&&Pe!==void 0&&Pe.update(xe,ye,u||o)}se&&se(fe,ye),ye.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ye}),x=null}const ce=new _K;ce.setAnimationLoop(ne),this.setAnimationLoop=function(fe){se=fe},this.dispose=function(){}}};const hf=new wh,tye=new Fi;function nye(t,e){function n(y,v){y.matrixAutoUpdate===!0&&y.updateMatrix(),v.value.copy(y.matrix)}function r(y,v){v.color.getRGB(y.fogColor.value,dK(t)),v.isFog?(y.fogNear.value=v.near,y.fogFar.value=v.far):v.isFogExp2&&(y.fogDensity.value=v.density)}function i(y,v,S,N,C){v.isMeshBasicMaterial||v.isMeshLambertMaterial?s(y,v):v.isMeshToonMaterial?(s(y,v),f(y,v)):v.isMeshPhongMaterial?(s(y,v),d(y,v)):v.isMeshStandardMaterial?(s(y,v),m(y,v),v.isMeshPhysicalMaterial&&p(y,v,C)):v.isMeshMatcapMaterial?(s(y,v),x(y,v)):v.isMeshDepthMaterial?s(y,v):v.isMeshDistanceMaterial?(s(y,v),b(y,v)):v.isMeshNormalMaterial?s(y,v):v.isLineBasicMaterial?(o(y,v),v.isLineDashedMaterial&&l(y,v)):v.isPointsMaterial?c(y,v,S,N):v.isSpriteMaterial?u(y,v):v.isShadowMaterial?(y.color.value.copy(v.color),y.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function s(y,v){y.opacity.value=v.opacity,v.color&&y.diffuse.value.copy(v.color),v.emissive&&y.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(y.map.value=v.map,n(v.map,y.mapTransform)),v.alphaMap&&(y.alphaMap.value=v.alphaMap,n(v.alphaMap,y.alphaMapTransform)),v.bumpMap&&(y.bumpMap.value=v.bumpMap,n(v.bumpMap,y.bumpMapTransform),y.bumpScale.value=v.bumpScale,v.side===zs&&(y.bumpScale.value*=-1)),v.normalMap&&(y.normalMap.value=v.normalMap,n(v.normalMap,y.normalMapTransform),y.normalScale.value.copy(v.normalScale),v.side===zs&&y.normalScale.value.negate()),v.displacementMap&&(y.displacementMap.value=v.displacementMap,n(v.displacementMap,y.displacementMapTransform),y.displacementScale.value=v.displacementScale,y.displacementBias.value=v.displacementBias),v.emissiveMap&&(y.emissiveMap.value=v.emissiveMap,n(v.emissiveMap,y.emissiveMapTransform)),v.specularMap&&(y.specularMap.value=v.specularMap,n(v.specularMap,y.specularMapTransform)),v.alphaTest>0&&(y.alphaTest.value=v.alphaTest);const S=e.get(v),N=S.envMap,C=S.envMapRotation;N&&(y.envMap.value=N,hf.copy(C),hf.x*=-1,hf.y*=-1,hf.z*=-1,N.isCubeTexture&&N.isRenderTargetTexture===!1&&(hf.y*=-1,hf.z*=-1),y.envMapRotation.value.setFromMatrix4(tye.makeRotationFromEuler(hf)),y.flipEnvMap.value=N.isCubeTexture&&N.isRenderTargetTexture===!1?-1:1,y.reflectivity.value=v.reflectivity,y.ior.value=v.ior,y.refractionRatio.value=v.refractionRatio),v.lightMap&&(y.lightMap.value=v.lightMap,y.lightMapIntensity.value=v.lightMapIntensity,n(v.lightMap,y.lightMapTransform)),v.aoMap&&(y.aoMap.value=v.aoMap,y.aoMapIntensity.value=v.aoMapIntensity,n(v.aoMap,y.aoMapTransform))}function o(y,v){y.diffuse.value.copy(v.color),y.opacity.value=v.opacity,v.map&&(y.map.value=v.map,n(v.map,y.mapTransform))}function l(y,v){y.dashSize.value=v.dashSize,y.totalSize.value=v.dashSize+v.gapSize,y.scale.value=v.scale}function c(y,v,S,N){y.diffuse.value.copy(v.color),y.opacity.value=v.opacity,y.size.value=v.size*S,y.scale.value=N*.5,v.map&&(y.map.value=v.map,n(v.map,y.uvTransform)),v.alphaMap&&(y.alphaMap.value=v.alphaMap,n(v.alphaMap,y.alphaMapTransform)),v.alphaTest>0&&(y.alphaTest.value=v.alphaTest)}function u(y,v){y.diffuse.value.copy(v.color),y.opacity.value=v.opacity,y.rotation.value=v.rotation,v.map&&(y.map.value=v.map,n(v.map,y.mapTransform)),v.alphaMap&&(y.alphaMap.value=v.alphaMap,n(v.alphaMap,y.alphaMapTransform)),v.alphaTest>0&&(y.alphaTest.value=v.alphaTest)}function d(y,v){y.specular.value.copy(v.specular),y.shininess.value=Math.max(v.shininess,1e-4)}function f(y,v){v.gradientMap&&(y.gradientMap.value=v.gradientMap)}function m(y,v){y.metalness.value=v.metalness,v.metalnessMap&&(y.metalnessMap.value=v.metalnessMap,n(v.metalnessMap,y.metalnessMapTransform)),y.roughness.value=v.roughness,v.roughnessMap&&(y.roughnessMap.value=v.roughnessMap,n(v.roughnessMap,y.roughnessMapTransform)),v.envMap&&(y.envMapIntensity.value=v.envMapIntensity)}function p(y,v,S){y.ior.value=v.ior,v.sheen>0&&(y.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),y.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(y.sheenColorMap.value=v.sheenColorMap,n(v.sheenColorMap,y.sheenColorMapTransform)),v.sheenRoughnessMap&&(y.sheenRoughnessMap.value=v.sheenRoughnessMap,n(v.sheenRoughnessMap,y.sheenRoughnessMapTransform))),v.clearcoat>0&&(y.clearcoat.value=v.clearcoat,y.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(y.clearcoatMap.value=v.clearcoatMap,n(v.clearcoatMap,y.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,n(v.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(y.clearcoatNormalMap.value=v.clearcoatNormalMap,n(v.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===zs&&y.clearcoatNormalScale.value.negate())),v.dispersion>0&&(y.dispersion.value=v.dispersion),v.iridescence>0&&(y.iridescence.value=v.iridescence,y.iridescenceIOR.value=v.iridescenceIOR,y.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(y.iridescenceMap.value=v.iridescenceMap,n(v.iridescenceMap,y.iridescenceMapTransform)),v.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=v.iridescenceThicknessMap,n(v.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),v.transmission>0&&(y.transmission.value=v.transmission,y.transmissionSamplerMap.value=S.texture,y.transmissionSamplerSize.value.set(S.width,S.height),v.transmissionMap&&(y.transmissionMap.value=v.transmissionMap,n(v.transmissionMap,y.transmissionMapTransform)),y.thickness.value=v.thickness,v.thicknessMap&&(y.thicknessMap.value=v.thicknessMap,n(v.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=v.attenuationDistance,y.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(y.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(y.anisotropyMap.value=v.anisotropyMap,n(v.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=v.specularIntensity,y.specularColor.value.copy(v.specularColor),v.specularColorMap&&(y.specularColorMap.value=v.specularColorMap,n(v.specularColorMap,y.specularColorMapTransform)),v.specularIntensityMap&&(y.specularIntensityMap.value=v.specularIntensityMap,n(v.specularIntensityMap,y.specularIntensityMapTransform))}function x(y,v){v.matcap&&(y.matcap.value=v.matcap)}function b(y,v){const S=e.get(v).light;y.referencePosition.value.setFromMatrixPosition(S.matrixWorld),y.nearDistance.value=S.shadow.camera.near,y.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function rye(t,e,n,r){let i={},s={},o=[];const l=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(S,N){const C=N.program;r.uniformBlockBinding(S,C)}function u(S,N){let C=i[S.id];C===void 0&&(x(S),C=d(S),i[S.id]=C,S.addEventListener("dispose",y));const T=N.program;r.updateUBOMapping(S,T);const k=e.render.frame;s[S.id]!==k&&(m(S),s[S.id]=k)}function d(S){const N=f();S.__bindingPointIndex=N;const C=t.createBuffer(),T=S.__size,k=S.usage;return t.bindBuffer(t.UNIFORM_BUFFER,C),t.bufferData(t.UNIFORM_BUFFER,T,k),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,N,C),C}function f(){for(let S=0;S<l;S++)if(o.indexOf(S)===-1)return o.push(S),S;return _i("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function m(S){const N=i[S.id],C=S.uniforms,T=S.__cache;t.bindBuffer(t.UNIFORM_BUFFER,N);for(let k=0,E=C.length;k<E;k++){const D=Array.isArray(C[k])?C[k]:[C[k]];for(let A=0,R=D.length;A<R;A++){const F=D[A];if(p(F,k,A,T)===!0){const O=F.__offset,H=Array.isArray(F.value)?F.value:[F.value];let j=0;for(let G=0;G<H.length;G++){const $=H[G],q=b($);typeof $=="number"||typeof $=="boolean"?(F.__data[0]=$,t.bufferSubData(t.UNIFORM_BUFFER,O+j,F.__data)):$.isMatrix3?(F.__data[0]=$.elements[0],F.__data[1]=$.elements[1],F.__data[2]=$.elements[2],F.__data[3]=0,F.__data[4]=$.elements[3],F.__data[5]=$.elements[4],F.__data[6]=$.elements[5],F.__data[7]=0,F.__data[8]=$.elements[6],F.__data[9]=$.elements[7],F.__data[10]=$.elements[8],F.__data[11]=0):($.toArray(F.__data,j),j+=q.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,O,F.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(S,N,C,T){const k=S.value,E=N+"_"+C;if(T[E]===void 0)return typeof k=="number"||typeof k=="boolean"?T[E]=k:T[E]=k.clone(),!0;{const D=T[E];if(typeof k=="number"||typeof k=="boolean"){if(D!==k)return T[E]=k,!0}else if(D.equals(k)===!1)return D.copy(k),!0}return!1}function x(S){const N=S.uniforms;let C=0;const T=16;for(let E=0,D=N.length;E<D;E++){const A=Array.isArray(N[E])?N[E]:[N[E]];for(let R=0,F=A.length;R<F;R++){const O=A[R],H=Array.isArray(O.value)?O.value:[O.value];for(let j=0,G=H.length;j<G;j++){const $=H[j],q=b($),Y=C%T,Z=Y%q.boundary,oe=Y+Z;C+=Z,oe!==0&&T-oe<q.storage&&(C+=T-oe),O.__data=new Float32Array(q.storage/Float32Array.BYTES_PER_ELEMENT),O.__offset=C,C+=q.storage}}}const k=C%T;return k>0&&(C+=T-k),S.__size=C,S.__cache={},this}function b(S){const N={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(N.boundary=4,N.storage=4):S.isVector2?(N.boundary=8,N.storage=8):S.isVector3||S.isColor?(N.boundary=16,N.storage=12):S.isVector4?(N.boundary=16,N.storage=16):S.isMatrix3?(N.boundary=48,N.storage=48):S.isMatrix4?(N.boundary=64,N.storage=64):S.isTexture?mn("WebGLRenderer: Texture samplers can not be part of an uniforms group."):mn("WebGLRenderer: Unsupported uniform value type.",S),N}function y(S){const N=S.target;N.removeEventListener("dispose",y);const C=o.indexOf(N.__bindingPointIndex);o.splice(C,1),t.deleteBuffer(i[N.id]),delete i[N.id],delete s[N.id]}function v(){for(const S in i)t.deleteBuffer(i[S]);o=[],i={},s={}}return{bind:c,update:u,dispose:v}}const iye=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 Qc=null;function aye(){return Qc===null&&(Qc=new npe(iye,32,32,qD,yx),Qc.minFilter=Zo,Qc.magFilter=Zo,Qc.wrapS=xu,Qc.wrapT=xu,Qc.generateMipmaps=!1,Qc.needsUpdate=!0),Qc}let sye=class{constructor(e={}){const{canvas:n=Cme(),context:r=null,depth:i=!0,stencil:s=!1,alpha:o=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:m=!1}=e;this.isWebGLRenderer=!0;let p;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=r.getContextAttributes().alpha}else p=o;const x=new Set([KD,WD,GD]),b=new Set([gc,lm,X0,Y0,HD,VD]),y=new Uint32Array(4),v=new Int32Array(4);let S=null,N=null;const C=[],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=sh,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const k=this;let E=!1;this._outputColorSpace=so;let D=0,A=0,R=null,F=-1,O=null;const H=new Di,j=new Di;let G=null;const $=new Rn(0);let q=0,Y=n.width,Z=n.height,oe=1,B=null,W=null;const se=new Di(0,0,Y,Z),ne=new Di(0,0,Y,Z);let ce=!1;const fe=new JD;let ye=!1,ge=!1;const xe=new Fi,Pe=new lt,Ue=new Di,be={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let it=!1;function U(){return R===null?oe:1}let K=r;function J(he,me){return n.getContext(he,me)}try{const he={alpha:!0,depth:i,stencil:s,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${zD}`),n.addEventListener("webglcontextlost",pe,!1),n.addEventListener("webglcontextrestored",Ce,!1),n.addEventListener("webglcontextcreationerror",de,!1),K===null){const me="webgl2";if(K=J(me,he),K===null)throw J(me)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(he){throw he("WebGLRenderer: "+he.message),he}let Q,z,re,Ee,_e,Te,V,L,X,te,Me,ie,De,Le,$e,Ze,Ie,ae,He,Se,Be,ft,we,tt;function ke(){Q=new mbe(K),Q.init(),ft=new Y0e(K,Q),z=new abe(K,Q,e,ft),re=new K0e(K,Q),z.reversedDepthBuffer&&m&&re.buffers.depth.setReversed(!0),Ee=new xbe(K),_e=new O0e,Te=new X0e(K,Q,re,_e,z,ft,Ee),V=new obe(k),L=new fbe(k),X=new _pe(K),we=new rbe(K,X),te=new pbe(K,X,Ee,we),Me=new ybe(K,te,X,Ee),He=new bbe(K,z,Te),Ze=new sbe(_e),ie=new D0e(k,V,L,Q,z,we,Ze),De=new nye(k,_e),Le=new I0e,$e=new H0e(Q),ae=new nbe(k,V,L,re,Me,p,c),Ie=new q0e(k,Me,z),tt=new rye(K,Ee,z,re),Se=new ibe(K,Q,Ee),Be=new gbe(K,Q,Ee),Ee.programs=ie.programs,k.capabilities=z,k.extensions=Q,k.properties=_e,k.renderLists=Le,k.shadowMap=Ie,k.state=re,k.info=Ee}ke();const We=new eye(k,K);this.xr=We,this.getContext=function(){return K},this.getContextAttributes=function(){return K.getContextAttributes()},this.forceContextLoss=function(){const he=Q.get("WEBGL_lose_context");he&&he.loseContext()},this.forceContextRestore=function(){const he=Q.get("WEBGL_lose_context");he&&he.restoreContext()},this.getPixelRatio=function(){return oe},this.setPixelRatio=function(he){he!==void 0&&(oe=he,this.setSize(Y,Z,!1))},this.getSize=function(he){return he.set(Y,Z)},this.setSize=function(he,me,Fe=!0){if(We.isPresenting){mn("WebGLRenderer: Can't change size while VR device is presenting.");return}Y=he,Z=me,n.width=Math.floor(he*oe),n.height=Math.floor(me*oe),Fe===!0&&(n.style.width=he+"px",n.style.height=me+"px"),this.setViewport(0,0,he,me)},this.getDrawingBufferSize=function(he){return he.set(Y*oe,Z*oe).floor()},this.setDrawingBufferSize=function(he,me,Fe){Y=he,Z=me,oe=Fe,n.width=Math.floor(he*Fe),n.height=Math.floor(me*Fe),this.setViewport(0,0,he,me)},this.getCurrentViewport=function(he){return he.copy(H)},this.getViewport=function(he){return he.copy(se)},this.setViewport=function(he,me,Fe,Oe){he.isVector4?se.set(he.x,he.y,he.z,he.w):se.set(he,me,Fe,Oe),re.viewport(H.copy(se).multiplyScalar(oe).round())},this.getScissor=function(he){return he.copy(ne)},this.setScissor=function(he,me,Fe,Oe){he.isVector4?ne.set(he.x,he.y,he.z,he.w):ne.set(he,me,Fe,Oe),re.scissor(j.copy(ne).multiplyScalar(oe).round())},this.getScissorTest=function(){return ce},this.setScissorTest=function(he){re.setScissorTest(ce=he)},this.setOpaqueSort=function(he){B=he},this.setTransparentSort=function(he){W=he},this.getClearColor=function(he){return he.copy(ae.getClearColor())},this.setClearColor=function(){ae.setClearColor(...arguments)},this.getClearAlpha=function(){return ae.getClearAlpha()},this.setClearAlpha=function(){ae.setClearAlpha(...arguments)},this.clear=function(he=!0,me=!0,Fe=!0){let Oe=0;if(he){let je=!1;if(R!==null){const ht=R.texture.format;je=x.has(ht)}if(je){const ht=R.texture.type,Nt=b.has(ht),Ct=ae.getClearColor(),At=ae.getClearAlpha(),Lt=Ct.r,Rt=Ct.g,Mt=Ct.b;Nt?(y[0]=Lt,y[1]=Rt,y[2]=Mt,y[3]=At,K.clearBufferuiv(K.COLOR,0,y)):(v[0]=Lt,v[1]=Rt,v[2]=Mt,v[3]=At,K.clearBufferiv(K.COLOR,0,v))}else Oe|=K.COLOR_BUFFER_BIT}me&&(Oe|=K.DEPTH_BUFFER_BIT),Fe&&(Oe|=K.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),K.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",pe,!1),n.removeEventListener("webglcontextrestored",Ce,!1),n.removeEventListener("webglcontextcreationerror",de,!1),ae.dispose(),Le.dispose(),$e.dispose(),_e.dispose(),V.dispose(),L.dispose(),Me.dispose(),we.dispose(),tt.dispose(),ie.dispose(),We.dispose(),We.removeEventListener("sessionstart",Kt),We.removeEventListener("sessionend",cr),dr.stop()};function pe(he){he.preventDefault(),Qz("WebGLRenderer: Context Lost."),E=!0}function Ce(){Qz("WebGLRenderer: Context Restored."),E=!1;const he=Ee.autoReset,me=Ie.enabled,Fe=Ie.autoUpdate,Oe=Ie.needsUpdate,je=Ie.type;ke(),Ee.autoReset=he,Ie.enabled=me,Ie.autoUpdate=Fe,Ie.needsUpdate=Oe,Ie.type=je}function de(he){_i("WebGLRenderer: A WebGL context could not be created. Reason: ",he.statusMessage)}function Ve(he){const me=he.target;me.removeEventListener("dispose",Ve),yt(me)}function yt(he){ut(he),_e.remove(he)}function ut(he){const me=_e.get(he).programs;me!==void 0&&(me.forEach(function(Fe){ie.releaseProgram(Fe)}),he.isShaderMaterial&&ie.releaseShaderCache(he))}this.renderBufferDirect=function(he,me,Fe,Oe,je,ht){me===null&&(me=be);const Nt=je.isMesh&&je.matrixWorld.determinant()<0,Ct=Ae(he,me,Fe,Oe,je);re.setMaterial(Oe,Nt);let At=Fe.index,Lt=1;if(Oe.wireframe===!0){if(At=te.getWireframeAttribute(Fe),At===void 0)return;Lt=2}const Rt=Fe.drawRange,Mt=Fe.attributes.position;let Zt=Rt.start*Lt,$t=(Rt.start+Rt.count)*Lt;ht!==null&&(Zt=Math.max(Zt,ht.start*Lt),$t=Math.min($t,(ht.start+ht.count)*Lt)),At!==null?(Zt=Math.max(Zt,0),$t=Math.min($t,At.count)):Mt!=null&&(Zt=Math.max(Zt,0),$t=Math.min($t,Mt.count));const un=$t-Zt;if(un<0||un===1/0)return;we.setup(je,Oe,Ct,Fe,At);let _n,Mn=Se;if(At!==null&&(_n=X.get(At),Mn=Be,Mn.setIndex(_n)),je.isMesh)Oe.wireframe===!0?(re.setLineWidth(Oe.wireframeLinewidth*U()),Mn.setMode(K.LINES)):Mn.setMode(K.TRIANGLES);else if(je.isLine){let Ht=Oe.linewidth;Ht===void 0&&(Ht=1),re.setLineWidth(Ht*U()),je.isLineSegments?Mn.setMode(K.LINES):je.isLineLoop?Mn.setMode(K.LINE_LOOP):Mn.setMode(K.LINE_STRIP)}else je.isPoints?Mn.setMode(K.POINTS):je.isSprite&&Mn.setMode(K.TRIANGLES);if(je.isBatchedMesh)if(je._multiDrawInstances!==null)J0("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Mn.renderMultiDrawInstances(je._multiDrawStarts,je._multiDrawCounts,je._multiDrawCount,je._multiDrawInstances);else if(Q.get("WEBGL_multi_draw"))Mn.renderMultiDraw(je._multiDrawStarts,je._multiDrawCounts,je._multiDrawCount);else{const Ht=je._multiDrawStarts,Xt=je._multiDrawCounts,tn=je._multiDrawCount,cn=At?X.get(At).bytesPerElement:1,Ur=_e.get(Oe).currentProgram.getUniforms();for(let qn=0;qn<tn;qn++)Ur.setValue(K,"_gl_DrawID",qn),Mn.render(Ht[qn]/cn,Xt[qn])}else if(je.isInstancedMesh)Mn.renderInstances(Zt,un,je.count);else if(Fe.isInstancedBufferGeometry){const Ht=Fe._maxInstanceCount!==void 0?Fe._maxInstanceCount:1/0,Xt=Math.min(Fe.instanceCount,Ht);Mn.renderInstances(Zt,un,Xt)}else Mn.render(Zt,un)};function It(he,me,Fe){he.transparent===!0&&he.side===ic&&he.forceSinglePass===!1?(he.side=zs,he.needsUpdate=!0,bn(he,me,Fe),he.side=_h,he.needsUpdate=!0,bn(he,me,Fe),he.side=ic):bn(he,me,Fe)}this.compile=function(he,me,Fe=null){Fe===null&&(Fe=he),N=$e.get(Fe),N.init(me),T.push(N),Fe.traverseVisible(function(je){je.isLight&&je.layers.test(me.layers)&&(N.pushLight(je),je.castShadow&&N.pushShadow(je))}),he!==Fe&&he.traverseVisible(function(je){je.isLight&&je.layers.test(me.layers)&&(N.pushLight(je),je.castShadow&&N.pushShadow(je))}),N.setupLights();const Oe=new Set;return he.traverse(function(je){if(!(je.isMesh||je.isPoints||je.isLine||je.isSprite))return;const ht=je.material;if(ht)if(Array.isArray(ht))for(let Nt=0;Nt<ht.length;Nt++){const Ct=ht[Nt];It(Ct,Fe,je),Oe.add(Ct)}else It(ht,Fe,je),Oe.add(ht)}),N=T.pop(),Oe},this.compileAsync=function(he,me,Fe=null){const Oe=this.compile(he,me,Fe);return new Promise(je=>{function ht(){if(Oe.forEach(function(Nt){_e.get(Nt).currentProgram.isReady()&&Oe.delete(Nt)}),Oe.size===0){je(he);return}setTimeout(ht,10)}Q.get("KHR_parallel_shader_compile")!==null?ht():setTimeout(ht,10)})};let Ft=null;function vn(he){Ft&&Ft(he)}function Kt(){dr.stop()}function cr(){dr.start()}const dr=new _K;dr.setAnimationLoop(vn),typeof self<"u"&&dr.setContext(self),this.setAnimationLoop=function(he){Ft=he,We.setAnimationLoop(he),he===null?dr.stop():dr.start()},We.addEventListener("sessionstart",Kt),We.addEventListener("sessionend",cr),this.render=function(he,me){if(me!==void 0&&me.isCamera!==!0){_i("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(E===!0)return;if(he.matrixWorldAutoUpdate===!0&&he.updateMatrixWorld(),me.parent===null&&me.matrixWorldAutoUpdate===!0&&me.updateMatrixWorld(),We.enabled===!0&&We.isPresenting===!0&&(We.cameraAutoUpdate===!0&&We.updateCamera(me),me=We.getCamera()),he.isScene===!0&&he.onBeforeRender(k,he,me,R),N=$e.get(he,T.length),N.init(me),T.push(N),xe.multiplyMatrices(me.projectionMatrix,me.matrixWorldInverse),fe.setFromProjectionMatrix(xe,lc,me.reversedDepth),ge=this.localClippingEnabled,ye=Ze.init(this.clippingPlanes,ge),S=Le.get(he,C.length),S.init(),C.push(S),We.enabled===!0&&We.isPresenting===!0){const ht=k.xr.getDepthSensingMesh();ht!==null&&Jn(ht,me,-1/0,k.sortObjects)}Jn(he,me,0,k.sortObjects),S.finish(),k.sortObjects===!0&&S.sort(B,W),it=We.enabled===!1||We.isPresenting===!1||We.hasDepthSensing()===!1,it&&ae.addToRenderList(S,he),this.info.render.frame++,ye===!0&&Ze.beginShadows();const Fe=N.state.shadowsArray;Ie.render(Fe,he,me),ye===!0&&Ze.endShadows(),this.info.autoReset===!0&&this.info.reset();const Oe=S.opaque,je=S.transmissive;if(N.setupLights(),me.isArrayCamera){const ht=me.cameras;if(je.length>0)for(let Nt=0,Ct=ht.length;Nt<Ct;Nt++){const At=ht[Nt];Gn(Oe,je,he,At)}it&&ae.render(he);for(let Nt=0,Ct=ht.length;Nt<Ct;Nt++){const At=ht[Nt];ln(S,he,At,At.viewport)}}else je.length>0&&Gn(Oe,je,he,me),it&&ae.render(he),ln(S,he,me);R!==null&&A===0&&(Te.updateMultisampleRenderTarget(R),Te.updateRenderTargetMipmap(R)),he.isScene===!0&&he.onAfterRender(k,he,me),we.resetDefaultState(),F=-1,O=null,T.pop(),T.length>0?(N=T[T.length-1],ye===!0&&Ze.setGlobalState(k.clippingPlanes,N.state.camera)):N=null,C.pop(),C.length>0?S=C[C.length-1]:S=null};function Jn(he,me,Fe,Oe){if(he.visible===!1)return;if(he.layers.test(me.layers)){if(he.isGroup)Fe=he.renderOrder;else if(he.isLOD)he.autoUpdate===!0&&he.update(me);else if(he.isLight)N.pushLight(he),he.castShadow&&N.pushShadow(he);else if(he.isSprite){if(!he.frustumCulled||fe.intersectsSprite(he)){Oe&&Ue.setFromMatrixPosition(he.matrixWorld).applyMatrix4(xe);const Nt=Me.update(he),Ct=he.material;Ct.visible&&S.push(he,Nt,Ct,Fe,Ue.z,null)}}else if((he.isMesh||he.isLine||he.isPoints)&&(!he.frustumCulled||fe.intersectsObject(he))){const Nt=Me.update(he),Ct=he.material;if(Oe&&(he.boundingSphere!==void 0?(he.boundingSphere===null&&he.computeBoundingSphere(),Ue.copy(he.boundingSphere.center)):(Nt.boundingSphere===null&&Nt.computeBoundingSphere(),Ue.copy(Nt.boundingSphere.center)),Ue.applyMatrix4(he.matrixWorld).applyMatrix4(xe)),Array.isArray(Ct)){const At=Nt.groups;for(let Lt=0,Rt=At.length;Lt<Rt;Lt++){const Mt=At[Lt],Zt=Ct[Mt.materialIndex];Zt&&Zt.visible&&S.push(he,Nt,Zt,Fe,Ue.z,Mt)}}else Ct.visible&&S.push(he,Nt,Ct,Fe,Ue.z,null)}}const ht=he.children;for(let Nt=0,Ct=ht.length;Nt<Ct;Nt++)Jn(ht[Nt],me,Fe,Oe)}function ln(he,me,Fe,Oe){const{opaque:je,transmissive:ht,transparent:Nt}=he;N.setupLightsView(Fe),ye===!0&&Ze.setGlobalState(k.clippingPlanes,Fe),Oe&&re.viewport(H.copy(Oe)),je.length>0&&nr(je,me,Fe),ht.length>0&&nr(ht,me,Fe),Nt.length>0&&nr(Nt,me,Fe),re.buffers.depth.setTest(!0),re.buffers.depth.setMask(!0),re.buffers.color.setMask(!0),re.setPolygonOffset(!1)}function Gn(he,me,Fe,Oe){if((Fe.isScene===!0?Fe.overrideMaterial:null)!==null)return;N.state.transmissionRenderTarget[Oe.id]===void 0&&(N.state.transmissionRenderTarget[Oe.id]=new um(1,1,{generateMipmaps:!0,type:Q.has("EXT_color_buffer_half_float")||Q.has("EXT_color_buffer_float")?yx:gc,minFilter:Pf,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ar.workingColorSpace}));const ht=N.state.transmissionRenderTarget[Oe.id],Nt=Oe.viewport||H;ht.setSize(Nt.z*k.transmissionResolutionScale,Nt.w*k.transmissionResolutionScale);const Ct=k.getRenderTarget(),At=k.getActiveCubeFace(),Lt=k.getActiveMipmapLevel();k.setRenderTarget(ht),k.getClearColor($),q=k.getClearAlpha(),q<1&&k.setClearColor(16777215,.5),k.clear(),it&&ae.render(Fe);const Rt=k.toneMapping;k.toneMapping=sh;const Mt=Oe.viewport;if(Oe.viewport!==void 0&&(Oe.viewport=void 0),N.setupLightsView(Oe),ye===!0&&Ze.setGlobalState(k.clippingPlanes,Oe),nr(he,Fe,Oe),Te.updateMultisampleRenderTarget(ht),Te.updateRenderTargetMipmap(ht),Q.has("WEBGL_multisampled_render_to_texture")===!1){let Zt=!1;for(let $t=0,un=me.length;$t<un;$t++){const _n=me[$t],{object:Mn,geometry:Ht,material:Xt,group:tn}=_n;if(Xt.side===ic&&Mn.layers.test(Oe.layers)){const cn=Xt.side;Xt.side=zs,Xt.needsUpdate=!0,er(Mn,Fe,Oe,Ht,Xt,tn),Xt.side=cn,Xt.needsUpdate=!0,Zt=!0}}Zt===!0&&(Te.updateMultisampleRenderTarget(ht),Te.updateRenderTargetMipmap(ht))}k.setRenderTarget(Ct,At,Lt),k.setClearColor($,q),Mt!==void 0&&(Oe.viewport=Mt),k.toneMapping=Rt}function nr(he,me,Fe){const Oe=me.isScene===!0?me.overrideMaterial:null;for(let je=0,ht=he.length;je<ht;je++){const Nt=he[je],{object:Ct,geometry:At,group:Lt}=Nt;let Rt=Nt.material;Rt.allowOverride===!0&&Oe!==null&&(Rt=Oe),Ct.layers.test(Fe.layers)&&er(Ct,me,Fe,At,Rt,Lt)}}function er(he,me,Fe,Oe,je,ht){he.onBeforeRender(k,me,Fe,Oe,je,ht),he.modelViewMatrix.multiplyMatrices(Fe.matrixWorldInverse,he.matrixWorld),he.normalMatrix.getNormalMatrix(he.modelViewMatrix),je.onBeforeRender(k,me,Fe,Oe,he,ht),je.transparent===!0&&je.side===ic&&je.forceSinglePass===!1?(je.side=zs,je.needsUpdate=!0,k.renderBufferDirect(Fe,me,Oe,je,he,ht),je.side=_h,je.needsUpdate=!0,k.renderBufferDirect(Fe,me,Oe,je,he,ht),je.side=ic):k.renderBufferDirect(Fe,me,Oe,je,he,ht),he.onAfterRender(k,me,Fe,Oe,je,ht)}function bn(he,me,Fe){me.isScene!==!0&&(me=be);const Oe=_e.get(he),je=N.state.lights,ht=N.state.shadowsArray,Nt=je.state.version,Ct=ie.getParameters(he,je.state,ht,me,Fe),At=ie.getProgramCacheKey(Ct);let Lt=Oe.programs;Oe.environment=he.isMeshStandardMaterial?me.environment:null,Oe.fog=me.fog,Oe.envMap=(he.isMeshStandardMaterial?L:V).get(he.envMap||Oe.environment),Oe.envMapRotation=Oe.environment!==null&&he.envMap===null?me.environmentRotation:he.envMapRotation,Lt===void 0&&(he.addEventListener("dispose",Ve),Lt=new Map,Oe.programs=Lt);let Rt=Lt.get(At);if(Rt!==void 0){if(Oe.currentProgram===Rt&&Oe.lightsStateVersion===Nt)return Ia(he,Ct),Rt}else Ct.uniforms=ie.getUniforms(he),he.onBeforeCompile(Ct,k),Rt=ie.acquireProgram(Ct,At),Lt.set(At,Rt),Oe.uniforms=Ct.uniforms;const Mt=Oe.uniforms;return(!he.isShaderMaterial&&!he.isRawShaderMaterial||he.clipping===!0)&&(Mt.clippingPlanes=Ze.uniform),Ia(he,Ct),Oe.needsLights=Je(he),Oe.lightsStateVersion=Nt,Oe.needsLights&&(Mt.ambientLightColor.value=je.state.ambient,Mt.lightProbe.value=je.state.probe,Mt.directionalLights.value=je.state.directional,Mt.directionalLightShadows.value=je.state.directionalShadow,Mt.spotLights.value=je.state.spot,Mt.spotLightShadows.value=je.state.spotShadow,Mt.rectAreaLights.value=je.state.rectArea,Mt.ltc_1.value=je.state.rectAreaLTC1,Mt.ltc_2.value=je.state.rectAreaLTC2,Mt.pointLights.value=je.state.point,Mt.pointLightShadows.value=je.state.pointShadow,Mt.hemisphereLights.value=je.state.hemi,Mt.directionalShadowMap.value=je.state.directionalShadowMap,Mt.directionalShadowMatrix.value=je.state.directionalShadowMatrix,Mt.spotShadowMap.value=je.state.spotShadowMap,Mt.spotLightMatrix.value=je.state.spotLightMatrix,Mt.spotLightMap.value=je.state.spotLightMap,Mt.pointShadowMap.value=je.state.pointShadowMap,Mt.pointShadowMatrix.value=je.state.pointShadowMatrix),Oe.currentProgram=Rt,Oe.uniformsList=null,Rt}function xi(he){if(he.uniformsList===null){const me=he.currentProgram.getUniforms();he.uniformsList=M1.seqWithValue(me.seq,he.uniforms)}return he.uniformsList}function Ia(he,me){const Fe=_e.get(he);Fe.outputColorSpace=me.outputColorSpace,Fe.batching=me.batching,Fe.batchingColor=me.batchingColor,Fe.instancing=me.instancing,Fe.instancingColor=me.instancingColor,Fe.instancingMorph=me.instancingMorph,Fe.skinning=me.skinning,Fe.morphTargets=me.morphTargets,Fe.morphNormals=me.morphNormals,Fe.morphColors=me.morphColors,Fe.morphTargetsCount=me.morphTargetsCount,Fe.numClippingPlanes=me.numClippingPlanes,Fe.numIntersection=me.numClipIntersection,Fe.vertexAlphas=me.vertexAlphas,Fe.vertexTangents=me.vertexTangents,Fe.toneMapping=me.toneMapping}function Ae(he,me,Fe,Oe,je){me.isScene!==!0&&(me=be),Te.resetTextureUnits();const ht=me.fog,Nt=Oe.isMeshStandardMaterial?me.environment:null,Ct=R===null?k.outputColorSpace:R.isXRRenderTarget===!0?R.texture.colorSpace:qg,At=(Oe.isMeshStandardMaterial?L:V).get(Oe.envMap||Nt),Lt=Oe.vertexColors===!0&&!!Fe.attributes.color&&Fe.attributes.color.itemSize===4,Rt=!!Fe.attributes.tangent&&(!!Oe.normalMap||Oe.anisotropy>0),Mt=!!Fe.morphAttributes.position,Zt=!!Fe.morphAttributes.normal,$t=!!Fe.morphAttributes.color;let un=sh;Oe.toneMapped&&(R===null||R.isXRRenderTarget===!0)&&(un=k.toneMapping);const _n=Fe.morphAttributes.position||Fe.morphAttributes.normal||Fe.morphAttributes.color,Mn=_n!==void 0?_n.length:0,Ht=_e.get(Oe),Xt=N.state.lights;if(ye===!0&&(ge===!0||he!==O)){const nn=he===O&&Oe.id===F;Ze.setState(Oe,he,nn)}let tn=!1;Oe.version===Ht.__version?(Ht.needsLights&&Ht.lightsStateVersion!==Xt.state.version||Ht.outputColorSpace!==Ct||je.isBatchedMesh&&Ht.batching===!1||!je.isBatchedMesh&&Ht.batching===!0||je.isBatchedMesh&&Ht.batchingColor===!0&&je.colorTexture===null||je.isBatchedMesh&&Ht.batchingColor===!1&&je.colorTexture!==null||je.isInstancedMesh&&Ht.instancing===!1||!je.isInstancedMesh&&Ht.instancing===!0||je.isSkinnedMesh&&Ht.skinning===!1||!je.isSkinnedMesh&&Ht.skinning===!0||je.isInstancedMesh&&Ht.instancingColor===!0&&je.instanceColor===null||je.isInstancedMesh&&Ht.instancingColor===!1&&je.instanceColor!==null||je.isInstancedMesh&&Ht.instancingMorph===!0&&je.morphTexture===null||je.isInstancedMesh&&Ht.instancingMorph===!1&&je.morphTexture!==null||Ht.envMap!==At||Oe.fog===!0&&Ht.fog!==ht||Ht.numClippingPlanes!==void 0&&(Ht.numClippingPlanes!==Ze.numPlanes||Ht.numIntersection!==Ze.numIntersection)||Ht.vertexAlphas!==Lt||Ht.vertexTangents!==Rt||Ht.morphTargets!==Mt||Ht.morphNormals!==Zt||Ht.morphColors!==$t||Ht.toneMapping!==un||Ht.morphTargetsCount!==Mn)&&(tn=!0):(tn=!0,Ht.__version=Oe.version);let cn=Ht.currentProgram;tn===!0&&(cn=bn(Oe,me,je));let Ur=!1,qn=!1,Qe=!1;const Tt=cn.getUniforms(),qt=Ht.uniforms;if(re.useProgram(cn.program)&&(Ur=!0,qn=!0,Qe=!0),Oe.id!==F&&(F=Oe.id,qn=!0),Ur||O!==he){re.buffers.depth.getReversed()&&he.reversedDepth!==!0&&(he._reversedDepth=!0,he.updateProjectionMatrix()),Tt.setValue(K,"projectionMatrix",he.projectionMatrix),Tt.setValue(K,"viewMatrix",he.matrixWorldInverse);const gn=Tt.map.cameraPosition;gn!==void 0&&gn.setValue(K,Pe.setFromMatrixPosition(he.matrixWorld)),z.logarithmicDepthBuffer&&Tt.setValue(K,"logDepthBufFC",2/(Math.log(he.far+1)/Math.LN2)),(Oe.isMeshPhongMaterial||Oe.isMeshToonMaterial||Oe.isMeshLambertMaterial||Oe.isMeshBasicMaterial||Oe.isMeshStandardMaterial||Oe.isShaderMaterial)&&Tt.setValue(K,"isOrthographic",he.isOrthographicCamera===!0),O!==he&&(O=he,qn=!0,Qe=!0)}if(je.isSkinnedMesh){Tt.setOptional(K,je,"bindMatrix"),Tt.setOptional(K,je,"bindMatrixInverse");const nn=je.skeleton;nn&&(nn.boneTexture===null&&nn.computeBoneTexture(),Tt.setValue(K,"boneTexture",nn.boneTexture,Te))}je.isBatchedMesh&&(Tt.setOptional(K,je,"batchingTexture"),Tt.setValue(K,"batchingTexture",je._matricesTexture,Te),Tt.setOptional(K,je,"batchingIdTexture"),Tt.setValue(K,"batchingIdTexture",je._indirectTexture,Te),Tt.setOptional(K,je,"batchingColorTexture"),je._colorsTexture!==null&&Tt.setValue(K,"batchingColorTexture",je._colorsTexture,Te));const xt=Fe.morphAttributes;if((xt.position!==void 0||xt.normal!==void 0||xt.color!==void 0)&&He.update(je,Fe,cn),(qn||Ht.receiveShadow!==je.receiveShadow)&&(Ht.receiveShadow=je.receiveShadow,Tt.setValue(K,"receiveShadow",je.receiveShadow)),Oe.isMeshGouraudMaterial&&Oe.envMap!==null&&(qt.envMap.value=At,qt.flipEnvMap.value=At.isCubeTexture&&At.isRenderTargetTexture===!1?-1:1),Oe.isMeshStandardMaterial&&Oe.envMap===null&&me.environment!==null&&(qt.envMapIntensity.value=me.environmentIntensity),qt.dfgLUT!==void 0&&(qt.dfgLUT.value=aye()),qn&&(Tt.setValue(K,"toneMappingExposure",k.toneMappingExposure),Ht.needsLights&&Xe(qt,Qe),ht&&Oe.fog===!0&&De.refreshFogUniforms(qt,ht),De.refreshMaterialUniforms(qt,Oe,oe,Z,N.state.transmissionRenderTarget[he.id]),M1.upload(K,xi(Ht),qt,Te)),Oe.isShaderMaterial&&Oe.uniformsNeedUpdate===!0&&(M1.upload(K,xi(Ht),qt,Te),Oe.uniformsNeedUpdate=!1),Oe.isSpriteMaterial&&Tt.setValue(K,"center",je.center),Tt.setValue(K,"modelViewMatrix",je.modelViewMatrix),Tt.setValue(K,"normalMatrix",je.normalMatrix),Tt.setValue(K,"modelMatrix",je.matrixWorld),Oe.isShaderMaterial||Oe.isRawShaderMaterial){const nn=Oe.uniformsGroups;for(let gn=0,tr=nn.length;gn<tr;gn++){const br=nn[gn];tt.update(br,cn),tt.bind(br,cn)}}return cn}function Xe(he,me){he.ambientLightColor.needsUpdate=me,he.lightProbe.needsUpdate=me,he.directionalLights.needsUpdate=me,he.directionalLightShadows.needsUpdate=me,he.pointLights.needsUpdate=me,he.pointLightShadows.needsUpdate=me,he.spotLights.needsUpdate=me,he.spotLightShadows.needsUpdate=me,he.rectAreaLights.needsUpdate=me,he.hemisphereLights.needsUpdate=me}function Je(he){return he.isMeshLambertMaterial||he.isMeshToonMaterial||he.isMeshPhongMaterial||he.isMeshStandardMaterial||he.isShadowMaterial||he.isShaderMaterial&&he.lights===!0}this.getActiveCubeFace=function(){return D},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return R},this.setRenderTargetTextures=function(he,me,Fe){const Oe=_e.get(he);Oe.__autoAllocateDepthBuffer=he.resolveDepthBuffer===!1,Oe.__autoAllocateDepthBuffer===!1&&(Oe.__useRenderToTexture=!1),_e.get(he.texture).__webglTexture=me,_e.get(he.depthTexture).__webglTexture=Oe.__autoAllocateDepthBuffer?void 0:Fe,Oe.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(he,me){const Fe=_e.get(he);Fe.__webglFramebuffer=me,Fe.__useDefaultFramebuffer=me===void 0};const dt=K.createFramebuffer();this.setRenderTarget=function(he,me=0,Fe=0){R=he,D=me,A=Fe;let Oe=!0,je=null,ht=!1,Nt=!1;if(he){const At=_e.get(he);if(At.__useDefaultFramebuffer!==void 0)re.bindFramebuffer(K.FRAMEBUFFER,null),Oe=!1;else if(At.__webglFramebuffer===void 0)Te.setupRenderTarget(he);else if(At.__hasExternalTextures)Te.rebindTextures(he,_e.get(he.texture).__webglTexture,_e.get(he.depthTexture).__webglTexture);else if(he.depthBuffer){const Mt=he.depthTexture;if(At.__boundDepthTexture!==Mt){if(Mt!==null&&_e.has(Mt)&&(he.width!==Mt.image.width||he.height!==Mt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Te.setupDepthRenderbuffer(he)}}const Lt=he.texture;(Lt.isData3DTexture||Lt.isDataArrayTexture||Lt.isCompressedArrayTexture)&&(Nt=!0);const Rt=_e.get(he).__webglFramebuffer;he.isWebGLCubeRenderTarget?(Array.isArray(Rt[me])?je=Rt[me][Fe]:je=Rt[me],ht=!0):he.samples>0&&Te.useMultisampledRTT(he)===!1?je=_e.get(he).__webglMultisampledFramebuffer:Array.isArray(Rt)?je=Rt[Fe]:je=Rt,H.copy(he.viewport),j.copy(he.scissor),G=he.scissorTest}else H.copy(se).multiplyScalar(oe).floor(),j.copy(ne).multiplyScalar(oe).floor(),G=ce;if(Fe!==0&&(je=dt),re.bindFramebuffer(K.FRAMEBUFFER,je)&&Oe&&re.drawBuffers(he,je),re.viewport(H),re.scissor(j),re.setScissorTest(G),ht){const At=_e.get(he.texture);K.framebufferTexture2D(K.FRAMEBUFFER,K.COLOR_ATTACHMENT0,K.TEXTURE_CUBE_MAP_POSITIVE_X+me,At.__webglTexture,Fe)}else if(Nt){const At=me;for(let Lt=0;Lt<he.textures.length;Lt++){const Rt=_e.get(he.textures[Lt]);K.framebufferTextureLayer(K.FRAMEBUFFER,K.COLOR_ATTACHMENT0+Lt,Rt.__webglTexture,Fe,At)}}else if(he!==null&&Fe!==0){const At=_e.get(he.texture);K.framebufferTexture2D(K.FRAMEBUFFER,K.COLOR_ATTACHMENT0,K.TEXTURE_2D,At.__webglTexture,Fe)}F=-1},this.readRenderTargetPixels=function(he,me,Fe,Oe,je,ht,Nt,Ct=0){if(!(he&&he.isWebGLRenderTarget)){_i("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let At=_e.get(he).__webglFramebuffer;if(he.isWebGLCubeRenderTarget&&Nt!==void 0&&(At=At[Nt]),At){re.bindFramebuffer(K.FRAMEBUFFER,At);try{const Lt=he.textures[Ct],Rt=Lt.format,Mt=Lt.type;if(!z.textureFormatReadable(Rt)){_i("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!z.textureTypeReadable(Mt)){_i("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}me>=0&&me<=he.width-Oe&&Fe>=0&&Fe<=he.height-je&&(he.textures.length>1&&K.readBuffer(K.COLOR_ATTACHMENT0+Ct),K.readPixels(me,Fe,Oe,je,ft.convert(Rt),ft.convert(Mt),ht))}finally{const Lt=R!==null?_e.get(R).__webglFramebuffer:null;re.bindFramebuffer(K.FRAMEBUFFER,Lt)}}},this.readRenderTargetPixelsAsync=async function(he,me,Fe,Oe,je,ht,Nt,Ct=0){if(!(he&&he.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let At=_e.get(he).__webglFramebuffer;if(he.isWebGLCubeRenderTarget&&Nt!==void 0&&(At=At[Nt]),At)if(me>=0&&me<=he.width-Oe&&Fe>=0&&Fe<=he.height-je){re.bindFramebuffer(K.FRAMEBUFFER,At);const Lt=he.textures[Ct],Rt=Lt.format,Mt=Lt.type;if(!z.textureFormatReadable(Rt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!z.textureTypeReadable(Mt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Zt=K.createBuffer();K.bindBuffer(K.PIXEL_PACK_BUFFER,Zt),K.bufferData(K.PIXEL_PACK_BUFFER,ht.byteLength,K.STREAM_READ),he.textures.length>1&&K.readBuffer(K.COLOR_ATTACHMENT0+Ct),K.readPixels(me,Fe,Oe,je,ft.convert(Rt),ft.convert(Mt),0);const $t=R!==null?_e.get(R).__webglFramebuffer:null;re.bindFramebuffer(K.FRAMEBUFFER,$t);const un=K.fenceSync(K.SYNC_GPU_COMMANDS_COMPLETE,0);return K.flush(),await Tme(K,un,4),K.bindBuffer(K.PIXEL_PACK_BUFFER,Zt),K.getBufferSubData(K.PIXEL_PACK_BUFFER,0,ht),K.deleteBuffer(Zt),K.deleteSync(un),ht}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(he,me=null,Fe=0){const Oe=Math.pow(2,-Fe),je=Math.floor(he.image.width*Oe),ht=Math.floor(he.image.height*Oe),Nt=me!==null?me.x:0,Ct=me!==null?me.y:0;Te.setTexture2D(he,0),K.copyTexSubImage2D(K.TEXTURE_2D,Fe,0,0,Nt,Ct,je,ht),re.unbindTexture()};const st=K.createFramebuffer(),jt=K.createFramebuffer();this.copyTextureToTexture=function(he,me,Fe=null,Oe=null,je=0,ht=null){ht===null&&(je!==0?(J0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ht=je,je=0):ht=0);let Nt,Ct,At,Lt,Rt,Mt,Zt,$t,un;const _n=he.isCompressedTexture?he.mipmaps[ht]:he.image;if(Fe!==null)Nt=Fe.max.x-Fe.min.x,Ct=Fe.max.y-Fe.min.y,At=Fe.isBox3?Fe.max.z-Fe.min.z:1,Lt=Fe.min.x,Rt=Fe.min.y,Mt=Fe.isBox3?Fe.min.z:0;else{const xt=Math.pow(2,-je);Nt=Math.floor(_n.width*xt),Ct=Math.floor(_n.height*xt),he.isDataArrayTexture?At=_n.depth:he.isData3DTexture?At=Math.floor(_n.depth*xt):At=1,Lt=0,Rt=0,Mt=0}Oe!==null?(Zt=Oe.x,$t=Oe.y,un=Oe.z):(Zt=0,$t=0,un=0);const Mn=ft.convert(me.format),Ht=ft.convert(me.type);let Xt;me.isData3DTexture?(Te.setTexture3D(me,0),Xt=K.TEXTURE_3D):me.isDataArrayTexture||me.isCompressedArrayTexture?(Te.setTexture2DArray(me,0),Xt=K.TEXTURE_2D_ARRAY):(Te.setTexture2D(me,0),Xt=K.TEXTURE_2D),K.pixelStorei(K.UNPACK_FLIP_Y_WEBGL,me.flipY),K.pixelStorei(K.UNPACK_PREMULTIPLY_ALPHA_WEBGL,me.premultiplyAlpha),K.pixelStorei(K.UNPACK_ALIGNMENT,me.unpackAlignment);const tn=K.getParameter(K.UNPACK_ROW_LENGTH),cn=K.getParameter(K.UNPACK_IMAGE_HEIGHT),Ur=K.getParameter(K.UNPACK_SKIP_PIXELS),qn=K.getParameter(K.UNPACK_SKIP_ROWS),Qe=K.getParameter(K.UNPACK_SKIP_IMAGES);K.pixelStorei(K.UNPACK_ROW_LENGTH,_n.width),K.pixelStorei(K.UNPACK_IMAGE_HEIGHT,_n.height),K.pixelStorei(K.UNPACK_SKIP_PIXELS,Lt),K.pixelStorei(K.UNPACK_SKIP_ROWS,Rt),K.pixelStorei(K.UNPACK_SKIP_IMAGES,Mt);const Tt=he.isDataArrayTexture||he.isData3DTexture,qt=me.isDataArrayTexture||me.isData3DTexture;if(he.isDepthTexture){const xt=_e.get(he),nn=_e.get(me),gn=_e.get(xt.__renderTarget),tr=_e.get(nn.__renderTarget);re.bindFramebuffer(K.READ_FRAMEBUFFER,gn.__webglFramebuffer),re.bindFramebuffer(K.DRAW_FRAMEBUFFER,tr.__webglFramebuffer);for(let br=0;br<At;br++)Tt&&(K.framebufferTextureLayer(K.READ_FRAMEBUFFER,K.COLOR_ATTACHMENT0,_e.get(he).__webglTexture,je,Mt+br),K.framebufferTextureLayer(K.DRAW_FRAMEBUFFER,K.COLOR_ATTACHMENT0,_e.get(me).__webglTexture,ht,un+br)),K.blitFramebuffer(Lt,Rt,Nt,Ct,Zt,$t,Nt,Ct,K.DEPTH_BUFFER_BIT,K.NEAREST);re.bindFramebuffer(K.READ_FRAMEBUFFER,null),re.bindFramebuffer(K.DRAW_FRAMEBUFFER,null)}else if(je!==0||he.isRenderTargetTexture||_e.has(he)){const xt=_e.get(he),nn=_e.get(me);re.bindFramebuffer(K.READ_FRAMEBUFFER,st),re.bindFramebuffer(K.DRAW_FRAMEBUFFER,jt);for(let gn=0;gn<At;gn++)Tt?K.framebufferTextureLayer(K.READ_FRAMEBUFFER,K.COLOR_ATTACHMENT0,xt.__webglTexture,je,Mt+gn):K.framebufferTexture2D(K.READ_FRAMEBUFFER,K.COLOR_ATTACHMENT0,K.TEXTURE_2D,xt.__webglTexture,je),qt?K.framebufferTextureLayer(K.DRAW_FRAMEBUFFER,K.COLOR_ATTACHMENT0,nn.__webglTexture,ht,un+gn):K.framebufferTexture2D(K.DRAW_FRAMEBUFFER,K.COLOR_ATTACHMENT0,K.TEXTURE_2D,nn.__webglTexture,ht),je!==0?K.blitFramebuffer(Lt,Rt,Nt,Ct,Zt,$t,Nt,Ct,K.COLOR_BUFFER_BIT,K.NEAREST):qt?K.copyTexSubImage3D(Xt,ht,Zt,$t,un+gn,Lt,Rt,Nt,Ct):K.copyTexSubImage2D(Xt,ht,Zt,$t,Lt,Rt,Nt,Ct);re.bindFramebuffer(K.READ_FRAMEBUFFER,null),re.bindFramebuffer(K.DRAW_FRAMEBUFFER,null)}else qt?he.isDataTexture||he.isData3DTexture?K.texSubImage3D(Xt,ht,Zt,$t,un,Nt,Ct,At,Mn,Ht,_n.data):me.isCompressedArrayTexture?K.compressedTexSubImage3D(Xt,ht,Zt,$t,un,Nt,Ct,At,Mn,_n.data):K.texSubImage3D(Xt,ht,Zt,$t,un,Nt,Ct,At,Mn,Ht,_n):he.isDataTexture?K.texSubImage2D(K.TEXTURE_2D,ht,Zt,$t,Nt,Ct,Mn,Ht,_n.data):he.isCompressedTexture?K.compressedTexSubImage2D(K.TEXTURE_2D,ht,Zt,$t,_n.width,_n.height,Mn,_n.data):K.texSubImage2D(K.TEXTURE_2D,ht,Zt,$t,Nt,Ct,Mn,Ht,_n);K.pixelStorei(K.UNPACK_ROW_LENGTH,tn),K.pixelStorei(K.UNPACK_IMAGE_HEIGHT,cn),K.pixelStorei(K.UNPACK_SKIP_PIXELS,Ur),K.pixelStorei(K.UNPACK_SKIP_ROWS,qn),K.pixelStorei(K.UNPACK_SKIP_IMAGES,Qe),ht===0&&me.generateMipmaps&&K.generateMipmap(Xt),re.unbindTexture()},this.initRenderTarget=function(he){_e.get(he).__webglFramebuffer===void 0&&Te.setupRenderTarget(he)},this.initTexture=function(he){he.isCubeTexture?Te.setTextureCube(he,0):he.isData3DTexture?Te.setTexture3D(he,0):he.isDataArrayTexture||he.isCompressedArrayTexture?Te.setTexture2DArray(he,0):Te.setTexture2D(he,0),re.unbindTexture()},this.resetState=function(){D=0,A=0,R=null,re.reset(),we.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return lc}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=ar._getDrawingBufferColorSpace(e),n.unpackColorSpace=ar._getUnpackColorSpace()}};const WB={type:"change"},n4={type:"start"},EK={type:"end"},rw=new YD,KB=new Fd,oye=Math.cos(70*kme.DEG2RAD),Hi=new lt,Rs=2*Math.PI,Cr={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},IT=1e-6;class lye extends ype{constructor(e,n=null){super(e,n),this.state=Cr.NONE,this.target=new lt,this.cursor=new lt,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:Mg.ROTATE,MIDDLE:Mg.DOLLY,RIGHT:Mg.PAN},this.touches={ONE:mg.ROTATE,TWO:mg.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new lt,this._lastQuaternion=new cm,this._lastTargetPosition=new lt,this._quat=new cm().setFromUnitVectors(e.up,new lt(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new wB,this._sphericalDelta=new wB,this._scale=1,this._panOffset=new lt,this._rotateStart=new An,this._rotateEnd=new An,this._rotateDelta=new An,this._panStart=new An,this._panEnd=new An,this._panDelta=new An,this._dollyStart=new An,this._dollyEnd=new An,this._dollyDelta=new An,this._dollyDirection=new lt,this._mouse=new An,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=uye.bind(this),this._onPointerDown=cye.bind(this),this._onPointerUp=dye.bind(this),this._onContextMenu=bye.bind(this),this._onMouseWheel=mye.bind(this),this._onKeyDown=pye.bind(this),this._onTouchStart=gye.bind(this),this._onTouchMove=xye.bind(this),this._onMouseDown=hye.bind(this),this._onMouseMove=fye.bind(this),this._interceptControlDown=yye.bind(this),this._interceptControlUp=vye.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(WB),this.update(),this.state=Cr.NONE}update(e=null){const n=this.object.position;Hi.copy(n).sub(this.target),Hi.applyQuaternion(this._quat),this._spherical.setFromVector3(Hi),this.autoRotate&&this.state===Cr.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+=Rs:r>Math.PI&&(r-=Rs),i<-Math.PI?i+=Rs:i>Math.PI&&(i-=Rs),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 o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=o!=this._spherical.radius}if(Hi.setFromSpherical(this._spherical),Hi.applyQuaternion(this._quatInverse),n.copy(this.target).add(Hi),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 o=null;if(this.object.isPerspectiveCamera){const l=Hi.length();o=this._clampDistance(l*this._scale);const c=l-o;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),s=!!c}else if(this.object.isOrthographicCamera){const l=new lt(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=c!==this.object.zoom;const u=new lt(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),o=Hi.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(rw.origin.copy(this.object.position),rw.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(rw.direction))<oye?this.object.lookAt(this.target):(KB.setFromNormalAndCoplanarPoint(this.object.up,this.target),rw.intersectPlane(KB,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>IT||8*(1-this._lastQuaternion.dot(this.object.quaternion))>IT||this._lastTargetPosition.distanceToSquared(this.target)>IT?(this.dispatchEvent(WB),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Rs/60*this.autoRotateSpeed*e:Rs/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){Hi.setFromMatrixColumn(n,0),Hi.multiplyScalar(-e),this._panOffset.add(Hi)}_panUp(e,n){this.screenSpacePanning===!0?Hi.setFromMatrixColumn(n,1):(Hi.setFromMatrixColumn(n,0),Hi.crossVectors(this.object.up,Hi)),Hi.multiplyScalar(e),this._panOffset.add(Hi)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Hi.copy(i).sub(this.target);let s=Hi.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,o=r.width,l=r.height;this._mouse.x=i/o*2-1,this._mouse.y=-(s/l)*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(Rs*this._rotateDelta.x/n.clientHeight),this._rotateUp(Rs*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(Rs*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(-Rs*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(Rs*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(-Rs*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(Rs*this._rotateDelta.x/n.clientHeight),this._rotateUp(Rs*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 o=(e.pageX+n.x)*.5,l=(e.pageY+n.y)*.5;this._updateZoomParameters(o,l)}_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 An,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 cye(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 uye(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function dye(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(EK),this.state=Cr.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 hye(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 Mg.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=Cr.DOLLY;break;case Mg.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Cr.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Cr.ROTATE}break;case Mg.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Cr.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Cr.PAN}break;default:this.state=Cr.NONE}this.state!==Cr.NONE&&this.dispatchEvent(n4)}function fye(t){switch(this.state){case Cr.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case Cr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case Cr.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function mye(t){this.enabled===!1||this.enableZoom===!1||this.state!==Cr.NONE||(t.preventDefault(),this.dispatchEvent(n4),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(EK))}function pye(t){this.enabled!==!1&&this._handleKeyDown(t)}function gye(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case mg.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=Cr.TOUCH_ROTATE;break;case mg.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=Cr.TOUCH_PAN;break;default:this.state=Cr.NONE}break;case 2:switch(this.touches.TWO){case mg.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=Cr.TOUCH_DOLLY_PAN;break;case mg.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=Cr.TOUCH_DOLLY_ROTATE;break;default:this.state=Cr.NONE}break;default:this.state=Cr.NONE}this.state!==Cr.NONE&&this.dispatchEvent(n4)}function xye(t){switch(this._trackPointer(t),this.state){case Cr.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case Cr.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case Cr.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case Cr.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=Cr.NONE}}function bye(t){this.enabled!==!1&&t.preventDefault()}function yye(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function vye(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function _ye(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={},o={},l=t[0].morphTargetsRelative,c=new al;let u=0;for(let d=0;d<t.length;++d){const f=t[d];let m=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 p in f.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;s[p]===void 0&&(s[p]=[]),s[p].push(f.attributes[p]),m++}if(m!==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(l!==f.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const p in f.morphAttributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;o[p]===void 0&&(o[p]=[]),o[p].push(f.morphAttributes[p])}if(e){let p;if(n)p=f.index.count;else if(f.attributes.position!==void 0)p=f.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;c.addGroup(u,p,d),u+=p}}if(n){let d=0;const f=[];for(let m=0;m<t.length;++m){const p=t[m].index;for(let x=0;x<p.count;++x)f.push(p.getX(x)+d);d+=t[m].attributes.position.count}c.setIndex(f)}for(const d in s){const f=XB(s[d]);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" attribute."),null;c.setAttribute(d,f)}for(const d in o){const f=o[d][0].length;if(f===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[d]=[];for(let m=0;m<f;++m){const p=[];for(let b=0;b<o[d].length;++b)p.push(o[d][b][m]);const x=XB(p);if(!x)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;c.morphAttributes[d].push(x)}}return c}function XB(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 o=new e(s),l=new bs(o,n,r);let c=0;for(let u=0;u<t.length;++u){const d=t[u];if(d.isInterleavedBufferAttribute){const f=c/n;for(let m=0,p=d.count;m<p;m++)for(let x=0;x<n;x++){const b=d.getComponent(m,x);l.setComponent(m+f,x,b)}}else o.set(d.array,c);c+=d.count*n}return i!==void 0&&(l.gpuType=i),l}class wye extends t4{constructor(e){super(e)}load(e,n,r,i){const s=this,o=new fpe(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){try{n(s.parse(l))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},r,i)}parse(e){function n(u){const d=new DataView(u),f=32/8*3+32/8*3*3+16/8,m=d.getUint32(80,!0);if(80+32/8+m*f===d.byteLength)return!0;const x=[115,111,108,105,100];for(let b=0;b<5;b++)if(r(x,d,b))return!1;return!0}function r(u,d,f){for(let m=0,p=u.length;m<p;m++)if(u[m]!==d.getUint8(f+m))return!1;return!0}function i(u){const d=new DataView(u),f=d.getUint32(80,!0);let m,p,x,b=!1,y,v,S,N,C;for(let F=0;F<70;F++)d.getUint32(F,!1)==1129270351&&d.getUint8(F+4)==82&&d.getUint8(F+5)==61&&(b=!0,y=new Float32Array(f*3*3),v=d.getUint8(F+6)/255,S=d.getUint8(F+7)/255,N=d.getUint8(F+8)/255,C=d.getUint8(F+9)/255);const T=84,k=50,E=new al,D=new Float32Array(f*3*3),A=new Float32Array(f*3*3),R=new Rn;for(let F=0;F<f;F++){const O=T+F*k,H=d.getFloat32(O,!0),j=d.getFloat32(O+4,!0),G=d.getFloat32(O+8,!0);if(b){const $=d.getUint16(O+48,!0);($&32768)===0?(m=($&31)/31,p=($>>5&31)/31,x=($>>10&31)/31):(m=v,p=S,x=N)}for(let $=1;$<=3;$++){const q=O+$*12,Y=F*3*3+($-1)*3;D[Y]=d.getFloat32(q,!0),D[Y+1]=d.getFloat32(q+4,!0),D[Y+2]=d.getFloat32(q+8,!0),A[Y]=H,A[Y+1]=j,A[Y+2]=G,b&&(R.setRGB(m,p,x,so),y[Y]=R.r,y[Y+1]=R.g,y[Y+2]=R.b)}}return E.setAttribute("position",new bs(D,3)),E.setAttribute("normal",new bs(A,3)),b&&(E.setAttribute("color",new bs(y,3)),E.hasColors=!0,E.alpha=C),E}function s(u){const d=new al,f=/solid([\s\S]*?)endsolid/g,m=/facet([\s\S]*?)endfacet/g,p=/solid\s(.+)/;let x=0;const b=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,y=new RegExp("vertex"+b+b+b,"g"),v=new RegExp("normal"+b+b+b,"g"),S=[],N=[],C=[],T=new lt;let k,E=0,D=0,A=0;for(;(k=f.exec(u))!==null;){D=A;const R=k[0],F=(k=p.exec(R))!==null?k[1]:"";for(C.push(F);(k=m.exec(R))!==null;){let j=0,G=0;const $=k[0];for(;(k=v.exec($))!==null;)T.x=parseFloat(k[1]),T.y=parseFloat(k[2]),T.z=parseFloat(k[3]),G++;for(;(k=y.exec($))!==null;)S.push(parseFloat(k[1]),parseFloat(k[2]),parseFloat(k[3])),N.push(T.x,T.y,T.z),j++,A++;G!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+x),j!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+x),x++}const O=D,H=A-D;d.userData.groupNames=C,d.addGroup(O,H,E),E++}return d.setAttribute("position",new po(S,3)),d.setAttribute("normal",new po(N,3)),d}function o(u){return typeof u!="string"?new TextDecoder().decode(u):u}function l(u){if(typeof u=="string"){const d=new Uint8Array(u.length);for(let f=0;f<u.length;f++)d[f]=u.charCodeAt(f)&255;return d.buffer||d}else return u}const c=l(e);return n(c)?i(c):s(o(e))}}function iw(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 FT={exports:{}};var YB;function Sye(){return YB||(YB=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(r,i,s){function o(u,d){if(!i[u]){if(!r[u]){var f=typeof iw=="function"&&iw;if(!d&&f)return f(u,!0);if(l)return l(u,!0);var m=new Error("Cannot find module '"+u+"'");throw m.code="MODULE_NOT_FOUND",m}var p=i[u]={exports:{}};r[u][0].call(p.exports,function(x){var b=r[u][1][x];return o(b||x)},p,p.exports,n,r,i,s)}return i[u].exports}for(var l=typeof iw=="function"&&iw,c=0;c<s.length;c++)o(s[c]);return o})({1:[function(n,r,i){var s=n("./utils"),o=n("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(c){for(var u,d,f,m,p,x,b,y=[],v=0,S=c.length,N=S,C=s.getTypeOf(c)!=="string";v<c.length;)N=S-v,f=C?(u=c[v++],d=v<S?c[v++]:0,v<S?c[v++]:0):(u=c.charCodeAt(v++),d=v<S?c.charCodeAt(v++):0,v<S?c.charCodeAt(v++):0),m=u>>2,p=(3&u)<<4|d>>4,x=1<N?(15&d)<<2|f>>6:64,b=2<N?63&f:64,y.push(l.charAt(m)+l.charAt(p)+l.charAt(x)+l.charAt(b));return y.join("")},i.decode=function(c){var u,d,f,m,p,x,b=0,y=0,v="data:";if(c.substr(0,v.length)===v)throw new Error("Invalid base64 input, it looks like a data url.");var S,N=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===l.charAt(64)&&N--,c.charAt(c.length-2)===l.charAt(64)&&N--,N%1!=0)throw new Error("Invalid base64 input, bad content length.");for(S=o.uint8array?new Uint8Array(0|N):new Array(0|N);b<c.length;)u=l.indexOf(c.charAt(b++))<<2|(m=l.indexOf(c.charAt(b++)))>>4,d=(15&m)<<4|(p=l.indexOf(c.charAt(b++)))>>2,f=(3&p)<<6|(x=l.indexOf(c.charAt(b++))),S[y++]=u,p!==64&&(S[y++]=d),x!==64&&(S[y++]=f);return S}},{"./support":30,"./utils":32}],2:[function(n,r,i){var s=n("./external"),o=n("./stream/DataWorker"),l=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(d,f,m,p,x){this.compressedSize=d,this.uncompressedSize=f,this.crc32=m,this.compression=p,this.compressedContent=x}u.prototype={getContentWorker:function(){var d=new o(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),f=this;return d.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new o(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,m){return d.pipe(new l).pipe(new c("uncompressedSize")).pipe(f.compressWorker(m)).pipe(new c("compressedSize")).withStreamInfo("compression",f)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){var s=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){var s=n("./utils"),o=(function(){for(var l,c=[],u=0;u<256;u++){l=u;for(var d=0;d<8;d++)l=1&l?3988292384^l>>>1:l>>>1;c[u]=l}return c})();r.exports=function(l,c){return l!==void 0&&l.length?s.getTypeOf(l)!=="string"?(function(u,d,f,m){var p=o,x=m+f;u^=-1;for(var b=m;b<x;b++)u=u>>>8^p[255&(u^d[b])];return-1^u})(0|c,l,l.length,0):(function(u,d,f,m){var p=o,x=m+f;u^=-1;for(var b=m;b<x;b++)u=u>>>8^p[255&(u^d.charCodeAt(b))];return-1^u})(0|c,l,l.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",o=n("pako"),l=n("./utils"),c=n("./stream/GenericWorker"),u=s?"uint8array":"array";function d(f,m){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=m,this.meta={}}i.magic="\b\0",l.inherits(d,c),d.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(l.transformTo(u,f.data),!1)},d.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(m){f.push({data:m,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(p,x){var b,y="";for(b=0;b<x;b++)y+=String.fromCharCode(255&p),p>>>=8;return y}function o(p,x,b,y,v,S){var N,C,T=p.file,k=p.compression,E=S!==u.utf8encode,D=l.transformTo("string",S(T.name)),A=l.transformTo("string",u.utf8encode(T.name)),R=T.comment,F=l.transformTo("string",S(R)),O=l.transformTo("string",u.utf8encode(R)),H=A.length!==T.name.length,j=O.length!==R.length,G="",$="",q="",Y=T.dir,Z=T.date,oe={crc32:0,compressedSize:0,uncompressedSize:0};x&&!b||(oe.crc32=p.crc32,oe.compressedSize=p.compressedSize,oe.uncompressedSize=p.uncompressedSize);var B=0;x&&(B|=8),E||!H&&!j||(B|=2048);var W=0,se=0;Y&&(W|=16),v==="UNIX"?(se=798,W|=(function(ce,fe){var ye=ce;return ce||(ye=fe?16893:33204),(65535&ye)<<16})(T.unixPermissions,Y)):(se=20,W|=(function(ce){return 63&(ce||0)})(T.dosPermissions)),N=Z.getUTCHours(),N<<=6,N|=Z.getUTCMinutes(),N<<=5,N|=Z.getUTCSeconds()/2,C=Z.getUTCFullYear()-1980,C<<=4,C|=Z.getUTCMonth()+1,C<<=5,C|=Z.getUTCDate(),H&&($=s(1,1)+s(d(D),4)+A,G+="up"+s($.length,2)+$),j&&(q=s(1,1)+s(d(F),4)+O,G+="uc"+s(q.length,2)+q);var ne="";return ne+=`
  3839. \0`,ne+=s(B,2),ne+=k.magic,ne+=s(N,2),ne+=s(C,2),ne+=s(oe.crc32,4),ne+=s(oe.compressedSize,4),ne+=s(oe.uncompressedSize,4),ne+=s(D.length,2),ne+=s(G.length,2),{fileRecord:f.LOCAL_FILE_HEADER+ne+D+G,dirRecord:f.CENTRAL_FILE_HEADER+s(se,2)+ne+s(F.length,2)+"\0\0\0\0"+s(W,4)+s(y,4)+D+G+F}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function m(p,x,b,y){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=b,this.encodeFileName=y,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(m,c),m.prototype.push=function(p){var x=p.meta.percent||0,b=this.entriesCount,y=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,c.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:b?(x+100*(b-y-1))/b:100}}))},m.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var x=this.streamFiles&&!p.file.dir;if(x){var b=o(p,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:b.fileRecord,meta:{percent:0}})}else this.accumulate=!0},m.prototype.closedSource=function(p){this.accumulate=!1;var x=this.streamFiles&&!p.file.dir,b=o(p,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(b.dirRecord),x)this.push({data:(function(y){return f.DATA_DESCRIPTOR+s(y.crc32,4)+s(y.compressedSize,4)+s(y.uncompressedSize,4)})(p),meta:{percent:100}});else for(this.push({data:b.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},m.prototype.flush=function(){for(var p=this.bytesWritten,x=0;x<this.dirRecords.length;x++)this.push({data:this.dirRecords[x],meta:{percent:100}});var b=this.bytesWritten-p,y=(function(v,S,N,C,T){var k=l.transformTo("string",T(C));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(v,2)+s(v,2)+s(S,4)+s(N,4)+s(k.length,2)+k})(this.dirRecords.length,b,p,this.zipComment,this.encodeFileName);this.push({data:y,meta:{percent:100}})},m.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},m.prototype.registerPrevious=function(p){this._sources.push(p);var x=this;return p.on("data",function(b){x.processChunk(b)}),p.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),p.on("error",function(b){x.error(b)}),this},m.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},m.prototype.error=function(p){var x=this._sources;if(!c.prototype.error.call(this,p))return!1;for(var b=0;b<x.length;b++)try{x[b].error(p)}catch{}return!0},m.prototype.lock=function(){c.prototype.lock.call(this);for(var p=this._sources,x=0;x<p.length;x++)p[x].lock()},r.exports=m},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){var s=n("../compressions"),o=n("./ZipFileWorker");i.generateWorker=function(l,c,u){var d=new o(c.streamFiles,u,c.platform,c.encodeFileName),f=0;try{l.forEach(function(m,p){f++;var x=(function(S,N){var C=S||N,T=s[C];if(!T)throw new Error(C+" is not a valid compression method !");return T})(p.options.compression,c.compression),b=p.options.compressionOptions||c.compressionOptions||{},y=p.dir,v=p.date;p._compressWorker(x,b).withStreamInfo("file",{name:m,dir:y,date:v,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(m){d.error(m)}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 o=new s;for(var l in this)typeof this[l]!="function"&&(o[l]=this[l]);return o}}(s.prototype=n("./object")).loadAsync=n("./load"),s.support=n("./support"),s.defaults=n("./defaults"),s.version="3.10.1",s.loadAsync=function(o,l){return new s().loadAsync(o,l)},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"),o=n("./external"),l=n("./utf8"),c=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function f(m){return new o.Promise(function(p,x){var b=m.decompressed.getContentWorker().pipe(new u);b.on("error",function(y){x(y)}).on("end",function(){b.streamInfo.crc32!==m.decompressed.crc32?x(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}r.exports=function(m,p){var x=this;return p=s.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:l.utf8decode}),d.isNode&&d.isStream(m)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",m,!0,p.optimizedBinaryString,p.base64).then(function(b){var y=new c(p);return y.load(b),y}).then(function(b){var y=[o.Promise.resolve(b)],v=b.files;if(p.checkCRC32)for(var S=0;S<v.length;S++)y.push(f(v[S]));return o.Promise.all(y)}).then(function(b){for(var y=b.shift(),v=y.files,S=0;S<v.length;S++){var N=v[S],C=N.fileNameStr,T=s.resolve(N.fileNameStr);x.file(T,N.decompressed,{binary:!0,optimizedBinaryString:!0,date:N.date,dir:N.dir,comment:N.fileCommentStr.length?N.fileCommentStr:null,unixPermissions:N.unixPermissions,dosPermissions:N.dosPermissions,createFolders:p.createFolders}),N.dir||(x.file(T).unsafeOriginalName=C)}return y.zipComment.length&&(x.comment=y.zipComment),x})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){var s=n("../utils"),o=n("../stream/GenericWorker");function l(c,u){o.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}s.inherits(l,o),l.prototype._bindStream=function(c){var u=this;(this._stream=c).pause(),c.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},l.prototype.pause=function(){return!!o.prototype.pause.call(this)&&(this._stream.pause(),!0)},l.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=l},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,i){var s=n("readable-stream").Readable;function o(l,c,u){s.call(this,c),this._helper=l;var d=this;l.on("data",function(f,m){d.push(f)||d._helper.pause(),u&&u(m)}).on("error",function(f){d.emit("error",f)}).on("end",function(){d.push(null)})}n("../utils").inherits(o,s),o.prototype._read=function(){this._helper.resume()},r.exports=o},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,o);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,o)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var o=new Buffer(s);return o.fill(0),o},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(n,r,i){function s(T,k,E){var D,A=l.getTypeOf(k),R=l.extend(E||{},d);R.date=R.date||new Date,R.compression!==null&&(R.compression=R.compression.toUpperCase()),typeof R.unixPermissions=="string"&&(R.unixPermissions=parseInt(R.unixPermissions,8)),R.unixPermissions&&16384&R.unixPermissions&&(R.dir=!0),R.dosPermissions&&16&R.dosPermissions&&(R.dir=!0),R.dir&&(T=v(T)),R.createFolders&&(D=y(T))&&S.call(this,D,!0);var F=A==="string"&&R.binary===!1&&R.base64===!1;E&&E.binary!==void 0||(R.binary=!F),(k instanceof f&&k.uncompressedSize===0||R.dir||!k||k.length===0)&&(R.base64=!1,R.binary=!0,k="",R.compression="STORE",A="string");var O=null;O=k instanceof f||k instanceof c?k:x.isNode&&x.isStream(k)?new b(T,k):l.prepareContent(T,k,R.binary,R.optimizedBinaryString,R.base64);var H=new m(T,O,R);this.files[T]=H}var o=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),m=n("./zipObject"),p=n("./generate"),x=n("./nodejsUtils"),b=n("./nodejs/NodejsStreamInputAdapter"),y=function(T){T.slice(-1)==="/"&&(T=T.substring(0,T.length-1));var k=T.lastIndexOf("/");return 0<k?T.substring(0,k):""},v=function(T){return T.slice(-1)!=="/"&&(T+="/"),T},S=function(T,k){return k=k!==void 0?k:d.createFolders,T=v(T),this.files[T]||s.call(this,T,null,{dir:!0,createFolders:k}),this.files[T]};function N(T){return Object.prototype.toString.call(T)==="[object RegExp]"}var C={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(T){var k,E,D;for(k in this.files)D=this.files[k],(E=k.slice(this.root.length,k.length))&&k.slice(0,this.root.length)===this.root&&T(E,D)},filter:function(T){var k=[];return this.forEach(function(E,D){T(E,D)&&k.push(D)}),k},file:function(T,k,E){if(arguments.length!==1)return T=this.root+T,s.call(this,T,k,E),this;if(N(T)){var D=T;return this.filter(function(R,F){return!F.dir&&D.test(R)})}var A=this.files[this.root+T];return A&&!A.dir?A:null},folder:function(T){if(!T)return this;if(N(T))return this.filter(function(A,R){return R.dir&&T.test(A)});var k=this.root+T,E=S.call(this,k),D=this.clone();return D.root=E.name,D},remove:function(T){T=this.root+T;var k=this.files[T];if(k||(T.slice(-1)!=="/"&&(T+="/"),k=this.files[T]),k&&!k.dir)delete this.files[T];else for(var E=this.filter(function(A,R){return R.name.slice(0,T.length)===T}),D=0;D<E.length;D++)delete this.files[E[D].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(T){var k,E={};try{if((E=l.extend(T||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=E.type.toLowerCase(),E.compression=E.compression.toUpperCase(),E.type==="binarystring"&&(E.type="string"),!E.type)throw new Error("No output type specified.");l.checkSupport(E.type),E.platform!=="darwin"&&E.platform!=="freebsd"&&E.platform!=="linux"&&E.platform!=="sunos"||(E.platform="UNIX"),E.platform==="win32"&&(E.platform="DOS");var D=E.comment||this.comment||"";k=p.generateWorker(this,E,D)}catch(A){(k=new c("error")).error(A)}return new u(k,E.type||"string",E.mimeType)},generateAsync:function(T,k){return this.generateInternalStream(T).accumulate(k)},generateNodeStream:function(T,k){return(T=T||{}).type||(T.type="nodebuffer"),this.generateInternalStream(T).toNodejsStream(k)}};r.exports=C},{"./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 o(l){s.call(this,l);for(var c=0;c<this.data.length;c++)l[c]=255&l[c]}n("../utils").inherits(o,s),o.prototype.byteAt=function(l){return this.data[this.zero+l]},o.prototype.lastIndexOfSignature=function(l){for(var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),f=l.charCodeAt(3),m=this.length-4;0<=m;--m)if(this.data[m]===c&&this.data[m+1]===u&&this.data[m+2]===d&&this.data[m+3]===f)return m-this.zero;return-1},o.prototype.readAndCheckSignature=function(l){var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),f=l.charCodeAt(3),m=this.readData(4);return c===m[0]&&u===m[1]&&d===m[2]&&f===m[3]},o.prototype.readData=function(l){if(this.checkOffset(l),l===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./DataReader":18}],18:[function(n,r,i){var s=n("../utils");function o(l){this.data=l,this.length=l.length,this.index=0,this.zero=0}o.prototype={checkOffset:function(l){this.checkIndex(this.index+l)},checkIndex:function(l){if(this.length<this.zero+l||l<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+l+"). Corrupted zip ?")},setIndex:function(l){this.checkIndex(l),this.index=l},skip:function(l){this.setIndex(this.index+l)},byteAt:function(){},readInt:function(l){var c,u=0;for(this.checkOffset(l),c=this.index+l-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=l,u},readString:function(l){return s.transformTo("string",this.readData(l))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var l=this.readInt(4);return new Date(Date.UTC(1980+(l>>25&127),(l>>21&15)-1,l>>16&31,l>>11&31,l>>5&63,(31&l)<<1))}},r.exports=o},{"../utils":32}],19:[function(n,r,i){var s=n("./Uint8ArrayReader");function o(l){s.call(this,l)}n("../utils").inherits(o,s),o.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){var s=n("./DataReader");function o(l){s.call(this,l)}n("../utils").inherits(o,s),o.prototype.byteAt=function(l){return this.data.charCodeAt(this.zero+l)},o.prototype.lastIndexOfSignature=function(l){return this.data.lastIndexOf(l)-this.zero},o.prototype.readAndCheckSignature=function(l){return l===this.readData(4)},o.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){var s=n("./ArrayReader");function o(l){s.call(this,l)}n("../utils").inherits(o,s),o.prototype.readData=function(l){if(this.checkOffset(l),l===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){var s=n("../utils"),o=n("../support"),l=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(f){var m=s.getTypeOf(f);return s.checkSupport(m),m!=="string"||o.uint8array?m==="nodebuffer"?new u(f):o.uint8array?new d(s.transformTo("uint8array",f)):new l(s.transformTo("array",f)):new c(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){var s=n("./GenericWorker"),o=n("../utils");function l(c){s.call(this,"ConvertWorker to "+c),this.destType=c}o.inherits(l,s),l.prototype.processChunk=function(c){this.push({data:o.transformTo(this.destType,c.data),meta:c.meta})},r.exports=l},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){var s=n("./GenericWorker"),o=n("../crc32");function l(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(l,s),l.prototype.processChunk=function(c){this.streamInfo.crc32=o(c.data,this.streamInfo.crc32||0),this.push(c)},r.exports=l},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){var s=n("../utils"),o=n("./GenericWorker");function l(c){o.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}s.inherits(l,o),l.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}o.prototype.processChunk.call(this,c)},r.exports=l},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){var s=n("../utils"),o=n("./GenericWorker");function l(c){o.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(d){u.dataIsReady=!0,u.data=d,u.max=d&&d.length||0,u.type=s.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}s.inherits(l,o),l.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},l.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},l.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},l.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,u);break;case"uint8array":c=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":c=this.data.slice(this.index,u)}return this.index=u,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=l},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){function s(o){this.name=o||"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(o){this.emit("data",o)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(o){this.emit("error",o)}return!0},error:function(o){return!this.isFinished&&(this.isPaused?this.generatedError=o:(this.isFinished=!0,this.emit("error",o),this.previous&&this.previous.error(o),this.cleanUp()),!0)},on:function(o,l){return this._listeners[o].push(l),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(o,l){if(this._listeners[o])for(var c=0;c<this._listeners[o].length;c++)this._listeners[o][c].call(this,l)},pipe:function(o){return o.registerPrevious(this)},registerPrevious:function(o){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=o.streamInfo,this.mergeStreamInfo(),this.previous=o;var l=this;return o.on("data",function(c){l.processChunk(c)}),o.on("end",function(){l.end()}),o.on("error",function(c){l.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var o=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),o=!0),this.previous&&this.previous.resume(),!o},flush:function(){},processChunk:function(o){this.push(o)},withStreamInfo:function(o,l){return this.extraStreamInfo[o]=l,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var o in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,o)&&(this.streamInfo[o]=this.extraStreamInfo[o])},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 o="Worker "+this.name;return this.previous?this.previous+" -> "+o:o}},r.exports=s},{}],29:[function(n,r,i){var s=n("../utils"),o=n("./ConvertWorker"),l=n("./GenericWorker"),c=n("../base64"),u=n("../support"),d=n("../external"),f=null;if(u.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function m(x,b){return new d.Promise(function(y,v){var S=[],N=x._internalType,C=x._outputType,T=x._mimeType;x.on("data",function(k,E){S.push(k),b&&b(E)}).on("error",function(k){S=[],v(k)}).on("end",function(){try{var k=(function(E,D,A){switch(E){case"blob":return s.newBlob(s.transformTo("arraybuffer",D),A);case"base64":return c.encode(D);default:return s.transformTo(E,D)}})(C,(function(E,D){var A,R=0,F=null,O=0;for(A=0;A<D.length;A++)O+=D[A].length;switch(E){case"string":return D.join("");case"array":return Array.prototype.concat.apply([],D);case"uint8array":for(F=new Uint8Array(O),A=0;A<D.length;A++)F.set(D[A],R),R+=D[A].length;return F;case"nodebuffer":return Buffer.concat(D);default:throw new Error("concat : unsupported type '"+E+"'")}})(N,S),T);y(k)}catch(E){v(E)}S=[]}).resume()})}function p(x,b,y){var v=b;switch(b){case"blob":case"arraybuffer":v="uint8array";break;case"base64":v="string"}try{this._internalType=v,this._outputType=b,this._mimeType=y,s.checkSupport(v),this._worker=x.pipe(new o(v)),x.lock()}catch(S){this._worker=new l("error"),this._worker.error(S)}}p.prototype={accumulate:function(x){return m(this,x)},on:function(x,b){var y=this;return x==="data"?this._worker.on(x,function(v){b.call(y,v.data,v.meta)}):this._worker.on(x,function(){s.delay(b,arguments,y)}),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=p},{"../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 o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(s),i.blob=o.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"),o=n("./support"),l=n("./nodejsUtils"),c=n("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function f(){c.call(this,"utf-8 decode"),this.leftOver=null}function m(){c.call(this,"utf-8 encode")}i.utf8encode=function(p){return o.nodebuffer?l.newBufferFrom(p,"utf-8"):(function(x){var b,y,v,S,N,C=x.length,T=0;for(S=0;S<C;S++)(64512&(y=x.charCodeAt(S)))==55296&&S+1<C&&(64512&(v=x.charCodeAt(S+1)))==56320&&(y=65536+(y-55296<<10)+(v-56320),S++),T+=y<128?1:y<2048?2:y<65536?3:4;for(b=o.uint8array?new Uint8Array(T):new Array(T),S=N=0;N<T;S++)(64512&(y=x.charCodeAt(S)))==55296&&S+1<C&&(64512&(v=x.charCodeAt(S+1)))==56320&&(y=65536+(y-55296<<10)+(v-56320),S++),y<128?b[N++]=y:(y<2048?b[N++]=192|y>>>6:(y<65536?b[N++]=224|y>>>12:(b[N++]=240|y>>>18,b[N++]=128|y>>>12&63),b[N++]=128|y>>>6&63),b[N++]=128|63&y);return b})(p)},i.utf8decode=function(p){return o.nodebuffer?s.transformTo("nodebuffer",p).toString("utf-8"):(function(x){var b,y,v,S,N=x.length,C=new Array(2*N);for(b=y=0;b<N;)if((v=x[b++])<128)C[y++]=v;else if(4<(S=u[v]))C[y++]=65533,b+=S-1;else{for(v&=S===2?31:S===3?15:7;1<S&&b<N;)v=v<<6|63&x[b++],S--;1<S?C[y++]=65533:v<65536?C[y++]=v:(v-=65536,C[y++]=55296|v>>10&1023,C[y++]=56320|1023&v)}return C.length!==y&&(C.subarray?C=C.subarray(0,y):C.length=y),s.applyFromCharCode(C)})(p=s.transformTo(o.uint8array?"uint8array":"array",p))},s.inherits(f,c),f.prototype.processChunk=function(p){var x=s.transformTo(o.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var b=x;(x=new Uint8Array(b.length+this.leftOver.length)).set(this.leftOver,0),x.set(b,this.leftOver.length)}else x=this.leftOver.concat(x);this.leftOver=null}var y=(function(S,N){var C;for((N=N||S.length)>S.length&&(N=S.length),C=N-1;0<=C&&(192&S[C])==128;)C--;return C<0||C===0?N:C+u[S[C]]>N?C:N})(x),v=x;y!==x.length&&(o.uint8array?(v=x.subarray(0,y),this.leftOver=x.subarray(y,x.length)):(v=x.slice(0,y),this.leftOver=x.slice(y,x.length))),this.push({data:i.utf8decode(v),meta:p.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(m,c),m.prototype.processChunk=function(p){this.push({data:i.utf8encode(p.data),meta:p.meta})},i.Utf8EncodeWorker=m},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,i){var s=n("./support"),o=n("./base64"),l=n("./nodejsUtils"),c=n("./external");function u(b){return b}function d(b,y){for(var v=0;v<b.length;++v)y[v]=255&b.charCodeAt(v);return y}n("setimmediate"),i.newBlob=function(b,y){i.checkSupport("blob");try{return new Blob([b],{type:y})}catch{try{var v=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return v.append(b),v.getBlob(y)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(b,y,v){var S=[],N=0,C=b.length;if(C<=v)return String.fromCharCode.apply(null,b);for(;N<C;)y==="array"||y==="nodebuffer"?S.push(String.fromCharCode.apply(null,b.slice(N,Math.min(N+v,C)))):S.push(String.fromCharCode.apply(null,b.subarray(N,Math.min(N+v,C)))),N+=v;return S.join("")},stringifyByChar:function(b){for(var y="",v=0;v<b.length;v++)y+=String.fromCharCode(b[v]);return y},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,l.allocBuffer(1)).length===1}catch{return!1}})()}};function m(b){var y=65536,v=i.getTypeOf(b),S=!0;if(v==="uint8array"?S=f.applyCanBeUsed.uint8array:v==="nodebuffer"&&(S=f.applyCanBeUsed.nodebuffer),S)for(;1<y;)try{return f.stringifyByChunk(b,v,y)}catch{y=Math.floor(y/2)}return f.stringifyByChar(b)}function p(b,y){for(var v=0;v<b.length;v++)y[v]=b[v];return y}i.applyFromCharCode=m;var x={};x.string={string:u,array:function(b){return d(b,new Array(b.length))},arraybuffer:function(b){return x.string.uint8array(b).buffer},uint8array:function(b){return d(b,new Uint8Array(b.length))},nodebuffer:function(b){return d(b,l.allocBuffer(b.length))}},x.array={string:m,array:u,arraybuffer:function(b){return new Uint8Array(b).buffer},uint8array:function(b){return new Uint8Array(b)},nodebuffer:function(b){return l.newBufferFrom(b)}},x.arraybuffer={string:function(b){return m(new Uint8Array(b))},array:function(b){return p(new Uint8Array(b),new Array(b.byteLength))},arraybuffer:u,uint8array:function(b){return new Uint8Array(b)},nodebuffer:function(b){return l.newBufferFrom(new Uint8Array(b))}},x.uint8array={string:m,array:function(b){return p(b,new Array(b.length))},arraybuffer:function(b){return b.buffer},uint8array:u,nodebuffer:function(b){return l.newBufferFrom(b)}},x.nodebuffer={string:m,array:function(b){return p(b,new Array(b.length))},arraybuffer:function(b){return x.nodebuffer.uint8array(b).buffer},uint8array:function(b){return p(b,new Uint8Array(b.length))},nodebuffer:u},i.transformTo=function(b,y){if(y=y||"",!b)return y;i.checkSupport(b);var v=i.getTypeOf(y);return x[v][b](y)},i.resolve=function(b){for(var y=b.split("/"),v=[],S=0;S<y.length;S++){var N=y[S];N==="."||N===""&&S!==0&&S!==y.length-1||(N===".."?v.pop():v.push(N))}return v.join("/")},i.getTypeOf=function(b){return typeof b=="string"?"string":Object.prototype.toString.call(b)==="[object Array]"?"array":s.nodebuffer&&l.isBuffer(b)?"nodebuffer":s.uint8array&&b instanceof Uint8Array?"uint8array":s.arraybuffer&&b instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(b){if(!s[b.toLowerCase()])throw new Error(b+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(b){var y,v,S="";for(v=0;v<(b||"").length;v++)S+="\\x"+((y=b.charCodeAt(v))<16?"0":"")+y.toString(16).toUpperCase();return S},i.delay=function(b,y,v){setImmediate(function(){b.apply(v||null,y||[])})},i.inherits=function(b,y){function v(){}v.prototype=y.prototype,b.prototype=new v},i.extend=function(){var b,y,v={};for(b=0;b<arguments.length;b++)for(y in arguments[b])Object.prototype.hasOwnProperty.call(arguments[b],y)&&v[y]===void 0&&(v[y]=arguments[b][y]);return v},i.prepareContent=function(b,y,v,S,N){return c.Promise.resolve(y).then(function(C){return s.blob&&(C instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(C))!==-1)&&typeof FileReader<"u"?new c.Promise(function(T,k){var E=new FileReader;E.onload=function(D){T(D.target.result)},E.onerror=function(D){k(D.target.error)},E.readAsArrayBuffer(C)}):C}).then(function(C){var T=i.getTypeOf(C);return T?(T==="arraybuffer"?C=i.transformTo("uint8array",C):T==="string"&&(N?C=o.decode(C):v&&S!==!0&&(C=(function(k){return d(k,s.uint8array?new Uint8Array(k.length):new Array(k.length))})(C))),C):c.Promise.reject(new Error("Can't read the data of '"+b+"'. 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"),o=n("./utils"),l=n("./signature"),c=n("./zipEntry"),u=n("./support");function d(f){this.files=[],this.loadOptions=f}d.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var m=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(m)+", expected "+o.pretty(f)+")")}},isSignature:function(f,m){var p=this.reader.index;this.reader.setIndex(f);var x=this.reader.readString(4)===m;return this.reader.setIndex(p),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),m=u.uint8array?"uint8array":"array",p=o.transformTo(m,f);this.zipComment=this.loadOptions.decodeFileName(p)},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,m,p,x=this.zip64EndOfCentralSize-44;0<x;)f=this.reader.readInt(2),m=this.reader.readInt(4),p=this.reader.readData(m),this.zip64ExtensibleData[f]={id:f,length:m,value:p}},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,m;for(f=0;f<this.files.length;f++)m=this.files[f],this.reader.setIndex(m.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),m.readLocalPart(this.reader),m.handleUTF8(),m.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(l.CENTRAL_FILE_HEADER);)(f=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(l.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,l.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 m=f;if(this.checkSignature(l.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===o.MAX_VALUE_16BITS||this.diskWithCentralDirStart===o.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===o.MAX_VALUE_16BITS||this.centralDirRecords===o.MAX_VALUE_16BITS||this.centralDirSize===o.MAX_VALUE_32BITS||this.centralDirOffset===o.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(l.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(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,l.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(l.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(l.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var p=this.centralDirOffset+this.centralDirSize;this.zip64&&(p+=20,p+=12+this.zip64EndOfCentralSize);var x=m-p;if(0<x)this.isSignature(m,l.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"),o=n("./utils"),l=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),d=n("./compressions"),f=n("./support");function m(p,x){this.options=p,this.loadOptions=x}m.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var x,b;if(p.skip(22),this.fileNameLength=p.readInt(2),b=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(b),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((x=(function(y){for(var v in d)if(Object.prototype.hasOwnProperty.call(d,v)&&d[v].magic===y)return d[v];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new l(this.compressedSize,this.uncompressedSize,this.crc32,x,p.readData(this.compressedSize))},readCentralPart:function(p){this.versionMadeBy=p.readInt(2),p.skip(2),this.bitFlag=p.readInt(2),this.compressionMethod=p.readString(2),this.date=p.readDate(),this.crc32=p.readInt(4),this.compressedSize=p.readInt(4),this.uncompressedSize=p.readInt(4);var x=p.readInt(2);if(this.extraFieldsLength=p.readInt(2),this.fileCommentLength=p.readInt(2),this.diskNumberStart=p.readInt(2),this.internalFileAttributes=p.readInt(2),this.externalFileAttributes=p.readInt(4),this.localHeaderOffset=p.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");p.skip(x),this.readExtraFields(p),this.parseZIP64ExtraField(p),this.fileComment=p.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var p=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=s(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var x,b,y,v=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<v;)x=p.readInt(2),b=p.readInt(2),y=p.readData(b),this.extraFields[x]={id:x,length:b,value:y};p.setIndex(v)},handleUTF8:function(){var p=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 b=o.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(b)}var y=this.findExtraFieldUnicodeComment();if(y!==null)this.fileCommentStr=y;else{var v=o.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(v)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var x=s(p.value);return x.readInt(1)!==1||c(this.fileName)!==x.readInt(4)?null:u.utf8decode(x.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var x=s(p.value);return x.readInt(1)!==1||c(this.fileComment)!==x.readInt(4)?null:u.utf8decode(x.readData(p.length-5))}return null}},r.exports=m},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function s(x,b,y){this.name=x,this.dir=y.dir,this.date=y.date,this.comment=y.comment,this.unixPermissions=y.unixPermissions,this.dosPermissions=y.dosPermissions,this._data=b,this._dataBinary=y.binary,this.options={compression:y.compression,compressionOptions:y.compressionOptions}}var o=n("./stream/StreamHelper"),l=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");s.prototype={internalStream:function(x){var b=null,y="string";try{if(!x)throw new Error("No output type specified.");var v=(y=x.toLowerCase())==="string"||y==="text";y!=="binarystring"&&y!=="text"||(y="string"),b=this._decompressWorker();var S=!this._dataBinary;S&&!v&&(b=b.pipe(new c.Utf8EncodeWorker)),!S&&v&&(b=b.pipe(new c.Utf8DecodeWorker))}catch(N){(b=new d("error")).error(N)}return new o(b,y,"")},async:function(x,b){return this.internalStream(x).accumulate(b)},nodeStream:function(x,b){return this.internalStream(x||"nodebuffer").toNodejsStream(b)},_compressWorker:function(x,b){if(this._data instanceof u&&this._data.compression.magic===x.magic)return this._data.getCompressedWorker();var y=this._decompressWorker();return this._dataBinary||(y=y.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(y,x,b)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new l(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],m=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},p=0;p<f.length;p++)s.prototype[f[p]]=m;r.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(s){var o,l,c=s.MutationObserver||s.WebKitMutationObserver;if(c){var u=0,d=new c(x),f=s.document.createTextNode("");d.observe(f,{characterData:!0}),o=function(){f.data=u=++u%2}}else if(s.setImmediate||s.MessageChannel===void 0)o="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var b=s.document.createElement("script");b.onreadystatechange=function(){x(),b.onreadystatechange=null,b.parentNode.removeChild(b),b=null},s.document.documentElement.appendChild(b)}:function(){setTimeout(x,0)};else{var m=new s.MessageChannel;m.port1.onmessage=x,o=function(){m.port2.postMessage(0)}}var p=[];function x(){var b,y;l=!0;for(var v=p.length;v;){for(y=p,p=[],b=-1;++b<v;)y[b]();v=p.length}l=!1}r.exports=function(b){p.push(b)!==1||l||o()}}).call(this,typeof k_<"u"?k_:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var s=n("immediate");function o(){}var l={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(v){if(typeof v!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,v!==o&&b(this,v)}function m(v,S,N){this.promise=v,typeof S=="function"&&(this.onFulfilled=S,this.callFulfilled=this.otherCallFulfilled),typeof N=="function"&&(this.onRejected=N,this.callRejected=this.otherCallRejected)}function p(v,S,N){s(function(){var C;try{C=S(N)}catch(T){return l.reject(v,T)}C===v?l.reject(v,new TypeError("Cannot resolve promise with itself")):l.resolve(v,C)})}function x(v){var S=v&&v.then;if(v&&(typeof v=="object"||typeof v=="function")&&typeof S=="function")return function(){S.apply(v,arguments)}}function b(v,S){var N=!1;function C(E){N||(N=!0,l.reject(v,E))}function T(E){N||(N=!0,l.resolve(v,E))}var k=y(function(){S(T,C)});k.status==="error"&&C(k.value)}function y(v,S){var N={};try{N.value=v(S),N.status="success"}catch(C){N.status="error",N.value=C}return N}(r.exports=f).prototype.finally=function(v){if(typeof v!="function")return this;var S=this.constructor;return this.then(function(N){return S.resolve(v()).then(function(){return N})},function(N){return S.resolve(v()).then(function(){throw N})})},f.prototype.catch=function(v){return this.then(null,v)},f.prototype.then=function(v,S){if(typeof v!="function"&&this.state===u||typeof S!="function"&&this.state===c)return this;var N=new this.constructor(o);return this.state!==d?p(N,this.state===u?v:S,this.outcome):this.queue.push(new m(N,v,S)),N},m.prototype.callFulfilled=function(v){l.resolve(this.promise,v)},m.prototype.otherCallFulfilled=function(v){p(this.promise,this.onFulfilled,v)},m.prototype.callRejected=function(v){l.reject(this.promise,v)},m.prototype.otherCallRejected=function(v){p(this.promise,this.onRejected,v)},l.resolve=function(v,S){var N=y(x,S);if(N.status==="error")return l.reject(v,N.value);var C=N.value;if(C)b(v,C);else{v.state=u,v.outcome=S;for(var T=-1,k=v.queue.length;++T<k;)v.queue[T].callFulfilled(S)}return v},l.reject=function(v,S){v.state=c,v.outcome=S;for(var N=-1,C=v.queue.length;++N<C;)v.queue[N].callRejected(S);return v},f.resolve=function(v){return v instanceof this?v:l.resolve(new this(o),v)},f.reject=function(v){var S=new this(o);return l.reject(S,v)},f.all=function(v){var S=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var N=v.length,C=!1;if(!N)return this.resolve([]);for(var T=new Array(N),k=0,E=-1,D=new this(o);++E<N;)A(v[E],E);return D;function A(R,F){S.resolve(R).then(function(O){T[F]=O,++k!==N||C||(C=!0,l.resolve(D,T))},function(O){C||(C=!0,l.reject(D,O))})}},f.race=function(v){var S=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var N=v.length,C=!1;if(!N)return this.resolve([]);for(var T=-1,k=new this(o);++T<N;)E=v[T],S.resolve(E).then(function(D){C||(C=!0,l.resolve(k,D))},function(D){C||(C=!0,l.reject(k,D))});var E;return k}},{immediate:36}],38:[function(n,r,i){var s={};(0,n("./lib/utils/common").assign)(s,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){var s=n("./zlib/deflate"),o=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,f=0,m=-1,p=0,x=8;function b(v){if(!(this instanceof b))return new b(v);this.options=o.assign({level:m,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},v||{});var S=this.options;S.raw&&0<S.windowBits?S.windowBits=-S.windowBits:S.gzip&&0<S.windowBits&&S.windowBits<16&&(S.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var N=s.deflateInit2(this.strm,S.level,S.method,S.windowBits,S.memLevel,S.strategy);if(N!==f)throw new Error(c[N]);if(S.header&&s.deflateSetHeader(this.strm,S.header),S.dictionary){var C;if(C=typeof S.dictionary=="string"?l.string2buf(S.dictionary):d.call(S.dictionary)==="[object ArrayBuffer]"?new Uint8Array(S.dictionary):S.dictionary,(N=s.deflateSetDictionary(this.strm,C))!==f)throw new Error(c[N]);this._dict_set=!0}}function y(v,S){var N=new b(S);if(N.push(v,!0),N.err)throw N.msg||c[N.err];return N.result}b.prototype.push=function(v,S){var N,C,T=this.strm,k=this.options.chunkSize;if(this.ended)return!1;C=S===~~S?S:S===!0?4:0,typeof v=="string"?T.input=l.string2buf(v):d.call(v)==="[object ArrayBuffer]"?T.input=new Uint8Array(v):T.input=v,T.next_in=0,T.avail_in=T.input.length;do{if(T.avail_out===0&&(T.output=new o.Buf8(k),T.next_out=0,T.avail_out=k),(N=s.deflate(T,C))!==1&&N!==f)return this.onEnd(N),!(this.ended=!0);T.avail_out!==0&&(T.avail_in!==0||C!==4&&C!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(o.shrinkBuf(T.output,T.next_out))):this.onData(o.shrinkBuf(T.output,T.next_out)))}while((0<T.avail_in||T.avail_out===0)&&N!==1);return C===4?(N=s.deflateEnd(this.strm),this.onEnd(N),this.ended=!0,N===f):C!==2||(this.onEnd(f),!(T.avail_out=0))},b.prototype.onData=function(v){this.chunks.push(v)},b.prototype.onEnd=function(v){v===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=v,this.msg=this.strm.msg},i.Deflate=b,i.deflate=y,i.deflateRaw=function(v,S){return(S=S||{}).raw=!0,y(v,S)},i.gzip=function(v,S){return(S=S||{}).gzip=!0,y(v,S)}},{"./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"),o=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/constants"),u=n("./zlib/messages"),d=n("./zlib/zstream"),f=n("./zlib/gzheader"),m=Object.prototype.toString;function p(b){if(!(this instanceof p))return new p(b);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},b||{});var y=this.options;y.raw&&0<=y.windowBits&&y.windowBits<16&&(y.windowBits=-y.windowBits,y.windowBits===0&&(y.windowBits=-15)),!(0<=y.windowBits&&y.windowBits<16)||b&&b.windowBits||(y.windowBits+=32),15<y.windowBits&&y.windowBits<48&&(15&y.windowBits)==0&&(y.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var v=s.inflateInit2(this.strm,y.windowBits);if(v!==c.Z_OK)throw new Error(u[v]);this.header=new f,s.inflateGetHeader(this.strm,this.header)}function x(b,y){var v=new p(y);if(v.push(b,!0),v.err)throw v.msg||u[v.err];return v.result}p.prototype.push=function(b,y){var v,S,N,C,T,k,E=this.strm,D=this.options.chunkSize,A=this.options.dictionary,R=!1;if(this.ended)return!1;S=y===~~y?y:y===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof b=="string"?E.input=l.binstring2buf(b):m.call(b)==="[object ArrayBuffer]"?E.input=new Uint8Array(b):E.input=b,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new o.Buf8(D),E.next_out=0,E.avail_out=D),(v=s.inflate(E,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&A&&(k=typeof A=="string"?l.string2buf(A):m.call(A)==="[object ArrayBuffer]"?new Uint8Array(A):A,v=s.inflateSetDictionary(this.strm,k)),v===c.Z_BUF_ERROR&&R===!0&&(v=c.Z_OK,R=!1),v!==c.Z_STREAM_END&&v!==c.Z_OK)return this.onEnd(v),!(this.ended=!0);E.next_out&&(E.avail_out!==0&&v!==c.Z_STREAM_END&&(E.avail_in!==0||S!==c.Z_FINISH&&S!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(N=l.utf8border(E.output,E.next_out),C=E.next_out-N,T=l.buf2string(E.output,N),E.next_out=C,E.avail_out=D-C,C&&o.arraySet(E.output,E.output,N,C,0),this.onData(T)):this.onData(o.shrinkBuf(E.output,E.next_out)))),E.avail_in===0&&E.avail_out===0&&(R=!0)}while((0<E.avail_in||E.avail_out===0)&&v!==c.Z_STREAM_END);return v===c.Z_STREAM_END&&(S=c.Z_FINISH),S===c.Z_FINISH?(v=s.inflateEnd(this.strm),this.onEnd(v),this.ended=!0,v===c.Z_OK):S!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(E.avail_out=0))},p.prototype.onData=function(b){this.chunks.push(b)},p.prototype.onEnd=function(b){b===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=b,this.msg=this.strm.msg},i.Inflate=p,i.inflate=x,i.inflateRaw=function(b,y){return(y=y||{}).raw=!0,x(b,y)},i.ungzip=x},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(c[f]=d[f])}}return c},i.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var o={arraySet:function(c,u,d,f,m){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+f),m);else for(var p=0;p<f;p++)c[m+p]=u[d+p]},flattenChunks:function(c){var u,d,f,m,p,x;for(u=f=0,d=c.length;u<d;u++)f+=c[u].length;for(x=new Uint8Array(f),u=m=0,d=c.length;u<d;u++)p=c[u],x.set(p,m),m+=p.length;return x}},l={arraySet:function(c,u,d,f,m){for(var p=0;p<f;p++)c[m+p]=u[d+p]},flattenChunks:function(c){return[].concat.apply([],c)}};i.setTyped=function(c){c?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,o)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,l))},i.setTyped(s)},{}],42:[function(n,r,i){var s=n("./common"),o=!0,l=!0;try{String.fromCharCode.apply(null,[0])}catch{o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{l=!1}for(var c=new s.Buf8(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(f,m){if(m<65537&&(f.subarray&&l||!f.subarray&&o))return String.fromCharCode.apply(null,s.shrinkBuf(f,m));for(var p="",x=0;x<m;x++)p+=String.fromCharCode(f[x]);return p}c[254]=c[254]=1,i.string2buf=function(f){var m,p,x,b,y,v=f.length,S=0;for(b=0;b<v;b++)(64512&(p=f.charCodeAt(b)))==55296&&b+1<v&&(64512&(x=f.charCodeAt(b+1)))==56320&&(p=65536+(p-55296<<10)+(x-56320),b++),S+=p<128?1:p<2048?2:p<65536?3:4;for(m=new s.Buf8(S),b=y=0;y<S;b++)(64512&(p=f.charCodeAt(b)))==55296&&b+1<v&&(64512&(x=f.charCodeAt(b+1)))==56320&&(p=65536+(p-55296<<10)+(x-56320),b++),p<128?m[y++]=p:(p<2048?m[y++]=192|p>>>6:(p<65536?m[y++]=224|p>>>12:(m[y++]=240|p>>>18,m[y++]=128|p>>>12&63),m[y++]=128|p>>>6&63),m[y++]=128|63&p);return m},i.buf2binstring=function(f){return d(f,f.length)},i.binstring2buf=function(f){for(var m=new s.Buf8(f.length),p=0,x=m.length;p<x;p++)m[p]=f.charCodeAt(p);return m},i.buf2string=function(f,m){var p,x,b,y,v=m||f.length,S=new Array(2*v);for(p=x=0;p<v;)if((b=f[p++])<128)S[x++]=b;else if(4<(y=c[b]))S[x++]=65533,p+=y-1;else{for(b&=y===2?31:y===3?15:7;1<y&&p<v;)b=b<<6|63&f[p++],y--;1<y?S[x++]=65533:b<65536?S[x++]=b:(b-=65536,S[x++]=55296|b>>10&1023,S[x++]=56320|1023&b)}return d(S,x)},i.utf8border=function(f,m){var p;for((m=m||f.length)>f.length&&(m=f.length),p=m-1;0<=p&&(192&f[p])==128;)p--;return p<0||p===0?m:p+c[f[p]]>m?p:m}},{"./common":41}],43:[function(n,r,i){r.exports=function(s,o,l,c){for(var u=65535&s|0,d=s>>>16&65535|0,f=0;l!==0;){for(l-=f=2e3<l?2e3:l;d=d+(u=u+o[c++]|0)|0,--f;);u%=65521,d%=65521}return u|d<<16|0}},{}],44:[function(n,r,i){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,i){var s=(function(){for(var o,l=[],c=0;c<256;c++){o=c;for(var u=0;u<8;u++)o=1&o?3988292384^o>>>1:o>>>1;l[c]=o}return l})();r.exports=function(o,l,c,u){var d=s,f=u+c;o^=-1;for(var m=u;m<f;m++)o=o>>>8^d[255&(o^l[m])];return-1^o}},{}],46:[function(n,r,i){var s,o=n("../utils/common"),l=n("./trees"),c=n("./adler32"),u=n("./crc32"),d=n("./messages"),f=0,m=4,p=0,x=-2,b=-1,y=4,v=2,S=8,N=9,C=286,T=30,k=19,E=2*C+1,D=15,A=3,R=258,F=R+A+1,O=42,H=113,j=1,G=2,$=3,q=4;function Y(U,K){return U.msg=d[K],K}function Z(U){return(U<<1)-(4<U?9:0)}function oe(U){for(var K=U.length;0<=--K;)U[K]=0}function B(U){var K=U.state,J=K.pending;J>U.avail_out&&(J=U.avail_out),J!==0&&(o.arraySet(U.output,K.pending_buf,K.pending_out,J,U.next_out),U.next_out+=J,K.pending_out+=J,U.total_out+=J,U.avail_out-=J,K.pending-=J,K.pending===0&&(K.pending_out=0))}function W(U,K){l._tr_flush_block(U,0<=U.block_start?U.block_start:-1,U.strstart-U.block_start,K),U.block_start=U.strstart,B(U.strm)}function se(U,K){U.pending_buf[U.pending++]=K}function ne(U,K){U.pending_buf[U.pending++]=K>>>8&255,U.pending_buf[U.pending++]=255&K}function ce(U,K){var J,Q,z=U.max_chain_length,re=U.strstart,Ee=U.prev_length,_e=U.nice_match,Te=U.strstart>U.w_size-F?U.strstart-(U.w_size-F):0,V=U.window,L=U.w_mask,X=U.prev,te=U.strstart+R,Me=V[re+Ee-1],ie=V[re+Ee];U.prev_length>=U.good_match&&(z>>=2),_e>U.lookahead&&(_e=U.lookahead);do if(V[(J=K)+Ee]===ie&&V[J+Ee-1]===Me&&V[J]===V[re]&&V[++J]===V[re+1]){re+=2,J++;do;while(V[++re]===V[++J]&&V[++re]===V[++J]&&V[++re]===V[++J]&&V[++re]===V[++J]&&V[++re]===V[++J]&&V[++re]===V[++J]&&V[++re]===V[++J]&&V[++re]===V[++J]&&re<te);if(Q=R-(te-re),re=te-R,Ee<Q){if(U.match_start=K,_e<=(Ee=Q))break;Me=V[re+Ee-1],ie=V[re+Ee]}}while((K=X[K&L])>Te&&--z!=0);return Ee<=U.lookahead?Ee:U.lookahead}function fe(U){var K,J,Q,z,re,Ee,_e,Te,V,L,X=U.w_size;do{if(z=U.window_size-U.lookahead-U.strstart,U.strstart>=X+(X-F)){for(o.arraySet(U.window,U.window,X,X,0),U.match_start-=X,U.strstart-=X,U.block_start-=X,K=J=U.hash_size;Q=U.head[--K],U.head[K]=X<=Q?Q-X:0,--J;);for(K=J=X;Q=U.prev[--K],U.prev[K]=X<=Q?Q-X:0,--J;);z+=X}if(U.strm.avail_in===0)break;if(Ee=U.strm,_e=U.window,Te=U.strstart+U.lookahead,V=z,L=void 0,L=Ee.avail_in,V<L&&(L=V),J=L===0?0:(Ee.avail_in-=L,o.arraySet(_e,Ee.input,Ee.next_in,L,Te),Ee.state.wrap===1?Ee.adler=c(Ee.adler,_e,L,Te):Ee.state.wrap===2&&(Ee.adler=u(Ee.adler,_e,L,Te)),Ee.next_in+=L,Ee.total_in+=L,L),U.lookahead+=J,U.lookahead+U.insert>=A)for(re=U.strstart-U.insert,U.ins_h=U.window[re],U.ins_h=(U.ins_h<<U.hash_shift^U.window[re+1])&U.hash_mask;U.insert&&(U.ins_h=(U.ins_h<<U.hash_shift^U.window[re+A-1])&U.hash_mask,U.prev[re&U.w_mask]=U.head[U.ins_h],U.head[U.ins_h]=re,re++,U.insert--,!(U.lookahead+U.insert<A)););}while(U.lookahead<F&&U.strm.avail_in!==0)}function ye(U,K){for(var J,Q;;){if(U.lookahead<F){if(fe(U),U.lookahead<F&&K===f)return j;if(U.lookahead===0)break}if(J=0,U.lookahead>=A&&(U.ins_h=(U.ins_h<<U.hash_shift^U.window[U.strstart+A-1])&U.hash_mask,J=U.prev[U.strstart&U.w_mask]=U.head[U.ins_h],U.head[U.ins_h]=U.strstart),J!==0&&U.strstart-J<=U.w_size-F&&(U.match_length=ce(U,J)),U.match_length>=A)if(Q=l._tr_tally(U,U.strstart-U.match_start,U.match_length-A),U.lookahead-=U.match_length,U.match_length<=U.max_lazy_match&&U.lookahead>=A){for(U.match_length--;U.strstart++,U.ins_h=(U.ins_h<<U.hash_shift^U.window[U.strstart+A-1])&U.hash_mask,J=U.prev[U.strstart&U.w_mask]=U.head[U.ins_h],U.head[U.ins_h]=U.strstart,--U.match_length!=0;);U.strstart++}else U.strstart+=U.match_length,U.match_length=0,U.ins_h=U.window[U.strstart],U.ins_h=(U.ins_h<<U.hash_shift^U.window[U.strstart+1])&U.hash_mask;else Q=l._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++;if(Q&&(W(U,!1),U.strm.avail_out===0))return j}return U.insert=U.strstart<A-1?U.strstart:A-1,K===m?(W(U,!0),U.strm.avail_out===0?$:q):U.last_lit&&(W(U,!1),U.strm.avail_out===0)?j:G}function ge(U,K){for(var J,Q,z;;){if(U.lookahead<F){if(fe(U),U.lookahead<F&&K===f)return j;if(U.lookahead===0)break}if(J=0,U.lookahead>=A&&(U.ins_h=(U.ins_h<<U.hash_shift^U.window[U.strstart+A-1])&U.hash_mask,J=U.prev[U.strstart&U.w_mask]=U.head[U.ins_h],U.head[U.ins_h]=U.strstart),U.prev_length=U.match_length,U.prev_match=U.match_start,U.match_length=A-1,J!==0&&U.prev_length<U.max_lazy_match&&U.strstart-J<=U.w_size-F&&(U.match_length=ce(U,J),U.match_length<=5&&(U.strategy===1||U.match_length===A&&4096<U.strstart-U.match_start)&&(U.match_length=A-1)),U.prev_length>=A&&U.match_length<=U.prev_length){for(z=U.strstart+U.lookahead-A,Q=l._tr_tally(U,U.strstart-1-U.prev_match,U.prev_length-A),U.lookahead-=U.prev_length-1,U.prev_length-=2;++U.strstart<=z&&(U.ins_h=(U.ins_h<<U.hash_shift^U.window[U.strstart+A-1])&U.hash_mask,J=U.prev[U.strstart&U.w_mask]=U.head[U.ins_h],U.head[U.ins_h]=U.strstart),--U.prev_length!=0;);if(U.match_available=0,U.match_length=A-1,U.strstart++,Q&&(W(U,!1),U.strm.avail_out===0))return j}else if(U.match_available){if((Q=l._tr_tally(U,0,U.window[U.strstart-1]))&&W(U,!1),U.strstart++,U.lookahead--,U.strm.avail_out===0)return j}else U.match_available=1,U.strstart++,U.lookahead--}return U.match_available&&(Q=l._tr_tally(U,0,U.window[U.strstart-1]),U.match_available=0),U.insert=U.strstart<A-1?U.strstart:A-1,K===m?(W(U,!0),U.strm.avail_out===0?$:q):U.last_lit&&(W(U,!1),U.strm.avail_out===0)?j:G}function xe(U,K,J,Q,z){this.good_length=U,this.max_lazy=K,this.nice_length=J,this.max_chain=Q,this.func=z}function Pe(){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=S,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 o.Buf16(2*E),this.dyn_dtree=new o.Buf16(2*(2*T+1)),this.bl_tree=new o.Buf16(2*(2*k+1)),oe(this.dyn_ltree),oe(this.dyn_dtree),oe(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(D+1),this.heap=new o.Buf16(2*C+1),oe(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*C+1),oe(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 Ue(U){var K;return U&&U.state?(U.total_in=U.total_out=0,U.data_type=v,(K=U.state).pending=0,K.pending_out=0,K.wrap<0&&(K.wrap=-K.wrap),K.status=K.wrap?O:H,U.adler=K.wrap===2?0:1,K.last_flush=f,l._tr_init(K),p):Y(U,x)}function be(U){var K=Ue(U);return K===p&&(function(J){J.window_size=2*J.w_size,oe(J.head),J.max_lazy_match=s[J.level].max_lazy,J.good_match=s[J.level].good_length,J.nice_match=s[J.level].nice_length,J.max_chain_length=s[J.level].max_chain,J.strstart=0,J.block_start=0,J.lookahead=0,J.insert=0,J.match_length=J.prev_length=A-1,J.match_available=0,J.ins_h=0})(U.state),K}function it(U,K,J,Q,z,re){if(!U)return x;var Ee=1;if(K===b&&(K=6),Q<0?(Ee=0,Q=-Q):15<Q&&(Ee=2,Q-=16),z<1||N<z||J!==S||Q<8||15<Q||K<0||9<K||re<0||y<re)return Y(U,x);Q===8&&(Q=9);var _e=new Pe;return(U.state=_e).strm=U,_e.wrap=Ee,_e.gzhead=null,_e.w_bits=Q,_e.w_size=1<<_e.w_bits,_e.w_mask=_e.w_size-1,_e.hash_bits=z+7,_e.hash_size=1<<_e.hash_bits,_e.hash_mask=_e.hash_size-1,_e.hash_shift=~~((_e.hash_bits+A-1)/A),_e.window=new o.Buf8(2*_e.w_size),_e.head=new o.Buf16(_e.hash_size),_e.prev=new o.Buf16(_e.w_size),_e.lit_bufsize=1<<z+6,_e.pending_buf_size=4*_e.lit_bufsize,_e.pending_buf=new o.Buf8(_e.pending_buf_size),_e.d_buf=1*_e.lit_bufsize,_e.l_buf=3*_e.lit_bufsize,_e.level=K,_e.strategy=re,_e.method=J,be(U)}s=[new xe(0,0,0,0,function(U,K){var J=65535;for(J>U.pending_buf_size-5&&(J=U.pending_buf_size-5);;){if(U.lookahead<=1){if(fe(U),U.lookahead===0&&K===f)return j;if(U.lookahead===0)break}U.strstart+=U.lookahead,U.lookahead=0;var Q=U.block_start+J;if((U.strstart===0||U.strstart>=Q)&&(U.lookahead=U.strstart-Q,U.strstart=Q,W(U,!1),U.strm.avail_out===0)||U.strstart-U.block_start>=U.w_size-F&&(W(U,!1),U.strm.avail_out===0))return j}return U.insert=0,K===m?(W(U,!0),U.strm.avail_out===0?$:q):(U.strstart>U.block_start&&(W(U,!1),U.strm.avail_out),j)}),new xe(4,4,8,4,ye),new xe(4,5,16,8,ye),new xe(4,6,32,32,ye),new xe(4,4,16,16,ge),new xe(8,16,32,32,ge),new xe(8,16,128,128,ge),new xe(8,32,128,256,ge),new xe(32,128,258,1024,ge),new xe(32,258,258,4096,ge)],i.deflateInit=function(U,K){return it(U,K,S,15,8,0)},i.deflateInit2=it,i.deflateReset=be,i.deflateResetKeep=Ue,i.deflateSetHeader=function(U,K){return U&&U.state?U.state.wrap!==2?x:(U.state.gzhead=K,p):x},i.deflate=function(U,K){var J,Q,z,re;if(!U||!U.state||5<K||K<0)return U?Y(U,x):x;if(Q=U.state,!U.output||!U.input&&U.avail_in!==0||Q.status===666&&K!==m)return Y(U,U.avail_out===0?-5:x);if(Q.strm=U,J=Q.last_flush,Q.last_flush=K,Q.status===O)if(Q.wrap===2)U.adler=0,se(Q,31),se(Q,139),se(Q,8),Q.gzhead?(se(Q,(Q.gzhead.text?1:0)+(Q.gzhead.hcrc?2:0)+(Q.gzhead.extra?4:0)+(Q.gzhead.name?8:0)+(Q.gzhead.comment?16:0)),se(Q,255&Q.gzhead.time),se(Q,Q.gzhead.time>>8&255),se(Q,Q.gzhead.time>>16&255),se(Q,Q.gzhead.time>>24&255),se(Q,Q.level===9?2:2<=Q.strategy||Q.level<2?4:0),se(Q,255&Q.gzhead.os),Q.gzhead.extra&&Q.gzhead.extra.length&&(se(Q,255&Q.gzhead.extra.length),se(Q,Q.gzhead.extra.length>>8&255)),Q.gzhead.hcrc&&(U.adler=u(U.adler,Q.pending_buf,Q.pending,0)),Q.gzindex=0,Q.status=69):(se(Q,0),se(Q,0),se(Q,0),se(Q,0),se(Q,0),se(Q,Q.level===9?2:2<=Q.strategy||Q.level<2?4:0),se(Q,3),Q.status=H);else{var Ee=S+(Q.w_bits-8<<4)<<8;Ee|=(2<=Q.strategy||Q.level<2?0:Q.level<6?1:Q.level===6?2:3)<<6,Q.strstart!==0&&(Ee|=32),Ee+=31-Ee%31,Q.status=H,ne(Q,Ee),Q.strstart!==0&&(ne(Q,U.adler>>>16),ne(Q,65535&U.adler)),U.adler=1}if(Q.status===69)if(Q.gzhead.extra){for(z=Q.pending;Q.gzindex<(65535&Q.gzhead.extra.length)&&(Q.pending!==Q.pending_buf_size||(Q.gzhead.hcrc&&Q.pending>z&&(U.adler=u(U.adler,Q.pending_buf,Q.pending-z,z)),B(U),z=Q.pending,Q.pending!==Q.pending_buf_size));)se(Q,255&Q.gzhead.extra[Q.gzindex]),Q.gzindex++;Q.gzhead.hcrc&&Q.pending>z&&(U.adler=u(U.adler,Q.pending_buf,Q.pending-z,z)),Q.gzindex===Q.gzhead.extra.length&&(Q.gzindex=0,Q.status=73)}else Q.status=73;if(Q.status===73)if(Q.gzhead.name){z=Q.pending;do{if(Q.pending===Q.pending_buf_size&&(Q.gzhead.hcrc&&Q.pending>z&&(U.adler=u(U.adler,Q.pending_buf,Q.pending-z,z)),B(U),z=Q.pending,Q.pending===Q.pending_buf_size)){re=1;break}re=Q.gzindex<Q.gzhead.name.length?255&Q.gzhead.name.charCodeAt(Q.gzindex++):0,se(Q,re)}while(re!==0);Q.gzhead.hcrc&&Q.pending>z&&(U.adler=u(U.adler,Q.pending_buf,Q.pending-z,z)),re===0&&(Q.gzindex=0,Q.status=91)}else Q.status=91;if(Q.status===91)if(Q.gzhead.comment){z=Q.pending;do{if(Q.pending===Q.pending_buf_size&&(Q.gzhead.hcrc&&Q.pending>z&&(U.adler=u(U.adler,Q.pending_buf,Q.pending-z,z)),B(U),z=Q.pending,Q.pending===Q.pending_buf_size)){re=1;break}re=Q.gzindex<Q.gzhead.comment.length?255&Q.gzhead.comment.charCodeAt(Q.gzindex++):0,se(Q,re)}while(re!==0);Q.gzhead.hcrc&&Q.pending>z&&(U.adler=u(U.adler,Q.pending_buf,Q.pending-z,z)),re===0&&(Q.status=103)}else Q.status=103;if(Q.status===103&&(Q.gzhead.hcrc?(Q.pending+2>Q.pending_buf_size&&B(U),Q.pending+2<=Q.pending_buf_size&&(se(Q,255&U.adler),se(Q,U.adler>>8&255),U.adler=0,Q.status=H)):Q.status=H),Q.pending!==0){if(B(U),U.avail_out===0)return Q.last_flush=-1,p}else if(U.avail_in===0&&Z(K)<=Z(J)&&K!==m)return Y(U,-5);if(Q.status===666&&U.avail_in!==0)return Y(U,-5);if(U.avail_in!==0||Q.lookahead!==0||K!==f&&Q.status!==666){var _e=Q.strategy===2?(function(Te,V){for(var L;;){if(Te.lookahead===0&&(fe(Te),Te.lookahead===0)){if(V===f)return j;break}if(Te.match_length=0,L=l._tr_tally(Te,0,Te.window[Te.strstart]),Te.lookahead--,Te.strstart++,L&&(W(Te,!1),Te.strm.avail_out===0))return j}return Te.insert=0,V===m?(W(Te,!0),Te.strm.avail_out===0?$:q):Te.last_lit&&(W(Te,!1),Te.strm.avail_out===0)?j:G})(Q,K):Q.strategy===3?(function(Te,V){for(var L,X,te,Me,ie=Te.window;;){if(Te.lookahead<=R){if(fe(Te),Te.lookahead<=R&&V===f)return j;if(Te.lookahead===0)break}if(Te.match_length=0,Te.lookahead>=A&&0<Te.strstart&&(X=ie[te=Te.strstart-1])===ie[++te]&&X===ie[++te]&&X===ie[++te]){Me=Te.strstart+R;do;while(X===ie[++te]&&X===ie[++te]&&X===ie[++te]&&X===ie[++te]&&X===ie[++te]&&X===ie[++te]&&X===ie[++te]&&X===ie[++te]&&te<Me);Te.match_length=R-(Me-te),Te.match_length>Te.lookahead&&(Te.match_length=Te.lookahead)}if(Te.match_length>=A?(L=l._tr_tally(Te,1,Te.match_length-A),Te.lookahead-=Te.match_length,Te.strstart+=Te.match_length,Te.match_length=0):(L=l._tr_tally(Te,0,Te.window[Te.strstart]),Te.lookahead--,Te.strstart++),L&&(W(Te,!1),Te.strm.avail_out===0))return j}return Te.insert=0,V===m?(W(Te,!0),Te.strm.avail_out===0?$:q):Te.last_lit&&(W(Te,!1),Te.strm.avail_out===0)?j:G})(Q,K):s[Q.level].func(Q,K);if(_e!==$&&_e!==q||(Q.status=666),_e===j||_e===$)return U.avail_out===0&&(Q.last_flush=-1),p;if(_e===G&&(K===1?l._tr_align(Q):K!==5&&(l._tr_stored_block(Q,0,0,!1),K===3&&(oe(Q.head),Q.lookahead===0&&(Q.strstart=0,Q.block_start=0,Q.insert=0))),B(U),U.avail_out===0))return Q.last_flush=-1,p}return K!==m?p:Q.wrap<=0?1:(Q.wrap===2?(se(Q,255&U.adler),se(Q,U.adler>>8&255),se(Q,U.adler>>16&255),se(Q,U.adler>>24&255),se(Q,255&U.total_in),se(Q,U.total_in>>8&255),se(Q,U.total_in>>16&255),se(Q,U.total_in>>24&255)):(ne(Q,U.adler>>>16),ne(Q,65535&U.adler)),B(U),0<Q.wrap&&(Q.wrap=-Q.wrap),Q.pending!==0?p:1)},i.deflateEnd=function(U){var K;return U&&U.state?(K=U.state.status)!==O&&K!==69&&K!==73&&K!==91&&K!==103&&K!==H&&K!==666?Y(U,x):(U.state=null,K===H?Y(U,-3):p):x},i.deflateSetDictionary=function(U,K){var J,Q,z,re,Ee,_e,Te,V,L=K.length;if(!U||!U.state||(re=(J=U.state).wrap)===2||re===1&&J.status!==O||J.lookahead)return x;for(re===1&&(U.adler=c(U.adler,K,L,0)),J.wrap=0,L>=J.w_size&&(re===0&&(oe(J.head),J.strstart=0,J.block_start=0,J.insert=0),V=new o.Buf8(J.w_size),o.arraySet(V,K,L-J.w_size,J.w_size,0),K=V,L=J.w_size),Ee=U.avail_in,_e=U.next_in,Te=U.input,U.avail_in=L,U.next_in=0,U.input=K,fe(J);J.lookahead>=A;){for(Q=J.strstart,z=J.lookahead-(A-1);J.ins_h=(J.ins_h<<J.hash_shift^J.window[Q+A-1])&J.hash_mask,J.prev[Q&J.w_mask]=J.head[J.ins_h],J.head[J.ins_h]=Q,Q++,--z;);J.strstart=Q,J.lookahead=A-1,fe(J)}return J.strstart+=J.lookahead,J.block_start=J.strstart,J.insert=J.lookahead,J.lookahead=0,J.match_length=J.prev_length=A-1,J.match_available=0,U.next_in=_e,U.input=Te,U.avail_in=Ee,J.wrap=re,p},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,o){var l,c,u,d,f,m,p,x,b,y,v,S,N,C,T,k,E,D,A,R,F,O,H,j,G;l=s.state,c=s.next_in,j=s.input,u=c+(s.avail_in-5),d=s.next_out,G=s.output,f=d-(o-s.avail_out),m=d+(s.avail_out-257),p=l.dmax,x=l.wsize,b=l.whave,y=l.wnext,v=l.window,S=l.hold,N=l.bits,C=l.lencode,T=l.distcode,k=(1<<l.lenbits)-1,E=(1<<l.distbits)-1;e:do{N<15&&(S+=j[c++]<<N,N+=8,S+=j[c++]<<N,N+=8),D=C[S&k];t:for(;;){if(S>>>=A=D>>>24,N-=A,(A=D>>>16&255)===0)G[d++]=65535&D;else{if(!(16&A)){if((64&A)==0){D=C[(65535&D)+(S&(1<<A)-1)];continue t}if(32&A){l.mode=12;break e}s.msg="invalid literal/length code",l.mode=30;break e}R=65535&D,(A&=15)&&(N<A&&(S+=j[c++]<<N,N+=8),R+=S&(1<<A)-1,S>>>=A,N-=A),N<15&&(S+=j[c++]<<N,N+=8,S+=j[c++]<<N,N+=8),D=T[S&E];n:for(;;){if(S>>>=A=D>>>24,N-=A,!(16&(A=D>>>16&255))){if((64&A)==0){D=T[(65535&D)+(S&(1<<A)-1)];continue n}s.msg="invalid distance code",l.mode=30;break e}if(F=65535&D,N<(A&=15)&&(S+=j[c++]<<N,(N+=8)<A&&(S+=j[c++]<<N,N+=8)),p<(F+=S&(1<<A)-1)){s.msg="invalid distance too far back",l.mode=30;break e}if(S>>>=A,N-=A,(A=d-f)<F){if(b<(A=F-A)&&l.sane){s.msg="invalid distance too far back",l.mode=30;break e}if(H=v,(O=0)===y){if(O+=x-A,A<R){for(R-=A;G[d++]=v[O++],--A;);O=d-F,H=G}}else if(y<A){if(O+=x+y-A,(A-=y)<R){for(R-=A;G[d++]=v[O++],--A;);if(O=0,y<R){for(R-=A=y;G[d++]=v[O++],--A;);O=d-F,H=G}}}else if(O+=y-A,A<R){for(R-=A;G[d++]=v[O++],--A;);O=d-F,H=G}for(;2<R;)G[d++]=H[O++],G[d++]=H[O++],G[d++]=H[O++],R-=3;R&&(G[d++]=H[O++],1<R&&(G[d++]=H[O++]))}else{for(O=d-F;G[d++]=G[O++],G[d++]=G[O++],G[d++]=G[O++],2<(R-=3););R&&(G[d++]=G[O++],1<R&&(G[d++]=G[O++]))}break}}break}}while(c<u&&d<m);c-=R=N>>3,S&=(1<<(N-=R<<3))-1,s.next_in=c,s.next_out=d,s.avail_in=c<u?u-c+5:5-(c-u),s.avail_out=d<m?m-d+257:257-(d-m),l.hold=S,l.bits=N}},{}],49:[function(n,r,i){var s=n("../utils/common"),o=n("./adler32"),l=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),d=1,f=2,m=0,p=-2,x=1,b=852,y=592;function v(O){return(O>>>24&255)+(O>>>8&65280)+((65280&O)<<8)+((255&O)<<24)}function S(){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 N(O){var H;return O&&O.state?(H=O.state,O.total_in=O.total_out=H.total=0,O.msg="",H.wrap&&(O.adler=1&H.wrap),H.mode=x,H.last=0,H.havedict=0,H.dmax=32768,H.head=null,H.hold=0,H.bits=0,H.lencode=H.lendyn=new s.Buf32(b),H.distcode=H.distdyn=new s.Buf32(y),H.sane=1,H.back=-1,m):p}function C(O){var H;return O&&O.state?((H=O.state).wsize=0,H.whave=0,H.wnext=0,N(O)):p}function T(O,H){var j,G;return O&&O.state?(G=O.state,H<0?(j=0,H=-H):(j=1+(H>>4),H<48&&(H&=15)),H&&(H<8||15<H)?p:(G.window!==null&&G.wbits!==H&&(G.window=null),G.wrap=j,G.wbits=H,C(O))):p}function k(O,H){var j,G;return O?(G=new S,(O.state=G).window=null,(j=T(O,H))!==m&&(O.state=null),j):p}var E,D,A=!0;function R(O){if(A){var H;for(E=new s.Buf32(512),D=new s.Buf32(32),H=0;H<144;)O.lens[H++]=8;for(;H<256;)O.lens[H++]=9;for(;H<280;)O.lens[H++]=7;for(;H<288;)O.lens[H++]=8;for(u(d,O.lens,0,288,E,0,O.work,{bits:9}),H=0;H<32;)O.lens[H++]=5;u(f,O.lens,0,32,D,0,O.work,{bits:5}),A=!1}O.lencode=E,O.lenbits=9,O.distcode=D,O.distbits=5}function F(O,H,j,G){var $,q=O.state;return q.window===null&&(q.wsize=1<<q.wbits,q.wnext=0,q.whave=0,q.window=new s.Buf8(q.wsize)),G>=q.wsize?(s.arraySet(q.window,H,j-q.wsize,q.wsize,0),q.wnext=0,q.whave=q.wsize):(G<($=q.wsize-q.wnext)&&($=G),s.arraySet(q.window,H,j-G,$,q.wnext),(G-=$)?(s.arraySet(q.window,H,j-G,G,0),q.wnext=G,q.whave=q.wsize):(q.wnext+=$,q.wnext===q.wsize&&(q.wnext=0),q.whave<q.wsize&&(q.whave+=$))),0}i.inflateReset=C,i.inflateReset2=T,i.inflateResetKeep=N,i.inflateInit=function(O){return k(O,15)},i.inflateInit2=k,i.inflate=function(O,H){var j,G,$,q,Y,Z,oe,B,W,se,ne,ce,fe,ye,ge,xe,Pe,Ue,be,it,U,K,J,Q,z=0,re=new s.Buf8(4),Ee=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!O||!O.state||!O.output||!O.input&&O.avail_in!==0)return p;(j=O.state).mode===12&&(j.mode=13),Y=O.next_out,$=O.output,oe=O.avail_out,q=O.next_in,G=O.input,Z=O.avail_in,B=j.hold,W=j.bits,se=Z,ne=oe,K=m;e:for(;;)switch(j.mode){case x:if(j.wrap===0){j.mode=13;break}for(;W<16;){if(Z===0)break e;Z--,B+=G[q++]<<W,W+=8}if(2&j.wrap&&B===35615){re[j.check=0]=255&B,re[1]=B>>>8&255,j.check=l(j.check,re,2,0),W=B=0,j.mode=2;break}if(j.flags=0,j.head&&(j.head.done=!1),!(1&j.wrap)||(((255&B)<<8)+(B>>8))%31){O.msg="incorrect header check",j.mode=30;break}if((15&B)!=8){O.msg="unknown compression method",j.mode=30;break}if(W-=4,U=8+(15&(B>>>=4)),j.wbits===0)j.wbits=U;else if(U>j.wbits){O.msg="invalid window size",j.mode=30;break}j.dmax=1<<U,O.adler=j.check=1,j.mode=512&B?10:12,W=B=0;break;case 2:for(;W<16;){if(Z===0)break e;Z--,B+=G[q++]<<W,W+=8}if(j.flags=B,(255&j.flags)!=8){O.msg="unknown compression method",j.mode=30;break}if(57344&j.flags){O.msg="unknown header flags set",j.mode=30;break}j.head&&(j.head.text=B>>8&1),512&j.flags&&(re[0]=255&B,re[1]=B>>>8&255,j.check=l(j.check,re,2,0)),W=B=0,j.mode=3;case 3:for(;W<32;){if(Z===0)break e;Z--,B+=G[q++]<<W,W+=8}j.head&&(j.head.time=B),512&j.flags&&(re[0]=255&B,re[1]=B>>>8&255,re[2]=B>>>16&255,re[3]=B>>>24&255,j.check=l(j.check,re,4,0)),W=B=0,j.mode=4;case 4:for(;W<16;){if(Z===0)break e;Z--,B+=G[q++]<<W,W+=8}j.head&&(j.head.xflags=255&B,j.head.os=B>>8),512&j.flags&&(re[0]=255&B,re[1]=B>>>8&255,j.check=l(j.check,re,2,0)),W=B=0,j.mode=5;case 5:if(1024&j.flags){for(;W<16;){if(Z===0)break e;Z--,B+=G[q++]<<W,W+=8}j.length=B,j.head&&(j.head.extra_len=B),512&j.flags&&(re[0]=255&B,re[1]=B>>>8&255,j.check=l(j.check,re,2,0)),W=B=0}else j.head&&(j.head.extra=null);j.mode=6;case 6:if(1024&j.flags&&(Z<(ce=j.length)&&(ce=Z),ce&&(j.head&&(U=j.head.extra_len-j.length,j.head.extra||(j.head.extra=new Array(j.head.extra_len)),s.arraySet(j.head.extra,G,q,ce,U)),512&j.flags&&(j.check=l(j.check,G,ce,q)),Z-=ce,q+=ce,j.length-=ce),j.length))break e;j.length=0,j.mode=7;case 7:if(2048&j.flags){if(Z===0)break e;for(ce=0;U=G[q+ce++],j.head&&U&&j.length<65536&&(j.head.name+=String.fromCharCode(U)),U&&ce<Z;);if(512&j.flags&&(j.check=l(j.check,G,ce,q)),Z-=ce,q+=ce,U)break e}else j.head&&(j.head.name=null);j.length=0,j.mode=8;case 8:if(4096&j.flags){if(Z===0)break e;for(ce=0;U=G[q+ce++],j.head&&U&&j.length<65536&&(j.head.comment+=String.fromCharCode(U)),U&&ce<Z;);if(512&j.flags&&(j.check=l(j.check,G,ce,q)),Z-=ce,q+=ce,U)break e}else j.head&&(j.head.comment=null);j.mode=9;case 9:if(512&j.flags){for(;W<16;){if(Z===0)break e;Z--,B+=G[q++]<<W,W+=8}if(B!==(65535&j.check)){O.msg="header crc mismatch",j.mode=30;break}W=B=0}j.head&&(j.head.hcrc=j.flags>>9&1,j.head.done=!0),O.adler=j.check=0,j.mode=12;break;case 10:for(;W<32;){if(Z===0)break e;Z--,B+=G[q++]<<W,W+=8}O.adler=j.check=v(B),W=B=0,j.mode=11;case 11:if(j.havedict===0)return O.next_out=Y,O.avail_out=oe,O.next_in=q,O.avail_in=Z,j.hold=B,j.bits=W,2;O.adler=j.check=1,j.mode=12;case 12:if(H===5||H===6)break e;case 13:if(j.last){B>>>=7&W,W-=7&W,j.mode=27;break}for(;W<3;){if(Z===0)break e;Z--,B+=G[q++]<<W,W+=8}switch(j.last=1&B,W-=1,3&(B>>>=1)){case 0:j.mode=14;break;case 1:if(R(j),j.mode=20,H!==6)break;B>>>=2,W-=2;break e;case 2:j.mode=17;break;case 3:O.msg="invalid block type",j.mode=30}B>>>=2,W-=2;break;case 14:for(B>>>=7&W,W-=7&W;W<32;){if(Z===0)break e;Z--,B+=G[q++]<<W,W+=8}if((65535&B)!=(B>>>16^65535)){O.msg="invalid stored block lengths",j.mode=30;break}if(j.length=65535&B,W=B=0,j.mode=15,H===6)break e;case 15:j.mode=16;case 16:if(ce=j.length){if(Z<ce&&(ce=Z),oe<ce&&(ce=oe),ce===0)break e;s.arraySet($,G,q,ce,Y),Z-=ce,q+=ce,oe-=ce,Y+=ce,j.length-=ce;break}j.mode=12;break;case 17:for(;W<14;){if(Z===0)break e;Z--,B+=G[q++]<<W,W+=8}if(j.nlen=257+(31&B),B>>>=5,W-=5,j.ndist=1+(31&B),B>>>=5,W-=5,j.ncode=4+(15&B),B>>>=4,W-=4,286<j.nlen||30<j.ndist){O.msg="too many length or distance symbols",j.mode=30;break}j.have=0,j.mode=18;case 18:for(;j.have<j.ncode;){for(;W<3;){if(Z===0)break e;Z--,B+=G[q++]<<W,W+=8}j.lens[Ee[j.have++]]=7&B,B>>>=3,W-=3}for(;j.have<19;)j.lens[Ee[j.have++]]=0;if(j.lencode=j.lendyn,j.lenbits=7,J={bits:j.lenbits},K=u(0,j.lens,0,19,j.lencode,0,j.work,J),j.lenbits=J.bits,K){O.msg="invalid code lengths set",j.mode=30;break}j.have=0,j.mode=19;case 19:for(;j.have<j.nlen+j.ndist;){for(;xe=(z=j.lencode[B&(1<<j.lenbits)-1])>>>16&255,Pe=65535&z,!((ge=z>>>24)<=W);){if(Z===0)break e;Z--,B+=G[q++]<<W,W+=8}if(Pe<16)B>>>=ge,W-=ge,j.lens[j.have++]=Pe;else{if(Pe===16){for(Q=ge+2;W<Q;){if(Z===0)break e;Z--,B+=G[q++]<<W,W+=8}if(B>>>=ge,W-=ge,j.have===0){O.msg="invalid bit length repeat",j.mode=30;break}U=j.lens[j.have-1],ce=3+(3&B),B>>>=2,W-=2}else if(Pe===17){for(Q=ge+3;W<Q;){if(Z===0)break e;Z--,B+=G[q++]<<W,W+=8}W-=ge,U=0,ce=3+(7&(B>>>=ge)),B>>>=3,W-=3}else{for(Q=ge+7;W<Q;){if(Z===0)break e;Z--,B+=G[q++]<<W,W+=8}W-=ge,U=0,ce=11+(127&(B>>>=ge)),B>>>=7,W-=7}if(j.have+ce>j.nlen+j.ndist){O.msg="invalid bit length repeat",j.mode=30;break}for(;ce--;)j.lens[j.have++]=U}}if(j.mode===30)break;if(j.lens[256]===0){O.msg="invalid code -- missing end-of-block",j.mode=30;break}if(j.lenbits=9,J={bits:j.lenbits},K=u(d,j.lens,0,j.nlen,j.lencode,0,j.work,J),j.lenbits=J.bits,K){O.msg="invalid literal/lengths set",j.mode=30;break}if(j.distbits=6,j.distcode=j.distdyn,J={bits:j.distbits},K=u(f,j.lens,j.nlen,j.ndist,j.distcode,0,j.work,J),j.distbits=J.bits,K){O.msg="invalid distances set",j.mode=30;break}if(j.mode=20,H===6)break e;case 20:j.mode=21;case 21:if(6<=Z&&258<=oe){O.next_out=Y,O.avail_out=oe,O.next_in=q,O.avail_in=Z,j.hold=B,j.bits=W,c(O,ne),Y=O.next_out,$=O.output,oe=O.avail_out,q=O.next_in,G=O.input,Z=O.avail_in,B=j.hold,W=j.bits,j.mode===12&&(j.back=-1);break}for(j.back=0;xe=(z=j.lencode[B&(1<<j.lenbits)-1])>>>16&255,Pe=65535&z,!((ge=z>>>24)<=W);){if(Z===0)break e;Z--,B+=G[q++]<<W,W+=8}if(xe&&(240&xe)==0){for(Ue=ge,be=xe,it=Pe;xe=(z=j.lencode[it+((B&(1<<Ue+be)-1)>>Ue)])>>>16&255,Pe=65535&z,!(Ue+(ge=z>>>24)<=W);){if(Z===0)break e;Z--,B+=G[q++]<<W,W+=8}B>>>=Ue,W-=Ue,j.back+=Ue}if(B>>>=ge,W-=ge,j.back+=ge,j.length=Pe,xe===0){j.mode=26;break}if(32&xe){j.back=-1,j.mode=12;break}if(64&xe){O.msg="invalid literal/length code",j.mode=30;break}j.extra=15&xe,j.mode=22;case 22:if(j.extra){for(Q=j.extra;W<Q;){if(Z===0)break e;Z--,B+=G[q++]<<W,W+=8}j.length+=B&(1<<j.extra)-1,B>>>=j.extra,W-=j.extra,j.back+=j.extra}j.was=j.length,j.mode=23;case 23:for(;xe=(z=j.distcode[B&(1<<j.distbits)-1])>>>16&255,Pe=65535&z,!((ge=z>>>24)<=W);){if(Z===0)break e;Z--,B+=G[q++]<<W,W+=8}if((240&xe)==0){for(Ue=ge,be=xe,it=Pe;xe=(z=j.distcode[it+((B&(1<<Ue+be)-1)>>Ue)])>>>16&255,Pe=65535&z,!(Ue+(ge=z>>>24)<=W);){if(Z===0)break e;Z--,B+=G[q++]<<W,W+=8}B>>>=Ue,W-=Ue,j.back+=Ue}if(B>>>=ge,W-=ge,j.back+=ge,64&xe){O.msg="invalid distance code",j.mode=30;break}j.offset=Pe,j.extra=15&xe,j.mode=24;case 24:if(j.extra){for(Q=j.extra;W<Q;){if(Z===0)break e;Z--,B+=G[q++]<<W,W+=8}j.offset+=B&(1<<j.extra)-1,B>>>=j.extra,W-=j.extra,j.back+=j.extra}if(j.offset>j.dmax){O.msg="invalid distance too far back",j.mode=30;break}j.mode=25;case 25:if(oe===0)break e;if(ce=ne-oe,j.offset>ce){if((ce=j.offset-ce)>j.whave&&j.sane){O.msg="invalid distance too far back",j.mode=30;break}fe=ce>j.wnext?(ce-=j.wnext,j.wsize-ce):j.wnext-ce,ce>j.length&&(ce=j.length),ye=j.window}else ye=$,fe=Y-j.offset,ce=j.length;for(oe<ce&&(ce=oe),oe-=ce,j.length-=ce;$[Y++]=ye[fe++],--ce;);j.length===0&&(j.mode=21);break;case 26:if(oe===0)break e;$[Y++]=j.length,oe--,j.mode=21;break;case 27:if(j.wrap){for(;W<32;){if(Z===0)break e;Z--,B|=G[q++]<<W,W+=8}if(ne-=oe,O.total_out+=ne,j.total+=ne,ne&&(O.adler=j.check=j.flags?l(j.check,$,ne,Y-ne):o(j.check,$,ne,Y-ne)),ne=oe,(j.flags?B:v(B))!==j.check){O.msg="incorrect data check",j.mode=30;break}W=B=0}j.mode=28;case 28:if(j.wrap&&j.flags){for(;W<32;){if(Z===0)break e;Z--,B+=G[q++]<<W,W+=8}if(B!==(4294967295&j.total)){O.msg="incorrect length check",j.mode=30;break}W=B=0}j.mode=29;case 29:K=1;break e;case 30:K=-3;break e;case 31:return-4;case 32:default:return p}return O.next_out=Y,O.avail_out=oe,O.next_in=q,O.avail_in=Z,j.hold=B,j.bits=W,(j.wsize||ne!==O.avail_out&&j.mode<30&&(j.mode<27||H!==4))&&F(O,O.output,O.next_out,ne-O.avail_out)?(j.mode=31,-4):(se-=O.avail_in,ne-=O.avail_out,O.total_in+=se,O.total_out+=ne,j.total+=ne,j.wrap&&ne&&(O.adler=j.check=j.flags?l(j.check,$,ne,O.next_out-ne):o(j.check,$,ne,O.next_out-ne)),O.data_type=j.bits+(j.last?64:0)+(j.mode===12?128:0)+(j.mode===20||j.mode===15?256:0),(se==0&&ne===0||H===4)&&K===m&&(K=-5),K)},i.inflateEnd=function(O){if(!O||!O.state)return p;var H=O.state;return H.window&&(H.window=null),O.state=null,m},i.inflateGetHeader=function(O,H){var j;return O&&O.state?(2&(j=O.state).wrap)==0?p:((j.head=H).done=!1,m):p},i.inflateSetDictionary=function(O,H){var j,G=H.length;return O&&O.state?(j=O.state).wrap!==0&&j.mode!==11?p:j.mode===11&&o(1,H,G,0)!==j.check?-3:F(O,H,G,G)?(j.mode=31,-4):(j.havedict=1,m):p},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"),o=[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],l=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(d,f,m,p,x,b,y,v){var S,N,C,T,k,E,D,A,R,F=v.bits,O=0,H=0,j=0,G=0,$=0,q=0,Y=0,Z=0,oe=0,B=0,W=null,se=0,ne=new s.Buf16(16),ce=new s.Buf16(16),fe=null,ye=0;for(O=0;O<=15;O++)ne[O]=0;for(H=0;H<p;H++)ne[f[m+H]]++;for($=F,G=15;1<=G&&ne[G]===0;G--);if(G<$&&($=G),G===0)return x[b++]=20971520,x[b++]=20971520,v.bits=1,0;for(j=1;j<G&&ne[j]===0;j++);for($<j&&($=j),O=Z=1;O<=15;O++)if(Z<<=1,(Z-=ne[O])<0)return-1;if(0<Z&&(d===0||G!==1))return-1;for(ce[1]=0,O=1;O<15;O++)ce[O+1]=ce[O]+ne[O];for(H=0;H<p;H++)f[m+H]!==0&&(y[ce[f[m+H]]++]=H);if(E=d===0?(W=fe=y,19):d===1?(W=o,se-=257,fe=l,ye-=257,256):(W=c,fe=u,-1),O=j,k=b,Y=H=B=0,C=-1,T=(oe=1<<(q=$))-1,d===1&&852<oe||d===2&&592<oe)return 1;for(;;){for(D=O-Y,R=y[H]<E?(A=0,y[H]):y[H]>E?(A=fe[ye+y[H]],W[se+y[H]]):(A=96,0),S=1<<O-Y,j=N=1<<q;x[k+(B>>Y)+(N-=S)]=D<<24|A<<16|R|0,N!==0;);for(S=1<<O-1;B&S;)S>>=1;if(S!==0?(B&=S-1,B+=S):B=0,H++,--ne[O]==0){if(O===G)break;O=f[m+y[H]]}if($<O&&(B&T)!==C){for(Y===0&&(Y=$),k+=j,Z=1<<(q=O-Y);q+Y<G&&!((Z-=ne[q+Y])<=0);)q++,Z<<=1;if(oe+=1<<q,d===1&&852<oe||d===2&&592<oe)return 1;x[C=B&T]=$<<24|q<<16|k-b|0}}return B!==0&&(x[k+B]=O-Y<<24|64<<16|0),v.bits=$,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"),o=0,l=1;function c(z){for(var re=z.length;0<=--re;)z[re]=0}var u=0,d=29,f=256,m=f+1+d,p=30,x=19,b=2*m+1,y=15,v=16,S=7,N=256,C=16,T=17,k=18,E=[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],D=[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],A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],R=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],F=new Array(2*(m+2));c(F);var O=new Array(2*p);c(O);var H=new Array(512);c(H);var j=new Array(256);c(j);var G=new Array(d);c(G);var $,q,Y,Z=new Array(p);function oe(z,re,Ee,_e,Te){this.static_tree=z,this.extra_bits=re,this.extra_base=Ee,this.elems=_e,this.max_length=Te,this.has_stree=z&&z.length}function B(z,re){this.dyn_tree=z,this.max_code=0,this.stat_desc=re}function W(z){return z<256?H[z]:H[256+(z>>>7)]}function se(z,re){z.pending_buf[z.pending++]=255&re,z.pending_buf[z.pending++]=re>>>8&255}function ne(z,re,Ee){z.bi_valid>v-Ee?(z.bi_buf|=re<<z.bi_valid&65535,se(z,z.bi_buf),z.bi_buf=re>>v-z.bi_valid,z.bi_valid+=Ee-v):(z.bi_buf|=re<<z.bi_valid&65535,z.bi_valid+=Ee)}function ce(z,re,Ee){ne(z,Ee[2*re],Ee[2*re+1])}function fe(z,re){for(var Ee=0;Ee|=1&z,z>>>=1,Ee<<=1,0<--re;);return Ee>>>1}function ye(z,re,Ee){var _e,Te,V=new Array(y+1),L=0;for(_e=1;_e<=y;_e++)V[_e]=L=L+Ee[_e-1]<<1;for(Te=0;Te<=re;Te++){var X=z[2*Te+1];X!==0&&(z[2*Te]=fe(V[X]++,X))}}function ge(z){var re;for(re=0;re<m;re++)z.dyn_ltree[2*re]=0;for(re=0;re<p;re++)z.dyn_dtree[2*re]=0;for(re=0;re<x;re++)z.bl_tree[2*re]=0;z.dyn_ltree[2*N]=1,z.opt_len=z.static_len=0,z.last_lit=z.matches=0}function xe(z){8<z.bi_valid?se(z,z.bi_buf):0<z.bi_valid&&(z.pending_buf[z.pending++]=z.bi_buf),z.bi_buf=0,z.bi_valid=0}function Pe(z,re,Ee,_e){var Te=2*re,V=2*Ee;return z[Te]<z[V]||z[Te]===z[V]&&_e[re]<=_e[Ee]}function Ue(z,re,Ee){for(var _e=z.heap[Ee],Te=Ee<<1;Te<=z.heap_len&&(Te<z.heap_len&&Pe(re,z.heap[Te+1],z.heap[Te],z.depth)&&Te++,!Pe(re,_e,z.heap[Te],z.depth));)z.heap[Ee]=z.heap[Te],Ee=Te,Te<<=1;z.heap[Ee]=_e}function be(z,re,Ee){var _e,Te,V,L,X=0;if(z.last_lit!==0)for(;_e=z.pending_buf[z.d_buf+2*X]<<8|z.pending_buf[z.d_buf+2*X+1],Te=z.pending_buf[z.l_buf+X],X++,_e===0?ce(z,Te,re):(ce(z,(V=j[Te])+f+1,re),(L=E[V])!==0&&ne(z,Te-=G[V],L),ce(z,V=W(--_e),Ee),(L=D[V])!==0&&ne(z,_e-=Z[V],L)),X<z.last_lit;);ce(z,N,re)}function it(z,re){var Ee,_e,Te,V=re.dyn_tree,L=re.stat_desc.static_tree,X=re.stat_desc.has_stree,te=re.stat_desc.elems,Me=-1;for(z.heap_len=0,z.heap_max=b,Ee=0;Ee<te;Ee++)V[2*Ee]!==0?(z.heap[++z.heap_len]=Me=Ee,z.depth[Ee]=0):V[2*Ee+1]=0;for(;z.heap_len<2;)V[2*(Te=z.heap[++z.heap_len]=Me<2?++Me:0)]=1,z.depth[Te]=0,z.opt_len--,X&&(z.static_len-=L[2*Te+1]);for(re.max_code=Me,Ee=z.heap_len>>1;1<=Ee;Ee--)Ue(z,V,Ee);for(Te=te;Ee=z.heap[1],z.heap[1]=z.heap[z.heap_len--],Ue(z,V,1),_e=z.heap[1],z.heap[--z.heap_max]=Ee,z.heap[--z.heap_max]=_e,V[2*Te]=V[2*Ee]+V[2*_e],z.depth[Te]=(z.depth[Ee]>=z.depth[_e]?z.depth[Ee]:z.depth[_e])+1,V[2*Ee+1]=V[2*_e+1]=Te,z.heap[1]=Te++,Ue(z,V,1),2<=z.heap_len;);z.heap[--z.heap_max]=z.heap[1],(function(ie,De){var Le,$e,Ze,Ie,ae,He,Se=De.dyn_tree,Be=De.max_code,ft=De.stat_desc.static_tree,we=De.stat_desc.has_stree,tt=De.stat_desc.extra_bits,ke=De.stat_desc.extra_base,We=De.stat_desc.max_length,pe=0;for(Ie=0;Ie<=y;Ie++)ie.bl_count[Ie]=0;for(Se[2*ie.heap[ie.heap_max]+1]=0,Le=ie.heap_max+1;Le<b;Le++)We<(Ie=Se[2*Se[2*($e=ie.heap[Le])+1]+1]+1)&&(Ie=We,pe++),Se[2*$e+1]=Ie,Be<$e||(ie.bl_count[Ie]++,ae=0,ke<=$e&&(ae=tt[$e-ke]),He=Se[2*$e],ie.opt_len+=He*(Ie+ae),we&&(ie.static_len+=He*(ft[2*$e+1]+ae)));if(pe!==0){do{for(Ie=We-1;ie.bl_count[Ie]===0;)Ie--;ie.bl_count[Ie]--,ie.bl_count[Ie+1]+=2,ie.bl_count[We]--,pe-=2}while(0<pe);for(Ie=We;Ie!==0;Ie--)for($e=ie.bl_count[Ie];$e!==0;)Be<(Ze=ie.heap[--Le])||(Se[2*Ze+1]!==Ie&&(ie.opt_len+=(Ie-Se[2*Ze+1])*Se[2*Ze],Se[2*Ze+1]=Ie),$e--)}})(z,re),ye(V,Me,z.bl_count)}function U(z,re,Ee){var _e,Te,V=-1,L=re[1],X=0,te=7,Me=4;for(L===0&&(te=138,Me=3),re[2*(Ee+1)+1]=65535,_e=0;_e<=Ee;_e++)Te=L,L=re[2*(_e+1)+1],++X<te&&Te===L||(X<Me?z.bl_tree[2*Te]+=X:Te!==0?(Te!==V&&z.bl_tree[2*Te]++,z.bl_tree[2*C]++):X<=10?z.bl_tree[2*T]++:z.bl_tree[2*k]++,V=Te,Me=(X=0)===L?(te=138,3):Te===L?(te=6,3):(te=7,4))}function K(z,re,Ee){var _e,Te,V=-1,L=re[1],X=0,te=7,Me=4;for(L===0&&(te=138,Me=3),_e=0;_e<=Ee;_e++)if(Te=L,L=re[2*(_e+1)+1],!(++X<te&&Te===L)){if(X<Me)for(;ce(z,Te,z.bl_tree),--X!=0;);else Te!==0?(Te!==V&&(ce(z,Te,z.bl_tree),X--),ce(z,C,z.bl_tree),ne(z,X-3,2)):X<=10?(ce(z,T,z.bl_tree),ne(z,X-3,3)):(ce(z,k,z.bl_tree),ne(z,X-11,7));V=Te,Me=(X=0)===L?(te=138,3):Te===L?(te=6,3):(te=7,4)}}c(Z);var J=!1;function Q(z,re,Ee,_e){ne(z,(u<<1)+(_e?1:0),3),(function(Te,V,L,X){xe(Te),se(Te,L),se(Te,~L),s.arraySet(Te.pending_buf,Te.window,V,L,Te.pending),Te.pending+=L})(z,re,Ee)}i._tr_init=function(z){J||((function(){var re,Ee,_e,Te,V,L=new Array(y+1);for(Te=_e=0;Te<d-1;Te++)for(G[Te]=_e,re=0;re<1<<E[Te];re++)j[_e++]=Te;for(j[_e-1]=Te,Te=V=0;Te<16;Te++)for(Z[Te]=V,re=0;re<1<<D[Te];re++)H[V++]=Te;for(V>>=7;Te<p;Te++)for(Z[Te]=V<<7,re=0;re<1<<D[Te]-7;re++)H[256+V++]=Te;for(Ee=0;Ee<=y;Ee++)L[Ee]=0;for(re=0;re<=143;)F[2*re+1]=8,re++,L[8]++;for(;re<=255;)F[2*re+1]=9,re++,L[9]++;for(;re<=279;)F[2*re+1]=7,re++,L[7]++;for(;re<=287;)F[2*re+1]=8,re++,L[8]++;for(ye(F,m+1,L),re=0;re<p;re++)O[2*re+1]=5,O[2*re]=fe(re,5);$=new oe(F,E,f+1,m,y),q=new oe(O,D,0,p,y),Y=new oe(new Array(0),A,0,x,S)})(),J=!0),z.l_desc=new B(z.dyn_ltree,$),z.d_desc=new B(z.dyn_dtree,q),z.bl_desc=new B(z.bl_tree,Y),z.bi_buf=0,z.bi_valid=0,ge(z)},i._tr_stored_block=Q,i._tr_flush_block=function(z,re,Ee,_e){var Te,V,L=0;0<z.level?(z.strm.data_type===2&&(z.strm.data_type=(function(X){var te,Me=4093624447;for(te=0;te<=31;te++,Me>>>=1)if(1&Me&&X.dyn_ltree[2*te]!==0)return o;if(X.dyn_ltree[18]!==0||X.dyn_ltree[20]!==0||X.dyn_ltree[26]!==0)return l;for(te=32;te<f;te++)if(X.dyn_ltree[2*te]!==0)return l;return o})(z)),it(z,z.l_desc),it(z,z.d_desc),L=(function(X){var te;for(U(X,X.dyn_ltree,X.l_desc.max_code),U(X,X.dyn_dtree,X.d_desc.max_code),it(X,X.bl_desc),te=x-1;3<=te&&X.bl_tree[2*R[te]+1]===0;te--);return X.opt_len+=3*(te+1)+5+5+4,te})(z),Te=z.opt_len+3+7>>>3,(V=z.static_len+3+7>>>3)<=Te&&(Te=V)):Te=V=Ee+5,Ee+4<=Te&&re!==-1?Q(z,re,Ee,_e):z.strategy===4||V===Te?(ne(z,2+(_e?1:0),3),be(z,F,O)):(ne(z,4+(_e?1:0),3),(function(X,te,Me,ie){var De;for(ne(X,te-257,5),ne(X,Me-1,5),ne(X,ie-4,4),De=0;De<ie;De++)ne(X,X.bl_tree[2*R[De]+1],3);K(X,X.dyn_ltree,te-1),K(X,X.dyn_dtree,Me-1)})(z,z.l_desc.max_code+1,z.d_desc.max_code+1,L+1),be(z,z.dyn_ltree,z.dyn_dtree)),ge(z),_e&&xe(z)},i._tr_tally=function(z,re,Ee){return z.pending_buf[z.d_buf+2*z.last_lit]=re>>>8&255,z.pending_buf[z.d_buf+2*z.last_lit+1]=255&re,z.pending_buf[z.l_buf+z.last_lit]=255&Ee,z.last_lit++,re===0?z.dyn_ltree[2*Ee]++:(z.matches++,re--,z.dyn_ltree[2*(j[Ee]+f+1)]++,z.dyn_dtree[2*W(re)]++),z.last_lit===z.lit_bufsize-1},i._tr_align=function(z){ne(z,2,3),ce(z,N,F),(function(re){re.bi_valid===16?(se(re,re.bi_buf),re.bi_buf=0,re.bi_valid=0):8<=re.bi_valid&&(re.pending_buf[re.pending++]=255&re.bi_buf,re.bi_buf>>=8,re.bi_valid-=8)})(z)}},{"../utils/common":41}],53:[function(n,r,i){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,i){(function(s){(function(o,l){if(!o.setImmediate){var c,u,d,f,m=1,p={},x=!1,b=o.document,y=Object.getPrototypeOf&&Object.getPrototypeOf(o);y=y&&y.setTimeout?y:o,c={}.toString.call(o.process)==="[object process]"?function(C){process.nextTick(function(){S(C)})}:(function(){if(o.postMessage&&!o.importScripts){var C=!0,T=o.onmessage;return o.onmessage=function(){C=!1},o.postMessage("","*"),o.onmessage=T,C}})()?(f="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",N,!1):o.attachEvent("onmessage",N),function(C){o.postMessage(f+C,"*")}):o.MessageChannel?((d=new MessageChannel).port1.onmessage=function(C){S(C.data)},function(C){d.port2.postMessage(C)}):b&&"onreadystatechange"in b.createElement("script")?(u=b.documentElement,function(C){var T=b.createElement("script");T.onreadystatechange=function(){S(C),T.onreadystatechange=null,u.removeChild(T),T=null},u.appendChild(T)}):function(C){setTimeout(S,0,C)},y.setImmediate=function(C){typeof C!="function"&&(C=new Function(""+C));for(var T=new Array(arguments.length-1),k=0;k<T.length;k++)T[k]=arguments[k+1];var E={callback:C,args:T};return p[m]=E,c(m),m++},y.clearImmediate=v}function v(C){delete p[C]}function S(C){if(x)setTimeout(S,0,C);else{var T=p[C];if(T){x=!0;try{(function(k){var E=k.callback,D=k.args;switch(D.length){case 0:E();break;case 1:E(D[0]);break;case 2:E(D[0],D[1]);break;case 3:E(D[0],D[1],D[2]);break;default:E.apply(l,D)}})(T)}finally{v(C),x=!1}}}}function N(C){C.source===o&&typeof C.data=="string"&&C.data.indexOf(f)===0&&S(+C.data.slice(f.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof k_<"u"?k_:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(FT)),FT.exports}var Nye=Sye();const Mye=ul(Nye);function Eye(t){const e=new Fi;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 QB=Eye;async function ZB(t,e=0){const n=[],r=t.getElementsByTagName("mesh");for(let i=0;i<r.length;i++){const s=r[i],o=[],l=[],c=s.getElementsByTagName("vertex");for(let d=0;d<c.length;d++){const f=c[d];o.push(parseFloat(f.getAttribute("x")||"0"),parseFloat(f.getAttribute("y")||"0"),parseFloat(f.getAttribute("z")||"0"))}const u=s.getElementsByTagName("triangle");for(let d=0;d<u.length;d++){const f=u[d];l.push(parseInt(f.getAttribute("v1")||"0"),parseInt(f.getAttribute("v2")||"0"),parseInt(f.getAttribute("v3")||"0"))}o.length>0&&l.length>0&&n.push({vertices:o,triangles:l,extruder:e})}return n}function JB(t){const e=Array.from(t.attributes).find(r=>{const i=r.name.toLowerCase();return i==="plate_id"||i==="plater_id"||i==="plateid"||i==="platerid"||i.endsWith(":plate_id")||i.endsWith(":plater_id")});if(!e?.value)return null;const n=Number.parseInt(e.value,10);return Number.isFinite(n)?n:null}async function Cye(t){let e;try{e=await Mye.loadAsync(t)}catch{throw new Error("Unsupported file format")}const n=new Map,r=[],i=new Map,s=new DOMParser;async function o(S){const N=S.startsWith("/")?S.slice(1):S,C=e.files[N];if(!C)return null;const T=await C.async("string");return s.parseFromString(T,"application/xml")}const l=new Map,c=new Map,u=new Map,d=new Map,f=e.files["Metadata/model_settings.config"];if(f)try{const S=await f.async("string"),N=s.parseFromString(S,"application/xml"),C=N.getElementsByTagName("object");for(let k=0;k<C.length;k++){const E=C[k],D=E.getAttribute("id");if(!D)continue;const A=Array.from(E.children).filter(H=>H.tagName==="metadata"&&H.getAttribute("key")==="extruder");if(A.length>0){const H=A[0].getAttribute("value");H&&l.set(D,Math.max(0,parseInt(H,10)-1))}const F=Array.from(E.children).find(H=>H.tagName==="metadata"&&H.getAttribute("key")==="name")?.getAttribute("value");F&&u.set(D,F);const O=E.getElementsByTagName("part");for(let H=0;H<O.length;H++){const j=O[H],G=j.getAttribute("id");if(!G)continue;const $=Array.from(j.children).filter(q=>q.tagName==="metadata"&&q.getAttribute("key")==="extruder");if($.length>0){const q=$[0].getAttribute("value");q&&c.set(`${D}:${G}`,Math.max(0,parseInt(q,10)-1))}}}const T=N.getElementsByTagName("plate");for(let k=0;k<T.length;k++){const E=T[k];let D=null;const A=E.getElementsByTagName("metadata");for(let F=0;F<A.length;F++){const O=A[F],H=O.getAttribute("key");if(H==="plater_id"||H==="plate_id"){const j=O.getAttribute("value");if(j){const G=Number.parseInt(j,10);Number.isFinite(G)&&(D=G)}}}if(D==null)continue;const R=E.getElementsByTagName("model_instance");for(let F=0;F<R.length;F++){const H=R[F].getElementsByTagName("metadata");for(let j=0;j<H.length;j++){const G=H[j];if(G.getAttribute("key")==="object_id"){const $=G.getAttribute("value");$&&d.set($,D)}}}}}catch{}const m=new Map,p=Object.keys(e.files).filter(S=>S.startsWith("Metadata/plate_")&&S.endsWith(".json"));for(const S of p){const N=S.match(/^Metadata\/plate_(\d+)\.json$/);if(!N)continue;const C=Number.parseInt(N[1],10);if(Number.isFinite(C))try{const T=await e.files[S].async("string"),k=JSON.parse(T),E=k.bbox_objects??[];for(const D of E)D?.name&&m.set(D.name,C);if(Array.isArray(k.bbox_all)&&k.bbox_all.length>=4){const[D,A,R,F]=k.bbox_all;[D,A,R,F].every(O=>Number.isFinite(O))&&i.set(C,{minX:D,minY:A,maxX:R,maxY:F})}}catch{}}const x=Object.keys(e.files).find(S=>S==="3D/3dmodel.model"||S.endsWith("/3dmodel.model"));if(!x){const S=Object.keys(e.files).find(N=>N.endsWith(".model"));if(S){const N=await o(S);if(N){const C=await ZB(N,0);C.length>0&&n.set("1",{id:"1",meshes:C,defaultExtruder:0})}}return{objects:n,buildItems:r,plateBounds:i}}const b=await o(x);if(!b)return{objects:n,buildItems:r,plateBounds:i};const y=b.getElementsByTagName("object");for(let S=0;S<y.length;S++){const N=y[S],C=N.getAttribute("id");if(!C)continue;const T=JB(N)??d.get(C)??null;let k=l.get(C)??-1;if(k<0){const R=N.getAttribute("p:extruder")||N.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","extruder")||"1";k=Math.max(0,parseInt(R,10)-1)}const E=[],D=N.getElementsByTagName("mesh");for(let R=0;R<D.length;R++){const F=D[R],O=[],H=[],j=F.getElementsByTagName("vertex");for(let $=0;$<j.length;$++){const q=j[$];O.push(parseFloat(q.getAttribute("x")||"0"),parseFloat(q.getAttribute("y")||"0"),parseFloat(q.getAttribute("z")||"0"))}const G=F.getElementsByTagName("triangle");for(let $=0;$<G.length;$++){const q=G[$];H.push(parseInt(q.getAttribute("v1")||"0"),parseInt(q.getAttribute("v2")||"0"),parseInt(q.getAttribute("v3")||"0"))}O.length>0&&H.length>0&&E.push({vertices:O,triangles:H,extruder:k})}const A=N.getElementsByTagName("component");for(let R=0;R<A.length;R++){const F=A[R],O=F.getAttribute("p:path")||F.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path"),H=F.getAttribute("objectid");if(O){const j=await o(O);if(j){const G=H?`${C}:${H}`:null,$=G?c.get(G)??k:k,q=await ZB(j,$),Y=F.getAttribute("transform"),Z=QB(Y);for(const oe of q)if(Y){const B=[];for(let W=0;W<oe.vertices.length;W+=3){const se=new lt(oe.vertices[W],oe.vertices[W+1],oe.vertices[W+2]);se.applyMatrix4(Z),B.push(se.x,se.y,se.z)}E.push({vertices:B,triangles:oe.triangles,extruder:oe.extruder})}else E.push(oe)}}}E.length>0&&n.set(C,{id:C,meshes:E,defaultExtruder:k,plateId:T})}const v=b.getElementsByTagName("build");if(v.length>0){const S=v[0].getElementsByTagName("item");for(let N=0;N<S.length;N++){const C=S[N],T=C.getAttribute("objectid");if(!T)continue;const k=QB(C.getAttribute("transform")),E=JB(C),D=n.get(T)?.plateId??null,A=u.get(T),R=A?m.get(A)??null:null;r.push({objectId:T,transform:k,plateId:E??D??R??null})}}return{objects:n,buildItems:r,plateBounds:i}}function e8(t){const e=new al,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 bs(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function Tye(t){t.traverse(e=>{if(e instanceof sl)if(e.geometry.dispose(),Array.isArray(e.material))for(const n of e.material)n.dispose();else e.material.dispose()})}function Aye(t,e,n){const{objects:r,buildItems:i}=t,s=new pg,o=f=>{const p=n?.[f]||"#00ae42",x=new Rn(p);return new bK({color:x,shininess:30,flatShading:!1})},l=new Map,c=i.some(f=>f.plateId!=null),u=e==null||!c?i:i.filter(f=>f.plateId===e),d=u.length>0?u:i;if(d.length>0)for(const f of d){const m=r.get(f.objectId);if(m)for(const p of m.meshes){const x=f.extruder??p.extruder,b=[];for(let v=0;v<p.vertices.length;v+=3){const S=new lt(p.vertices[v],p.vertices[v+1],p.vertices[v+2]);S.applyMatrix4(f.transform),b.push(S.x,S.y,S.z)}const y=e8({vertices:b,triangles:p.triangles});l.has(x)||l.set(x,[]),l.get(x).push(y)}}else for(const f of r.values())for(const m of f.meshes){const p=m.extruder,x=e8(m);l.has(p)||l.set(p,[]),l.get(p).push(x)}for(const[f,m]of l){if(m.length===0)continue;const p=m.length===1?m[0]:_ye(m,!1);if(p){const x=o(f),b=new sl(p,x);s.add(b)}if(m.length>1)for(const x of m)x.dispose()}return s}function CK({url:t,fileType:e,buildVolume:n={x:256,y:256,z:256},filamentColors:r,selectedPlateId:i=null,className:s=""}){const o=w.useRef(null),l=w.useRef(null),c=w.useRef(null),u=w.useRef(null),d=w.useRef(null),f=w.useRef(null),m=w.useRef(null),p=w.useRef(null),[x,b]=w.useState(!0),[y,v]=w.useState(null),[S,N]=w.useState(null),[C,T]=w.useState(null);w.useEffect(()=>{if(!o.current)return;const D=o.current,A=D.clientWidth,R=D.clientHeight,F=new tpe;F.background=new Rn(1710618),c.current=F;const O=new qo(45,A/R,.1,1e4);O.position.set(150,150,150),u.current=O;const H=new sye({antialias:!0});H.setSize(A,R),H.setPixelRatio(window.devicePixelRatio),D.appendChild(H.domElement),l.current=H;const j=new lye(O,H.domElement);j.enableDamping=!0,j.dampingFactor=.05,d.current=j;const G=new gpe(16777215,.6);F.add(G);const $=new _B(16777215,.8);$.position.set(100,100,100),F.add($);const q=new _B(16777215,.4);q.position.set(-100,50,-100),F.add(q);const Y=Math.max(n.x,n.y),Z=Math.ceil(Y/16),oe=new bpe(Y,Z,4473924,3355443);F.add(oe),p.current=oe;const B=new e4(n.x,n.y),W=new QD({color:44610,transparent:!0,opacity:.15,side:ic}),se=new sl(B,W);se.rotation.x=-Math.PI/2,se.position.y=-.5,F.add(se),m.current=se;let ne;const ce=()=>{ne=requestAnimationFrame(ce),j.update(),H.render(F,O)};ce(),b(!0),v(null),N(null),T(null);const fe=(e||t.split("?")[0].split(".").pop()||"").toLowerCase();fe==="stl"?fetch(t).then(ge=>{if(!ge.ok)throw new Error("Failed to load file");return ge.arrayBuffer()}).then(ge=>{const Pe=new wye().parse(ge);Pe.computeVertexNormals(),Pe.rotateX(-Math.PI/2),T(Pe)}).catch(ge=>{v(ge.message),b(!1)}):fe==="3mf"?fetch(t).then(ge=>{if(!ge.ok)throw new Error("Failed to load file");return ge.arrayBuffer()}).then(Cye).then(ge=>{if(ge.objects.size===0)throw new Error("No meshes found in 3MF file");N(ge)}).catch(ge=>{v(ge.message),b(!1)}):(v("Unsupported file format"),b(!1));const ye=()=>{if(!D)return;const ge=D.clientWidth,xe=D.clientHeight;O.aspect=ge/xe,O.updateProjectionMatrix(),H.setSize(ge,xe)};return window.addEventListener("resize",ye),()=>{window.removeEventListener("resize",ye),cancelAnimationFrame(ne),j.dispose(),H.dispose(),D.removeChild(H.domElement),f.current=null,m.current=null,p.current=null}},[t,n,e]),w.useEffect(()=>{if(!c.current||!u.current||!d.current||!S&&!C)return;f.current&&(c.current.remove(f.current),Tye(f.current));const D=!!C,A=D?(()=>{const ne=r?.[0]||"#00ae42",ce=new bK({color:new Rn(ne),shininess:30}),fe=new sl(C,ce),ye=new pg;return ye.add(fe),ye})():Aye(S,i??null,r);f.current=A,c.current.add(A);const R=new oh().setFromObject(A),F=R.getCenter(new lt);A.position.y=-R.min.y;const O=D||S.buildItems.length===0,H=O?-F.x:0,j=O?-F.z:0;let G=0,$=0;if(!D&&i!=null&&S.buildItems.length>0){const ne=new oh().setFromObject(A),ce=S.plateBounds.get(i);ce?(G=ne.min.x-ce.minX,$=ne.min.z-ce.minY):(G=Math.floor((ne.min.x+1e-6)/n.x)*n.x,$=Math.floor((ne.min.z+1e-6)/n.y)*n.y)}const q=n.x/2,Y=n.y/2;!D&&i!=null&&S.buildItems.length>0?(A.position.x=H-G,A.position.z=j-$):D?(A.position.x=H+q,A.position.z=j+Y):(A.position.x=H,A.position.z=j),m.current&&(m.current.position.x=q,m.current.position.z=Y),p.current&&(p.current.position.x=q,p.current.position.z=Y);const Z=new oh().setFromObject(A),oe=Z.getCenter(new lt),B=Z.getSize(new lt),se=Math.max(B.x,B.y,B.z)*1.8;u.current.position.set(oe.x+se*.7,oe.y+se*.5,oe.z+se*.7),d.current.target.copy(oe),d.current.update(),b(!1)},[S,C,i,r,n]);const k=()=>{u.current&&d.current&&(u.current.position.set(150,150,150),d.current.target.set(0,50,0),d.current.update())},E=D=>{u.current&&u.current.position.multiplyScalar(D)};return a.jsxs("div",{className:`relative ${s}`,children:[a.jsx("div",{ref:o,className:"w-full h-full min-h-[400px]"}),x&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:a.jsx(ct,{className:"w-8 h-8 text-bambu-green animate-spin"})}),y&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:a.jsx("p",{className:"text-red-400",children:y})}),!x&&!y&&a.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[a.jsx(Ne,{variant:"secondary",size:"sm",onClick:()=>E(.8),children:a.jsx(ID,{className:"w-4 h-4"})}),a.jsx(Ne,{variant:"secondary",size:"sm",onClick:()=>E(1.25),children:a.jsx(FD,{className:"w-4 h-4"})}),a.jsx(Ne,{variant:"secondary",size:"sm",onClick:k,children:a.jsx(Dh,{className:"w-4 h-4"})})]})]})}const MN="159",kp={ROTATE:0,DOLLY:1,PAN:2},jp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},kye=0,t8=1,jye=2,TK=1,Pye=2,lu=3,Sh=0,Bs=1,hu=2,lh=0,Tg=1,n8=2,r8=3,i8=4,Rye=5,Ef=100,Dye=101,Oye=102,a8=103,s8=104,Lye=200,Iye=201,Fye=202,Uye=203,dP=204,hP=205,zye=206,Bye=207,$ye=208,Hye=209,Vye=210,Gye=211,qye=212,Wye=213,Kye=214,Xye=0,Yye=1,Qye=2,tS=3,Zye=4,Jye=5,eve=6,tve=7,r4=0,nve=1,rve=2,ch=0,ive=1,ave=2,sve=3,ove=4,lve=5,AK=300,Kg=301,Xg=302,fP=303,mP=304,EN=306,pP=1e3,Cl=1001,gP=1002,ka=1003,o8=1004,UT=1005,Wo=1006,cve=1007,ey=1008,uh=1009,uve=1010,dve=1011,i4=1012,kK=1013,Qd=1014,yu=1015,ty=1016,jK=1017,PK=1018,Bf=1020,hve=1021,Ko=1023,fve=1024,mve=1025,$f=1026,Yg=1027,pve=1028,RK=1029,gve=1030,DK=1031,OK=1033,zT=33776,BT=33777,$T=33778,HT=33779,l8=35840,c8=35841,u8=35842,d8=35843,LK=36196,h8=37492,f8=37496,m8=37808,p8=37809,g8=37810,x8=37811,b8=37812,y8=37813,v8=37814,_8=37815,w8=37816,S8=37817,N8=37818,M8=37819,E8=37820,C8=37821,VT=36492,T8=36494,A8=36495,xve=36283,k8=36284,j8=36285,P8=36286,IK=3e3,Hf=3001,bve=3200,yve=3201,FK=0,vve=1,Xo="",ja="srgb",Lu="srgb-linear",a4="display-p3",CN="display-p3-linear",nS="linear",$r="srgb",rS="rec709",iS="p3",Pp=7680,R8=519,_ve=512,wve=513,Sve=514,UK=515,Nve=516,Mve=517,Eve=518,Cve=519,xP=35044,D8="300 es",bP=1035,cc=2e3,ny=2001;class Cm{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,o=i.length;s<o;s++)i[s].call(this,e);e.target=null}}}const Ha=["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 O8=1234567;const v0=Math.PI/180,ry=180/Math.PI;function Cu(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Ha[t&255]+Ha[t>>8&255]+Ha[t>>16&255]+Ha[t>>24&255]+"-"+Ha[e&255]+Ha[e>>8&255]+"-"+Ha[e>>16&15|64]+Ha[e>>24&255]+"-"+Ha[n&63|128]+Ha[n>>8&255]+"-"+Ha[n>>16&255]+Ha[n>>24&255]+Ha[r&255]+Ha[r>>8&255]+Ha[r>>16&255]+Ha[r>>24&255]).toLowerCase()}function Pa(t,e,n){return Math.max(e,Math.min(n,t))}function s4(t,e){return(t%e+e)%e}function Tve(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function Ave(t,e,n){return t!==e?(n-t)/(e-t):0}function _0(t,e,n){return(1-n)*t+n*e}function kve(t,e,n,r){return _0(t,e,1-Math.exp(-n*r))}function jve(t,e=1){return e-Math.abs(s4(t,e*2)-e)}function Pve(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function Rve(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function Dve(t,e){return t+Math.floor(Math.random()*(e-t+1))}function Ove(t,e){return t+Math.random()*(e-t)}function Lve(t){return t*(.5-Math.random())}function Ive(t){t!==void 0&&(O8=t);let e=O8+=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 Fve(t){return t*v0}function Uve(t){return t*ry}function yP(t){return(t&t-1)===0&&t!==0}function zve(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function aS(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function Bve(t,e,n,r,i){const s=Math.cos,o=Math.sin,l=s(n/2),c=o(n/2),u=s((e+r)/2),d=o((e+r)/2),f=s((e-r)/2),m=o((e-r)/2),p=s((r-e)/2),x=o((r-e)/2);switch(i){case"XYX":t.set(l*d,c*f,c*m,l*u);break;case"YZY":t.set(c*m,l*d,c*f,l*u);break;case"ZXZ":t.set(c*f,c*m,l*d,l*u);break;case"XZX":t.set(l*d,c*x,c*p,l*u);break;case"YXY":t.set(c*p,l*d,c*x,l*u);break;case"ZYZ":t.set(c*x,c*p,l*d,l*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function ac(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 Mr(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 zK={DEG2RAD:v0,RAD2DEG:ry,generateUUID:Cu,clamp:Pa,euclideanModulo:s4,mapLinear:Tve,inverseLerp:Ave,lerp:_0,damp:kve,pingpong:jve,smoothstep:Pve,smootherstep:Rve,randInt:Dve,randFloat:Ove,randFloatSpread:Lve,seededRandom:Ive,degToRad:Fve,radToDeg:Uve,isPowerOfTwo:yP,ceilPowerOfTwo:zve,floorPowerOfTwo:aS,setQuaternionFromProperEuler:Bve,normalize:Mr,denormalize:ac};class xn{constructor(e=0,n=0){xn.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(Pa(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,o=this.y-e.y;return this.x=s*r-o*i+e.x,this.y=s*i+o*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ln{constructor(e,n,r,i,s,o,l,c,u){Ln.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,o,l,c,u)}set(e,n,r,i,s,o,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=s,d[5]=c,d[6]=r,d[7]=o,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,o=r[0],l=r[3],c=r[6],u=r[1],d=r[4],f=r[7],m=r[2],p=r[5],x=r[8],b=i[0],y=i[3],v=i[6],S=i[1],N=i[4],C=i[7],T=i[2],k=i[5],E=i[8];return s[0]=o*b+l*S+c*T,s[3]=o*y+l*N+c*k,s[6]=o*v+l*C+c*E,s[1]=u*b+d*S+f*T,s[4]=u*y+d*N+f*k,s[7]=u*v+d*C+f*E,s[2]=m*b+p*S+x*T,s[5]=m*y+p*N+x*k,s[8]=m*v+p*C+x*E,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],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8];return n*o*d-n*l*u-r*s*d+r*l*c+i*s*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=d*o-l*u,m=l*c-d*s,p=u*s-o*c,x=n*f+r*m+i*p;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const b=1/x;return e[0]=f*b,e[1]=(i*u-d*r)*b,e[2]=(l*r-i*o)*b,e[3]=m*b,e[4]=(d*n-i*c)*b,e[5]=(i*s-l*n)*b,e[6]=p*b,e[7]=(r*c-u*n)*b,e[8]=(o*n-r*s)*b,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,o,l){const c=Math.cos(s),u=Math.sin(s);return this.set(r*c,r*u,-r*(c*o+u*l)+o+e,-i*u,i*c,-i*(-u*o+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply(GT.makeScale(e,n)),this}rotate(e){return this.premultiply(GT.makeRotation(-e)),this}translate(e,n){return this.premultiply(GT.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 GT=new Ln;function BK(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function sS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function $ve(){const t=sS("canvas");return t.style.display="block",t}const L8={};function w0(t){t in L8||(L8[t]=!0,console.warn(t))}const I8=new Ln().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),F8=new Ln().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),aw={[Lu]:{transfer:nS,primaries:rS,toReference:t=>t,fromReference:t=>t},[ja]:{transfer:$r,primaries:rS,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[CN]:{transfer:nS,primaries:iS,toReference:t=>t.applyMatrix3(F8),fromReference:t=>t.applyMatrix3(I8)},[a4]:{transfer:$r,primaries:iS,toReference:t=>t.convertSRGBToLinear().applyMatrix3(F8),fromReference:t=>t.applyMatrix3(I8).convertLinearToSRGB()}},Hve=new Set([Lu,CN]),Er={enabled:!0,_workingColorSpace:Lu,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(!Hve.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=aw[e].toReference,i=aw[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 aw[t].primaries},getTransfer:function(t){return t===Xo?nS:aw[t].transfer}};function Ag(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function qT(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Rp;class $K{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Rp===void 0&&(Rp=sS("canvas")),Rp.width=e.width,Rp.height=e.height;const r=Rp.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Rp}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=sS("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 o=0;o<s.length;o++)s[o]=Ag(s[o]/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(Ag(n[r]/255)*255):n[r]=Ag(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 Vve=0;class HK{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Vve++}),this.uuid=Cu(),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 o=0,l=i.length;o<l;o++)i[o].isDataTexture?s.push(WT(i[o].image)):s.push(WT(i[o]))}else s=WT(i);r.url=s}return n||(e.images[this.uuid]=r),r}}function WT(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?$K.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 Gve=0;class $s extends Cm{constructor(e=$s.DEFAULT_IMAGE,n=$s.DEFAULT_MAPPING,r=Cl,i=Cl,s=Wo,o=ey,l=Ko,c=uh,u=$s.DEFAULT_ANISOTROPY,d=Xo){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Gve++}),this.uuid=Cu(),this.name="",this.source=new HK(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=u,this.format=l,this.internalFormat=null,this.type=c,this.offset=new xn(0,0),this.repeat=new xn(1,1),this.center=new xn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ln,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(w0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===Hf?ja:Xo),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!==AK)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case pP:e.x=e.x-Math.floor(e.x);break;case Cl:e.x=e.x<0?0:1;break;case gP:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case pP:e.y=e.y-Math.floor(e.y);break;case Cl:e.y=e.y<0?0:1;break;case gP: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 w0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===ja?Hf:IK}set encoding(e){w0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Hf?ja:Xo}}$s.DEFAULT_IMAGE=null;$s.DEFAULT_MAPPING=AK;$s.DEFAULT_ANISOTROPY=1;class Ar{constructor(e=0,n=0,r=0,i=1){Ar.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,o=e.elements;return this.x=o[0]*n+o[4]*r+o[8]*i+o[12]*s,this.y=o[1]*n+o[5]*r+o[9]*i+o[13]*s,this.z=o[2]*n+o[6]*r+o[10]*i+o[14]*s,this.w=o[3]*n+o[7]*r+o[11]*i+o[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,s;const c=e.elements,u=c[0],d=c[4],f=c[8],m=c[1],p=c[5],x=c[9],b=c[2],y=c[6],v=c[10];if(Math.abs(d-m)<.01&&Math.abs(f-b)<.01&&Math.abs(x-y)<.01){if(Math.abs(d+m)<.1&&Math.abs(f+b)<.1&&Math.abs(x+y)<.1&&Math.abs(u+p+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const N=(u+1)/2,C=(p+1)/2,T=(v+1)/2,k=(d+m)/4,E=(f+b)/4,D=(x+y)/4;return N>C&&N>T?N<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(N),i=k/r,s=E/r):C>T?C<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(C),r=k/i,s=D/i):T<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(T),r=E/s,i=D/s),this.set(r,i,s,n),this}let S=Math.sqrt((y-x)*(y-x)+(f-b)*(f-b)+(m-d)*(m-d));return Math.abs(S)<.001&&(S=1),this.x=(y-x)/S,this.y=(f-b)/S,this.z=(m-d)/S,this.w=Math.acos((u+p+v-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 qve extends Cm{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new Ar(0,0,e,n),this.scissorTest=!1,this.viewport=new Ar(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(w0("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===Hf?ja:Xo),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Wo,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new $s(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 HK(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 dm extends qve{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class VK extends $s{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=ka,this.minFilter=ka,this.wrapR=Cl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Wve extends $s{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=ka,this.minFilter=ka,this.wrapR=Cl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class hm{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,o,l){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3];const m=s[o+0],p=s[o+1],x=s[o+2],b=s[o+3];if(l===0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(l===1){e[n+0]=m,e[n+1]=p,e[n+2]=x,e[n+3]=b;return}if(f!==b||c!==m||u!==p||d!==x){let y=1-l;const v=c*m+u*p+d*x+f*b,S=v>=0?1:-1,N=1-v*v;if(N>Number.EPSILON){const T=Math.sqrt(N),k=Math.atan2(T,v*S);y=Math.sin(y*k)/T,l=Math.sin(l*k)/T}const C=l*S;if(c=c*y+m*C,u=u*y+p*C,d=d*y+x*C,f=f*y+b*C,y===1-l){const T=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=T,u*=T,d*=T,f*=T}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,s,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=s[o],m=s[o+1],p=s[o+2],x=s[o+3];return e[n]=l*x+d*f+c*p-u*m,e[n+1]=c*x+d*m+u*f-l*p,e[n+2]=u*x+d*p+l*m-c*f,e[n+3]=d*x-l*f-c*m-u*p,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,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(s/2),m=c(r/2),p=c(i/2),x=c(s/2);switch(o){case"XYZ":this._x=m*d*f+u*p*x,this._y=u*p*f-m*d*x,this._z=u*d*x+m*p*f,this._w=u*d*f-m*p*x;break;case"YXZ":this._x=m*d*f+u*p*x,this._y=u*p*f-m*d*x,this._z=u*d*x-m*p*f,this._w=u*d*f+m*p*x;break;case"ZXY":this._x=m*d*f-u*p*x,this._y=u*p*f+m*d*x,this._z=u*d*x+m*p*f,this._w=u*d*f-m*p*x;break;case"ZYX":this._x=m*d*f-u*p*x,this._y=u*p*f+m*d*x,this._z=u*d*x-m*p*f,this._w=u*d*f+m*p*x;break;case"YZX":this._x=m*d*f+u*p*x,this._y=u*p*f+m*d*x,this._z=u*d*x-m*p*f,this._w=u*d*f-m*p*x;break;case"XZY":this._x=m*d*f-u*p*x,this._y=u*p*f-m*d*x,this._z=u*d*x+m*p*f,this._w=u*d*f+m*p*x;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}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],o=n[1],l=n[5],c=n[9],u=n[2],d=n[6],f=n[10],m=r+l+f;if(m>0){const p=.5/Math.sqrt(m+1);this._w=.25/p,this._x=(d-c)*p,this._y=(s-u)*p,this._z=(o-i)*p}else if(r>l&&r>f){const p=2*Math.sqrt(1+r-l-f);this._w=(d-c)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(s+u)/p}else if(l>f){const p=2*Math.sqrt(1+l-r-f);this._w=(s-u)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+f-r-l);this._w=(o-i)/p,this._x=(s+u)/p,this._y=(c+d)/p,this._z=.25*p}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(Pa(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,o=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+o*l+i*u-s*c,this._y=i*d+o*c+s*l-r*u,this._z=s*d+o*u+r*c-i*l,this._w=o*d-r*l-i*c-s*u,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);const r=this._x,i=this._y,s=this._z,o=this._w;let l=o*e._w+r*e._x+i*e._y+s*e._z;if(l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),l>=1)return this._w=o,this._x=r,this._y=i,this._z=s,this;const c=1-l*l;if(c<=Number.EPSILON){const p=1-n;return this._w=p*o+n*this._w,this._x=p*r+n*this._x,this._y=p*i+n*this._y,this._z=p*s+n*this._z,this.normalize(),this._onChangeCallback(),this}const u=Math.sqrt(c),d=Math.atan2(u,l),f=Math.sin((1-n)*d)/u,m=Math.sin(n*d)/u;return this._w=o*f+this._w*m,this._x=r*f+this._x*m,this._y=i*f+this._y*m,this._z=s*f+this._z*m,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 qe{constructor(e=0,n=0,r=0){qe.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(U8.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(U8.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,o=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])*o,this.y=(s[1]*n+s[5]*r+s[9]*i+s[13])*o,this.z=(s[2]*n+s[6]*r+s[10]*i+s[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,s=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-s*i),f=2*(s*r-o*n);return this.x=n+c*u+o*f-l*d,this.y=r+c*d+l*u-s*f,this.z=i+c*f+s*d-o*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,o=n.x,l=n.y,c=n.z;return this.x=i*c-s*l,this.y=s*o-r*c,this.z=r*l-i*o,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 KT.copy(this).projectOnVector(e),this.sub(KT)}reflect(e){return this.sub(KT.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(Pa(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 KT=new qe,U8=new hm;class tl{constructor(e=new qe(1/0,1/0,1/0),n=new qe(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(Sl.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Sl.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=Sl.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 o=0,l=s.count;o<l;o++)e.isMesh===!0?e.getVertexPosition(o,Sl):Sl.fromBufferAttribute(s,o),Sl.applyMatrix4(e.matrixWorld),this.expandByPoint(Sl);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),sw.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),sw.copy(r.boundingBox)),sw.applyMatrix4(e.matrixWorld),this.union(sw)}const i=e.children;for(let s=0,o=i.length;s<o;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,Sl),Sl.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(zb),ow.subVectors(this.max,zb),Dp.subVectors(e.a,zb),Op.subVectors(e.b,zb),Lp.subVectors(e.c,zb),Cd.subVectors(Op,Dp),Td.subVectors(Lp,Op),ff.subVectors(Dp,Lp);let n=[0,-Cd.z,Cd.y,0,-Td.z,Td.y,0,-ff.z,ff.y,Cd.z,0,-Cd.x,Td.z,0,-Td.x,ff.z,0,-ff.x,-Cd.y,Cd.x,0,-Td.y,Td.x,0,-ff.y,ff.x,0];return!XT(n,Dp,Op,Lp,ow)||(n=[1,0,0,0,1,0,0,0,1],!XT(n,Dp,Op,Lp,ow))?!1:(lw.crossVectors(Cd,Td),n=[lw.x,lw.y,lw.z],XT(n,Dp,Op,Lp,ow))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Sl).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Sl).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:(Zc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Zc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Zc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Zc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Zc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Zc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Zc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Zc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Zc),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 Zc=[new qe,new qe,new qe,new qe,new qe,new qe,new qe,new qe],Sl=new qe,sw=new tl,Dp=new qe,Op=new qe,Lp=new qe,Cd=new qe,Td=new qe,ff=new qe,zb=new qe,ow=new qe,lw=new qe,mf=new qe;function XT(t,e,n,r,i){for(let s=0,o=t.length-3;s<=o;s+=3){mf.fromArray(t,s);const l=i.x*Math.abs(mf.x)+i.y*Math.abs(mf.y)+i.z*Math.abs(mf.z),c=e.dot(mf),u=n.dot(mf),d=r.dot(mf);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const Kve=new tl,Bb=new qe,YT=new qe;class hc{constructor(e=new qe,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):Kve.setFromPoints(e).getCenter(r);let i=0;for(let s=0,o=e.length;s<o;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;Bb.subVectors(e,this.center);const n=Bb.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Bb,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):(YT.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Bb.copy(e.center).add(YT)),this.expandByPoint(Bb.copy(e.center).sub(YT))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Jc=new qe,QT=new qe,cw=new qe,Ad=new qe,ZT=new qe,uw=new qe,JT=new qe;class o4{constructor(e=new qe,n=new qe(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Jc)),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=Jc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Jc.copy(this.origin).addScaledVector(this.direction,n),Jc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){QT.copy(e).add(n).multiplyScalar(.5),cw.copy(n).sub(e).normalize(),Ad.copy(this.origin).sub(QT);const s=e.distanceTo(n)*.5,o=-this.direction.dot(cw),l=Ad.dot(this.direction),c=-Ad.dot(cw),u=Ad.lengthSq(),d=Math.abs(1-o*o);let f,m,p,x;if(d>0)if(f=o*c-l,m=o*l-c,x=s*d,f>=0)if(m>=-x)if(m<=x){const b=1/d;f*=b,m*=b,p=f*(f+o*m+2*l)+m*(o*f+m+2*c)+u}else m=s,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m=-s,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m<=-x?(f=Math.max(0,-(-o*s+l)),m=f>0?-s:Math.min(Math.max(-s,-c),s),p=-f*f+m*(m+2*c)+u):m<=x?(f=0,m=Math.min(Math.max(-s,-c),s),p=m*(m+2*c)+u):(f=Math.max(0,-(o*s+l)),m=f>0?s:Math.min(Math.max(-s,-c),s),p=-f*f+m*(m+2*c)+u);else m=o>0?-s:s,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(QT).addScaledVector(cw,m),p}intersectSphere(e,n){Jc.subVectors(e.center,this.origin);const r=Jc.dot(this.direction),i=Jc.dot(Jc)-r*r,s=e.radius*e.radius;if(i>s)return null;const o=Math.sqrt(s-i),l=r-o,c=r+o;return c<0?null:l<0?this.at(c,n):this.at(l,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,o,l,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,m=this.origin;return u>=0?(r=(e.min.x-m.x)*u,i=(e.max.x-m.x)*u):(r=(e.max.x-m.x)*u,i=(e.min.x-m.x)*u),d>=0?(s=(e.min.y-m.y)*d,o=(e.max.y-m.y)*d):(s=(e.max.y-m.y)*d,o=(e.min.y-m.y)*d),r>o||s>i||((s>r||isNaN(r))&&(r=s),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-m.z)*f,c=(e.max.z-m.z)*f):(l=(e.max.z-m.z)*f,c=(e.min.z-m.z)*f),r>c||l>i)||((l>r||r!==r)&&(r=l),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,Jc)!==null}intersectTriangle(e,n,r,i,s){ZT.subVectors(n,e),uw.subVectors(r,e),JT.crossVectors(ZT,uw);let o=this.direction.dot(JT),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;Ad.subVectors(this.origin,e);const c=l*this.direction.dot(uw.crossVectors(Ad,uw));if(c<0)return null;const u=l*this.direction.dot(ZT.cross(Ad));if(u<0||c+u>o)return null;const d=-l*Ad.dot(JT);return d<0?null:this.at(d/o,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 Fr{constructor(e,n,r,i,s,o,l,c,u,d,f,m,p,x,b,y){Fr.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,o,l,c,u,d,f,m,p,x,b,y)}set(e,n,r,i,s,o,l,c,u,d,f,m,p,x,b,y){const v=this.elements;return v[0]=e,v[4]=n,v[8]=r,v[12]=i,v[1]=s,v[5]=o,v[9]=l,v[13]=c,v[2]=u,v[6]=d,v[10]=f,v[14]=m,v[3]=p,v[7]=x,v[11]=b,v[15]=y,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Fr().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/Ip.setFromMatrixColumn(e,0).length(),s=1/Ip.setFromMatrixColumn(e,1).length(),o=1/Ip.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]*o,n[9]=r[9]*o,n[10]=r[10]*o,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,o=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(s),f=Math.sin(s);if(e.order==="XYZ"){const m=o*d,p=o*f,x=l*d,b=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+x*u,n[5]=m-b*u,n[9]=-l*c,n[2]=b-m*u,n[6]=x+p*u,n[10]=o*c}else if(e.order==="YXZ"){const m=c*d,p=c*f,x=u*d,b=u*f;n[0]=m+b*l,n[4]=x*l-p,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=p*l-x,n[6]=b+m*l,n[10]=o*c}else if(e.order==="ZXY"){const m=c*d,p=c*f,x=u*d,b=u*f;n[0]=m-b*l,n[4]=-o*f,n[8]=x+p*l,n[1]=p+x*l,n[5]=o*d,n[9]=b-m*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const m=o*d,p=o*f,x=l*d,b=l*f;n[0]=c*d,n[4]=x*u-p,n[8]=m*u+b,n[1]=c*f,n[5]=b*u+m,n[9]=p*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const m=o*c,p=o*u,x=l*c,b=l*u;n[0]=c*d,n[4]=b-m*f,n[8]=x*f+p,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=p*f+x,n[10]=m-b*f}else if(e.order==="XZY"){const m=o*c,p=o*u,x=l*c,b=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=m*f+b,n[5]=o*d,n[9]=p*f-x,n[2]=x*f-p,n[6]=l*d,n[10]=b*f+m}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(Xve,e,Yve)}lookAt(e,n,r){const i=this.elements;return io.subVectors(e,n),io.lengthSq()===0&&(io.z=1),io.normalize(),kd.crossVectors(r,io),kd.lengthSq()===0&&(Math.abs(r.z)===1?io.x+=1e-4:io.z+=1e-4,io.normalize(),kd.crossVectors(r,io)),kd.normalize(),dw.crossVectors(io,kd),i[0]=kd.x,i[4]=dw.x,i[8]=io.x,i[1]=kd.y,i[5]=dw.y,i[9]=io.y,i[2]=kd.z,i[6]=dw.z,i[10]=io.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,o=r[0],l=r[4],c=r[8],u=r[12],d=r[1],f=r[5],m=r[9],p=r[13],x=r[2],b=r[6],y=r[10],v=r[14],S=r[3],N=r[7],C=r[11],T=r[15],k=i[0],E=i[4],D=i[8],A=i[12],R=i[1],F=i[5],O=i[9],H=i[13],j=i[2],G=i[6],$=i[10],q=i[14],Y=i[3],Z=i[7],oe=i[11],B=i[15];return s[0]=o*k+l*R+c*j+u*Y,s[4]=o*E+l*F+c*G+u*Z,s[8]=o*D+l*O+c*$+u*oe,s[12]=o*A+l*H+c*q+u*B,s[1]=d*k+f*R+m*j+p*Y,s[5]=d*E+f*F+m*G+p*Z,s[9]=d*D+f*O+m*$+p*oe,s[13]=d*A+f*H+m*q+p*B,s[2]=x*k+b*R+y*j+v*Y,s[6]=x*E+b*F+y*G+v*Z,s[10]=x*D+b*O+y*$+v*oe,s[14]=x*A+b*H+y*q+v*B,s[3]=S*k+N*R+C*j+T*Y,s[7]=S*E+N*F+C*G+T*Z,s[11]=S*D+N*O+C*$+T*oe,s[15]=S*A+N*H+C*q+T*B,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],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],m=e[10],p=e[14],x=e[3],b=e[7],y=e[11],v=e[15];return x*(+s*c*f-i*u*f-s*l*m+r*u*m+i*l*p-r*c*p)+b*(+n*c*p-n*u*m+s*o*m-i*o*p+i*u*d-s*c*d)+y*(+n*u*f-n*l*p-s*o*f+r*o*p+s*l*d-r*u*d)+v*(-i*l*d-n*c*f+n*l*m+i*o*f-r*o*m+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9],m=e[10],p=e[11],x=e[12],b=e[13],y=e[14],v=e[15],S=f*y*u-b*m*u+b*c*p-l*y*p-f*c*v+l*m*v,N=x*m*u-d*y*u-x*c*p+o*y*p+d*c*v-o*m*v,C=d*b*u-x*f*u+x*l*p-o*b*p-d*l*v+o*f*v,T=x*f*c-d*b*c-x*l*m+o*b*m+d*l*y-o*f*y,k=n*S+r*N+i*C+s*T;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const E=1/k;return e[0]=S*E,e[1]=(b*m*s-f*y*s-b*i*p+r*y*p+f*i*v-r*m*v)*E,e[2]=(l*y*s-b*c*s+b*i*u-r*y*u-l*i*v+r*c*v)*E,e[3]=(f*c*s-l*m*s-f*i*u+r*m*u+l*i*p-r*c*p)*E,e[4]=N*E,e[5]=(d*y*s-x*m*s+x*i*p-n*y*p-d*i*v+n*m*v)*E,e[6]=(x*c*s-o*y*s-x*i*u+n*y*u+o*i*v-n*c*v)*E,e[7]=(o*m*s-d*c*s+d*i*u-n*m*u-o*i*p+n*c*p)*E,e[8]=C*E,e[9]=(x*f*s-d*b*s-x*r*p+n*b*p+d*r*v-n*f*v)*E,e[10]=(o*b*s-x*l*s+x*r*u-n*b*u-o*r*v+n*l*v)*E,e[11]=(d*l*s-o*f*s-d*r*u+n*f*u+o*r*p-n*l*p)*E,e[12]=T*E,e[13]=(d*b*i-x*f*i+x*r*m-n*b*m-d*r*y+n*f*y)*E,e[14]=(x*l*i-o*b*i-x*r*c+n*b*c+o*r*y-n*l*y)*E,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*m+n*l*m)*E,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,o=e.x,l=e.y,c=e.z,u=s*o,d=s*l;return this.set(u*o+r,u*l-i*c,u*c+i*l,0,u*l+i*c,d*l+r,d*c-i*o,0,u*c-i*l,d*c+i*o,s*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,s,o){return this.set(1,r,s,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,s=n._x,o=n._y,l=n._z,c=n._w,u=s+s,d=o+o,f=l+l,m=s*u,p=s*d,x=s*f,b=o*d,y=o*f,v=l*f,S=c*u,N=c*d,C=c*f,T=r.x,k=r.y,E=r.z;return i[0]=(1-(b+v))*T,i[1]=(p+C)*T,i[2]=(x-N)*T,i[3]=0,i[4]=(p-C)*k,i[5]=(1-(m+v))*k,i[6]=(y+S)*k,i[7]=0,i[8]=(x+N)*E,i[9]=(y-S)*E,i[10]=(1-(m+b))*E,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=Ip.set(i[0],i[1],i[2]).length();const o=Ip.set(i[4],i[5],i[6]).length(),l=Ip.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],Nl.copy(this);const u=1/s,d=1/o,f=1/l;return Nl.elements[0]*=u,Nl.elements[1]*=u,Nl.elements[2]*=u,Nl.elements[4]*=d,Nl.elements[5]*=d,Nl.elements[6]*=d,Nl.elements[8]*=f,Nl.elements[9]*=f,Nl.elements[10]*=f,n.setFromRotationMatrix(Nl),r.x=s,r.y=o,r.z=l,this}makePerspective(e,n,r,i,s,o,l=cc){const c=this.elements,u=2*s/(n-e),d=2*s/(r-i),f=(n+e)/(n-e),m=(r+i)/(r-i);let p,x;if(l===cc)p=-(o+s)/(o-s),x=-2*o*s/(o-s);else if(l===ny)p=-o/(o-s),x=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return c[0]=u,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=d,c[9]=m,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,s,o,l=cc){const c=this.elements,u=1/(n-e),d=1/(r-i),f=1/(o-s),m=(n+e)*u,p=(r+i)*d;let x,b;if(l===cc)x=(o+s)*f,b=-2*f;else if(l===ny)x=s*f,b=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return c[0]=2*u,c[4]=0,c[8]=0,c[12]=-m,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-p,c[2]=0,c[6]=0,c[10]=b,c[14]=-x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}}const Ip=new qe,Nl=new Fr,Xve=new qe(0,0,0),Yve=new qe(1,1,1),kd=new qe,dw=new qe,io=new qe,z8=new Fr,B8=new hm;class zy{constructor(e=0,n=0,r=0,i=zy.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],o=i[4],l=i[8],c=i[1],u=i[5],d=i[9],f=i[2],m=i[6],p=i[10];switch(n){case"XYZ":this._y=Math.asin(Pa(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(m,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Pa(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,p),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(Pa(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Pa(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(m,p),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(Pa(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(l,p));break;case"XZY":this._z=Math.asin(-Pa(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(m,u),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-d,p),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 z8.makeRotationFromQuaternion(e),this.setFromRotationMatrix(z8,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return B8.setFromEuler(this),this.setFromQuaternion(B8,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}zy.DEFAULT_ORDER="XYZ";class GK{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 Qve=0;const $8=new qe,Fp=new hm,eu=new Fr,hw=new qe,$b=new qe,Zve=new qe,Jve=new hm,H8=new qe(1,0,0),V8=new qe(0,1,0),G8=new qe(0,0,1),e_e={type:"added"},t_e={type:"removed"};class ys extends Cm{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Qve++}),this.uuid=Cu(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ys.DEFAULT_UP.clone();const e=new qe,n=new zy,r=new hm,i=new qe(1,1,1);function s(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(s),r._onChange(o),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 Fr},normalMatrix:{value:new Ln}}),this.matrix=new Fr,this.matrixWorld=new Fr,this.matrixAutoUpdate=ys.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ys.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new GK,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 Fp.setFromAxisAngle(e,n),this.quaternion.multiply(Fp),this}rotateOnWorldAxis(e,n){return Fp.setFromAxisAngle(e,n),this.quaternion.premultiply(Fp),this}rotateX(e){return this.rotateOnAxis(H8,e)}rotateY(e){return this.rotateOnAxis(V8,e)}rotateZ(e){return this.rotateOnAxis(G8,e)}translateOnAxis(e,n){return $8.copy(e).applyQuaternion(this.quaternion),this.position.add($8.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(H8,e)}translateY(e){return this.translateOnAxis(V8,e)}translateZ(e){return this.translateOnAxis(G8,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(eu.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?hw.copy(e):hw.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),$b.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?eu.lookAt($b,hw,this.up):eu.lookAt(hw,$b,this.up),this.quaternion.setFromRotationMatrix(eu),i&&(eu.extractRotation(i.matrixWorld),Fp.setFromRotationMatrix(eu),this.quaternion.premultiply(Fp.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(e_e)):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(t_e)),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),eu.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),eu.multiply(e.parent.matrixWorld)),e.applyMatrix4(eu),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 o=this.children[r].getObjectByProperty(e,n);if(o!==void 0)return o}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let s=0,o=i.length;s<o;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($b,e,Zve),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose($b,Jve,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,o=i.length;s<o;s++){const l=i[s];l.matrixWorldAutoUpdate===!0&&l.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(l=>({boxInitialized:l.boxInitialized,boxMin:l.box.min.toArray(),boxMax:l.box.max.toArray(),sphereInitialized:l.sphereInitialized,sphereRadius:l.sphere.radius,sphereCenter:l.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(l,c){return l[c.uuid]===void 0&&(l[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const c=l.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];s(e.shapes,f)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let c=0,u=this.material.length;c<u;c++)l.push(s(e.materials,this.material[c]));i.material=l}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let l=0;l<this.children.length;l++)i.children.push(this.children[l].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let l=0;l<this.animations.length;l++){const c=this.animations[l];i.animations.push(s(e.animations,c))}}if(n){const l=o(e.geometries),c=o(e.materials),u=o(e.textures),d=o(e.images),f=o(e.shapes),m=o(e.skeletons),p=o(e.animations),x=o(e.nodes);l.length>0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),m.length>0&&(r.skeletons=m),p.length>0&&(r.animations=p),x.length>0&&(r.nodes=x)}return r.object=i,r;function o(l){const c=[];for(const u in l){const d=l[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}ys.DEFAULT_UP=new qe(0,1,0);ys.DEFAULT_MATRIX_AUTO_UPDATE=!0;ys.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Ml=new qe,tu=new qe,eA=new qe,nu=new qe,Up=new qe,zp=new qe,q8=new qe,tA=new qe,nA=new qe,rA=new qe;let fw=!1;class El{constructor(e=new qe,n=new qe,r=new qe){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Ml.subVectors(e,n),i.cross(Ml);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){Ml.subVectors(i,n),tu.subVectors(r,n),eA.subVectors(e,n);const o=Ml.dot(Ml),l=Ml.dot(tu),c=Ml.dot(eA),u=tu.dot(tu),d=tu.dot(eA),f=o*u-l*l;if(f===0)return s.set(-2,-1,-1);const m=1/f,p=(u*c-l*d)*m,x=(o*d-l*c)*m;return s.set(1-p-x,x,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,nu),nu.x>=0&&nu.y>=0&&nu.x+nu.y<=1}static getUV(e,n,r,i,s,o,l,c){return fw===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),fw=!0),this.getInterpolation(e,n,r,i,s,o,l,c)}static getInterpolation(e,n,r,i,s,o,l,c){return this.getBarycoord(e,n,r,i,nu),c.setScalar(0),c.addScaledVector(s,nu.x),c.addScaledVector(o,nu.y),c.addScaledVector(l,nu.z),c}static isFrontFacing(e,n,r,i){return Ml.subVectors(r,n),tu.subVectors(e,n),Ml.cross(tu).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 Ml.subVectors(this.c,this.b),tu.subVectors(this.a,this.b),Ml.cross(tu).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return El.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return El.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,s){return fw===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),fw=!0),El.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}getInterpolation(e,n,r,i,s){return El.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return El.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return El.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 o,l;Up.subVectors(i,r),zp.subVectors(s,r),tA.subVectors(e,r);const c=Up.dot(tA),u=zp.dot(tA);if(c<=0&&u<=0)return n.copy(r);nA.subVectors(e,i);const d=Up.dot(nA),f=zp.dot(nA);if(d>=0&&f<=d)return n.copy(i);const m=c*f-d*u;if(m<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(Up,o);rA.subVectors(e,s);const p=Up.dot(rA),x=zp.dot(rA);if(x>=0&&p<=x)return n.copy(s);const b=p*u-c*x;if(b<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(zp,l);const y=d*x-p*f;if(y<=0&&f-d>=0&&p-x>=0)return q8.subVectors(s,i),l=(f-d)/(f-d+(p-x)),n.copy(i).addScaledVector(q8,l);const v=1/(y+b+m);return o=b*v,l=m*v,n.copy(r).addScaledVector(Up,o).addScaledVector(zp,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const qK={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},jd={h:0,s:0,l:0},mw={h:0,s:0,l:0};function iA(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 en=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=ja){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Er.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=Er.workingColorSpace){return this.r=e,this.g=n,this.b=r,Er.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=Er.workingColorSpace){if(e=s4(e,1),n=Pa(n,0,1),r=Pa(r,0,1),n===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+n):r+n-r*n,o=2*r-s;this.r=iA(o,s,e+1/3),this.g=iA(o,s,e),this.b=iA(o,s,e-1/3)}return Er.toWorkingColorSpace(this,i),this}setStyle(e,n=ja){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 o=i[1],l=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))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(l))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(l))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],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,n);if(o===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=ja){const r=qK[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=Ag(e.r),this.g=Ag(e.g),this.b=Ag(e.b),this}copyLinearToSRGB(e){return this.r=qT(e.r),this.g=qT(e.g),this.b=qT(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ja){return Er.fromWorkingColorSpace(Va.copy(this),e),Math.round(Pa(Va.r*255,0,255))*65536+Math.round(Pa(Va.g*255,0,255))*256+Math.round(Pa(Va.b*255,0,255))}getHexString(e=ja){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Er.workingColorSpace){Er.fromWorkingColorSpace(Va.copy(this),n);const r=Va.r,i=Va.g,s=Va.b,o=Math.max(r,i,s),l=Math.min(r,i,s);let c,u;const d=(l+o)/2;if(l===o)c=0,u=0;else{const f=o-l;switch(u=d<=.5?f/(o+l):f/(2-o-l),o){case r:c=(i-s)/f+(i<s?6:0);break;case i:c=(s-r)/f+2;break;case s:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=Er.workingColorSpace){return Er.fromWorkingColorSpace(Va.copy(this),n),e.r=Va.r,e.g=Va.g,e.b=Va.b,e}getStyle(e=ja){Er.fromWorkingColorSpace(Va.copy(this),e);const n=Va.r,r=Va.g,i=Va.b;return e!==ja?`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(jd),this.setHSL(jd.h+e,jd.s+n,jd.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(jd),e.getHSL(mw);const r=_0(jd.h,mw.h,n),i=_0(jd.s,mw.s,n),s=_0(jd.l,mw.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 Va=new en;en.NAMES=qK;let n_e=0;class wx extends Cm{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:n_e++}),this.uuid=Cu(),this.name="",this.type="Material",this.blending=Tg,this.side=Sh,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=dP,this.blendDst=hP,this.blendEquation=Ef,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new en(0,0,0),this.blendAlpha=0,this.depthFunc=tS,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=R8,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Pp,this.stencilZFail=Pp,this.stencilZPass=Pp,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!==Tg&&(r.blending=this.blending),this.side!==Sh&&(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!==dP&&(r.blendSrc=this.blendSrc),this.blendDst!==hP&&(r.blendDst=this.blendDst),this.blendEquation!==Ef&&(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!==tS&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==R8&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Pp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Pp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Pp&&(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 o=[];for(const l in s){const c=s[l];delete c.metadata,o.push(c)}return o}if(n){const s=i(e.textures),o=i(e.images);s.length>0&&(r.textures=s),o.length>0&&(r.images=o)}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 WK extends wx{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new en(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=r4,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 Ai=new qe,pw=new xn;class go{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=xP,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=yu,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++)pw.fromBufferAttribute(this,n),pw.applyMatrix3(e),this.setXY(n,pw.x,pw.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Ai.fromBufferAttribute(this,n),Ai.applyMatrix3(e),this.setXYZ(n,Ai.x,Ai.y,Ai.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Ai.fromBufferAttribute(this,n),Ai.applyMatrix4(e),this.setXYZ(n,Ai.x,Ai.y,Ai.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Ai.fromBufferAttribute(this,n),Ai.applyNormalMatrix(e),this.setXYZ(n,Ai.x,Ai.y,Ai.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Ai.fromBufferAttribute(this,n),Ai.transformDirection(e),this.setXYZ(n,Ai.x,Ai.y,Ai.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=ac(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Mr(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=ac(n,this.array)),n}setX(e,n){return this.normalized&&(n=Mr(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=ac(n,this.array)),n}setY(e,n){return this.normalized&&(n=Mr(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=ac(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Mr(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=ac(n,this.array)),n}setW(e,n){return this.normalized&&(n=Mr(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Mr(n,this.array),r=Mr(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=Mr(n,this.array),r=Mr(r,this.array),i=Mr(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=Mr(n,this.array),r=Mr(r,this.array),i=Mr(i,this.array),s=Mr(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!==xP&&(e.usage=this.usage),e}}class KK extends go{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class XK extends go{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class wi extends go{constructor(e,n,r){super(new Float32Array(e),n,r)}}let r_e=0;const Oo=new Fr,aA=new ys,Bp=new qe,ao=new tl,Hb=new tl,ca=new qe;class Ja extends Cm{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:r_e++}),this.uuid=Cu(),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(BK(e)?XK:KK)(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 Ln().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 Oo.makeRotationFromQuaternion(e),this.applyMatrix4(Oo),this}rotateX(e){return Oo.makeRotationX(e),this.applyMatrix4(Oo),this}rotateY(e){return Oo.makeRotationY(e),this.applyMatrix4(Oo),this}rotateZ(e){return Oo.makeRotationZ(e),this.applyMatrix4(Oo),this}translate(e,n,r){return Oo.makeTranslation(e,n,r),this.applyMatrix4(Oo),this}scale(e,n,r){return Oo.makeScale(e,n,r),this.applyMatrix4(Oo),this}lookAt(e){return aA.lookAt(e),aA.updateMatrix(),this.applyMatrix4(aA.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Bp).negate(),this.translate(Bp.x,Bp.y,Bp.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 wi(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new tl);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 qe(-1/0,-1/0,-1/0),new qe(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const s=n[r];ao.setFromBufferAttribute(s),this.morphTargetsRelative?(ca.addVectors(this.boundingBox.min,ao.min),this.boundingBox.expandByPoint(ca),ca.addVectors(this.boundingBox.max,ao.max),this.boundingBox.expandByPoint(ca)):(this.boundingBox.expandByPoint(ao.min),this.boundingBox.expandByPoint(ao.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 hc);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 qe,1/0);return}if(e){const r=this.boundingSphere.center;if(ao.setFromBufferAttribute(e),n)for(let s=0,o=n.length;s<o;s++){const l=n[s];Hb.setFromBufferAttribute(l),this.morphTargetsRelative?(ca.addVectors(ao.min,Hb.min),ao.expandByPoint(ca),ca.addVectors(ao.max,Hb.max),ao.expandByPoint(ca)):(ao.expandByPoint(Hb.min),ao.expandByPoint(Hb.max))}ao.getCenter(r);let i=0;for(let s=0,o=e.count;s<o;s++)ca.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(ca));if(n)for(let s=0,o=n.length;s<o;s++){const l=n[s],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)ca.fromBufferAttribute(l,u),c&&(Bp.fromBufferAttribute(e,u),ca.add(Bp)),i=Math.max(i,r.distanceToSquared(ca))}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,o=n.uv.array,l=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new go(new Float32Array(4*l),4));const c=this.getAttribute("tangent").array,u=[],d=[];for(let R=0;R<l;R++)u[R]=new qe,d[R]=new qe;const f=new qe,m=new qe,p=new qe,x=new xn,b=new xn,y=new xn,v=new qe,S=new qe;function N(R,F,O){f.fromArray(i,R*3),m.fromArray(i,F*3),p.fromArray(i,O*3),x.fromArray(o,R*2),b.fromArray(o,F*2),y.fromArray(o,O*2),m.sub(f),p.sub(f),b.sub(x),y.sub(x);const H=1/(b.x*y.y-y.x*b.y);isFinite(H)&&(v.copy(m).multiplyScalar(y.y).addScaledVector(p,-b.y).multiplyScalar(H),S.copy(p).multiplyScalar(b.x).addScaledVector(m,-y.x).multiplyScalar(H),u[R].add(v),u[F].add(v),u[O].add(v),d[R].add(S),d[F].add(S),d[O].add(S))}let C=this.groups;C.length===0&&(C=[{start:0,count:r.length}]);for(let R=0,F=C.length;R<F;++R){const O=C[R],H=O.start,j=O.count;for(let G=H,$=H+j;G<$;G+=3)N(r[G+0],r[G+1],r[G+2])}const T=new qe,k=new qe,E=new qe,D=new qe;function A(R){E.fromArray(s,R*3),D.copy(E);const F=u[R];T.copy(F),T.sub(E.multiplyScalar(E.dot(F))).normalize(),k.crossVectors(D,F);const H=k.dot(d[R])<0?-1:1;c[R*4]=T.x,c[R*4+1]=T.y,c[R*4+2]=T.z,c[R*4+3]=H}for(let R=0,F=C.length;R<F;++R){const O=C[R],H=O.start,j=O.count;for(let G=H,$=H+j;G<$;G+=3)A(r[G+0]),A(r[G+1]),A(r[G+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 go(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let m=0,p=r.count;m<p;m++)r.setXYZ(m,0,0,0);const i=new qe,s=new qe,o=new qe,l=new qe,c=new qe,u=new qe,d=new qe,f=new qe;if(e)for(let m=0,p=e.count;m<p;m+=3){const x=e.getX(m+0),b=e.getX(m+1),y=e.getX(m+2);i.fromBufferAttribute(n,x),s.fromBufferAttribute(n,b),o.fromBufferAttribute(n,y),d.subVectors(o,s),f.subVectors(i,s),d.cross(f),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,b),u.fromBufferAttribute(r,y),l.add(d),c.add(d),u.add(d),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(b,c.x,c.y,c.z),r.setXYZ(y,u.x,u.y,u.z)}else for(let m=0,p=n.count;m<p;m+=3)i.fromBufferAttribute(n,m+0),s.fromBufferAttribute(n,m+1),o.fromBufferAttribute(n,m+2),d.subVectors(o,s),f.subVectors(i,s),d.cross(f),r.setXYZ(m+0,d.x,d.y,d.z),r.setXYZ(m+1,d.x,d.y,d.z),r.setXYZ(m+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++)ca.fromBufferAttribute(e,n),ca.normalize(),e.setXYZ(n,ca.x,ca.y,ca.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,m=new u.constructor(c.length*d);let p=0,x=0;for(let b=0,y=c.length;b<y;b++){l.isInterleavedBufferAttribute?p=c[b]*l.data.stride+l.offset:p=c[b]*d;for(let v=0;v<d;v++)m[x++]=u[p++]}return new go(m,d,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new Ja,r=this.index.array,i=this.attributes;for(const l in i){const c=i[l],u=e(c,r);n.setAttribute(l,u)}const s=this.morphAttributes;for(const l in s){const c=[],u=s[l];for(let d=0,f=u.length;d<f;d++){const m=u[d],p=e(m,r);c.push(p)}n.morphAttributes[l]=c}n.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let l=0,c=o.length;l<c;l++){const u=o[l];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let s=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,m=u.length;f<m;f++){const p=u[f];d.push(p.toJSON(e.data))}d.length>0&&(i[c]=d,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere={center:l.center.toArray(),radius:l.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 m=0,p=f.length;m<p;m++)d.push(f[m].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let u=0,d=o.length;u<d;u++){const f=o[u];this.addGroup(f.start,f.count,f.materialIndex)}const l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const W8=new Fr,pf=new o4,gw=new hc,K8=new qe,$p=new qe,Hp=new qe,Vp=new qe,sA=new qe,xw=new qe,bw=new xn,yw=new xn,vw=new xn,X8=new qe,Y8=new qe,Q8=new qe,_w=new qe,ww=new qe;class Rl extends ys{constructor(e=new Ja,n=new WK){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,o=i.length;s<o;s++){const l=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=s}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,o=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(s&&l){xw.set(0,0,0);for(let c=0,u=s.length;c<u;c++){const d=l[c],f=s[c];d!==0&&(sA.fromBufferAttribute(f,e),o?xw.addScaledVector(sA,d):xw.addScaledVector(sA.sub(n),d))}n.add(xw)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),gw.copy(r.boundingSphere),gw.applyMatrix4(s),pf.copy(e.ray).recast(e.near),!(gw.containsPoint(pf.origin)===!1&&(pf.intersectSphere(gw,K8)===null||pf.origin.distanceToSquared(K8)>(e.far-e.near)**2))&&(W8.copy(s).invert(),pf.copy(e.ray).applyMatrix4(W8),!(r.boundingBox!==null&&pf.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,pf)))}_computeIntersections(e,n,r){let i;const s=this.geometry,o=this.material,l=s.index,c=s.attributes.position,u=s.attributes.uv,d=s.attributes.uv1,f=s.attributes.normal,m=s.groups,p=s.drawRange;if(l!==null)if(Array.isArray(o))for(let x=0,b=m.length;x<b;x++){const y=m[x],v=o[y.materialIndex],S=Math.max(y.start,p.start),N=Math.min(l.count,Math.min(y.start+y.count,p.start+p.count));for(let C=S,T=N;C<T;C+=3){const k=l.getX(C),E=l.getX(C+1),D=l.getX(C+2);i=Sw(this,v,e,r,u,d,f,k,E,D),i&&(i.faceIndex=Math.floor(C/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),b=Math.min(l.count,p.start+p.count);for(let y=x,v=b;y<v;y+=3){const S=l.getX(y),N=l.getX(y+1),C=l.getX(y+2);i=Sw(this,o,e,r,u,d,f,S,N,C),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,b=m.length;x<b;x++){const y=m[x],v=o[y.materialIndex],S=Math.max(y.start,p.start),N=Math.min(c.count,Math.min(y.start+y.count,p.start+p.count));for(let C=S,T=N;C<T;C+=3){const k=C,E=C+1,D=C+2;i=Sw(this,v,e,r,u,d,f,k,E,D),i&&(i.faceIndex=Math.floor(C/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),b=Math.min(c.count,p.start+p.count);for(let y=x,v=b;y<v;y+=3){const S=y,N=y+1,C=y+2;i=Sw(this,o,e,r,u,d,f,S,N,C),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}}}function i_e(t,e,n,r,i,s,o,l){let c;if(e.side===Bs?c=r.intersectTriangle(o,s,i,!0,l):c=r.intersectTriangle(i,s,o,e.side===Sh,l),c===null)return null;ww.copy(l),ww.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(ww);return u<n.near||u>n.far?null:{distance:u,point:ww.clone(),object:t}}function Sw(t,e,n,r,i,s,o,l,c,u){t.getVertexPosition(l,$p),t.getVertexPosition(c,Hp),t.getVertexPosition(u,Vp);const d=i_e(t,e,n,r,$p,Hp,Vp,_w);if(d){i&&(bw.fromBufferAttribute(i,l),yw.fromBufferAttribute(i,c),vw.fromBufferAttribute(i,u),d.uv=El.getInterpolation(_w,$p,Hp,Vp,bw,yw,vw,new xn)),s&&(bw.fromBufferAttribute(s,l),yw.fromBufferAttribute(s,c),vw.fromBufferAttribute(s,u),d.uv1=El.getInterpolation(_w,$p,Hp,Vp,bw,yw,vw,new xn),d.uv2=d.uv1),o&&(X8.fromBufferAttribute(o,l),Y8.fromBufferAttribute(o,c),Q8.fromBufferAttribute(o,u),d.normal=El.getInterpolation(_w,$p,Hp,Vp,X8,Y8,Q8,new qe),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const f={a:l,b:c,c:u,normal:new qe,materialIndex:0};El.getNormal($p,Hp,Vp,f.normal),d.face=f}return d}class By extends Ja{constructor(e=1,n=1,r=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:s,depthSegments:o};const l=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const c=[],u=[],d=[],f=[];let m=0,p=0;x("z","y","x",-1,-1,r,n,e,o,s,0),x("z","y","x",1,-1,r,n,-e,o,s,1),x("x","z","y",1,1,e,r,n,i,o,2),x("x","z","y",1,-1,e,r,-n,i,o,3),x("x","y","z",1,-1,e,n,r,i,s,4),x("x","y","z",-1,-1,e,n,-r,i,s,5),this.setIndex(c),this.setAttribute("position",new wi(u,3)),this.setAttribute("normal",new wi(d,3)),this.setAttribute("uv",new wi(f,2));function x(b,y,v,S,N,C,T,k,E,D,A){const R=C/E,F=T/D,O=C/2,H=T/2,j=k/2,G=E+1,$=D+1;let q=0,Y=0;const Z=new qe;for(let oe=0;oe<$;oe++){const B=oe*F-H;for(let W=0;W<G;W++){const se=W*R-O;Z[b]=se*S,Z[y]=B*N,Z[v]=j,u.push(Z.x,Z.y,Z.z),Z[b]=0,Z[y]=0,Z[v]=k>0?1:-1,d.push(Z.x,Z.y,Z.z),f.push(W/E),f.push(1-oe/D),q+=1}}for(let oe=0;oe<D;oe++)for(let B=0;B<E;B++){const W=m+B+G*oe,se=m+B+G*(oe+1),ne=m+(B+1)+G*(oe+1),ce=m+(B+1)+G*oe;c.push(W,se,ce),c.push(se,ne,ce),Y+=6}l.addGroup(p,Y,A),p+=Y,m+=q}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new By(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Qg(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 ds(t){const e={};for(let n=0;n<t.length;n++){const r=Qg(t[n]);for(const i in r)e[i]=r[i]}return e}function a_e(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function YK(t){return t.getRenderTarget()===null?t.outputColorSpace:Er.workingColorSpace}const l4={clone:Qg,merge:ds};var s_e=`void main() {
  3840. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  3841. }`,o_e=`void main() {
  3842. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  3843. }`;class Nh extends wx{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=s_e,this.fragmentShader=o_e,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=Qg(e.uniforms),this.uniformsGroups=a_e(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 o=this.uniforms[i].value;o&&o.isTexture?n.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?n.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?n.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?n.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?n.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?n.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?n.uniforms[i]={type:"m4",value:o.toArray()}:n.uniforms[i]={value:o}}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 QK extends ys{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Fr,this.projectionMatrix=new Fr,this.projectionMatrixInverse=new Fr,this.coordinateSystem=cc}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 lo extends QK{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=ry*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(v0*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ry*2*Math.atan(Math.tan(v0*.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,o){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=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(v0*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,s=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,u=o.fullHeight;s+=o.offsetX*i/c,n-=o.offsetY*r/u,i*=o.width/c,r*=o.height/u}const l=this.filmOffset;l!==0&&(s+=e*l/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 Gp=-90,qp=1;class l_e extends ys{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new lo(Gp,qp,e,n);i.layers=this.layers,this.add(i);const s=new lo(Gp,qp,e,n);s.layers=this.layers,this.add(s);const o=new lo(Gp,qp,e,n);o.layers=this.layers,this.add(o);const l=new lo(Gp,qp,e,n);l.layers=this.layers,this.add(l);const c=new lo(Gp,qp,e,n);c.layers=this.layers,this.add(c);const u=new lo(Gp,qp,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,s,o,l,c]=n;for(const u of n)this.remove(u);if(e===cc)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),o.up.set(0,0,1),o.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===ny)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),o.up.set(0,0,-1),o.lookAt(0,-1,0),l.up.set(0,-1,0),l.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,o,l,c,u,d]=this.children,f=e.getRenderTarget(),m=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const b=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,s),e.setRenderTarget(r,1,i),e.render(n,o),e.setRenderTarget(r,2,i),e.render(n,l),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=b,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,m,p),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}}class ZK extends $s{constructor(e,n,r,i,s,o,l,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:Kg,super(e,n,r,i,s,o,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class c_e extends dm{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&&(w0("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Hf?ja:Xo),this.texture=new ZK(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:Wo}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:`
  3844. varying vec3 vWorldDirection;
  3845. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  3846. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  3847. }
  3848. void main() {
  3849. vWorldDirection = transformDirection( position, modelMatrix );
  3850. #include <begin_vertex>
  3851. #include <project_vertex>
  3852. }
  3853. `,fragmentShader:`
  3854. uniform sampler2D tEquirect;
  3855. varying vec3 vWorldDirection;
  3856. #include <common>
  3857. void main() {
  3858. vec3 direction = normalize( vWorldDirection );
  3859. vec2 sampleUV = equirectUv( direction );
  3860. gl_FragColor = texture2D( tEquirect, sampleUV );
  3861. }
  3862. `},i=new By(5,5,5),s=new Nh({name:"CubemapFromEquirect",uniforms:Qg(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Bs,blending:lh});s.uniforms.tEquirect.value=n;const o=new Rl(i,s),l=n.minFilter;return n.minFilter===ey&&(n.minFilter=Wo),new l_e(1,10,this).update(e,o),n.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,n,r,i){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(n,r,i);e.setRenderTarget(s)}}const oA=new qe,u_e=new qe,d_e=new Ln;class Ud{constructor(e=new qe(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=oA.subVectors(r,n).cross(u_e.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(oA),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||d_e.getNormalMatrix(e),i=this.coplanarPoint(oA).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 gf=new hc,Nw=new qe;class TN{constructor(e=new Ud,n=new Ud,r=new Ud,i=new Ud,s=new Ud,o=new Ud){this.planes=[e,n,r,i,s,o]}set(e,n,r,i,s,o){const l=this.planes;return l[0].copy(e),l[1].copy(n),l[2].copy(r),l[3].copy(i),l[4].copy(s),l[5].copy(o),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=cc){const r=this.planes,i=e.elements,s=i[0],o=i[1],l=i[2],c=i[3],u=i[4],d=i[5],f=i[6],m=i[7],p=i[8],x=i[9],b=i[10],y=i[11],v=i[12],S=i[13],N=i[14],C=i[15];if(r[0].setComponents(c-s,m-u,y-p,C-v).normalize(),r[1].setComponents(c+s,m+u,y+p,C+v).normalize(),r[2].setComponents(c+o,m+d,y+x,C+S).normalize(),r[3].setComponents(c-o,m-d,y-x,C-S).normalize(),r[4].setComponents(c-l,m-f,y-b,C-N).normalize(),n===cc)r[5].setComponents(c+l,m+f,y+b,C+N).normalize();else if(n===ny)r[5].setComponents(l,f,b,N).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(),gf.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),gf.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(gf)}intersectsSprite(e){return gf.center.set(0,0,0),gf.radius=.7071067811865476,gf.applyMatrix4(e.matrixWorld),this.intersectsSphere(gf)}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(Nw.x=i.normal.x>0?e.max.x:e.min.x,Nw.y=i.normal.y>0?e.max.y:e.min.y,Nw.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Nw)<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 JK(){let t=null,e=!1,n=null,r=null;function i(s,o){n(s,o),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 h_e(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const f=u.array,m=u.usage,p=f.byteLength,x=t.createBuffer();t.bindBuffer(d,x),t.bufferData(d,f,m),u.onUploadCallback();let b;if(f instanceof Float32Array)b=t.FLOAT;else if(f instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(n)b=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else b=t.UNSIGNED_SHORT;else if(f instanceof Int16Array)b=t.SHORT;else if(f instanceof Uint32Array)b=t.UNSIGNED_INT;else if(f instanceof Int32Array)b=t.INT;else if(f instanceof Int8Array)b=t.BYTE;else if(f instanceof Uint8Array)b=t.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)b=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:x,type:b,bytesPerElement:f.BYTES_PER_ELEMENT,version:u.version,size:p}}function s(u,d,f){const m=d.array,p=d._updateRange,x=d.updateRanges;if(t.bindBuffer(f,u),p.count===-1&&x.length===0&&t.bufferSubData(f,0,m),x.length!==0){for(let b=0,y=x.length;b<y;b++){const v=x[b];n?t.bufferSubData(f,v.start*m.BYTES_PER_ELEMENT,m,v.start,v.count):t.bufferSubData(f,v.start*m.BYTES_PER_ELEMENT,m.subarray(v.start,v.start+v.count))}d.clearUpdateRanges()}p.count!==-1&&(n?t.bufferSubData(f,p.offset*m.BYTES_PER_ELEMENT,m,p.offset,p.count):t.bufferSubData(f,p.offset*m.BYTES_PER_ELEMENT,m.subarray(p.offset,p.offset+p.count)),p.count=-1),d.onUploadCallback()}function o(u){return u.isInterleavedBufferAttribute&&(u=u.data),r.get(u)}function l(u){u.isInterleavedBufferAttribute&&(u=u.data);const d=r.get(u);d&&(t.deleteBuffer(d.buffer),r.delete(u))}function c(u,d){if(u.isGLBufferAttribute){const m=r.get(u);(!m||m.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:o,remove:l,update:c}}class c4 extends Ja{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,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,m=n/c,p=[],x=[],b=[],y=[];for(let v=0;v<d;v++){const S=v*m-o;for(let N=0;N<u;N++){const C=N*f-s;x.push(C,-S,0),b.push(0,0,1),y.push(N/l),y.push(1-v/c)}}for(let v=0;v<c;v++)for(let S=0;S<l;S++){const N=S+u*v,C=S+u*(v+1),T=S+1+u*(v+1),k=S+1+u*v;p.push(N,C,k),p.push(C,T,k)}this.setIndex(p),this.setAttribute("position",new wi(x,3)),this.setAttribute("normal",new wi(b,3)),this.setAttribute("uv",new wi(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new c4(e.width,e.height,e.widthSegments,e.heightSegments)}}var f_e=`#ifdef USE_ALPHAHASH
  3863. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  3864. #endif`,m_e=`#ifdef USE_ALPHAHASH
  3865. const float ALPHA_HASH_SCALE = 0.05;
  3866. float hash2D( vec2 value ) {
  3867. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  3868. }
  3869. float hash3D( vec3 value ) {
  3870. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  3871. }
  3872. float getAlphaHashThreshold( vec3 position ) {
  3873. float maxDeriv = max(
  3874. length( dFdx( position.xyz ) ),
  3875. length( dFdy( position.xyz ) )
  3876. );
  3877. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  3878. vec2 pixScales = vec2(
  3879. exp2( floor( log2( pixScale ) ) ),
  3880. exp2( ceil( log2( pixScale ) ) )
  3881. );
  3882. vec2 alpha = vec2(
  3883. hash3D( floor( pixScales.x * position.xyz ) ),
  3884. hash3D( floor( pixScales.y * position.xyz ) )
  3885. );
  3886. float lerpFactor = fract( log2( pixScale ) );
  3887. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  3888. float a = min( lerpFactor, 1.0 - lerpFactor );
  3889. vec3 cases = vec3(
  3890. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  3891. ( x - 0.5 * a ) / ( 1.0 - a ),
  3892. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  3893. );
  3894. float threshold = ( x < ( 1.0 - a ) )
  3895. ? ( ( x < a ) ? cases.x : cases.y )
  3896. : cases.z;
  3897. return clamp( threshold , 1.0e-6, 1.0 );
  3898. }
  3899. #endif`,p_e=`#ifdef USE_ALPHAMAP
  3900. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  3901. #endif`,g_e=`#ifdef USE_ALPHAMAP
  3902. uniform sampler2D alphaMap;
  3903. #endif`,x_e=`#ifdef USE_ALPHATEST
  3904. if ( diffuseColor.a < alphaTest ) discard;
  3905. #endif`,b_e=`#ifdef USE_ALPHATEST
  3906. uniform float alphaTest;
  3907. #endif`,y_e=`#ifdef USE_AOMAP
  3908. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  3909. reflectedLight.indirectDiffuse *= ambientOcclusion;
  3910. #if defined( USE_CLEARCOAT )
  3911. clearcoatSpecularIndirect *= ambientOcclusion;
  3912. #endif
  3913. #if defined( USE_SHEEN )
  3914. sheenSpecularIndirect *= ambientOcclusion;
  3915. #endif
  3916. #if defined( USE_ENVMAP ) && defined( STANDARD )
  3917. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  3918. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  3919. #endif
  3920. #endif`,v_e=`#ifdef USE_AOMAP
  3921. uniform sampler2D aoMap;
  3922. uniform float aoMapIntensity;
  3923. #endif`,__e=`#ifdef USE_BATCHING
  3924. attribute float batchId;
  3925. uniform highp sampler2D batchingTexture;
  3926. mat4 getBatchingMatrix( const in float i ) {
  3927. int size = textureSize( batchingTexture, 0 ).x;
  3928. int j = int( i ) * 4;
  3929. int x = j % size;
  3930. int y = j / size;
  3931. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  3932. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  3933. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  3934. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  3935. return mat4( v1, v2, v3, v4 );
  3936. }
  3937. #endif`,w_e=`#ifdef USE_BATCHING
  3938. mat4 batchingMatrix = getBatchingMatrix( batchId );
  3939. #endif`,S_e=`vec3 transformed = vec3( position );
  3940. #ifdef USE_ALPHAHASH
  3941. vPosition = vec3( position );
  3942. #endif`,N_e=`vec3 objectNormal = vec3( normal );
  3943. #ifdef USE_TANGENT
  3944. vec3 objectTangent = vec3( tangent.xyz );
  3945. #endif`,M_e=`float G_BlinnPhong_Implicit( ) {
  3946. return 0.25;
  3947. }
  3948. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  3949. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  3950. }
  3951. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  3952. vec3 halfDir = normalize( lightDir + viewDir );
  3953. float dotNH = saturate( dot( normal, halfDir ) );
  3954. float dotVH = saturate( dot( viewDir, halfDir ) );
  3955. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  3956. float G = G_BlinnPhong_Implicit( );
  3957. float D = D_BlinnPhong( shininess, dotNH );
  3958. return F * ( G * D );
  3959. } // validated`,E_e=`#ifdef USE_IRIDESCENCE
  3960. const mat3 XYZ_TO_REC709 = mat3(
  3961. 3.2404542, -0.9692660, 0.0556434,
  3962. -1.5371385, 1.8760108, -0.2040259,
  3963. -0.4985314, 0.0415560, 1.0572252
  3964. );
  3965. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  3966. vec3 sqrtF0 = sqrt( fresnel0 );
  3967. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  3968. }
  3969. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  3970. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  3971. }
  3972. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  3973. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  3974. }
  3975. vec3 evalSensitivity( float OPD, vec3 shift ) {
  3976. float phase = 2.0 * PI * OPD * 1.0e-9;
  3977. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  3978. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  3979. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  3980. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  3981. 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 ) );
  3982. xyz /= 1.0685e-7;
  3983. vec3 rgb = XYZ_TO_REC709 * xyz;
  3984. return rgb;
  3985. }
  3986. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  3987. vec3 I;
  3988. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  3989. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  3990. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  3991. if ( cosTheta2Sq < 0.0 ) {
  3992. return vec3( 1.0 );
  3993. }
  3994. float cosTheta2 = sqrt( cosTheta2Sq );
  3995. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  3996. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  3997. float T121 = 1.0 - R12;
  3998. float phi12 = 0.0;
  3999. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  4000. float phi21 = PI - phi12;
  4001. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  4002. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  4003. vec3 phi23 = vec3( 0.0 );
  4004. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  4005. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  4006. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  4007. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  4008. vec3 phi = vec3( phi21 ) + phi23;
  4009. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  4010. vec3 r123 = sqrt( R123 );
  4011. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  4012. vec3 C0 = R12 + Rs;
  4013. I = C0;
  4014. vec3 Cm = Rs - T121;
  4015. for ( int m = 1; m <= 2; ++ m ) {
  4016. Cm *= r123;
  4017. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  4018. I += Cm * Sm;
  4019. }
  4020. return max( I, vec3( 0.0 ) );
  4021. }
  4022. #endif`,C_e=`#ifdef USE_BUMPMAP
  4023. uniform sampler2D bumpMap;
  4024. uniform float bumpScale;
  4025. vec2 dHdxy_fwd() {
  4026. vec2 dSTdx = dFdx( vBumpMapUv );
  4027. vec2 dSTdy = dFdy( vBumpMapUv );
  4028. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  4029. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  4030. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  4031. return vec2( dBx, dBy );
  4032. }
  4033. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  4034. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  4035. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  4036. vec3 vN = surf_norm;
  4037. vec3 R1 = cross( vSigmaY, vN );
  4038. vec3 R2 = cross( vN, vSigmaX );
  4039. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  4040. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  4041. return normalize( abs( fDet ) * surf_norm - vGrad );
  4042. }
  4043. #endif`,T_e=`#if NUM_CLIPPING_PLANES > 0
  4044. vec4 plane;
  4045. #pragma unroll_loop_start
  4046. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  4047. plane = clippingPlanes[ i ];
  4048. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  4049. }
  4050. #pragma unroll_loop_end
  4051. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  4052. bool clipped = true;
  4053. #pragma unroll_loop_start
  4054. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  4055. plane = clippingPlanes[ i ];
  4056. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  4057. }
  4058. #pragma unroll_loop_end
  4059. if ( clipped ) discard;
  4060. #endif
  4061. #endif`,A_e=`#if NUM_CLIPPING_PLANES > 0
  4062. varying vec3 vClipPosition;
  4063. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  4064. #endif`,k_e=`#if NUM_CLIPPING_PLANES > 0
  4065. varying vec3 vClipPosition;
  4066. #endif`,j_e=`#if NUM_CLIPPING_PLANES > 0
  4067. vClipPosition = - mvPosition.xyz;
  4068. #endif`,P_e=`#if defined( USE_COLOR_ALPHA )
  4069. diffuseColor *= vColor;
  4070. #elif defined( USE_COLOR )
  4071. diffuseColor.rgb *= vColor;
  4072. #endif`,R_e=`#if defined( USE_COLOR_ALPHA )
  4073. varying vec4 vColor;
  4074. #elif defined( USE_COLOR )
  4075. varying vec3 vColor;
  4076. #endif`,D_e=`#if defined( USE_COLOR_ALPHA )
  4077. varying vec4 vColor;
  4078. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4079. varying vec3 vColor;
  4080. #endif`,O_e=`#if defined( USE_COLOR_ALPHA )
  4081. vColor = vec4( 1.0 );
  4082. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4083. vColor = vec3( 1.0 );
  4084. #endif
  4085. #ifdef USE_COLOR
  4086. vColor *= color;
  4087. #endif
  4088. #ifdef USE_INSTANCING_COLOR
  4089. vColor.xyz *= instanceColor.xyz;
  4090. #endif`,L_e=`#define PI 3.141592653589793
  4091. #define PI2 6.283185307179586
  4092. #define PI_HALF 1.5707963267948966
  4093. #define RECIPROCAL_PI 0.3183098861837907
  4094. #define RECIPROCAL_PI2 0.15915494309189535
  4095. #define EPSILON 1e-6
  4096. #ifndef saturate
  4097. #define saturate( a ) clamp( a, 0.0, 1.0 )
  4098. #endif
  4099. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  4100. float pow2( const in float x ) { return x*x; }
  4101. vec3 pow2( const in vec3 x ) { return x*x; }
  4102. float pow3( const in float x ) { return x*x*x; }
  4103. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  4104. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  4105. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  4106. highp float rand( const in vec2 uv ) {
  4107. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  4108. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  4109. return fract( sin( sn ) * c );
  4110. }
  4111. #ifdef HIGH_PRECISION
  4112. float precisionSafeLength( vec3 v ) { return length( v ); }
  4113. #else
  4114. float precisionSafeLength( vec3 v ) {
  4115. float maxComponent = max3( abs( v ) );
  4116. return length( v / maxComponent ) * maxComponent;
  4117. }
  4118. #endif
  4119. struct IncidentLight {
  4120. vec3 color;
  4121. vec3 direction;
  4122. bool visible;
  4123. };
  4124. struct ReflectedLight {
  4125. vec3 directDiffuse;
  4126. vec3 directSpecular;
  4127. vec3 indirectDiffuse;
  4128. vec3 indirectSpecular;
  4129. };
  4130. #ifdef USE_ALPHAHASH
  4131. varying vec3 vPosition;
  4132. #endif
  4133. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  4134. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  4135. }
  4136. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  4137. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  4138. }
  4139. mat3 transposeMat3( const in mat3 m ) {
  4140. mat3 tmp;
  4141. tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
  4142. tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
  4143. tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
  4144. return tmp;
  4145. }
  4146. float luminance( const in vec3 rgb ) {
  4147. const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
  4148. return dot( weights, rgb );
  4149. }
  4150. bool isPerspectiveMatrix( mat4 m ) {
  4151. return m[ 2 ][ 3 ] == - 1.0;
  4152. }
  4153. vec2 equirectUv( in vec3 dir ) {
  4154. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  4155. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  4156. return vec2( u, v );
  4157. }
  4158. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  4159. return RECIPROCAL_PI * diffuseColor;
  4160. }
  4161. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  4162. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4163. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4164. }
  4165. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  4166. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4167. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4168. } // validated`,I_e=`#ifdef ENVMAP_TYPE_CUBE_UV
  4169. #define cubeUV_minMipLevel 4.0
  4170. #define cubeUV_minTileSize 16.0
  4171. float getFace( vec3 direction ) {
  4172. vec3 absDirection = abs( direction );
  4173. float face = - 1.0;
  4174. if ( absDirection.x > absDirection.z ) {
  4175. if ( absDirection.x > absDirection.y )
  4176. face = direction.x > 0.0 ? 0.0 : 3.0;
  4177. else
  4178. face = direction.y > 0.0 ? 1.0 : 4.0;
  4179. } else {
  4180. if ( absDirection.z > absDirection.y )
  4181. face = direction.z > 0.0 ? 2.0 : 5.0;
  4182. else
  4183. face = direction.y > 0.0 ? 1.0 : 4.0;
  4184. }
  4185. return face;
  4186. }
  4187. vec2 getUV( vec3 direction, float face ) {
  4188. vec2 uv;
  4189. if ( face == 0.0 ) {
  4190. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  4191. } else if ( face == 1.0 ) {
  4192. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  4193. } else if ( face == 2.0 ) {
  4194. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  4195. } else if ( face == 3.0 ) {
  4196. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  4197. } else if ( face == 4.0 ) {
  4198. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  4199. } else {
  4200. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  4201. }
  4202. return 0.5 * ( uv + 1.0 );
  4203. }
  4204. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  4205. float face = getFace( direction );
  4206. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  4207. mipInt = max( mipInt, cubeUV_minMipLevel );
  4208. float faceSize = exp2( mipInt );
  4209. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  4210. if ( face > 2.0 ) {
  4211. uv.y += faceSize;
  4212. face -= 3.0;
  4213. }
  4214. uv.x += face * faceSize;
  4215. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  4216. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  4217. uv.x *= CUBEUV_TEXEL_WIDTH;
  4218. uv.y *= CUBEUV_TEXEL_HEIGHT;
  4219. #ifdef texture2DGradEXT
  4220. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  4221. #else
  4222. return texture2D( envMap, uv ).rgb;
  4223. #endif
  4224. }
  4225. #define cubeUV_r0 1.0
  4226. #define cubeUV_v0 0.339
  4227. #define cubeUV_m0 - 2.0
  4228. #define cubeUV_r1 0.8
  4229. #define cubeUV_v1 0.276
  4230. #define cubeUV_m1 - 1.0
  4231. #define cubeUV_r4 0.4
  4232. #define cubeUV_v4 0.046
  4233. #define cubeUV_m4 2.0
  4234. #define cubeUV_r5 0.305
  4235. #define cubeUV_v5 0.016
  4236. #define cubeUV_m5 3.0
  4237. #define cubeUV_r6 0.21
  4238. #define cubeUV_v6 0.0038
  4239. #define cubeUV_m6 4.0
  4240. float roughnessToMip( float roughness ) {
  4241. float mip = 0.0;
  4242. if ( roughness >= cubeUV_r1 ) {
  4243. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  4244. } else if ( roughness >= cubeUV_r4 ) {
  4245. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  4246. } else if ( roughness >= cubeUV_r5 ) {
  4247. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  4248. } else if ( roughness >= cubeUV_r6 ) {
  4249. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  4250. } else {
  4251. mip = - 2.0 * log2( 1.16 * roughness ); }
  4252. return mip;
  4253. }
  4254. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  4255. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  4256. float mipF = fract( mip );
  4257. float mipInt = floor( mip );
  4258. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  4259. if ( mipF == 0.0 ) {
  4260. return vec4( color0, 1.0 );
  4261. } else {
  4262. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  4263. return vec4( mix( color0, color1, mipF ), 1.0 );
  4264. }
  4265. }
  4266. #endif`,F_e=`vec3 transformedNormal = objectNormal;
  4267. #ifdef USE_TANGENT
  4268. vec3 transformedTangent = objectTangent;
  4269. #endif
  4270. #ifdef USE_BATCHING
  4271. mat3 bm = mat3( batchingMatrix );
  4272. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  4273. transformedNormal = bm * transformedNormal;
  4274. #ifdef USE_TANGENT
  4275. transformedTangent = bm * transformedTangent;
  4276. #endif
  4277. #endif
  4278. #ifdef USE_INSTANCING
  4279. mat3 im = mat3( instanceMatrix );
  4280. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  4281. transformedNormal = im * transformedNormal;
  4282. #ifdef USE_TANGENT
  4283. transformedTangent = im * transformedTangent;
  4284. #endif
  4285. #endif
  4286. transformedNormal = normalMatrix * transformedNormal;
  4287. #ifdef FLIP_SIDED
  4288. transformedNormal = - transformedNormal;
  4289. #endif
  4290. #ifdef USE_TANGENT
  4291. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  4292. #ifdef FLIP_SIDED
  4293. transformedTangent = - transformedTangent;
  4294. #endif
  4295. #endif`,U_e=`#ifdef USE_DISPLACEMENTMAP
  4296. uniform sampler2D displacementMap;
  4297. uniform float displacementScale;
  4298. uniform float displacementBias;
  4299. #endif`,z_e=`#ifdef USE_DISPLACEMENTMAP
  4300. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  4301. #endif`,B_e=`#ifdef USE_EMISSIVEMAP
  4302. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  4303. totalEmissiveRadiance *= emissiveColor.rgb;
  4304. #endif`,$_e=`#ifdef USE_EMISSIVEMAP
  4305. uniform sampler2D emissiveMap;
  4306. #endif`,H_e="gl_FragColor = linearToOutputTexel( gl_FragColor );",V_e=`
  4307. const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
  4308. vec3( 0.8224621, 0.177538, 0.0 ),
  4309. vec3( 0.0331941, 0.9668058, 0.0 ),
  4310. vec3( 0.0170827, 0.0723974, 0.9105199 )
  4311. );
  4312. const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
  4313. vec3( 1.2249401, - 0.2249404, 0.0 ),
  4314. vec3( - 0.0420569, 1.0420571, 0.0 ),
  4315. vec3( - 0.0196376, - 0.0786361, 1.0982735 )
  4316. );
  4317. vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
  4318. return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
  4319. }
  4320. vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
  4321. return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
  4322. }
  4323. vec4 LinearTransferOETF( in vec4 value ) {
  4324. return value;
  4325. }
  4326. vec4 sRGBTransferOETF( in vec4 value ) {
  4327. 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 );
  4328. }
  4329. vec4 LinearToLinear( in vec4 value ) {
  4330. return value;
  4331. }
  4332. vec4 LinearTosRGB( in vec4 value ) {
  4333. return sRGBTransferOETF( value );
  4334. }`,G_e=`#ifdef USE_ENVMAP
  4335. #ifdef ENV_WORLDPOS
  4336. vec3 cameraToFrag;
  4337. if ( isOrthographic ) {
  4338. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4339. } else {
  4340. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  4341. }
  4342. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4343. #ifdef ENVMAP_MODE_REFLECTION
  4344. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  4345. #else
  4346. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  4347. #endif
  4348. #else
  4349. vec3 reflectVec = vReflect;
  4350. #endif
  4351. #ifdef ENVMAP_TYPE_CUBE
  4352. vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  4353. #else
  4354. vec4 envColor = vec4( 0.0 );
  4355. #endif
  4356. #ifdef ENVMAP_BLENDING_MULTIPLY
  4357. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  4358. #elif defined( ENVMAP_BLENDING_MIX )
  4359. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  4360. #elif defined( ENVMAP_BLENDING_ADD )
  4361. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  4362. #endif
  4363. #endif`,q_e=`#ifdef USE_ENVMAP
  4364. uniform float envMapIntensity;
  4365. uniform float flipEnvMap;
  4366. #ifdef ENVMAP_TYPE_CUBE
  4367. uniform samplerCube envMap;
  4368. #else
  4369. uniform sampler2D envMap;
  4370. #endif
  4371. #endif`,W_e=`#ifdef USE_ENVMAP
  4372. uniform float reflectivity;
  4373. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4374. #define ENV_WORLDPOS
  4375. #endif
  4376. #ifdef ENV_WORLDPOS
  4377. varying vec3 vWorldPosition;
  4378. uniform float refractionRatio;
  4379. #else
  4380. varying vec3 vReflect;
  4381. #endif
  4382. #endif`,K_e=`#ifdef USE_ENVMAP
  4383. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4384. #define ENV_WORLDPOS
  4385. #endif
  4386. #ifdef ENV_WORLDPOS
  4387. varying vec3 vWorldPosition;
  4388. #else
  4389. varying vec3 vReflect;
  4390. uniform float refractionRatio;
  4391. #endif
  4392. #endif`,X_e=`#ifdef USE_ENVMAP
  4393. #ifdef ENV_WORLDPOS
  4394. vWorldPosition = worldPosition.xyz;
  4395. #else
  4396. vec3 cameraToVertex;
  4397. if ( isOrthographic ) {
  4398. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4399. } else {
  4400. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  4401. }
  4402. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  4403. #ifdef ENVMAP_MODE_REFLECTION
  4404. vReflect = reflect( cameraToVertex, worldNormal );
  4405. #else
  4406. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  4407. #endif
  4408. #endif
  4409. #endif`,Y_e=`#ifdef USE_FOG
  4410. vFogDepth = - mvPosition.z;
  4411. #endif`,Q_e=`#ifdef USE_FOG
  4412. varying float vFogDepth;
  4413. #endif`,Z_e=`#ifdef USE_FOG
  4414. #ifdef FOG_EXP2
  4415. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  4416. #else
  4417. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  4418. #endif
  4419. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  4420. #endif`,J_e=`#ifdef USE_FOG
  4421. uniform vec3 fogColor;
  4422. varying float vFogDepth;
  4423. #ifdef FOG_EXP2
  4424. uniform float fogDensity;
  4425. #else
  4426. uniform float fogNear;
  4427. uniform float fogFar;
  4428. #endif
  4429. #endif`,ewe=`#ifdef USE_GRADIENTMAP
  4430. uniform sampler2D gradientMap;
  4431. #endif
  4432. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  4433. float dotNL = dot( normal, lightDirection );
  4434. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  4435. #ifdef USE_GRADIENTMAP
  4436. return vec3( texture2D( gradientMap, coord ).r );
  4437. #else
  4438. vec2 fw = fwidth( coord ) * 0.5;
  4439. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  4440. #endif
  4441. }`,twe=`#ifdef USE_LIGHTMAP
  4442. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  4443. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  4444. reflectedLight.indirectDiffuse += lightMapIrradiance;
  4445. #endif`,nwe=`#ifdef USE_LIGHTMAP
  4446. uniform sampler2D lightMap;
  4447. uniform float lightMapIntensity;
  4448. #endif`,rwe=`LambertMaterial material;
  4449. material.diffuseColor = diffuseColor.rgb;
  4450. material.specularStrength = specularStrength;`,iwe=`varying vec3 vViewPosition;
  4451. struct LambertMaterial {
  4452. vec3 diffuseColor;
  4453. float specularStrength;
  4454. };
  4455. 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 ) {
  4456. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4457. vec3 irradiance = dotNL * directLight.color;
  4458. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4459. }
  4460. 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 ) {
  4461. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4462. }
  4463. #define RE_Direct RE_Direct_Lambert
  4464. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,awe=`uniform bool receiveShadow;
  4465. uniform vec3 ambientLightColor;
  4466. #if defined( USE_LIGHT_PROBES )
  4467. uniform vec3 lightProbe[ 9 ];
  4468. #endif
  4469. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  4470. float x = normal.x, y = normal.y, z = normal.z;
  4471. vec3 result = shCoefficients[ 0 ] * 0.886227;
  4472. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  4473. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  4474. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  4475. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  4476. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  4477. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  4478. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  4479. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  4480. return result;
  4481. }
  4482. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  4483. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4484. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  4485. return irradiance;
  4486. }
  4487. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  4488. vec3 irradiance = ambientLightColor;
  4489. return irradiance;
  4490. }
  4491. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  4492. #if defined ( LEGACY_LIGHTS )
  4493. if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
  4494. return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
  4495. }
  4496. return 1.0;
  4497. #else
  4498. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  4499. if ( cutoffDistance > 0.0 ) {
  4500. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  4501. }
  4502. return distanceFalloff;
  4503. #endif
  4504. }
  4505. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  4506. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  4507. }
  4508. #if NUM_DIR_LIGHTS > 0
  4509. struct DirectionalLight {
  4510. vec3 direction;
  4511. vec3 color;
  4512. };
  4513. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  4514. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  4515. light.color = directionalLight.color;
  4516. light.direction = directionalLight.direction;
  4517. light.visible = true;
  4518. }
  4519. #endif
  4520. #if NUM_POINT_LIGHTS > 0
  4521. struct PointLight {
  4522. vec3 position;
  4523. vec3 color;
  4524. float distance;
  4525. float decay;
  4526. };
  4527. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  4528. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4529. vec3 lVector = pointLight.position - geometryPosition;
  4530. light.direction = normalize( lVector );
  4531. float lightDistance = length( lVector );
  4532. light.color = pointLight.color;
  4533. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  4534. light.visible = ( light.color != vec3( 0.0 ) );
  4535. }
  4536. #endif
  4537. #if NUM_SPOT_LIGHTS > 0
  4538. struct SpotLight {
  4539. vec3 position;
  4540. vec3 direction;
  4541. vec3 color;
  4542. float distance;
  4543. float decay;
  4544. float coneCos;
  4545. float penumbraCos;
  4546. };
  4547. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  4548. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4549. vec3 lVector = spotLight.position - geometryPosition;
  4550. light.direction = normalize( lVector );
  4551. float angleCos = dot( light.direction, spotLight.direction );
  4552. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  4553. if ( spotAttenuation > 0.0 ) {
  4554. float lightDistance = length( lVector );
  4555. light.color = spotLight.color * spotAttenuation;
  4556. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  4557. light.visible = ( light.color != vec3( 0.0 ) );
  4558. } else {
  4559. light.color = vec3( 0.0 );
  4560. light.visible = false;
  4561. }
  4562. }
  4563. #endif
  4564. #if NUM_RECT_AREA_LIGHTS > 0
  4565. struct RectAreaLight {
  4566. vec3 color;
  4567. vec3 position;
  4568. vec3 halfWidth;
  4569. vec3 halfHeight;
  4570. };
  4571. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  4572. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  4573. #endif
  4574. #if NUM_HEMI_LIGHTS > 0
  4575. struct HemisphereLight {
  4576. vec3 direction;
  4577. vec3 skyColor;
  4578. vec3 groundColor;
  4579. };
  4580. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  4581. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  4582. float dotNL = dot( normal, hemiLight.direction );
  4583. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  4584. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  4585. return irradiance;
  4586. }
  4587. #endif`,swe=`#ifdef USE_ENVMAP
  4588. vec3 getIBLIrradiance( const in vec3 normal ) {
  4589. #ifdef ENVMAP_TYPE_CUBE_UV
  4590. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4591. vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
  4592. return PI * envMapColor.rgb * envMapIntensity;
  4593. #else
  4594. return vec3( 0.0 );
  4595. #endif
  4596. }
  4597. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  4598. #ifdef ENVMAP_TYPE_CUBE_UV
  4599. vec3 reflectVec = reflect( - viewDir, normal );
  4600. reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
  4601. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  4602. vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
  4603. return envMapColor.rgb * envMapIntensity;
  4604. #else
  4605. return vec3( 0.0 );
  4606. #endif
  4607. }
  4608. #ifdef USE_ANISOTROPY
  4609. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  4610. #ifdef ENVMAP_TYPE_CUBE_UV
  4611. vec3 bentNormal = cross( bitangent, viewDir );
  4612. bentNormal = normalize( cross( bentNormal, bitangent ) );
  4613. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  4614. return getIBLRadiance( viewDir, bentNormal, roughness );
  4615. #else
  4616. return vec3( 0.0 );
  4617. #endif
  4618. }
  4619. #endif
  4620. #endif`,owe=`ToonMaterial material;
  4621. material.diffuseColor = diffuseColor.rgb;`,lwe=`varying vec3 vViewPosition;
  4622. struct ToonMaterial {
  4623. vec3 diffuseColor;
  4624. };
  4625. 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 ) {
  4626. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  4627. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4628. }
  4629. 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 ) {
  4630. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4631. }
  4632. #define RE_Direct RE_Direct_Toon
  4633. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,cwe=`BlinnPhongMaterial material;
  4634. material.diffuseColor = diffuseColor.rgb;
  4635. material.specularColor = specular;
  4636. material.specularShininess = shininess;
  4637. material.specularStrength = specularStrength;`,uwe=`varying vec3 vViewPosition;
  4638. struct BlinnPhongMaterial {
  4639. vec3 diffuseColor;
  4640. vec3 specularColor;
  4641. float specularShininess;
  4642. float specularStrength;
  4643. };
  4644. 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 ) {
  4645. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4646. vec3 irradiance = dotNL * directLight.color;
  4647. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4648. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  4649. }
  4650. 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 ) {
  4651. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4652. }
  4653. #define RE_Direct RE_Direct_BlinnPhong
  4654. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,dwe=`PhysicalMaterial material;
  4655. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  4656. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  4657. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  4658. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  4659. material.roughness = min( material.roughness, 1.0 );
  4660. #ifdef IOR
  4661. material.ior = ior;
  4662. #ifdef USE_SPECULAR
  4663. float specularIntensityFactor = specularIntensity;
  4664. vec3 specularColorFactor = specularColor;
  4665. #ifdef USE_SPECULAR_COLORMAP
  4666. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  4667. #endif
  4668. #ifdef USE_SPECULAR_INTENSITYMAP
  4669. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  4670. #endif
  4671. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  4672. #else
  4673. float specularIntensityFactor = 1.0;
  4674. vec3 specularColorFactor = vec3( 1.0 );
  4675. material.specularF90 = 1.0;
  4676. #endif
  4677. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  4678. #else
  4679. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  4680. material.specularF90 = 1.0;
  4681. #endif
  4682. #ifdef USE_CLEARCOAT
  4683. material.clearcoat = clearcoat;
  4684. material.clearcoatRoughness = clearcoatRoughness;
  4685. material.clearcoatF0 = vec3( 0.04 );
  4686. material.clearcoatF90 = 1.0;
  4687. #ifdef USE_CLEARCOATMAP
  4688. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  4689. #endif
  4690. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  4691. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  4692. #endif
  4693. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  4694. material.clearcoatRoughness += geometryRoughness;
  4695. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  4696. #endif
  4697. #ifdef USE_IRIDESCENCE
  4698. material.iridescence = iridescence;
  4699. material.iridescenceIOR = iridescenceIOR;
  4700. #ifdef USE_IRIDESCENCEMAP
  4701. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  4702. #endif
  4703. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  4704. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  4705. #else
  4706. material.iridescenceThickness = iridescenceThicknessMaximum;
  4707. #endif
  4708. #endif
  4709. #ifdef USE_SHEEN
  4710. material.sheenColor = sheenColor;
  4711. #ifdef USE_SHEEN_COLORMAP
  4712. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  4713. #endif
  4714. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  4715. #ifdef USE_SHEEN_ROUGHNESSMAP
  4716. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  4717. #endif
  4718. #endif
  4719. #ifdef USE_ANISOTROPY
  4720. #ifdef USE_ANISOTROPYMAP
  4721. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  4722. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  4723. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  4724. #else
  4725. vec2 anisotropyV = anisotropyVector;
  4726. #endif
  4727. material.anisotropy = length( anisotropyV );
  4728. if( material.anisotropy == 0.0 ) {
  4729. anisotropyV = vec2( 1.0, 0.0 );
  4730. } else {
  4731. anisotropyV /= material.anisotropy;
  4732. material.anisotropy = saturate( material.anisotropy );
  4733. }
  4734. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  4735. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  4736. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  4737. #endif`,hwe=`struct PhysicalMaterial {
  4738. vec3 diffuseColor;
  4739. float roughness;
  4740. vec3 specularColor;
  4741. float specularF90;
  4742. #ifdef USE_CLEARCOAT
  4743. float clearcoat;
  4744. float clearcoatRoughness;
  4745. vec3 clearcoatF0;
  4746. float clearcoatF90;
  4747. #endif
  4748. #ifdef USE_IRIDESCENCE
  4749. float iridescence;
  4750. float iridescenceIOR;
  4751. float iridescenceThickness;
  4752. vec3 iridescenceFresnel;
  4753. vec3 iridescenceF0;
  4754. #endif
  4755. #ifdef USE_SHEEN
  4756. vec3 sheenColor;
  4757. float sheenRoughness;
  4758. #endif
  4759. #ifdef IOR
  4760. float ior;
  4761. #endif
  4762. #ifdef USE_TRANSMISSION
  4763. float transmission;
  4764. float transmissionAlpha;
  4765. float thickness;
  4766. float attenuationDistance;
  4767. vec3 attenuationColor;
  4768. #endif
  4769. #ifdef USE_ANISOTROPY
  4770. float anisotropy;
  4771. float alphaT;
  4772. vec3 anisotropyT;
  4773. vec3 anisotropyB;
  4774. #endif
  4775. };
  4776. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  4777. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  4778. vec3 sheenSpecularDirect = vec3( 0.0 );
  4779. vec3 sheenSpecularIndirect = vec3(0.0 );
  4780. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  4781. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  4782. float x2 = x * x;
  4783. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  4784. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  4785. }
  4786. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  4787. float a2 = pow2( alpha );
  4788. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  4789. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  4790. return 0.5 / max( gv + gl, EPSILON );
  4791. }
  4792. float D_GGX( const in float alpha, const in float dotNH ) {
  4793. float a2 = pow2( alpha );
  4794. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  4795. return RECIPROCAL_PI * a2 / pow2( denom );
  4796. }
  4797. #ifdef USE_ANISOTROPY
  4798. 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 ) {
  4799. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  4800. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  4801. float v = 0.5 / ( gv + gl );
  4802. return saturate(v);
  4803. }
  4804. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  4805. float a2 = alphaT * alphaB;
  4806. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  4807. highp float v2 = dot( v, v );
  4808. float w2 = a2 / v2;
  4809. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  4810. }
  4811. #endif
  4812. #ifdef USE_CLEARCOAT
  4813. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  4814. vec3 f0 = material.clearcoatF0;
  4815. float f90 = material.clearcoatF90;
  4816. float roughness = material.clearcoatRoughness;
  4817. float alpha = pow2( roughness );
  4818. vec3 halfDir = normalize( lightDir + viewDir );
  4819. float dotNL = saturate( dot( normal, lightDir ) );
  4820. float dotNV = saturate( dot( normal, viewDir ) );
  4821. float dotNH = saturate( dot( normal, halfDir ) );
  4822. float dotVH = saturate( dot( viewDir, halfDir ) );
  4823. vec3 F = F_Schlick( f0, f90, dotVH );
  4824. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4825. float D = D_GGX( alpha, dotNH );
  4826. return F * ( V * D );
  4827. }
  4828. #endif
  4829. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  4830. vec3 f0 = material.specularColor;
  4831. float f90 = material.specularF90;
  4832. float roughness = material.roughness;
  4833. float alpha = pow2( roughness );
  4834. vec3 halfDir = normalize( lightDir + viewDir );
  4835. float dotNL = saturate( dot( normal, lightDir ) );
  4836. float dotNV = saturate( dot( normal, viewDir ) );
  4837. float dotNH = saturate( dot( normal, halfDir ) );
  4838. float dotVH = saturate( dot( viewDir, halfDir ) );
  4839. vec3 F = F_Schlick( f0, f90, dotVH );
  4840. #ifdef USE_IRIDESCENCE
  4841. F = mix( F, material.iridescenceFresnel, material.iridescence );
  4842. #endif
  4843. #ifdef USE_ANISOTROPY
  4844. float dotTL = dot( material.anisotropyT, lightDir );
  4845. float dotTV = dot( material.anisotropyT, viewDir );
  4846. float dotTH = dot( material.anisotropyT, halfDir );
  4847. float dotBL = dot( material.anisotropyB, lightDir );
  4848. float dotBV = dot( material.anisotropyB, viewDir );
  4849. float dotBH = dot( material.anisotropyB, halfDir );
  4850. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  4851. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  4852. #else
  4853. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4854. float D = D_GGX( alpha, dotNH );
  4855. #endif
  4856. return F * ( V * D );
  4857. }
  4858. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  4859. const float LUT_SIZE = 64.0;
  4860. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  4861. const float LUT_BIAS = 0.5 / LUT_SIZE;
  4862. float dotNV = saturate( dot( N, V ) );
  4863. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  4864. uv = uv * LUT_SCALE + LUT_BIAS;
  4865. return uv;
  4866. }
  4867. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  4868. float l = length( f );
  4869. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  4870. }
  4871. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  4872. float x = dot( v1, v2 );
  4873. float y = abs( x );
  4874. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  4875. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  4876. float v = a / b;
  4877. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  4878. return cross( v1, v2 ) * theta_sintheta;
  4879. }
  4880. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  4881. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  4882. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  4883. vec3 lightNormal = cross( v1, v2 );
  4884. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  4885. vec3 T1, T2;
  4886. T1 = normalize( V - N * dot( V, N ) );
  4887. T2 = - cross( N, T1 );
  4888. mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
  4889. vec3 coords[ 4 ];
  4890. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  4891. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  4892. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  4893. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  4894. coords[ 0 ] = normalize( coords[ 0 ] );
  4895. coords[ 1 ] = normalize( coords[ 1 ] );
  4896. coords[ 2 ] = normalize( coords[ 2 ] );
  4897. coords[ 3 ] = normalize( coords[ 3 ] );
  4898. vec3 vectorFormFactor = vec3( 0.0 );
  4899. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  4900. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  4901. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  4902. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  4903. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  4904. return vec3( result );
  4905. }
  4906. #if defined( USE_SHEEN )
  4907. float D_Charlie( float roughness, float dotNH ) {
  4908. float alpha = pow2( roughness );
  4909. float invAlpha = 1.0 / alpha;
  4910. float cos2h = dotNH * dotNH;
  4911. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  4912. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  4913. }
  4914. float V_Neubelt( float dotNV, float dotNL ) {
  4915. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  4916. }
  4917. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  4918. vec3 halfDir = normalize( lightDir + viewDir );
  4919. float dotNL = saturate( dot( normal, lightDir ) );
  4920. float dotNV = saturate( dot( normal, viewDir ) );
  4921. float dotNH = saturate( dot( normal, halfDir ) );
  4922. float D = D_Charlie( sheenRoughness, dotNH );
  4923. float V = V_Neubelt( dotNV, dotNL );
  4924. return sheenColor * ( D * V );
  4925. }
  4926. #endif
  4927. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  4928. float dotNV = saturate( dot( normal, viewDir ) );
  4929. float r2 = roughness * roughness;
  4930. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  4931. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  4932. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  4933. return saturate( DG * RECIPROCAL_PI );
  4934. }
  4935. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  4936. float dotNV = saturate( dot( normal, viewDir ) );
  4937. const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
  4938. const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
  4939. vec4 r = roughness * c0 + c1;
  4940. float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
  4941. vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
  4942. return fab;
  4943. }
  4944. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  4945. vec2 fab = DFGApprox( normal, viewDir, roughness );
  4946. return specularColor * fab.x + specularF90 * fab.y;
  4947. }
  4948. #ifdef USE_IRIDESCENCE
  4949. 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 ) {
  4950. #else
  4951. 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 ) {
  4952. #endif
  4953. vec2 fab = DFGApprox( normal, viewDir, roughness );
  4954. #ifdef USE_IRIDESCENCE
  4955. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  4956. #else
  4957. vec3 Fr = specularColor;
  4958. #endif
  4959. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  4960. float Ess = fab.x + fab.y;
  4961. float Ems = 1.0 - Ess;
  4962. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  4963. singleScatter += FssEss;
  4964. multiScatter += Fms * Ems;
  4965. }
  4966. #if NUM_RECT_AREA_LIGHTS > 0
  4967. 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 ) {
  4968. vec3 normal = geometryNormal;
  4969. vec3 viewDir = geometryViewDir;
  4970. vec3 position = geometryPosition;
  4971. vec3 lightPos = rectAreaLight.position;
  4972. vec3 halfWidth = rectAreaLight.halfWidth;
  4973. vec3 halfHeight = rectAreaLight.halfHeight;
  4974. vec3 lightColor = rectAreaLight.color;
  4975. float roughness = material.roughness;
  4976. vec3 rectCoords[ 4 ];
  4977. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  4978. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  4979. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  4980. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  4981. vec4 t1 = texture2D( ltc_1, uv );
  4982. vec4 t2 = texture2D( ltc_2, uv );
  4983. mat3 mInv = mat3(
  4984. vec3( t1.x, 0, t1.y ),
  4985. vec3( 0, 1, 0 ),
  4986. vec3( t1.z, 0, t1.w )
  4987. );
  4988. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  4989. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  4990. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  4991. }
  4992. #endif
  4993. 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 ) {
  4994. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4995. vec3 irradiance = dotNL * directLight.color;
  4996. #ifdef USE_CLEARCOAT
  4997. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  4998. vec3 ccIrradiance = dotNLcc * directLight.color;
  4999. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  5000. #endif
  5001. #ifdef USE_SHEEN
  5002. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  5003. #endif
  5004. reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
  5005. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5006. }
  5007. 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 ) {
  5008. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5009. }
  5010. 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) {
  5011. #ifdef USE_CLEARCOAT
  5012. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  5013. #endif
  5014. #ifdef USE_SHEEN
  5015. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  5016. #endif
  5017. vec3 singleScattering = vec3( 0.0 );
  5018. vec3 multiScattering = vec3( 0.0 );
  5019. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  5020. #ifdef USE_IRIDESCENCE
  5021. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  5022. #else
  5023. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  5024. #endif
  5025. vec3 totalScattering = singleScattering + multiScattering;
  5026. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  5027. reflectedLight.indirectSpecular += radiance * singleScattering;
  5028. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  5029. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  5030. }
  5031. #define RE_Direct RE_Direct_Physical
  5032. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  5033. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  5034. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  5035. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  5036. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  5037. }`,fwe=`
  5038. vec3 geometryPosition = - vViewPosition;
  5039. vec3 geometryNormal = normal;
  5040. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  5041. vec3 geometryClearcoatNormal = vec3( 0.0 );
  5042. #ifdef USE_CLEARCOAT
  5043. geometryClearcoatNormal = clearcoatNormal;
  5044. #endif
  5045. #ifdef USE_IRIDESCENCE
  5046. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  5047. if ( material.iridescenceThickness == 0.0 ) {
  5048. material.iridescence = 0.0;
  5049. } else {
  5050. material.iridescence = saturate( material.iridescence );
  5051. }
  5052. if ( material.iridescence > 0.0 ) {
  5053. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  5054. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  5055. }
  5056. #endif
  5057. IncidentLight directLight;
  5058. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  5059. PointLight pointLight;
  5060. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  5061. PointLightShadow pointLightShadow;
  5062. #endif
  5063. #pragma unroll_loop_start
  5064. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  5065. pointLight = pointLights[ i ];
  5066. getPointLightInfo( pointLight, geometryPosition, directLight );
  5067. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  5068. pointLightShadow = pointLightShadows[ i ];
  5069. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  5070. #endif
  5071. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5072. }
  5073. #pragma unroll_loop_end
  5074. #endif
  5075. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  5076. SpotLight spotLight;
  5077. vec4 spotColor;
  5078. vec3 spotLightCoord;
  5079. bool inSpotLightMap;
  5080. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  5081. SpotLightShadow spotLightShadow;
  5082. #endif
  5083. #pragma unroll_loop_start
  5084. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  5085. spotLight = spotLights[ i ];
  5086. getSpotLightInfo( spotLight, geometryPosition, directLight );
  5087. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5088. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  5089. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5090. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  5091. #else
  5092. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5093. #endif
  5094. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  5095. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  5096. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  5097. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  5098. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  5099. #endif
  5100. #undef SPOT_LIGHT_MAP_INDEX
  5101. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5102. spotLightShadow = spotLightShadows[ i ];
  5103. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5104. #endif
  5105. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5106. }
  5107. #pragma unroll_loop_end
  5108. #endif
  5109. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  5110. DirectionalLight directionalLight;
  5111. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  5112. DirectionalLightShadow directionalLightShadow;
  5113. #endif
  5114. #pragma unroll_loop_start
  5115. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  5116. directionalLight = directionalLights[ i ];
  5117. getDirectionalLightInfo( directionalLight, directLight );
  5118. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  5119. directionalLightShadow = directionalLightShadows[ i ];
  5120. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5121. #endif
  5122. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5123. }
  5124. #pragma unroll_loop_end
  5125. #endif
  5126. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  5127. RectAreaLight rectAreaLight;
  5128. #pragma unroll_loop_start
  5129. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  5130. rectAreaLight = rectAreaLights[ i ];
  5131. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5132. }
  5133. #pragma unroll_loop_end
  5134. #endif
  5135. #if defined( RE_IndirectDiffuse )
  5136. vec3 iblIrradiance = vec3( 0.0 );
  5137. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  5138. #if defined( USE_LIGHT_PROBES )
  5139. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  5140. #endif
  5141. #if ( NUM_HEMI_LIGHTS > 0 )
  5142. #pragma unroll_loop_start
  5143. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  5144. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  5145. }
  5146. #pragma unroll_loop_end
  5147. #endif
  5148. #endif
  5149. #if defined( RE_IndirectSpecular )
  5150. vec3 radiance = vec3( 0.0 );
  5151. vec3 clearcoatRadiance = vec3( 0.0 );
  5152. #endif`,mwe=`#if defined( RE_IndirectDiffuse )
  5153. #ifdef USE_LIGHTMAP
  5154. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  5155. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  5156. irradiance += lightMapIrradiance;
  5157. #endif
  5158. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  5159. iblIrradiance += getIBLIrradiance( geometryNormal );
  5160. #endif
  5161. #endif
  5162. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  5163. #ifdef USE_ANISOTROPY
  5164. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  5165. #else
  5166. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  5167. #endif
  5168. #ifdef USE_CLEARCOAT
  5169. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  5170. #endif
  5171. #endif`,pwe=`#if defined( RE_IndirectDiffuse )
  5172. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5173. #endif
  5174. #if defined( RE_IndirectSpecular )
  5175. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5176. #endif`,gwe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5177. gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  5178. #endif`,xwe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5179. uniform float logDepthBufFC;
  5180. varying float vFragDepth;
  5181. varying float vIsPerspective;
  5182. #endif`,bwe=`#ifdef USE_LOGDEPTHBUF
  5183. #ifdef USE_LOGDEPTHBUF_EXT
  5184. varying float vFragDepth;
  5185. varying float vIsPerspective;
  5186. #else
  5187. uniform float logDepthBufFC;
  5188. #endif
  5189. #endif`,ywe=`#ifdef USE_LOGDEPTHBUF
  5190. #ifdef USE_LOGDEPTHBUF_EXT
  5191. vFragDepth = 1.0 + gl_Position.w;
  5192. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  5193. #else
  5194. if ( isPerspectiveMatrix( projectionMatrix ) ) {
  5195. gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
  5196. gl_Position.z *= gl_Position.w;
  5197. }
  5198. #endif
  5199. #endif`,vwe=`#ifdef USE_MAP
  5200. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  5201. #ifdef DECODE_VIDEO_TEXTURE
  5202. 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 );
  5203. #endif
  5204. diffuseColor *= sampledDiffuseColor;
  5205. #endif`,_we=`#ifdef USE_MAP
  5206. uniform sampler2D map;
  5207. #endif`,wwe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5208. #if defined( USE_POINTS_UV )
  5209. vec2 uv = vUv;
  5210. #else
  5211. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  5212. #endif
  5213. #endif
  5214. #ifdef USE_MAP
  5215. diffuseColor *= texture2D( map, uv );
  5216. #endif
  5217. #ifdef USE_ALPHAMAP
  5218. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  5219. #endif`,Swe=`#if defined( USE_POINTS_UV )
  5220. varying vec2 vUv;
  5221. #else
  5222. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5223. uniform mat3 uvTransform;
  5224. #endif
  5225. #endif
  5226. #ifdef USE_MAP
  5227. uniform sampler2D map;
  5228. #endif
  5229. #ifdef USE_ALPHAMAP
  5230. uniform sampler2D alphaMap;
  5231. #endif`,Nwe=`float metalnessFactor = metalness;
  5232. #ifdef USE_METALNESSMAP
  5233. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  5234. metalnessFactor *= texelMetalness.b;
  5235. #endif`,Mwe=`#ifdef USE_METALNESSMAP
  5236. uniform sampler2D metalnessMap;
  5237. #endif`,Ewe=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
  5238. vColor *= morphTargetBaseInfluence;
  5239. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5240. #if defined( USE_COLOR_ALPHA )
  5241. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  5242. #elif defined( USE_COLOR )
  5243. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  5244. #endif
  5245. }
  5246. #endif`,Cwe=`#ifdef USE_MORPHNORMALS
  5247. objectNormal *= morphTargetBaseInfluence;
  5248. #ifdef MORPHTARGETS_TEXTURE
  5249. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5250. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  5251. }
  5252. #else
  5253. objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
  5254. objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
  5255. objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
  5256. objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
  5257. #endif
  5258. #endif`,Twe=`#ifdef USE_MORPHTARGETS
  5259. uniform float morphTargetBaseInfluence;
  5260. #ifdef MORPHTARGETS_TEXTURE
  5261. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  5262. uniform sampler2DArray morphTargetsTexture;
  5263. uniform ivec2 morphTargetsTextureSize;
  5264. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  5265. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  5266. int y = texelIndex / morphTargetsTextureSize.x;
  5267. int x = texelIndex - y * morphTargetsTextureSize.x;
  5268. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  5269. return texelFetch( morphTargetsTexture, morphUV, 0 );
  5270. }
  5271. #else
  5272. #ifndef USE_MORPHNORMALS
  5273. uniform float morphTargetInfluences[ 8 ];
  5274. #else
  5275. uniform float morphTargetInfluences[ 4 ];
  5276. #endif
  5277. #endif
  5278. #endif`,Awe=`#ifdef USE_MORPHTARGETS
  5279. transformed *= morphTargetBaseInfluence;
  5280. #ifdef MORPHTARGETS_TEXTURE
  5281. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5282. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  5283. }
  5284. #else
  5285. transformed += morphTarget0 * morphTargetInfluences[ 0 ];
  5286. transformed += morphTarget1 * morphTargetInfluences[ 1 ];
  5287. transformed += morphTarget2 * morphTargetInfluences[ 2 ];
  5288. transformed += morphTarget3 * morphTargetInfluences[ 3 ];
  5289. #ifndef USE_MORPHNORMALS
  5290. transformed += morphTarget4 * morphTargetInfluences[ 4 ];
  5291. transformed += morphTarget5 * morphTargetInfluences[ 5 ];
  5292. transformed += morphTarget6 * morphTargetInfluences[ 6 ];
  5293. transformed += morphTarget7 * morphTargetInfluences[ 7 ];
  5294. #endif
  5295. #endif
  5296. #endif`,kwe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  5297. #ifdef FLAT_SHADED
  5298. vec3 fdx = dFdx( vViewPosition );
  5299. vec3 fdy = dFdy( vViewPosition );
  5300. vec3 normal = normalize( cross( fdx, fdy ) );
  5301. #else
  5302. vec3 normal = normalize( vNormal );
  5303. #ifdef DOUBLE_SIDED
  5304. normal *= faceDirection;
  5305. #endif
  5306. #endif
  5307. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  5308. #ifdef USE_TANGENT
  5309. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5310. #else
  5311. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  5312. #if defined( USE_NORMALMAP )
  5313. vNormalMapUv
  5314. #elif defined( USE_CLEARCOAT_NORMALMAP )
  5315. vClearcoatNormalMapUv
  5316. #else
  5317. vUv
  5318. #endif
  5319. );
  5320. #endif
  5321. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5322. tbn[0] *= faceDirection;
  5323. tbn[1] *= faceDirection;
  5324. #endif
  5325. #endif
  5326. #ifdef USE_CLEARCOAT_NORMALMAP
  5327. #ifdef USE_TANGENT
  5328. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5329. #else
  5330. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  5331. #endif
  5332. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5333. tbn2[0] *= faceDirection;
  5334. tbn2[1] *= faceDirection;
  5335. #endif
  5336. #endif
  5337. vec3 nonPerturbedNormal = normal;`,jwe=`#ifdef USE_NORMALMAP_OBJECTSPACE
  5338. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5339. #ifdef FLIP_SIDED
  5340. normal = - normal;
  5341. #endif
  5342. #ifdef DOUBLE_SIDED
  5343. normal = normal * faceDirection;
  5344. #endif
  5345. normal = normalize( normalMatrix * normal );
  5346. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  5347. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5348. mapN.xy *= normalScale;
  5349. normal = normalize( tbn * mapN );
  5350. #elif defined( USE_BUMPMAP )
  5351. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  5352. #endif`,Pwe=`#ifndef FLAT_SHADED
  5353. varying vec3 vNormal;
  5354. #ifdef USE_TANGENT
  5355. varying vec3 vTangent;
  5356. varying vec3 vBitangent;
  5357. #endif
  5358. #endif`,Rwe=`#ifndef FLAT_SHADED
  5359. varying vec3 vNormal;
  5360. #ifdef USE_TANGENT
  5361. varying vec3 vTangent;
  5362. varying vec3 vBitangent;
  5363. #endif
  5364. #endif`,Dwe=`#ifndef FLAT_SHADED
  5365. vNormal = normalize( transformedNormal );
  5366. #ifdef USE_TANGENT
  5367. vTangent = normalize( transformedTangent );
  5368. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  5369. #endif
  5370. #endif`,Owe=`#ifdef USE_NORMALMAP
  5371. uniform sampler2D normalMap;
  5372. uniform vec2 normalScale;
  5373. #endif
  5374. #ifdef USE_NORMALMAP_OBJECTSPACE
  5375. uniform mat3 normalMatrix;
  5376. #endif
  5377. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  5378. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  5379. vec3 q0 = dFdx( eye_pos.xyz );
  5380. vec3 q1 = dFdy( eye_pos.xyz );
  5381. vec2 st0 = dFdx( uv.st );
  5382. vec2 st1 = dFdy( uv.st );
  5383. vec3 N = surf_norm;
  5384. vec3 q1perp = cross( q1, N );
  5385. vec3 q0perp = cross( N, q0 );
  5386. vec3 T = q1perp * st0.x + q0perp * st1.x;
  5387. vec3 B = q1perp * st0.y + q0perp * st1.y;
  5388. float det = max( dot( T, T ), dot( B, B ) );
  5389. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  5390. return mat3( T * scale, B * scale, N );
  5391. }
  5392. #endif`,Lwe=`#ifdef USE_CLEARCOAT
  5393. vec3 clearcoatNormal = nonPerturbedNormal;
  5394. #endif`,Iwe=`#ifdef USE_CLEARCOAT_NORMALMAP
  5395. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  5396. clearcoatMapN.xy *= clearcoatNormalScale;
  5397. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  5398. #endif`,Fwe=`#ifdef USE_CLEARCOATMAP
  5399. uniform sampler2D clearcoatMap;
  5400. #endif
  5401. #ifdef USE_CLEARCOAT_NORMALMAP
  5402. uniform sampler2D clearcoatNormalMap;
  5403. uniform vec2 clearcoatNormalScale;
  5404. #endif
  5405. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  5406. uniform sampler2D clearcoatRoughnessMap;
  5407. #endif`,Uwe=`#ifdef USE_IRIDESCENCEMAP
  5408. uniform sampler2D iridescenceMap;
  5409. #endif
  5410. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  5411. uniform sampler2D iridescenceThicknessMap;
  5412. #endif`,zwe=`#ifdef OPAQUE
  5413. diffuseColor.a = 1.0;
  5414. #endif
  5415. #ifdef USE_TRANSMISSION
  5416. diffuseColor.a *= material.transmissionAlpha;
  5417. #endif
  5418. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Bwe=`vec3 packNormalToRGB( const in vec3 normal ) {
  5419. return normalize( normal ) * 0.5 + 0.5;
  5420. }
  5421. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  5422. return 2.0 * rgb.xyz - 1.0;
  5423. }
  5424. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
  5425. const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
  5426. const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
  5427. const float ShiftRight8 = 1. / 256.;
  5428. vec4 packDepthToRGBA( const in float v ) {
  5429. vec4 r = vec4( fract( v * PackFactors ), v );
  5430. r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
  5431. }
  5432. float unpackRGBAToDepth( const in vec4 v ) {
  5433. return dot( v, UnpackFactors );
  5434. }
  5435. vec2 packDepthToRG( in highp float v ) {
  5436. return packDepthToRGBA( v ).yx;
  5437. }
  5438. float unpackRGToDepth( const in highp vec2 v ) {
  5439. return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
  5440. }
  5441. vec4 pack2HalfToRGBA( vec2 v ) {
  5442. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  5443. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  5444. }
  5445. vec2 unpackRGBATo2Half( vec4 v ) {
  5446. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  5447. }
  5448. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  5449. return ( viewZ + near ) / ( near - far );
  5450. }
  5451. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5452. return depth * ( near - far ) - near;
  5453. }
  5454. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  5455. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  5456. }
  5457. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5458. return ( near * far ) / ( ( far - near ) * depth - far );
  5459. }`,$we=`#ifdef PREMULTIPLIED_ALPHA
  5460. gl_FragColor.rgb *= gl_FragColor.a;
  5461. #endif`,Hwe=`vec4 mvPosition = vec4( transformed, 1.0 );
  5462. #ifdef USE_BATCHING
  5463. mvPosition = batchingMatrix * mvPosition;
  5464. #endif
  5465. #ifdef USE_INSTANCING
  5466. mvPosition = instanceMatrix * mvPosition;
  5467. #endif
  5468. mvPosition = modelViewMatrix * mvPosition;
  5469. gl_Position = projectionMatrix * mvPosition;`,Vwe=`#ifdef DITHERING
  5470. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  5471. #endif`,Gwe=`#ifdef DITHERING
  5472. vec3 dithering( vec3 color ) {
  5473. float grid_position = rand( gl_FragCoord.xy );
  5474. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  5475. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  5476. return color + dither_shift_RGB;
  5477. }
  5478. #endif`,qwe=`float roughnessFactor = roughness;
  5479. #ifdef USE_ROUGHNESSMAP
  5480. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  5481. roughnessFactor *= texelRoughness.g;
  5482. #endif`,Wwe=`#ifdef USE_ROUGHNESSMAP
  5483. uniform sampler2D roughnessMap;
  5484. #endif`,Kwe=`#if NUM_SPOT_LIGHT_COORDS > 0
  5485. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5486. #endif
  5487. #if NUM_SPOT_LIGHT_MAPS > 0
  5488. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  5489. #endif
  5490. #ifdef USE_SHADOWMAP
  5491. #if NUM_DIR_LIGHT_SHADOWS > 0
  5492. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  5493. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5494. struct DirectionalLightShadow {
  5495. float shadowBias;
  5496. float shadowNormalBias;
  5497. float shadowRadius;
  5498. vec2 shadowMapSize;
  5499. };
  5500. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5501. #endif
  5502. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5503. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  5504. struct SpotLightShadow {
  5505. float shadowBias;
  5506. float shadowNormalBias;
  5507. float shadowRadius;
  5508. vec2 shadowMapSize;
  5509. };
  5510. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5511. #endif
  5512. #if NUM_POINT_LIGHT_SHADOWS > 0
  5513. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  5514. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5515. struct PointLightShadow {
  5516. float shadowBias;
  5517. float shadowNormalBias;
  5518. float shadowRadius;
  5519. vec2 shadowMapSize;
  5520. float shadowCameraNear;
  5521. float shadowCameraFar;
  5522. };
  5523. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5524. #endif
  5525. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  5526. return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
  5527. }
  5528. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  5529. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  5530. }
  5531. float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
  5532. float occlusion = 1.0;
  5533. vec2 distribution = texture2DDistribution( shadow, uv );
  5534. float hard_shadow = step( compare , distribution.x );
  5535. if (hard_shadow != 1.0 ) {
  5536. float distance = compare - distribution.x ;
  5537. float variance = max( 0.00000, distribution.y * distribution.y );
  5538. 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 );
  5539. }
  5540. return occlusion;
  5541. }
  5542. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  5543. float shadow = 1.0;
  5544. shadowCoord.xyz /= shadowCoord.w;
  5545. shadowCoord.z += shadowBias;
  5546. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  5547. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  5548. if ( frustumTest ) {
  5549. #if defined( SHADOWMAP_TYPE_PCF )
  5550. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5551. float dx0 = - texelSize.x * shadowRadius;
  5552. float dy0 = - texelSize.y * shadowRadius;
  5553. float dx1 = + texelSize.x * shadowRadius;
  5554. float dy1 = + texelSize.y * shadowRadius;
  5555. float dx2 = dx0 / 2.0;
  5556. float dy2 = dy0 / 2.0;
  5557. float dx3 = dx1 / 2.0;
  5558. float dy3 = dy1 / 2.0;
  5559. shadow = (
  5560. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  5561. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  5562. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  5563. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  5564. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  5565. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  5566. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  5567. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  5568. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  5569. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  5570. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  5571. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  5572. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  5573. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  5574. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  5575. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  5576. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  5577. ) * ( 1.0 / 17.0 );
  5578. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  5579. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5580. float dx = texelSize.x;
  5581. float dy = texelSize.y;
  5582. vec2 uv = shadowCoord.xy;
  5583. vec2 f = fract( uv * shadowMapSize + 0.5 );
  5584. uv -= f * texelSize;
  5585. shadow = (
  5586. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  5587. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  5588. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  5589. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  5590. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  5591. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  5592. f.x ) +
  5593. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  5594. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  5595. f.x ) +
  5596. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  5597. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  5598. f.y ) +
  5599. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  5600. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  5601. f.y ) +
  5602. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  5603. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  5604. f.x ),
  5605. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  5606. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  5607. f.x ),
  5608. f.y )
  5609. ) * ( 1.0 / 9.0 );
  5610. #elif defined( SHADOWMAP_TYPE_VSM )
  5611. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  5612. #else
  5613. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  5614. #endif
  5615. }
  5616. return shadow;
  5617. }
  5618. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  5619. vec3 absV = abs( v );
  5620. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  5621. absV *= scaleToCube;
  5622. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  5623. vec2 planar = v.xy;
  5624. float almostATexel = 1.5 * texelSizeY;
  5625. float almostOne = 1.0 - almostATexel;
  5626. if ( absV.z >= almostOne ) {
  5627. if ( v.z > 0.0 )
  5628. planar.x = 4.0 - v.x;
  5629. } else if ( absV.x >= almostOne ) {
  5630. float signX = sign( v.x );
  5631. planar.x = v.z * signX + 2.0 * signX;
  5632. } else if ( absV.y >= almostOne ) {
  5633. float signY = sign( v.y );
  5634. planar.x = v.x + 2.0 * signY + 2.0;
  5635. planar.y = v.z * signY - 2.0;
  5636. }
  5637. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  5638. }
  5639. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  5640. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  5641. vec3 lightToPosition = shadowCoord.xyz;
  5642. float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  5643. vec3 bd3D = normalize( lightToPosition );
  5644. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  5645. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  5646. return (
  5647. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  5648. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  5649. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  5650. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  5651. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  5652. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  5653. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  5654. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  5655. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  5656. ) * ( 1.0 / 9.0 );
  5657. #else
  5658. return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  5659. #endif
  5660. }
  5661. #endif`,Xwe=`#if NUM_SPOT_LIGHT_COORDS > 0
  5662. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  5663. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5664. #endif
  5665. #ifdef USE_SHADOWMAP
  5666. #if NUM_DIR_LIGHT_SHADOWS > 0
  5667. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  5668. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5669. struct DirectionalLightShadow {
  5670. float shadowBias;
  5671. float shadowNormalBias;
  5672. float shadowRadius;
  5673. vec2 shadowMapSize;
  5674. };
  5675. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5676. #endif
  5677. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5678. struct SpotLightShadow {
  5679. float shadowBias;
  5680. float shadowNormalBias;
  5681. float shadowRadius;
  5682. vec2 shadowMapSize;
  5683. };
  5684. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5685. #endif
  5686. #if NUM_POINT_LIGHT_SHADOWS > 0
  5687. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  5688. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5689. struct PointLightShadow {
  5690. float shadowBias;
  5691. float shadowNormalBias;
  5692. float shadowRadius;
  5693. vec2 shadowMapSize;
  5694. float shadowCameraNear;
  5695. float shadowCameraFar;
  5696. };
  5697. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5698. #endif
  5699. #endif`,Ywe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  5700. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  5701. vec4 shadowWorldPosition;
  5702. #endif
  5703. #if defined( USE_SHADOWMAP )
  5704. #if NUM_DIR_LIGHT_SHADOWS > 0
  5705. #pragma unroll_loop_start
  5706. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5707. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  5708. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  5709. }
  5710. #pragma unroll_loop_end
  5711. #endif
  5712. #if NUM_POINT_LIGHT_SHADOWS > 0
  5713. #pragma unroll_loop_start
  5714. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5715. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  5716. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  5717. }
  5718. #pragma unroll_loop_end
  5719. #endif
  5720. #endif
  5721. #if NUM_SPOT_LIGHT_COORDS > 0
  5722. #pragma unroll_loop_start
  5723. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  5724. shadowWorldPosition = worldPosition;
  5725. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5726. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  5727. #endif
  5728. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  5729. }
  5730. #pragma unroll_loop_end
  5731. #endif`,Qwe=`float getShadowMask() {
  5732. float shadow = 1.0;
  5733. #ifdef USE_SHADOWMAP
  5734. #if NUM_DIR_LIGHT_SHADOWS > 0
  5735. DirectionalLightShadow directionalLight;
  5736. #pragma unroll_loop_start
  5737. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5738. directionalLight = directionalLightShadows[ i ];
  5739. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5740. }
  5741. #pragma unroll_loop_end
  5742. #endif
  5743. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5744. SpotLightShadow spotLight;
  5745. #pragma unroll_loop_start
  5746. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  5747. spotLight = spotLightShadows[ i ];
  5748. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5749. }
  5750. #pragma unroll_loop_end
  5751. #endif
  5752. #if NUM_POINT_LIGHT_SHADOWS > 0
  5753. PointLightShadow pointLight;
  5754. #pragma unroll_loop_start
  5755. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5756. pointLight = pointLightShadows[ i ];
  5757. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  5758. }
  5759. #pragma unroll_loop_end
  5760. #endif
  5761. #endif
  5762. return shadow;
  5763. }`,Zwe=`#ifdef USE_SKINNING
  5764. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  5765. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  5766. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  5767. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  5768. #endif`,Jwe=`#ifdef USE_SKINNING
  5769. uniform mat4 bindMatrix;
  5770. uniform mat4 bindMatrixInverse;
  5771. uniform highp sampler2D boneTexture;
  5772. mat4 getBoneMatrix( const in float i ) {
  5773. int size = textureSize( boneTexture, 0 ).x;
  5774. int j = int( i ) * 4;
  5775. int x = j % size;
  5776. int y = j / size;
  5777. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  5778. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  5779. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  5780. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  5781. return mat4( v1, v2, v3, v4 );
  5782. }
  5783. #endif`,e1e=`#ifdef USE_SKINNING
  5784. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  5785. vec4 skinned = vec4( 0.0 );
  5786. skinned += boneMatX * skinVertex * skinWeight.x;
  5787. skinned += boneMatY * skinVertex * skinWeight.y;
  5788. skinned += boneMatZ * skinVertex * skinWeight.z;
  5789. skinned += boneMatW * skinVertex * skinWeight.w;
  5790. transformed = ( bindMatrixInverse * skinned ).xyz;
  5791. #endif`,t1e=`#ifdef USE_SKINNING
  5792. mat4 skinMatrix = mat4( 0.0 );
  5793. skinMatrix += skinWeight.x * boneMatX;
  5794. skinMatrix += skinWeight.y * boneMatY;
  5795. skinMatrix += skinWeight.z * boneMatZ;
  5796. skinMatrix += skinWeight.w * boneMatW;
  5797. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  5798. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  5799. #ifdef USE_TANGENT
  5800. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  5801. #endif
  5802. #endif`,n1e=`float specularStrength;
  5803. #ifdef USE_SPECULARMAP
  5804. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  5805. specularStrength = texelSpecular.r;
  5806. #else
  5807. specularStrength = 1.0;
  5808. #endif`,r1e=`#ifdef USE_SPECULARMAP
  5809. uniform sampler2D specularMap;
  5810. #endif`,i1e=`#if defined( TONE_MAPPING )
  5811. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  5812. #endif`,a1e=`#ifndef saturate
  5813. #define saturate( a ) clamp( a, 0.0, 1.0 )
  5814. #endif
  5815. uniform float toneMappingExposure;
  5816. vec3 LinearToneMapping( vec3 color ) {
  5817. return saturate( toneMappingExposure * color );
  5818. }
  5819. vec3 ReinhardToneMapping( vec3 color ) {
  5820. color *= toneMappingExposure;
  5821. return saturate( color / ( vec3( 1.0 ) + color ) );
  5822. }
  5823. vec3 OptimizedCineonToneMapping( vec3 color ) {
  5824. color *= toneMappingExposure;
  5825. color = max( vec3( 0.0 ), color - 0.004 );
  5826. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  5827. }
  5828. vec3 RRTAndODTFit( vec3 v ) {
  5829. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  5830. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  5831. return a / b;
  5832. }
  5833. vec3 ACESFilmicToneMapping( vec3 color ) {
  5834. const mat3 ACESInputMat = mat3(
  5835. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  5836. vec3( 0.04823, 0.01566, 0.83777 )
  5837. );
  5838. const mat3 ACESOutputMat = mat3(
  5839. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  5840. vec3( -0.07367, -0.00605, 1.07602 )
  5841. );
  5842. color *= toneMappingExposure / 0.6;
  5843. color = ACESInputMat * color;
  5844. color = RRTAndODTFit( color );
  5845. color = ACESOutputMat * color;
  5846. return saturate( color );
  5847. }
  5848. vec3 CustomToneMapping( vec3 color ) { return color; }`,s1e=`#ifdef USE_TRANSMISSION
  5849. material.transmission = transmission;
  5850. material.transmissionAlpha = 1.0;
  5851. material.thickness = thickness;
  5852. material.attenuationDistance = attenuationDistance;
  5853. material.attenuationColor = attenuationColor;
  5854. #ifdef USE_TRANSMISSIONMAP
  5855. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  5856. #endif
  5857. #ifdef USE_THICKNESSMAP
  5858. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  5859. #endif
  5860. vec3 pos = vWorldPosition;
  5861. vec3 v = normalize( cameraPosition - pos );
  5862. vec3 n = inverseTransformDirection( normal, viewMatrix );
  5863. vec4 transmitted = getIBLVolumeRefraction(
  5864. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  5865. pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
  5866. material.attenuationColor, material.attenuationDistance );
  5867. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  5868. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  5869. #endif`,o1e=`#ifdef USE_TRANSMISSION
  5870. uniform float transmission;
  5871. uniform float thickness;
  5872. uniform float attenuationDistance;
  5873. uniform vec3 attenuationColor;
  5874. #ifdef USE_TRANSMISSIONMAP
  5875. uniform sampler2D transmissionMap;
  5876. #endif
  5877. #ifdef USE_THICKNESSMAP
  5878. uniform sampler2D thicknessMap;
  5879. #endif
  5880. uniform vec2 transmissionSamplerSize;
  5881. uniform sampler2D transmissionSamplerMap;
  5882. uniform mat4 modelMatrix;
  5883. uniform mat4 projectionMatrix;
  5884. varying vec3 vWorldPosition;
  5885. float w0( float a ) {
  5886. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  5887. }
  5888. float w1( float a ) {
  5889. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  5890. }
  5891. float w2( float a ){
  5892. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  5893. }
  5894. float w3( float a ) {
  5895. return ( 1.0 / 6.0 ) * ( a * a * a );
  5896. }
  5897. float g0( float a ) {
  5898. return w0( a ) + w1( a );
  5899. }
  5900. float g1( float a ) {
  5901. return w2( a ) + w3( a );
  5902. }
  5903. float h0( float a ) {
  5904. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  5905. }
  5906. float h1( float a ) {
  5907. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  5908. }
  5909. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  5910. uv = uv * texelSize.zw + 0.5;
  5911. vec2 iuv = floor( uv );
  5912. vec2 fuv = fract( uv );
  5913. float g0x = g0( fuv.x );
  5914. float g1x = g1( fuv.x );
  5915. float h0x = h0( fuv.x );
  5916. float h1x = h1( fuv.x );
  5917. float h0y = h0( fuv.y );
  5918. float h1y = h1( fuv.y );
  5919. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  5920. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  5921. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  5922. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  5923. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  5924. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  5925. }
  5926. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  5927. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  5928. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  5929. vec2 fLodSizeInv = 1.0 / fLodSize;
  5930. vec2 cLodSizeInv = 1.0 / cLodSize;
  5931. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  5932. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  5933. return mix( fSample, cSample, fract( lod ) );
  5934. }
  5935. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  5936. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  5937. vec3 modelScale;
  5938. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  5939. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  5940. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  5941. return normalize( refractionVector ) * thickness * modelScale;
  5942. }
  5943. float applyIorToRoughness( const in float roughness, const in float ior ) {
  5944. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  5945. }
  5946. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  5947. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  5948. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  5949. }
  5950. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  5951. if ( isinf( attenuationDistance ) ) {
  5952. return vec3( 1.0 );
  5953. } else {
  5954. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  5955. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  5956. }
  5957. }
  5958. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  5959. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  5960. const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
  5961. const in vec3 attenuationColor, const in float attenuationDistance ) {
  5962. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  5963. vec3 refractedRayExit = position + transmissionRay;
  5964. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  5965. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  5966. refractionCoords += 1.0;
  5967. refractionCoords /= 2.0;
  5968. vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  5969. vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  5970. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  5971. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  5972. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  5973. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  5974. }
  5975. #endif`,l1e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  5976. varying vec2 vUv;
  5977. #endif
  5978. #ifdef USE_MAP
  5979. varying vec2 vMapUv;
  5980. #endif
  5981. #ifdef USE_ALPHAMAP
  5982. varying vec2 vAlphaMapUv;
  5983. #endif
  5984. #ifdef USE_LIGHTMAP
  5985. varying vec2 vLightMapUv;
  5986. #endif
  5987. #ifdef USE_AOMAP
  5988. varying vec2 vAoMapUv;
  5989. #endif
  5990. #ifdef USE_BUMPMAP
  5991. varying vec2 vBumpMapUv;
  5992. #endif
  5993. #ifdef USE_NORMALMAP
  5994. varying vec2 vNormalMapUv;
  5995. #endif
  5996. #ifdef USE_EMISSIVEMAP
  5997. varying vec2 vEmissiveMapUv;
  5998. #endif
  5999. #ifdef USE_METALNESSMAP
  6000. varying vec2 vMetalnessMapUv;
  6001. #endif
  6002. #ifdef USE_ROUGHNESSMAP
  6003. varying vec2 vRoughnessMapUv;
  6004. #endif
  6005. #ifdef USE_ANISOTROPYMAP
  6006. varying vec2 vAnisotropyMapUv;
  6007. #endif
  6008. #ifdef USE_CLEARCOATMAP
  6009. varying vec2 vClearcoatMapUv;
  6010. #endif
  6011. #ifdef USE_CLEARCOAT_NORMALMAP
  6012. varying vec2 vClearcoatNormalMapUv;
  6013. #endif
  6014. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6015. varying vec2 vClearcoatRoughnessMapUv;
  6016. #endif
  6017. #ifdef USE_IRIDESCENCEMAP
  6018. varying vec2 vIridescenceMapUv;
  6019. #endif
  6020. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6021. varying vec2 vIridescenceThicknessMapUv;
  6022. #endif
  6023. #ifdef USE_SHEEN_COLORMAP
  6024. varying vec2 vSheenColorMapUv;
  6025. #endif
  6026. #ifdef USE_SHEEN_ROUGHNESSMAP
  6027. varying vec2 vSheenRoughnessMapUv;
  6028. #endif
  6029. #ifdef USE_SPECULARMAP
  6030. varying vec2 vSpecularMapUv;
  6031. #endif
  6032. #ifdef USE_SPECULAR_COLORMAP
  6033. varying vec2 vSpecularColorMapUv;
  6034. #endif
  6035. #ifdef USE_SPECULAR_INTENSITYMAP
  6036. varying vec2 vSpecularIntensityMapUv;
  6037. #endif
  6038. #ifdef USE_TRANSMISSIONMAP
  6039. uniform mat3 transmissionMapTransform;
  6040. varying vec2 vTransmissionMapUv;
  6041. #endif
  6042. #ifdef USE_THICKNESSMAP
  6043. uniform mat3 thicknessMapTransform;
  6044. varying vec2 vThicknessMapUv;
  6045. #endif`,c1e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6046. varying vec2 vUv;
  6047. #endif
  6048. #ifdef USE_MAP
  6049. uniform mat3 mapTransform;
  6050. varying vec2 vMapUv;
  6051. #endif
  6052. #ifdef USE_ALPHAMAP
  6053. uniform mat3 alphaMapTransform;
  6054. varying vec2 vAlphaMapUv;
  6055. #endif
  6056. #ifdef USE_LIGHTMAP
  6057. uniform mat3 lightMapTransform;
  6058. varying vec2 vLightMapUv;
  6059. #endif
  6060. #ifdef USE_AOMAP
  6061. uniform mat3 aoMapTransform;
  6062. varying vec2 vAoMapUv;
  6063. #endif
  6064. #ifdef USE_BUMPMAP
  6065. uniform mat3 bumpMapTransform;
  6066. varying vec2 vBumpMapUv;
  6067. #endif
  6068. #ifdef USE_NORMALMAP
  6069. uniform mat3 normalMapTransform;
  6070. varying vec2 vNormalMapUv;
  6071. #endif
  6072. #ifdef USE_DISPLACEMENTMAP
  6073. uniform mat3 displacementMapTransform;
  6074. varying vec2 vDisplacementMapUv;
  6075. #endif
  6076. #ifdef USE_EMISSIVEMAP
  6077. uniform mat3 emissiveMapTransform;
  6078. varying vec2 vEmissiveMapUv;
  6079. #endif
  6080. #ifdef USE_METALNESSMAP
  6081. uniform mat3 metalnessMapTransform;
  6082. varying vec2 vMetalnessMapUv;
  6083. #endif
  6084. #ifdef USE_ROUGHNESSMAP
  6085. uniform mat3 roughnessMapTransform;
  6086. varying vec2 vRoughnessMapUv;
  6087. #endif
  6088. #ifdef USE_ANISOTROPYMAP
  6089. uniform mat3 anisotropyMapTransform;
  6090. varying vec2 vAnisotropyMapUv;
  6091. #endif
  6092. #ifdef USE_CLEARCOATMAP
  6093. uniform mat3 clearcoatMapTransform;
  6094. varying vec2 vClearcoatMapUv;
  6095. #endif
  6096. #ifdef USE_CLEARCOAT_NORMALMAP
  6097. uniform mat3 clearcoatNormalMapTransform;
  6098. varying vec2 vClearcoatNormalMapUv;
  6099. #endif
  6100. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6101. uniform mat3 clearcoatRoughnessMapTransform;
  6102. varying vec2 vClearcoatRoughnessMapUv;
  6103. #endif
  6104. #ifdef USE_SHEEN_COLORMAP
  6105. uniform mat3 sheenColorMapTransform;
  6106. varying vec2 vSheenColorMapUv;
  6107. #endif
  6108. #ifdef USE_SHEEN_ROUGHNESSMAP
  6109. uniform mat3 sheenRoughnessMapTransform;
  6110. varying vec2 vSheenRoughnessMapUv;
  6111. #endif
  6112. #ifdef USE_IRIDESCENCEMAP
  6113. uniform mat3 iridescenceMapTransform;
  6114. varying vec2 vIridescenceMapUv;
  6115. #endif
  6116. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6117. uniform mat3 iridescenceThicknessMapTransform;
  6118. varying vec2 vIridescenceThicknessMapUv;
  6119. #endif
  6120. #ifdef USE_SPECULARMAP
  6121. uniform mat3 specularMapTransform;
  6122. varying vec2 vSpecularMapUv;
  6123. #endif
  6124. #ifdef USE_SPECULAR_COLORMAP
  6125. uniform mat3 specularColorMapTransform;
  6126. varying vec2 vSpecularColorMapUv;
  6127. #endif
  6128. #ifdef USE_SPECULAR_INTENSITYMAP
  6129. uniform mat3 specularIntensityMapTransform;
  6130. varying vec2 vSpecularIntensityMapUv;
  6131. #endif
  6132. #ifdef USE_TRANSMISSIONMAP
  6133. uniform mat3 transmissionMapTransform;
  6134. varying vec2 vTransmissionMapUv;
  6135. #endif
  6136. #ifdef USE_THICKNESSMAP
  6137. uniform mat3 thicknessMapTransform;
  6138. varying vec2 vThicknessMapUv;
  6139. #endif`,u1e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6140. vUv = vec3( uv, 1 ).xy;
  6141. #endif
  6142. #ifdef USE_MAP
  6143. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  6144. #endif
  6145. #ifdef USE_ALPHAMAP
  6146. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  6147. #endif
  6148. #ifdef USE_LIGHTMAP
  6149. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  6150. #endif
  6151. #ifdef USE_AOMAP
  6152. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  6153. #endif
  6154. #ifdef USE_BUMPMAP
  6155. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  6156. #endif
  6157. #ifdef USE_NORMALMAP
  6158. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  6159. #endif
  6160. #ifdef USE_DISPLACEMENTMAP
  6161. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  6162. #endif
  6163. #ifdef USE_EMISSIVEMAP
  6164. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  6165. #endif
  6166. #ifdef USE_METALNESSMAP
  6167. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  6168. #endif
  6169. #ifdef USE_ROUGHNESSMAP
  6170. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  6171. #endif
  6172. #ifdef USE_ANISOTROPYMAP
  6173. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  6174. #endif
  6175. #ifdef USE_CLEARCOATMAP
  6176. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  6177. #endif
  6178. #ifdef USE_CLEARCOAT_NORMALMAP
  6179. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  6180. #endif
  6181. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6182. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  6183. #endif
  6184. #ifdef USE_IRIDESCENCEMAP
  6185. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  6186. #endif
  6187. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6188. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  6189. #endif
  6190. #ifdef USE_SHEEN_COLORMAP
  6191. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  6192. #endif
  6193. #ifdef USE_SHEEN_ROUGHNESSMAP
  6194. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  6195. #endif
  6196. #ifdef USE_SPECULARMAP
  6197. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  6198. #endif
  6199. #ifdef USE_SPECULAR_COLORMAP
  6200. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  6201. #endif
  6202. #ifdef USE_SPECULAR_INTENSITYMAP
  6203. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  6204. #endif
  6205. #ifdef USE_TRANSMISSIONMAP
  6206. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  6207. #endif
  6208. #ifdef USE_THICKNESSMAP
  6209. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  6210. #endif`,d1e=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  6211. vec4 worldPosition = vec4( transformed, 1.0 );
  6212. #ifdef USE_BATCHING
  6213. worldPosition = batchingMatrix * worldPosition;
  6214. #endif
  6215. #ifdef USE_INSTANCING
  6216. worldPosition = instanceMatrix * worldPosition;
  6217. #endif
  6218. worldPosition = modelMatrix * worldPosition;
  6219. #endif`;const h1e=`varying vec2 vUv;
  6220. uniform mat3 uvTransform;
  6221. void main() {
  6222. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  6223. gl_Position = vec4( position.xy, 1.0, 1.0 );
  6224. }`,f1e=`uniform sampler2D t2D;
  6225. uniform float backgroundIntensity;
  6226. varying vec2 vUv;
  6227. void main() {
  6228. vec4 texColor = texture2D( t2D, vUv );
  6229. #ifdef DECODE_VIDEO_TEXTURE
  6230. 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 );
  6231. #endif
  6232. texColor.rgb *= backgroundIntensity;
  6233. gl_FragColor = texColor;
  6234. #include <tonemapping_fragment>
  6235. #include <colorspace_fragment>
  6236. }`,m1e=`varying vec3 vWorldDirection;
  6237. #include <common>
  6238. void main() {
  6239. vWorldDirection = transformDirection( position, modelMatrix );
  6240. #include <begin_vertex>
  6241. #include <project_vertex>
  6242. gl_Position.z = gl_Position.w;
  6243. }`,p1e=`#ifdef ENVMAP_TYPE_CUBE
  6244. uniform samplerCube envMap;
  6245. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6246. uniform sampler2D envMap;
  6247. #endif
  6248. uniform float flipEnvMap;
  6249. uniform float backgroundBlurriness;
  6250. uniform float backgroundIntensity;
  6251. varying vec3 vWorldDirection;
  6252. #include <cube_uv_reflection_fragment>
  6253. void main() {
  6254. #ifdef ENVMAP_TYPE_CUBE
  6255. vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  6256. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6257. vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
  6258. #else
  6259. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  6260. #endif
  6261. texColor.rgb *= backgroundIntensity;
  6262. gl_FragColor = texColor;
  6263. #include <tonemapping_fragment>
  6264. #include <colorspace_fragment>
  6265. }`,g1e=`varying vec3 vWorldDirection;
  6266. #include <common>
  6267. void main() {
  6268. vWorldDirection = transformDirection( position, modelMatrix );
  6269. #include <begin_vertex>
  6270. #include <project_vertex>
  6271. gl_Position.z = gl_Position.w;
  6272. }`,x1e=`uniform samplerCube tCube;
  6273. uniform float tFlip;
  6274. uniform float opacity;
  6275. varying vec3 vWorldDirection;
  6276. void main() {
  6277. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  6278. gl_FragColor = texColor;
  6279. gl_FragColor.a *= opacity;
  6280. #include <tonemapping_fragment>
  6281. #include <colorspace_fragment>
  6282. }`,b1e=`#include <common>
  6283. #include <batching_pars_vertex>
  6284. #include <uv_pars_vertex>
  6285. #include <displacementmap_pars_vertex>
  6286. #include <morphtarget_pars_vertex>
  6287. #include <skinning_pars_vertex>
  6288. #include <logdepthbuf_pars_vertex>
  6289. #include <clipping_planes_pars_vertex>
  6290. varying vec2 vHighPrecisionZW;
  6291. void main() {
  6292. #include <uv_vertex>
  6293. #include <batching_vertex>
  6294. #include <skinbase_vertex>
  6295. #ifdef USE_DISPLACEMENTMAP
  6296. #include <beginnormal_vertex>
  6297. #include <morphnormal_vertex>
  6298. #include <skinnormal_vertex>
  6299. #endif
  6300. #include <begin_vertex>
  6301. #include <morphtarget_vertex>
  6302. #include <skinning_vertex>
  6303. #include <displacementmap_vertex>
  6304. #include <project_vertex>
  6305. #include <logdepthbuf_vertex>
  6306. #include <clipping_planes_vertex>
  6307. vHighPrecisionZW = gl_Position.zw;
  6308. }`,y1e=`#if DEPTH_PACKING == 3200
  6309. uniform float opacity;
  6310. #endif
  6311. #include <common>
  6312. #include <packing>
  6313. #include <uv_pars_fragment>
  6314. #include <map_pars_fragment>
  6315. #include <alphamap_pars_fragment>
  6316. #include <alphatest_pars_fragment>
  6317. #include <alphahash_pars_fragment>
  6318. #include <logdepthbuf_pars_fragment>
  6319. #include <clipping_planes_pars_fragment>
  6320. varying vec2 vHighPrecisionZW;
  6321. void main() {
  6322. #include <clipping_planes_fragment>
  6323. vec4 diffuseColor = vec4( 1.0 );
  6324. #if DEPTH_PACKING == 3200
  6325. diffuseColor.a = opacity;
  6326. #endif
  6327. #include <map_fragment>
  6328. #include <alphamap_fragment>
  6329. #include <alphatest_fragment>
  6330. #include <alphahash_fragment>
  6331. #include <logdepthbuf_fragment>
  6332. float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
  6333. #if DEPTH_PACKING == 3200
  6334. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  6335. #elif DEPTH_PACKING == 3201
  6336. gl_FragColor = packDepthToRGBA( fragCoordZ );
  6337. #endif
  6338. }`,v1e=`#define DISTANCE
  6339. varying vec3 vWorldPosition;
  6340. #include <common>
  6341. #include <batching_pars_vertex>
  6342. #include <uv_pars_vertex>
  6343. #include <displacementmap_pars_vertex>
  6344. #include <morphtarget_pars_vertex>
  6345. #include <skinning_pars_vertex>
  6346. #include <clipping_planes_pars_vertex>
  6347. void main() {
  6348. #include <uv_vertex>
  6349. #include <batching_vertex>
  6350. #include <skinbase_vertex>
  6351. #ifdef USE_DISPLACEMENTMAP
  6352. #include <beginnormal_vertex>
  6353. #include <morphnormal_vertex>
  6354. #include <skinnormal_vertex>
  6355. #endif
  6356. #include <begin_vertex>
  6357. #include <morphtarget_vertex>
  6358. #include <skinning_vertex>
  6359. #include <displacementmap_vertex>
  6360. #include <project_vertex>
  6361. #include <worldpos_vertex>
  6362. #include <clipping_planes_vertex>
  6363. vWorldPosition = worldPosition.xyz;
  6364. }`,_1e=`#define DISTANCE
  6365. uniform vec3 referencePosition;
  6366. uniform float nearDistance;
  6367. uniform float farDistance;
  6368. varying vec3 vWorldPosition;
  6369. #include <common>
  6370. #include <packing>
  6371. #include <uv_pars_fragment>
  6372. #include <map_pars_fragment>
  6373. #include <alphamap_pars_fragment>
  6374. #include <alphatest_pars_fragment>
  6375. #include <alphahash_pars_fragment>
  6376. #include <clipping_planes_pars_fragment>
  6377. void main () {
  6378. #include <clipping_planes_fragment>
  6379. vec4 diffuseColor = vec4( 1.0 );
  6380. #include <map_fragment>
  6381. #include <alphamap_fragment>
  6382. #include <alphatest_fragment>
  6383. #include <alphahash_fragment>
  6384. float dist = length( vWorldPosition - referencePosition );
  6385. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  6386. dist = saturate( dist );
  6387. gl_FragColor = packDepthToRGBA( dist );
  6388. }`,w1e=`varying vec3 vWorldDirection;
  6389. #include <common>
  6390. void main() {
  6391. vWorldDirection = transformDirection( position, modelMatrix );
  6392. #include <begin_vertex>
  6393. #include <project_vertex>
  6394. }`,S1e=`uniform sampler2D tEquirect;
  6395. varying vec3 vWorldDirection;
  6396. #include <common>
  6397. void main() {
  6398. vec3 direction = normalize( vWorldDirection );
  6399. vec2 sampleUV = equirectUv( direction );
  6400. gl_FragColor = texture2D( tEquirect, sampleUV );
  6401. #include <tonemapping_fragment>
  6402. #include <colorspace_fragment>
  6403. }`,N1e=`uniform float scale;
  6404. attribute float lineDistance;
  6405. varying float vLineDistance;
  6406. #include <common>
  6407. #include <uv_pars_vertex>
  6408. #include <color_pars_vertex>
  6409. #include <fog_pars_vertex>
  6410. #include <morphtarget_pars_vertex>
  6411. #include <logdepthbuf_pars_vertex>
  6412. #include <clipping_planes_pars_vertex>
  6413. void main() {
  6414. vLineDistance = scale * lineDistance;
  6415. #include <uv_vertex>
  6416. #include <color_vertex>
  6417. #include <morphcolor_vertex>
  6418. #include <begin_vertex>
  6419. #include <morphtarget_vertex>
  6420. #include <project_vertex>
  6421. #include <logdepthbuf_vertex>
  6422. #include <clipping_planes_vertex>
  6423. #include <fog_vertex>
  6424. }`,M1e=`uniform vec3 diffuse;
  6425. uniform float opacity;
  6426. uniform float dashSize;
  6427. uniform float totalSize;
  6428. varying float vLineDistance;
  6429. #include <common>
  6430. #include <color_pars_fragment>
  6431. #include <uv_pars_fragment>
  6432. #include <map_pars_fragment>
  6433. #include <fog_pars_fragment>
  6434. #include <logdepthbuf_pars_fragment>
  6435. #include <clipping_planes_pars_fragment>
  6436. void main() {
  6437. #include <clipping_planes_fragment>
  6438. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  6439. discard;
  6440. }
  6441. vec3 outgoingLight = vec3( 0.0 );
  6442. vec4 diffuseColor = vec4( diffuse, opacity );
  6443. #include <logdepthbuf_fragment>
  6444. #include <map_fragment>
  6445. #include <color_fragment>
  6446. outgoingLight = diffuseColor.rgb;
  6447. #include <opaque_fragment>
  6448. #include <tonemapping_fragment>
  6449. #include <colorspace_fragment>
  6450. #include <fog_fragment>
  6451. #include <premultiplied_alpha_fragment>
  6452. }`,E1e=`#include <common>
  6453. #include <batching_pars_vertex>
  6454. #include <uv_pars_vertex>
  6455. #include <envmap_pars_vertex>
  6456. #include <color_pars_vertex>
  6457. #include <fog_pars_vertex>
  6458. #include <morphtarget_pars_vertex>
  6459. #include <skinning_pars_vertex>
  6460. #include <logdepthbuf_pars_vertex>
  6461. #include <clipping_planes_pars_vertex>
  6462. void main() {
  6463. #include <uv_vertex>
  6464. #include <color_vertex>
  6465. #include <morphcolor_vertex>
  6466. #include <batching_vertex>
  6467. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  6468. #include <beginnormal_vertex>
  6469. #include <morphnormal_vertex>
  6470. #include <skinbase_vertex>
  6471. #include <skinnormal_vertex>
  6472. #include <defaultnormal_vertex>
  6473. #endif
  6474. #include <begin_vertex>
  6475. #include <morphtarget_vertex>
  6476. #include <skinning_vertex>
  6477. #include <project_vertex>
  6478. #include <logdepthbuf_vertex>
  6479. #include <clipping_planes_vertex>
  6480. #include <worldpos_vertex>
  6481. #include <envmap_vertex>
  6482. #include <fog_vertex>
  6483. }`,C1e=`uniform vec3 diffuse;
  6484. uniform float opacity;
  6485. #ifndef FLAT_SHADED
  6486. varying vec3 vNormal;
  6487. #endif
  6488. #include <common>
  6489. #include <dithering_pars_fragment>
  6490. #include <color_pars_fragment>
  6491. #include <uv_pars_fragment>
  6492. #include <map_pars_fragment>
  6493. #include <alphamap_pars_fragment>
  6494. #include <alphatest_pars_fragment>
  6495. #include <alphahash_pars_fragment>
  6496. #include <aomap_pars_fragment>
  6497. #include <lightmap_pars_fragment>
  6498. #include <envmap_common_pars_fragment>
  6499. #include <envmap_pars_fragment>
  6500. #include <fog_pars_fragment>
  6501. #include <specularmap_pars_fragment>
  6502. #include <logdepthbuf_pars_fragment>
  6503. #include <clipping_planes_pars_fragment>
  6504. void main() {
  6505. #include <clipping_planes_fragment>
  6506. vec4 diffuseColor = vec4( diffuse, opacity );
  6507. #include <logdepthbuf_fragment>
  6508. #include <map_fragment>
  6509. #include <color_fragment>
  6510. #include <alphamap_fragment>
  6511. #include <alphatest_fragment>
  6512. #include <alphahash_fragment>
  6513. #include <specularmap_fragment>
  6514. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6515. #ifdef USE_LIGHTMAP
  6516. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  6517. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  6518. #else
  6519. reflectedLight.indirectDiffuse += vec3( 1.0 );
  6520. #endif
  6521. #include <aomap_fragment>
  6522. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  6523. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  6524. #include <envmap_fragment>
  6525. #include <opaque_fragment>
  6526. #include <tonemapping_fragment>
  6527. #include <colorspace_fragment>
  6528. #include <fog_fragment>
  6529. #include <premultiplied_alpha_fragment>
  6530. #include <dithering_fragment>
  6531. }`,T1e=`#define LAMBERT
  6532. varying vec3 vViewPosition;
  6533. #include <common>
  6534. #include <batching_pars_vertex>
  6535. #include <uv_pars_vertex>
  6536. #include <displacementmap_pars_vertex>
  6537. #include <envmap_pars_vertex>
  6538. #include <color_pars_vertex>
  6539. #include <fog_pars_vertex>
  6540. #include <normal_pars_vertex>
  6541. #include <morphtarget_pars_vertex>
  6542. #include <skinning_pars_vertex>
  6543. #include <shadowmap_pars_vertex>
  6544. #include <logdepthbuf_pars_vertex>
  6545. #include <clipping_planes_pars_vertex>
  6546. void main() {
  6547. #include <uv_vertex>
  6548. #include <color_vertex>
  6549. #include <morphcolor_vertex>
  6550. #include <batching_vertex>
  6551. #include <beginnormal_vertex>
  6552. #include <morphnormal_vertex>
  6553. #include <skinbase_vertex>
  6554. #include <skinnormal_vertex>
  6555. #include <defaultnormal_vertex>
  6556. #include <normal_vertex>
  6557. #include <begin_vertex>
  6558. #include <morphtarget_vertex>
  6559. #include <skinning_vertex>
  6560. #include <displacementmap_vertex>
  6561. #include <project_vertex>
  6562. #include <logdepthbuf_vertex>
  6563. #include <clipping_planes_vertex>
  6564. vViewPosition = - mvPosition.xyz;
  6565. #include <worldpos_vertex>
  6566. #include <envmap_vertex>
  6567. #include <shadowmap_vertex>
  6568. #include <fog_vertex>
  6569. }`,A1e=`#define LAMBERT
  6570. uniform vec3 diffuse;
  6571. uniform vec3 emissive;
  6572. uniform float opacity;
  6573. #include <common>
  6574. #include <packing>
  6575. #include <dithering_pars_fragment>
  6576. #include <color_pars_fragment>
  6577. #include <uv_pars_fragment>
  6578. #include <map_pars_fragment>
  6579. #include <alphamap_pars_fragment>
  6580. #include <alphatest_pars_fragment>
  6581. #include <alphahash_pars_fragment>
  6582. #include <aomap_pars_fragment>
  6583. #include <lightmap_pars_fragment>
  6584. #include <emissivemap_pars_fragment>
  6585. #include <envmap_common_pars_fragment>
  6586. #include <envmap_pars_fragment>
  6587. #include <fog_pars_fragment>
  6588. #include <bsdfs>
  6589. #include <lights_pars_begin>
  6590. #include <normal_pars_fragment>
  6591. #include <lights_lambert_pars_fragment>
  6592. #include <shadowmap_pars_fragment>
  6593. #include <bumpmap_pars_fragment>
  6594. #include <normalmap_pars_fragment>
  6595. #include <specularmap_pars_fragment>
  6596. #include <logdepthbuf_pars_fragment>
  6597. #include <clipping_planes_pars_fragment>
  6598. void main() {
  6599. #include <clipping_planes_fragment>
  6600. vec4 diffuseColor = vec4( diffuse, opacity );
  6601. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6602. vec3 totalEmissiveRadiance = emissive;
  6603. #include <logdepthbuf_fragment>
  6604. #include <map_fragment>
  6605. #include <color_fragment>
  6606. #include <alphamap_fragment>
  6607. #include <alphatest_fragment>
  6608. #include <alphahash_fragment>
  6609. #include <specularmap_fragment>
  6610. #include <normal_fragment_begin>
  6611. #include <normal_fragment_maps>
  6612. #include <emissivemap_fragment>
  6613. #include <lights_lambert_fragment>
  6614. #include <lights_fragment_begin>
  6615. #include <lights_fragment_maps>
  6616. #include <lights_fragment_end>
  6617. #include <aomap_fragment>
  6618. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  6619. #include <envmap_fragment>
  6620. #include <opaque_fragment>
  6621. #include <tonemapping_fragment>
  6622. #include <colorspace_fragment>
  6623. #include <fog_fragment>
  6624. #include <premultiplied_alpha_fragment>
  6625. #include <dithering_fragment>
  6626. }`,k1e=`#define MATCAP
  6627. varying vec3 vViewPosition;
  6628. #include <common>
  6629. #include <batching_pars_vertex>
  6630. #include <uv_pars_vertex>
  6631. #include <color_pars_vertex>
  6632. #include <displacementmap_pars_vertex>
  6633. #include <fog_pars_vertex>
  6634. #include <normal_pars_vertex>
  6635. #include <morphtarget_pars_vertex>
  6636. #include <skinning_pars_vertex>
  6637. #include <logdepthbuf_pars_vertex>
  6638. #include <clipping_planes_pars_vertex>
  6639. void main() {
  6640. #include <uv_vertex>
  6641. #include <color_vertex>
  6642. #include <morphcolor_vertex>
  6643. #include <batching_vertex>
  6644. #include <beginnormal_vertex>
  6645. #include <morphnormal_vertex>
  6646. #include <skinbase_vertex>
  6647. #include <skinnormal_vertex>
  6648. #include <defaultnormal_vertex>
  6649. #include <normal_vertex>
  6650. #include <begin_vertex>
  6651. #include <morphtarget_vertex>
  6652. #include <skinning_vertex>
  6653. #include <displacementmap_vertex>
  6654. #include <project_vertex>
  6655. #include <logdepthbuf_vertex>
  6656. #include <clipping_planes_vertex>
  6657. #include <fog_vertex>
  6658. vViewPosition = - mvPosition.xyz;
  6659. }`,j1e=`#define MATCAP
  6660. uniform vec3 diffuse;
  6661. uniform float opacity;
  6662. uniform sampler2D matcap;
  6663. varying vec3 vViewPosition;
  6664. #include <common>
  6665. #include <dithering_pars_fragment>
  6666. #include <color_pars_fragment>
  6667. #include <uv_pars_fragment>
  6668. #include <map_pars_fragment>
  6669. #include <alphamap_pars_fragment>
  6670. #include <alphatest_pars_fragment>
  6671. #include <alphahash_pars_fragment>
  6672. #include <fog_pars_fragment>
  6673. #include <normal_pars_fragment>
  6674. #include <bumpmap_pars_fragment>
  6675. #include <normalmap_pars_fragment>
  6676. #include <logdepthbuf_pars_fragment>
  6677. #include <clipping_planes_pars_fragment>
  6678. void main() {
  6679. #include <clipping_planes_fragment>
  6680. vec4 diffuseColor = vec4( diffuse, opacity );
  6681. #include <logdepthbuf_fragment>
  6682. #include <map_fragment>
  6683. #include <color_fragment>
  6684. #include <alphamap_fragment>
  6685. #include <alphatest_fragment>
  6686. #include <alphahash_fragment>
  6687. #include <normal_fragment_begin>
  6688. #include <normal_fragment_maps>
  6689. vec3 viewDir = normalize( vViewPosition );
  6690. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  6691. vec3 y = cross( viewDir, x );
  6692. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  6693. #ifdef USE_MATCAP
  6694. vec4 matcapColor = texture2D( matcap, uv );
  6695. #else
  6696. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  6697. #endif
  6698. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  6699. #include <opaque_fragment>
  6700. #include <tonemapping_fragment>
  6701. #include <colorspace_fragment>
  6702. #include <fog_fragment>
  6703. #include <premultiplied_alpha_fragment>
  6704. #include <dithering_fragment>
  6705. }`,P1e=`#define NORMAL
  6706. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6707. varying vec3 vViewPosition;
  6708. #endif
  6709. #include <common>
  6710. #include <batching_pars_vertex>
  6711. #include <uv_pars_vertex>
  6712. #include <displacementmap_pars_vertex>
  6713. #include <normal_pars_vertex>
  6714. #include <morphtarget_pars_vertex>
  6715. #include <skinning_pars_vertex>
  6716. #include <logdepthbuf_pars_vertex>
  6717. #include <clipping_planes_pars_vertex>
  6718. void main() {
  6719. #include <uv_vertex>
  6720. #include <batching_vertex>
  6721. #include <beginnormal_vertex>
  6722. #include <morphnormal_vertex>
  6723. #include <skinbase_vertex>
  6724. #include <skinnormal_vertex>
  6725. #include <defaultnormal_vertex>
  6726. #include <normal_vertex>
  6727. #include <begin_vertex>
  6728. #include <morphtarget_vertex>
  6729. #include <skinning_vertex>
  6730. #include <displacementmap_vertex>
  6731. #include <project_vertex>
  6732. #include <logdepthbuf_vertex>
  6733. #include <clipping_planes_vertex>
  6734. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6735. vViewPosition = - mvPosition.xyz;
  6736. #endif
  6737. }`,R1e=`#define NORMAL
  6738. uniform float opacity;
  6739. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6740. varying vec3 vViewPosition;
  6741. #endif
  6742. #include <packing>
  6743. #include <uv_pars_fragment>
  6744. #include <normal_pars_fragment>
  6745. #include <bumpmap_pars_fragment>
  6746. #include <normalmap_pars_fragment>
  6747. #include <logdepthbuf_pars_fragment>
  6748. #include <clipping_planes_pars_fragment>
  6749. void main() {
  6750. #include <clipping_planes_fragment>
  6751. #include <logdepthbuf_fragment>
  6752. #include <normal_fragment_begin>
  6753. #include <normal_fragment_maps>
  6754. gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
  6755. #ifdef OPAQUE
  6756. gl_FragColor.a = 1.0;
  6757. #endif
  6758. }`,D1e=`#define PHONG
  6759. varying vec3 vViewPosition;
  6760. #include <common>
  6761. #include <batching_pars_vertex>
  6762. #include <uv_pars_vertex>
  6763. #include <displacementmap_pars_vertex>
  6764. #include <envmap_pars_vertex>
  6765. #include <color_pars_vertex>
  6766. #include <fog_pars_vertex>
  6767. #include <normal_pars_vertex>
  6768. #include <morphtarget_pars_vertex>
  6769. #include <skinning_pars_vertex>
  6770. #include <shadowmap_pars_vertex>
  6771. #include <logdepthbuf_pars_vertex>
  6772. #include <clipping_planes_pars_vertex>
  6773. void main() {
  6774. #include <uv_vertex>
  6775. #include <color_vertex>
  6776. #include <morphcolor_vertex>
  6777. #include <batching_vertex>
  6778. #include <beginnormal_vertex>
  6779. #include <morphnormal_vertex>
  6780. #include <skinbase_vertex>
  6781. #include <skinnormal_vertex>
  6782. #include <defaultnormal_vertex>
  6783. #include <normal_vertex>
  6784. #include <begin_vertex>
  6785. #include <morphtarget_vertex>
  6786. #include <skinning_vertex>
  6787. #include <displacementmap_vertex>
  6788. #include <project_vertex>
  6789. #include <logdepthbuf_vertex>
  6790. #include <clipping_planes_vertex>
  6791. vViewPosition = - mvPosition.xyz;
  6792. #include <worldpos_vertex>
  6793. #include <envmap_vertex>
  6794. #include <shadowmap_vertex>
  6795. #include <fog_vertex>
  6796. }`,O1e=`#define PHONG
  6797. uniform vec3 diffuse;
  6798. uniform vec3 emissive;
  6799. uniform vec3 specular;
  6800. uniform float shininess;
  6801. uniform float opacity;
  6802. #include <common>
  6803. #include <packing>
  6804. #include <dithering_pars_fragment>
  6805. #include <color_pars_fragment>
  6806. #include <uv_pars_fragment>
  6807. #include <map_pars_fragment>
  6808. #include <alphamap_pars_fragment>
  6809. #include <alphatest_pars_fragment>
  6810. #include <alphahash_pars_fragment>
  6811. #include <aomap_pars_fragment>
  6812. #include <lightmap_pars_fragment>
  6813. #include <emissivemap_pars_fragment>
  6814. #include <envmap_common_pars_fragment>
  6815. #include <envmap_pars_fragment>
  6816. #include <fog_pars_fragment>
  6817. #include <bsdfs>
  6818. #include <lights_pars_begin>
  6819. #include <normal_pars_fragment>
  6820. #include <lights_phong_pars_fragment>
  6821. #include <shadowmap_pars_fragment>
  6822. #include <bumpmap_pars_fragment>
  6823. #include <normalmap_pars_fragment>
  6824. #include <specularmap_pars_fragment>
  6825. #include <logdepthbuf_pars_fragment>
  6826. #include <clipping_planes_pars_fragment>
  6827. void main() {
  6828. #include <clipping_planes_fragment>
  6829. vec4 diffuseColor = vec4( diffuse, opacity );
  6830. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6831. vec3 totalEmissiveRadiance = emissive;
  6832. #include <logdepthbuf_fragment>
  6833. #include <map_fragment>
  6834. #include <color_fragment>
  6835. #include <alphamap_fragment>
  6836. #include <alphatest_fragment>
  6837. #include <alphahash_fragment>
  6838. #include <specularmap_fragment>
  6839. #include <normal_fragment_begin>
  6840. #include <normal_fragment_maps>
  6841. #include <emissivemap_fragment>
  6842. #include <lights_phong_fragment>
  6843. #include <lights_fragment_begin>
  6844. #include <lights_fragment_maps>
  6845. #include <lights_fragment_end>
  6846. #include <aomap_fragment>
  6847. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  6848. #include <envmap_fragment>
  6849. #include <opaque_fragment>
  6850. #include <tonemapping_fragment>
  6851. #include <colorspace_fragment>
  6852. #include <fog_fragment>
  6853. #include <premultiplied_alpha_fragment>
  6854. #include <dithering_fragment>
  6855. }`,L1e=`#define STANDARD
  6856. varying vec3 vViewPosition;
  6857. #ifdef USE_TRANSMISSION
  6858. varying vec3 vWorldPosition;
  6859. #endif
  6860. #include <common>
  6861. #include <batching_pars_vertex>
  6862. #include <uv_pars_vertex>
  6863. #include <displacementmap_pars_vertex>
  6864. #include <color_pars_vertex>
  6865. #include <fog_pars_vertex>
  6866. #include <normal_pars_vertex>
  6867. #include <morphtarget_pars_vertex>
  6868. #include <skinning_pars_vertex>
  6869. #include <shadowmap_pars_vertex>
  6870. #include <logdepthbuf_pars_vertex>
  6871. #include <clipping_planes_pars_vertex>
  6872. void main() {
  6873. #include <uv_vertex>
  6874. #include <color_vertex>
  6875. #include <morphcolor_vertex>
  6876. #include <batching_vertex>
  6877. #include <beginnormal_vertex>
  6878. #include <morphnormal_vertex>
  6879. #include <skinbase_vertex>
  6880. #include <skinnormal_vertex>
  6881. #include <defaultnormal_vertex>
  6882. #include <normal_vertex>
  6883. #include <begin_vertex>
  6884. #include <morphtarget_vertex>
  6885. #include <skinning_vertex>
  6886. #include <displacementmap_vertex>
  6887. #include <project_vertex>
  6888. #include <logdepthbuf_vertex>
  6889. #include <clipping_planes_vertex>
  6890. vViewPosition = - mvPosition.xyz;
  6891. #include <worldpos_vertex>
  6892. #include <shadowmap_vertex>
  6893. #include <fog_vertex>
  6894. #ifdef USE_TRANSMISSION
  6895. vWorldPosition = worldPosition.xyz;
  6896. #endif
  6897. }`,I1e=`#define STANDARD
  6898. #ifdef PHYSICAL
  6899. #define IOR
  6900. #define USE_SPECULAR
  6901. #endif
  6902. uniform vec3 diffuse;
  6903. uniform vec3 emissive;
  6904. uniform float roughness;
  6905. uniform float metalness;
  6906. uniform float opacity;
  6907. #ifdef IOR
  6908. uniform float ior;
  6909. #endif
  6910. #ifdef USE_SPECULAR
  6911. uniform float specularIntensity;
  6912. uniform vec3 specularColor;
  6913. #ifdef USE_SPECULAR_COLORMAP
  6914. uniform sampler2D specularColorMap;
  6915. #endif
  6916. #ifdef USE_SPECULAR_INTENSITYMAP
  6917. uniform sampler2D specularIntensityMap;
  6918. #endif
  6919. #endif
  6920. #ifdef USE_CLEARCOAT
  6921. uniform float clearcoat;
  6922. uniform float clearcoatRoughness;
  6923. #endif
  6924. #ifdef USE_IRIDESCENCE
  6925. uniform float iridescence;
  6926. uniform float iridescenceIOR;
  6927. uniform float iridescenceThicknessMinimum;
  6928. uniform float iridescenceThicknessMaximum;
  6929. #endif
  6930. #ifdef USE_SHEEN
  6931. uniform vec3 sheenColor;
  6932. uniform float sheenRoughness;
  6933. #ifdef USE_SHEEN_COLORMAP
  6934. uniform sampler2D sheenColorMap;
  6935. #endif
  6936. #ifdef USE_SHEEN_ROUGHNESSMAP
  6937. uniform sampler2D sheenRoughnessMap;
  6938. #endif
  6939. #endif
  6940. #ifdef USE_ANISOTROPY
  6941. uniform vec2 anisotropyVector;
  6942. #ifdef USE_ANISOTROPYMAP
  6943. uniform sampler2D anisotropyMap;
  6944. #endif
  6945. #endif
  6946. varying vec3 vViewPosition;
  6947. #include <common>
  6948. #include <packing>
  6949. #include <dithering_pars_fragment>
  6950. #include <color_pars_fragment>
  6951. #include <uv_pars_fragment>
  6952. #include <map_pars_fragment>
  6953. #include <alphamap_pars_fragment>
  6954. #include <alphatest_pars_fragment>
  6955. #include <alphahash_pars_fragment>
  6956. #include <aomap_pars_fragment>
  6957. #include <lightmap_pars_fragment>
  6958. #include <emissivemap_pars_fragment>
  6959. #include <iridescence_fragment>
  6960. #include <cube_uv_reflection_fragment>
  6961. #include <envmap_common_pars_fragment>
  6962. #include <envmap_physical_pars_fragment>
  6963. #include <fog_pars_fragment>
  6964. #include <lights_pars_begin>
  6965. #include <normal_pars_fragment>
  6966. #include <lights_physical_pars_fragment>
  6967. #include <transmission_pars_fragment>
  6968. #include <shadowmap_pars_fragment>
  6969. #include <bumpmap_pars_fragment>
  6970. #include <normalmap_pars_fragment>
  6971. #include <clearcoat_pars_fragment>
  6972. #include <iridescence_pars_fragment>
  6973. #include <roughnessmap_pars_fragment>
  6974. #include <metalnessmap_pars_fragment>
  6975. #include <logdepthbuf_pars_fragment>
  6976. #include <clipping_planes_pars_fragment>
  6977. void main() {
  6978. #include <clipping_planes_fragment>
  6979. vec4 diffuseColor = vec4( diffuse, opacity );
  6980. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6981. vec3 totalEmissiveRadiance = emissive;
  6982. #include <logdepthbuf_fragment>
  6983. #include <map_fragment>
  6984. #include <color_fragment>
  6985. #include <alphamap_fragment>
  6986. #include <alphatest_fragment>
  6987. #include <alphahash_fragment>
  6988. #include <roughnessmap_fragment>
  6989. #include <metalnessmap_fragment>
  6990. #include <normal_fragment_begin>
  6991. #include <normal_fragment_maps>
  6992. #include <clearcoat_normal_fragment_begin>
  6993. #include <clearcoat_normal_fragment_maps>
  6994. #include <emissivemap_fragment>
  6995. #include <lights_physical_fragment>
  6996. #include <lights_fragment_begin>
  6997. #include <lights_fragment_maps>
  6998. #include <lights_fragment_end>
  6999. #include <aomap_fragment>
  7000. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  7001. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  7002. #include <transmission_fragment>
  7003. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  7004. #ifdef USE_SHEEN
  7005. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  7006. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  7007. #endif
  7008. #ifdef USE_CLEARCOAT
  7009. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  7010. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  7011. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  7012. #endif
  7013. #include <opaque_fragment>
  7014. #include <tonemapping_fragment>
  7015. #include <colorspace_fragment>
  7016. #include <fog_fragment>
  7017. #include <premultiplied_alpha_fragment>
  7018. #include <dithering_fragment>
  7019. }`,F1e=`#define TOON
  7020. varying vec3 vViewPosition;
  7021. #include <common>
  7022. #include <batching_pars_vertex>
  7023. #include <uv_pars_vertex>
  7024. #include <displacementmap_pars_vertex>
  7025. #include <color_pars_vertex>
  7026. #include <fog_pars_vertex>
  7027. #include <normal_pars_vertex>
  7028. #include <morphtarget_pars_vertex>
  7029. #include <skinning_pars_vertex>
  7030. #include <shadowmap_pars_vertex>
  7031. #include <logdepthbuf_pars_vertex>
  7032. #include <clipping_planes_pars_vertex>
  7033. void main() {
  7034. #include <uv_vertex>
  7035. #include <color_vertex>
  7036. #include <morphcolor_vertex>
  7037. #include <batching_vertex>
  7038. #include <beginnormal_vertex>
  7039. #include <morphnormal_vertex>
  7040. #include <skinbase_vertex>
  7041. #include <skinnormal_vertex>
  7042. #include <defaultnormal_vertex>
  7043. #include <normal_vertex>
  7044. #include <begin_vertex>
  7045. #include <morphtarget_vertex>
  7046. #include <skinning_vertex>
  7047. #include <displacementmap_vertex>
  7048. #include <project_vertex>
  7049. #include <logdepthbuf_vertex>
  7050. #include <clipping_planes_vertex>
  7051. vViewPosition = - mvPosition.xyz;
  7052. #include <worldpos_vertex>
  7053. #include <shadowmap_vertex>
  7054. #include <fog_vertex>
  7055. }`,U1e=`#define TOON
  7056. uniform vec3 diffuse;
  7057. uniform vec3 emissive;
  7058. uniform float opacity;
  7059. #include <common>
  7060. #include <packing>
  7061. #include <dithering_pars_fragment>
  7062. #include <color_pars_fragment>
  7063. #include <uv_pars_fragment>
  7064. #include <map_pars_fragment>
  7065. #include <alphamap_pars_fragment>
  7066. #include <alphatest_pars_fragment>
  7067. #include <alphahash_pars_fragment>
  7068. #include <aomap_pars_fragment>
  7069. #include <lightmap_pars_fragment>
  7070. #include <emissivemap_pars_fragment>
  7071. #include <gradientmap_pars_fragment>
  7072. #include <fog_pars_fragment>
  7073. #include <bsdfs>
  7074. #include <lights_pars_begin>
  7075. #include <normal_pars_fragment>
  7076. #include <lights_toon_pars_fragment>
  7077. #include <shadowmap_pars_fragment>
  7078. #include <bumpmap_pars_fragment>
  7079. #include <normalmap_pars_fragment>
  7080. #include <logdepthbuf_pars_fragment>
  7081. #include <clipping_planes_pars_fragment>
  7082. void main() {
  7083. #include <clipping_planes_fragment>
  7084. vec4 diffuseColor = vec4( diffuse, opacity );
  7085. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  7086. vec3 totalEmissiveRadiance = emissive;
  7087. #include <logdepthbuf_fragment>
  7088. #include <map_fragment>
  7089. #include <color_fragment>
  7090. #include <alphamap_fragment>
  7091. #include <alphatest_fragment>
  7092. #include <alphahash_fragment>
  7093. #include <normal_fragment_begin>
  7094. #include <normal_fragment_maps>
  7095. #include <emissivemap_fragment>
  7096. #include <lights_toon_fragment>
  7097. #include <lights_fragment_begin>
  7098. #include <lights_fragment_maps>
  7099. #include <lights_fragment_end>
  7100. #include <aomap_fragment>
  7101. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  7102. #include <opaque_fragment>
  7103. #include <tonemapping_fragment>
  7104. #include <colorspace_fragment>
  7105. #include <fog_fragment>
  7106. #include <premultiplied_alpha_fragment>
  7107. #include <dithering_fragment>
  7108. }`,z1e=`uniform float size;
  7109. uniform float scale;
  7110. #include <common>
  7111. #include <color_pars_vertex>
  7112. #include <fog_pars_vertex>
  7113. #include <morphtarget_pars_vertex>
  7114. #include <logdepthbuf_pars_vertex>
  7115. #include <clipping_planes_pars_vertex>
  7116. #ifdef USE_POINTS_UV
  7117. varying vec2 vUv;
  7118. uniform mat3 uvTransform;
  7119. #endif
  7120. void main() {
  7121. #ifdef USE_POINTS_UV
  7122. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  7123. #endif
  7124. #include <color_vertex>
  7125. #include <morphcolor_vertex>
  7126. #include <begin_vertex>
  7127. #include <morphtarget_vertex>
  7128. #include <project_vertex>
  7129. gl_PointSize = size;
  7130. #ifdef USE_SIZEATTENUATION
  7131. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7132. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  7133. #endif
  7134. #include <logdepthbuf_vertex>
  7135. #include <clipping_planes_vertex>
  7136. #include <worldpos_vertex>
  7137. #include <fog_vertex>
  7138. }`,B1e=`uniform vec3 diffuse;
  7139. uniform float opacity;
  7140. #include <common>
  7141. #include <color_pars_fragment>
  7142. #include <map_particle_pars_fragment>
  7143. #include <alphatest_pars_fragment>
  7144. #include <alphahash_pars_fragment>
  7145. #include <fog_pars_fragment>
  7146. #include <logdepthbuf_pars_fragment>
  7147. #include <clipping_planes_pars_fragment>
  7148. void main() {
  7149. #include <clipping_planes_fragment>
  7150. vec3 outgoingLight = vec3( 0.0 );
  7151. vec4 diffuseColor = vec4( diffuse, opacity );
  7152. #include <logdepthbuf_fragment>
  7153. #include <map_particle_fragment>
  7154. #include <color_fragment>
  7155. #include <alphatest_fragment>
  7156. #include <alphahash_fragment>
  7157. outgoingLight = diffuseColor.rgb;
  7158. #include <opaque_fragment>
  7159. #include <tonemapping_fragment>
  7160. #include <colorspace_fragment>
  7161. #include <fog_fragment>
  7162. #include <premultiplied_alpha_fragment>
  7163. }`,$1e=`#include <common>
  7164. #include <batching_pars_vertex>
  7165. #include <fog_pars_vertex>
  7166. #include <morphtarget_pars_vertex>
  7167. #include <skinning_pars_vertex>
  7168. #include <logdepthbuf_pars_vertex>
  7169. #include <shadowmap_pars_vertex>
  7170. void main() {
  7171. #include <batching_vertex>
  7172. #include <beginnormal_vertex>
  7173. #include <morphnormal_vertex>
  7174. #include <skinbase_vertex>
  7175. #include <skinnormal_vertex>
  7176. #include <defaultnormal_vertex>
  7177. #include <begin_vertex>
  7178. #include <morphtarget_vertex>
  7179. #include <skinning_vertex>
  7180. #include <project_vertex>
  7181. #include <logdepthbuf_vertex>
  7182. #include <worldpos_vertex>
  7183. #include <shadowmap_vertex>
  7184. #include <fog_vertex>
  7185. }`,H1e=`uniform vec3 color;
  7186. uniform float opacity;
  7187. #include <common>
  7188. #include <packing>
  7189. #include <fog_pars_fragment>
  7190. #include <bsdfs>
  7191. #include <lights_pars_begin>
  7192. #include <logdepthbuf_pars_fragment>
  7193. #include <shadowmap_pars_fragment>
  7194. #include <shadowmask_pars_fragment>
  7195. void main() {
  7196. #include <logdepthbuf_fragment>
  7197. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  7198. #include <tonemapping_fragment>
  7199. #include <colorspace_fragment>
  7200. #include <fog_fragment>
  7201. }`,V1e=`uniform float rotation;
  7202. uniform vec2 center;
  7203. #include <common>
  7204. #include <uv_pars_vertex>
  7205. #include <fog_pars_vertex>
  7206. #include <logdepthbuf_pars_vertex>
  7207. #include <clipping_planes_pars_vertex>
  7208. void main() {
  7209. #include <uv_vertex>
  7210. vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
  7211. vec2 scale;
  7212. scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
  7213. scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
  7214. #ifndef USE_SIZEATTENUATION
  7215. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7216. if ( isPerspective ) scale *= - mvPosition.z;
  7217. #endif
  7218. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  7219. vec2 rotatedPosition;
  7220. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  7221. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  7222. mvPosition.xy += rotatedPosition;
  7223. gl_Position = projectionMatrix * mvPosition;
  7224. #include <logdepthbuf_vertex>
  7225. #include <clipping_planes_vertex>
  7226. #include <fog_vertex>
  7227. }`,G1e=`uniform vec3 diffuse;
  7228. uniform float opacity;
  7229. #include <common>
  7230. #include <uv_pars_fragment>
  7231. #include <map_pars_fragment>
  7232. #include <alphamap_pars_fragment>
  7233. #include <alphatest_pars_fragment>
  7234. #include <alphahash_pars_fragment>
  7235. #include <fog_pars_fragment>
  7236. #include <logdepthbuf_pars_fragment>
  7237. #include <clipping_planes_pars_fragment>
  7238. void main() {
  7239. #include <clipping_planes_fragment>
  7240. vec3 outgoingLight = vec3( 0.0 );
  7241. vec4 diffuseColor = vec4( diffuse, opacity );
  7242. #include <logdepthbuf_fragment>
  7243. #include <map_fragment>
  7244. #include <alphamap_fragment>
  7245. #include <alphatest_fragment>
  7246. #include <alphahash_fragment>
  7247. outgoingLight = diffuseColor.rgb;
  7248. #include <opaque_fragment>
  7249. #include <tonemapping_fragment>
  7250. #include <colorspace_fragment>
  7251. #include <fog_fragment>
  7252. }`,Tn={alphahash_fragment:f_e,alphahash_pars_fragment:m_e,alphamap_fragment:p_e,alphamap_pars_fragment:g_e,alphatest_fragment:x_e,alphatest_pars_fragment:b_e,aomap_fragment:y_e,aomap_pars_fragment:v_e,batching_pars_vertex:__e,batching_vertex:w_e,begin_vertex:S_e,beginnormal_vertex:N_e,bsdfs:M_e,iridescence_fragment:E_e,bumpmap_pars_fragment:C_e,clipping_planes_fragment:T_e,clipping_planes_pars_fragment:A_e,clipping_planes_pars_vertex:k_e,clipping_planes_vertex:j_e,color_fragment:P_e,color_pars_fragment:R_e,color_pars_vertex:D_e,color_vertex:O_e,common:L_e,cube_uv_reflection_fragment:I_e,defaultnormal_vertex:F_e,displacementmap_pars_vertex:U_e,displacementmap_vertex:z_e,emissivemap_fragment:B_e,emissivemap_pars_fragment:$_e,colorspace_fragment:H_e,colorspace_pars_fragment:V_e,envmap_fragment:G_e,envmap_common_pars_fragment:q_e,envmap_pars_fragment:W_e,envmap_pars_vertex:K_e,envmap_physical_pars_fragment:swe,envmap_vertex:X_e,fog_vertex:Y_e,fog_pars_vertex:Q_e,fog_fragment:Z_e,fog_pars_fragment:J_e,gradientmap_pars_fragment:ewe,lightmap_fragment:twe,lightmap_pars_fragment:nwe,lights_lambert_fragment:rwe,lights_lambert_pars_fragment:iwe,lights_pars_begin:awe,lights_toon_fragment:owe,lights_toon_pars_fragment:lwe,lights_phong_fragment:cwe,lights_phong_pars_fragment:uwe,lights_physical_fragment:dwe,lights_physical_pars_fragment:hwe,lights_fragment_begin:fwe,lights_fragment_maps:mwe,lights_fragment_end:pwe,logdepthbuf_fragment:gwe,logdepthbuf_pars_fragment:xwe,logdepthbuf_pars_vertex:bwe,logdepthbuf_vertex:ywe,map_fragment:vwe,map_pars_fragment:_we,map_particle_fragment:wwe,map_particle_pars_fragment:Swe,metalnessmap_fragment:Nwe,metalnessmap_pars_fragment:Mwe,morphcolor_vertex:Ewe,morphnormal_vertex:Cwe,morphtarget_pars_vertex:Twe,morphtarget_vertex:Awe,normal_fragment_begin:kwe,normal_fragment_maps:jwe,normal_pars_fragment:Pwe,normal_pars_vertex:Rwe,normal_vertex:Dwe,normalmap_pars_fragment:Owe,clearcoat_normal_fragment_begin:Lwe,clearcoat_normal_fragment_maps:Iwe,clearcoat_pars_fragment:Fwe,iridescence_pars_fragment:Uwe,opaque_fragment:zwe,packing:Bwe,premultiplied_alpha_fragment:$we,project_vertex:Hwe,dithering_fragment:Vwe,dithering_pars_fragment:Gwe,roughnessmap_fragment:qwe,roughnessmap_pars_fragment:Wwe,shadowmap_pars_fragment:Kwe,shadowmap_pars_vertex:Xwe,shadowmap_vertex:Ywe,shadowmask_pars_fragment:Qwe,skinbase_vertex:Zwe,skinning_pars_vertex:Jwe,skinning_vertex:e1e,skinnormal_vertex:t1e,specularmap_fragment:n1e,specularmap_pars_fragment:r1e,tonemapping_fragment:i1e,tonemapping_pars_fragment:a1e,transmission_fragment:s1e,transmission_pars_fragment:o1e,uv_pars_fragment:l1e,uv_pars_vertex:c1e,uv_vertex:u1e,worldpos_vertex:d1e,background_vert:h1e,background_frag:f1e,backgroundCube_vert:m1e,backgroundCube_frag:p1e,cube_vert:g1e,cube_frag:x1e,depth_vert:b1e,depth_frag:y1e,distanceRGBA_vert:v1e,distanceRGBA_frag:_1e,equirect_vert:w1e,equirect_frag:S1e,linedashed_vert:N1e,linedashed_frag:M1e,meshbasic_vert:E1e,meshbasic_frag:C1e,meshlambert_vert:T1e,meshlambert_frag:A1e,meshmatcap_vert:k1e,meshmatcap_frag:j1e,meshnormal_vert:P1e,meshnormal_frag:R1e,meshphong_vert:D1e,meshphong_frag:O1e,meshphysical_vert:L1e,meshphysical_frag:I1e,meshtoon_vert:F1e,meshtoon_frag:U1e,points_vert:z1e,points_frag:B1e,shadow_vert:$1e,shadow_frag:H1e,sprite_vert:V1e,sprite_frag:G1e},Pt={common:{diffuse:{value:new en(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ln},alphaMap:{value:null},alphaMapTransform:{value:new Ln},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ln}},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 Ln}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ln}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ln},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ln},normalScale:{value:new xn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ln},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ln}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ln}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ln}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new en(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 en(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ln},alphaTest:{value:0},uvTransform:{value:new Ln}},sprite:{diffuse:{value:new en(16777215)},opacity:{value:1},center:{value:new xn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ln},alphaMap:{value:null},alphaMapTransform:{value:new Ln},alphaTest:{value:0}}},Ls={basic:{uniforms:ds([Pt.common,Pt.specularmap,Pt.envmap,Pt.aomap,Pt.lightmap,Pt.fog]),vertexShader:Tn.meshbasic_vert,fragmentShader:Tn.meshbasic_frag},lambert:{uniforms:ds([Pt.common,Pt.specularmap,Pt.envmap,Pt.aomap,Pt.lightmap,Pt.emissivemap,Pt.bumpmap,Pt.normalmap,Pt.displacementmap,Pt.fog,Pt.lights,{emissive:{value:new en(0)}}]),vertexShader:Tn.meshlambert_vert,fragmentShader:Tn.meshlambert_frag},phong:{uniforms:ds([Pt.common,Pt.specularmap,Pt.envmap,Pt.aomap,Pt.lightmap,Pt.emissivemap,Pt.bumpmap,Pt.normalmap,Pt.displacementmap,Pt.fog,Pt.lights,{emissive:{value:new en(0)},specular:{value:new en(1118481)},shininess:{value:30}}]),vertexShader:Tn.meshphong_vert,fragmentShader:Tn.meshphong_frag},standard:{uniforms:ds([Pt.common,Pt.envmap,Pt.aomap,Pt.lightmap,Pt.emissivemap,Pt.bumpmap,Pt.normalmap,Pt.displacementmap,Pt.roughnessmap,Pt.metalnessmap,Pt.fog,Pt.lights,{emissive:{value:new en(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Tn.meshphysical_vert,fragmentShader:Tn.meshphysical_frag},toon:{uniforms:ds([Pt.common,Pt.aomap,Pt.lightmap,Pt.emissivemap,Pt.bumpmap,Pt.normalmap,Pt.displacementmap,Pt.gradientmap,Pt.fog,Pt.lights,{emissive:{value:new en(0)}}]),vertexShader:Tn.meshtoon_vert,fragmentShader:Tn.meshtoon_frag},matcap:{uniforms:ds([Pt.common,Pt.bumpmap,Pt.normalmap,Pt.displacementmap,Pt.fog,{matcap:{value:null}}]),vertexShader:Tn.meshmatcap_vert,fragmentShader:Tn.meshmatcap_frag},points:{uniforms:ds([Pt.points,Pt.fog]),vertexShader:Tn.points_vert,fragmentShader:Tn.points_frag},dashed:{uniforms:ds([Pt.common,Pt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Tn.linedashed_vert,fragmentShader:Tn.linedashed_frag},depth:{uniforms:ds([Pt.common,Pt.displacementmap]),vertexShader:Tn.depth_vert,fragmentShader:Tn.depth_frag},normal:{uniforms:ds([Pt.common,Pt.bumpmap,Pt.normalmap,Pt.displacementmap,{opacity:{value:1}}]),vertexShader:Tn.meshnormal_vert,fragmentShader:Tn.meshnormal_frag},sprite:{uniforms:ds([Pt.sprite,Pt.fog]),vertexShader:Tn.sprite_vert,fragmentShader:Tn.sprite_frag},background:{uniforms:{uvTransform:{value:new Ln},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Tn.background_vert,fragmentShader:Tn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Tn.backgroundCube_vert,fragmentShader:Tn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Tn.cube_vert,fragmentShader:Tn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Tn.equirect_vert,fragmentShader:Tn.equirect_frag},distanceRGBA:{uniforms:ds([Pt.common,Pt.displacementmap,{referencePosition:{value:new qe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Tn.distanceRGBA_vert,fragmentShader:Tn.distanceRGBA_frag},shadow:{uniforms:ds([Pt.lights,Pt.fog,{color:{value:new en(0)},opacity:{value:1}}]),vertexShader:Tn.shadow_vert,fragmentShader:Tn.shadow_frag}};Ls.physical={uniforms:ds([Ls.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ln},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ln},clearcoatNormalScale:{value:new xn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ln},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ln},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ln},sheen:{value:0},sheenColor:{value:new en(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ln},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ln},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ln},transmissionSamplerSize:{value:new xn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ln},attenuationDistance:{value:0},attenuationColor:{value:new en(0)},specularColor:{value:new en(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ln},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ln},anisotropyVector:{value:new xn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ln}}]),vertexShader:Tn.meshphysical_vert,fragmentShader:Tn.meshphysical_frag};const Mw={r:0,b:0,g:0};function q1e(t,e,n,r,i,s,o){const l=new en(0);let c=s===!0?0:1,u,d,f=null,m=0,p=null;function x(y,v){let S=!1,N=v.isScene===!0?v.background:null;N&&N.isTexture&&(N=(v.backgroundBlurriness>0?n:e).get(N)),N===null?b(l,c):N&&N.isColor&&(b(N,1),S=!0);const C=t.xr.getEnvironmentBlendMode();C==="additive"?r.buffers.color.setClear(0,0,0,1,o):C==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,o),(t.autoClear||S)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),N&&(N.isCubeTexture||N.mapping===EN)?(d===void 0&&(d=new Rl(new By(1,1,1),new Nh({name:"BackgroundCubeMaterial",uniforms:Qg(Ls.backgroundCube.uniforms),vertexShader:Ls.backgroundCube.vertexShader,fragmentShader:Ls.backgroundCube.fragmentShader,side:Bs,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(T,k,E){this.matrixWorld.copyPosition(E.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),d.material.uniforms.envMap.value=N,d.material.uniforms.flipEnvMap.value=N.isCubeTexture&&N.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,d.material.toneMapped=Er.getTransfer(N.colorSpace)!==$r,(f!==N||m!==N.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,f=N,m=N.version,p=t.toneMapping),d.layers.enableAll(),y.unshift(d,d.geometry,d.material,0,0,null)):N&&N.isTexture&&(u===void 0&&(u=new Rl(new c4(2,2),new Nh({name:"BackgroundMaterial",uniforms:Qg(Ls.background.uniforms),vertexShader:Ls.background.vertexShader,fragmentShader:Ls.background.fragmentShader,side:Sh,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=N,u.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,u.material.toneMapped=Er.getTransfer(N.colorSpace)!==$r,N.matrixAutoUpdate===!0&&N.updateMatrix(),u.material.uniforms.uvTransform.value.copy(N.matrix),(f!==N||m!==N.version||p!==t.toneMapping)&&(u.material.needsUpdate=!0,f=N,m=N.version,p=t.toneMapping),u.layers.enableAll(),y.unshift(u,u.geometry,u.material,0,0,null))}function b(y,v){y.getRGB(Mw,YK(t)),r.buffers.color.setClear(Mw.r,Mw.g,Mw.b,v,o)}return{getClearColor:function(){return l},setClearColor:function(y,v=1){l.set(y),c=v,b(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(y){c=y,b(l,c)},render:x}}function W1e(t,e,n,r){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),s=r.isWebGL2?null:e.get("OES_vertex_array_object"),o=r.isWebGL2||s!==null,l={},c=y(null);let u=c,d=!1;function f(j,G,$,q,Y){let Z=!1;if(o){const oe=b(q,$,G);u!==oe&&(u=oe,p(u.object)),Z=v(j,q,$,Y),Z&&S(j,q,$,Y)}else{const oe=G.wireframe===!0;(u.geometry!==q.id||u.program!==$.id||u.wireframe!==oe)&&(u.geometry=q.id,u.program=$.id,u.wireframe=oe,Z=!0)}Y!==null&&n.update(Y,t.ELEMENT_ARRAY_BUFFER),(Z||d)&&(d=!1,D(j,G,$,q),Y!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(Y).buffer))}function m(){return r.isWebGL2?t.createVertexArray():s.createVertexArrayOES()}function p(j){return r.isWebGL2?t.bindVertexArray(j):s.bindVertexArrayOES(j)}function x(j){return r.isWebGL2?t.deleteVertexArray(j):s.deleteVertexArrayOES(j)}function b(j,G,$){const q=$.wireframe===!0;let Y=l[j.id];Y===void 0&&(Y={},l[j.id]=Y);let Z=Y[G.id];Z===void 0&&(Z={},Y[G.id]=Z);let oe=Z[q];return oe===void 0&&(oe=y(m()),Z[q]=oe),oe}function y(j){const G=[],$=[],q=[];for(let Y=0;Y<i;Y++)G[Y]=0,$[Y]=0,q[Y]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:G,enabledAttributes:$,attributeDivisors:q,object:j,attributes:{},index:null}}function v(j,G,$,q){const Y=u.attributes,Z=G.attributes;let oe=0;const B=$.getAttributes();for(const W in B)if(B[W].location>=0){const ne=Y[W];let ce=Z[W];if(ce===void 0&&(W==="instanceMatrix"&&j.instanceMatrix&&(ce=j.instanceMatrix),W==="instanceColor"&&j.instanceColor&&(ce=j.instanceColor)),ne===void 0||ne.attribute!==ce||ce&&ne.data!==ce.data)return!0;oe++}return u.attributesNum!==oe||u.index!==q}function S(j,G,$,q){const Y={},Z=G.attributes;let oe=0;const B=$.getAttributes();for(const W in B)if(B[W].location>=0){let ne=Z[W];ne===void 0&&(W==="instanceMatrix"&&j.instanceMatrix&&(ne=j.instanceMatrix),W==="instanceColor"&&j.instanceColor&&(ne=j.instanceColor));const ce={};ce.attribute=ne,ne&&ne.data&&(ce.data=ne.data),Y[W]=ce,oe++}u.attributes=Y,u.attributesNum=oe,u.index=q}function N(){const j=u.newAttributes;for(let G=0,$=j.length;G<$;G++)j[G]=0}function C(j){T(j,0)}function T(j,G){const $=u.newAttributes,q=u.enabledAttributes,Y=u.attributeDivisors;$[j]=1,q[j]===0&&(t.enableVertexAttribArray(j),q[j]=1),Y[j]!==G&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](j,G),Y[j]=G)}function k(){const j=u.newAttributes,G=u.enabledAttributes;for(let $=0,q=G.length;$<q;$++)G[$]!==j[$]&&(t.disableVertexAttribArray($),G[$]=0)}function E(j,G,$,q,Y,Z,oe){oe===!0?t.vertexAttribIPointer(j,G,$,Y,Z):t.vertexAttribPointer(j,G,$,q,Y,Z)}function D(j,G,$,q){if(r.isWebGL2===!1&&(j.isInstancedMesh||q.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;N();const Y=q.attributes,Z=$.getAttributes(),oe=G.defaultAttributeValues;for(const B in Z){const W=Z[B];if(W.location>=0){let se=Y[B];if(se===void 0&&(B==="instanceMatrix"&&j.instanceMatrix&&(se=j.instanceMatrix),B==="instanceColor"&&j.instanceColor&&(se=j.instanceColor)),se!==void 0){const ne=se.normalized,ce=se.itemSize,fe=n.get(se);if(fe===void 0)continue;const ye=fe.buffer,ge=fe.type,xe=fe.bytesPerElement,Pe=r.isWebGL2===!0&&(ge===t.INT||ge===t.UNSIGNED_INT||se.gpuType===kK);if(se.isInterleavedBufferAttribute){const Ue=se.data,be=Ue.stride,it=se.offset;if(Ue.isInstancedInterleavedBuffer){for(let U=0;U<W.locationSize;U++)T(W.location+U,Ue.meshPerAttribute);j.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=Ue.meshPerAttribute*Ue.count)}else for(let U=0;U<W.locationSize;U++)C(W.location+U);t.bindBuffer(t.ARRAY_BUFFER,ye);for(let U=0;U<W.locationSize;U++)E(W.location+U,ce/W.locationSize,ge,ne,be*xe,(it+ce/W.locationSize*U)*xe,Pe)}else{if(se.isInstancedBufferAttribute){for(let Ue=0;Ue<W.locationSize;Ue++)T(W.location+Ue,se.meshPerAttribute);j.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=se.meshPerAttribute*se.count)}else for(let Ue=0;Ue<W.locationSize;Ue++)C(W.location+Ue);t.bindBuffer(t.ARRAY_BUFFER,ye);for(let Ue=0;Ue<W.locationSize;Ue++)E(W.location+Ue,ce/W.locationSize,ge,ne,ce*xe,ce/W.locationSize*Ue*xe,Pe)}}else if(oe!==void 0){const ne=oe[B];if(ne!==void 0)switch(ne.length){case 2:t.vertexAttrib2fv(W.location,ne);break;case 3:t.vertexAttrib3fv(W.location,ne);break;case 4:t.vertexAttrib4fv(W.location,ne);break;default:t.vertexAttrib1fv(W.location,ne)}}}}k()}function A(){O();for(const j in l){const G=l[j];for(const $ in G){const q=G[$];for(const Y in q)x(q[Y].object),delete q[Y];delete G[$]}delete l[j]}}function R(j){if(l[j.id]===void 0)return;const G=l[j.id];for(const $ in G){const q=G[$];for(const Y in q)x(q[Y].object),delete q[Y];delete G[$]}delete l[j.id]}function F(j){for(const G in l){const $=l[G];if($[j.id]===void 0)continue;const q=$[j.id];for(const Y in q)x(q[Y].object),delete q[Y];delete $[j.id]}}function O(){H(),d=!0,u!==c&&(u=c,p(u.object))}function H(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:f,reset:O,resetDefaultState:H,dispose:A,releaseStatesOfGeometry:R,releaseStatesOfProgram:F,initAttributes:N,enableAttribute:C,disableUnusedAttributes:k}}function K1e(t,e,n,r){const i=r.isWebGL2;let s;function o(d){s=d}function l(d,f){t.drawArrays(s,d,f),n.update(f,s,1)}function c(d,f,m){if(m===0)return;let p,x;if(i)p=t,x="drawArraysInstanced";else if(p=e.get("ANGLE_instanced_arrays"),x="drawArraysInstancedANGLE",p===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}p[x](s,d,f,m),n.update(f,s,m)}function u(d,f,m){if(m===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let x=0;x<m;x++)this.render(d[x],f[x]);else{p.multiDrawArraysWEBGL(s,d,0,f,0,m);let x=0;for(let b=0;b<m;b++)x+=f[b];n.update(x,s,1)}}this.setMode=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function X1e(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const E=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(E.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function s(E){if(E==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";E="mediump"}return E==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext<"u"&&t.constructor.name==="WebGL2RenderingContext";let l=n.precision!==void 0?n.precision:"highp";const c=s(l);c!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",c,"instead."),l=c);const u=o||e.has("WEBGL_draw_buffers"),d=n.logarithmicDepthBuffer===!0,f=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),m=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=t.getParameter(t.MAX_TEXTURE_SIZE),x=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),b=t.getParameter(t.MAX_VERTEX_ATTRIBS),y=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),v=t.getParameter(t.MAX_VARYING_VECTORS),S=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),N=m>0,C=o||e.has("OES_texture_float"),T=N&&C,k=o?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:s,precision:l,logarithmicDepthBuffer:d,maxTextures:f,maxVertexTextures:m,maxTextureSize:p,maxCubemapSize:x,maxAttributes:b,maxVertexUniforms:y,maxVaryings:v,maxFragmentUniforms:S,vertexTextures:N,floatFragmentTextures:C,floatVertexTextures:T,maxSamples:k}}function Y1e(t){const e=this;let n=null,r=0,i=!1,s=!1;const o=new Ud,l=new Ln,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,m){const p=f.length!==0||m||r!==0||i;return i=m,r=f.length,p},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,m){n=d(f,m,0)},this.setState=function(f,m,p){const x=f.clippingPlanes,b=f.clipIntersection,y=f.clipShadows,v=t.get(f);if(!i||x===null||x.length===0||s&&!y)s?d(null):u();else{const S=s?0:r,N=S*4;let C=v.clippingState||null;c.value=C,C=d(x,m,N,p);for(let T=0;T!==N;++T)C[T]=n[T];v.clippingState=C,this.numIntersection=b?this.numPlanes:0,this.numPlanes+=S}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,m,p,x){const b=f!==null?f.length:0;let y=null;if(b!==0){if(y=c.value,x!==!0||y===null){const v=p+b*4,S=m.matrixWorldInverse;l.getNormalMatrix(S),(y===null||y.length<v)&&(y=new Float32Array(v));for(let N=0,C=p;N!==b;++N,C+=4)o.copy(f[N]).applyMatrix4(S,l),o.normal.toArray(y,C),y[C+3]=o.constant}c.value=y,c.needsUpdate=!0}return e.numPlanes=b,e.numIntersection=0,y}}function Q1e(t){let e=new WeakMap;function n(o,l){return l===fP?o.mapping=Kg:l===mP&&(o.mapping=Xg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===fP||l===mP)if(e.has(o)){const c=e.get(o).texture;return n(c,o.mapping)}else{const c=o.image;if(c&&c.height>0){const u=new c_e(c.height/2);return u.fromEquirectangularTexture(t,o),e.set(o,u),o.addEventListener("dispose",i),n(u.texture,o.mapping)}else return null}}return o}function i(o){const l=o.target;l.removeEventListener("dispose",i);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function s(){e=new WeakMap}return{get:r,dispose:s}}class Z1e extends QK{constructor(e=-1,n=1,r=1,i=-1,s=.1,o=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=o,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,o){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=o,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,o=r+e,l=i+n,c=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=u*this.view.offsetX,o=s+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(s,o,l,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}}const gg=4,Z8=[.125,.215,.35,.446,.526,.582],Cf=20,lA=new Z1e,J8=new en;let cA=null,uA=0,dA=0;const vf=(1+Math.sqrt(5))/2,Wp=1/vf,e6=[new qe(1,1,1),new qe(-1,1,1),new qe(1,1,-1),new qe(-1,1,-1),new qe(0,vf,Wp),new qe(0,vf,-Wp),new qe(Wp,0,vf),new qe(-Wp,0,vf),new qe(vf,Wp,0),new qe(-vf,Wp,0)];class t6{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){cA=this._renderer.getRenderTarget(),uA=this._renderer.getActiveCubeFace(),dA=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=i6(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=r6(),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(cA,uA,dA),e.scissorTest=!1,Ew(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Kg||e.mapping===Xg?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),cA=this._renderer.getRenderTarget(),uA=this._renderer.getActiveCubeFace(),dA=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:Wo,minFilter:Wo,generateMipmaps:!1,type:ty,format:Ko,colorSpace:Lu,depthBuffer:!1},i=n6(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=n6(e,n,r);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=J1e(s)),this._blurMaterial=eSe(s,e,n)}return i}_compileMaterial(e){const n=new Rl(this._lodPlanes[0],e);this._renderer.compile(n,lA)}_sceneToCubeUV(e,n,r,i){const l=new lo(90,1,n,r),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,f=d.autoClear,m=d.toneMapping;d.getClearColor(J8),d.toneMapping=ch,d.autoClear=!1;const p=new WK({name:"PMREM.Background",side:Bs,depthWrite:!1,depthTest:!1}),x=new Rl(new By,p);let b=!1;const y=e.background;y?y.isColor&&(p.color.copy(y),e.background=null,b=!0):(p.color.copy(J8),b=!0);for(let v=0;v<6;v++){const S=v%3;S===0?(l.up.set(0,c[v],0),l.lookAt(u[v],0,0)):S===1?(l.up.set(0,0,c[v]),l.lookAt(0,u[v],0)):(l.up.set(0,c[v],0),l.lookAt(0,0,u[v]));const N=this._cubeSize;Ew(i,S*N,v>2?N:0,N,N),d.setRenderTarget(i),b&&d.render(x,l),d.render(e,l)}x.geometry.dispose(),x.material.dispose(),d.toneMapping=m,d.autoClear=f,e.background=y}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Kg||e.mapping===Xg;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=i6()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=r6());const s=i?this._cubemapMaterial:this._equirectMaterial,o=new Rl(this._lodPlanes[0],s),l=s.uniforms;l.envMap.value=e;const c=this._cubeSize;Ew(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,lA)}_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]),o=e6[(i-1)%e6.length];this._blur(e,i-1,i,s,o)}n.autoClear=r}_blur(e,n,r,i,s){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",s),this._halfBlur(o,e,r,r,i,"longitudinal",s)}_halfBlur(e,n,r,i,s,o,l){const c=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,f=new Rl(this._lodPlanes[i],u),m=u.uniforms,p=this._sizeLods[r]-1,x=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*Cf-1),b=s/x,y=isFinite(s)?1+Math.floor(d*b):Cf;y>Cf&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${Cf}`);const v=[];let S=0;for(let E=0;E<Cf;++E){const D=E/b,A=Math.exp(-D*D/2);v.push(A),E===0?S+=A:E<y&&(S+=2*A)}for(let E=0;E<v.length;E++)v[E]=v[E]/S;m.envMap.value=e.texture,m.samples.value=y,m.weights.value=v,m.latitudinal.value=o==="latitudinal",l&&(m.poleAxis.value=l);const{_lodMax:N}=this;m.dTheta.value=x,m.mipInt.value=N-r;const C=this._sizeLods[i],T=3*C*(i>N-gg?i-N+gg:0),k=4*(this._cubeSize-C);Ew(n,T,k,3*C,2*C),c.setRenderTarget(n),c.render(f,lA)}}function J1e(t){const e=[],n=[],r=[];let i=t;const s=t-gg+1+Z8.length;for(let o=0;o<s;o++){const l=Math.pow(2,i);n.push(l);let c=1/l;o>t-gg?c=Z8[o-t+gg-1]:o===0&&(c=0),r.push(c);const u=1/(l-2),d=-u,f=1+u,m=[d,d,f,d,f,f,d,d,f,f,d,f],p=6,x=6,b=3,y=2,v=1,S=new Float32Array(b*x*p),N=new Float32Array(y*x*p),C=new Float32Array(v*x*p);for(let k=0;k<p;k++){const E=k%3*2/3-1,D=k>2?0:-1,A=[E,D,0,E+2/3,D,0,E+2/3,D+1,0,E,D,0,E+2/3,D+1,0,E,D+1,0];S.set(A,b*x*k),N.set(m,y*x*k);const R=[k,k,k,k,k,k];C.set(R,v*x*k)}const T=new Ja;T.setAttribute("position",new go(S,b)),T.setAttribute("uv",new go(N,y)),T.setAttribute("faceIndex",new go(C,v)),e.push(T),i>gg&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function n6(t,e,n){const r=new dm(t,e,n);return r.texture.mapping=EN,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Ew(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function eSe(t,e,n){const r=new Float32Array(Cf),i=new qe(0,1,0);return new Nh({name:"SphericalGaussianBlur",defines:{n:Cf,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:u4(),fragmentShader:`
  7253. precision mediump float;
  7254. precision mediump int;
  7255. varying vec3 vOutputDirection;
  7256. uniform sampler2D envMap;
  7257. uniform int samples;
  7258. uniform float weights[ n ];
  7259. uniform bool latitudinal;
  7260. uniform float dTheta;
  7261. uniform float mipInt;
  7262. uniform vec3 poleAxis;
  7263. #define ENVMAP_TYPE_CUBE_UV
  7264. #include <cube_uv_reflection_fragment>
  7265. vec3 getSample( float theta, vec3 axis ) {
  7266. float cosTheta = cos( theta );
  7267. // Rodrigues' axis-angle rotation
  7268. vec3 sampleDirection = vOutputDirection * cosTheta
  7269. + cross( axis, vOutputDirection ) * sin( theta )
  7270. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  7271. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  7272. }
  7273. void main() {
  7274. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  7275. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  7276. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  7277. }
  7278. axis = normalize( axis );
  7279. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  7280. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  7281. for ( int i = 1; i < n; i++ ) {
  7282. if ( i >= samples ) {
  7283. break;
  7284. }
  7285. float theta = dTheta * float( i );
  7286. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  7287. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  7288. }
  7289. }
  7290. `,blending:lh,depthTest:!1,depthWrite:!1})}function r6(){return new Nh({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:u4(),fragmentShader:`
  7291. precision mediump float;
  7292. precision mediump int;
  7293. varying vec3 vOutputDirection;
  7294. uniform sampler2D envMap;
  7295. #include <common>
  7296. void main() {
  7297. vec3 outputDirection = normalize( vOutputDirection );
  7298. vec2 uv = equirectUv( outputDirection );
  7299. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  7300. }
  7301. `,blending:lh,depthTest:!1,depthWrite:!1})}function i6(){return new Nh({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:u4(),fragmentShader:`
  7302. precision mediump float;
  7303. precision mediump int;
  7304. uniform float flipEnvMap;
  7305. varying vec3 vOutputDirection;
  7306. uniform samplerCube envMap;
  7307. void main() {
  7308. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  7309. }
  7310. `,blending:lh,depthTest:!1,depthWrite:!1})}function u4(){return`
  7311. precision mediump float;
  7312. precision mediump int;
  7313. attribute float faceIndex;
  7314. varying vec3 vOutputDirection;
  7315. // RH coordinate system; PMREM face-indexing convention
  7316. vec3 getDirection( vec2 uv, float face ) {
  7317. uv = 2.0 * uv - 1.0;
  7318. vec3 direction = vec3( uv, 1.0 );
  7319. if ( face == 0.0 ) {
  7320. direction = direction.zyx; // ( 1, v, u ) pos x
  7321. } else if ( face == 1.0 ) {
  7322. direction = direction.xzy;
  7323. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  7324. } else if ( face == 2.0 ) {
  7325. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  7326. } else if ( face == 3.0 ) {
  7327. direction = direction.zyx;
  7328. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  7329. } else if ( face == 4.0 ) {
  7330. direction = direction.xzy;
  7331. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  7332. } else if ( face == 5.0 ) {
  7333. direction.z *= -1.0; // ( u, v, -1 ) neg z
  7334. }
  7335. return direction;
  7336. }
  7337. void main() {
  7338. vOutputDirection = getDirection( uv, faceIndex );
  7339. gl_Position = vec4( position, 1.0 );
  7340. }
  7341. `}function tSe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===fP||c===mP,d=c===Kg||c===Xg;if(u||d)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let f=e.get(l);return n===null&&(n=new t6(t)),f=u?n.fromEquirectangular(l,f):n.fromCubemap(l,f),e.set(l,f),f.texture}else{if(e.has(l))return e.get(l).texture;{const f=l.image;if(u&&f&&f.height>0||d&&f&&i(f)){n===null&&(n=new t6(t));const m=u?n.fromEquirectangular(l):n.fromCubemap(l);return e.set(l,m),l.addEventListener("dispose",s),m.texture}else return null}}}return l}function i(l){let c=0;const u=6;for(let d=0;d<u;d++)l[d]!==void 0&&c++;return c===u}function s(l){const c=l.target;c.removeEventListener("dispose",s);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function o(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function nSe(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 rSe(t,e,n,r){const i={},s=new WeakMap;function o(f){const m=f.target;m.index!==null&&e.remove(m.index);for(const x in m.attributes)e.remove(m.attributes[x]);for(const x in m.morphAttributes){const b=m.morphAttributes[x];for(let y=0,v=b.length;y<v;y++)e.remove(b[y])}m.removeEventListener("dispose",o),delete i[m.id];const p=s.get(m);p&&(e.remove(p),s.delete(m)),r.releaseStatesOfGeometry(m),m.isInstancedBufferGeometry===!0&&delete m._maxInstanceCount,n.memory.geometries--}function l(f,m){return i[m.id]===!0||(m.addEventListener("dispose",o),i[m.id]=!0,n.memory.geometries++),m}function c(f){const m=f.attributes;for(const x in m)e.update(m[x],t.ARRAY_BUFFER);const p=f.morphAttributes;for(const x in p){const b=p[x];for(let y=0,v=b.length;y<v;y++)e.update(b[y],t.ARRAY_BUFFER)}}function u(f){const m=[],p=f.index,x=f.attributes.position;let b=0;if(p!==null){const S=p.array;b=p.version;for(let N=0,C=S.length;N<C;N+=3){const T=S[N+0],k=S[N+1],E=S[N+2];m.push(T,k,k,E,E,T)}}else if(x!==void 0){const S=x.array;b=x.version;for(let N=0,C=S.length/3-1;N<C;N+=3){const T=N+0,k=N+1,E=N+2;m.push(T,k,k,E,E,T)}}else return;const y=new(BK(m)?XK:KK)(m,1);y.version=b;const v=s.get(f);v&&e.remove(v),s.set(f,y)}function d(f){const m=s.get(f);if(m){const p=f.index;p!==null&&m.version<p.version&&u(f)}else u(f);return s.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function iSe(t,e,n,r){const i=r.isWebGL2;let s;function o(p){s=p}let l,c;function u(p){l=p.type,c=p.bytesPerElement}function d(p,x){t.drawElements(s,x,l,p*c),n.update(x,s,1)}function f(p,x,b){if(b===0)return;let y,v;if(i)y=t,v="drawElementsInstanced";else if(y=e.get("ANGLE_instanced_arrays"),v="drawElementsInstancedANGLE",y===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}y[v](s,x,l,p*c,b),n.update(x,s,b)}function m(p,x,b){if(b===0)return;const y=e.get("WEBGL_multi_draw");if(y===null)for(let v=0;v<b;v++)this.render(p[v]/c,x[v]);else{y.multiDrawElementsWEBGL(s,x,0,l,p,0,b);let v=0;for(let S=0;S<b;S++)v+=x[S];n.update(v,s,1)}}this.setMode=o,this.setIndex=u,this.render=d,this.renderInstances=f,this.renderMultiDraw=m}function aSe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(s,o,l){switch(n.calls++,o){case t.TRIANGLES:n.triangles+=l*(s/3);break;case t.LINES:n.lines+=l*(s/2);break;case t.LINE_STRIP:n.lines+=l*(s-1);break;case t.LINE_LOOP:n.lines+=l*s;break;case t.POINTS:n.points+=l*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);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 sSe(t,e){return t[0]-e[0]}function oSe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function lSe(t,e,n){const r={},i=new Float32Array(8),s=new WeakMap,o=new Ar,l=[];for(let u=0;u<8;u++)l[u]=[u,0];function c(u,d,f){const m=u.morphTargetInfluences;if(e.isWebGL2===!0){const x=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,b=x!==void 0?x.length:0;let y=s.get(d);if(y===void 0||y.count!==b){let G=function(){H.dispose(),s.delete(d),d.removeEventListener("dispose",G)};var p=G;y!==void 0&&y.texture.dispose();const N=d.morphAttributes.position!==void 0,C=d.morphAttributes.normal!==void 0,T=d.morphAttributes.color!==void 0,k=d.morphAttributes.position||[],E=d.morphAttributes.normal||[],D=d.morphAttributes.color||[];let A=0;N===!0&&(A=1),C===!0&&(A=2),T===!0&&(A=3);let R=d.attributes.position.count*A,F=1;R>e.maxTextureSize&&(F=Math.ceil(R/e.maxTextureSize),R=e.maxTextureSize);const O=new Float32Array(R*F*4*b),H=new VK(O,R,F,b);H.type=yu,H.needsUpdate=!0;const j=A*4;for(let $=0;$<b;$++){const q=k[$],Y=E[$],Z=D[$],oe=R*F*4*$;for(let B=0;B<q.count;B++){const W=B*j;N===!0&&(o.fromBufferAttribute(q,B),O[oe+W+0]=o.x,O[oe+W+1]=o.y,O[oe+W+2]=o.z,O[oe+W+3]=0),C===!0&&(o.fromBufferAttribute(Y,B),O[oe+W+4]=o.x,O[oe+W+5]=o.y,O[oe+W+6]=o.z,O[oe+W+7]=0),T===!0&&(o.fromBufferAttribute(Z,B),O[oe+W+8]=o.x,O[oe+W+9]=o.y,O[oe+W+10]=o.z,O[oe+W+11]=Z.itemSize===4?o.w:1)}}y={count:b,texture:H,size:new xn(R,F)},s.set(d,y),d.addEventListener("dispose",G)}let v=0;for(let N=0;N<m.length;N++)v+=m[N];const S=d.morphTargetsRelative?1:1-v;f.getUniforms().setValue(t,"morphTargetBaseInfluence",S),f.getUniforms().setValue(t,"morphTargetInfluences",m),f.getUniforms().setValue(t,"morphTargetsTexture",y.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",y.size)}else{const x=m===void 0?0:m.length;let b=r[d.id];if(b===void 0||b.length!==x){b=[];for(let C=0;C<x;C++)b[C]=[C,0];r[d.id]=b}for(let C=0;C<x;C++){const T=b[C];T[0]=C,T[1]=m[C]}b.sort(oSe);for(let C=0;C<8;C++)C<x&&b[C][1]?(l[C][0]=b[C][0],l[C][1]=b[C][1]):(l[C][0]=Number.MAX_SAFE_INTEGER,l[C][1]=0);l.sort(sSe);const y=d.morphAttributes.position,v=d.morphAttributes.normal;let S=0;for(let C=0;C<8;C++){const T=l[C],k=T[0],E=T[1];k!==Number.MAX_SAFE_INTEGER&&E?(y&&d.getAttribute("morphTarget"+C)!==y[k]&&d.setAttribute("morphTarget"+C,y[k]),v&&d.getAttribute("morphNormal"+C)!==v[k]&&d.setAttribute("morphNormal"+C,v[k]),i[C]=E,S+=E):(y&&d.hasAttribute("morphTarget"+C)===!0&&d.deleteAttribute("morphTarget"+C),v&&d.hasAttribute("morphNormal"+C)===!0&&d.deleteAttribute("morphNormal"+C),i[C]=0)}const N=d.morphTargetsRelative?1:1-S;f.getUniforms().setValue(t,"morphTargetBaseInfluence",N),f.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function cSe(t,e,n,r){let i=new WeakMap;function s(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const m=c.skeleton;i.get(m)!==u&&(m.update(),i.set(m,u))}return f}function o(){i=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:s,dispose:o}}class eX extends $s{constructor(e,n,r,i,s,o,l,c,u,d){if(d=d!==void 0?d:$f,d!==$f&&d!==Yg)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===$f&&(r=Qd),r===void 0&&d===Yg&&(r=Bf),super(null,i,s,o,l,c,d,r,u),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=l!==void 0?l:ka,this.minFilter=c!==void 0?c:ka,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 tX=new $s,nX=new eX(1,1);nX.compareFunction=UK;const rX=new VK,iX=new Wve,aX=new ZK,a6=[],s6=[],o6=new Float32Array(16),l6=new Float32Array(9),c6=new Float32Array(4);function Sx(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=a6[i];if(s===void 0&&(s=new Float32Array(i),a6[i]=s),e!==0){r.toArray(s,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(s,l)}return s}function Qi(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 Zi(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function AN(t,e){let n=s6[e];n===void 0&&(n=new Int32Array(e),s6[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function uSe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function dSe(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(Qi(n,e))return;t.uniform2fv(this.addr,e),Zi(n,e)}}function hSe(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(Qi(n,e))return;t.uniform3fv(this.addr,e),Zi(n,e)}}function fSe(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(Qi(n,e))return;t.uniform4fv(this.addr,e),Zi(n,e)}}function mSe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Qi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Zi(n,e)}else{if(Qi(n,r))return;c6.set(r),t.uniformMatrix2fv(this.addr,!1,c6),Zi(n,r)}}function pSe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Qi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Zi(n,e)}else{if(Qi(n,r))return;l6.set(r),t.uniformMatrix3fv(this.addr,!1,l6),Zi(n,r)}}function gSe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Qi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Zi(n,e)}else{if(Qi(n,r))return;o6.set(r),t.uniformMatrix4fv(this.addr,!1,o6),Zi(n,r)}}function xSe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function bSe(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(Qi(n,e))return;t.uniform2iv(this.addr,e),Zi(n,e)}}function ySe(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(Qi(n,e))return;t.uniform3iv(this.addr,e),Zi(n,e)}}function vSe(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(Qi(n,e))return;t.uniform4iv(this.addr,e),Zi(n,e)}}function _Se(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function wSe(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(Qi(n,e))return;t.uniform2uiv(this.addr,e),Zi(n,e)}}function SSe(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(Qi(n,e))return;t.uniform3uiv(this.addr,e),Zi(n,e)}}function NSe(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(Qi(n,e))return;t.uniform4uiv(this.addr,e),Zi(n,e)}}function MSe(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?nX:tX;n.setTexture2D(e||s,i)}function ESe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||iX,i)}function CSe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||aX,i)}function TSe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||rX,i)}function ASe(t){switch(t){case 5126:return uSe;case 35664:return dSe;case 35665:return hSe;case 35666:return fSe;case 35674:return mSe;case 35675:return pSe;case 35676:return gSe;case 5124:case 35670:return xSe;case 35667:case 35671:return bSe;case 35668:case 35672:return ySe;case 35669:case 35673:return vSe;case 5125:return _Se;case 36294:return wSe;case 36295:return SSe;case 36296:return NSe;case 35678:case 36198:case 36298:case 36306:case 35682:return MSe;case 35679:case 36299:case 36307:return ESe;case 35680:case 36300:case 36308:case 36293:return CSe;case 36289:case 36303:case 36311:case 36292:return TSe}}function kSe(t,e){t.uniform1fv(this.addr,e)}function jSe(t,e){const n=Sx(e,this.size,2);t.uniform2fv(this.addr,n)}function PSe(t,e){const n=Sx(e,this.size,3);t.uniform3fv(this.addr,n)}function RSe(t,e){const n=Sx(e,this.size,4);t.uniform4fv(this.addr,n)}function DSe(t,e){const n=Sx(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function OSe(t,e){const n=Sx(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function LSe(t,e){const n=Sx(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function ISe(t,e){t.uniform1iv(this.addr,e)}function FSe(t,e){t.uniform2iv(this.addr,e)}function USe(t,e){t.uniform3iv(this.addr,e)}function zSe(t,e){t.uniform4iv(this.addr,e)}function BSe(t,e){t.uniform1uiv(this.addr,e)}function $Se(t,e){t.uniform2uiv(this.addr,e)}function HSe(t,e){t.uniform3uiv(this.addr,e)}function VSe(t,e){t.uniform4uiv(this.addr,e)}function GSe(t,e,n){const r=this.cache,i=e.length,s=AN(n,i);Qi(r,s)||(t.uniform1iv(this.addr,s),Zi(r,s));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||tX,s[o])}function qSe(t,e,n){const r=this.cache,i=e.length,s=AN(n,i);Qi(r,s)||(t.uniform1iv(this.addr,s),Zi(r,s));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||iX,s[o])}function WSe(t,e,n){const r=this.cache,i=e.length,s=AN(n,i);Qi(r,s)||(t.uniform1iv(this.addr,s),Zi(r,s));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||aX,s[o])}function KSe(t,e,n){const r=this.cache,i=e.length,s=AN(n,i);Qi(r,s)||(t.uniform1iv(this.addr,s),Zi(r,s));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||rX,s[o])}function XSe(t){switch(t){case 5126:return kSe;case 35664:return jSe;case 35665:return PSe;case 35666:return RSe;case 35674:return DSe;case 35675:return OSe;case 35676:return LSe;case 5124:case 35670:return ISe;case 35667:case 35671:return FSe;case 35668:case 35672:return USe;case 35669:case 35673:return zSe;case 5125:return BSe;case 36294:return $Se;case 36295:return HSe;case 36296:return VSe;case 35678:case 36198:case 36298:case 36306:case 35682:return GSe;case 35679:case 36299:case 36307:return qSe;case 35680:case 36300:case 36308:case 36293:return WSe;case 36289:case 36303:case 36311:case 36292:return KSe}}class YSe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=ASe(n.type)}}class QSe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=XSe(n.type)}}class ZSe{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let s=0,o=i.length;s!==o;++s){const l=i[s];l.setValue(e,n[l.id],r)}}}const hA=/(\w+)(\])?(\[|\.)?/g;function u6(t,e){t.seq.push(e),t.map[e.id]=e}function JSe(t,e,n){const r=t.name,i=r.length;for(hA.lastIndex=0;;){const s=hA.exec(r),o=hA.lastIndex;let l=s[1];const c=s[2]==="]",u=s[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){u6(n,u===void 0?new YSe(l,t,e):new QSe(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new ZSe(l),u6(n,f)),n=f}}}class E1{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),o=e.getUniformLocation(n,s.name);JSe(s,o,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,o=n.length;s!==o;++s){const l=n[s],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,s=e.length;i!==s;++i){const o=e[i];o.id in n&&r.push(o)}return r}}function d6(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const e2e=37297;let t2e=0;function n2e(t,e){const n=t.split(`
  7342. `),r=[],i=Math.max(e-6,0),s=Math.min(e+6,n.length);for(let o=i;o<s;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
  7343. `)}function r2e(t){const e=Er.getPrimaries(Er.workingColorSpace),n=Er.getPrimaries(t);let r;switch(e===n?r="":e===iS&&n===rS?r="LinearDisplayP3ToLinearSRGB":e===rS&&n===iS&&(r="LinearSRGBToLinearDisplayP3"),t){case Lu:case CN:return[r,"LinearTransferOETF"];case ja:case a4:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function h6(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 o=parseInt(s[1]);return n.toUpperCase()+`
  7344. `+i+`
  7345. `+n2e(t.getShaderSource(e),o)}else return i}function i2e(t,e){const n=r2e(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function a2e(t,e){let n;switch(e){case ive:n="Linear";break;case ave:n="Reinhard";break;case sve:n="OptimizedCineon";break;case ove:n="ACESFilmic";break;case lve:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function s2e(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(s0).join(`
  7346. `)}function o2e(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  7347. `)}function l2e(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const s=t.getActiveAttrib(e,i),o=s.name;let l=1;s.type===t.FLOAT_MAT2&&(l=2),s.type===t.FLOAT_MAT3&&(l=3),s.type===t.FLOAT_MAT4&&(l=4),n[o]={type:s.type,location:t.getAttribLocation(e,o),locationSize:l}}return n}function s0(t){return t!==""}function f6(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 m6(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const c2e=/^[ \t]*#include +<([\w\d./]+)>/gm;function vP(t){return t.replace(c2e,d2e)}const u2e=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function d2e(t,e){let n=Tn[e];if(n===void 0){const r=u2e.get(e);if(r!==void 0)n=Tn[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 vP(n)}const h2e=/#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 p6(t){return t.replace(h2e,f2e)}function f2e(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 g6(t){let e="precision "+t.precision+` float;
  7348. precision `+t.precision+" int;";return t.precision==="highp"?e+=`
  7349. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  7350. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  7351. #define LOW_PRECISION`),e}function m2e(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===TK?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===Pye?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===lu&&(e="SHADOWMAP_TYPE_VSM"),e}function p2e(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Kg:case Xg:e="ENVMAP_TYPE_CUBE";break;case EN:e="ENVMAP_TYPE_CUBE_UV";break}return e}function g2e(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Xg:e="ENVMAP_MODE_REFRACTION";break}return e}function x2e(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case r4:e="ENVMAP_BLENDING_MULTIPLY";break;case nve:e="ENVMAP_BLENDING_MIX";break;case rve:e="ENVMAP_BLENDING_ADD";break}return e}function b2e(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 y2e(t,e,n,r){const i=t.getContext(),s=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=m2e(n),u=p2e(n),d=g2e(n),f=x2e(n),m=b2e(n),p=n.isWebGL2?"":s2e(n),x=o2e(s),b=i.createProgram();let y,v,S=n.glslVersion?"#version "+n.glslVersion+`
  7352. `:"";n.isRawShaderMaterial?(y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(s0).join(`
  7353. `),y.length>0&&(y+=`
  7354. `),v=[p,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(s0).join(`
  7355. `),v.length>0&&(v+=`
  7356. `)):(y=[g6(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  7357. `].filter(s0).join(`
  7358. `),v=[p,g6(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:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==ch?"#define TONE_MAPPING":"",n.toneMapping!==ch?Tn.tonemapping_pars_fragment:"",n.toneMapping!==ch?a2e("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Tn.colorspace_pars_fragment,i2e("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  7359. `].filter(s0).join(`
  7360. `)),o=vP(o),o=f6(o,n),o=m6(o,n),l=vP(l),l=f6(l,n),l=m6(l,n),o=p6(o),l=p6(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(S=`#version 300 es
  7361. `,y=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
  7362. `)+`
  7363. `+y,v=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===D8?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===D8?"":"#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(`
  7364. `)+`
  7365. `+v);const N=S+y+o,C=S+v+l,T=d6(i,i.VERTEX_SHADER,N),k=d6(i,i.FRAGMENT_SHADER,C);i.attachShader(b,T),i.attachShader(b,k),n.index0AttributeName!==void 0?i.bindAttribLocation(b,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(b,0,"position"),i.linkProgram(b);function E(F){if(t.debug.checkShaderErrors){const O=i.getProgramInfoLog(b).trim(),H=i.getShaderInfoLog(T).trim(),j=i.getShaderInfoLog(k).trim();let G=!0,$=!0;if(i.getProgramParameter(b,i.LINK_STATUS)===!1)if(G=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,b,T,k);else{const q=h6(i,T,"vertex"),Y=h6(i,k,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(b,i.VALIDATE_STATUS)+`
  7366. Program Info Log: `+O+`
  7367. `+q+`
  7368. `+Y)}else O!==""?console.warn("THREE.WebGLProgram: Program Info Log:",O):(H===""||j==="")&&($=!1);$&&(F.diagnostics={runnable:G,programLog:O,vertexShader:{log:H,prefix:y},fragmentShader:{log:j,prefix:v}})}i.deleteShader(T),i.deleteShader(k),D=new E1(i,b),A=l2e(i,b)}let D;this.getUniforms=function(){return D===void 0&&E(this),D};let A;this.getAttributes=function(){return A===void 0&&E(this),A};let R=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=i.getProgramParameter(b,e2e)),R},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(b),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=t2e++,this.cacheKey=e,this.usedTimes=1,this.program=b,this.vertexShader=T,this.fragmentShader=k,this}let v2e=0;class _2e{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),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.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 w2e(e),n.set(e,r)),r}}class w2e{constructor(e){this.id=v2e++,this.code=e,this.usedTimes=0}}function S2e(t,e,n,r,i,s,o){const l=new GK,c=new _2e,u=[],d=i.isWebGL2,f=i.logarithmicDepthBuffer,m=i.vertexTextures;let p=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 b(A){return A===0?"uv":`uv${A}`}function y(A,R,F,O,H){const j=O.fog,G=H.geometry,$=A.isMeshStandardMaterial?O.environment:null,q=(A.isMeshStandardMaterial?n:e).get(A.envMap||$),Y=q&&q.mapping===EN?q.image.height:null,Z=x[A.type];A.precision!==null&&(p=i.getMaxPrecision(A.precision),p!==A.precision&&console.warn("THREE.WebGLProgram.getParameters:",A.precision,"not supported, using",p,"instead."));const oe=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,B=oe!==void 0?oe.length:0;let W=0;G.morphAttributes.position!==void 0&&(W=1),G.morphAttributes.normal!==void 0&&(W=2),G.morphAttributes.color!==void 0&&(W=3);let se,ne,ce,fe;if(Z){const It=Ls[Z];se=It.vertexShader,ne=It.fragmentShader}else se=A.vertexShader,ne=A.fragmentShader,c.update(A),ce=c.getVertexShaderID(A),fe=c.getFragmentShaderID(A);const ye=t.getRenderTarget(),ge=H.isInstancedMesh===!0,xe=H.isBatchedMesh===!0,Pe=!!A.map,Ue=!!A.matcap,be=!!q,it=!!A.aoMap,U=!!A.lightMap,K=!!A.bumpMap,J=!!A.normalMap,Q=!!A.displacementMap,z=!!A.emissiveMap,re=!!A.metalnessMap,Ee=!!A.roughnessMap,_e=A.anisotropy>0,Te=A.clearcoat>0,V=A.iridescence>0,L=A.sheen>0,X=A.transmission>0,te=_e&&!!A.anisotropyMap,Me=Te&&!!A.clearcoatMap,ie=Te&&!!A.clearcoatNormalMap,De=Te&&!!A.clearcoatRoughnessMap,Le=V&&!!A.iridescenceMap,$e=V&&!!A.iridescenceThicknessMap,Ze=L&&!!A.sheenColorMap,Ie=L&&!!A.sheenRoughnessMap,ae=!!A.specularMap,He=!!A.specularColorMap,Se=!!A.specularIntensityMap,Be=X&&!!A.transmissionMap,ft=X&&!!A.thicknessMap,we=!!A.gradientMap,tt=!!A.alphaMap,ke=A.alphaTest>0,We=!!A.alphaHash,pe=!!A.extensions,Ce=!!G.attributes.uv1,de=!!G.attributes.uv2,Ve=!!G.attributes.uv3;let yt=ch;return A.toneMapped&&(ye===null||ye.isXRRenderTarget===!0)&&(yt=t.toneMapping),{isWebGL2:d,shaderID:Z,shaderType:A.type,shaderName:A.name,vertexShader:se,fragmentShader:ne,defines:A.defines,customVertexShaderID:ce,customFragmentShaderID:fe,isRawShaderMaterial:A.isRawShaderMaterial===!0,glslVersion:A.glslVersion,precision:p,batching:xe,instancing:ge,instancingColor:ge&&H.instanceColor!==null,supportsVertexTextures:m,outputColorSpace:ye===null?t.outputColorSpace:ye.isXRRenderTarget===!0?ye.texture.colorSpace:Lu,map:Pe,matcap:Ue,envMap:be,envMapMode:be&&q.mapping,envMapCubeUVHeight:Y,aoMap:it,lightMap:U,bumpMap:K,normalMap:J,displacementMap:m&&Q,emissiveMap:z,normalMapObjectSpace:J&&A.normalMapType===vve,normalMapTangentSpace:J&&A.normalMapType===FK,metalnessMap:re,roughnessMap:Ee,anisotropy:_e,anisotropyMap:te,clearcoat:Te,clearcoatMap:Me,clearcoatNormalMap:ie,clearcoatRoughnessMap:De,iridescence:V,iridescenceMap:Le,iridescenceThicknessMap:$e,sheen:L,sheenColorMap:Ze,sheenRoughnessMap:Ie,specularMap:ae,specularColorMap:He,specularIntensityMap:Se,transmission:X,transmissionMap:Be,thicknessMap:ft,gradientMap:we,opaque:A.transparent===!1&&A.blending===Tg,alphaMap:tt,alphaTest:ke,alphaHash:We,combine:A.combine,mapUv:Pe&&b(A.map.channel),aoMapUv:it&&b(A.aoMap.channel),lightMapUv:U&&b(A.lightMap.channel),bumpMapUv:K&&b(A.bumpMap.channel),normalMapUv:J&&b(A.normalMap.channel),displacementMapUv:Q&&b(A.displacementMap.channel),emissiveMapUv:z&&b(A.emissiveMap.channel),metalnessMapUv:re&&b(A.metalnessMap.channel),roughnessMapUv:Ee&&b(A.roughnessMap.channel),anisotropyMapUv:te&&b(A.anisotropyMap.channel),clearcoatMapUv:Me&&b(A.clearcoatMap.channel),clearcoatNormalMapUv:ie&&b(A.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:De&&b(A.clearcoatRoughnessMap.channel),iridescenceMapUv:Le&&b(A.iridescenceMap.channel),iridescenceThicknessMapUv:$e&&b(A.iridescenceThicknessMap.channel),sheenColorMapUv:Ze&&b(A.sheenColorMap.channel),sheenRoughnessMapUv:Ie&&b(A.sheenRoughnessMap.channel),specularMapUv:ae&&b(A.specularMap.channel),specularColorMapUv:He&&b(A.specularColorMap.channel),specularIntensityMapUv:Se&&b(A.specularIntensityMap.channel),transmissionMapUv:Be&&b(A.transmissionMap.channel),thicknessMapUv:ft&&b(A.thicknessMap.channel),alphaMapUv:tt&&b(A.alphaMap.channel),vertexTangents:!!G.attributes.tangent&&(J||_e),vertexColors:A.vertexColors,vertexAlphas:A.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,vertexUv1s:Ce,vertexUv2s:de,vertexUv3s:Ve,pointsUvs:H.isPoints===!0&&!!G.attributes.uv&&(Pe||tt),fog:!!j,useFog:A.fog===!0,fogExp2:j&&j.isFogExp2,flatShading:A.flatShading===!0,sizeAttenuation:A.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:H.isSkinnedMesh===!0,morphTargets:G.morphAttributes.position!==void 0,morphNormals:G.morphAttributes.normal!==void 0,morphColors:G.morphAttributes.color!==void 0,morphTargetsCount:B,morphTextureStride:W,numDirLights:R.directional.length,numPointLights:R.point.length,numSpotLights:R.spot.length,numSpotLightMaps:R.spotLightMap.length,numRectAreaLights:R.rectArea.length,numHemiLights:R.hemi.length,numDirLightShadows:R.directionalShadowMap.length,numPointLightShadows:R.pointShadowMap.length,numSpotLightShadows:R.spotShadowMap.length,numSpotLightShadowsWithMaps:R.numSpotLightShadowsWithMaps,numLightProbes:R.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:A.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:yt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:Pe&&A.map.isVideoTexture===!0&&Er.getTransfer(A.map.colorSpace)===$r,premultipliedAlpha:A.premultipliedAlpha,doubleSided:A.side===hu,flipSided:A.side===Bs,useDepthPacking:A.depthPacking>=0,depthPacking:A.depthPacking||0,index0AttributeName:A.index0AttributeName,extensionDerivatives:pe&&A.extensions.derivatives===!0,extensionFragDepth:pe&&A.extensions.fragDepth===!0,extensionDrawBuffers:pe&&A.extensions.drawBuffers===!0,extensionShaderTextureLOD:pe&&A.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:A.customProgramCacheKey()}}function v(A){const R=[];if(A.shaderID?R.push(A.shaderID):(R.push(A.customVertexShaderID),R.push(A.customFragmentShaderID)),A.defines!==void 0)for(const F in A.defines)R.push(F),R.push(A.defines[F]);return A.isRawShaderMaterial===!1&&(S(R,A),N(R,A),R.push(t.outputColorSpace)),R.push(A.customProgramCacheKey),R.join()}function S(A,R){A.push(R.precision),A.push(R.outputColorSpace),A.push(R.envMapMode),A.push(R.envMapCubeUVHeight),A.push(R.mapUv),A.push(R.alphaMapUv),A.push(R.lightMapUv),A.push(R.aoMapUv),A.push(R.bumpMapUv),A.push(R.normalMapUv),A.push(R.displacementMapUv),A.push(R.emissiveMapUv),A.push(R.metalnessMapUv),A.push(R.roughnessMapUv),A.push(R.anisotropyMapUv),A.push(R.clearcoatMapUv),A.push(R.clearcoatNormalMapUv),A.push(R.clearcoatRoughnessMapUv),A.push(R.iridescenceMapUv),A.push(R.iridescenceThicknessMapUv),A.push(R.sheenColorMapUv),A.push(R.sheenRoughnessMapUv),A.push(R.specularMapUv),A.push(R.specularColorMapUv),A.push(R.specularIntensityMapUv),A.push(R.transmissionMapUv),A.push(R.thicknessMapUv),A.push(R.combine),A.push(R.fogExp2),A.push(R.sizeAttenuation),A.push(R.morphTargetsCount),A.push(R.morphAttributeCount),A.push(R.numDirLights),A.push(R.numPointLights),A.push(R.numSpotLights),A.push(R.numSpotLightMaps),A.push(R.numHemiLights),A.push(R.numRectAreaLights),A.push(R.numDirLightShadows),A.push(R.numPointLightShadows),A.push(R.numSpotLightShadows),A.push(R.numSpotLightShadowsWithMaps),A.push(R.numLightProbes),A.push(R.shadowMapType),A.push(R.toneMapping),A.push(R.numClippingPlanes),A.push(R.numClipIntersection),A.push(R.depthPacking)}function N(A,R){l.disableAll(),R.isWebGL2&&l.enable(0),R.supportsVertexTextures&&l.enable(1),R.instancing&&l.enable(2),R.instancingColor&&l.enable(3),R.matcap&&l.enable(4),R.envMap&&l.enable(5),R.normalMapObjectSpace&&l.enable(6),R.normalMapTangentSpace&&l.enable(7),R.clearcoat&&l.enable(8),R.iridescence&&l.enable(9),R.alphaTest&&l.enable(10),R.vertexColors&&l.enable(11),R.vertexAlphas&&l.enable(12),R.vertexUv1s&&l.enable(13),R.vertexUv2s&&l.enable(14),R.vertexUv3s&&l.enable(15),R.vertexTangents&&l.enable(16),R.anisotropy&&l.enable(17),R.alphaHash&&l.enable(18),R.batching&&l.enable(19),A.push(l.mask),l.disableAll(),R.fog&&l.enable(0),R.useFog&&l.enable(1),R.flatShading&&l.enable(2),R.logarithmicDepthBuffer&&l.enable(3),R.skinning&&l.enable(4),R.morphTargets&&l.enable(5),R.morphNormals&&l.enable(6),R.morphColors&&l.enable(7),R.premultipliedAlpha&&l.enable(8),R.shadowMapEnabled&&l.enable(9),R.useLegacyLights&&l.enable(10),R.doubleSided&&l.enable(11),R.flipSided&&l.enable(12),R.useDepthPacking&&l.enable(13),R.dithering&&l.enable(14),R.transmission&&l.enable(15),R.sheen&&l.enable(16),R.opaque&&l.enable(17),R.pointsUvs&&l.enable(18),R.decodeVideoTexture&&l.enable(19),A.push(l.mask)}function C(A){const R=x[A.type];let F;if(R){const O=Ls[R];F=l4.clone(O.uniforms)}else F=A.uniforms;return F}function T(A,R){let F;for(let O=0,H=u.length;O<H;O++){const j=u[O];if(j.cacheKey===R){F=j,++F.usedTimes;break}}return F===void 0&&(F=new y2e(t,R,A,s),u.push(F)),F}function k(A){if(--A.usedTimes===0){const R=u.indexOf(A);u[R]=u[u.length-1],u.pop(),A.destroy()}}function E(A){c.remove(A)}function D(){c.dispose()}return{getParameters:y,getProgramCacheKey:v,getUniforms:C,acquireProgram:T,releaseProgram:k,releaseShaderCache:E,programs:u,dispose:D}}function N2e(){let t=new WeakMap;function e(s){let o=t.get(s);return o===void 0&&(o={},t.set(s,o)),o}function n(s){t.delete(s)}function r(s,o,l){t.get(s)[o]=l}function i(){t=new WeakMap}return{get:e,remove:n,update:r,dispose:i}}function M2e(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 x6(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 b6(){const t=[];let e=0;const n=[],r=[],i=[];function s(){e=0,n.length=0,r.length=0,i.length=0}function o(f,m,p,x,b,y){let v=t[e];return v===void 0?(v={id:f.id,object:f,geometry:m,material:p,groupOrder:x,renderOrder:f.renderOrder,z:b,group:y},t[e]=v):(v.id=f.id,v.object=f,v.geometry=m,v.material=p,v.groupOrder=x,v.renderOrder=f.renderOrder,v.z=b,v.group=y),e++,v}function l(f,m,p,x,b,y){const v=o(f,m,p,x,b,y);p.transmission>0?r.push(v):p.transparent===!0?i.push(v):n.push(v)}function c(f,m,p,x,b,y){const v=o(f,m,p,x,b,y);p.transmission>0?r.unshift(v):p.transparent===!0?i.unshift(v):n.unshift(v)}function u(f,m){n.length>1&&n.sort(f||M2e),r.length>1&&r.sort(m||x6),i.length>1&&i.sort(m||x6)}function d(){for(let f=e,m=t.length;f<m;f++){const p=t[f];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:n,transmissive:r,transparent:i,init:s,push:l,unshift:c,finish:d,sort:u}}function E2e(){let t=new WeakMap;function e(r,i){const s=t.get(r);let o;return s===void 0?(o=new b6,t.set(r,[o])):i>=s.length?(o=new b6,s.push(o)):o=s[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function C2e(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new qe,color:new en};break;case"SpotLight":n={position:new qe,direction:new qe,color:new en,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new qe,color:new en,distance:0,decay:0};break;case"HemisphereLight":n={direction:new qe,skyColor:new en,groundColor:new en};break;case"RectAreaLight":n={color:new en,position:new qe,halfWidth:new qe,halfHeight:new qe};break}return t[e.id]=n,n}}}function T2e(){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 xn};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xn};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let A2e=0;function k2e(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function j2e(t,e){const n=new C2e,r=T2e(),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 qe);const s=new qe,o=new Fr,l=new Fr;function c(d,f){let m=0,p=0,x=0;for(let O=0;O<9;O++)i.probe[O].set(0,0,0);let b=0,y=0,v=0,S=0,N=0,C=0,T=0,k=0,E=0,D=0,A=0;d.sort(k2e);const R=f===!0?Math.PI:1;for(let O=0,H=d.length;O<H;O++){const j=d[O],G=j.color,$=j.intensity,q=j.distance,Y=j.shadow&&j.shadow.map?j.shadow.map.texture:null;if(j.isAmbientLight)m+=G.r*$*R,p+=G.g*$*R,x+=G.b*$*R;else if(j.isLightProbe){for(let Z=0;Z<9;Z++)i.probe[Z].addScaledVector(j.sh.coefficients[Z],$);A++}else if(j.isDirectionalLight){const Z=n.get(j);if(Z.color.copy(j.color).multiplyScalar(j.intensity*R),j.castShadow){const oe=j.shadow,B=r.get(j);B.shadowBias=oe.bias,B.shadowNormalBias=oe.normalBias,B.shadowRadius=oe.radius,B.shadowMapSize=oe.mapSize,i.directionalShadow[b]=B,i.directionalShadowMap[b]=Y,i.directionalShadowMatrix[b]=j.shadow.matrix,C++}i.directional[b]=Z,b++}else if(j.isSpotLight){const Z=n.get(j);Z.position.setFromMatrixPosition(j.matrixWorld),Z.color.copy(G).multiplyScalar($*R),Z.distance=q,Z.coneCos=Math.cos(j.angle),Z.penumbraCos=Math.cos(j.angle*(1-j.penumbra)),Z.decay=j.decay,i.spot[v]=Z;const oe=j.shadow;if(j.map&&(i.spotLightMap[E]=j.map,E++,oe.updateMatrices(j),j.castShadow&&D++),i.spotLightMatrix[v]=oe.matrix,j.castShadow){const B=r.get(j);B.shadowBias=oe.bias,B.shadowNormalBias=oe.normalBias,B.shadowRadius=oe.radius,B.shadowMapSize=oe.mapSize,i.spotShadow[v]=B,i.spotShadowMap[v]=Y,k++}v++}else if(j.isRectAreaLight){const Z=n.get(j);Z.color.copy(G).multiplyScalar($),Z.halfWidth.set(j.width*.5,0,0),Z.halfHeight.set(0,j.height*.5,0),i.rectArea[S]=Z,S++}else if(j.isPointLight){const Z=n.get(j);if(Z.color.copy(j.color).multiplyScalar(j.intensity*R),Z.distance=j.distance,Z.decay=j.decay,j.castShadow){const oe=j.shadow,B=r.get(j);B.shadowBias=oe.bias,B.shadowNormalBias=oe.normalBias,B.shadowRadius=oe.radius,B.shadowMapSize=oe.mapSize,B.shadowCameraNear=oe.camera.near,B.shadowCameraFar=oe.camera.far,i.pointShadow[y]=B,i.pointShadowMap[y]=Y,i.pointShadowMatrix[y]=j.shadow.matrix,T++}i.point[y]=Z,y++}else if(j.isHemisphereLight){const Z=n.get(j);Z.skyColor.copy(j.color).multiplyScalar($*R),Z.groundColor.copy(j.groundColor).multiplyScalar($*R),i.hemi[N]=Z,N++}}S>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Pt.LTC_FLOAT_1,i.rectAreaLTC2=Pt.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Pt.LTC_HALF_1,i.rectAreaLTC2=Pt.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=m,i.ambient[1]=p,i.ambient[2]=x;const F=i.hash;(F.directionalLength!==b||F.pointLength!==y||F.spotLength!==v||F.rectAreaLength!==S||F.hemiLength!==N||F.numDirectionalShadows!==C||F.numPointShadows!==T||F.numSpotShadows!==k||F.numSpotMaps!==E||F.numLightProbes!==A)&&(i.directional.length=b,i.spot.length=v,i.rectArea.length=S,i.point.length=y,i.hemi.length=N,i.directionalShadow.length=C,i.directionalShadowMap.length=C,i.pointShadow.length=T,i.pointShadowMap.length=T,i.spotShadow.length=k,i.spotShadowMap.length=k,i.directionalShadowMatrix.length=C,i.pointShadowMatrix.length=T,i.spotLightMatrix.length=k+E-D,i.spotLightMap.length=E,i.numSpotLightShadowsWithMaps=D,i.numLightProbes=A,F.directionalLength=b,F.pointLength=y,F.spotLength=v,F.rectAreaLength=S,F.hemiLength=N,F.numDirectionalShadows=C,F.numPointShadows=T,F.numSpotShadows=k,F.numSpotMaps=E,F.numLightProbes=A,i.version=A2e++)}function u(d,f){let m=0,p=0,x=0,b=0,y=0;const v=f.matrixWorldInverse;for(let S=0,N=d.length;S<N;S++){const C=d[S];if(C.isDirectionalLight){const T=i.directional[m];T.direction.setFromMatrixPosition(C.matrixWorld),s.setFromMatrixPosition(C.target.matrixWorld),T.direction.sub(s),T.direction.transformDirection(v),m++}else if(C.isSpotLight){const T=i.spot[x];T.position.setFromMatrixPosition(C.matrixWorld),T.position.applyMatrix4(v),T.direction.setFromMatrixPosition(C.matrixWorld),s.setFromMatrixPosition(C.target.matrixWorld),T.direction.sub(s),T.direction.transformDirection(v),x++}else if(C.isRectAreaLight){const T=i.rectArea[b];T.position.setFromMatrixPosition(C.matrixWorld),T.position.applyMatrix4(v),l.identity(),o.copy(C.matrixWorld),o.premultiply(v),l.extractRotation(o),T.halfWidth.set(C.width*.5,0,0),T.halfHeight.set(0,C.height*.5,0),T.halfWidth.applyMatrix4(l),T.halfHeight.applyMatrix4(l),b++}else if(C.isPointLight){const T=i.point[p];T.position.setFromMatrixPosition(C.matrixWorld),T.position.applyMatrix4(v),p++}else if(C.isHemisphereLight){const T=i.hemi[y];T.direction.setFromMatrixPosition(C.matrixWorld),T.direction.transformDirection(v),y++}}}return{setup:c,setupView:u,state:i}}function y6(t,e){const n=new j2e(t,e),r=[],i=[];function s(){r.length=0,i.length=0}function o(f){r.push(f)}function l(f){i.push(f)}function c(f){n.setup(r,f)}function u(f){n.setupView(r,f)}return{init:s,state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:c,setupLightsView:u,pushLight:o,pushShadow:l}}function P2e(t,e){let n=new WeakMap;function r(s,o=0){const l=n.get(s);let c;return l===void 0?(c=new y6(t,e),n.set(s,[c])):o>=l.length?(c=new y6(t,e),l.push(c)):c=l[o],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class R2e extends wx{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=bve,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 D2e extends wx{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 O2e=`void main() {
  7369. gl_Position = vec4( position, 1.0 );
  7370. }`,L2e=`uniform sampler2D shadow_pass;
  7371. uniform vec2 resolution;
  7372. uniform float radius;
  7373. #include <packing>
  7374. void main() {
  7375. const float samples = float( VSM_SAMPLES );
  7376. float mean = 0.0;
  7377. float squared_mean = 0.0;
  7378. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  7379. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  7380. for ( float i = 0.0; i < samples; i ++ ) {
  7381. float uvOffset = uvStart + i * uvStride;
  7382. #ifdef HORIZONTAL_PASS
  7383. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  7384. mean += distribution.x;
  7385. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  7386. #else
  7387. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  7388. mean += depth;
  7389. squared_mean += depth * depth;
  7390. #endif
  7391. }
  7392. mean = mean / samples;
  7393. squared_mean = squared_mean / samples;
  7394. float std_dev = sqrt( squared_mean - mean * mean );
  7395. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  7396. }`;function I2e(t,e,n){let r=new TN;const i=new xn,s=new xn,o=new Ar,l=new R2e({depthPacking:yve}),c=new D2e,u={},d=n.maxTextureSize,f={[Sh]:Bs,[Bs]:Sh,[hu]:hu},m=new Nh({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new xn},radius:{value:4}},vertexShader:O2e,fragmentShader:L2e}),p=m.clone();p.defines.HORIZONTAL_PASS=1;const x=new Ja;x.setAttribute("position",new go(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const b=new Rl(x,m),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=TK;let v=this.type;this.render=function(T,k,E){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||T.length===0)return;const D=t.getRenderTarget(),A=t.getActiveCubeFace(),R=t.getActiveMipmapLevel(),F=t.state;F.setBlending(lh),F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const O=v!==lu&&this.type===lu,H=v===lu&&this.type!==lu;for(let j=0,G=T.length;j<G;j++){const $=T[j],q=$.shadow;if(q===void 0){console.warn("THREE.WebGLShadowMap:",$,"has no shadow.");continue}if(q.autoUpdate===!1&&q.needsUpdate===!1)continue;i.copy(q.mapSize);const Y=q.getFrameExtents();if(i.multiply(Y),s.copy(q.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/Y.x),i.x=s.x*Y.x,q.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/Y.y),i.y=s.y*Y.y,q.mapSize.y=s.y)),q.map===null||O===!0||H===!0){const oe=this.type!==lu?{minFilter:ka,magFilter:ka}:{};q.map!==null&&q.map.dispose(),q.map=new dm(i.x,i.y,oe),q.map.texture.name=$.name+".shadowMap",q.camera.updateProjectionMatrix()}t.setRenderTarget(q.map),t.clear();const Z=q.getViewportCount();for(let oe=0;oe<Z;oe++){const B=q.getViewport(oe);o.set(s.x*B.x,s.y*B.y,s.x*B.z,s.y*B.w),F.viewport(o),q.updateMatrices($,oe),r=q.getFrustum(),C(k,E,q.camera,$,this.type)}q.isPointLightShadow!==!0&&this.type===lu&&S(q,E),q.needsUpdate=!1}v=this.type,y.needsUpdate=!1,t.setRenderTarget(D,A,R)};function S(T,k){const E=e.update(b);m.defines.VSM_SAMPLES!==T.blurSamples&&(m.defines.VSM_SAMPLES=T.blurSamples,p.defines.VSM_SAMPLES=T.blurSamples,m.needsUpdate=!0,p.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new dm(i.x,i.y)),m.uniforms.shadow_pass.value=T.map.texture,m.uniforms.resolution.value=T.mapSize,m.uniforms.radius.value=T.radius,t.setRenderTarget(T.mapPass),t.clear(),t.renderBufferDirect(k,null,E,m,b,null),p.uniforms.shadow_pass.value=T.mapPass.texture,p.uniforms.resolution.value=T.mapSize,p.uniforms.radius.value=T.radius,t.setRenderTarget(T.map),t.clear(),t.renderBufferDirect(k,null,E,p,b,null)}function N(T,k,E,D){let A=null;const R=E.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(R!==void 0)A=R;else if(A=E.isPointLight===!0?c:l,t.localClippingEnabled&&k.clipShadows===!0&&Array.isArray(k.clippingPlanes)&&k.clippingPlanes.length!==0||k.displacementMap&&k.displacementScale!==0||k.alphaMap&&k.alphaTest>0||k.map&&k.alphaTest>0){const F=A.uuid,O=k.uuid;let H=u[F];H===void 0&&(H={},u[F]=H);let j=H[O];j===void 0&&(j=A.clone(),H[O]=j),A=j}if(A.visible=k.visible,A.wireframe=k.wireframe,D===lu?A.side=k.shadowSide!==null?k.shadowSide:k.side:A.side=k.shadowSide!==null?k.shadowSide:f[k.side],A.alphaMap=k.alphaMap,A.alphaTest=k.alphaTest,A.map=k.map,A.clipShadows=k.clipShadows,A.clippingPlanes=k.clippingPlanes,A.clipIntersection=k.clipIntersection,A.displacementMap=k.displacementMap,A.displacementScale=k.displacementScale,A.displacementBias=k.displacementBias,A.wireframeLinewidth=k.wireframeLinewidth,A.linewidth=k.linewidth,E.isPointLight===!0&&A.isMeshDistanceMaterial===!0){const F=t.properties.get(A);F.light=E}return A}function C(T,k,E,D,A){if(T.visible===!1)return;if(T.layers.test(k.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&A===lu)&&(!T.frustumCulled||r.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(E.matrixWorldInverse,T.matrixWorld);const O=e.update(T),H=T.material;if(Array.isArray(H)){const j=O.groups;for(let G=0,$=j.length;G<$;G++){const q=j[G],Y=H[q.materialIndex];if(Y&&Y.visible){const Z=N(T,Y,D,A);T.onBeforeShadow(t,T,k,E,O,Z,q),t.renderBufferDirect(E,null,O,Z,T,q),T.onAfterShadow(t,T,k,E,O,Z,q)}}}else if(H.visible){const j=N(T,H,D,A);T.onBeforeShadow(t,T,k,E,O,j,null),t.renderBufferDirect(E,null,O,j,T,null),T.onAfterShadow(t,T,k,E,O,j,null)}}const F=T.children;for(let O=0,H=F.length;O<H;O++)C(F[O],k,E,D,A)}}function F2e(t,e,n){const r=n.isWebGL2;function i(){let ke=!1;const We=new Ar;let pe=null;const Ce=new Ar(0,0,0,0);return{setMask:function(de){pe!==de&&!ke&&(t.colorMask(de,de,de,de),pe=de)},setLocked:function(de){ke=de},setClear:function(de,Ve,yt,ut,It){It===!0&&(de*=ut,Ve*=ut,yt*=ut),We.set(de,Ve,yt,ut),Ce.equals(We)===!1&&(t.clearColor(de,Ve,yt,ut),Ce.copy(We))},reset:function(){ke=!1,pe=null,Ce.set(-1,0,0,0)}}}function s(){let ke=!1,We=null,pe=null,Ce=null;return{setTest:function(de){de?xe(t.DEPTH_TEST):Pe(t.DEPTH_TEST)},setMask:function(de){We!==de&&!ke&&(t.depthMask(de),We=de)},setFunc:function(de){if(pe!==de){switch(de){case Xye:t.depthFunc(t.NEVER);break;case Yye:t.depthFunc(t.ALWAYS);break;case Qye:t.depthFunc(t.LESS);break;case tS:t.depthFunc(t.LEQUAL);break;case Zye:t.depthFunc(t.EQUAL);break;case Jye:t.depthFunc(t.GEQUAL);break;case eve:t.depthFunc(t.GREATER);break;case tve:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}pe=de}},setLocked:function(de){ke=de},setClear:function(de){Ce!==de&&(t.clearDepth(de),Ce=de)},reset:function(){ke=!1,We=null,pe=null,Ce=null}}}function o(){let ke=!1,We=null,pe=null,Ce=null,de=null,Ve=null,yt=null,ut=null,It=null;return{setTest:function(Ft){ke||(Ft?xe(t.STENCIL_TEST):Pe(t.STENCIL_TEST))},setMask:function(Ft){We!==Ft&&!ke&&(t.stencilMask(Ft),We=Ft)},setFunc:function(Ft,vn,Kt){(pe!==Ft||Ce!==vn||de!==Kt)&&(t.stencilFunc(Ft,vn,Kt),pe=Ft,Ce=vn,de=Kt)},setOp:function(Ft,vn,Kt){(Ve!==Ft||yt!==vn||ut!==Kt)&&(t.stencilOp(Ft,vn,Kt),Ve=Ft,yt=vn,ut=Kt)},setLocked:function(Ft){ke=Ft},setClear:function(Ft){It!==Ft&&(t.clearStencil(Ft),It=Ft)},reset:function(){ke=!1,We=null,pe=null,Ce=null,de=null,Ve=null,yt=null,ut=null,It=null}}}const l=new i,c=new s,u=new o,d=new WeakMap,f=new WeakMap;let m={},p={},x=new WeakMap,b=[],y=null,v=!1,S=null,N=null,C=null,T=null,k=null,E=null,D=null,A=new en(0,0,0),R=0,F=!1,O=null,H=null,j=null,G=null,$=null;const q=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Y=!1,Z=0;const oe=t.getParameter(t.VERSION);oe.indexOf("WebGL")!==-1?(Z=parseFloat(/^WebGL (\d)/.exec(oe)[1]),Y=Z>=1):oe.indexOf("OpenGL ES")!==-1&&(Z=parseFloat(/^OpenGL ES (\d)/.exec(oe)[1]),Y=Z>=2);let B=null,W={};const se=t.getParameter(t.SCISSOR_BOX),ne=t.getParameter(t.VIEWPORT),ce=new Ar().fromArray(se),fe=new Ar().fromArray(ne);function ye(ke,We,pe,Ce){const de=new Uint8Array(4),Ve=t.createTexture();t.bindTexture(ke,Ve),t.texParameteri(ke,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(ke,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let yt=0;yt<pe;yt++)r&&(ke===t.TEXTURE_3D||ke===t.TEXTURE_2D_ARRAY)?t.texImage3D(We,0,t.RGBA,1,1,Ce,0,t.RGBA,t.UNSIGNED_BYTE,de):t.texImage2D(We+yt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,de);return Ve}const ge={};ge[t.TEXTURE_2D]=ye(t.TEXTURE_2D,t.TEXTURE_2D,1),ge[t.TEXTURE_CUBE_MAP]=ye(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(ge[t.TEXTURE_2D_ARRAY]=ye(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),ge[t.TEXTURE_3D]=ye(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),c.setClear(1),u.setClear(0),xe(t.DEPTH_TEST),c.setFunc(tS),z(!1),re(t8),xe(t.CULL_FACE),J(lh);function xe(ke){m[ke]!==!0&&(t.enable(ke),m[ke]=!0)}function Pe(ke){m[ke]!==!1&&(t.disable(ke),m[ke]=!1)}function Ue(ke,We){return p[ke]!==We?(t.bindFramebuffer(ke,We),p[ke]=We,r&&(ke===t.DRAW_FRAMEBUFFER&&(p[t.FRAMEBUFFER]=We),ke===t.FRAMEBUFFER&&(p[t.DRAW_FRAMEBUFFER]=We)),!0):!1}function be(ke,We){let pe=b,Ce=!1;if(ke)if(pe=x.get(We),pe===void 0&&(pe=[],x.set(We,pe)),ke.isWebGLMultipleRenderTargets){const de=ke.texture;if(pe.length!==de.length||pe[0]!==t.COLOR_ATTACHMENT0){for(let Ve=0,yt=de.length;Ve<yt;Ve++)pe[Ve]=t.COLOR_ATTACHMENT0+Ve;pe.length=de.length,Ce=!0}}else pe[0]!==t.COLOR_ATTACHMENT0&&(pe[0]=t.COLOR_ATTACHMENT0,Ce=!0);else pe[0]!==t.BACK&&(pe[0]=t.BACK,Ce=!0);Ce&&(n.isWebGL2?t.drawBuffers(pe):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(pe))}function it(ke){return y!==ke?(t.useProgram(ke),y=ke,!0):!1}const U={[Ef]:t.FUNC_ADD,[Dye]:t.FUNC_SUBTRACT,[Oye]:t.FUNC_REVERSE_SUBTRACT};if(r)U[a8]=t.MIN,U[s8]=t.MAX;else{const ke=e.get("EXT_blend_minmax");ke!==null&&(U[a8]=ke.MIN_EXT,U[s8]=ke.MAX_EXT)}const K={[Lye]:t.ZERO,[Iye]:t.ONE,[Fye]:t.SRC_COLOR,[dP]:t.SRC_ALPHA,[Vye]:t.SRC_ALPHA_SATURATE,[$ye]:t.DST_COLOR,[zye]:t.DST_ALPHA,[Uye]:t.ONE_MINUS_SRC_COLOR,[hP]:t.ONE_MINUS_SRC_ALPHA,[Hye]:t.ONE_MINUS_DST_COLOR,[Bye]:t.ONE_MINUS_DST_ALPHA,[Gye]:t.CONSTANT_COLOR,[qye]:t.ONE_MINUS_CONSTANT_COLOR,[Wye]:t.CONSTANT_ALPHA,[Kye]:t.ONE_MINUS_CONSTANT_ALPHA};function J(ke,We,pe,Ce,de,Ve,yt,ut,It,Ft){if(ke===lh){v===!0&&(Pe(t.BLEND),v=!1);return}if(v===!1&&(xe(t.BLEND),v=!0),ke!==Rye){if(ke!==S||Ft!==F){if((N!==Ef||k!==Ef)&&(t.blendEquation(t.FUNC_ADD),N=Ef,k=Ef),Ft)switch(ke){case Tg:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case n8:t.blendFunc(t.ONE,t.ONE);break;case r8:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case i8:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",ke);break}else switch(ke){case Tg:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case n8:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case r8:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case i8:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",ke);break}C=null,T=null,E=null,D=null,A.set(0,0,0),R=0,S=ke,F=Ft}return}de=de||We,Ve=Ve||pe,yt=yt||Ce,(We!==N||de!==k)&&(t.blendEquationSeparate(U[We],U[de]),N=We,k=de),(pe!==C||Ce!==T||Ve!==E||yt!==D)&&(t.blendFuncSeparate(K[pe],K[Ce],K[Ve],K[yt]),C=pe,T=Ce,E=Ve,D=yt),(ut.equals(A)===!1||It!==R)&&(t.blendColor(ut.r,ut.g,ut.b,It),A.copy(ut),R=It),S=ke,F=!1}function Q(ke,We){ke.side===hu?Pe(t.CULL_FACE):xe(t.CULL_FACE);let pe=ke.side===Bs;We&&(pe=!pe),z(pe),ke.blending===Tg&&ke.transparent===!1?J(lh):J(ke.blending,ke.blendEquation,ke.blendSrc,ke.blendDst,ke.blendEquationAlpha,ke.blendSrcAlpha,ke.blendDstAlpha,ke.blendColor,ke.blendAlpha,ke.premultipliedAlpha),c.setFunc(ke.depthFunc),c.setTest(ke.depthTest),c.setMask(ke.depthWrite),l.setMask(ke.colorWrite);const Ce=ke.stencilWrite;u.setTest(Ce),Ce&&(u.setMask(ke.stencilWriteMask),u.setFunc(ke.stencilFunc,ke.stencilRef,ke.stencilFuncMask),u.setOp(ke.stencilFail,ke.stencilZFail,ke.stencilZPass)),_e(ke.polygonOffset,ke.polygonOffsetFactor,ke.polygonOffsetUnits),ke.alphaToCoverage===!0?xe(t.SAMPLE_ALPHA_TO_COVERAGE):Pe(t.SAMPLE_ALPHA_TO_COVERAGE)}function z(ke){O!==ke&&(ke?t.frontFace(t.CW):t.frontFace(t.CCW),O=ke)}function re(ke){ke!==kye?(xe(t.CULL_FACE),ke!==H&&(ke===t8?t.cullFace(t.BACK):ke===jye?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Pe(t.CULL_FACE),H=ke}function Ee(ke){ke!==j&&(Y&&t.lineWidth(ke),j=ke)}function _e(ke,We,pe){ke?(xe(t.POLYGON_OFFSET_FILL),(G!==We||$!==pe)&&(t.polygonOffset(We,pe),G=We,$=pe)):Pe(t.POLYGON_OFFSET_FILL)}function Te(ke){ke?xe(t.SCISSOR_TEST):Pe(t.SCISSOR_TEST)}function V(ke){ke===void 0&&(ke=t.TEXTURE0+q-1),B!==ke&&(t.activeTexture(ke),B=ke)}function L(ke,We,pe){pe===void 0&&(B===null?pe=t.TEXTURE0+q-1:pe=B);let Ce=W[pe];Ce===void 0&&(Ce={type:void 0,texture:void 0},W[pe]=Ce),(Ce.type!==ke||Ce.texture!==We)&&(B!==pe&&(t.activeTexture(pe),B=pe),t.bindTexture(ke,We||ge[ke]),Ce.type=ke,Ce.texture=We)}function X(){const ke=W[B];ke!==void 0&&ke.type!==void 0&&(t.bindTexture(ke.type,null),ke.type=void 0,ke.texture=void 0)}function te(){try{t.compressedTexImage2D.apply(t,arguments)}catch(ke){console.error("THREE.WebGLState:",ke)}}function Me(){try{t.compressedTexImage3D.apply(t,arguments)}catch(ke){console.error("THREE.WebGLState:",ke)}}function ie(){try{t.texSubImage2D.apply(t,arguments)}catch(ke){console.error("THREE.WebGLState:",ke)}}function De(){try{t.texSubImage3D.apply(t,arguments)}catch(ke){console.error("THREE.WebGLState:",ke)}}function Le(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(ke){console.error("THREE.WebGLState:",ke)}}function $e(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(ke){console.error("THREE.WebGLState:",ke)}}function Ze(){try{t.texStorage2D.apply(t,arguments)}catch(ke){console.error("THREE.WebGLState:",ke)}}function Ie(){try{t.texStorage3D.apply(t,arguments)}catch(ke){console.error("THREE.WebGLState:",ke)}}function ae(){try{t.texImage2D.apply(t,arguments)}catch(ke){console.error("THREE.WebGLState:",ke)}}function He(){try{t.texImage3D.apply(t,arguments)}catch(ke){console.error("THREE.WebGLState:",ke)}}function Se(ke){ce.equals(ke)===!1&&(t.scissor(ke.x,ke.y,ke.z,ke.w),ce.copy(ke))}function Be(ke){fe.equals(ke)===!1&&(t.viewport(ke.x,ke.y,ke.z,ke.w),fe.copy(ke))}function ft(ke,We){let pe=f.get(We);pe===void 0&&(pe=new WeakMap,f.set(We,pe));let Ce=pe.get(ke);Ce===void 0&&(Ce=t.getUniformBlockIndex(We,ke.name),pe.set(ke,Ce))}function we(ke,We){const Ce=f.get(We).get(ke);d.get(We)!==Ce&&(t.uniformBlockBinding(We,Ce,ke.__bindingPointIndex),d.set(We,Ce))}function tt(){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),m={},B=null,W={},p={},x=new WeakMap,b=[],y=null,v=!1,S=null,N=null,C=null,T=null,k=null,E=null,D=null,A=new en(0,0,0),R=0,F=!1,O=null,H=null,j=null,G=null,$=null,ce.set(0,0,t.canvas.width,t.canvas.height),fe.set(0,0,t.canvas.width,t.canvas.height),l.reset(),c.reset(),u.reset()}return{buffers:{color:l,depth:c,stencil:u},enable:xe,disable:Pe,bindFramebuffer:Ue,drawBuffers:be,useProgram:it,setBlending:J,setMaterial:Q,setFlipSided:z,setCullFace:re,setLineWidth:Ee,setPolygonOffset:_e,setScissorTest:Te,activeTexture:V,bindTexture:L,unbindTexture:X,compressedTexImage2D:te,compressedTexImage3D:Me,texImage2D:ae,texImage3D:He,updateUBOMapping:ft,uniformBlockBinding:we,texStorage2D:Ze,texStorage3D:Ie,texSubImage2D:ie,texSubImage3D:De,compressedTexSubImage2D:Le,compressedTexSubImage3D:$e,scissor:Se,viewport:Be,reset:tt}}function U2e(t,e,n,r,i,s,o){const l=i.isWebGL2,c=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,f=i.maxSamples,m=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),x=new WeakMap;let b;const y=new WeakMap;let v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function S(V,L){return v?new OffscreenCanvas(V,L):sS("canvas")}function N(V,L,X,te){let Me=1;if((V.width>te||V.height>te)&&(Me=te/Math.max(V.width,V.height)),Me<1||L===!0)if(typeof HTMLImageElement<"u"&&V instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&V instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&V instanceof ImageBitmap){const ie=L?aS:Math.floor,De=ie(Me*V.width),Le=ie(Me*V.height);b===void 0&&(b=S(De,Le));const $e=X?S(De,Le):b;return $e.width=De,$e.height=Le,$e.getContext("2d").drawImage(V,0,0,De,Le),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+V.width+"x"+V.height+") to ("+De+"x"+Le+")."),$e}else return"data"in V&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+V.width+"x"+V.height+")."),V;return V}function C(V){return yP(V.width)&&yP(V.height)}function T(V){return l?!1:V.wrapS!==Cl||V.wrapT!==Cl||V.minFilter!==ka&&V.minFilter!==Wo}function k(V,L){return V.generateMipmaps&&L&&V.minFilter!==ka&&V.minFilter!==Wo}function E(V){t.generateMipmap(V)}function D(V,L,X,te,Me=!1){if(l===!1)return L;if(V!==null){if(t[V]!==void 0)return t[V];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+V+"'")}let ie=L;if(L===t.RED&&(X===t.FLOAT&&(ie=t.R32F),X===t.HALF_FLOAT&&(ie=t.R16F),X===t.UNSIGNED_BYTE&&(ie=t.R8)),L===t.RED_INTEGER&&(X===t.UNSIGNED_BYTE&&(ie=t.R8UI),X===t.UNSIGNED_SHORT&&(ie=t.R16UI),X===t.UNSIGNED_INT&&(ie=t.R32UI),X===t.BYTE&&(ie=t.R8I),X===t.SHORT&&(ie=t.R16I),X===t.INT&&(ie=t.R32I)),L===t.RG&&(X===t.FLOAT&&(ie=t.RG32F),X===t.HALF_FLOAT&&(ie=t.RG16F),X===t.UNSIGNED_BYTE&&(ie=t.RG8)),L===t.RGBA){const De=Me?nS:Er.getTransfer(te);X===t.FLOAT&&(ie=t.RGBA32F),X===t.HALF_FLOAT&&(ie=t.RGBA16F),X===t.UNSIGNED_BYTE&&(ie=De===$r?t.SRGB8_ALPHA8:t.RGBA8),X===t.UNSIGNED_SHORT_4_4_4_4&&(ie=t.RGBA4),X===t.UNSIGNED_SHORT_5_5_5_1&&(ie=t.RGB5_A1)}return(ie===t.R16F||ie===t.R32F||ie===t.RG16F||ie===t.RG32F||ie===t.RGBA16F||ie===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ie}function A(V,L,X){return k(V,X)===!0||V.isFramebufferTexture&&V.minFilter!==ka&&V.minFilter!==Wo?Math.log2(Math.max(L.width,L.height))+1:V.mipmaps!==void 0&&V.mipmaps.length>0?V.mipmaps.length:V.isCompressedTexture&&Array.isArray(V.image)?L.mipmaps.length:1}function R(V){return V===ka||V===o8||V===UT?t.NEAREST:t.LINEAR}function F(V){const L=V.target;L.removeEventListener("dispose",F),H(L),L.isVideoTexture&&x.delete(L)}function O(V){const L=V.target;L.removeEventListener("dispose",O),G(L)}function H(V){const L=r.get(V);if(L.__webglInit===void 0)return;const X=V.source,te=y.get(X);if(te){const Me=te[L.__cacheKey];Me.usedTimes--,Me.usedTimes===0&&j(V),Object.keys(te).length===0&&y.delete(X)}r.remove(V)}function j(V){const L=r.get(V);t.deleteTexture(L.__webglTexture);const X=V.source,te=y.get(X);delete te[L.__cacheKey],o.memory.textures--}function G(V){const L=V.texture,X=r.get(V),te=r.get(L);if(te.__webglTexture!==void 0&&(t.deleteTexture(te.__webglTexture),o.memory.textures--),V.depthTexture&&V.depthTexture.dispose(),V.isWebGLCubeRenderTarget)for(let Me=0;Me<6;Me++){if(Array.isArray(X.__webglFramebuffer[Me]))for(let ie=0;ie<X.__webglFramebuffer[Me].length;ie++)t.deleteFramebuffer(X.__webglFramebuffer[Me][ie]);else t.deleteFramebuffer(X.__webglFramebuffer[Me]);X.__webglDepthbuffer&&t.deleteRenderbuffer(X.__webglDepthbuffer[Me])}else{if(Array.isArray(X.__webglFramebuffer))for(let Me=0;Me<X.__webglFramebuffer.length;Me++)t.deleteFramebuffer(X.__webglFramebuffer[Me]);else t.deleteFramebuffer(X.__webglFramebuffer);if(X.__webglDepthbuffer&&t.deleteRenderbuffer(X.__webglDepthbuffer),X.__webglMultisampledFramebuffer&&t.deleteFramebuffer(X.__webglMultisampledFramebuffer),X.__webglColorRenderbuffer)for(let Me=0;Me<X.__webglColorRenderbuffer.length;Me++)X.__webglColorRenderbuffer[Me]&&t.deleteRenderbuffer(X.__webglColorRenderbuffer[Me]);X.__webglDepthRenderbuffer&&t.deleteRenderbuffer(X.__webglDepthRenderbuffer)}if(V.isWebGLMultipleRenderTargets)for(let Me=0,ie=L.length;Me<ie;Me++){const De=r.get(L[Me]);De.__webglTexture&&(t.deleteTexture(De.__webglTexture),o.memory.textures--),r.remove(L[Me])}r.remove(L),r.remove(V)}let $=0;function q(){$=0}function Y(){const V=$;return V>=c&&console.warn("THREE.WebGLTextures: Trying to use "+V+" texture units while this GPU supports only "+c),$+=1,V}function Z(V){const L=[];return L.push(V.wrapS),L.push(V.wrapT),L.push(V.wrapR||0),L.push(V.magFilter),L.push(V.minFilter),L.push(V.anisotropy),L.push(V.internalFormat),L.push(V.format),L.push(V.type),L.push(V.generateMipmaps),L.push(V.premultiplyAlpha),L.push(V.flipY),L.push(V.unpackAlignment),L.push(V.colorSpace),L.join()}function oe(V,L){const X=r.get(V);if(V.isVideoTexture&&_e(V),V.isRenderTargetTexture===!1&&V.version>0&&X.__version!==V.version){const te=V.image;if(te===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(te.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{xe(X,V,L);return}}n.bindTexture(t.TEXTURE_2D,X.__webglTexture,t.TEXTURE0+L)}function B(V,L){const X=r.get(V);if(V.version>0&&X.__version!==V.version){xe(X,V,L);return}n.bindTexture(t.TEXTURE_2D_ARRAY,X.__webglTexture,t.TEXTURE0+L)}function W(V,L){const X=r.get(V);if(V.version>0&&X.__version!==V.version){xe(X,V,L);return}n.bindTexture(t.TEXTURE_3D,X.__webglTexture,t.TEXTURE0+L)}function se(V,L){const X=r.get(V);if(V.version>0&&X.__version!==V.version){Pe(X,V,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,X.__webglTexture,t.TEXTURE0+L)}const ne={[pP]:t.REPEAT,[Cl]:t.CLAMP_TO_EDGE,[gP]:t.MIRRORED_REPEAT},ce={[ka]:t.NEAREST,[o8]:t.NEAREST_MIPMAP_NEAREST,[UT]:t.NEAREST_MIPMAP_LINEAR,[Wo]:t.LINEAR,[cve]:t.LINEAR_MIPMAP_NEAREST,[ey]:t.LINEAR_MIPMAP_LINEAR},fe={[_ve]:t.NEVER,[Cve]:t.ALWAYS,[wve]:t.LESS,[UK]:t.LEQUAL,[Sve]:t.EQUAL,[Eve]:t.GEQUAL,[Nve]:t.GREATER,[Mve]:t.NOTEQUAL};function ye(V,L,X){if(X?(t.texParameteri(V,t.TEXTURE_WRAP_S,ne[L.wrapS]),t.texParameteri(V,t.TEXTURE_WRAP_T,ne[L.wrapT]),(V===t.TEXTURE_3D||V===t.TEXTURE_2D_ARRAY)&&t.texParameteri(V,t.TEXTURE_WRAP_R,ne[L.wrapR]),t.texParameteri(V,t.TEXTURE_MAG_FILTER,ce[L.magFilter]),t.texParameteri(V,t.TEXTURE_MIN_FILTER,ce[L.minFilter])):(t.texParameteri(V,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(V,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(V===t.TEXTURE_3D||V===t.TEXTURE_2D_ARRAY)&&t.texParameteri(V,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(L.wrapS!==Cl||L.wrapT!==Cl)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(V,t.TEXTURE_MAG_FILTER,R(L.magFilter)),t.texParameteri(V,t.TEXTURE_MIN_FILTER,R(L.minFilter)),L.minFilter!==ka&&L.minFilter!==Wo&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),L.compareFunction&&(t.texParameteri(V,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(V,t.TEXTURE_COMPARE_FUNC,fe[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const te=e.get("EXT_texture_filter_anisotropic");if(L.magFilter===ka||L.minFilter!==UT&&L.minFilter!==ey||L.type===yu&&e.has("OES_texture_float_linear")===!1||l===!1&&L.type===ty&&e.has("OES_texture_half_float_linear")===!1)return;(L.anisotropy>1||r.get(L).__currentAnisotropy)&&(t.texParameterf(V,te.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy)}}function ge(V,L){let X=!1;V.__webglInit===void 0&&(V.__webglInit=!0,L.addEventListener("dispose",F));const te=L.source;let Me=y.get(te);Me===void 0&&(Me={},y.set(te,Me));const ie=Z(L);if(ie!==V.__cacheKey){Me[ie]===void 0&&(Me[ie]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,X=!0),Me[ie].usedTimes++;const De=Me[V.__cacheKey];De!==void 0&&(Me[V.__cacheKey].usedTimes--,De.usedTimes===0&&j(L)),V.__cacheKey=ie,V.__webglTexture=Me[ie].texture}return X}function xe(V,L,X){let te=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(te=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(te=t.TEXTURE_3D);const Me=ge(V,L),ie=L.source;n.bindTexture(te,V.__webglTexture,t.TEXTURE0+X);const De=r.get(ie);if(ie.version!==De.__version||Me===!0){n.activeTexture(t.TEXTURE0+X);const Le=Er.getPrimaries(Er.workingColorSpace),$e=L.colorSpace===Xo?null:Er.getPrimaries(L.colorSpace),Ze=L.colorSpace===Xo||Le===$e?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ze);const Ie=T(L)&&C(L.image)===!1;let ae=N(L.image,Ie,!1,d);ae=Te(L,ae);const He=C(ae)||l,Se=s.convert(L.format,L.colorSpace);let Be=s.convert(L.type),ft=D(L.internalFormat,Se,Be,L.colorSpace,L.isVideoTexture);ye(te,L,He);let we;const tt=L.mipmaps,ke=l&&L.isVideoTexture!==!0&&ft!==LK,We=De.__version===void 0||Me===!0,pe=A(L,ae,He);if(L.isDepthTexture)ft=t.DEPTH_COMPONENT,l?L.type===yu?ft=t.DEPTH_COMPONENT32F:L.type===Qd?ft=t.DEPTH_COMPONENT24:L.type===Bf?ft=t.DEPTH24_STENCIL8:ft=t.DEPTH_COMPONENT16:L.type===yu&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),L.format===$f&&ft===t.DEPTH_COMPONENT&&L.type!==i4&&L.type!==Qd&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),L.type=Qd,Be=s.convert(L.type)),L.format===Yg&&ft===t.DEPTH_COMPONENT&&(ft=t.DEPTH_STENCIL,L.type!==Bf&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),L.type=Bf,Be=s.convert(L.type))),We&&(ke?n.texStorage2D(t.TEXTURE_2D,1,ft,ae.width,ae.height):n.texImage2D(t.TEXTURE_2D,0,ft,ae.width,ae.height,0,Se,Be,null));else if(L.isDataTexture)if(tt.length>0&&He){ke&&We&&n.texStorage2D(t.TEXTURE_2D,pe,ft,tt[0].width,tt[0].height);for(let Ce=0,de=tt.length;Ce<de;Ce++)we=tt[Ce],ke?n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,we.width,we.height,Se,Be,we.data):n.texImage2D(t.TEXTURE_2D,Ce,ft,we.width,we.height,0,Se,Be,we.data);L.generateMipmaps=!1}else ke?(We&&n.texStorage2D(t.TEXTURE_2D,pe,ft,ae.width,ae.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,ae.width,ae.height,Se,Be,ae.data)):n.texImage2D(t.TEXTURE_2D,0,ft,ae.width,ae.height,0,Se,Be,ae.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){ke&&We&&n.texStorage3D(t.TEXTURE_2D_ARRAY,pe,ft,tt[0].width,tt[0].height,ae.depth);for(let Ce=0,de=tt.length;Ce<de;Ce++)we=tt[Ce],L.format!==Ko?Se!==null?ke?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ce,0,0,0,we.width,we.height,ae.depth,Se,we.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Ce,ft,we.width,we.height,ae.depth,0,we.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ke?n.texSubImage3D(t.TEXTURE_2D_ARRAY,Ce,0,0,0,we.width,we.height,ae.depth,Se,Be,we.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Ce,ft,we.width,we.height,ae.depth,0,Se,Be,we.data)}else{ke&&We&&n.texStorage2D(t.TEXTURE_2D,pe,ft,tt[0].width,tt[0].height);for(let Ce=0,de=tt.length;Ce<de;Ce++)we=tt[Ce],L.format!==Ko?Se!==null?ke?n.compressedTexSubImage2D(t.TEXTURE_2D,Ce,0,0,we.width,we.height,Se,we.data):n.compressedTexImage2D(t.TEXTURE_2D,Ce,ft,we.width,we.height,0,we.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ke?n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,we.width,we.height,Se,Be,we.data):n.texImage2D(t.TEXTURE_2D,Ce,ft,we.width,we.height,0,Se,Be,we.data)}else if(L.isDataArrayTexture)ke?(We&&n.texStorage3D(t.TEXTURE_2D_ARRAY,pe,ft,ae.width,ae.height,ae.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,ae.width,ae.height,ae.depth,Se,Be,ae.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,ft,ae.width,ae.height,ae.depth,0,Se,Be,ae.data);else if(L.isData3DTexture)ke?(We&&n.texStorage3D(t.TEXTURE_3D,pe,ft,ae.width,ae.height,ae.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,ae.width,ae.height,ae.depth,Se,Be,ae.data)):n.texImage3D(t.TEXTURE_3D,0,ft,ae.width,ae.height,ae.depth,0,Se,Be,ae.data);else if(L.isFramebufferTexture){if(We)if(ke)n.texStorage2D(t.TEXTURE_2D,pe,ft,ae.width,ae.height);else{let Ce=ae.width,de=ae.height;for(let Ve=0;Ve<pe;Ve++)n.texImage2D(t.TEXTURE_2D,Ve,ft,Ce,de,0,Se,Be,null),Ce>>=1,de>>=1}}else if(tt.length>0&&He){ke&&We&&n.texStorage2D(t.TEXTURE_2D,pe,ft,tt[0].width,tt[0].height);for(let Ce=0,de=tt.length;Ce<de;Ce++)we=tt[Ce],ke?n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,Se,Be,we):n.texImage2D(t.TEXTURE_2D,Ce,ft,Se,Be,we);L.generateMipmaps=!1}else ke?(We&&n.texStorage2D(t.TEXTURE_2D,pe,ft,ae.width,ae.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,Se,Be,ae)):n.texImage2D(t.TEXTURE_2D,0,ft,Se,Be,ae);k(L,He)&&E(te),De.__version=ie.version,L.onUpdate&&L.onUpdate(L)}V.__version=L.version}function Pe(V,L,X){if(L.image.length!==6)return;const te=ge(V,L),Me=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,V.__webglTexture,t.TEXTURE0+X);const ie=r.get(Me);if(Me.version!==ie.__version||te===!0){n.activeTexture(t.TEXTURE0+X);const De=Er.getPrimaries(Er.workingColorSpace),Le=L.colorSpace===Xo?null:Er.getPrimaries(L.colorSpace),$e=L.colorSpace===Xo||De===Le?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,$e);const Ze=L.isCompressedTexture||L.image[0].isCompressedTexture,Ie=L.image[0]&&L.image[0].isDataTexture,ae=[];for(let Ce=0;Ce<6;Ce++)!Ze&&!Ie?ae[Ce]=N(L.image[Ce],!1,!0,u):ae[Ce]=Ie?L.image[Ce].image:L.image[Ce],ae[Ce]=Te(L,ae[Ce]);const He=ae[0],Se=C(He)||l,Be=s.convert(L.format,L.colorSpace),ft=s.convert(L.type),we=D(L.internalFormat,Be,ft,L.colorSpace),tt=l&&L.isVideoTexture!==!0,ke=ie.__version===void 0||te===!0;let We=A(L,He,Se);ye(t.TEXTURE_CUBE_MAP,L,Se);let pe;if(Ze){tt&&ke&&n.texStorage2D(t.TEXTURE_CUBE_MAP,We,we,He.width,He.height);for(let Ce=0;Ce<6;Ce++){pe=ae[Ce].mipmaps;for(let de=0;de<pe.length;de++){const Ve=pe[de];L.format!==Ko?Be!==null?tt?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,de,0,0,Ve.width,Ve.height,Be,Ve.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,de,we,Ve.width,Ve.height,0,Ve.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):tt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,de,0,0,Ve.width,Ve.height,Be,ft,Ve.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,de,we,Ve.width,Ve.height,0,Be,ft,Ve.data)}}}else{pe=L.mipmaps,tt&&ke&&(pe.length>0&&We++,n.texStorage2D(t.TEXTURE_CUBE_MAP,We,we,ae[0].width,ae[0].height));for(let Ce=0;Ce<6;Ce++)if(Ie){tt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,0,0,ae[Ce].width,ae[Ce].height,Be,ft,ae[Ce].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,we,ae[Ce].width,ae[Ce].height,0,Be,ft,ae[Ce].data);for(let de=0;de<pe.length;de++){const yt=pe[de].image[Ce].image;tt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,de+1,0,0,yt.width,yt.height,Be,ft,yt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,de+1,we,yt.width,yt.height,0,Be,ft,yt.data)}}else{tt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,0,0,Be,ft,ae[Ce]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,we,Be,ft,ae[Ce]);for(let de=0;de<pe.length;de++){const Ve=pe[de];tt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,de+1,0,0,Be,ft,Ve.image[Ce]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,de+1,we,Be,ft,Ve.image[Ce])}}}k(L,Se)&&E(t.TEXTURE_CUBE_MAP),ie.__version=Me.version,L.onUpdate&&L.onUpdate(L)}V.__version=L.version}function Ue(V,L,X,te,Me,ie){const De=s.convert(X.format,X.colorSpace),Le=s.convert(X.type),$e=D(X.internalFormat,De,Le,X.colorSpace);if(!r.get(L).__hasExternalTextures){const Ie=Math.max(1,L.width>>ie),ae=Math.max(1,L.height>>ie);Me===t.TEXTURE_3D||Me===t.TEXTURE_2D_ARRAY?n.texImage3D(Me,ie,$e,Ie,ae,L.depth,0,De,Le,null):n.texImage2D(Me,ie,$e,Ie,ae,0,De,Le,null)}n.bindFramebuffer(t.FRAMEBUFFER,V),Ee(L)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,te,Me,r.get(X).__webglTexture,0,re(L)):(Me===t.TEXTURE_2D||Me>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&Me<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,te,Me,r.get(X).__webglTexture,ie),n.bindFramebuffer(t.FRAMEBUFFER,null)}function be(V,L,X){if(t.bindRenderbuffer(t.RENDERBUFFER,V),L.depthBuffer&&!L.stencilBuffer){let te=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(X||Ee(L)){const Me=L.depthTexture;Me&&Me.isDepthTexture&&(Me.type===yu?te=t.DEPTH_COMPONENT32F:Me.type===Qd&&(te=t.DEPTH_COMPONENT24));const ie=re(L);Ee(L)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ie,te,L.width,L.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,ie,te,L.width,L.height)}else t.renderbufferStorage(t.RENDERBUFFER,te,L.width,L.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,V)}else if(L.depthBuffer&&L.stencilBuffer){const te=re(L);X&&Ee(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,te,t.DEPTH24_STENCIL8,L.width,L.height):Ee(L)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,te,t.DEPTH24_STENCIL8,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,V)}else{const te=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let Me=0;Me<te.length;Me++){const ie=te[Me],De=s.convert(ie.format,ie.colorSpace),Le=s.convert(ie.type),$e=D(ie.internalFormat,De,Le,ie.colorSpace),Ze=re(L);X&&Ee(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ze,$e,L.width,L.height):Ee(L)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ze,$e,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,$e,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function it(V,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,V),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(L.depthTexture).__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),oe(L.depthTexture,0);const te=r.get(L.depthTexture).__webglTexture,Me=re(L);if(L.depthTexture.format===$f)Ee(L)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,te,0,Me):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,te,0);else if(L.depthTexture.format===Yg)Ee(L)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,te,0,Me):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,te,0);else throw new Error("Unknown depthTexture format")}function U(V){const L=r.get(V),X=V.isWebGLCubeRenderTarget===!0;if(V.depthTexture&&!L.__autoAllocateDepthBuffer){if(X)throw new Error("target.depthTexture not supported in Cube render targets");it(L.__webglFramebuffer,V)}else if(X){L.__webglDepthbuffer=[];for(let te=0;te<6;te++)n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[te]),L.__webglDepthbuffer[te]=t.createRenderbuffer(),be(L.__webglDepthbuffer[te],V,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer=t.createRenderbuffer(),be(L.__webglDepthbuffer,V,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function K(V,L,X){const te=r.get(V);L!==void 0&&Ue(te.__webglFramebuffer,V,V.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),X!==void 0&&U(V)}function J(V){const L=V.texture,X=r.get(V),te=r.get(L);V.addEventListener("dispose",O),V.isWebGLMultipleRenderTargets!==!0&&(te.__webglTexture===void 0&&(te.__webglTexture=t.createTexture()),te.__version=L.version,o.memory.textures++);const Me=V.isWebGLCubeRenderTarget===!0,ie=V.isWebGLMultipleRenderTargets===!0,De=C(V)||l;if(Me){X.__webglFramebuffer=[];for(let Le=0;Le<6;Le++)if(l&&L.mipmaps&&L.mipmaps.length>0){X.__webglFramebuffer[Le]=[];for(let $e=0;$e<L.mipmaps.length;$e++)X.__webglFramebuffer[Le][$e]=t.createFramebuffer()}else X.__webglFramebuffer[Le]=t.createFramebuffer()}else{if(l&&L.mipmaps&&L.mipmaps.length>0){X.__webglFramebuffer=[];for(let Le=0;Le<L.mipmaps.length;Le++)X.__webglFramebuffer[Le]=t.createFramebuffer()}else X.__webglFramebuffer=t.createFramebuffer();if(ie)if(i.drawBuffers){const Le=V.texture;for(let $e=0,Ze=Le.length;$e<Ze;$e++){const Ie=r.get(Le[$e]);Ie.__webglTexture===void 0&&(Ie.__webglTexture=t.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(l&&V.samples>0&&Ee(V)===!1){const Le=ie?L:[L];X.__webglMultisampledFramebuffer=t.createFramebuffer(),X.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,X.__webglMultisampledFramebuffer);for(let $e=0;$e<Le.length;$e++){const Ze=Le[$e];X.__webglColorRenderbuffer[$e]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,X.__webglColorRenderbuffer[$e]);const Ie=s.convert(Ze.format,Ze.colorSpace),ae=s.convert(Ze.type),He=D(Ze.internalFormat,Ie,ae,Ze.colorSpace,V.isXRRenderTarget===!0),Se=re(V);t.renderbufferStorageMultisample(t.RENDERBUFFER,Se,He,V.width,V.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+$e,t.RENDERBUFFER,X.__webglColorRenderbuffer[$e])}t.bindRenderbuffer(t.RENDERBUFFER,null),V.depthBuffer&&(X.__webglDepthRenderbuffer=t.createRenderbuffer(),be(X.__webglDepthRenderbuffer,V,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(Me){n.bindTexture(t.TEXTURE_CUBE_MAP,te.__webglTexture),ye(t.TEXTURE_CUBE_MAP,L,De);for(let Le=0;Le<6;Le++)if(l&&L.mipmaps&&L.mipmaps.length>0)for(let $e=0;$e<L.mipmaps.length;$e++)Ue(X.__webglFramebuffer[Le][$e],V,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Le,$e);else Ue(X.__webglFramebuffer[Le],V,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Le,0);k(L,De)&&E(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ie){const Le=V.texture;for(let $e=0,Ze=Le.length;$e<Ze;$e++){const Ie=Le[$e],ae=r.get(Ie);n.bindTexture(t.TEXTURE_2D,ae.__webglTexture),ye(t.TEXTURE_2D,Ie,De),Ue(X.__webglFramebuffer,V,Ie,t.COLOR_ATTACHMENT0+$e,t.TEXTURE_2D,0),k(Ie,De)&&E(t.TEXTURE_2D)}n.unbindTexture()}else{let Le=t.TEXTURE_2D;if((V.isWebGL3DRenderTarget||V.isWebGLArrayRenderTarget)&&(l?Le=V.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Le,te.__webglTexture),ye(Le,L,De),l&&L.mipmaps&&L.mipmaps.length>0)for(let $e=0;$e<L.mipmaps.length;$e++)Ue(X.__webglFramebuffer[$e],V,L,t.COLOR_ATTACHMENT0,Le,$e);else Ue(X.__webglFramebuffer,V,L,t.COLOR_ATTACHMENT0,Le,0);k(L,De)&&E(Le),n.unbindTexture()}V.depthBuffer&&U(V)}function Q(V){const L=C(V)||l,X=V.isWebGLMultipleRenderTargets===!0?V.texture:[V.texture];for(let te=0,Me=X.length;te<Me;te++){const ie=X[te];if(k(ie,L)){const De=V.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Le=r.get(ie).__webglTexture;n.bindTexture(De,Le),E(De),n.unbindTexture()}}}function z(V){if(l&&V.samples>0&&Ee(V)===!1){const L=V.isWebGLMultipleRenderTargets?V.texture:[V.texture],X=V.width,te=V.height;let Me=t.COLOR_BUFFER_BIT;const ie=[],De=V.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Le=r.get(V),$e=V.isWebGLMultipleRenderTargets===!0;if($e)for(let Ze=0;Ze<L.length;Ze++)n.bindFramebuffer(t.FRAMEBUFFER,Le.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ze,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Le.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ze,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Le.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Le.__webglFramebuffer);for(let Ze=0;Ze<L.length;Ze++){ie.push(t.COLOR_ATTACHMENT0+Ze),V.depthBuffer&&ie.push(De);const Ie=Le.__ignoreDepthValues!==void 0?Le.__ignoreDepthValues:!1;if(Ie===!1&&(V.depthBuffer&&(Me|=t.DEPTH_BUFFER_BIT),V.stencilBuffer&&(Me|=t.STENCIL_BUFFER_BIT)),$e&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Le.__webglColorRenderbuffer[Ze]),Ie===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[De]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[De])),$e){const ae=r.get(L[Ze]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,ae,0)}t.blitFramebuffer(0,0,X,te,0,0,X,te,Me,t.NEAREST),p&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,ie)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),$e)for(let Ze=0;Ze<L.length;Ze++){n.bindFramebuffer(t.FRAMEBUFFER,Le.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ze,t.RENDERBUFFER,Le.__webglColorRenderbuffer[Ze]);const Ie=r.get(L[Ze]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Le.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ze,t.TEXTURE_2D,Ie,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Le.__webglMultisampledFramebuffer)}}function re(V){return Math.min(f,V.samples)}function Ee(V){const L=r.get(V);return l&&V.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function _e(V){const L=o.render.frame;x.get(V)!==L&&(x.set(V,L),V.update())}function Te(V,L){const X=V.colorSpace,te=V.format,Me=V.type;return V.isCompressedTexture===!0||V.isVideoTexture===!0||V.format===bP||X!==Lu&&X!==Xo&&(Er.getTransfer(X)===$r?l===!1?e.has("EXT_sRGB")===!0&&te===Ko?(V.format=bP,V.minFilter=Wo,V.generateMipmaps=!1):L=$K.sRGBToLinear(L):(te!==Ko||Me!==uh)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",X)),L}this.allocateTextureUnit=Y,this.resetTextureUnits=q,this.setTexture2D=oe,this.setTexture2DArray=B,this.setTexture3D=W,this.setTextureCube=se,this.rebindTextures=K,this.setupRenderTarget=J,this.updateRenderTargetMipmap=Q,this.updateMultisampleRenderTarget=z,this.setupDepthRenderbuffer=U,this.setupFrameBufferTexture=Ue,this.useMultisampledRTT=Ee}function z2e(t,e,n){const r=n.isWebGL2;function i(s,o=Xo){let l;const c=Er.getTransfer(o);if(s===uh)return t.UNSIGNED_BYTE;if(s===jK)return t.UNSIGNED_SHORT_4_4_4_4;if(s===PK)return t.UNSIGNED_SHORT_5_5_5_1;if(s===uve)return t.BYTE;if(s===dve)return t.SHORT;if(s===i4)return t.UNSIGNED_SHORT;if(s===kK)return t.INT;if(s===Qd)return t.UNSIGNED_INT;if(s===yu)return t.FLOAT;if(s===ty)return r?t.HALF_FLOAT:(l=e.get("OES_texture_half_float"),l!==null?l.HALF_FLOAT_OES:null);if(s===hve)return t.ALPHA;if(s===Ko)return t.RGBA;if(s===fve)return t.LUMINANCE;if(s===mve)return t.LUMINANCE_ALPHA;if(s===$f)return t.DEPTH_COMPONENT;if(s===Yg)return t.DEPTH_STENCIL;if(s===bP)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(s===pve)return t.RED;if(s===RK)return t.RED_INTEGER;if(s===gve)return t.RG;if(s===DK)return t.RG_INTEGER;if(s===OK)return t.RGBA_INTEGER;if(s===zT||s===BT||s===$T||s===HT)if(c===$r)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(s===zT)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===BT)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===$T)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===HT)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(s===zT)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===BT)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===$T)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===HT)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===l8||s===c8||s===u8||s===d8)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(s===l8)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===c8)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===u8)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===d8)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===LK)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===h8||s===f8)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(s===h8)return c===$r?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(s===f8)return c===$r?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===m8||s===p8||s===g8||s===x8||s===b8||s===y8||s===v8||s===_8||s===w8||s===S8||s===N8||s===M8||s===E8||s===C8)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(s===m8)return c===$r?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===p8)return c===$r?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===g8)return c===$r?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===x8)return c===$r?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===b8)return c===$r?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===y8)return c===$r?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===v8)return c===$r?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===_8)return c===$r?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===w8)return c===$r?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===S8)return c===$r?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===N8)return c===$r?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===M8)return c===$r?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===E8)return c===$r?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===C8)return c===$r?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===VT||s===T8||s===A8)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(s===VT)return c===$r?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===T8)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===A8)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===xve||s===k8||s===j8||s===P8)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(s===VT)return l.COMPRESSED_RED_RGTC1_EXT;if(s===k8)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===j8)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===P8)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Bf?r?t.UNSIGNED_INT_24_8:(l=e.get("WEBGL_depth_texture"),l!==null?l.UNSIGNED_INT_24_8_WEBGL:null):t[s]!==void 0?t[s]:null}return{convert:i}}class B2e extends lo{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class o0 extends ys{constructor(){super(),this.isGroup=!0,this.type="Group"}}const $2e={type:"move"};class fA{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new o0,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 o0,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new qe,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new qe),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new o0,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new qe,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new qe),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,s=null,o=null;const l=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){o=!0;for(const b of e.hand.values()){const y=n.getJointPose(b,r),v=this._getHandJoint(u,b);y!==null&&(v.matrix.fromArray(y.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=y.radius),v.visible=y!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],m=d.position.distanceTo(f.position),p=.02,x=.005;u.inputState.pinching&&m>p+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&m<=p-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=n.getPose(e.gripSpace,r),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent($2e)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=s!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new o0;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class H2e extends Cm{constructor(e,n){super();const r=this;let i=null,s=1,o=null,l="local-floor",c=1,u=null,d=null,f=null,m=null,p=null,x=null;const b=n.getContextAttributes();let y=null,v=null;const S=[],N=[],C=new xn;let T=null;const k=new lo;k.layers.enable(1),k.viewport=new Ar;const E=new lo;E.layers.enable(2),E.viewport=new Ar;const D=[k,E],A=new B2e;A.layers.enable(1),A.layers.enable(2);let R=null,F=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(se){let ne=S[se];return ne===void 0&&(ne=new fA,S[se]=ne),ne.getTargetRaySpace()},this.getControllerGrip=function(se){let ne=S[se];return ne===void 0&&(ne=new fA,S[se]=ne),ne.getGripSpace()},this.getHand=function(se){let ne=S[se];return ne===void 0&&(ne=new fA,S[se]=ne),ne.getHandSpace()};function O(se){const ne=N.indexOf(se.inputSource);if(ne===-1)return;const ce=S[ne];ce!==void 0&&(ce.update(se.inputSource,se.frame,u||o),ce.dispatchEvent({type:se.type,data:se.inputSource}))}function H(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",H),i.removeEventListener("inputsourceschange",j);for(let se=0;se<S.length;se++){const ne=N[se];ne!==null&&(N[se]=null,S[se].disconnect(ne))}R=null,F=null,e.setRenderTarget(y),p=null,m=null,f=null,i=null,v=null,W.stop(),r.isPresenting=!1,e.setPixelRatio(T),e.setSize(C.width,C.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(se){s=se,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(se){l=se,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(se){u=se},this.getBaseLayer=function(){return m!==null?m:p},this.getBinding=function(){return f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(se){if(i=se,i!==null){if(y=e.getRenderTarget(),i.addEventListener("select",O),i.addEventListener("selectstart",O),i.addEventListener("selectend",O),i.addEventListener("squeeze",O),i.addEventListener("squeezestart",O),i.addEventListener("squeezeend",O),i.addEventListener("end",H),i.addEventListener("inputsourceschange",j),b.xrCompatible!==!0&&await n.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(C),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ne={antialias:i.renderState.layers===void 0?b.antialias:!0,alpha:!0,depth:b.depth,stencil:b.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(i,n,ne),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),v=new dm(p.framebufferWidth,p.framebufferHeight,{format:Ko,type:uh,colorSpace:e.outputColorSpace,stencilBuffer:b.stencil})}else{let ne=null,ce=null,fe=null;b.depth&&(fe=b.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ne=b.stencil?Yg:$f,ce=b.stencil?Bf:Qd);const ye={colorFormat:n.RGBA8,depthFormat:fe,scaleFactor:s};f=new XRWebGLBinding(i,n),m=f.createProjectionLayer(ye),i.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),v=new dm(m.textureWidth,m.textureHeight,{format:Ko,type:uh,depthTexture:new eX(m.textureWidth,m.textureHeight,ce,void 0,void 0,void 0,void 0,void 0,void 0,ne),stencilBuffer:b.stencil,colorSpace:e.outputColorSpace,samples:b.antialias?4:0});const ge=e.properties.get(v);ge.__ignoreDepthValues=m.ignoreDepthValues}v.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),W.setContext(i),W.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function j(se){for(let ne=0;ne<se.removed.length;ne++){const ce=se.removed[ne],fe=N.indexOf(ce);fe>=0&&(N[fe]=null,S[fe].disconnect(ce))}for(let ne=0;ne<se.added.length;ne++){const ce=se.added[ne];let fe=N.indexOf(ce);if(fe===-1){for(let ge=0;ge<S.length;ge++)if(ge>=N.length){N.push(ce),fe=ge;break}else if(N[ge]===null){N[ge]=ce,fe=ge;break}if(fe===-1)break}const ye=S[fe];ye&&ye.connect(ce)}}const G=new qe,$=new qe;function q(se,ne,ce){G.setFromMatrixPosition(ne.matrixWorld),$.setFromMatrixPosition(ce.matrixWorld);const fe=G.distanceTo($),ye=ne.projectionMatrix.elements,ge=ce.projectionMatrix.elements,xe=ye[14]/(ye[10]-1),Pe=ye[14]/(ye[10]+1),Ue=(ye[9]+1)/ye[5],be=(ye[9]-1)/ye[5],it=(ye[8]-1)/ye[0],U=(ge[8]+1)/ge[0],K=xe*it,J=xe*U,Q=fe/(-it+U),z=Q*-it;ne.matrixWorld.decompose(se.position,se.quaternion,se.scale),se.translateX(z),se.translateZ(Q),se.matrixWorld.compose(se.position,se.quaternion,se.scale),se.matrixWorldInverse.copy(se.matrixWorld).invert();const re=xe+Q,Ee=Pe+Q,_e=K-z,Te=J+(fe-z),V=Ue*Pe/Ee*re,L=be*Pe/Ee*re;se.projectionMatrix.makePerspective(_e,Te,V,L,re,Ee),se.projectionMatrixInverse.copy(se.projectionMatrix).invert()}function Y(se,ne){ne===null?se.matrixWorld.copy(se.matrix):se.matrixWorld.multiplyMatrices(ne.matrixWorld,se.matrix),se.matrixWorldInverse.copy(se.matrixWorld).invert()}this.updateCamera=function(se){if(i===null)return;A.near=E.near=k.near=se.near,A.far=E.far=k.far=se.far,(R!==A.near||F!==A.far)&&(i.updateRenderState({depthNear:A.near,depthFar:A.far}),R=A.near,F=A.far);const ne=se.parent,ce=A.cameras;Y(A,ne);for(let fe=0;fe<ce.length;fe++)Y(ce[fe],ne);ce.length===2?q(A,k,E):A.projectionMatrix.copy(k.projectionMatrix),Z(se,A,ne)};function Z(se,ne,ce){ce===null?se.matrix.copy(ne.matrixWorld):(se.matrix.copy(ce.matrixWorld),se.matrix.invert(),se.matrix.multiply(ne.matrixWorld)),se.matrix.decompose(se.position,se.quaternion,se.scale),se.updateMatrixWorld(!0),se.projectionMatrix.copy(ne.projectionMatrix),se.projectionMatrixInverse.copy(ne.projectionMatrixInverse),se.isPerspectiveCamera&&(se.fov=ry*2*Math.atan(1/se.projectionMatrix.elements[5]),se.zoom=1)}this.getCamera=function(){return A},this.getFoveation=function(){if(!(m===null&&p===null))return c},this.setFoveation=function(se){c=se,m!==null&&(m.fixedFoveation=se),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=se)};let oe=null;function B(se,ne){if(d=ne.getViewerPose(u||o),x=ne,d!==null){const ce=d.views;p!==null&&(e.setRenderTargetFramebuffer(v,p.framebuffer),e.setRenderTarget(v));let fe=!1;ce.length!==A.cameras.length&&(A.cameras.length=0,fe=!0);for(let ye=0;ye<ce.length;ye++){const ge=ce[ye];let xe=null;if(p!==null)xe=p.getViewport(ge);else{const Ue=f.getViewSubImage(m,ge);xe=Ue.viewport,ye===0&&(e.setRenderTargetTextures(v,Ue.colorTexture,m.ignoreDepthValues?void 0:Ue.depthStencilTexture),e.setRenderTarget(v))}let Pe=D[ye];Pe===void 0&&(Pe=new lo,Pe.layers.enable(ye),Pe.viewport=new Ar,D[ye]=Pe),Pe.matrix.fromArray(ge.transform.matrix),Pe.matrix.decompose(Pe.position,Pe.quaternion,Pe.scale),Pe.projectionMatrix.fromArray(ge.projectionMatrix),Pe.projectionMatrixInverse.copy(Pe.projectionMatrix).invert(),Pe.viewport.set(xe.x,xe.y,xe.width,xe.height),ye===0&&(A.matrix.copy(Pe.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),fe===!0&&A.cameras.push(Pe)}}for(let ce=0;ce<S.length;ce++){const fe=N[ce],ye=S[ce];fe!==null&&ye!==void 0&&ye.update(fe,ne,u||o)}oe&&oe(se,ne),ne.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ne}),x=null}const W=new JK;W.setAnimationLoop(B),this.setAnimationLoop=function(se){oe=se},this.dispose=function(){}}}function V2e(t,e){function n(y,v){y.matrixAutoUpdate===!0&&y.updateMatrix(),v.value.copy(y.matrix)}function r(y,v){v.color.getRGB(y.fogColor.value,YK(t)),v.isFog?(y.fogNear.value=v.near,y.fogFar.value=v.far):v.isFogExp2&&(y.fogDensity.value=v.density)}function i(y,v,S,N,C){v.isMeshBasicMaterial||v.isMeshLambertMaterial?s(y,v):v.isMeshToonMaterial?(s(y,v),f(y,v)):v.isMeshPhongMaterial?(s(y,v),d(y,v)):v.isMeshStandardMaterial?(s(y,v),m(y,v),v.isMeshPhysicalMaterial&&p(y,v,C)):v.isMeshMatcapMaterial?(s(y,v),x(y,v)):v.isMeshDepthMaterial?s(y,v):v.isMeshDistanceMaterial?(s(y,v),b(y,v)):v.isMeshNormalMaterial?s(y,v):v.isLineBasicMaterial?(o(y,v),v.isLineDashedMaterial&&l(y,v)):v.isPointsMaterial?c(y,v,S,N):v.isSpriteMaterial?u(y,v):v.isShadowMaterial?(y.color.value.copy(v.color),y.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function s(y,v){y.opacity.value=v.opacity,v.color&&y.diffuse.value.copy(v.color),v.emissive&&y.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(y.map.value=v.map,n(v.map,y.mapTransform)),v.alphaMap&&(y.alphaMap.value=v.alphaMap,n(v.alphaMap,y.alphaMapTransform)),v.bumpMap&&(y.bumpMap.value=v.bumpMap,n(v.bumpMap,y.bumpMapTransform),y.bumpScale.value=v.bumpScale,v.side===Bs&&(y.bumpScale.value*=-1)),v.normalMap&&(y.normalMap.value=v.normalMap,n(v.normalMap,y.normalMapTransform),y.normalScale.value.copy(v.normalScale),v.side===Bs&&y.normalScale.value.negate()),v.displacementMap&&(y.displacementMap.value=v.displacementMap,n(v.displacementMap,y.displacementMapTransform),y.displacementScale.value=v.displacementScale,y.displacementBias.value=v.displacementBias),v.emissiveMap&&(y.emissiveMap.value=v.emissiveMap,n(v.emissiveMap,y.emissiveMapTransform)),v.specularMap&&(y.specularMap.value=v.specularMap,n(v.specularMap,y.specularMapTransform)),v.alphaTest>0&&(y.alphaTest.value=v.alphaTest);const S=e.get(v).envMap;if(S&&(y.envMap.value=S,y.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,y.reflectivity.value=v.reflectivity,y.ior.value=v.ior,y.refractionRatio.value=v.refractionRatio),v.lightMap){y.lightMap.value=v.lightMap;const N=t._useLegacyLights===!0?Math.PI:1;y.lightMapIntensity.value=v.lightMapIntensity*N,n(v.lightMap,y.lightMapTransform)}v.aoMap&&(y.aoMap.value=v.aoMap,y.aoMapIntensity.value=v.aoMapIntensity,n(v.aoMap,y.aoMapTransform))}function o(y,v){y.diffuse.value.copy(v.color),y.opacity.value=v.opacity,v.map&&(y.map.value=v.map,n(v.map,y.mapTransform))}function l(y,v){y.dashSize.value=v.dashSize,y.totalSize.value=v.dashSize+v.gapSize,y.scale.value=v.scale}function c(y,v,S,N){y.diffuse.value.copy(v.color),y.opacity.value=v.opacity,y.size.value=v.size*S,y.scale.value=N*.5,v.map&&(y.map.value=v.map,n(v.map,y.uvTransform)),v.alphaMap&&(y.alphaMap.value=v.alphaMap,n(v.alphaMap,y.alphaMapTransform)),v.alphaTest>0&&(y.alphaTest.value=v.alphaTest)}function u(y,v){y.diffuse.value.copy(v.color),y.opacity.value=v.opacity,y.rotation.value=v.rotation,v.map&&(y.map.value=v.map,n(v.map,y.mapTransform)),v.alphaMap&&(y.alphaMap.value=v.alphaMap,n(v.alphaMap,y.alphaMapTransform)),v.alphaTest>0&&(y.alphaTest.value=v.alphaTest)}function d(y,v){y.specular.value.copy(v.specular),y.shininess.value=Math.max(v.shininess,1e-4)}function f(y,v){v.gradientMap&&(y.gradientMap.value=v.gradientMap)}function m(y,v){y.metalness.value=v.metalness,v.metalnessMap&&(y.metalnessMap.value=v.metalnessMap,n(v.metalnessMap,y.metalnessMapTransform)),y.roughness.value=v.roughness,v.roughnessMap&&(y.roughnessMap.value=v.roughnessMap,n(v.roughnessMap,y.roughnessMapTransform)),e.get(v).envMap&&(y.envMapIntensity.value=v.envMapIntensity)}function p(y,v,S){y.ior.value=v.ior,v.sheen>0&&(y.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),y.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(y.sheenColorMap.value=v.sheenColorMap,n(v.sheenColorMap,y.sheenColorMapTransform)),v.sheenRoughnessMap&&(y.sheenRoughnessMap.value=v.sheenRoughnessMap,n(v.sheenRoughnessMap,y.sheenRoughnessMapTransform))),v.clearcoat>0&&(y.clearcoat.value=v.clearcoat,y.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(y.clearcoatMap.value=v.clearcoatMap,n(v.clearcoatMap,y.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,n(v.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(y.clearcoatNormalMap.value=v.clearcoatNormalMap,n(v.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===Bs&&y.clearcoatNormalScale.value.negate())),v.iridescence>0&&(y.iridescence.value=v.iridescence,y.iridescenceIOR.value=v.iridescenceIOR,y.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(y.iridescenceMap.value=v.iridescenceMap,n(v.iridescenceMap,y.iridescenceMapTransform)),v.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=v.iridescenceThicknessMap,n(v.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),v.transmission>0&&(y.transmission.value=v.transmission,y.transmissionSamplerMap.value=S.texture,y.transmissionSamplerSize.value.set(S.width,S.height),v.transmissionMap&&(y.transmissionMap.value=v.transmissionMap,n(v.transmissionMap,y.transmissionMapTransform)),y.thickness.value=v.thickness,v.thicknessMap&&(y.thicknessMap.value=v.thicknessMap,n(v.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=v.attenuationDistance,y.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(y.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(y.anisotropyMap.value=v.anisotropyMap,n(v.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=v.specularIntensity,y.specularColor.value.copy(v.specularColor),v.specularColorMap&&(y.specularColorMap.value=v.specularColorMap,n(v.specularColorMap,y.specularColorMapTransform)),v.specularIntensityMap&&(y.specularIntensityMap.value=v.specularIntensityMap,n(v.specularIntensityMap,y.specularIntensityMapTransform))}function x(y,v){v.matcap&&(y.matcap.value=v.matcap)}function b(y,v){const S=e.get(v).light;y.referencePosition.value.setFromMatrixPosition(S.matrixWorld),y.nearDistance.value=S.shadow.camera.near,y.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function G2e(t,e,n,r){let i={},s={},o=[];const l=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(S,N){const C=N.program;r.uniformBlockBinding(S,C)}function u(S,N){let C=i[S.id];C===void 0&&(x(S),C=d(S),i[S.id]=C,S.addEventListener("dispose",y));const T=N.program;r.updateUBOMapping(S,T);const k=e.render.frame;s[S.id]!==k&&(m(S),s[S.id]=k)}function d(S){const N=f();S.__bindingPointIndex=N;const C=t.createBuffer(),T=S.__size,k=S.usage;return t.bindBuffer(t.UNIFORM_BUFFER,C),t.bufferData(t.UNIFORM_BUFFER,T,k),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,N,C),C}function f(){for(let S=0;S<l;S++)if(o.indexOf(S)===-1)return o.push(S),S;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function m(S){const N=i[S.id],C=S.uniforms,T=S.__cache;t.bindBuffer(t.UNIFORM_BUFFER,N);for(let k=0,E=C.length;k<E;k++){const D=C[k];if(p(D,k,T)===!0){const A=D.__offset,R=Array.isArray(D.value)?D.value:[D.value];let F=0;for(let O=0;O<R.length;O++){const H=R[O],j=b(H);typeof H=="number"?(D.__data[0]=H,t.bufferSubData(t.UNIFORM_BUFFER,A+F,D.__data)):H.isMatrix3?(D.__data[0]=H.elements[0],D.__data[1]=H.elements[1],D.__data[2]=H.elements[2],D.__data[3]=H.elements[0],D.__data[4]=H.elements[3],D.__data[5]=H.elements[4],D.__data[6]=H.elements[5],D.__data[7]=H.elements[0],D.__data[8]=H.elements[6],D.__data[9]=H.elements[7],D.__data[10]=H.elements[8],D.__data[11]=H.elements[0]):(H.toArray(D.__data,F),F+=j.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,A,D.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(S,N,C){const T=S.value;if(C[N]===void 0){if(typeof T=="number")C[N]=T;else{const k=Array.isArray(T)?T:[T],E=[];for(let D=0;D<k.length;D++)E.push(k[D].clone());C[N]=E}return!0}else if(typeof T=="number"){if(C[N]!==T)return C[N]=T,!0}else{const k=Array.isArray(C[N])?C[N]:[C[N]],E=Array.isArray(T)?T:[T];for(let D=0;D<k.length;D++){const A=k[D];if(A.equals(E[D])===!1)return A.copy(E[D]),!0}}return!1}function x(S){const N=S.uniforms;let C=0;const T=16;let k=0;for(let E=0,D=N.length;E<D;E++){const A=N[E],R={boundary:0,storage:0},F=Array.isArray(A.value)?A.value:[A.value];for(let O=0,H=F.length;O<H;O++){const j=F[O],G=b(j);R.boundary+=G.boundary,R.storage+=G.storage}if(A.__data=new Float32Array(R.storage/Float32Array.BYTES_PER_ELEMENT),A.__offset=C,E>0){k=C%T;const O=T-k;k!==0&&O-R.boundary<0&&(C+=T-k,A.__offset=C)}C+=R.storage}return k=C%T,k>0&&(C+=T-k),S.__size=C,S.__cache={},this}function b(S){const N={boundary:0,storage:0};return typeof S=="number"?(N.boundary=4,N.storage=4):S.isVector2?(N.boundary=8,N.storage=8):S.isVector3||S.isColor?(N.boundary=16,N.storage=12):S.isVector4?(N.boundary=16,N.storage=16):S.isMatrix3?(N.boundary=48,N.storage=48):S.isMatrix4?(N.boundary=64,N.storage=64):S.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",S),N}function y(S){const N=S.target;N.removeEventListener("dispose",y);const C=o.indexOf(N.__bindingPointIndex);o.splice(C,1),t.deleteBuffer(i[N.id]),delete i[N.id],delete s[N.id]}function v(){for(const S in i)t.deleteBuffer(i[S]);o=[],i={},s={}}return{bind:c,update:u,dispose:v}}class _P{constructor(e={}){const{canvas:n=$ve(),context:r=null,depth:i=!0,stencil:s=!0,alpha:o=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let m;r!==null?m=r.getContextAttributes().alpha:m=o;const p=new Uint32Array(4),x=new Int32Array(4);let b=null,y=null;const v=[],S=[];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=ja,this._useLegacyLights=!1,this.toneMapping=ch,this.toneMappingExposure=1;const N=this;let C=!1,T=0,k=0,E=null,D=-1,A=null;const R=new Ar,F=new Ar;let O=null;const H=new en(0);let j=0,G=n.width,$=n.height,q=1,Y=null,Z=null;const oe=new Ar(0,0,G,$),B=new Ar(0,0,G,$);let W=!1;const se=new TN;let ne=!1,ce=!1,fe=null;const ye=new Fr,ge=new xn,xe=new qe,Pe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ue(){return E===null?q:1}let be=r;function it(Ae,Xe){for(let Je=0;Je<Ae.length;Je++){const dt=Ae[Je],st=n.getContext(dt,Xe);if(st!==null)return st}return null}try{const Ae={alpha:!0,depth:i,stencil:s,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${MN}`),n.addEventListener("webglcontextlost",tt,!1),n.addEventListener("webglcontextrestored",ke,!1),n.addEventListener("webglcontextcreationerror",We,!1),be===null){const Xe=["webgl2","webgl","experimental-webgl"];if(N.isWebGL1Renderer===!0&&Xe.shift(),be=it(Xe,Ae),be===null)throw it(Xe)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&be instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),be.getShaderPrecisionFormat===void 0&&(be.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(Ae){throw console.error("THREE.WebGLRenderer: "+Ae.message),Ae}let U,K,J,Q,z,re,Ee,_e,Te,V,L,X,te,Me,ie,De,Le,$e,Ze,Ie,ae,He,Se,Be;function ft(){U=new nSe(be),K=new X1e(be,U,e),U.init(K),He=new z2e(be,U,K),J=new F2e(be,U,K),Q=new aSe(be),z=new N2e,re=new U2e(be,U,J,z,K,He,Q),Ee=new Q1e(N),_e=new tSe(N),Te=new h_e(be,K),Se=new W1e(be,U,Te,K),V=new rSe(be,Te,Q,Se),L=new cSe(be,V,Te,Q),Ze=new lSe(be,K,re),De=new Y1e(z),X=new S2e(N,Ee,_e,U,K,Se,De),te=new V2e(N,z),Me=new E2e,ie=new P2e(U,K),$e=new q1e(N,Ee,_e,J,L,m,c),Le=new I2e(N,L,K),Be=new G2e(be,Q,K,J),Ie=new K1e(be,U,Q,K),ae=new iSe(be,U,Q,K),Q.programs=X.programs,N.capabilities=K,N.extensions=U,N.properties=z,N.renderLists=Me,N.shadowMap=Le,N.state=J,N.info=Q}ft();const we=new H2e(N,be);this.xr=we,this.getContext=function(){return be},this.getContextAttributes=function(){return be.getContextAttributes()},this.forceContextLoss=function(){const Ae=U.get("WEBGL_lose_context");Ae&&Ae.loseContext()},this.forceContextRestore=function(){const Ae=U.get("WEBGL_lose_context");Ae&&Ae.restoreContext()},this.getPixelRatio=function(){return q},this.setPixelRatio=function(Ae){Ae!==void 0&&(q=Ae,this.setSize(G,$,!1))},this.getSize=function(Ae){return Ae.set(G,$)},this.setSize=function(Ae,Xe,Je=!0){if(we.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}G=Ae,$=Xe,n.width=Math.floor(Ae*q),n.height=Math.floor(Xe*q),Je===!0&&(n.style.width=Ae+"px",n.style.height=Xe+"px"),this.setViewport(0,0,Ae,Xe)},this.getDrawingBufferSize=function(Ae){return Ae.set(G*q,$*q).floor()},this.setDrawingBufferSize=function(Ae,Xe,Je){G=Ae,$=Xe,q=Je,n.width=Math.floor(Ae*Je),n.height=Math.floor(Xe*Je),this.setViewport(0,0,Ae,Xe)},this.getCurrentViewport=function(Ae){return Ae.copy(R)},this.getViewport=function(Ae){return Ae.copy(oe)},this.setViewport=function(Ae,Xe,Je,dt){Ae.isVector4?oe.set(Ae.x,Ae.y,Ae.z,Ae.w):oe.set(Ae,Xe,Je,dt),J.viewport(R.copy(oe).multiplyScalar(q).floor())},this.getScissor=function(Ae){return Ae.copy(B)},this.setScissor=function(Ae,Xe,Je,dt){Ae.isVector4?B.set(Ae.x,Ae.y,Ae.z,Ae.w):B.set(Ae,Xe,Je,dt),J.scissor(F.copy(B).multiplyScalar(q).floor())},this.getScissorTest=function(){return W},this.setScissorTest=function(Ae){J.setScissorTest(W=Ae)},this.setOpaqueSort=function(Ae){Y=Ae},this.setTransparentSort=function(Ae){Z=Ae},this.getClearColor=function(Ae){return Ae.copy($e.getClearColor())},this.setClearColor=function(){$e.setClearColor.apply($e,arguments)},this.getClearAlpha=function(){return $e.getClearAlpha()},this.setClearAlpha=function(){$e.setClearAlpha.apply($e,arguments)},this.clear=function(Ae=!0,Xe=!0,Je=!0){let dt=0;if(Ae){let st=!1;if(E!==null){const jt=E.texture.format;st=jt===OK||jt===DK||jt===RK}if(st){const jt=E.texture.type,he=jt===uh||jt===Qd||jt===i4||jt===Bf||jt===jK||jt===PK,me=$e.getClearColor(),Fe=$e.getClearAlpha(),Oe=me.r,je=me.g,ht=me.b;he?(p[0]=Oe,p[1]=je,p[2]=ht,p[3]=Fe,be.clearBufferuiv(be.COLOR,0,p)):(x[0]=Oe,x[1]=je,x[2]=ht,x[3]=Fe,be.clearBufferiv(be.COLOR,0,x))}else dt|=be.COLOR_BUFFER_BIT}Xe&&(dt|=be.DEPTH_BUFFER_BIT),Je&&(dt|=be.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),be.clear(dt)},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",tt,!1),n.removeEventListener("webglcontextrestored",ke,!1),n.removeEventListener("webglcontextcreationerror",We,!1),Me.dispose(),ie.dispose(),z.dispose(),Ee.dispose(),_e.dispose(),L.dispose(),Se.dispose(),Be.dispose(),X.dispose(),we.dispose(),we.removeEventListener("sessionstart",It),we.removeEventListener("sessionend",Ft),fe&&(fe.dispose(),fe=null),vn.stop()};function tt(Ae){Ae.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),C=!0}function ke(){console.log("THREE.WebGLRenderer: Context Restored."),C=!1;const Ae=Q.autoReset,Xe=Le.enabled,Je=Le.autoUpdate,dt=Le.needsUpdate,st=Le.type;ft(),Q.autoReset=Ae,Le.enabled=Xe,Le.autoUpdate=Je,Le.needsUpdate=dt,Le.type=st}function We(Ae){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",Ae.statusMessage)}function pe(Ae){const Xe=Ae.target;Xe.removeEventListener("dispose",pe),Ce(Xe)}function Ce(Ae){de(Ae),z.remove(Ae)}function de(Ae){const Xe=z.get(Ae).programs;Xe!==void 0&&(Xe.forEach(function(Je){X.releaseProgram(Je)}),Ae.isShaderMaterial&&X.releaseShaderCache(Ae))}this.renderBufferDirect=function(Ae,Xe,Je,dt,st,jt){Xe===null&&(Xe=Pe);const he=st.isMesh&&st.matrixWorld.determinant()<0,me=bn(Ae,Xe,Je,dt,st);J.setMaterial(dt,he);let Fe=Je.index,Oe=1;if(dt.wireframe===!0){if(Fe=V.getWireframeAttribute(Je),Fe===void 0)return;Oe=2}const je=Je.drawRange,ht=Je.attributes.position;let Nt=je.start*Oe,Ct=(je.start+je.count)*Oe;jt!==null&&(Nt=Math.max(Nt,jt.start*Oe),Ct=Math.min(Ct,(jt.start+jt.count)*Oe)),Fe!==null?(Nt=Math.max(Nt,0),Ct=Math.min(Ct,Fe.count)):ht!=null&&(Nt=Math.max(Nt,0),Ct=Math.min(Ct,ht.count));const At=Ct-Nt;if(At<0||At===1/0)return;Se.setup(st,dt,me,Je,Fe);let Lt,Rt=Ie;if(Fe!==null&&(Lt=Te.get(Fe),Rt=ae,Rt.setIndex(Lt)),st.isMesh)dt.wireframe===!0?(J.setLineWidth(dt.wireframeLinewidth*Ue()),Rt.setMode(be.LINES)):Rt.setMode(be.TRIANGLES);else if(st.isLine){let Mt=dt.linewidth;Mt===void 0&&(Mt=1),J.setLineWidth(Mt*Ue()),st.isLineSegments?Rt.setMode(be.LINES):st.isLineLoop?Rt.setMode(be.LINE_LOOP):Rt.setMode(be.LINE_STRIP)}else st.isPoints?Rt.setMode(be.POINTS):st.isSprite&&Rt.setMode(be.TRIANGLES);if(st.isBatchedMesh)Rt.renderMultiDraw(st._multiDrawStarts,st._multiDrawCounts,st._multiDrawCount);else if(st.isInstancedMesh)Rt.renderInstances(Nt,At,st.count);else if(Je.isInstancedBufferGeometry){const Mt=Je._maxInstanceCount!==void 0?Je._maxInstanceCount:1/0,Zt=Math.min(Je.instanceCount,Mt);Rt.renderInstances(Nt,At,Zt)}else Rt.render(Nt,At)};function Ve(Ae,Xe,Je){Ae.transparent===!0&&Ae.side===hu&&Ae.forceSinglePass===!1?(Ae.side=Bs,Ae.needsUpdate=!0,Gn(Ae,Xe,Je),Ae.side=Sh,Ae.needsUpdate=!0,Gn(Ae,Xe,Je),Ae.side=hu):Gn(Ae,Xe,Je)}this.compile=function(Ae,Xe,Je=null){Je===null&&(Je=Ae),y=ie.get(Je),y.init(),S.push(y),Je.traverseVisible(function(st){st.isLight&&st.layers.test(Xe.layers)&&(y.pushLight(st),st.castShadow&&y.pushShadow(st))}),Ae!==Je&&Ae.traverseVisible(function(st){st.isLight&&st.layers.test(Xe.layers)&&(y.pushLight(st),st.castShadow&&y.pushShadow(st))}),y.setupLights(N._useLegacyLights);const dt=new Set;return Ae.traverse(function(st){const jt=st.material;if(jt)if(Array.isArray(jt))for(let he=0;he<jt.length;he++){const me=jt[he];Ve(me,Je,st),dt.add(me)}else Ve(jt,Je,st),dt.add(jt)}),S.pop(),y=null,dt},this.compileAsync=function(Ae,Xe,Je=null){const dt=this.compile(Ae,Xe,Je);return new Promise(st=>{function jt(){if(dt.forEach(function(he){z.get(he).currentProgram.isReady()&&dt.delete(he)}),dt.size===0){st(Ae);return}setTimeout(jt,10)}U.get("KHR_parallel_shader_compile")!==null?jt():setTimeout(jt,10)})};let yt=null;function ut(Ae){yt&&yt(Ae)}function It(){vn.stop()}function Ft(){vn.start()}const vn=new JK;vn.setAnimationLoop(ut),typeof self<"u"&&vn.setContext(self),this.setAnimationLoop=function(Ae){yt=Ae,we.setAnimationLoop(Ae),Ae===null?vn.stop():vn.start()},we.addEventListener("sessionstart",It),we.addEventListener("sessionend",Ft),this.render=function(Ae,Xe){if(Xe!==void 0&&Xe.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;Ae.matrixWorldAutoUpdate===!0&&Ae.updateMatrixWorld(),Xe.parent===null&&Xe.matrixWorldAutoUpdate===!0&&Xe.updateMatrixWorld(),we.enabled===!0&&we.isPresenting===!0&&(we.cameraAutoUpdate===!0&&we.updateCamera(Xe),Xe=we.getCamera()),Ae.isScene===!0&&Ae.onBeforeRender(N,Ae,Xe,E),y=ie.get(Ae,S.length),y.init(),S.push(y),ye.multiplyMatrices(Xe.projectionMatrix,Xe.matrixWorldInverse),se.setFromProjectionMatrix(ye),ce=this.localClippingEnabled,ne=De.init(this.clippingPlanes,ce),b=Me.get(Ae,v.length),b.init(),v.push(b),Kt(Ae,Xe,0,N.sortObjects),b.finish(),N.sortObjects===!0&&b.sort(Y,Z),this.info.render.frame++,ne===!0&&De.beginShadows();const Je=y.state.shadowsArray;if(Le.render(Je,Ae,Xe),ne===!0&&De.endShadows(),this.info.autoReset===!0&&this.info.reset(),$e.render(b,Ae),y.setupLights(N._useLegacyLights),Xe.isArrayCamera){const dt=Xe.cameras;for(let st=0,jt=dt.length;st<jt;st++){const he=dt[st];cr(b,Ae,he,he.viewport)}}else cr(b,Ae,Xe);E!==null&&(re.updateMultisampleRenderTarget(E),re.updateRenderTargetMipmap(E)),Ae.isScene===!0&&Ae.onAfterRender(N,Ae,Xe),Se.resetDefaultState(),D=-1,A=null,S.pop(),S.length>0?y=S[S.length-1]:y=null,v.pop(),v.length>0?b=v[v.length-1]:b=null};function Kt(Ae,Xe,Je,dt){if(Ae.visible===!1)return;if(Ae.layers.test(Xe.layers)){if(Ae.isGroup)Je=Ae.renderOrder;else if(Ae.isLOD)Ae.autoUpdate===!0&&Ae.update(Xe);else if(Ae.isLight)y.pushLight(Ae),Ae.castShadow&&y.pushShadow(Ae);else if(Ae.isSprite){if(!Ae.frustumCulled||se.intersectsSprite(Ae)){dt&&xe.setFromMatrixPosition(Ae.matrixWorld).applyMatrix4(ye);const he=L.update(Ae),me=Ae.material;me.visible&&b.push(Ae,he,me,Je,xe.z,null)}}else if((Ae.isMesh||Ae.isLine||Ae.isPoints)&&(!Ae.frustumCulled||se.intersectsObject(Ae))){const he=L.update(Ae),me=Ae.material;if(dt&&(Ae.boundingSphere!==void 0?(Ae.boundingSphere===null&&Ae.computeBoundingSphere(),xe.copy(Ae.boundingSphere.center)):(he.boundingSphere===null&&he.computeBoundingSphere(),xe.copy(he.boundingSphere.center)),xe.applyMatrix4(Ae.matrixWorld).applyMatrix4(ye)),Array.isArray(me)){const Fe=he.groups;for(let Oe=0,je=Fe.length;Oe<je;Oe++){const ht=Fe[Oe],Nt=me[ht.materialIndex];Nt&&Nt.visible&&b.push(Ae,he,Nt,Je,xe.z,ht)}}else me.visible&&b.push(Ae,he,me,Je,xe.z,null)}}const jt=Ae.children;for(let he=0,me=jt.length;he<me;he++)Kt(jt[he],Xe,Je,dt)}function cr(Ae,Xe,Je,dt){const st=Ae.opaque,jt=Ae.transmissive,he=Ae.transparent;y.setupLightsView(Je),ne===!0&&De.setGlobalState(N.clippingPlanes,Je),jt.length>0&&dr(st,jt,Xe,Je),dt&&J.viewport(R.copy(dt)),st.length>0&&Jn(st,Xe,Je),jt.length>0&&Jn(jt,Xe,Je),he.length>0&&Jn(he,Xe,Je),J.buffers.depth.setTest(!0),J.buffers.depth.setMask(!0),J.buffers.color.setMask(!0),J.setPolygonOffset(!1)}function dr(Ae,Xe,Je,dt){if((Je.isScene===!0?Je.overrideMaterial:null)!==null)return;const jt=K.isWebGL2;fe===null&&(fe=new dm(1,1,{generateMipmaps:!0,type:U.has("EXT_color_buffer_half_float")?ty:uh,minFilter:ey,samples:jt?4:0})),N.getDrawingBufferSize(ge),jt?fe.setSize(ge.x,ge.y):fe.setSize(aS(ge.x),aS(ge.y));const he=N.getRenderTarget();N.setRenderTarget(fe),N.getClearColor(H),j=N.getClearAlpha(),j<1&&N.setClearColor(16777215,.5),N.clear();const me=N.toneMapping;N.toneMapping=ch,Jn(Ae,Je,dt),re.updateMultisampleRenderTarget(fe),re.updateRenderTargetMipmap(fe);let Fe=!1;for(let Oe=0,je=Xe.length;Oe<je;Oe++){const ht=Xe[Oe],Nt=ht.object,Ct=ht.geometry,At=ht.material,Lt=ht.group;if(At.side===hu&&Nt.layers.test(dt.layers)){const Rt=At.side;At.side=Bs,At.needsUpdate=!0,ln(Nt,Je,dt,Ct,At,Lt),At.side=Rt,At.needsUpdate=!0,Fe=!0}}Fe===!0&&(re.updateMultisampleRenderTarget(fe),re.updateRenderTargetMipmap(fe)),N.setRenderTarget(he),N.setClearColor(H,j),N.toneMapping=me}function Jn(Ae,Xe,Je){const dt=Xe.isScene===!0?Xe.overrideMaterial:null;for(let st=0,jt=Ae.length;st<jt;st++){const he=Ae[st],me=he.object,Fe=he.geometry,Oe=dt===null?he.material:dt,je=he.group;me.layers.test(Je.layers)&&ln(me,Xe,Je,Fe,Oe,je)}}function ln(Ae,Xe,Je,dt,st,jt){Ae.onBeforeRender(N,Xe,Je,dt,st,jt),Ae.modelViewMatrix.multiplyMatrices(Je.matrixWorldInverse,Ae.matrixWorld),Ae.normalMatrix.getNormalMatrix(Ae.modelViewMatrix),st.onBeforeRender(N,Xe,Je,dt,Ae,jt),st.transparent===!0&&st.side===hu&&st.forceSinglePass===!1?(st.side=Bs,st.needsUpdate=!0,N.renderBufferDirect(Je,Xe,dt,st,Ae,jt),st.side=Sh,st.needsUpdate=!0,N.renderBufferDirect(Je,Xe,dt,st,Ae,jt),st.side=hu):N.renderBufferDirect(Je,Xe,dt,st,Ae,jt),Ae.onAfterRender(N,Xe,Je,dt,st,jt)}function Gn(Ae,Xe,Je){Xe.isScene!==!0&&(Xe=Pe);const dt=z.get(Ae),st=y.state.lights,jt=y.state.shadowsArray,he=st.state.version,me=X.getParameters(Ae,st.state,jt,Xe,Je),Fe=X.getProgramCacheKey(me);let Oe=dt.programs;dt.environment=Ae.isMeshStandardMaterial?Xe.environment:null,dt.fog=Xe.fog,dt.envMap=(Ae.isMeshStandardMaterial?_e:Ee).get(Ae.envMap||dt.environment),Oe===void 0&&(Ae.addEventListener("dispose",pe),Oe=new Map,dt.programs=Oe);let je=Oe.get(Fe);if(je!==void 0){if(dt.currentProgram===je&&dt.lightsStateVersion===he)return er(Ae,me),je}else me.uniforms=X.getUniforms(Ae),Ae.onBuild(Je,me,N),Ae.onBeforeCompile(me,N),je=X.acquireProgram(me,Fe),Oe.set(Fe,je),dt.uniforms=me.uniforms;const ht=dt.uniforms;return(!Ae.isShaderMaterial&&!Ae.isRawShaderMaterial||Ae.clipping===!0)&&(ht.clippingPlanes=De.uniform),er(Ae,me),dt.needsLights=Ia(Ae),dt.lightsStateVersion=he,dt.needsLights&&(ht.ambientLightColor.value=st.state.ambient,ht.lightProbe.value=st.state.probe,ht.directionalLights.value=st.state.directional,ht.directionalLightShadows.value=st.state.directionalShadow,ht.spotLights.value=st.state.spot,ht.spotLightShadows.value=st.state.spotShadow,ht.rectAreaLights.value=st.state.rectArea,ht.ltc_1.value=st.state.rectAreaLTC1,ht.ltc_2.value=st.state.rectAreaLTC2,ht.pointLights.value=st.state.point,ht.pointLightShadows.value=st.state.pointShadow,ht.hemisphereLights.value=st.state.hemi,ht.directionalShadowMap.value=st.state.directionalShadowMap,ht.directionalShadowMatrix.value=st.state.directionalShadowMatrix,ht.spotShadowMap.value=st.state.spotShadowMap,ht.spotLightMatrix.value=st.state.spotLightMatrix,ht.spotLightMap.value=st.state.spotLightMap,ht.pointShadowMap.value=st.state.pointShadowMap,ht.pointShadowMatrix.value=st.state.pointShadowMatrix),dt.currentProgram=je,dt.uniformsList=null,je}function nr(Ae){if(Ae.uniformsList===null){const Xe=Ae.currentProgram.getUniforms();Ae.uniformsList=E1.seqWithValue(Xe.seq,Ae.uniforms)}return Ae.uniformsList}function er(Ae,Xe){const Je=z.get(Ae);Je.outputColorSpace=Xe.outputColorSpace,Je.batching=Xe.batching,Je.instancing=Xe.instancing,Je.instancingColor=Xe.instancingColor,Je.skinning=Xe.skinning,Je.morphTargets=Xe.morphTargets,Je.morphNormals=Xe.morphNormals,Je.morphColors=Xe.morphColors,Je.morphTargetsCount=Xe.morphTargetsCount,Je.numClippingPlanes=Xe.numClippingPlanes,Je.numIntersection=Xe.numClipIntersection,Je.vertexAlphas=Xe.vertexAlphas,Je.vertexTangents=Xe.vertexTangents,Je.toneMapping=Xe.toneMapping}function bn(Ae,Xe,Je,dt,st){Xe.isScene!==!0&&(Xe=Pe),re.resetTextureUnits();const jt=Xe.fog,he=dt.isMeshStandardMaterial?Xe.environment:null,me=E===null?N.outputColorSpace:E.isXRRenderTarget===!0?E.texture.colorSpace:Lu,Fe=(dt.isMeshStandardMaterial?_e:Ee).get(dt.envMap||he),Oe=dt.vertexColors===!0&&!!Je.attributes.color&&Je.attributes.color.itemSize===4,je=!!Je.attributes.tangent&&(!!dt.normalMap||dt.anisotropy>0),ht=!!Je.morphAttributes.position,Nt=!!Je.morphAttributes.normal,Ct=!!Je.morphAttributes.color;let At=ch;dt.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(At=N.toneMapping);const Lt=Je.morphAttributes.position||Je.morphAttributes.normal||Je.morphAttributes.color,Rt=Lt!==void 0?Lt.length:0,Mt=z.get(dt),Zt=y.state.lights;if(ne===!0&&(ce===!0||Ae!==A)){const Ur=Ae===A&&dt.id===D;De.setState(dt,Ae,Ur)}let $t=!1;dt.version===Mt.__version?(Mt.needsLights&&Mt.lightsStateVersion!==Zt.state.version||Mt.outputColorSpace!==me||st.isBatchedMesh&&Mt.batching===!1||!st.isBatchedMesh&&Mt.batching===!0||st.isInstancedMesh&&Mt.instancing===!1||!st.isInstancedMesh&&Mt.instancing===!0||st.isSkinnedMesh&&Mt.skinning===!1||!st.isSkinnedMesh&&Mt.skinning===!0||st.isInstancedMesh&&Mt.instancingColor===!0&&st.instanceColor===null||st.isInstancedMesh&&Mt.instancingColor===!1&&st.instanceColor!==null||Mt.envMap!==Fe||dt.fog===!0&&Mt.fog!==jt||Mt.numClippingPlanes!==void 0&&(Mt.numClippingPlanes!==De.numPlanes||Mt.numIntersection!==De.numIntersection)||Mt.vertexAlphas!==Oe||Mt.vertexTangents!==je||Mt.morphTargets!==ht||Mt.morphNormals!==Nt||Mt.morphColors!==Ct||Mt.toneMapping!==At||K.isWebGL2===!0&&Mt.morphTargetsCount!==Rt)&&($t=!0):($t=!0,Mt.__version=dt.version);let un=Mt.currentProgram;$t===!0&&(un=Gn(dt,Xe,st));let _n=!1,Mn=!1,Ht=!1;const Xt=un.getUniforms(),tn=Mt.uniforms;if(J.useProgram(un.program)&&(_n=!0,Mn=!0,Ht=!0),dt.id!==D&&(D=dt.id,Mn=!0),_n||A!==Ae){Xt.setValue(be,"projectionMatrix",Ae.projectionMatrix),Xt.setValue(be,"viewMatrix",Ae.matrixWorldInverse);const Ur=Xt.map.cameraPosition;Ur!==void 0&&Ur.setValue(be,xe.setFromMatrixPosition(Ae.matrixWorld)),K.logarithmicDepthBuffer&&Xt.setValue(be,"logDepthBufFC",2/(Math.log(Ae.far+1)/Math.LN2)),(dt.isMeshPhongMaterial||dt.isMeshToonMaterial||dt.isMeshLambertMaterial||dt.isMeshBasicMaterial||dt.isMeshStandardMaterial||dt.isShaderMaterial)&&Xt.setValue(be,"isOrthographic",Ae.isOrthographicCamera===!0),A!==Ae&&(A=Ae,Mn=!0,Ht=!0)}if(st.isSkinnedMesh){Xt.setOptional(be,st,"bindMatrix"),Xt.setOptional(be,st,"bindMatrixInverse");const Ur=st.skeleton;Ur&&(K.floatVertexTextures?(Ur.boneTexture===null&&Ur.computeBoneTexture(),Xt.setValue(be,"boneTexture",Ur.boneTexture,re)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}st.isBatchedMesh&&(Xt.setOptional(be,st,"batchingTexture"),Xt.setValue(be,"batchingTexture",st._matricesTexture,re));const cn=Je.morphAttributes;if((cn.position!==void 0||cn.normal!==void 0||cn.color!==void 0&&K.isWebGL2===!0)&&Ze.update(st,Je,un),(Mn||Mt.receiveShadow!==st.receiveShadow)&&(Mt.receiveShadow=st.receiveShadow,Xt.setValue(be,"receiveShadow",st.receiveShadow)),dt.isMeshGouraudMaterial&&dt.envMap!==null&&(tn.envMap.value=Fe,tn.flipEnvMap.value=Fe.isCubeTexture&&Fe.isRenderTargetTexture===!1?-1:1),Mn&&(Xt.setValue(be,"toneMappingExposure",N.toneMappingExposure),Mt.needsLights&&xi(tn,Ht),jt&&dt.fog===!0&&te.refreshFogUniforms(tn,jt),te.refreshMaterialUniforms(tn,dt,q,$,fe),E1.upload(be,nr(Mt),tn,re)),dt.isShaderMaterial&&dt.uniformsNeedUpdate===!0&&(E1.upload(be,nr(Mt),tn,re),dt.uniformsNeedUpdate=!1),dt.isSpriteMaterial&&Xt.setValue(be,"center",st.center),Xt.setValue(be,"modelViewMatrix",st.modelViewMatrix),Xt.setValue(be,"normalMatrix",st.normalMatrix),Xt.setValue(be,"modelMatrix",st.matrixWorld),dt.isShaderMaterial||dt.isRawShaderMaterial){const Ur=dt.uniformsGroups;for(let qn=0,Qe=Ur.length;qn<Qe;qn++)if(K.isWebGL2){const Tt=Ur[qn];Be.update(Tt,un),Be.bind(Tt,un)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return un}function xi(Ae,Xe){Ae.ambientLightColor.needsUpdate=Xe,Ae.lightProbe.needsUpdate=Xe,Ae.directionalLights.needsUpdate=Xe,Ae.directionalLightShadows.needsUpdate=Xe,Ae.pointLights.needsUpdate=Xe,Ae.pointLightShadows.needsUpdate=Xe,Ae.spotLights.needsUpdate=Xe,Ae.spotLightShadows.needsUpdate=Xe,Ae.rectAreaLights.needsUpdate=Xe,Ae.hemisphereLights.needsUpdate=Xe}function Ia(Ae){return Ae.isMeshLambertMaterial||Ae.isMeshToonMaterial||Ae.isMeshPhongMaterial||Ae.isMeshStandardMaterial||Ae.isShadowMaterial||Ae.isShaderMaterial&&Ae.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(Ae,Xe,Je){z.get(Ae.texture).__webglTexture=Xe,z.get(Ae.depthTexture).__webglTexture=Je;const dt=z.get(Ae);dt.__hasExternalTextures=!0,dt.__hasExternalTextures&&(dt.__autoAllocateDepthBuffer=Je===void 0,dt.__autoAllocateDepthBuffer||U.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),dt.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(Ae,Xe){const Je=z.get(Ae);Je.__webglFramebuffer=Xe,Je.__useDefaultFramebuffer=Xe===void 0},this.setRenderTarget=function(Ae,Xe=0,Je=0){E=Ae,T=Xe,k=Je;let dt=!0,st=null,jt=!1,he=!1;if(Ae){const Fe=z.get(Ae);Fe.__useDefaultFramebuffer!==void 0?(J.bindFramebuffer(be.FRAMEBUFFER,null),dt=!1):Fe.__webglFramebuffer===void 0?re.setupRenderTarget(Ae):Fe.__hasExternalTextures&&re.rebindTextures(Ae,z.get(Ae.texture).__webglTexture,z.get(Ae.depthTexture).__webglTexture);const Oe=Ae.texture;(Oe.isData3DTexture||Oe.isDataArrayTexture||Oe.isCompressedArrayTexture)&&(he=!0);const je=z.get(Ae).__webglFramebuffer;Ae.isWebGLCubeRenderTarget?(Array.isArray(je[Xe])?st=je[Xe][Je]:st=je[Xe],jt=!0):K.isWebGL2&&Ae.samples>0&&re.useMultisampledRTT(Ae)===!1?st=z.get(Ae).__webglMultisampledFramebuffer:Array.isArray(je)?st=je[Je]:st=je,R.copy(Ae.viewport),F.copy(Ae.scissor),O=Ae.scissorTest}else R.copy(oe).multiplyScalar(q).floor(),F.copy(B).multiplyScalar(q).floor(),O=W;if(J.bindFramebuffer(be.FRAMEBUFFER,st)&&K.drawBuffers&&dt&&J.drawBuffers(Ae,st),J.viewport(R),J.scissor(F),J.setScissorTest(O),jt){const Fe=z.get(Ae.texture);be.framebufferTexture2D(be.FRAMEBUFFER,be.COLOR_ATTACHMENT0,be.TEXTURE_CUBE_MAP_POSITIVE_X+Xe,Fe.__webglTexture,Je)}else if(he){const Fe=z.get(Ae.texture),Oe=Xe||0;be.framebufferTextureLayer(be.FRAMEBUFFER,be.COLOR_ATTACHMENT0,Fe.__webglTexture,Je||0,Oe)}D=-1},this.readRenderTargetPixels=function(Ae,Xe,Je,dt,st,jt,he){if(!(Ae&&Ae.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let me=z.get(Ae).__webglFramebuffer;if(Ae.isWebGLCubeRenderTarget&&he!==void 0&&(me=me[he]),me){J.bindFramebuffer(be.FRAMEBUFFER,me);try{const Fe=Ae.texture,Oe=Fe.format,je=Fe.type;if(Oe!==Ko&&He.convert(Oe)!==be.getParameter(be.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const ht=je===ty&&(U.has("EXT_color_buffer_half_float")||K.isWebGL2&&U.has("EXT_color_buffer_float"));if(je!==uh&&He.convert(je)!==be.getParameter(be.IMPLEMENTATION_COLOR_READ_TYPE)&&!(je===yu&&(K.isWebGL2||U.has("OES_texture_float")||U.has("WEBGL_color_buffer_float")))&&!ht){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Xe>=0&&Xe<=Ae.width-dt&&Je>=0&&Je<=Ae.height-st&&be.readPixels(Xe,Je,dt,st,He.convert(Oe),He.convert(je),jt)}finally{const Fe=E!==null?z.get(E).__webglFramebuffer:null;J.bindFramebuffer(be.FRAMEBUFFER,Fe)}}},this.copyFramebufferToTexture=function(Ae,Xe,Je=0){const dt=Math.pow(2,-Je),st=Math.floor(Xe.image.width*dt),jt=Math.floor(Xe.image.height*dt);re.setTexture2D(Xe,0),be.copyTexSubImage2D(be.TEXTURE_2D,Je,0,0,Ae.x,Ae.y,st,jt),J.unbindTexture()},this.copyTextureToTexture=function(Ae,Xe,Je,dt=0){const st=Xe.image.width,jt=Xe.image.height,he=He.convert(Je.format),me=He.convert(Je.type);re.setTexture2D(Je,0),be.pixelStorei(be.UNPACK_FLIP_Y_WEBGL,Je.flipY),be.pixelStorei(be.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Je.premultiplyAlpha),be.pixelStorei(be.UNPACK_ALIGNMENT,Je.unpackAlignment),Xe.isDataTexture?be.texSubImage2D(be.TEXTURE_2D,dt,Ae.x,Ae.y,st,jt,he,me,Xe.image.data):Xe.isCompressedTexture?be.compressedTexSubImage2D(be.TEXTURE_2D,dt,Ae.x,Ae.y,Xe.mipmaps[0].width,Xe.mipmaps[0].height,he,Xe.mipmaps[0].data):be.texSubImage2D(be.TEXTURE_2D,dt,Ae.x,Ae.y,he,me,Xe.image),dt===0&&Je.generateMipmaps&&be.generateMipmap(be.TEXTURE_2D),J.unbindTexture()},this.copyTextureToTexture3D=function(Ae,Xe,Je,dt,st=0){if(N.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const jt=Ae.max.x-Ae.min.x+1,he=Ae.max.y-Ae.min.y+1,me=Ae.max.z-Ae.min.z+1,Fe=He.convert(dt.format),Oe=He.convert(dt.type);let je;if(dt.isData3DTexture)re.setTexture3D(dt,0),je=be.TEXTURE_3D;else if(dt.isDataArrayTexture)re.setTexture2DArray(dt,0),je=be.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}be.pixelStorei(be.UNPACK_FLIP_Y_WEBGL,dt.flipY),be.pixelStorei(be.UNPACK_PREMULTIPLY_ALPHA_WEBGL,dt.premultiplyAlpha),be.pixelStorei(be.UNPACK_ALIGNMENT,dt.unpackAlignment);const ht=be.getParameter(be.UNPACK_ROW_LENGTH),Nt=be.getParameter(be.UNPACK_IMAGE_HEIGHT),Ct=be.getParameter(be.UNPACK_SKIP_PIXELS),At=be.getParameter(be.UNPACK_SKIP_ROWS),Lt=be.getParameter(be.UNPACK_SKIP_IMAGES),Rt=Je.isCompressedTexture?Je.mipmaps[0]:Je.image;be.pixelStorei(be.UNPACK_ROW_LENGTH,Rt.width),be.pixelStorei(be.UNPACK_IMAGE_HEIGHT,Rt.height),be.pixelStorei(be.UNPACK_SKIP_PIXELS,Ae.min.x),be.pixelStorei(be.UNPACK_SKIP_ROWS,Ae.min.y),be.pixelStorei(be.UNPACK_SKIP_IMAGES,Ae.min.z),Je.isDataTexture||Je.isData3DTexture?be.texSubImage3D(je,st,Xe.x,Xe.y,Xe.z,jt,he,me,Fe,Oe,Rt.data):Je.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),be.compressedTexSubImage3D(je,st,Xe.x,Xe.y,Xe.z,jt,he,me,Fe,Rt.data)):be.texSubImage3D(je,st,Xe.x,Xe.y,Xe.z,jt,he,me,Fe,Oe,Rt),be.pixelStorei(be.UNPACK_ROW_LENGTH,ht),be.pixelStorei(be.UNPACK_IMAGE_HEIGHT,Nt),be.pixelStorei(be.UNPACK_SKIP_PIXELS,Ct),be.pixelStorei(be.UNPACK_SKIP_ROWS,At),be.pixelStorei(be.UNPACK_SKIP_IMAGES,Lt),st===0&&dt.generateMipmaps&&be.generateMipmap(je),J.unbindTexture()},this.initTexture=function(Ae){Ae.isCubeTexture?re.setTextureCube(Ae,0):Ae.isData3DTexture?re.setTexture3D(Ae,0):Ae.isDataArrayTexture||Ae.isCompressedArrayTexture?re.setTexture2DArray(Ae,0):re.setTexture2D(Ae,0),J.unbindTexture()},this.resetState=function(){T=0,k=0,E=null,J.reset(),Se.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return cc}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===a4?"display-p3":"srgb",n.unpackColorSpace=Er.workingColorSpace===CN?"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===ja?Hf:IK}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Hf?ja:Lu}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 q2e extends _P{}q2e.prototype.isWebGL1Renderer=!0;class d4{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new en(e),this.near=n,this.far=r}clone(){return new d4(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class W2e extends ys{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 K2e{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=xP,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Cu()}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=Cu()),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=Cu()),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 cs=new qe;class Zd{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++)cs.fromBufferAttribute(this,n),cs.applyMatrix4(e),this.setXYZ(n,cs.x,cs.y,cs.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)cs.fromBufferAttribute(this,n),cs.applyNormalMatrix(e),this.setXYZ(n,cs.x,cs.y,cs.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)cs.fromBufferAttribute(this,n),cs.transformDirection(e),this.setXYZ(n,cs.x,cs.y,cs.z);return this}setX(e,n){return this.normalized&&(n=Mr(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=Mr(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=Mr(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=Mr(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=ac(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=ac(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=ac(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=ac(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=Mr(n,this.array),r=Mr(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=Mr(n,this.array),r=Mr(r,this.array),i=Mr(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=Mr(n,this.array),r=Mr(r,this.array),i=Mr(i,this.array),s=Mr(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 go(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 Zd(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 X2e extends $s{constructor(e=null,n=1,r=1,i,s,o,l,c,u=ka,d=ka,f,m){super(null,o,l,c,u,d,i,s,f,m),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function Y2e(t,e){return t.z-e.z}function Q2e(t,e){return e.z-t.z}class Z2e{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 Kp="batchId",Pd=new Fr,v6=new Fr,J2e=new Fr,_6=new Fr,mA=new TN,Cw=new tl,xf=new hc,Vb=new qe,pA=new Z2e,Ga=new Rl,Tw=[];function eNe(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 o=0;o<r;o++)e.setComponent(s+n,o,t.getComponent(s,o))}else e.array.set(t.array,n*r);e.needsUpdate=!0}class tNe extends Rl{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new Ja,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 X2e(n,e,e,Ko,yu);this._matricesTexture=r}_initializeGeometry(e){const n=this.geometry,r=this._maxVertexCount,i=this._maxGeometryCount,s=this._maxIndexCount;if(this._geometryInitialized===!1){for(const l in e.attributes){const c=e.getAttribute(l),{array:u,itemSize:d,normalized:f}=c,m=new u.constructor(r*d),p=new c.constructor(m,d,f);p.setUsage(c.usage),n.setAttribute(l,p)}if(e.getIndex()!==null){const l=r>65536?new Uint32Array(s):new Uint16Array(s);n.setIndex(new go(l,1))}const o=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(Kp,new go(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Kp))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Kp}"`);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===Kp)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 tl);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,Pd),this.getBoundingBoxAt(i,Cw).applyMatrix4(Pd),n.union(Cw))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new hc);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,Pd),this.getBoundingSphereAt(i,xf).applyMatrix4(Pd),n.union(xf))}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 o=this._reservedRanges,l=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(s=o[o.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,m=this._active,p=this._matricesTexture,x=this._matricesTexture.image.data;f.push(!0),m.push(!0);const b=this._geometryCount;this._geometryCount++,J2e.toArray(x,b*16),p.needsUpdate=!0,o.push(i),l.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new tl,sphereInitialized:!1,sphere:new hc});const y=this.geometry.getAttribute(Kp);for(let v=0;v<i.vertexCount;v++)y.setX(i.vertexStart+v,b);return y.needsUpdate=!0,this.setGeometryAt(b,e),b}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(),o=n.getIndex(),l=this._reservedRanges[e];if(i&&o.count>l.indexCount||n.attributes.position.count>l.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const c=l.vertexStart,u=l.vertexCount;for(const p in r.attributes){if(p===Kp)continue;const x=n.getAttribute(p),b=r.getAttribute(p);eNe(x,b,c);const y=x.itemSize;for(let v=x.count,S=u;v<S;v++){const N=c+v;for(let C=0;C<y;C++)b.setComponent(N,C,0)}b.needsUpdate=!0}if(i){const p=l.indexStart;for(let x=0;x<o.count;x++)s.setX(p+x,c+o.getX(x));for(let x=o.count,b=l.indexCount;x<b;x++)s.setX(p+x,c);s.needsUpdate=!0}const d=this._bounds[e];n.boundingBox!==null?(d.box.copy(n.boundingBox),d.boxInitialized=!0):d.boxInitialized=!1,n.boundingSphere!==null?(d.sphere.copy(n.boundingSphere),d.sphereInitialized=!0):d.sphereInitialized=!1;const f=this._drawRanges[e],m=n.getAttribute("position");return f.count=i?o.count:m.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,o=this.geometry;if(i.boxInitialized===!1){s.makeEmpty();const l=o.index,c=o.attributes.position,u=this._drawRanges[e];for(let d=u.start,f=u.start+u.count;d<f;d++){let m=d;l&&(m=l.getX(m)),s.expandByPoint(Vb.fromBufferAttribute(c,m))}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,o=this.geometry;if(i.sphereInitialized===!1){s.makeEmpty(),this.getBoundingBoxAt(e,Cw),Cw.getCenter(s.center);const l=o.index,c=o.attributes.position,u=this._drawRanges[e];let d=0;for(let f=u.start,m=u.start+u.count;f<m;f++){let p=f;l&&(p=l.getX(p)),Vb.fromBufferAttribute(c,p),d=Math.max(d,s.center.distanceToSquared(Vb))}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,o=this._geometryCount;return e>=o||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,o=this._geometryCount,l=this.matrixWorld,c=this.geometry;Ga.material=this.material,Ga.geometry.index=c.index,Ga.geometry.attributes=c.attributes,Ga.geometry.boundingBox===null&&(Ga.geometry.boundingBox=new tl),Ga.geometry.boundingSphere===null&&(Ga.geometry.boundingSphere=new hc);for(let u=0;u<o;u++){if(!r[u]||!i[u])continue;const d=s[u];Ga.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,Ga.matrixWorld).premultiply(l),this.getBoundingBoxAt(u,Ga.geometry.boundingBox),this.getBoundingSphereAt(u,Ga.geometry.boundingSphere),Ga.raycast(e,Tw);for(let f=0,m=Tw.length;f<m;f++){const p=Tw[f];p.object=this,p.batchId=u,n.push(p)}Tw.length=0}Ga.material=null,Ga.geometry.index=null,Ga.geometry.attributes={},Ga.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 o=i.getIndex(),l=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,f=this._drawRanges,m=this.perObjectFrustumCulled;m&&(_6.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),mA.setFromProjectionMatrix(_6,e.isWebGPURenderer?ny:cc));let p=0;if(this.sortObjects){v6.copy(this.matrixWorld).invert(),Vb.setFromMatrixPosition(r.matrixWorld).applyMatrix4(v6);for(let y=0,v=c.length;y<v;y++)if(c[y]){this.getMatrixAt(y,Pd),this.getBoundingSphereAt(y,xf).applyMatrix4(Pd);let S=!1;if(m&&(S=!mA.intersectsSphere(xf)),!S){const N=Vb.distanceTo(xf.center);pA.push(f[y],N)}}const x=pA.list,b=this.customSort;b===null?x.sort(s.transparent?Q2e:Y2e):b.call(this,x,r);for(let y=0,v=x.length;y<v;y++){const S=x[y];u[p]=S.start*l,d[p]=S.count,p++}pA.reset()}else for(let x=0,b=c.length;x<b;x++)if(c[x]){let y=!1;if(m&&(this.getMatrixAt(x,Pd),this.getBoundingSphereAt(x,xf).applyMatrix4(Pd),y=!mA.intersectsSphere(xf)),!y){const v=f[x];u[p]=v.start*l,d[p]=v.count,p++}}this._multiDrawCount=p,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,s,o){this.onBeforeRender(e,null,i,s,o)}}class $y extends wx{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new en(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 w6=new qe,S6=new qe,N6=new Fr,gA=new o4,Aw=new hc;let nNe=class extends ys{constructor(e=new Ja,n=new $y){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++)w6.fromBufferAttribute(n,i-1),S6.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=w6.distanceTo(S6);e.setAttribute("lineDistance",new wi(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,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),Aw.copy(r.boundingSphere),Aw.applyMatrix4(i),Aw.radius+=s,e.ray.intersectsSphere(Aw)===!1)return;N6.copy(i).invert(),gA.copy(e.ray).applyMatrix4(N6);const l=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=new qe,d=new qe,f=new qe,m=new qe,p=this.isLineSegments?2:1,x=r.index,y=r.attributes.position;if(x!==null){const v=Math.max(0,o.start),S=Math.min(x.count,o.start+o.count);for(let N=v,C=S-1;N<C;N+=p){const T=x.getX(N),k=x.getX(N+1);if(u.fromBufferAttribute(y,T),d.fromBufferAttribute(y,k),gA.distanceSqToSegment(u,d,m,f)>c)continue;m.applyMatrix4(this.matrixWorld);const D=e.ray.origin.distanceTo(m);D<e.near||D>e.far||n.push({distance:D,point:f.clone().applyMatrix4(this.matrixWorld),index:N,face:null,faceIndex:null,object:this})}}else{const v=Math.max(0,o.start),S=Math.min(y.count,o.start+o.count);for(let N=v,C=S-1;N<C;N+=p){if(u.fromBufferAttribute(y,N),d.fromBufferAttribute(y,N+1),gA.distanceSqToSegment(u,d,m,f)>c)continue;m.applyMatrix4(this.matrixWorld);const k=e.ray.origin.distanceTo(m);k<e.near||k>e.far||n.push({distance:k,point:f.clone().applyMatrix4(this.matrixWorld),index:N,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,o=i.length;s<o;s++){const l=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=s}}}}};const M6=new qe,E6=new qe;class kN extends nNe{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)M6.fromBufferAttribute(n,i),E6.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+M6.distanceTo(E6);e.setAttribute("lineDistance",new wi(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class rNe extends Ja{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new qe,s=new qe;if(e.index!==null){const o=e.attributes.position,l=e.index;let c=e.groups;c.length===0&&(c=[{start:0,count:l.count,materialIndex:0}]);for(let u=0,d=c.length;u<d;++u){const f=c[u],m=f.start,p=f.count;for(let x=m,b=m+p;x<b;x+=3)for(let y=0;y<3;y++){const v=l.getX(x+y),S=l.getX(x+(y+1)%3);i.fromBufferAttribute(o,v),s.fromBufferAttribute(o,S),C6(i,s,r)===!0&&(n.push(i.x,i.y,i.z),n.push(s.x,s.y,s.z))}}}else{const o=e.attributes.position;for(let l=0,c=o.count/3;l<c;l++)for(let u=0;u<3;u++){const d=3*l+u,f=3*l+(u+1)%3;i.fromBufferAttribute(o,d),s.fromBufferAttribute(o,f),C6(i,s,r)===!0&&(n.push(i.x,i.y,i.z),n.push(s.x,s.y,s.z))}}this.setAttribute("position",new wi(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function C6(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 iNe extends wx{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new en(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new en(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=FK,this.normalScale=new xn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=r4,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 aNe extends $y{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 sX extends ys{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new en(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 xA=new Fr,T6=new qe,A6=new qe;class sNe{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new xn(512,512),this.map=null,this.mapPass=null,this.matrix=new Fr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new TN,this._frameExtents=new xn(1,1),this._viewportCount=1,this._viewports=[new Ar(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;T6.setFromMatrixPosition(e.matrixWorld),n.position.copy(T6),A6.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(A6),n.updateMatrixWorld(),xA.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(xA),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(xA)}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 k6=new Fr,Gb=new qe,bA=new qe;class oNe extends sNe{constructor(){super(new lo(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new xn(4,2),this._viewportCount=6,this._viewports=[new Ar(2,1,1,1),new Ar(0,1,1,1),new Ar(3,1,1,1),new Ar(1,1,1,1),new Ar(3,0,1,1),new Ar(1,0,1,1)],this._cubeDirections=[new qe(1,0,0),new qe(-1,0,0),new qe(0,0,1),new qe(0,0,-1),new qe(0,1,0),new qe(0,-1,0)],this._cubeUps=[new qe(0,1,0),new qe(0,1,0),new qe(0,1,0),new qe(0,1,0),new qe(0,0,1),new qe(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()),Gb.setFromMatrixPosition(e.matrixWorld),r.position.copy(Gb),bA.copy(r.position),bA.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(bA),r.updateMatrixWorld(),i.makeTranslation(-Gb.x,-Gb.y,-Gb.z),k6.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(k6)}}class lNe extends sX{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 oNe}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 cNe extends sX{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class uNe extends Ja{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 wP extends K2e{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 j6{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(Pa(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const P6=new qe,kw=new qe;class dNe{constructor(e=new qe,n=new qe){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){P6.subVectors(e,this.start),kw.subVectors(this.end,this.start);const r=kw.dot(kw);let s=kw.dot(P6)/r;return n&&(s=Pa(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 hNe extends kN{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 Ja;i.setAttribute("position",new wi(n,3)),i.setAttribute("color",new wi(r,3));const s=new $y({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,n,r){const i=new en,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:MN}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=MN);class fc{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"),fc.nextNameID=fc.nextNameID||0,this.$name.id=`lil-gui-name-${++fc.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",o=>o.stopPropagation()),this.domElement.addEventListener("keyup",o=>o.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 fNe extends fc{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 SP(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 mNe={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:SP,toHexString:SP},iy={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},pNe={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=iy.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 iy.toHexString(i)}},gNe={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=iy.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 iy.toHexString(i)}},xNe=[mNe,iy,pNe,gNe];function bNe(t){return xNe.find(e=>e.match(t))}class yNe extends fc{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=bNe(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=SP(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 yA extends fc{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 vNe extends fc{constructor(e,n,r,i,s,o){super(e,n,r,"number"),this._initInput(),this.min(i),this.max(s);const l=o!==void 0;this.step(l?o:this._getImplicitStep(),l),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 S=parseFloat(this.$input.value);isNaN(S)||(this._stepExplicit&&(S=this._snap(S)),this.setValue(this._clamp(S)))},r=S=>{const N=parseFloat(this.$input.value);isNaN(N)||(this._snapClampSetValue(N+S),this.$input.value=this.getValue())},i=S=>{S.key==="Enter"&&this.$input.blur(),S.code==="ArrowUp"&&(S.preventDefault(),r(this._step*this._arrowKeyMultiplier(S))),S.code==="ArrowDown"&&(S.preventDefault(),r(this._step*this._arrowKeyMultiplier(S)*-1))},s=S=>{this._inputFocused&&(S.preventDefault(),r(this._step*this._normalizeMouseWheel(S)))};let o=!1,l,c,u,d,f;const m=5,p=S=>{l=S.clientX,c=u=S.clientY,o=!0,d=this.getValue(),f=0,window.addEventListener("mousemove",x),window.addEventListener("mouseup",b)},x=S=>{if(o){const N=S.clientX-l,C=S.clientY-c;Math.abs(C)>m?(S.preventDefault(),this.$input.blur(),o=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(N)>m&&b()}if(!o){const N=S.clientY-u;f-=N*this._step*this._arrowKeyMultiplier(S),d+f>this._max?f=this._max-d:d+f<this._min&&(f=this._min-d),this._snapClampSetValue(d+f)}u=S.clientY},b=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",b)},y=()=>{this._inputFocused=!0},v=()=>{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",p),this.$input.addEventListener("focus",y),this.$input.addEventListener("blur",v)}_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=(v,S,N,C,T)=>(v-S)/(N-S)*(T-C)+C,n=v=>{const S=this.$slider.getBoundingClientRect();let N=e(v,S.left,S.right,this._min,this._max);this._snapClampSetValue(N)},r=v=>{this._setDraggingStyle(!0),n(v.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",s)},i=v=>{n(v.clientX)},s=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",s)};let o=!1,l,c;const u=v=>{v.preventDefault(),this._setDraggingStyle(!0),n(v.touches[0].clientX),o=!1},d=v=>{v.touches.length>1||(this._hasScrollBar?(l=v.touches[0].clientX,c=v.touches[0].clientY,o=!0):u(v),window.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("touchend",m))},f=v=>{if(o){const S=v.touches[0].clientX-l,N=v.touches[0].clientY-c;Math.abs(S)>Math.abs(N)?u(v):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",m))}else v.preventDefault(),n(v.touches[0].clientX)},m=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",m)},p=this._callOnFinishChange.bind(this),x=400;let b;const y=v=>{if(Math.abs(v.deltaX)<Math.abs(v.deltaY)&&this._hasScrollBar)return;v.preventDefault();const N=this._normalizeMouseWheel(v)*this._step;this._snapClampSetValue(this.getValue()+N),this.$input.value=this.getValue(),clearTimeout(b),b=setTimeout(p,x)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",d,{passive:!1}),this.$slider.addEventListener("wheel",y,{passive:!1})}_setDraggingStyle(e,n="horizontal"){this.$slider&&this.$slider.classList.toggle("active",e),document.body.classList.toggle("lil-gui-dragging",e),document.body.classList.toggle(`lil-gui-${n}`,e)}_getImplicitStep(){return this._hasMin&&this._hasMax?(this._max-this._min)/1e3:.1}_onUpdateMinMax(){!this._hasSlider&&this._hasMin&&this._hasMax&&(this._stepExplicit||this.step(this._getImplicitStep(),!1),this._initSlider(),this.updateDisplay())}_normalizeMouseWheel(e){let{deltaX:n,deltaY:r}=e;return Math.floor(e.deltaY)!==e.deltaY&&e.wheelDelta&&(n=0,r=-e.wheelDelta/120,r*=this._stepExplicit?1:10),n+-r}_arrowKeyMultiplier(e){let n=this._stepExplicit?1:10;return e.shiftKey?n*=10:e.altKey&&(n/=10),n}_snap(e){const n=Math.round(e/this._step)*this._step;return parseFloat(n.toPrecision(15))}_clamp(e){return e<this._min&&(e=this._min),e>this._max&&(e=this._max),e}_snapClampSetValue(e){this.setValue(this._clamp(this._snap(e)))}get _hasScrollBar(){const e=this.parent.root.$children;return e.scrollHeight>e.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}}class _Ne extends fc{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 wNe extends fc{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 SNe=`.lil-gui {
  7397. font-family: var(--font-family);
  7398. font-size: var(--font-size);
  7399. line-height: 1;
  7400. font-weight: normal;
  7401. font-style: normal;
  7402. text-align: left;
  7403. color: var(--text-color);
  7404. user-select: none;
  7405. -webkit-user-select: none;
  7406. touch-action: manipulation;
  7407. --background-color: #1f1f1f;
  7408. --text-color: #ebebeb;
  7409. --title-background-color: #111111;
  7410. --title-text-color: #ebebeb;
  7411. --widget-color: #424242;
  7412. --hover-color: #4f4f4f;
  7413. --focus-color: #595959;
  7414. --number-color: #2cc9ff;
  7415. --string-color: #a2db3c;
  7416. --font-size: 11px;
  7417. --input-font-size: 11px;
  7418. --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  7419. --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
  7420. --padding: 4px;
  7421. --spacing: 4px;
  7422. --widget-height: 20px;
  7423. --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
  7424. --name-width: 45%;
  7425. --slider-knob-width: 2px;
  7426. --slider-input-width: 27%;
  7427. --color-input-width: 27%;
  7428. --slider-input-min-width: 45px;
  7429. --color-input-min-width: 45px;
  7430. --folder-indent: 7px;
  7431. --widget-padding: 0 0 0 3px;
  7432. --widget-border-radius: 2px;
  7433. --checkbox-size: calc(0.75 * var(--widget-height));
  7434. --scrollbar-width: 5px;
  7435. }
  7436. .lil-gui, .lil-gui * {
  7437. box-sizing: border-box;
  7438. margin: 0;
  7439. padding: 0;
  7440. }
  7441. .lil-gui.root {
  7442. width: var(--width, 245px);
  7443. display: flex;
  7444. flex-direction: column;
  7445. background: var(--background-color);
  7446. }
  7447. .lil-gui.root > .title {
  7448. background: var(--title-background-color);
  7449. color: var(--title-text-color);
  7450. }
  7451. .lil-gui.root > .children {
  7452. overflow-x: hidden;
  7453. overflow-y: auto;
  7454. }
  7455. .lil-gui.root > .children::-webkit-scrollbar {
  7456. width: var(--scrollbar-width);
  7457. height: var(--scrollbar-width);
  7458. background: var(--background-color);
  7459. }
  7460. .lil-gui.root > .children::-webkit-scrollbar-thumb {
  7461. border-radius: var(--scrollbar-width);
  7462. background: var(--focus-color);
  7463. }
  7464. @media (pointer: coarse) {
  7465. .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
  7466. --widget-height: 28px;
  7467. --padding: 6px;
  7468. --spacing: 6px;
  7469. --font-size: 13px;
  7470. --input-font-size: 16px;
  7471. --folder-indent: 10px;
  7472. --scrollbar-width: 7px;
  7473. --slider-input-min-width: 50px;
  7474. --color-input-min-width: 65px;
  7475. }
  7476. }
  7477. .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
  7478. --widget-height: 28px;
  7479. --padding: 6px;
  7480. --spacing: 6px;
  7481. --font-size: 13px;
  7482. --input-font-size: 16px;
  7483. --folder-indent: 10px;
  7484. --scrollbar-width: 7px;
  7485. --slider-input-min-width: 50px;
  7486. --color-input-min-width: 65px;
  7487. }
  7488. .lil-gui.autoPlace {
  7489. max-height: 100%;
  7490. position: fixed;
  7491. top: 0;
  7492. right: 15px;
  7493. z-index: 1001;
  7494. }
  7495. .lil-gui .controller {
  7496. display: flex;
  7497. align-items: center;
  7498. padding: 0 var(--padding);
  7499. margin: var(--spacing) 0;
  7500. }
  7501. .lil-gui .controller.disabled {
  7502. opacity: 0.5;
  7503. }
  7504. .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
  7505. pointer-events: none !important;
  7506. }
  7507. .lil-gui .controller > .name {
  7508. min-width: var(--name-width);
  7509. flex-shrink: 0;
  7510. white-space: pre;
  7511. padding-right: var(--spacing);
  7512. line-height: var(--widget-height);
  7513. }
  7514. .lil-gui .controller .widget {
  7515. position: relative;
  7516. display: flex;
  7517. align-items: center;
  7518. width: 100%;
  7519. min-height: var(--widget-height);
  7520. }
  7521. .lil-gui .controller.string input {
  7522. color: var(--string-color);
  7523. }
  7524. .lil-gui .controller.boolean {
  7525. cursor: pointer;
  7526. }
  7527. .lil-gui .controller.color .display {
  7528. width: 100%;
  7529. height: var(--widget-height);
  7530. border-radius: var(--widget-border-radius);
  7531. position: relative;
  7532. }
  7533. @media (hover: hover) {
  7534. .lil-gui .controller.color .display:hover:before {
  7535. content: " ";
  7536. display: block;
  7537. position: absolute;
  7538. border-radius: var(--widget-border-radius);
  7539. border: 1px solid #fff9;
  7540. top: 0;
  7541. right: 0;
  7542. bottom: 0;
  7543. left: 0;
  7544. }
  7545. }
  7546. .lil-gui .controller.color input[type=color] {
  7547. opacity: 0;
  7548. width: 100%;
  7549. height: 100%;
  7550. cursor: pointer;
  7551. }
  7552. .lil-gui .controller.color input[type=text] {
  7553. margin-left: var(--spacing);
  7554. font-family: var(--font-family-mono);
  7555. min-width: var(--color-input-min-width);
  7556. width: var(--color-input-width);
  7557. flex-shrink: 0;
  7558. }
  7559. .lil-gui .controller.option select {
  7560. opacity: 0;
  7561. position: absolute;
  7562. width: 100%;
  7563. max-width: 100%;
  7564. }
  7565. .lil-gui .controller.option .display {
  7566. position: relative;
  7567. pointer-events: none;
  7568. border-radius: var(--widget-border-radius);
  7569. height: var(--widget-height);
  7570. line-height: var(--widget-height);
  7571. max-width: 100%;
  7572. overflow: hidden;
  7573. word-break: break-all;
  7574. padding-left: 0.55em;
  7575. padding-right: 1.75em;
  7576. background: var(--widget-color);
  7577. }
  7578. @media (hover: hover) {
  7579. .lil-gui .controller.option .display.focus {
  7580. background: var(--focus-color);
  7581. }
  7582. }
  7583. .lil-gui .controller.option .display.active {
  7584. background: var(--focus-color);
  7585. }
  7586. .lil-gui .controller.option .display:after {
  7587. font-family: "lil-gui";
  7588. content: "↕";
  7589. position: absolute;
  7590. top: 0;
  7591. right: 0;
  7592. bottom: 0;
  7593. padding-right: 0.375em;
  7594. }
  7595. .lil-gui .controller.option .widget,
  7596. .lil-gui .controller.option select {
  7597. cursor: pointer;
  7598. }
  7599. @media (hover: hover) {
  7600. .lil-gui .controller.option .widget:hover .display {
  7601. background: var(--hover-color);
  7602. }
  7603. }
  7604. .lil-gui .controller.number input {
  7605. color: var(--number-color);
  7606. }
  7607. .lil-gui .controller.number.hasSlider input {
  7608. margin-left: var(--spacing);
  7609. width: var(--slider-input-width);
  7610. min-width: var(--slider-input-min-width);
  7611. flex-shrink: 0;
  7612. }
  7613. .lil-gui .controller.number .slider {
  7614. width: 100%;
  7615. height: var(--widget-height);
  7616. background: var(--widget-color);
  7617. border-radius: var(--widget-border-radius);
  7618. padding-right: var(--slider-knob-width);
  7619. overflow: hidden;
  7620. cursor: ew-resize;
  7621. touch-action: pan-y;
  7622. }
  7623. @media (hover: hover) {
  7624. .lil-gui .controller.number .slider:hover {
  7625. background: var(--hover-color);
  7626. }
  7627. }
  7628. .lil-gui .controller.number .slider.active {
  7629. background: var(--focus-color);
  7630. }
  7631. .lil-gui .controller.number .slider.active .fill {
  7632. opacity: 0.95;
  7633. }
  7634. .lil-gui .controller.number .fill {
  7635. height: 100%;
  7636. border-right: var(--slider-knob-width) solid var(--number-color);
  7637. box-sizing: content-box;
  7638. }
  7639. .lil-gui-dragging .lil-gui {
  7640. --hover-color: var(--widget-color);
  7641. }
  7642. .lil-gui-dragging * {
  7643. cursor: ew-resize !important;
  7644. }
  7645. .lil-gui-dragging.lil-gui-vertical * {
  7646. cursor: ns-resize !important;
  7647. }
  7648. .lil-gui .title {
  7649. height: var(--title-height);
  7650. line-height: calc(var(--title-height) - 4px);
  7651. font-weight: 600;
  7652. padding: 0 var(--padding);
  7653. -webkit-tap-highlight-color: transparent;
  7654. cursor: pointer;
  7655. outline: none;
  7656. text-decoration-skip: objects;
  7657. }
  7658. .lil-gui .title:before {
  7659. font-family: "lil-gui";
  7660. content: "▾";
  7661. padding-right: 2px;
  7662. display: inline-block;
  7663. }
  7664. .lil-gui .title:active {
  7665. background: var(--title-background-color);
  7666. opacity: 0.75;
  7667. }
  7668. @media (hover: hover) {
  7669. body:not(.lil-gui-dragging) .lil-gui .title:hover {
  7670. background: var(--title-background-color);
  7671. opacity: 0.85;
  7672. }
  7673. .lil-gui .title:focus {
  7674. text-decoration: underline var(--focus-color);
  7675. }
  7676. }
  7677. .lil-gui.root > .title:focus {
  7678. text-decoration: none !important;
  7679. }
  7680. .lil-gui.closed > .title:before {
  7681. content: "▸";
  7682. }
  7683. .lil-gui.closed > .children {
  7684. transform: translateY(-7px);
  7685. opacity: 0;
  7686. }
  7687. .lil-gui.closed:not(.transition) > .children {
  7688. display: none;
  7689. }
  7690. .lil-gui.transition > .children {
  7691. transition-duration: 300ms;
  7692. transition-property: height, opacity, transform;
  7693. transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
  7694. overflow: hidden;
  7695. pointer-events: none;
  7696. }
  7697. .lil-gui .children:empty:before {
  7698. content: "Empty";
  7699. padding: 0 var(--padding);
  7700. margin: var(--spacing) 0;
  7701. display: block;
  7702. height: var(--widget-height);
  7703. font-style: italic;
  7704. line-height: var(--widget-height);
  7705. opacity: 0.5;
  7706. }
  7707. .lil-gui.root > .children > .lil-gui > .title {
  7708. border: 0 solid var(--widget-color);
  7709. border-width: 1px 0;
  7710. transition: border-color 300ms;
  7711. }
  7712. .lil-gui.root > .children > .lil-gui.closed > .title {
  7713. border-bottom-color: transparent;
  7714. }
  7715. .lil-gui + .controller {
  7716. border-top: 1px solid var(--widget-color);
  7717. margin-top: 0;
  7718. padding-top: var(--spacing);
  7719. }
  7720. .lil-gui .lil-gui .lil-gui > .title {
  7721. border: none;
  7722. }
  7723. .lil-gui .lil-gui .lil-gui > .children {
  7724. border: none;
  7725. margin-left: var(--folder-indent);
  7726. border-left: 2px solid var(--widget-color);
  7727. }
  7728. .lil-gui .lil-gui .controller {
  7729. border: none;
  7730. }
  7731. .lil-gui label, .lil-gui input, .lil-gui button {
  7732. -webkit-tap-highlight-color: transparent;
  7733. }
  7734. .lil-gui input {
  7735. border: 0;
  7736. outline: none;
  7737. font-family: var(--font-family);
  7738. font-size: var(--input-font-size);
  7739. border-radius: var(--widget-border-radius);
  7740. height: var(--widget-height);
  7741. background: var(--widget-color);
  7742. color: var(--text-color);
  7743. width: 100%;
  7744. }
  7745. @media (hover: hover) {
  7746. .lil-gui input:hover {
  7747. background: var(--hover-color);
  7748. }
  7749. .lil-gui input:active {
  7750. background: var(--focus-color);
  7751. }
  7752. }
  7753. .lil-gui input:disabled {
  7754. opacity: 1;
  7755. }
  7756. .lil-gui input[type=text],
  7757. .lil-gui input[type=number] {
  7758. padding: var(--widget-padding);
  7759. -moz-appearance: textfield;
  7760. }
  7761. .lil-gui input[type=text]:focus,
  7762. .lil-gui input[type=number]:focus {
  7763. background: var(--focus-color);
  7764. }
  7765. .lil-gui input[type=checkbox] {
  7766. appearance: none;
  7767. width: var(--checkbox-size);
  7768. height: var(--checkbox-size);
  7769. border-radius: var(--widget-border-radius);
  7770. text-align: center;
  7771. cursor: pointer;
  7772. }
  7773. .lil-gui input[type=checkbox]:checked:before {
  7774. font-family: "lil-gui";
  7775. content: "✓";
  7776. font-size: var(--checkbox-size);
  7777. line-height: var(--checkbox-size);
  7778. }
  7779. @media (hover: hover) {
  7780. .lil-gui input[type=checkbox]:focus {
  7781. box-shadow: inset 0 0 0 1px var(--focus-color);
  7782. }
  7783. }
  7784. .lil-gui button {
  7785. outline: none;
  7786. cursor: pointer;
  7787. font-family: var(--font-family);
  7788. font-size: var(--font-size);
  7789. color: var(--text-color);
  7790. width: 100%;
  7791. height: var(--widget-height);
  7792. text-transform: none;
  7793. background: var(--widget-color);
  7794. border-radius: var(--widget-border-radius);
  7795. border: none;
  7796. }
  7797. @media (hover: hover) {
  7798. .lil-gui button:hover {
  7799. background: var(--hover-color);
  7800. }
  7801. .lil-gui button:focus {
  7802. box-shadow: inset 0 0 0 1px var(--focus-color);
  7803. }
  7804. }
  7805. .lil-gui button:active {
  7806. background: var(--focus-color);
  7807. }
  7808. @font-face {
  7809. font-family: "lil-gui";
  7810. 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");
  7811. }`;function NNe(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 R6=!1;class oS{constructor({parent:e,autoPlace:n=e===void 0,container:r,width:i,title:s="Controls",closeFolders:o=!1,injectStyles:l=!0,touchStyles:c=!0}={}){if(this.parent=e,this.root=e?e.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",u=>{(u.code==="Enter"||u.code==="Space")&&(u.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(s),this.parent){this.parent.children.push(this),this.parent.folders.push(this),this.parent.$children.appendChild(this.domElement);return}this.domElement.classList.add("root"),c&&this.domElement.classList.add("allow-touch-styles"),!R6&&l&&(NNe(SNe),R6=!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=o}add(e,n,r,i,s){if(Object(r)===r)return new _Ne(this,e,n,r);const o=e[n];switch(typeof o){case"number":return new vNe(this,e,n,r,i,s);case"boolean":return new fNe(this,e,n);case"string":return new wNe(this,e,n);case"function":return new yA(this,e,n)}console.error(`gui.add failed
  7812. property:`,n,`
  7813. object:`,e,`
  7814. value:`,o)}addColor(e,n,r=1){return new yNe(this,e,n,r)}addFolder(e){const n=new oS({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof yA||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 yA)){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 vA(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(u){try{c(r.next(u))}catch(d){s(d)}}function l(u){try{c(r.throw(u))}catch(d){s(d)}}function c(u){var d;u.done?i(u.value):(d=u.value,d instanceof n?d:new n((function(f){f(d)}))).then(o,l)}c((r=r.apply(t,[])).next())}))}class h4{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 h4(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 f4{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class D6 extends f4{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class Rd extends f4{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class O6{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class lS{constructor(e){this.lines=[],this.preamble=new O6(-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(`
  7815. `);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,o]of Object.entries(i))this.metadata.thumbnails[s]=o;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],o=n&&i[1]||void 0,l=s.split(/([a-zA-Z])/g).slice(1).map((d=>d.trim())),c=l.length?`${(r=l[0])===null||r===void 0?void 0:r.toLowerCase()}${l[1]}`:"",u=this.parseParams(l.slice(2));switch(c){case"g0":case"g00":case"g1":case"g01":case"g2":case"g02":case"g3":case"g03":return new D6(e,c,u,o);case"t0":return new Rd(e,c,o,0);case"t1":return new Rd(e,c,o,1);case"t2":return new Rd(e,c,o,2);case"t3":return new Rd(e,c,o,3);case"t4":return new Rd(e,c,o,4);case"t5":return new Rd(e,c,o,5);case"t6":return new Rd(e,c,o,6);case"t7":return new Rd(e,c,o,7);default:return new f4(e,c,u,o)}}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 o=s[i-1];return o=o.toLowerCase(),this.isAlpha(o)&&(n[o]=parseFloat(r)),n}),{})}groupIntoLayers(e){var n;for(let r=0;r<e.length;r++){const i=e[r];if(i instanceof D6){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 o=Math.abs(this.curZ-this.maxZ);this.maxZ=this.curZ,this.layers.push(new O6(this.layers.length,[],r,o))}}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 o=s.indexOf("thumbnail begin"),l=s.indexOf("thumbnail end");o>-1?r=h4.parse(s.slice(o+15).trim()):r&&(l==-1?r.chars+=s.trim():(r.isValid&&(n[r.size]=r),r=void 0))}return{thumbnails:n}}}lS.prototype.parseGcode=lS.prototype.parseGCode;const L6={type:"change"},_A={type:"start"},I6={type:"end"},jw=new o4,F6=new Ud,MNe=Math.cos(70*zK.DEG2RAD);class ENe extends Cm{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new qe,this.cursor=new qe,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.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:kp.ROTATE,MIDDLE:kp.DOLLY,RIGHT:kp.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.getPolarAngle=function(){return l.phi},this.getAzimuthalAngle=function(){return l.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(K){K.addEventListener("keydown",Ue),this._domElementKeyEvents=K},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Ue),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(L6),r.update(),s=i.NONE},this.update=(function(){const K=new qe,J=new hm().setFromUnitVectors(e.up,new qe(0,1,0)),Q=J.clone().invert(),z=new qe,re=new hm,Ee=new qe,_e=2*Math.PI;return function(Te=null){const V=r.object.position;K.copy(V).sub(r.target),K.applyQuaternion(J),l.setFromVector3(K),r.autoRotate&&s===i.NONE&&R((function(Me){return Me!==null?2*Math.PI/60*r.autoRotateSpeed*Me:2*Math.PI/60/60*r.autoRotateSpeed})(Te)),r.enableDamping?(l.theta+=c.theta*r.dampingFactor,l.phi+=c.phi*r.dampingFactor):(l.theta+=c.theta,l.phi+=c.phi);let L=r.minAzimuthAngle,X=r.maxAzimuthAngle;isFinite(L)&&isFinite(X)&&(L<-Math.PI?L+=_e:L>Math.PI&&(L-=_e),X<-Math.PI?X+=_e:X>Math.PI&&(X-=_e),l.theta=L<=X?Math.max(L,Math.min(X,l.theta)):l.theta>(L+X)/2?Math.max(L,l.theta):Math.min(X,l.theta)),l.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,l.phi)),l.makeSafe(),r.enableDamping===!0?r.target.addScaledVector(d,r.dampingFactor):r.target.add(d),r.target.sub(r.cursor),r.target.clampLength(r.minTargetRadius,r.maxTargetRadius),r.target.add(r.cursor),r.zoomToCursor&&k||r.object.isOrthographicCamera?l.radius=Y(l.radius):l.radius=Y(l.radius*u),K.setFromSpherical(l),K.applyQuaternion(Q),V.copy(r.target).add(K),r.object.lookAt(r.target),r.enableDamping===!0?(c.theta*=1-r.dampingFactor,c.phi*=1-r.dampingFactor,d.multiplyScalar(1-r.dampingFactor)):(c.set(0,0,0),d.set(0,0,0));let te=!1;if(r.zoomToCursor&&k){let Me=null;if(r.object.isPerspectiveCamera){const ie=K.length();Me=Y(ie*u);const De=ie-Me;r.object.position.addScaledVector(C,De),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const ie=new qe(T.x,T.y,0);ie.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),te=!0;const De=new qe(T.x,T.y,0);De.unproject(r.object),r.object.position.sub(De).add(ie),r.object.updateMatrixWorld(),Me=K.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;Me!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(Me).add(r.object.position):(jw.origin.copy(r.object.position),jw.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(jw.direction))<MNe?e.lookAt(r.target):(F6.setFromNormalAndCoplanarPoint(r.object.up,r.target),jw.intersectPlane(F6,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),te=!0);return u=1,k=!1,!!(te||z.distanceToSquared(r.object.position)>o||8*(1-re.dot(r.object.quaternion))>o||Ee.distanceToSquared(r.target)>0)&&(r.dispatchEvent(L6),z.copy(r.object.position),re.copy(r.object.quaternion),Ee.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",be),r.domElement.removeEventListener("pointerdown",ye),r.domElement.removeEventListener("pointercancel",xe),r.domElement.removeEventListener("wheel",Pe),r.domElement.removeEventListener("pointermove",ge),r.domElement.removeEventListener("pointerup",xe),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",Ue),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 o=1e-6,l=new j6,c=new j6;let u=1;const d=new qe,f=new xn,m=new xn,p=new xn,x=new xn,b=new xn,y=new xn,v=new xn,S=new xn,N=new xn,C=new qe,T=new xn;let k=!1;const E=[],D={};function A(){return Math.pow(.95,r.zoomSpeed)}function R(K){c.theta-=K}function F(K){c.phi-=K}const O=(function(){const K=new qe;return function(J,Q){K.setFromMatrixColumn(Q,0),K.multiplyScalar(-J),d.add(K)}})(),H=(function(){const K=new qe;return function(J,Q){r.screenSpacePanning===!0?K.setFromMatrixColumn(Q,1):(K.setFromMatrixColumn(Q,0),K.crossVectors(r.object.up,K)),K.multiplyScalar(J),d.add(K)}})(),j=(function(){const K=new qe;return function(J,Q){const z=r.domElement;if(r.object.isPerspectiveCamera){const re=r.object.position;K.copy(re).sub(r.target);let Ee=K.length();Ee*=Math.tan(r.object.fov/2*Math.PI/180),O(2*J*Ee/z.clientHeight,r.object.matrix),H(2*Q*Ee/z.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(O(J*(r.object.right-r.object.left)/r.object.zoom/z.clientWidth,r.object.matrix),H(Q*(r.object.top-r.object.bottom)/r.object.zoom/z.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function G(K){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=K:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function $(K){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=K:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function q(K){if(!r.zoomToCursor)return;k=!0;const J=r.domElement.getBoundingClientRect(),Q=K.clientX-J.left,z=K.clientY-J.top,re=J.width,Ee=J.height;T.x=Q/re*2-1,T.y=-z/Ee*2+1,C.set(T.x,T.y,1).unproject(r.object).sub(r.object.position).normalize()}function Y(K){return Math.max(r.minDistance,Math.min(r.maxDistance,K))}function Z(K){f.set(K.clientX,K.clientY)}function oe(K){x.set(K.clientX,K.clientY)}function B(){if(E.length===1)f.set(E[0].pageX,E[0].pageY);else{const K=.5*(E[0].pageX+E[1].pageX),J=.5*(E[0].pageY+E[1].pageY);f.set(K,J)}}function W(){if(E.length===1)x.set(E[0].pageX,E[0].pageY);else{const K=.5*(E[0].pageX+E[1].pageX),J=.5*(E[0].pageY+E[1].pageY);x.set(K,J)}}function se(){const K=E[0].pageX-E[1].pageX,J=E[0].pageY-E[1].pageY,Q=Math.sqrt(K*K+J*J);v.set(0,Q)}function ne(K){if(E.length==1)m.set(K.pageX,K.pageY);else{const Q=U(K),z=.5*(K.pageX+Q.x),re=.5*(K.pageY+Q.y);m.set(z,re)}p.subVectors(m,f).multiplyScalar(r.rotateSpeed);const J=r.domElement;R(2*Math.PI*p.x/J.clientHeight),F(2*Math.PI*p.y/J.clientHeight),f.copy(m)}function ce(K){if(E.length===1)b.set(K.pageX,K.pageY);else{const J=U(K),Q=.5*(K.pageX+J.x),z=.5*(K.pageY+J.y);b.set(Q,z)}y.subVectors(b,x).multiplyScalar(r.panSpeed),j(y.x,y.y),x.copy(b)}function fe(K){const J=U(K),Q=K.pageX-J.x,z=K.pageY-J.y,re=Math.sqrt(Q*Q+z*z);S.set(0,re),N.set(0,Math.pow(S.y/v.y,r.zoomSpeed)),G(N.y),v.copy(S)}function ye(K){r.enabled!==!1&&(E.length===0&&(r.domElement.setPointerCapture(K.pointerId),r.domElement.addEventListener("pointermove",ge),r.domElement.addEventListener("pointerup",xe)),(function(J){E.push(J)})(K),K.pointerType==="touch"?(function(J){switch(it(J),E.length){case 1:switch(r.touches.ONE){case jp.ROTATE:if(r.enableRotate===!1)return;B(),s=i.TOUCH_ROTATE;break;case jp.PAN:if(r.enablePan===!1)return;W(),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(r.touches.TWO){case jp.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&se(),r.enablePan&&W(),s=i.TOUCH_DOLLY_PAN;break;case jp.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&se(),r.enableRotate&&B(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(_A)})(K):(function(J){let Q;switch(J.button){case 0:Q=r.mouseButtons.LEFT;break;case 1:Q=r.mouseButtons.MIDDLE;break;case 2:Q=r.mouseButtons.RIGHT;break;default:Q=-1}switch(Q){case kp.DOLLY:if(r.enableZoom===!1)return;(function(z){q(z),v.set(z.clientX,z.clientY)})(J),s=i.DOLLY;break;case kp.ROTATE:if(J.ctrlKey||J.metaKey||J.shiftKey){if(r.enablePan===!1)return;oe(J),s=i.PAN}else{if(r.enableRotate===!1)return;Z(J),s=i.ROTATE}break;case kp.PAN:if(J.ctrlKey||J.metaKey||J.shiftKey){if(r.enableRotate===!1)return;Z(J),s=i.ROTATE}else{if(r.enablePan===!1)return;oe(J),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(_A)})(K))}function ge(K){r.enabled!==!1&&(K.pointerType==="touch"?(function(J){switch(it(J),s){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;ne(J),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;ce(J),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(Q){r.enableZoom&&fe(Q),r.enablePan&&ce(Q)})(J),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(Q){r.enableZoom&&fe(Q),r.enableRotate&&ne(Q)})(J),r.update();break;default:s=i.NONE}})(K):(function(J){switch(s){case i.ROTATE:if(r.enableRotate===!1)return;(function(Q){m.set(Q.clientX,Q.clientY),p.subVectors(m,f).multiplyScalar(r.rotateSpeed);const z=r.domElement;R(2*Math.PI*p.x/z.clientHeight),F(2*Math.PI*p.y/z.clientHeight),f.copy(m),r.update()})(J);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(Q){S.set(Q.clientX,Q.clientY),N.subVectors(S,v),N.y>0?G(A()):N.y<0&&$(A()),v.copy(S),r.update()})(J);break;case i.PAN:if(r.enablePan===!1)return;(function(Q){b.set(Q.clientX,Q.clientY),y.subVectors(b,x).multiplyScalar(r.panSpeed),j(y.x,y.y),x.copy(b),r.update()})(J)}})(K))}function xe(K){(function(J){delete D[J.pointerId];for(let Q=0;Q<E.length;Q++)if(E[Q].pointerId==J.pointerId)return void E.splice(Q,1)})(K),E.length===0&&(r.domElement.releasePointerCapture(K.pointerId),r.domElement.removeEventListener("pointermove",ge),r.domElement.removeEventListener("pointerup",xe)),r.dispatchEvent(I6),s=i.NONE}function Pe(K){r.enabled!==!1&&r.enableZoom!==!1&&s===i.NONE&&(K.preventDefault(),r.dispatchEvent(_A),(function(J){q(J),J.deltaY<0?$(A()):J.deltaY>0&&G(A()),r.update()})(K),r.dispatchEvent(I6))}function Ue(K){r.enabled!==!1&&r.enablePan!==!1&&(function(J){let Q=!1;switch(J.code){case r.keys.UP:J.ctrlKey||J.metaKey||J.shiftKey?F(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(0,r.keyPanSpeed),Q=!0;break;case r.keys.BOTTOM:J.ctrlKey||J.metaKey||J.shiftKey?F(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(0,-r.keyPanSpeed),Q=!0;break;case r.keys.LEFT:J.ctrlKey||J.metaKey||J.shiftKey?R(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(r.keyPanSpeed,0),Q=!0;break;case r.keys.RIGHT:J.ctrlKey||J.metaKey||J.shiftKey?R(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(-r.keyPanSpeed,0),Q=!0}Q&&(J.preventDefault(),r.update())})(K)}function be(K){r.enabled!==!1&&K.preventDefault()}function it(K){let J=D[K.pointerId];J===void 0&&(J=new xn,D[K.pointerId]=J),J.set(K.pageX,K.pageY)}function U(K){const J=K.pointerId===E[0].pointerId?E[1]:E[0];return D[J.pointerId]}r.domElement.addEventListener("contextmenu",be),r.domElement.addEventListener("pointerdown",ye),r.domElement.addEventListener("pointercancel",xe),r.domElement.addEventListener("wheel",Pe,{passive:!1}),this.update()}}Pt.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new xn(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},Ls.line={uniforms:l4.merge([Pt.common,Pt.fog,Pt.line]),vertexShader:`
  7816. #include <common>
  7817. #include <color_pars_vertex>
  7818. #include <fog_pars_vertex>
  7819. #include <logdepthbuf_pars_vertex>
  7820. #include <clipping_planes_pars_vertex>
  7821. uniform float linewidth;
  7822. uniform vec2 resolution;
  7823. attribute vec3 instanceStart;
  7824. attribute vec3 instanceEnd;
  7825. attribute vec3 instanceColorStart;
  7826. attribute vec3 instanceColorEnd;
  7827. #ifdef WORLD_UNITS
  7828. varying vec4 worldPos;
  7829. varying vec3 worldStart;
  7830. varying vec3 worldEnd;
  7831. #ifdef USE_DASH
  7832. varying vec2 vUv;
  7833. #endif
  7834. #else
  7835. varying vec2 vUv;
  7836. #endif
  7837. #ifdef USE_DASH
  7838. uniform float dashScale;
  7839. attribute float instanceDistanceStart;
  7840. attribute float instanceDistanceEnd;
  7841. varying float vLineDistance;
  7842. #endif
  7843. void trimSegment( const in vec4 start, inout vec4 end ) {
  7844. // trim end segment so it terminates between the camera plane and the near plane
  7845. // conservative estimate of the near plane
  7846. float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
  7847. float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
  7848. float nearEstimate = - 0.5 * b / a;
  7849. float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
  7850. end.xyz = mix( start.xyz, end.xyz, alpha );
  7851. }
  7852. void main() {
  7853. #ifdef USE_COLOR
  7854. vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
  7855. #endif
  7856. #ifdef USE_DASH
  7857. vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
  7858. vUv = uv;
  7859. #endif
  7860. float aspect = resolution.x / resolution.y;
  7861. // camera space
  7862. vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
  7863. vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
  7864. #ifdef WORLD_UNITS
  7865. worldStart = start.xyz;
  7866. worldEnd = end.xyz;
  7867. #else
  7868. vUv = uv;
  7869. #endif
  7870. // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
  7871. // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
  7872. // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
  7873. // perhaps there is a more elegant solution -- WestLangley
  7874. bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
  7875. if ( perspective ) {
  7876. if ( start.z < 0.0 && end.z >= 0.0 ) {
  7877. trimSegment( start, end );
  7878. } else if ( end.z < 0.0 && start.z >= 0.0 ) {
  7879. trimSegment( end, start );
  7880. }
  7881. }
  7882. // clip space
  7883. vec4 clipStart = projectionMatrix * start;
  7884. vec4 clipEnd = projectionMatrix * end;
  7885. // ndc space
  7886. vec3 ndcStart = clipStart.xyz / clipStart.w;
  7887. vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
  7888. // direction
  7889. vec2 dir = ndcEnd.xy - ndcStart.xy;
  7890. // account for clip-space aspect ratio
  7891. dir.x *= aspect;
  7892. dir = normalize( dir );
  7893. #ifdef WORLD_UNITS
  7894. // get the offset direction as perpendicular to the view vector
  7895. vec3 worldDir = normalize( end.xyz - start.xyz );
  7896. vec3 offset;
  7897. if ( position.y < 0.5 ) {
  7898. offset = normalize( cross( start.xyz, worldDir ) );
  7899. } else {
  7900. offset = normalize( cross( end.xyz, worldDir ) );
  7901. }
  7902. // sign flip
  7903. if ( position.x < 0.0 ) offset *= - 1.0;
  7904. float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
  7905. // don't extend the line if we're rendering dashes because we
  7906. // won't be rendering the endcaps
  7907. #ifndef USE_DASH
  7908. // extend the line bounds to encompass endcaps
  7909. start.xyz += - worldDir * linewidth * 0.5;
  7910. end.xyz += worldDir * linewidth * 0.5;
  7911. // shift the position of the quad so it hugs the forward edge of the line
  7912. offset.xy -= dir * forwardOffset;
  7913. offset.z += 0.5;
  7914. #endif
  7915. // endcaps
  7916. if ( position.y > 1.0 || position.y < 0.0 ) {
  7917. offset.xy += dir * 2.0 * forwardOffset;
  7918. }
  7919. // adjust for linewidth
  7920. offset *= linewidth * 0.5;
  7921. // set the world position
  7922. worldPos = ( position.y < 0.5 ) ? start : end;
  7923. worldPos.xyz += offset;
  7924. // project the worldpos
  7925. vec4 clip = projectionMatrix * worldPos;
  7926. // shift the depth of the projected points so the line
  7927. // segments overlap neatly
  7928. vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
  7929. clip.z = clipPose.z * clip.w;
  7930. #else
  7931. vec2 offset = vec2( dir.y, - dir.x );
  7932. // undo aspect ratio adjustment
  7933. dir.x /= aspect;
  7934. offset.x /= aspect;
  7935. // sign flip
  7936. if ( position.x < 0.0 ) offset *= - 1.0;
  7937. // endcaps
  7938. if ( position.y < 0.0 ) {
  7939. offset += - dir;
  7940. } else if ( position.y > 1.0 ) {
  7941. offset += dir;
  7942. }
  7943. // adjust for linewidth
  7944. offset *= linewidth;
  7945. // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
  7946. offset /= resolution.y;
  7947. // select end
  7948. vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
  7949. // back to clip space
  7950. offset *= clip.w;
  7951. clip.xy += offset;
  7952. #endif
  7953. gl_Position = clip;
  7954. vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
  7955. #include <logdepthbuf_vertex>
  7956. #include <clipping_planes_vertex>
  7957. #include <fog_vertex>
  7958. }
  7959. `,fragmentShader:`
  7960. uniform vec3 diffuse;
  7961. uniform float opacity;
  7962. uniform float linewidth;
  7963. #ifdef USE_DASH
  7964. uniform float dashOffset;
  7965. uniform float dashSize;
  7966. uniform float gapSize;
  7967. #endif
  7968. varying float vLineDistance;
  7969. #ifdef WORLD_UNITS
  7970. varying vec4 worldPos;
  7971. varying vec3 worldStart;
  7972. varying vec3 worldEnd;
  7973. #ifdef USE_DASH
  7974. varying vec2 vUv;
  7975. #endif
  7976. #else
  7977. varying vec2 vUv;
  7978. #endif
  7979. #include <common>
  7980. #include <color_pars_fragment>
  7981. #include <fog_pars_fragment>
  7982. #include <logdepthbuf_pars_fragment>
  7983. #include <clipping_planes_pars_fragment>
  7984. vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
  7985. float mua;
  7986. float mub;
  7987. vec3 p13 = p1 - p3;
  7988. vec3 p43 = p4 - p3;
  7989. vec3 p21 = p2 - p1;
  7990. float d1343 = dot( p13, p43 );
  7991. float d4321 = dot( p43, p21 );
  7992. float d1321 = dot( p13, p21 );
  7993. float d4343 = dot( p43, p43 );
  7994. float d2121 = dot( p21, p21 );
  7995. float denom = d2121 * d4343 - d4321 * d4321;
  7996. float numer = d1343 * d4321 - d1321 * d4343;
  7997. mua = numer / denom;
  7998. mua = clamp( mua, 0.0, 1.0 );
  7999. mub = ( d1343 + d4321 * ( mua ) ) / d4343;
  8000. mub = clamp( mub, 0.0, 1.0 );
  8001. return vec2( mua, mub );
  8002. }
  8003. void main() {
  8004. #include <clipping_planes_fragment>
  8005. #ifdef USE_DASH
  8006. if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
  8007. if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
  8008. #endif
  8009. float alpha = opacity;
  8010. #ifdef WORLD_UNITS
  8011. // Find the closest points on the view ray and the line segment
  8012. vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
  8013. vec3 lineDir = worldEnd - worldStart;
  8014. vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
  8015. vec3 p1 = worldStart + lineDir * params.x;
  8016. vec3 p2 = rayEnd * params.y;
  8017. vec3 delta = p1 - p2;
  8018. float len = length( delta );
  8019. float norm = len / linewidth;
  8020. #ifndef USE_DASH
  8021. #ifdef USE_ALPHA_TO_COVERAGE
  8022. float dnorm = fwidth( norm );
  8023. alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
  8024. #else
  8025. if ( norm > 0.5 ) {
  8026. discard;
  8027. }
  8028. #endif
  8029. #endif
  8030. #else
  8031. #ifdef USE_ALPHA_TO_COVERAGE
  8032. // artifacts appear on some hardware if a derivative is taken within a conditional
  8033. float a = vUv.x;
  8034. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8035. float len2 = a * a + b * b;
  8036. float dlen = fwidth( len2 );
  8037. if ( abs( vUv.y ) > 1.0 ) {
  8038. alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
  8039. }
  8040. #else
  8041. if ( abs( vUv.y ) > 1.0 ) {
  8042. float a = vUv.x;
  8043. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8044. float len2 = a * a + b * b;
  8045. if ( len2 > 1.0 ) discard;
  8046. }
  8047. #endif
  8048. #endif
  8049. vec4 diffuseColor = vec4( diffuse, alpha );
  8050. #include <logdepthbuf_fragment>
  8051. #include <color_fragment>
  8052. gl_FragColor = vec4( diffuseColor.rgb, alpha );
  8053. #include <tonemapping_fragment>
  8054. #include <colorspace_fragment>
  8055. #include <fog_fragment>
  8056. #include <premultiplied_alpha_fragment>
  8057. }
  8058. `};class oX extends Nh{constructor(e){super({type:"LineMaterial",uniforms:l4.clone(Ls.line.uniforms),vertexShader:Ls.line.vertexShader,fragmentShader:Ls.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 U6=new tl,Pw=new qe;class lX extends uNe{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 wi([-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 wi([-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 wP(n,6,1);return this.setAttribute("instanceStart",new Zd(r,3,0)),this.setAttribute("instanceEnd",new Zd(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 wP(n,6,1);return this.setAttribute("instanceColorStart",new Zd(r,3,0)),this.setAttribute("instanceColorEnd",new Zd(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 rNe(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new tl);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),U6.setFromBufferAttribute(n),this.boundingBox.union(U6))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new hc),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,o=e.count;s<o;s++)Pw.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(Pw)),Pw.fromBufferAttribute(n,s),i=Math.max(i,r.distanceToSquared(Pw));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 z6=new qe,B6=new qe,Ma=new Ar,Ea=new Ar,Yl=new Ar,wA=new qe,SA=new Fr,Ca=new dNe,$6=new qe,Rw=new tl,Dw=new hc,Ql=new Ar;let Zl,Tf;function H6(t,e,n){return Ql.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),Ql.multiplyScalar(1/Ql.w),Ql.x=Tf/n.width,Ql.y=Tf/n.height,Ql.applyMatrix4(t.projectionMatrixInverse),Ql.multiplyScalar(1/Ql.w),Math.abs(Math.max(Ql.x,Ql.y))}class CNe extends Rl{constructor(e=new lX,n=new oX({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 o=0,l=0,c=n.count;o<c;o++,l+=2)z6.fromBufferAttribute(n,o),B6.fromBufferAttribute(r,o),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+z6.distanceTo(B6);const s=new wP(i,2,1);return e.setAttribute("instanceDistanceStart",new Zd(s,1,0)),e.setAttribute("instanceDistanceEnd",new Zd(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;Zl=e.ray;const o=this.matrixWorld,l=this.geometry,c=this.material;let u,d;Tf=c.linewidth+s,l.boundingSphere===null&&l.computeBoundingSphere(),Dw.copy(l.boundingSphere).applyMatrix4(o),r?u=.5*Tf:u=H6(i,Math.max(i.near,Dw.distanceToPoint(Zl.origin)),c.resolution),Dw.radius+=u,Zl.intersectsSphere(Dw)!==!1&&(l.boundingBox===null&&l.computeBoundingBox(),Rw.copy(l.boundingBox).applyMatrix4(o),r?d=.5*Tf:d=H6(i,Math.max(i.near,Rw.distanceToPoint(Zl.origin)),c.resolution),Rw.expandByScalar(d),Zl.intersectsBox(Rw)!==!1&&(r?(function(f,m){const p=f.matrixWorld,x=f.geometry,b=x.attributes.instanceStart,y=x.attributes.instanceEnd;for(let v=0,S=Math.min(x.instanceCount,b.count);v<S;v++){Ca.start.fromBufferAttribute(b,v),Ca.end.fromBufferAttribute(y,v),Ca.applyMatrix4(p);const N=new qe,C=new qe;Zl.distanceSqToSegment(Ca.start,Ca.end,C,N),C.distanceTo(N)<.5*Tf&&m.push({point:C,pointOnLine:N,distance:Zl.origin.distanceTo(C),object:f,face:null,faceIndex:v,uv:null,uv1:null})}})(this,n):(function(f,m,p){const x=m.projectionMatrix,b=f.material.resolution,y=f.matrixWorld,v=f.geometry,S=v.attributes.instanceStart,N=v.attributes.instanceEnd,C=Math.min(v.instanceCount,S.count),T=-m.near;Zl.at(1,Yl),Yl.w=1,Yl.applyMatrix4(m.matrixWorldInverse),Yl.applyMatrix4(x),Yl.multiplyScalar(1/Yl.w),Yl.x*=b.x/2,Yl.y*=b.y/2,Yl.z=0,wA.copy(Yl),SA.multiplyMatrices(m.matrixWorldInverse,y);for(let k=0,E=C;k<E;k++){if(Ma.fromBufferAttribute(S,k),Ea.fromBufferAttribute(N,k),Ma.w=1,Ea.w=1,Ma.applyMatrix4(SA),Ea.applyMatrix4(SA),Ma.z>T&&Ea.z>T)continue;if(Ma.z>T){const O=Ma.z-Ea.z,H=(Ma.z-T)/O;Ma.lerp(Ea,H)}else if(Ea.z>T){const O=Ea.z-Ma.z,H=(Ea.z-T)/O;Ea.lerp(Ma,H)}Ma.applyMatrix4(x),Ea.applyMatrix4(x),Ma.multiplyScalar(1/Ma.w),Ea.multiplyScalar(1/Ea.w),Ma.x*=b.x/2,Ma.y*=b.y/2,Ea.x*=b.x/2,Ea.y*=b.y/2,Ca.start.copy(Ma),Ca.start.z=0,Ca.end.copy(Ea),Ca.end.z=0;const D=Ca.closestPointToPointParameter(wA,!0);Ca.at(D,$6);const A=zK.lerp(Ma.z,Ea.z,D),R=A>=-1&&A<=1,F=wA.distanceTo($6)<.5*Tf;if(R&&F){Ca.start.fromBufferAttribute(S,k),Ca.end.fromBufferAttribute(N,k),Ca.start.applyMatrix4(y),Ca.end.applyMatrix4(y);const O=new qe,H=new qe;Zl.distanceSqToSegment(Ca.start,Ca.end,H,O),p.push({point:H,pointOnLine:O,distance:Zl.origin.distanceTo(H),object:f,face:null,faceIndex:k,uv:null,uv1:null})}}})(this,i,n)))}}class TNe extends kN{constructor(e,n,r,i,s=4473924,o=8947848){s=new en(s),o=new en(o);const l=Math.round(e/n);r=Math.round(r/i)*i/2;const c=[],u=[];let d=0;for(let m=-1*(e=l*n/2);m<=e;m+=n){c.push(m,0,-1*r,m,0,r);const p=m===0?s:o;p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3}for(let m=-1*r;m<=r;m+=i){c.push(-1*e,0,m,e,0,m);const p=m===0?s:o;p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3}const f=new Ja;f.setAttribute("position",new wi(c,3)),f.setAttribute("color",new wi(u,3)),super(f,new $y({vertexColors:!0,toneMapped:!1}))}}function ANe(t,e,n,r){const i=(function(o,l,c){o*=.5,l*=.5,c*=.5;const u=new Ja,d=[];return d.push(-o,-l,-c,-o,l,-c,-o,l,-c,o,l,-c,o,l,-c,o,-l,-c,o,-l,-c,-o,-l,-c,-o,-l,c,-o,l,c,-o,l,c,o,l,c,o,l,c,o,-l,c,o,-l,c,-o,-l,c,-o,-l,-c,-o,-l,c,-o,l,-c,-o,l,c,o,l,-c,o,l,c,o,-l,-c,o,-l,c),u.setAttribute("position",new wi(d,3)),u})(t,e,n),s=new kN(i,new aNe({color:new en(r),dashSize:3,gapSize:1}));return s.computeLineDistances(),s}var S0=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,o=0,l=n(new S0.Panel("FPS","#0ff","#002")),c=n(new S0.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new S0.Panel("MB","#f08","#201"));return r(0),{REVISION:16,dom:e,addPanel:n,showPanel:r,begin:function(){i=(performance||Date).now()},end:function(){o++;var d=(performance||Date).now();if(c.update(d-i,200),d>=s+1e3&&(l.update(1e3*o/(d-s),100),s=d,o=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}};S0.Panel=function(t,e,n){var r=1/0,i=0,s=Math.round,o=s(window.devicePixelRatio||1),l=80*o,c=48*o,u=3*o,d=2*o,f=3*o,m=15*o,p=74*o,x=30*o,b=document.createElement("canvas");b.width=l,b.height=c,b.style.cssText="width:80px;height:48px";var y=b.getContext("2d");return y.font="bold "+9*o+"px Helvetica,Arial,sans-serif",y.textBaseline="top",y.fillStyle=n,y.fillRect(0,0,l,c),y.fillStyle=e,y.fillText(t,u,d),y.fillRect(f,m,p,x),y.fillStyle=n,y.globalAlpha=.9,y.fillRect(f,m,p,x),{dom:b,update:function(v,S){r=Math.min(r,v),i=Math.max(i,v),y.fillStyle=n,y.globalAlpha=1,y.fillRect(0,0,l,m),y.fillStyle=e,y.fillText(s(v)+" "+t+" ("+s(r)+"-"+s(i)+")",u,d),y.drawImage(b,f+o,m,p-o,x,f,m,p-o,x),y.fillRect(f+p-o,m,o,x),y.fillStyle=n,y.globalAlpha=.9,y.fillRect(f+p-o,m,o,s((1-v/S)*x))}}};var kNe=S0;class V6{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new oS,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 oS,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 jNe extends Ja{constructor(e=[new qe],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 qe,o=new qe,l=new xn,c=[],u=[],d=[],f=[];function m(p){const[x,b,y]=(function(v){const S=e[v],N=new qe,C=new qe,T=new qe,k=new qe;N.copy(S).sub(e[v-1]||S).normalize().add((e[v+1]||S).clone().sub(S).normalize()).normalize();let E=Number.MAX_VALUE;const D=Math.abs(N.x),A=Math.abs(N.y),R=Math.abs(N.z);return D<=E&&(E=D,C.set(1,0,0)),A<=E&&(E=A,C.set(0,1,0)),R<=E&&C.set(0,0,1),k.crossVectors(N,C).normalize(),C.crossVectors(N,k),T.crossVectors(N,C),[S,C,T]})(p);for(let v=0;v<=i;v++){const S=v/i*Math.PI*2,N=Math.sin(S),C=-Math.cos(S);o.x=C*b.x+N*y.x,o.y=C*b.y+N*y.y,o.z=C*b.z+N*y.z,o.normalize(),u.push(o.x,o.y,o.z),s.x=x.x+n*o.x*.5,s.y=x.y+n*o.y*.5,s.z=x.z+r*o.z*.5,c.push(s.x,s.y,s.z)}}(function(){for(let p=0;p<e.length;p++)m(p);m(closed===!1?e.length-1:0),(function(){for(let p=0;p<e.length;p++)for(let x=0;x<=i;x++)l.x=p/e.length,l.y=x/i,d.push(l.x,l.y)})(),(function(){for(let p=1;p<e.length;p++)for(let x=1;x<=i;x++){const b=(i+1)*(p-1)+(x-1),y=(i+1)*p+(x-1),v=(i+1)*p+x,S=(i+1)*(p-1)+x;f.push(b,y,S),f.push(y,v,S)}})()})(),this.setIndex(f),this.setAttribute("position",new wi(c,3)),this.setAttribute("normal",new wi(u,3)),this.setAttribute("uv",new wi(d,2))}}class N0{static get initial(){const e=new N0;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const NA={h:0,s:0,l:0};class kg{constructor(e){var n,r,i,s,o,l,c,u,d;if(this.minLayerThreshold=.05,this.renderExtrusion=!0,this.renderTravel=!1,this.renderTubes=!1,this.extrusionWidth=.6,this.singleLayerMode=!1,this.initialCameraPosition=[-100,400,450],this.debug=!1,this.inches=!1,this.nonTravelmoves=[],this.disableGradient=!1,this.state=N0.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=kg.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new en(14737632),this._travelColor=new en(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 lS(this.minLayerThreshold),this.scene=new W2e,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new en(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=(o=e.renderTravel)!==null&&o!==void 0?o:this.renderTravel,this.nonTravelmoves=(l=e.nonTravelMoves)!==null&&l!==void 0?l:this.nonTravelmoves,this.renderTubes=(c=e.renderTubes)!==null&&c!==void 0?c:this.renderTubes,this.extrusionWidth=(u=e.extrusionWidth)!==null&&u!==void 0?u:this.extrusionWidth,this.devMode=(d=e.devMode)!==null&&d!==void 0?d:this.devMode,this.stats=this.devMode?new kNe:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new en(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new en(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new en(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[p,x]of Object.entries(e.toolColors))this._toolColors[parseInt(p)]=new en(x)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+MN),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 _P({canvas:this.canvas,preserveDrawingBuffer:!0});else{if(!this.targetId)throw Error("Set either opts.canvas or opts.targetId");const p=document.getElementById(this.targetId);if(!p)throw new Error("Unable to find element "+this.targetId);this.renderer=new _P({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,p.appendChild(this.canvas)}this.camera=new lo(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const f=this.camera.far,m=.8*f;this.scene.fog=new d4(this._backgroundColor,m,f),this.resize(),this.controls=new ENe(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 en(r)}else this._extrusionColor=new en(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?kg.defaultExtrusionColor:this._extrusionColor instanceof en?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:kg.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new en(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new en(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new en(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new en(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 hNe(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 cNe(13421772,.3*Math.PI),n=new lNe(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 o0;return n.name=e,n.quaternion.setFromEuler(new zy(-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=N0.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 vA(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,o,l,c,u;if(e>this.maxLayerIndex)return;const d=this.layers[e],f={extrusion:[],travel:[],z:this.state.z,height:d.height};for(const m of d.commands)if(m.gcode!="g20"){if(m.gcode.startsWith("t")){this.doRenderExtrusion(f,e),f.extrusion=[];const p=m;this.state.t=p.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(m.gcode)>-1){const p=m,x={x:(n=p.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=p.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=p.params.z)!==null&&i!==void 0?i:this.state.z,r:(s=p.params.r)!==null&&s!==void 0?s:this.state.r,e:(o=p.params.e)!==null&&o!==void 0?o:this.state.e,i:(l=p.params.i)!==null&&l!==void 0?l:this.state.i,j:(c=p.params.j)!==null&&c!==void 0?c:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const b=((u=p.params.e)!==null&&u!==void 0?u:0)>0||this.nonTravelmoves.indexOf(m.gcode)>-1;(x.x!=this.state.x||x.y!=this.state.y||x.z!=this.state.z)&&(b&&this.renderExtrusion||!b&&this.renderTravel)&&(m.gcode=="g2"||m.gcode=="g3"||m.gcode=="g02"||m.gcode=="g03"?this.addArcSegment(f,this.state,x,b,m.gcode=="g2"||m.gcode=="g02"):this.addLineSegment(f,this.state,x,b))}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 o=.1+.7*n/this.layers.length;s.getHSL(NA),s=new en().setHSL(NA.h,NA.s,o)}if(n==this.layers.length-1){const o=(r=this._topLayerColor)!==null&&r!==void 0?r:s,l=(i=this._lastSegmentColor)!==null&&i!==void 0?i:o,c=e.extrusion.splice(-3),u=e.extrusion.splice(-3);this.renderTubes?(this.addTubeLine(e.extrusion,o.getHex(),e.height),this.addTubeLine([...u,...c],l.getHex(),e.height)):(this.addLine(e.extrusion,o.getHex()),this.addLine([...u,...c],l.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 TNe(this.buildVolume.x,10,this.buildVolume.y,10));const e=ANe(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 lS(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=N0.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 o=i?e.extrusion:e.travel,l=n.x,c=n.y,u=n.z,d=r.x,f=r.y,m=r.z;let p=r.r,x=r.i,b=r.j;if(p){const G=d-l,$=f-c,q=Math.sqrt(Math.pow(G/2,2)+Math.pow($/2,2));p=Math.max(p,q);const Y=Math.pow(G,2)+Math.pow($,2),Z=Math.pow(p,2)-Y/4;let oe=Math.sqrt(Z/Y);(s&&p<0||!s&&p>0)&&(oe=-oe),x=G/2+$*oe,b=$/2-G*oe}const y=l==d&&c==f,v=l+x,S=c+b,N=Math.sqrt(x*x+b*b),C=Math.atan2(-b,-x),T=Math.atan2(f-S,d-v);let k;y?k=2*Math.PI:(k=s?C-T:T-C,k<0&&(k+=2*Math.PI));let E=N*k/1.8;this.inches&&(E*=25),E<1&&(E=1);let D=k/E;D*=s?-1:1;const A=[];A.push({x:l,y:c,z:u});const R=(u-m)/E;let F=l,O=c,H=u,j=C;for(let G=0;G<E-1;G++)j+=D,F=v+N*Math.cos(j),O=S+N*Math.sin(j),H+=R,A.push({x:F,y:O,z:H});A.push({x:r.x,y:r.y,z:r.z});for(let G=0;G<A.length-1;G++)o.push(A[G].x,A[G].y,A[G].z,A[G+1].x,A[G+1].y,A[G+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new Ja;i.setAttribute("position",new wi(e,3)),this.disposables.push(i);const s=new $y({color:n});this.disposables.push(s);const o=new kN(i,s);(r=this.group)===null||r===void 0||r.add(o)}addTubeLine(e,n,r=.2){let i=[];const s=[];for(let o=0;o<e.length;o+=6){const l=e.slice(o,o+9),c=new qe(l[0],l[1],l[2]),u=new qe(l[3],l[4],l[5]),d=new qe(l[6],l[7],l[8]);i.push(c),u.equals(d)||(i.push(u),s.push(i),i=[])}s.forEach((o=>{var l;const c=new jNe(o,this.extrusionWidth,this.lineHeight||r,4);(l=this._geometries)[n]||(l[n]=[]),this._geometries[n].push(c)}))}addThickLine(e,n){var r;if(!e.length||!this.lineWidth)return;const i=new lX;this.disposables.push(i);const s=new oX({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(s),i.setPositions(e);const o=new CNe(i,s);(r=this.group)===null||r===void 0||r.add(o)}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=>vA(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 iNe({color:e,wireframe:this._wireframe});this.disposables.push(i);const s=r.reduce(((l,c)=>3*c.attributes.position.count+l),0),o=new tNe(r.length,s,void 0,i);return this.disposables.push(o),(n=this.group)===null||n===void 0||n.add(o),o}_readFromStream(e){var n,r;return vA(this,void 0,void 0,(function*(){const i=e.getReader();let s,o="",l=0;do{console.debug("reading from stream"),s=yield i.read(),l+=(r=(n=s.value)===null||n===void 0?void 0:n.length)!==null&&r!==void 0?r:0;const u=(c=s.value,new TextDecoder("utf-8").decode(c)),d=u.lastIndexOf(`
  8059. `),f=u.slice(0,d);this.parser.parseGCode(o+f),o=u.slice(d)}while(!s.done);var c;console.debug("read from stream",l)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new V6(this):typeof this.devMode=="object"&&(this.devGui=new V6(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())}}kg.defaultExtrusionColor=new en("hotpink");function cX({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=w.useRef(null),s=w.useRef(null),o=w.useRef(null),l=w.useRef(!1),[c,u]=w.useState(!0),[d,f]=w.useState(null),[m,p]=w.useState(!1),[x,b]=w.useState(0),[y,v]=w.useState(0),S=w.useMemo(()=>JSON.stringify(n),[n]);w.useEffect(()=>{if(!i.current||l.current)return;l.current=!0;const T=i.current,k=T.parentElement?.getBoundingClientRect();k&&(T.width=k.width,T.height=k.height);const E=n&&n.length>1,D=n?.[0]||"#00ae42",A=new kg({canvas:T,buildVolume:e,backgroundColor:1710618,extrusionColor:E?n:D,disableGradient:!0,lineHeight:.2,lineWidth:2,renderTravel:!1,renderExtrusion:!0});s.current=A,fetch(t).then(async F=>{if(!F.ok)throw F.status===404&&(await F.json().catch(()=>({}))).detail?.includes("sliced")?(p(!0),new Error("not_sliced")):new Error("Failed to load G-code");return F.text()}).then(F=>{const O=new Set,H=/^(\s*)T(\d+)(\s*;.*)?$/gim;let j;for(;(j=H.exec(F))!==null;){const oe=parseInt(j[2],10);oe<=15&&O.add(oe)}const G=new Map,$=Array.from(O).sort((oe,B)=>oe-B);$.forEach((oe,B)=>{G.set(oe,B%8)});const q=[];$.forEach((oe,B)=>{const W=n?.[oe]||"#00ae42";q[B%8]=W});const Y=F.split(`
  8060. `).map(oe=>{const B=oe.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(B){const W=parseInt(B[2],10);if(W>15)return`; FILTERED: ${oe.trim()}`;const se=G.get(W)??0;return`${B[1]}T${se}${B[3]||""}`}return oe}).join(`
  8061. `);q.length>0&&(A.extrusionColor=q),A.processGCode(Y);const Z=A.layers?.length||0;v(Z),b(Z),A.render(),u(!1)}).catch(F=>{F.message!=="not_sliced"&&f(F.message),u(!1)});const R=()=>{if(T.parentElement&&s.current){const F=T.parentElement.getBoundingClientRect();T.width=F.width,T.height=F.height,s.current.resize()}};return window.addEventListener("resize",R),()=>{window.removeEventListener("resize",R),o.current&&cancelAnimationFrame(o.current),s.current&&(s.current.dispose(),s.current=null),l.current=!1}},[t,S]);const N=w.useCallback(T=>{if(!s.current)return;const k=Math.max(1,Math.min(T,y));b(k),o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{s.current&&(s.current.endLayer=k,s.current.render())})},[y]),C=T=>{N(parseInt(T.target.value,10))};return a.jsxs("div",{className:`relative flex flex-col h-full ${r}`,children:[a.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[a.jsx("canvas",{ref:i,className:"w-full h-full"}),c&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:a.jsxs("div",{className:"text-center",children:[a.jsx(ct,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),a.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),m&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:a.jsxs("div",{className:"text-center max-w-sm px-4",children:[a.jsx(Rue,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),a.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),a.jsx("p",{className:"text-bambu-gray text-sm",children:"This file hasn't been sliced yet. G-code preview is only available after slicing in Bambu Studio or Orca Slicer."})]})}),d&&!m&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:a.jsx("div",{className:"text-center text-red-400",children:a.jsx("p",{className:"text-sm",children:d})})})]}),!c&&!d&&!m&&y>0&&a.jsx("div",{className:"mt-4 px-2",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(xs,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("button",{onClick:()=>N(x-1),disabled:x<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:a.jsx(gh,{className:"w-4 h-4"})}),a.jsx("input",{type:"range",min:1,max:y,value:x,onChange:C,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),a.jsx("button",{onClick:()=>N(x+1),disabled:x>=y,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:a.jsx(vs,{className:"w-4 h-4"})}),a.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[x," / ",y]})]})})]})}function PNe({printerId:t,filePath:e,filename:n,onClose:r}){const[i,s]=w.useState(null),[o,l]=w.useState([]),[c,u]=w.useState(!1),[d,f]=w.useState(null),m=n.toLowerCase().split(".").pop()||"",p=m==="3mf"||m==="stl",x=m==="gcode"||m==="3mf";w.useEffect(()=>{s(p?"3d":x?"gcode":null)},[p,x]),w.useEffect(()=>{l([]),f(null),p&&(u(!0),ue.getPrinterFilePlates(t,e).then(v=>l(v.plates||[])).catch(()=>l([])).finally(()=>u(!1)))},[e,p,t]);const b=o.length>1,y=d==null?null:o.find(v=>v.index===d)??null;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-6",onClick:r,children:a.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:v=>v.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:n}),a.jsx(Ne,{variant:"ghost",size:"sm",onClick:r,children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[a.jsxs("button",{onClick:()=>p&&s("3d"),disabled:!p,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${i==="3d"?"text-bambu-green border-b-2 border-bambu-green":p?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[a.jsx(Pi,{className:"w-4 h-4"}),"3D Model",!p&&a.jsx("span",{className:"text-xs",children:"(not available)"})]}),a.jsxs("button",{onClick:()=>x&&s("gcode"),disabled:!x,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${i==="gcode"?"text-bambu-green border-b-2 border-bambu-green":x?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[a.jsx(fs,{className:"w-4 h-4"}),"G-code Preview",!x&&a.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),a.jsx("div",{className:"flex-1 overflow-hidden p-4",children:i==="3d"&&p?a.jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[b&&a.jsxs("div",{className:"rounded-lg border border-bambu-dark-tertiary bg-bambu-dark p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray mb-2",children:[a.jsx(Pi,{className:"w-4 h-4"}),"Plates",c&&a.jsx(ct,{className:"w-3 h-3 animate-spin"})]}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2",children:[a.jsxs("button",{type:"button",onClick:()=>f(null),className:`flex items-center gap-2 rounded-lg border p-2 text-left transition-colors ${d==null?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray"}`,children:[a.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:a.jsx(Pi,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm text-white font-medium truncate",children:"All Plates"}),a.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[o.length," plate",o.length!==1?"s":""]})]}),d==null&&a.jsx(Vs,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]}),o.map(v=>a.jsxs("button",{type:"button",onClick:()=>f(v.index),className:`flex items-center gap-2 rounded-lg border p-2 text-left transition-colors ${d===v.index?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray"}`,children:[v.has_thumbnail?a.jsx("img",{src:ue.getPrinterFilePlateThumbnail(t,v.index,e),alt:`Plate ${v.index}`,className:"w-10 h-10 rounded object-cover bg-bambu-dark-tertiary"}):a.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:a.jsx(Pi,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm text-white font-medium truncate",children:v.name||`Plate ${v.index}`}),a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:v.objects.length>0?v.objects.slice(0,2).join(", ")+(v.objects.length>2?"…":""):`${v.filaments.length} filament${v.filaments.length!==1?"s":""}`})]}),d===v.index&&a.jsx(Vs,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},v.index))]}),y&&a.jsxs("div",{className:"mt-3 text-xs text-bambu-gray flex flex-wrap gap-x-4 gap-y-1",children:[a.jsxs("span",{children:["Plate ",y.index]}),y.print_time_seconds!=null&&a.jsxs("span",{children:["ETA ",Math.round(y.print_time_seconds/60)," min"]}),y.filament_used_grams!=null&&a.jsxs("span",{children:[y.filament_used_grams.toFixed(1)," g"]}),y.filaments.length>0&&a.jsxs("span",{children:[y.filaments.length," filament",y.filaments.length!==1?"s":""]})]})]}),a.jsx("div",{className:"flex-1",children:a.jsx(CK,{url:ue.getPrinterFileDownloadUrl(t,e),fileType:m,selectedPlateId:d,className:"w-full h-full"})})]}):i==="gcode"&&x?a.jsx(cX,{gcodeUrl:ue.getPrinterFileGcodeUrl(t,e),className:"w-full h-full"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}function RNe(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 G6(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 DNe(t,e){if(e)return wW;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return zf;case"gcode":return fs;case"mp4":case"avi":return ih;case"png":case"jpg":case"jpeg":return Du;default:return uN}}const ONe=[{value:"name-asc",label:"Name (A-Z)"},{value:"name-desc",label:"Name (Z-A)"},{value:"size-asc",label:"Size (smallest)"},{value:"size-desc",label:"Size (largest)"},{value:"date-asc",label:"Date (oldest)"},{value:"date-desc",label:"Date (newest)"}];function LNe({printerId:t,printerName:e,onClose:n}){const{showToast:r}=Vn(),i=on(),[s,o]=w.useState("/"),[l,c]=w.useState(new Set),[u,d]=w.useState(""),[f,m]=w.useState([]),[p,x]=w.useState("name-asc"),[b,y]=w.useState(null),[v,S]=w.useState(null);w.useEffect(()=>{const $=q=>{q.key==="Escape"&&n()};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[n]);const{data:N,isLoading:C,refetch:T}=at({queryKey:["printerFiles",t,s],queryFn:()=>ue.getPrinterFiles(t,s)}),{data:k}=at({queryKey:["printerStorage",t],queryFn:()=>ue.getPrinterStorage(t),staleTime:3e4}),E=mt({mutationFn:async $=>{for(const q of $)await ue.deletePrinterFile(t,q)},onSuccess:()=>{r(`Deleted ${f.length} file${f.length>1?"s":""}`),i.invalidateQueries({queryKey:["printerFiles",t]}),c(new Set),m([])},onError:$=>{r(`Delete failed: ${$.message}`,"error")}}),D=$=>{o($),c(new Set)},A=()=>{if(s==="/")return;const $=s.split("/").filter(Boolean);$.pop(),o($.length?"/"+$.join("/"):"/"),c(new Set)},R=($,q)=>{q.stopPropagation(),c(Y=>{const Z=new Set(Y);return Z.has($)?Z.delete($):Z.add($),Z})},F=()=>{if(!N?.files)return;const $=N.files.filter(q=>!q.is_directory&&(!u||q.name.toLowerCase().includes(u.toLowerCase()))).map(q=>q.path);c(new Set($))},O=()=>{c(new Set)},H=async()=>{if(l.size===0)return;const $=Array.from(l);if($.length===1){window.open(ue.getPrinterFileDownloadUrl(t,$[0]),"_blank"),c(new Set);return}y({current:0,total:$.length});try{const q=await ue.downloadPrinterFilesAsZip(t,$),Y=URL.createObjectURL(q),Z=document.createElement("a");Z.href=Y,Z.download=`${e.replace(/[^a-zA-Z0-9]/g,"_")}-files.zip`,document.body.appendChild(Z),Z.click(),document.body.removeChild(Z),URL.revokeObjectURL(Y),r(`Downloaded ${$.length} files as ZIP`),c(new Set)}catch(q){r(`Download failed: ${q instanceof Error?q.message:"Unknown error"}`,"error")}finally{y(null)}},j=()=>{l.size!==0&&m(Array.from(l))},G=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[a.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:$=>$.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(fN,{className:"w-5 h-5 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:"File Manager"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),a.jsxs("div",{className:"flex items-center gap-4",children:[k&&(k.used_bytes!=null||k.free_bytes!=null)&&a.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[k.used_bytes!=null&&a.jsxs("span",{children:["Used: ",G6(k.used_bytes)]}),k.used_bytes!=null&&k.free_bytes!=null&&a.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),k.free_bytes!=null&&a.jsxs("span",{children:["Free: ",G6(k.free_bytes)]})]}),a.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",title:"Close file manager","aria-label":"Close file manager",children:a.jsx(Dt,{className:"w-5 h-5"})})]})]}),a.jsxs("div",{className:"flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[G.map($=>a.jsx("button",{onClick:()=>{D($.path),d("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${s===$.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:$.label},$.path)),a.jsx("div",{className:"flex-1"}),a.jsxs("div",{className:"relative",children:[a.jsx(pa,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:"Filter files...",value:u,onChange:$=>d($.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"})]}),a.jsxs("div",{className:"relative flex items-center gap-1",children:[a.jsx(bW,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("select",{value:p,onChange:$=>x($.target.value),className:"appearance-none bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm py-1.5 pl-2 pr-6 focus:border-bambu-green focus:outline-none cursor-pointer",title:"Sort files","aria-label":"Sort files",children:ONe.map($=>a.jsx("option",{value:$.value,children:$.label},$.value))})]}),a.jsx(Ne,{variant:"secondary",size:"sm",onClick:()=>T(),disabled:C,children:a.jsx(Pr,{className:`w-4 h-4 ${C?"animate-spin":""}`})})]}),a.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[a.jsx("button",{onClick:A,disabled:s==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",title:"Go to parent folder","aria-label":"Go to parent folder",children:a.jsx(gh,{className:"w-4 h-4"})}),a.jsx("span",{className:"text-bambu-gray font-mono",children:s})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:C?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(ct,{className:"w-8 h-8 text-bambu-green animate-spin"})}):N?.files?.length?a.jsx("div",{className:"space-y-1",children:[...N.files].filter($=>!u||$.name.toLowerCase().includes(u.toLowerCase())).sort(($,q)=>{if($.is_directory&&!q.is_directory)return-1;if(!$.is_directory&&q.is_directory)return 1;switch(p){case"name-asc":return $.name.localeCompare(q.name);case"name-desc":return q.name.localeCompare($.name);case"size-asc":return $.size-q.size;case"size-desc":return q.size-$.size;case"date-asc":{const Y=$.mtime?new Date($.mtime).getTime():0,Z=q.mtime?new Date(q.mtime).getTime():0;return Y-Z}case"date-desc":{const Y=$.mtime?new Date($.mtime).getTime():0;return(q.mtime?new Date(q.mtime).getTime():0)-Y}default:return $.name.localeCompare(q.name)}}).map($=>{const q=DNe($.name,$.is_directory),Y=l.has($.path);return a.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${Y?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{$.is_directory&&D($.path)},children:[$.is_directory?null:a.jsx("button",{onClick:Z=>R($.path,Z),className:"flex-shrink-0 text-bambu-gray hover:text-white",children:Y?a.jsx(Vs,{className:"w-5 h-5 text-bambu-green"}):a.jsx(il,{className:"w-5 h-5"})}),a.jsx(q,{className:`w-5 h-5 flex-shrink-0 ${$.is_directory?"text-bambu-green":"text-bambu-gray"}`}),a.jsx("span",{className:"flex-1 text-white truncate",children:$.name}),!$.is_directory&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:RNe($.size)}),($.name.toLowerCase().endsWith(".3mf")||$.name.toLowerCase().endsWith(".gcode")||$.name.toLowerCase().endsWith(".stl"))&&a.jsx("button",{onClick:Z=>{Z.stopPropagation(),S({path:$.path,name:$.name})},className:"p-1 rounded hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green",title:"3D View",children:a.jsx(Pi,{className:"w-4 h-4"})})]}),$.is_directory&&a.jsx(gh,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},$.path)})}):a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),a.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("div",{className:"text-sm text-bambu-gray",children:l.size>0?`${l.size} selected`:u?`${N?.files?.filter($=>$.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${N?.files?.length||0} items`:`${N?.files?.length||0} items`}),N?.files?.some($=>!$.is_directory)&&a.jsx("div",{className:"flex items-center gap-2",children:l.size>0?a.jsxs("button",{onClick:O,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[a.jsx(Uhe,{className:"w-4 h-4"}),"Deselect All"]}):a.jsxs("button",{onClick:F,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[a.jsx(Vs,{className:"w-4 h-4"}),"Select All"]})})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ne,{variant:"secondary",disabled:l.size===0||b!==null,onClick:H,children:b?a.jsxs(a.Fragment,{children:[a.jsx(ct,{className:"w-4 h-4 animate-spin"}),b.current,"/",b.total]}):a.jsxs(a.Fragment,{children:[a.jsx(pi,{className:"w-4 h-4"}),"Download",l.size>1?` (${l.size})`:""]})}),a.jsxs(Ne,{variant:"secondary",disabled:l.size===0||E.isPending,onClick:j,className:"text-red-400 hover:text-red-300",children:[E.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(an,{className:"w-4 h-4"}),"Delete",l.size>1?` (${l.size})`:""]})]})]})]}),f.length>0&&a.jsx(Yn,{title:f.length>1?`Delete ${f.length} Files`:"Delete File",message:f.length>1?`Delete ${f.length} selected files? This cannot be undone.`:`Delete "${f[0].split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{E.mutate(f)},onCancel:()=>m([])}),v&&a.jsx(PNe,{printerId:t,filePath:v.path,filename:v.name,onClose:()=>S(null)})]})}const INe="embeddedCameraState_",q6=5,FNe=2e3,UNe=3e4,zNe=5e3,MA={x:window.innerWidth-420,y:20,width:400,height:300};function BNe({printerId:t,printerName:e,viewerIndex:n=0,onClose:r}){const i=`${INe}${t}`,s=()=>{try{const He=localStorage.getItem(i);if(He){const Se=JSON.parse(He);return{x:Math.min(Math.max(0,Se.x),window.innerWidth-100),y:Math.min(Math.max(0,Se.y),window.innerHeight-100),width:Math.max(200,Math.min(Se.width,window.innerWidth-20)),height:Math.max(150,Math.min(Se.height,window.innerHeight-20))}}}catch{}const ae=n*30;return{...MA,x:Math.max(0,MA.x-ae),y:Math.max(0,MA.y+ae)}},[o,l]=w.useState(s),[c,u]=w.useState(!1),[d,f]=w.useState(!1),[m,p]=w.useState({x:0,y:0}),[x,b]=w.useState(!1),[y,v]=w.useState(!1),[S,N]=w.useState(1),[C,T]=w.useState({x:0,y:0}),[k,E]=w.useState(!1),[D,A]=w.useState({x:0,y:0}),[R,F]=w.useState(null),[O,H]=w.useState(null),[j,G]=w.useState(!1),[$,q]=w.useState(!0),[Y,Z]=w.useState(Date.now()),[oe,B]=w.useState(0),[W,se]=w.useState(!1),[ne,ce]=w.useState(0),fe=w.useRef(null),ye=w.useRef(null),ge=w.useRef(null),xe=w.useRef(null),Pe=w.useRef(null),{data:Ue}=at({queryKey:["printer",t],queryFn:()=>ue.getPrinter(t),enabled:t>0});w.useEffect(()=>{const ae=setTimeout(()=>{localStorage.setItem(i,JSON.stringify(o))},500);return()=>clearTimeout(ae)},[o,i]);const be=w.useRef(!1);w.useEffect(()=>{be.current=!1;const ae=`/api/v1/printers/${t}/camera/stop`,He=()=>{t>0&&!be.current&&(be.current=!0,navigator.sendBeacon(ae))},Se=ye.current;return()=>{Se&&(Se.src=""),He(),ge.current&&clearTimeout(ge.current),xe.current&&clearInterval(xe.current),Pe.current&&clearInterval(Pe.current)}},[t]),w.useEffect(()=>{if($){const ae=setTimeout(()=>q(!1),3e3);return()=>clearTimeout(ae)}},[$,Y]);const it=w.useCallback(()=>{if(oe>=q6){se(!1),G(!0);return}const ae=Math.min(FNe*Math.pow(2,oe),UNe);se(!0),ce(Math.ceil(ae/1e3)),xe.current=setInterval(()=>{ce(He=>He<=1?(xe.current&&clearInterval(xe.current),0):He-1)},1e3),ge.current=setTimeout(()=>{B(He=>He+1),se(!1),q(!0),G(!1),ye.current&&(ye.current.src=""),Z(Date.now())},ae)},[oe]);w.useEffect(()=>{if($||W||x){Pe.current&&(clearInterval(Pe.current),Pe.current=null);return}return Pe.current=setInterval(async()=>{try{const ae=await fetch(`/api/v1/printers/${t}/camera/status`);if(ae.ok){const He=await ae.json();(He.stalled||!He.active&&!j)&&(Pe.current&&(clearInterval(Pe.current),Pe.current=null),q(!1),it())}}catch{}},zNe),()=>{Pe.current&&(clearInterval(Pe.current),Pe.current=null)}},[$,j,W,x,t,it]),w.useEffect(()=>{const ae=()=>{const He=!!document.fullscreenElement;v(He),He||(N(1),T({x:0,y:0}))};return document.addEventListener("fullscreenchange",ae),()=>document.removeEventListener("fullscreenchange",ae)},[]);const U=()=>{fe.current&&(document.fullscreenElement?document.exitFullscreen():fe.current.requestFullscreen())},K=()=>{N(ae=>Math.min(ae+.5,4))},J=()=>{N(ae=>{const He=Math.max(ae-.5,1);return He===1&&T({x:0,y:0}),He})},Q=ae=>{ae.preventDefault(),ae.deltaY<0?K():J()},z=ae=>{S>1&&(ae.preventDefault(),E(!0),A({x:ae.clientX-C.x,y:ae.clientY-C.y}))},re=w.useCallback(()=>{if(!fe.current||!ye.current)return{x:200,y:150};const ae=fe.current.getBoundingClientRect(),He=ae.width*(S-1)/2,Se=ae.height*(S-1)/2;return{x:Math.max(50,He),y:Math.max(50,Se)}},[S]),Ee=ae=>{if(k&&S>1){const He=ae.clientX-D.x,Se=ae.clientY-D.y,Be=re();T({x:Math.max(-Be.x,Math.min(Be.x,He)),y:Math.max(-Be.y,Math.min(Be.y,Se))})}},_e=()=>{E(!1)},Te=ae=>{if(ae.length<2)return 0;const He=ae[0].clientX-ae[1].clientX,Se=ae[0].clientY-ae[1].clientY;return Math.sqrt(He*He+Se*Se)},V=ae=>ae.length<2?{x:ae[0].clientX,y:ae[0].clientY}:{x:(ae[0].clientX+ae[1].clientX)/2,y:(ae[0].clientY+ae[1].clientY)/2},L=ae=>{ae.touches.length===2?(ae.preventDefault(),F(Te(ae.touches)),H(V(ae.touches))):ae.touches.length===1&&S>1&&(ae.preventDefault(),E(!0),A({x:ae.touches[0].clientX-C.x,y:ae.touches[0].clientY-C.y}))},X=ae=>{if(ae.touches.length===2&&R!==null){ae.preventDefault();const He=Te(ae.touches),Se=He/R;N(ft=>{const we=Math.max(1,Math.min(4,ft*Se));return we===1&&T({x:0,y:0}),we}),F(He);const Be=V(ae.touches);if(O){const ft=re();T(we=>({x:Math.max(-ft.x,Math.min(ft.x,we.x+(Be.x-O.x))),y:Math.max(-ft.y,Math.min(ft.y,we.y+(Be.y-O.y)))}))}H(Be)}else if(ae.touches.length===1&&k&&S>1){ae.preventDefault();const He=ae.touches[0].clientX-D.x,Se=ae.touches[0].clientY-D.y,Be=re();T({x:Math.max(-Be.x,Math.min(Be.x,He)),y:Math.max(-Be.y,Math.min(Be.y,Se))})}},te=ae=>{ae.touches.length<2&&(F(null),H(null)),ae.touches.length===0&&E(!1)},Me=()=>{N(1),T({x:0,y:0})},ie=()=>{q(!1),oe<q6?it():G(!0)},De=()=>{q(!1),G(!1),B(0),se(!1),ge.current&&clearTimeout(ge.current),xe.current&&clearInterval(xe.current)},Le=()=>{q(!0),G(!1),B(0),se(!1),ge.current&&clearTimeout(ge.current),xe.current&&clearInterval(xe.current),fetch(`/api/v1/printers/${t}/camera/stop`).catch(()=>{}),ye.current&&(ye.current.src=""),setTimeout(()=>Z(Date.now()),100)},$e=ae=>{ae.target.closest(".no-drag")||(u(!0),p({x:ae.clientX-o.x,y:ae.clientY-o.y}))},Ze=ae=>{ae.stopPropagation(),f(!0)};w.useEffect(()=>{const ae=Se=>{if(c)l(Be=>({...Be,x:Math.max(0,Math.min(Se.clientX-m.x,window.innerWidth-Be.width)),y:Math.max(0,Math.min(Se.clientY-m.y,window.innerHeight-Be.height))}));else if(d&&fe.current){const Be=fe.current.getBoundingClientRect();l(ft=>({...ft,width:Math.max(200,Math.min(Se.clientX-Be.left,window.innerWidth-ft.x-10)),height:Math.max(150,Math.min(Se.clientY-Be.top,window.innerHeight-ft.y-10))}))}},He=()=>{u(!1),f(!1)};if(c||d)return document.addEventListener("mousemove",ae),document.addEventListener("mouseup",He),()=>{document.removeEventListener("mousemove",ae),document.removeEventListener("mouseup",He)}},[c,d,m]);const Ie=`/api/v1/printers/${t}/camera/stream?fps=15&t=${Y}`;return a.jsxs("div",{ref:fe,className:`${y?"fixed inset-0 z-[100]":"fixed z-50 rounded-lg shadow-2xl border border-bambu-dark-tertiary"} bg-bambu-dark-secondary overflow-hidden`,style:y?void 0:{left:o.x,top:o.y,width:x?200:o.width,height:x?40:o.height,cursor:c?"grabbing":"default"},children:[a.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-bambu-dark border-b border-bambu-dark-tertiary cursor-grab active:cursor-grabbing",onMouseDown:$e,children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-white truncate",children:[a.jsx(zg,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"truncate",children:Ue?.name||e})]}),a.jsxs("div",{className:"flex items-center gap-1 no-drag",children:[a.jsx("button",{onClick:Le,disabled:$||W,className:"p-1 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:"Refresh stream",children:a.jsx(Pr,{className:`w-3.5 h-3.5 text-bambu-gray ${$?"animate-spin":""}`})}),a.jsx("button",{onClick:U,className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:y?"Exit fullscreen":"Fullscreen",children:y?a.jsx(CW,{className:"w-3.5 h-3.5 text-bambu-gray"}):a.jsx(Kue,{className:"w-3.5 h-3.5 text-bambu-gray"})}),a.jsx("button",{onClick:()=>b(!x),className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:x?"Expand":"Minimize",children:x?a.jsx(MW,{className:"w-3.5 h-3.5 text-bambu-gray"}):a.jsx(EW,{className:"w-3.5 h-3.5 text-bambu-gray"})}),a.jsx("button",{onClick:r,className:"p-1 hover:bg-red-500/20 rounded",title:"Close",children:a.jsx(Dt,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-red-400"})})]})]}),!x&&a.jsxs("div",{className:"relative w-full bg-black flex items-center justify-center overflow-hidden h-[calc(100%-40px)]",onWheel:Q,onMouseMove:Ee,onMouseUp:_e,onMouseLeave:_e,onTouchStart:L,onTouchMove:X,onTouchEnd:te,style:{touchAction:"none"},children:[$&&!W&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:a.jsx(Pr,{className:"w-6 h-6 text-bambu-gray animate-spin"})}),W&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:a.jsxs("div",{className:"text-center p-2",children:[a.jsx(sm,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Reconnecting in ",ne,"s..."]})]})}),j&&!W&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:a.jsxs("div",{className:"text-center p-2",children:[a.jsx(jn,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Camera unavailable"}),a.jsx("button",{onClick:Le,className:"px-2 py-1 text-xs bg-bambu-green text-white rounded hover:bg-bambu-green/80",children:"Retry"})]})}),a.jsx("img",{ref:ye,src:Ie,alt:"Camera stream",className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${S}) translate(${C.x/S}px, ${C.y/S}px)`,cursor:S>1?k?"grabbing":"grab":"default"},onError:ie,onLoad:De,onMouseDown:z,draggable:!1},Y),a.jsxs("div",{className:"absolute bottom-2 left-2 flex items-center gap-1 bg-black/60 rounded px-1.5 py-1 no-drag",children:[a.jsx("button",{onClick:J,disabled:S<=1,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:a.jsx(FD,{className:"w-3.5 h-3.5 text-white"})}),a.jsxs("button",{onClick:Me,className:"px-1.5 py-0.5 text-xs text-white hover:bg-white/10 rounded min-w-[32px]",title:"Reset zoom",children:[Math.round(S*100),"%"]}),a.jsx("button",{onClick:K,disabled:S>=4,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:a.jsx(ID,{className:"w-3.5 h-3.5 text-white"})})]}),!y&&a.jsx("div",{className:"absolute bottom-0 right-0 w-6 h-6 cursor-se-resize no-drag hover:bg-white/10 rounded-tl transition-colors",onMouseDown:Ze,title:"Drag to resize",children:a.jsx("svg",{className:"w-6 h-6 text-bambu-gray/70 hover:text-bambu-gray",viewBox:"0 0 24 24",fill:"currentColor",children:a.jsx("path",{d:"M22 22H20V20H22V22ZM22 18H20V16H22V18ZM18 22H16V20H18V22ZM22 14H20V12H22V14ZM18 18H16V16H18V18ZM14 22H12V20H14V22ZM22 10H20V8H22V10ZM18 14H16V12H18V14ZM14 18H12V16H14V18ZM10 22H8V20H10V22Z"})})})]})]})}function $Ne({printerId:t,printerName:e,onClose:n}){const r=on(),[i,s]=w.useState(!0),[o,l]=w.useState(new Set),[c,u]=w.useState(""),[d,f]=w.useState("all"),m=w.useRef(null),{data:p,isLoading:x,refetch:b}=at({queryKey:["mqtt-logs",t],queryFn:()=>ue.getMQTTLogs(t),refetchInterval:1e3}),y=mt({mutationFn:()=>ue.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),v=mt({mutationFn:()=>ue.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),S=mt({mutationFn:()=>ue.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});w.useEffect(()=>{const A=R=>{R.key==="Escape"&&n()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[n]),w.useEffect(()=>{i&&m.current&&(m.current.scrollTop=m.current.scrollHeight)},[p?.logs,i]);const N=A=>{l(R=>{const F=new Set(R);return F.has(A)?F.delete(A):F.add(A),F})},C=A=>new Date(A).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),T=(A,R)=>{if(A==null)return"<empty>";const F=typeof A=="string"?JSON.parse(A):A,O=JSON.stringify(F,null,R?2:0);return!R&&O.length>100?O.substring(0,100)+"...":O},k=p?.logging_enabled??!1,E=w.useMemo(()=>p?.logs??[],[p?.logs]),D=w.useMemo(()=>E.filter(A=>{if(d!=="all"&&A.direction!==d)return!1;if(c.trim()){const R=c.toLowerCase(),F=A.topic.toLowerCase().includes(R),H=JSON.stringify(A.payload).toLowerCase().includes(R);return F||H}return!0}),[E,c,d]);return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:"MQTT Debug Log"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),a.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[k?a.jsxs(Ne,{size:"sm",variant:"secondary",onClick:()=>v.mutate(),disabled:v.isPending,children:[a.jsx(il,{className:"w-4 h-4"}),"Stop"]}):a.jsxs(Ne,{size:"sm",onClick:()=>y.mutate(),disabled:y.isPending,children:[a.jsx(Us,{className:"w-4 h-4"}),"Start Logging"]}),a.jsxs(Ne,{size:"sm",variant:"secondary",onClick:()=>S.mutate(),disabled:S.isPending||E.length===0,children:[a.jsx(an,{className:"w-4 h-4"}),"Clear"]}),a.jsx(Ne,{size:"sm",variant:"secondary",onClick:()=>b(),disabled:x,children:a.jsx(Pr,{className:`w-4 h-4 ${x?"animate-spin":""}`})}),a.jsx("div",{className:"flex-1"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:i,onChange:A=>s(A.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:[D.length,"/",E.length]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(pa,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:"Search topic or payload...",value:c,onChange:A=>u(A.target.value),className:"w-full pl-8 pr-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),c&&a.jsx("button",{onClick:()=>u(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:a.jsx(Dt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[a.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"}),a.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:[a.jsx(G0,{className:"w-3 h-3"}),"In"]}),a.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:[a.jsx(Fg,{className:"w-3 h-3"}),"Out"]})]})]})]}),a.jsx("div",{ref:m,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:E.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[a.jsx("p",{className:"mb-2",children:"No messages logged yet"}),!k&&a.jsx("p",{className:"text-sm",children:'Click "Start Logging" to begin capturing MQTT messages'})]}):D.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[a.jsx("p",{className:"mb-2",children:"No messages match your filter"}),a.jsx("p",{className:"text-sm",children:"Try adjusting your search or filter criteria"})]}):a.jsx("div",{className:"space-y-1",children:D.map((A,R)=>{const F=o.has(R),O=A.direction==="in";return a.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${F?"bg-bambu-dark-secondary":""}`,onClick:()=>N(R),children:[a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("span",{className:"text-bambu-gray shrink-0",children:C(A.timestamp)}),a.jsx("span",{className:`shrink-0 ${O?"text-blue-400":"text-green-400"}`,title:O?"Incoming":"Outgoing",children:O?a.jsx(G0,{className:"w-3 h-3"}):a.jsx(Fg,{className:"w-3 h-3"})}),a.jsx("span",{className:"text-purple-400 shrink-0",children:A.topic})]}),F?a.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(A.payload,!0)}):a.jsx("pre",{className:"mt-1 text-white/80 truncate",children:T(A.payload,!1)})]},R)})})}),a.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-sm text-bambu-gray",children:k?a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Logging active - messages will auto-refresh"]}):a.jsx("span",{children:"Logging stopped"})}),a.jsx(Ne,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const NP={"0300_4000":"Z axis homing failed; the task has been stopped.","0300_4001":"The printer timed out waiting for the nozzle to cool down before homing.","0300_4002":"Auto Bed Leveling failed; the task has been stopped.","0300_4005":"The hotend cooling fan speed is abnormal.","0300_4006":"The nozzle is clogged.","0300_4008":"The AMS failed to change filament.","0300_4009":"Homing XY axis failed.","0300_400A":"Mechanical resonance frequency identification failed.","0300_400B":"Internal communication exception","0300_400C":"The task was canceled.","0300_400D":"Resume failed after power loss.","0300_400E":"The motor self-check failed.","0300_400F":"The power supply voltage does not match the printer.","0300_4010":"Nozzle offset calibration failed.","0300_4011":"Flow Dynamics Calibration failed; please reinitiate printing or calibration.","0300_4013":"Printing cannot be initiated while AMS is drying.","0300_4014":"Homing Z axis failed: temperature control abnormality.","0300_4015":"Nozzle clumping detection calibration failed. Please go to 'Assistant' for troubleshooting.","0300_4016":"Nozzle cleaning failed. Please click the Assistant for troubleshooting.","0300_401F":"The hotend is not installed, and the toolhead cannot perform homing. Please install the hotend and then continue.","0300_4020":"The nozzle presence detection failed. Please check the Assistant for details.","0300_4021":"Nozzle offset calibration sensor signal abnormality detected. Please check the sensor and retry.","0300_4042":"The Laser Safety Window is not properly installed. The task has been stopped.","0300_4044":"The Flame Sensor is abnormal. The sensor may be short-circuited. Please troubleshoot the issue before starting a print job.","0300_404B":"Task aborted because the front door or top cover is open.","0300_404D":"The current temperature of the hotend, heatbed, or chamber is too high. Please wait for it to cool down to room temperature before restarting the task.","0300_4050":"Liveview Camera calibration timeout; please restart the printer.","0300_4052":"Blade Z-axis homing failed","0300_4057":"Z-axis step loss detected. The task has stopped. Please check if there are any obstructions beneath the heatbed.","0300_4066":"Calibration of motion precision failed.","0300_4067":"Calibration result is over the threshold.","0300_4068":"Step loss occurred during the motion accuracy enhancement process. Please try again.","0300_8000":"Printing was paused for unknown reason. You can select 'Resume' to resume the print job.","0300_8001":"Printing was paused by the user. You can select 'Resume' to continue printing.","0300_8002":"First layer defects were detected by the Micro Lidar. Please check the quality of the printed model before continuing your print.","0300_8003":"Spaghetti defects were detected by the AI Print Monitoring. Please check the quality of the printed model before continuing your print.","0300_8004":"Filament ran out. Please load new filament.","0300_8005":"Toolhead front cover fell off. Please remount the front cover and check to make sure your print is going okay.","0300_8006":"The build plate marker was not detected. Please confirm the build plate is correctly positioned on the heatbed with all four corners aligned, and the marker is visible.","0300_8007":"There was an unfinished print job when the printer lost power. If the model is still adhered to the build plate, you can try resuming the print job.","0300_8008":"Nozzle temperature malfunction","0300_8009":"Heatbed temperature malfunction","0300_800A":"A Filament pile-up was detected by AI Print Monitoring. Please clean filament from the waste chute.","0300_800B":"The cutter is stuck. Please make sure the cutter handle is out and check the filament sensor cable connection.","0300_800C":"Skipped step detected: auto-recover complete; please resume print and check if there are any layer shift problems.","0300_800D":"Detected that the extruder is not extruding normally. If the defects are acceptable, select 'Resume' to resume the print job.","0300_800E":"The print file is not available. Please check to see if the storage media has been removed.","0300_800F":"The door seems to be open, so printing was paused.","0300_8010":"The hotend cooling fan speed is abnormal.","0300_8011":"Detected build plate is not the same as the Gcode file. Please adjust slicer settings or use the correct plate.","0300_8013":"Printing paused due to the pause command added to the printing file.","0300_8014":"The nozzle is covered with filament, or the build plate is installed incorrectly. Please cancel this print and clean the nozzle or adjust the build plate according to the actual status. You can als...","0300_8015":"The filament on external spool has run out; please load new filament. If the filament is loaded, please select 'Resume'.","0300_8016":"The nozzle is clogged with filament. Please cancel this print and clean the nozzle or select 'Resume' to resume the print job.","0300_8017":"Foreign objects detected on heatbed. Please check and clean the heatbed. Then, select 'Resume' to resume the print job.","0300_8018":"Chamber temperature malfunction.","0300_8019":"No build plate is placed.","0300_801A":"Filament extrusion error; please check the assistant for troubleshooting. After resolving the issue, decide whether to cancel or resume the print job based on the actual print status.","0300_801B":"Nozzle temperature problem detected. Refer to Assistant to re-connect the hotend connector. POWER OFF the printer before this operation to avoid short circuits.","0300_801C":"The extrusion resistance is abnormal. The extruder may be clogged; please refer to the assistant. After trouble shooting, you can select 'Resume' to resume the print job.","0300_801D":"The extruder servo motor position sensor is malfunctioning. Please power off the printer first and check if the connection cable is loose.","0300_801E":"The extrusion motor is overloaded, please check the Assistant for details.","0300_8021":"The nozzle may not be installed or not properly installed. Please ensure the nozzle is correctly installed before proceeding.","0300_8022":"The heatbed may be obstructed while moving downward. Please clear any objects beneath the heatbed and check for any resistance or jamming during its movement.","0300_8028":"Nozzle offset calibration sensor error. If using a single hotend or the calibration function is disabled, you may ignore this and continue printing; otherwise, it is recommended to check the sensor...","0300_8041":"Platform detection timeout: please restart the printer.","0300_8042":"Task paused because the door is open.","0300_8043":"The laser module is abnormal.","0300_8044":"Fire was detected inside the chamber.","0300_8045":"Material detection timeout: please restart the printer.","0300_8046":"Foreign object detect timeout: please restart the printer.","0300_8047":"Quick-release lever detection time out: please restart the printer.","0300_8048":"Laser Module unlock has timed out, and the task cannot proceed. Please restart the printer and try again.","0300_8049":"The current plate is invalid.","0300_804A":"Emergency stop button improperly installed. Please reinstall according to the Wiki before proceeding.","0300_804B":"Task paused. The Laser Safety Window is open.","0300_804E":"This is a printing task. Please detach the Laser/Cutting Module from the Toolhead.","0300_804F":"The loading/unloading process is currently ongoing. Please stop the process or remove the laser/cutting module.","0300_8050":"This device does not support the 40W Laser Module. Please remove it or replace it with a 10W Laser Module.","0300_8051":"The cutting module has dropped or the cutting module cable is disconnected; please check the module.","0300_8053":"Laser module detected. Please install the right nozzle correctly to ensure proper Laser Module Mounting Calibration.","0300_8054":"Please place the paper required for Print Then Cut.","0300_8055":"The module mounted on the toolhead does not match the task. Please install the correct module.","0300_8057":"The rotary attachment is disconnected. Please ensure it is properly installed and the cable is securely plugged in.","0300_8058":"The rotary attachment is detected. Please remove it before continuing.","0300_8061":"The mode of Airflow System failed to activate; check the air door condition.","0300_8062":"The chamber temperature is too high. It may be due to high environmental temperature.","0300_8063":"The chamber temperature is too high. Please open the top cover and front door to cool down.","0300_8064":"The chamber temperature is too high. Please open the top cover and front door to cool down. (Open door detection for this print job will be set to 'Notification' level)","0300_8065":"The temperature of the MC module is too high. Please check the Wiki for possible explanations.","0300_8071":"The Toolhead Enhanced Cooling Fan module is malfunctioning.","0300_807D":"Fire Extinguisher not detected, the automatic extinguishing function will be unavailable.","0300_807E":"Fire Extinguisher not detected, the automatic extinguishing function will be unavailable.","0300_807F":"Fire Extinguisher is malfunctioning.","0300_8080":"Fire extinguisher motor reset failed.","0300_8081":"Fire extinguisher cylinder not installed. Please confirm on the extinguisher page.","0300_8082":"The Fire Extinguisher Gas Cylinder is empty.","0300_C012":"Please heat the nozzle to above 170°C.","0300_C056":"A minor fire was detected inside the chamber, and the Auto Fire Extinguishing process has been aborted.","0300_C070":"The fire extinguisher has been detected and is ready for use after the laser module is connected.","0500_4001":"Failed to connect to Bambu Cloud. Please check your network connection.","0500_4002":"Unsupported print file path or name. Please resend the print job.","0500_4003":"Printing stopped because the printer was unable to parse the file. Please resend your print job.","0500_4004":"Device is busy and cannot start new task. Please wait for current task to complete before sending new task.","0500_4005":"Print jobs are not allowed to be sent while updating firmware.","0500_4006":"There is not enough free storage space for the print job. Restoring to factory settings can free up available space.","0500_4007":"The device requires a repair upgrade, and printing is currently unavailable.","0500_4008":"Starting printing failed; please power cycle the printer and resend the print job.","0500_4009":"Print jobs are not allowed to be sent while updating logs.","0500_400A":"The file name is not supported. Please rename and restart the print job.","0500_400B":"There was a problem downloading a file. Please check your network connection and resend the print job.","0500_400C":"Please insert a MicroSD card and restart the print job.","0500_400D":"Please run a self-test and restart the print job.","0500_400E":"Printing was cancelled.","0500_400F":"AMS is initializing and cannot be upgraded at the moment. Please try again later.","0500_4010":"AMS is drying and cannot be upgraded at the moment. Please try again later.","0500_4011":"The printer is loading or unloading filament and cannot be upgraded at the moment. Please try again later.","0500_4012":"The device is printing and cannot be upgraded at the moment. Please try again later.","0500_4013":"AMS is in operation and cannot be upgraded at the moment. Please try again when it is idle.","0500_4014":"Slicing for the print job failed. Please check your settings and restart the print job.","0500_4015":"There is not enough free storage space for the print job. Please format or clear files from the MicroSD card to free up space.","0500_4016":"The MicroSD Card is write-protected. Please replace the MicroSD Card.","0500_4017":"Binding failed. Please retry or restart the printer and retry.","0500_4018":"Binding configuration information parsing failed; please try again.","0500_4019":"The printer has already been bound. Please unbind it and try again.","0500_401A":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0500_401B":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_401C":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_401D":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_401E":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_401F":"Authorization timed out. Please make sure that your phone or PC has access to the internet, and ensure that the Bambu Studio/Bambu Handy APP is running in the foreground during the binding operation.","0500_4020":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4021":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_4022":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4023":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4024":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0500_4025":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4026":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4027":"Cloud access failed; this may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_4028":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4029":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_402A":"Failed to connect to the router, which may be caused by wireless interference or being too far away from the router. Please try again or move the printer closer to the router and try again.","0500_402B":"Router connection failed due to incorrect password. Please check the password and try again.","0500_402C":"Failed to obtain IP address, which may be caused by wireless interference resulting in data transmission failure or the DHCP address pool of the router being full. Please move the printer closer to...","0500_402D":"System exception","0500_402E":"System does not support the file system currently used by the USB flash drive. Please replace or format the USB flash drive to FAT32.","0500_402F":"The MicroSD card sector data is damaged. Please use the SD card repair tool to repair or format it. If it still cannot be identified, please replace the MicroSD card.","0500_4030":"The device is currently upgrading. Please try again when it is idle.","0500_4031":"The accessory firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4033":"The AMS firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4034":"The Laser Module firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4035":"The BirdsEye Camera is malfunctioning. Please try restarting the device. If the issue persists after multiple restarts, check the camera connection status or contact customer support.","0500_4037":"Your sliced file is not compatible with current printer model. This file can't be printed on this printer.","0500_4038":"The nozzle diameter in sliced file is not consistent with the current nozzle setting. This file can't be printed.","0500_4039":"The current task does not allow the installation of the laser/cutting module, and the task has been halted.","0500_403A":"The current temperature is too low. In order to protect you and your printer, printing tasks, moving an axis and other operations are disabled. Please move the printer to an environment above 10 de...","0500_403B":"Laser/cutting tasks cannot be initiated on the machine at the moment. Please use the computer software to start the task.","0500_403C":"The current nozzle setting does not match the slicing file. Continuing to print may affect print quality. It is recommended to re-slice before starting the print.","0500_403D":"The toolhead module is not set up. Please set it up before initiating the task.","0500_403E":"The current tool head does not support initialization.","0500_403F":"Failed to download print job; please check your network connection.","0500_4040":"The printer has reached its power limit. Please connect a dedicated power adapter to this AMS to enable drying.","0500_4041":"The AMS drying cannot be started during printing.","0500_4042":"Due to power limitations, starting AMS drying will pause current operations such as nozzle heating and fan running. Do you want to proceed with drying?","0500_4043":"Due to power limitations, only one AMS is allowed to use the device's power for drying.","0500_4044":"BirdsEye Camera malfunction: please contact customer support.","0500_4045":"Hotend check in progress. This operation is temporarily unavailable. Please wait.","0500_4050":"Error detected on the print board.","0500_4052":"Error detected on the hot end.","0500_4054":"Error detected on the mat.","0500_405D":"Laser module Serial Number error: unable to calibrate or make project.","0500_4065":"The task requires a Laser Platform, but the current one is a Cutting Platform. Please replace it, measure the material thickness in the software, and then restart the task.","0500_4070":"The laser or cutter module is connected, so the device cannot initiate a 3D printing task.","0500_4075":"No Laser Platform was detected, which may affect thickness measurement accuracy. Please place the laser platform correctly and ensure the rear markers are not blocked, then restart the thickness me...","0500_4076":"Please place the Laser Platform correctly and ensure the rear markers are not blocked, then restart the thickness measurement in the software before initiating the task.","0500_4097":"The device cannot detect the Laser Module. Please reconnect the module cable or restart the printer.","0500_4098":"The device cannot detect AMS A. Please reconnect the AMS cable or restart the printer.","0500_4099":"The firmware of Cutting Module does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409A":"The firmware of the Air Pump does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409B":"The firmware of the Laser Module does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409D":"The firmware of AMS A does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0500_409E":"The device cannot detect the Cutting Module. Please reconnect the module cable or restart the printer.","0500_409F":"The device cannot detect the Air Pump. Please reconnect the module cable or restart the printer.","0500_40A0":"The Rotary Attachment module is not detected. Please reconnect the cable or restart the printer.","0500_40A1":"The Auto Fire Extinguishing System is not detected. Please reconnect the module cable or restart the printer.","0500_40A3":"AMS(or AMS lite) A communication is abnormal. Please reconnect the module cable or restart the printer.","0500_40A4":"The current firmware only supports 1 AMS Lite. Please remove all AMS units before reconnecting the supported AMS Lite device.","0500_40A5":"The current firmware only supports AMS/AMS 2 Pro/AMS HT, with a maximum of 4 units. Please remove all AMS units before reconnecting the supported one.","0500_8013":"The print file is not available. Please check to see if the storage media has been removed.","0500_8036":"Your sliced file is not consistent with the current printer model. Continue?","0500_803C":"The current nozzle setting does not match the slicing file. Continuing to print may affect print quality. It is recommended to re-slice before starting the print.","0500_8040":"Toolhead front cover is detached. Moving the toolhead may damage the printer. Do you want to continue?","0500_8041":"The filament in hotend is too cold. Extrusion may damage the extruder. Still feeding in/out the filament?","0500_8048":"The module on the toolhead is not calibrated. Please cancel the task to perform calibration or switch to a calibrated module.","0500_8051":"Detected build plate is not the same as the Gcode file. Please adjust slicer settings or use the correct plate.","0500_8053":"Nozzle mismatch was detected during printing. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","0500_8055":"Laser module is installed, but a Cutting Platform is detected. Please place a Laser Platform and perform laser calibration.","0500_8056":"Cutting module is installed, but the laser platform is detected. Please place the cutting platform for calibration.","0500_8058":"Please place the light grip cutting mat correctly and ensure the marker is exposed.","0500_8059":"Cutting platform base is not correctly aligned. Please ensure that the four corners of the platform are aligned with the heatbed.","0500_805A":"Please place the cutting mat on cutting protection base.","0500_805B":"The cutting mat type is unknown; please replace it with the correct cutting mat.","0500_805C":"The grip cutting mat type does not match; please place a LightGrip cutting mat.","0500_805E":"Cutting module Serial Number error: unable to calibrate or make project.","0500_8060":"The current module on toolhead does not meet requirements. Please replace the module as per the on-screen instructions.","0500_8061":"No print plate detected. Please make sure it is placed correctly.","0500_8062":"The print plate marker was not detected. Please confirm the print plate is correctly positioned on the heatbed with all four corners aligned, and the marker is visible. If strong light is shining o...","0500_8063":"The platform is not detected during calibration; please make sure the Laser Platform is properly placed.","0500_8064":"Please place the Laser Platform correctly and ensure the rear markers are not blocked for laser calibration.","0500_8066":"The task requires a Cutting Platform, but the current one is a Laser Platform. Please replace it with a Cutting Platform (Cutting Protection Base + LightGrip cutting mat).","0500_8067":"Please place a LightGrip cutting mat on the cutting protection base.","0500_8068":"Please place the strong grip cutting mat correctly and ensure the marker is exposed.","0500_8069":"Unable to recognize the left and right hotends. They might be third party hotends, or the hotend marks may be dirty. Please manually set the hotend types.","0500_806A":"Unable to recognize the left and right hotends. They might be third party hotends, or the hotend marks may be dirty. Please set hotend types on printer screen before next print.","0500_806B":"Quick-release Lever is not locked. Please press down the external toolhead module to ensure it is properly seated, then push down the level to lock it in place.","0500_806C":"Please place the cutting platform correctly and ensure the marker is exposed.","0500_806D":"Material not detected. Please confirm placement and continue.","0500_806E":"Foreign objects detected on heatbed; please check and clean up the heatbed.","0500_806F":"The grip cutting mat type does not match; please place a StrongGrip cutting mat.","0500_8071":"No cutting platform was detected. Please confirm that it has been correctly placed.","0500_8072":"Live View camera is blocked","0500_8073":"Heatbed limit block is obstructed or contaminated. Please clean and ensure the limit block is visible, otherwise platform position offset detection may be inaccurate.","0500_8074":"The Laser Platform is offset. Please ensure that the four corners of the platform are aligned with the heatbed, and the marker is not obstructed.","0500_8077":"The visual marker was not detected. Please ensure the paper is properly placed.","0500_8078":"Current material does not match the sliced file settings. Please load the correct material and ensure the QR code on the material is not damaged or dirty.","0500_8079":"Please place the Laser Test Material (350g paperboard) and position support strips underneath to prevent material warping.","0500_807A":"The foreign object detection function is not working. You can continue the task or check the assistant for troubleshooting.","0500_807B":"Please place the cutting platform (cutting protection base + LightGrip cutting mat).","0500_807C":"Please place the cutting platform (cutting protection base + StrongGrip cutting mat).","0500_807D":"This task requires a Cutting Platform, but the current one is a Laser Platform. Please replace it with a Cutting Platform (Cutting Protection Base + StrongGrip Cutting Mat).","0500_807E":"Please place a StrongGrip cutting mat on the cutting protection base.","0500_8080":"The left and right hotends are not installed.","0500_8081":"The left and right hotends are not installed.","0500_8082":"Please remove the protective film on the Opaque Glossy Acrylic before processing","0500_8083":"Material is not allowed in Mounting Calibration. Please remove the material from the platform.","0500_8084":"The Live View Camera is dirty; please clean it and continue.","0500_8085":"Toolhead camera is obstructed","0500_8086":"Toolhead Camera is dirty, which affects the AI function; please clean the lens surface.","0500_8087":"BirdsEye camera is obstructed","0500_8088":"The Birdseye Camera is dirty","0500_8089":"Task paused due to Presence Check failed. Please check the printer to continue.","0500_808A":"The BirdsEye Camera is installed offset. Please refer to the assistant to reinstall it.","0500_808B":"The BirdsEye Camera setup failed. Please remove all objects and the mat on the heatbed to ensure the heatbed markers are visible. Meanwhile, please ensure the BirdsEye Camera is installed correctly...","0500_808C":"Detected build plate offset. Please align the build plate with the heatbed, and then continue.","0500_808D":"The Cutting Module offset calibration failed, which may result in inaccurate cuts. Please ensure the cutting material is properly positioned and check whether the cutting blade tip is worn.","0500_808E":"BirdsEye Camera initialization failed. The toolhead camera did not detect the Heatbed features. Please clean the Heatbed, remove all objects and pads, and ensure the bed markings are visible. Check...","0500_808F":"Nozzle camera lens is dirty, affecting AI monitoring. Clean the lens with a non-woven cloth and a small amount of alcohol. Beware of hotend heat; wait for it to cool before handling.","0500_8090":"Please attach the 80g White Printing Paper to the center area of the platform.","0500_8091":"The Cutting Module offset calibration failed, which may result in inaccurate cuts. Please ensure the 80g white printer paper(letter paper thickness) is properly positioned and check whether the cut...","0500_8092":"Toolhead Camera initialization failed. This print can still continue, but some AI functions will be disabled. If you encounter this issue again after restarting, please contact customer support.","0500_8093":"The nozzle silicone sleeve is not installed; there is a risk of temperature control failure. Please install it correctly and try again.","0500_80A0":"The visual encoder board was not detected. Please check if the board is properly placed and aligned at all four corners, and ensure the positioning markings are clear and free from wear.","0500_C010":"MicroSD Card read/write exception: please reinsert or replace the MicroSD Card.","0500_C032":"Laser/Cutting module connected to the toolhead. The drying process has been automatically stopped.","0500_C036":"This is a printing task. Please detach the Laser/Cutting Module from the Toolhead.","0500_C07F":"Device is busy and cannot perform this operation. To proceed, please pause or stop the current task.","0501_4017":"Binding failed. Please retry or restart the printer and retry.","0501_4018":"Binding configuration information parsing failed; please try again.","0501_4019":"The printer has already been bound. Please unbind it and try again.","0501_401A":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0501_401B":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_401C":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_401D":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_401E":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_401F":"Authorization timed out. Please make sure that your phone or PC has access to the internet, and ensure that the Bambu Studio/Bambu Handy APP is running in the foreground during the binding operation.","0501_4020":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4021":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_4022":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4023":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4024":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0501_4025":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4026":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4027":"Cloud access failed; this may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_4028":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4029":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4031":"Device discovery binding is in progress, and the QR code cannot be displayed on the screen. You can wait for the binding to finish or abort the device discovery binding process in the APP/Studio an...","0501_4032":"QR code binding is in progress, so device discovery binding cannot be performed. You can scan the QR code on the screen for binding or exit the QR code display page on screen and try device discove...","0501_4033":"Your APP region does not match with your printer; please download the APP in the corresponding region and register your account again.","0501_4034":"The slicing progress has not been updated for a long time, and the printing task has exited. Please confirm the parameters and reinitiate printing.","0501_4035":"The device is in the process of binding and cannot respond to new binding requests.","0501_4038":"The regional settings do not match the printer; please check the printer's regional settings.","0501_4039":"Device login has expired; please try to bind again.","0501_4098":"The device cannot detect AMS B. Please reconnect the AMS cable or restart the printer.","0501_409D":"The firmware of AMS B does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0501_40A3":"AMS(or AMS lite) B communication is abnormal. Please reconnect the module cable or restart the printer.","0502_4001":"Current filament will be used in this print job. Settings cannot be changed.","0502_4002":"Please go to “Settings > Calibration” to run the Motion Accuracy Enhancement Calibration before turning on Motion Accuracy Enhancement mode.","0502_4003":"The printer is currently printing and the motion accuracy enhancement feature cannot be turned on or off.","0502_4004":"Some features are not supported by the current device. Please check the Studio feature settings or update the firmware to the latest version.","0502_4005":"The AMS has not been calibrated yet, so printing cannot be initiated.","0502_4006":"Unknown module detected; please try updating the firmware to the latest version.","0502_400D":"Failed to start a new task: filament loading/unloading not completed.","0502_400E":"Failed to start a new task: The nozzle cold pull was not completed.","0502_4013":"This device is not compatible with the 40W laser module. Please replace it with a 10W laser module or remove it.","0502_4098":"The device cannot detect AMS C. Please reconnect the AMS cable or restart the printer.","0502_409D":"The firmware of AMS C does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0502_40A3":"AMS(or AMS lite) C communication is abnormal. Please reconnect the module cable or restart the printer.","0502_C00F":"The device is busy and cannot perform nozzle identification.","0502_C010":"Due to printer power limitations, printing, calibration, controls and other actions cannot be performed during AMS drying. Please stop the drying process before proceeding with any other operation.","0502_C011":"Currently in 2D production mode. Please continue the operation on the printer","0502_C012":"The task cannot be paused.","0502_C014":"The AMS Remaining Filament Estimation is enabled by default and cannot be disabled.","0502_C024":"The flow dynamic calibration records have exceeded the storage limit. Please delete some historical records in the slicer software before adding new calibration data.","0503_4098":"The device cannot detect AMS D. Please reconnect the AMS cable or restart the printer.","0503_409D":"The firmware of AMS D does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0503_40A3":"AMS(or AMS lite) D communication is abnormal. Please reconnect the module cable or restart the printer.","0580_4096":"The device cannot detect AMS-HT A. Please reconnect the AMS-HT cable or restart the printer.","0580_409C":"The firmware of AMS-HT A does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0580_40A2":"AMS-HT A communication is abnormal. Please reconnect the module cable or restart the printer.","0581_4096":"The device cannot detect AMS-HT B. Please reconnect the AMS-HT cable or restart the printer.","0581_409C":"The firmware of AMS-HT B does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0581_40A2":"AMS-HT B communication is abnormal. Please reconnect the module cable or restart the printer.","0582_4096":"The device cannot detect AMS-HT C. Please reconnect the AMS-HT cable or restart the printer.","0582_409C":"The firmware of AMS-HT C does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0582_40A2":"AMS-HT C communication is abnormal. Please reconnect the module cable or restart the printer.","0583_4096":"The device cannot detect AMS-HT D. Please reconnect the AMS-HT cable or restart the printer.","0583_409C":"The firmware of AMS-HT D does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0583_40A2":"AMS-HT D communication is abnormal. Please reconnect the module cable or restart the printer.","0584_4096":"The device cannot detect AMS-HT F. Please reconnect the AMS-HT cable or restart the printer.","0584_409C":"The firmware of AMS-HT E does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0584_40A2":"AMS-HT E communication is abnormal. Please reconnect the module cable or restart the printer.","0585_4096":"The device cannot detect AMS-HT E. Please reconnect the AMS-HT cable or restart the printer.","0585_409C":"The firmware of AMS-HT F does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0585_40A2":"AMS-HT F communication is abnormal. Please reconnect the module cable or restart the printer.","0586_4096":"The device cannot detect AMS-HT G. Please reconnect the AMS-HT cable or restart the printer.","0586_409C":"The firmware of AMS-HT G does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0586_40A2":"AMS-HT G communication is abnormal. Please reconnect the module cable or restart the printer.","0587_4096":"The device cannot detect AMS-HT H. Please reconnect the AMS-HT cable or restart the printer.","0587_409C":"The firmware of AMS-HT H does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0587_40A2":"AMS-HT H communication is abnormal. Please reconnect the module cable or restart the printer.","05FE_8053":"The left nozzle is not matched with slicing file. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","05FE_8069":"Unable to recognize the left hotend. It might be a third party hotend, or the hotend mark may be dirty. Please manually set the hotend type.","05FE_806A":"Unable to recognize the left hotend. It might be a third party hotend, or the hotend mark may be dirty. Please set hotend type on printer screen before next print.","05FE_8080":"The left hotend is not installed.","05FE_8081":"The left hotend is not installed.","05FF_8053":"The right nozzle is not matched with slicing file. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","05FF_8069":"Unable to recognize the right hotend. It might be a third party hotend, or the hotend mark may be dirty. Please manually set the hotend type.","05FF_806A":"Unable to recognize the right hotend. It might be a third party hotend, or the hotend mark may be dirty. Please set hotend type on printer screen before next print.","05FF_8080":"The right hotend is not installed.","05FF_8081":"The right hotend is not installed.","0700_4001":"The AMS has been disabled for a print, but it still has filament loaded. Please unload the AMS filament and switch to the spool holder filament for printing.","0700_4025":"Failed to read the filament information.","0700_8001":"Failed to cut the filament. Please check the cutter.","0700_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0700_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0700_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0700_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0700_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0700_8007":"Extruding filament failed. The extruder might be clogged.","0700_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS A to the extruder is properly connected.","0700_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0700_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0700_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0700_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0700_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0700_8017":"AMS A is drying. Please stop drying process before loading/unloading material.","0700_8021":"AMS setup failed; please refer to the assistant.","0700_8023":"AMS A cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0700_C069":"An error occurred during AMS A drying. Please go to Assistant for more details.","0700_C06A":"AMS A is reading RFID. Unable to start drying. Please try again later.","0700_C06B":"AMS A is changing filament. Unable to start drying. Please try again later.","0700_C06C":"AMS A is in Feed Assist Mode. Unable to start drying. Please try again later.","0700_C06D":"AMS A is assisting in filament insertion. Unable to start drying. Please try again later.","0700_C06E":"AMS A motor is performing self-test. Unable to start drying. Please try again later.","0701_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0701_4025":"Failed to read the filament information.","0701_8001":"Failed to cut the filament. Please check the cutter.","0701_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0701_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0701_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0701_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0701_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0701_8007":"Extruding filament failed. The extruder might be clogged.","0701_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS B to the extruder is properly connected.","0701_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0701_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0701_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0701_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0701_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0701_8017":"AMS B is drying. Please stop drying process before loading/unloading material.","0701_8021":"AMS setup failed; please refer to the assistant.","0701_8023":"AMS B cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0701_C069":"An error occurred during AMS B drying. Please go to Assistant for more details.","0701_C06A":"AMS B is reading RFID. Unable to start drying. Please try again later.","0701_C06B":"AMS B is changing filament. Unable to start drying. Please try again later.","0701_C06C":"AMS B is in Feed Assist Mode. Unable to start drying. Please try again later.","0701_C06D":"AMS B is assisting in filament insertion. Unable to start drying. Please try again later.","0701_C06E":"AMS B motor is performing self-test. Unable to start drying. Please try again later.","0702_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0702_4025":"Failed to read the filament information.","0702_8001":"Failed to cut the filament. Please check the cutter.","0702_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0702_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0702_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0702_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0702_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0702_8007":"Extruding filament failed. The extruder might be clogged.","0702_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS C to the extruder is properly connected.","0702_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0702_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0702_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0702_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0702_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0702_8017":"AMS C is drying. Please stop drying process before loading/unloading material.","0702_8021":"AMS setup failed; please refer to the assistant.","0702_8023":"AMS C cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0702_C069":"An error occurred during AMS C drying. Please go to Assistant for more details.","0702_C06A":"AMS C is reading RFID. Unable to start drying. Please try again later.","0702_C06B":"AMS C is changing filament. Unable to start drying. Please try again later.","0702_C06C":"AMS C is in Feed Assist Mode. Unable to start drying. Please try again later.","0702_C06D":"AMS C is assisting in filament insertion. Unable to start drying. Please try again later.","0702_C06E":"AMS C motor is performing self-test. Unable to start drying. Please try again later.","0703_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0703_4025":"Failed to read the filament information.","0703_8001":"Failed to cut the filament. Please check the cutter.","0703_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0703_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0703_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0703_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0703_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0703_8007":"Extruding filament failed. The extruder might be clogged.","0703_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS D to the extruder is properly connected.","0703_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0703_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0703_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0703_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0703_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0703_8017":"AMS D is drying. Please stop drying process before loading/unloading material.","0703_8021":"AMS setup failed; please refer to the assistant.","0703_8023":"AMS D cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0703_C069":"An error occurred during AMS D drying. Please go to Assistant for more details.","0703_C06A":"AMS D is reading RFID. Unable to start drying. Please try again later.","0703_C06B":"AMS D is changing filament. Unable to start drying. Please try again later.","0703_C06C":"AMS D is in Feed Assist Mode. Unable to start drying. Please try again later.","0703_C06D":"AMS D is assisting in filament insertion. Unable to start drying. Please try again later.","0703_C06E":"AMS D motor is performing self-test. Unable to start drying. Please try again later.","0704_4025":"Failed to read the filament information.","0704_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0704_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0704_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0704_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0704_8007":"Extruding filament failed. The extruder might be clogged.","0704_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS E to the extruder is properly connected.","0704_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0704_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0704_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0704_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0704_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0704_8021":"AMS setup failed; please refer to the assistant.","0704_8023":"AMS E cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0705_4025":"Failed to read the filament information.","0705_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0705_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0705_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0705_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0705_8007":"Extruding filament failed. The extruder might be clogged.","0705_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS F to the extruder is properly connected.","0705_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0705_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0705_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0705_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0705_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0705_8021":"AMS setup failed; please refer to the assistant.","0705_8023":"AMS F cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0706_4025":"Failed to read the filament information.","0706_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0706_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0706_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0706_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0706_8007":"Extruding filament failed. The extruder might be clogged.","0706_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS G to the extruder is properly connected.","0706_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0706_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0706_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0706_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0706_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0706_8021":"AMS setup failed; please refer to the assistant.","0706_8023":"AMS G cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0707_4025":"Failed to read the filament information.","0707_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0707_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0707_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0707_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0707_8007":"Extruding filament failed. The extruder might be clogged.","0707_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS H to the extruder is properly connected.","0707_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0707_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0707_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0707_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0707_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0707_8021":"AMS setup failed; please refer to the assistant.","0707_8023":"AMS H cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","07FE_8001":"Failed to cut the filament of the left extruder. Please check the cutter.","07FE_8002":"The cutter of the left extruder is stuck. Please pull out the cutter handle.","07FE_8003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are ab...","07FE_8004":"Failed to pull back the filament from the left extruder. Please check whether the filament is stuck inside the extruder.","07FE_8005":"Failed to feed the filament outside the AMS. Please clip the end of the filament flat and check to see if the spool is stuck.","07FE_8006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_8007":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","07FE_8010":"Check if the left external filament spool or filament is stuck.","07FE_8011":"The external filament connected to the left extruder has run out; please load a new filament.","07FE_8012":"Failed to get mapping table; please select 'Resume' to retry.","07FE_8013":"Timeout purging old filament of the left extruder: Please check if the filament is stuck or the extruder is clogged.","07FE_8020":"Extruder change failed; please refer to the assistant.","07FE_8021":"AMS setup failed; please refer to the assistant.","07FE_8024":"Extruder position calibration failed; please refer to the assistant.","07FE_8025":"Cold pull timed out. Please promptly operate or check whether the filament is broken inside the extruder, and click the Assistant for details.","07FE_8030":"The filament specified in the slicer has been used up. Printing is paused. Please go to the machine to replace the material and resume printing.","07FE_C003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","07FE_C006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_C008":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","07FE_C009":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_C00A":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","07FE_C010":"Insert the filament (over 30cm long) until it stops. You might see slight smoke during flushing. After insertion, close the front door and top cover.","07FE_C011":"Please manually and slowly pull out the filament from the extruder. Then click “Continue”.","07FE_C012":"Press the black PTFE tube coupler and unplug the PTFE tube. After completing the operation, click 'Continue.'","07FF_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","07FF_8001":"Failed to cut the filament of the right extruder. Please check the cutter.","07FF_8002":"The cutter is stuck. Please make sure the cutter handle is out.","07FF_8003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are a...","07FF_8004":"Failed to pull back the filament from the right extruder. Please check whether the filament is stuck inside the extruder.","07FF_8005":"Failed to feed the filament outside the AMS. Please clip the end of the filament flat and check to see if the spool is stuck.","07FF_8006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_8007":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","07FF_8010":"Check if the external filament spool or filament is stuck.","07FF_8011":"External filament has run out; please load a new filament.","07FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","07FF_8013":"Timeout purging old filament of the right extruder: Please check if the filament is stuck or the extruder is clogged.","07FF_8020":"Extruder change failed; please refer to the assistant.","07FF_8021":"AMS setup failed; please refer to the assistant.","07FF_8024":"Extruder position calibration failed; please refer to the assistant.","07FF_8025":"Cold pull timed out. Please promptly operate or check whether the filament is broken inside the extruder, and click the Assistant for details.","07FF_8030":"The filament specified in the slicer has been used up. Printing is paused. Please go to the machine to replace the material and resume printing.","07FF_C003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","07FF_C006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_C008":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","07FF_C009":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_C00A":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","07FF_C010":"Insert the filament (over 30cm long) until it stops. You might see slight smoke during flushing. After insertion, close the front door and top cover.","07FF_C011":"Hold the driven wheel bracket, slowly pull the filament from the extruder, then press 'Continue'.","07FF_C012":"Press the black PTFE tube coupler and unplug the PTFE tube. After completing the operation, click 'Continue.'","0C00_4020":"The setup of BirdsEye Camera failed. Please clear all objects and remove the mat. Make sure the marker is not obstructed. Meanwhile, clean both the BirdsEye Camera and Toolhead Camera, and remove a...","0C00_4021":"The setup of BirdsEye Camera failed; please reboot the printer.","0C00_4022":"The setup of BirdsEye Camera failed. Please check if the laser module is working properly.","0C00_4024":"The Birdseye Camera is installed offset. Please refer to the assistant to reinstall it.","0C00_4025":"The Birdseye Camera is dirty. Please clean it and restart the process.","0C00_4026":"The Live View Camera initialization failed; please reboot the printer.","0C00_4027":"The Live View Camera calibration failed. Please refer to the assistant for details and recalibrate the camera after processing.","0C00_4029":"Material not detected. Please confirm placement and continue.","0C00_402A":"The visual marker was not detected. Please re-paste the paper in the correct position.","0C00_402C":"Device data link error. Please reboot the printer","0C00_402D":"The toolhead camera is not working properly; please reboot the device.","0C00_403D":"The vision encoder plate was not detected. Please confirm it is correctly positioned on the heatbed.","0C00_403E":"The high-precision nozzle offset calibration has failed, possibly due to a damaged pattern or the similarity of the colors of the two selected filaments. Please clear the printed pattern and replac...","0C00_4041":"Toolhead camera calibration failed. Please ensure the Calibration Marker on the heatbed or Height Calibration Marker on the homing area is clean and undamaged, then re-run the calibration process.","0C00_8001":"First layer defects were detected. If the defects are acceptable, select 'Resume' to resume the print job.","0C00_8005":"Purged filament has piled up in the waste chute, which may cause a tool head collision.","0C00_8009":"Build plate localization marker was not found.","0C00_800B":"The heatbed marker was not detected. Please clear all objects and remove the mat. Make sure the marker is not obstructed.","0C00_8015":"Objects detected on the platform; please clean them up in a timely manner.","0C00_8016":"The foreign object detection function is not working. You can continue the task or check assistant for solutions.","0C00_8017":"Foreign objects detected on the platform; please clean them up on time.","0C00_8018":"The foreign object detection function is not working. You can continue the task or view the assistant for troubleshooting.","0C00_8033":"Quick-release Lever is not locked. Please push it down to secure.","0C00_8034":"Liveview Camera initialization failed. This print can still continue, but some AI functions will be disabled. If you encounter this issue again after restarting, please contact customer support.","0C00_803F":"AI detected nozzle clumping. Please check the nozzle condition. Refer to assistant for solutions.","0C00_8040":"AI detected air-printing defect. Please check the hotend extrusion status. Refer to assistant for solutions.","0C00_8042":"The AI print monitor has detected a spaghetti defect. Please check the print and take the necessary action.","0C00_8043":"AI detected nozzle clumping. Please check the nozzle condition. Refer to assistant for solutions.","0C00_C003":"Possible defects were detected in the first layer.","0C00_C004":"Possible spaghetti failure was detected.","0C00_C006":"Purged filament may have piled up in the waste chute.","1000_C001":"High bed temperature may lead to filament clogging in the nozzle. You may open the chamber door.","1000_C002":"Printing CF material with stainless steel may cause nozzle damage.","1000_C003":"Enabling Timelapse in traditional mode may cause defects; please activate this feature as needed.","1001_4001":"Timelapse is not supported as Spiral Vase mode is enabled in slicing presets.","1001_4002":"Timelapse is not supported as the Print sequence is set to 'By object'.","1001_8003":"The time-lapse mode is set to Traditional in the slicing file. This may cause surface defects. Would you like to enable it?","1001_8004":"Prime Tower is not enabled and time-lapse mode is set to Smooth in slicing file. This may cause surface defects. Would you like to enable it?","1200_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1200_8001":"Cutting the filament failed. Please check to see if the cutter is stuck. Refer to the Assistant for solutions.","1200_8002":"The cutter is stuck. Please pull out the cutter handle.","1200_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1200_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1200_8005":"The filament is not inserted. Please insert the filament.","1200_8006":"Unable to feed filament into the extruder. This could be due to tangled filament or a stuck spool. If not, please check if the AMS PTFE tube is connected.","1200_8007":"Failed to extrude the filament. This might be caused by clogged extruder or stuck filament. Refer to the Assistant for solutions.","1200_8010":"Filament or spool may be stuck.","1200_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1200_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1200_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1200_8014":"The filament location in the toolhead was not found. Refer to the Assistant for solutions.","1200_8015":"Failed to pull out the filament from the toolhead. Please check if the filament is stuck, or if it is broken inside the extruder or PTFE tube.","1200_8016":"The extruder is not extruding normally. Refer to the Assistant for troubleshooting. There may be defects in this layer, but you may resume if the defects are acceptable.","1201_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1201_8001":"Failed to cut the filament. Please check the cutter.","1201_8002":"The cutter is stuck. Please pull out the cutter handle.","1201_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1201_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1201_8005":"Failed to feed the filament. Please load the filament and then select 'Retry'.","1201_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1201_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1201_8010":"Please check if the spool or filament is stuck.","1201_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1201_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1201_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1201_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1201_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or the filament is broken inside the extruder.","1201_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","1202_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1202_8001":"Failed to cut the filament. Please check the cutter.","1202_8002":"The cutter is stuck. Please pull out the cutter handle.","1202_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1202_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1202_8005":"The filament is not inserted. Please insert the filament.","1202_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1202_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1202_8010":"Please check if the spool or filament is stuck.","1202_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1202_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1202_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1202_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1202_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or is broken inside the extruder.","1202_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","1203_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1203_8001":"Failed to cut the filament. Please check the cutter.","1203_8002":"The cutter is stuck. Please pull out the cutter handle.","1203_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1203_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1203_8005":"The filament is not inserted. Please insert the filament.","1203_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1203_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1203_8010":"Please check if the spool or filament is stuck.","1203_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1203_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1203_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1203_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1203_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or is broken inside the extruder.","1203_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","12FF_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","12FF_8001":"Failed to cut the filament. Please check the cutter.","12FF_8002":"The cutter is stuck. Please pull out the cutter handle.","12FF_8003":"Please pull out the filament on the spool holder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube if you are about to us...","12FF_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","12FF_8005":"The filament is not inserted. Please insert the filament.","12FF_8006":"Please feed filament into the PTFE tube until it can not be pushed any farther.","12FF_8007":"Check nozzle. Select 'Done' if filament was extruded, otherwise push filament forward slightly and select 'Retry.'","12FF_8010":"Please check if the filament or the spool is stuck.","12FF_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","12FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","12FF_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","12FF_C003":"Please pull out the filament on the spool holder. If this message persists, please check to see if there is filament broken in the extruder or PTFE Tube. (Connect a PTFE tube if you are about to us...","12FF_C006":"Please feed filament into the PTFE tube until it can not be pushed any farther.","1800_4025":"Failed to read the filament information.","1800_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1800_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1800_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1800_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1800_8007":"Extruding filament failed. The extruder might be clogged.","1800_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT A to the extruder is properly connected.","1800_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1800_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1800_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1800_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1800_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1800_8017":"AMS-HT A is drying. Please stop drying process before loading/unloading material.","1800_8021":"AMS setup failed; please refer to the assistant.","1800_8023":"AMS-HT A cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1800_C069":"An error occurred during AMS-HT A drying. Please go to Assistant for more details.","1800_C06A":"AMS-HT A is reading RFID. Unable to start drying. Please try again later.","1800_C06B":"AMS-HT A is changing filament. Unable to start drying. Please try again later.","1800_C06C":"AMS-HT A is in Feed Assist Mode. Unable to start drying. Please try again later.","1800_C06D":"AMS-HT A is assisting in filament insertion. Unable to start drying. Please try again later.","1800_C06E":"AMS-HT A motor is performing self-test. Unable to start drying. Please try again later.","1801_4025":"Failed to read the filament information.","1801_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1801_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1801_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1801_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1801_8007":"Extruding filament failed. The extruder might be clogged.","1801_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT B to the extruder is properly connected.","1801_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1801_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1801_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1801_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1801_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1801_8017":"AMS-HT B is drying. Please stop drying process before loading/unloading material.","1801_8021":"AMS setup failed; please refer to the assistant.","1801_8023":"AMS-HT B cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1801_C069":"An error occurred during AMS-HT B drying. Please go to Assistant for more details.","1801_C06A":"AMS-HT B is reading RFID. Unable to start drying. Please try again later.","1801_C06B":"AMS-HT B is changing filament. Unable to start drying. Please try again later.","1801_C06C":"AMS-HT B is in Feed Assist Mode. Unable to start drying. Please try again later.","1801_C06D":"AMS-HT B is assisting in filament insertion. Unable to start drying. Please try again later.","1801_C06E":"AMS-HT B motor is performing self-test. Unable to start drying. Please try again later.","1802_4025":"Failed to read the filament information.","1802_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1802_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1802_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1802_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1802_8007":"Extruding filament failed. The extruder might be clogged.","1802_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT C to the extruder is properly connected.","1802_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1802_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1802_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1802_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1802_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1802_8017":"AMS-HT C is drying. Please stop drying process before loading/unloading material.","1802_8021":"AMS setup failed; please refer to the assistant.","1802_8023":"AMS-HT C cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1802_C069":"An error occurred during AMS-HT C drying. Please go to Assistant for more details.","1802_C06A":"AMS-HT C is reading RFID. Unable to start drying. Please try again later.","1802_C06B":"AMS-HT C is changing filament. Unable to start drying. Please try again later.","1802_C06C":"AMS-HT C is in Feed Assist Mode. Unable to start drying. Please try again later.","1802_C06D":"AMS-HT C is assisting in filament insertion. Unable to start drying. Please try again later.","1802_C06E":"AMS-HT C motor is performing self-test. Unable to start drying. Please try again later.","1803_4025":"Failed to read the filament information.","1803_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1803_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1803_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1803_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1803_8007":"Extruding filament failed. The extruder might be clogged.","1803_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT D to the extruder is properly connected.","1803_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1803_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1803_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1803_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1803_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1803_8017":"AMS-HT D is drying. Please stop drying process before loading/unloading material.","1803_8021":"AMS setup failed; please refer to the assistant.","1803_8023":"AMS-HT D cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1803_C069":"An error occurred during AMS-HT D drying. Please go to Assistant for more details.","1803_C06A":"AMS-HT D is reading RFID. Unable to start drying. Please try again later.","1803_C06B":"AMS-HT D is changing filament. Unable to start drying. Please try again later.","1803_C06C":"AMS-HT D is in Feed Assist Mode. Unable to start drying. Please try again later.","1803_C06D":"AMS-HT D is assisting in filament insertion. Unable to start drying. Please try again later.","1803_C06E":"AMS-HT D motor is performing self-test. Unable to start drying. Please try again later.","1804_4025":"Failed to read the filament information.","1804_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1804_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1804_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1804_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1804_8007":"Extruding filament failed. The extruder might be clogged.","1804_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT E to the extruder is properly connected.","1804_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1804_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1804_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1804_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1804_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1804_8021":"AMS setup failed; please refer to the assistant.","1804_8023":"AMS-HT E cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1804_C069":"An error occurred during AMS-HT E drying. Please go to Assistant for more details.","1804_C06A":"AMS-HT E is reading RFID. Unable to start drying. Please try again later.","1804_C06B":"AMS-HT E is changing filament. Unable to start drying. Please try again later.","1804_C06C":"AMS-HT E is in Feed Assist Mode. Unable to start drying. Please try again later.","1804_C06D":"AMS-HT E is assisting in filament insertion. Unable to start drying. Please try again later.","1804_C06E":"AMS-HT E motor is performing self-test. Unable to start drying. Please try again later.","1805_4025":"Failed to read the filament information.","1805_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1805_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1805_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1805_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1805_8007":"Extruding filament failed. The extruder might be clogged.","1805_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT F to the extruder is properly connected.","1805_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1805_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1805_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1805_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1805_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1805_8021":"AMS setup failed; please refer to the assistant.","1805_8023":"AMS-HT F cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1805_C069":"An error occurred during AMS-HT F drying. Please go to Assistant for more details.","1805_C06A":"AMS-HT F is reading RFID. Unable to start drying. Please try again later.","1805_C06B":"AMS-HT F is changing filament. Unable to start drying. Please try again later.","1805_C06C":"AMS-HT F is in Feed Assist Mode. Unable to start drying. Please try again later.","1805_C06D":"AMS-HT F is assisting in filament insertion. Unable to start drying. Please try again later.","1805_C06E":"AMS-HT F motor is performing self-test. Unable to start drying. Please try again later.","1806_4025":"Failed to read the filament information.","1806_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1806_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1806_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1806_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1806_8007":"Extruding filament failed. The extruder might be clogged.","1806_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT G to the extruder is properly connected.","1806_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1806_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1806_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1806_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1806_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1806_8021":"AMS setup failed; please refer to the assistant.","1806_8023":"AMS-HT G cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1806_C069":"An error occurred during AMS-HT G drying. Please go to Assistant for more details.","1806_C06A":"AMS-HT G is reading RFID. Unable to start drying. Please try again later.","1806_C06B":"AMS-HT G is changing filament. Unable to start drying. Please try again later.","1806_C06C":"AMS-HT G is in Feed Assist Mode. Unable to start drying. Please try again later.","1806_C06D":"AMS-HT G is assisting in filament insertion. Unable to start drying. Please try again later.","1806_C06E":"AMS-HT G motor is performing self-test. Unable to start drying. Please try again later.","1807_4025":"Failed to read the filament information.","1807_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1807_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1807_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1807_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1807_8007":"Extruding filament failed. The extruder might be clogged.","1807_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT H to the extruder is properly connected.","1807_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1807_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1807_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1807_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1807_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1807_8021":"AMS setup failed; please refer to the assistant.","1807_8023":"AMS-HT H cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1807_C069":"An error occurred during AMS-HT H drying. Please go to Assistant for more details.","1807_C06A":"AMS-HT H is reading RFID. Unable to start drying. Please try again later.","1807_C06B":"AMS-HT H is changing filament. Unable to start drying. Please try again later.","1807_C06C":"AMS-HT H is in Feed Assist Mode. Unable to start drying. Please try again later.","1807_C06D":"AMS-HT H is assisting in filament insertion. Unable to start drying. Please try again later.","1807_C06E":"AMS-HT H motor is performing self-test. Unable to start drying. Please try again later.","18FE_8001":"Failed to cut the filament of the left extruder. Please check the cutter.","18FE_8002":"The cutter of the left extruder is stuck. Please pull out the cutter handle.","18FE_8003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are ab...","18FE_8004":"Failed to pull back the filament from the left extruder. Please check whether the filament is stuck inside the extruder.","18FE_8005":"Failed to feed the filament outside the AMS-HT. Please clip the end of the filament flat and check to see if the spool is stuck.","18FE_8006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_8007":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","18FE_8011":"The external filament connected to the left extruder has run out; please load a new filament.","18FE_8012":"Failed to get mapping table; please select 'Resume' to retry.","18FE_8013":"Timeout purging old filament of the left extruder: Please check if the filament is stuck or the extruder is clogged.","18FE_8020":"Extruder change failed; please refer to the assistant.","18FE_8021":"AMS setup failed; please refer to the assistant.","18FE_8024":"Extruder position calibration failed; please refer to the assistant.","18FE_C003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","18FE_C006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_C008":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","18FE_C009":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_C00A":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","18FF_8001":"Failed to cut the filament of the right extruder. Please check the cutter.","18FF_8002":"The cutter of the right extruder is stuck. Please pull out the cutter handle.","18FF_8003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are a...","18FF_8004":"Failed to pull back the filament from the right extruder. Please check whether the filament is stuck inside the extruder.","18FF_8005":"Failed to feed the filament outside the AMS-HT. Please clip the end of the filament flat and check to see if the spool is stuck.","18FF_8006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_8007":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","18FF_8011":"The external filament connected to the right extruder has run out; please load a new filament.","18FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","18FF_8013":"Timeout purging old filament of the right extruder: Please check if the filament is stuck or the extruder is clogged.","18FF_8020":"Extruder change failed; please refer to the assistant.","18FF_8021":"AMS setup failed; please refer to the assistant.","18FF_8024":"Extruder position calibration failed; please refer to the assistant.","18FF_C003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","18FF_C006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_C008":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","18FF_C009":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_C00A":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'."};function HNe(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:jn};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:jn};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:Ii};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:Qo}}}function MP(t,e){const n=t>>16&65535||(t>>8&255)<<8|t&255,r=e&65535;return`${n.toString(16).padStart(4,"0").toUpperCase()}_${r.toString(16).padStart(4,"0").toUpperCase()}`}function VNe(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=MP(e.attr,n);return NP[r]!==void 0})}function GNe(){return"https://wiki.bambulab.com/en/hms/home"}function qNe({printerName:t,errors:e,onClose:n}){console.log("HMSErrorModal errors:",JSON.stringify(e,null,2));const r=e.filter(i=>{const s=parseInt(i.code.replace("0x",""),16)||0,o=MP(i.attr,s);return NP[o]!==void 0});return w.useEffect(()=>{const i=s=>{s.key==="Escape"&&n()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[n]),a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(jn,{className:"w-5 h-5 text-orange-400"}),a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Errors - ",t]})]}),a.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Dt,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r.length===0?a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(Ii,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{children:"No errors"})]}):a.jsx("div",{className:"space-y-3",children:r.map((i,s)=>{const{label:o,color:l,bgColor:c,Icon:u}=HNe(i.severity),d=parseInt(i.code.replace("0x",""),16)||0,f=MP(i.attr,d),m=NP[f],p=GNe(),x=f.replace("_","-");return a.jsx("div",{className:`p-4 rounded-lg ${c} border border-white/10`,children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(u,{className:`w-5 h-5 ${l} flex-shrink-0 mt-0.5`}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsxs("span",{className:`font-mono text-sm ${l}`,children:["[",x,"]"]}),a.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${c} ${l}`,children:o})]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:m}),a.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[a.jsx(Yr,{className:"w-3 h-3"}),"View on Bambu Lab Wiki"]})]})]})},`${i.code}-${s}`)})})}),a.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:a.jsx("p",{className:"text-xs text-bambu-gray",children:"Clear errors on the printer to dismiss them here."})})]})})}function WNe(t){if(!t)return"ASAP";const e=Ri(t);if(!e)return"ASAP";const 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 KNe({printerId:t}){const{data:e}=at({queryKey:["queue",t,"pending"],queryFn:()=>ue.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:a.jsx(Os,{to:"/queue",className:"block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx(ti,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"Next in queue"}),a.jsx("p",{className:"text-sm text-white truncate",children:n?.archive_name||`Archive #${n?.archive_id}`})]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[a.jsx(Qn,{className:"w-3 h-3"}),WNe(n?.scheduled_time||null)]}),r>1&&a.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",r-1]}),a.jsx(vs,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function uX(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=uX(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function Zn(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=uX(t))&&(r&&(r+=" "),r+=e);return r}var XNe=["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 m4(t){if(typeof t!="string")return!1;var e=XNe;return e.includes(t)}var YNe=["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"],QNe=new Set(YNe);function dX(t){return typeof t!="string"?!1:QNe.has(t)}function hX(t){return typeof t=="string"&&t.startsWith("data-")}function _s(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(dX(n)||hX(n))&&(e[n]=t[n]);return e}function fm(t){if(t==null)return null;if(w.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return _s(e)}return typeof t=="object"&&!Array.isArray(t)?_s(t):null}function La(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(dX(n)||hX(n)||m4(n))&&(e[n]=t[n]);return e}function ZNe(t){return t==null?null:w.isValidElement(t)?La(t.props):typeof t=="object"&&!Array.isArray(t)?La(t):null}var JNe=["children","width","height","viewBox","className","style","title","desc"];function EP(){return EP=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},EP.apply(null,arguments)}function eMe(t,e){if(t==null)return{};var n,r,i=tMe(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 tMe(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 p4=w.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:s,className:o,style:l,title:c,desc:u}=t,d=eMe(t,JNe),f=s||{width:r,height:i,x:0,y:0},m=Zn("recharts-surface",o);return w.createElement("svg",EP({},La(d),{className:m,width:r,height:i,style:l,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:e}),w.createElement("title",null,c),w.createElement("desc",null,u),n)}),nMe=["children","className"];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)}function rMe(t,e){if(t==null)return{};var n,r,i=iMe(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 iMe(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 ni=w.forwardRef((t,e)=>{var{children:n,className:r}=t,i=rMe(t,nMe),s=Zn("recharts-layer",r);return w.createElement("g",CP({className:s},La(i),{ref:e}),n)}),fX=w.createContext(null),aMe=()=>w.useContext(fX);function Lr(t){return function(){return t}}const mX=Math.cos,cS=Math.sin,Bl=Math.sqrt,uS=Math.PI,jN=2*uS,TP=Math.PI,AP=2*TP,_f=1e-6,sMe=AP-_f;function pX(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function oMe(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return pX;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 lMe{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?pX:oMe(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,o){this._append`C${+e},${+n},${+r},${+i},${this._x1=+s},${this._y1=+o}`}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 o=this._x1,l=this._y1,c=r-e,u=i-n,d=o-e,f=l-n,m=d*d+f*f;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(m>_f)if(!(Math.abs(f*c-u*d)>_f)||!s)this._append`L${this._x1=e},${this._y1=n}`;else{let p=r-o,x=i-l,b=c*c+u*u,y=p*p+x*x,v=Math.sqrt(b),S=Math.sqrt(m),N=s*Math.tan((TP-Math.acos((b+m-y)/(2*v*S)))/2),C=N/S,T=N/v;Math.abs(C-1)>_f&&this._append`L${e+C*d},${n+C*f}`,this._append`A${s},${s},0,0,${+(f*p>d*x)},${this._x1=e+T*c},${this._y1=n+T*u}`}}arc(e,n,r,i,s,o){if(e=+e,n=+n,r=+r,o=!!o,r<0)throw new Error(`negative radius: ${r}`);let l=r*Math.cos(i),c=r*Math.sin(i),u=e+l,d=n+c,f=1^o,m=o?i-s:s-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>_f||Math.abs(this._y1-d)>_f)&&this._append`L${u},${d}`,r&&(m<0&&(m=m%AP+AP),m>sMe?this._append`A${r},${r},0,1,${f},${e-l},${n-c}A${r},${r},0,1,${f},${this._x1=u},${this._y1=d}`:m>_f&&this._append`A${r},${r},0,${+(m>=TP)},${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 g4(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 lMe(e)}function x4(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function gX(t){this._context=t}gX.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 PN(t){return new gX(t)}function xX(t){return t[0]}function bX(t){return t[1]}function yX(t,e){var n=Lr(!0),r=null,i=PN,s=null,o=g4(l);t=typeof t=="function"?t:t===void 0?xX:Lr(t),e=typeof e=="function"?e:e===void 0?bX:Lr(e);function l(c){var u,d=(c=x4(c)).length,f,m=!1,p;for(r==null&&(s=i(p=o())),u=0;u<=d;++u)!(u<d&&n(f=c[u],u,c))===m&&((m=!m)?s.lineStart():s.lineEnd()),m&&s.point(+t(f,u,c),+e(f,u,c));if(p)return s=null,p+""||null}return l.x=function(c){return arguments.length?(t=typeof c=="function"?c:Lr(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:Lr(+c),l):e},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:Lr(!!c),l):n},l.curve=function(c){return arguments.length?(i=c,r!=null&&(s=i(r)),l):i},l.context=function(c){return arguments.length?(c==null?r=s=null:s=i(r=c),l):r},l}function Ow(t,e,n){var r=null,i=Lr(!0),s=null,o=PN,l=null,c=g4(u);t=typeof t=="function"?t:t===void 0?xX:Lr(+t),e=typeof e=="function"?e:Lr(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?bX:Lr(+n);function u(f){var m,p,x,b=(f=x4(f)).length,y,v=!1,S,N=new Array(b),C=new Array(b);for(s==null&&(l=o(S=c())),m=0;m<=b;++m){if(!(m<b&&i(y=f[m],m,f))===v)if(v=!v)p=m,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),x=m-1;x>=p;--x)l.point(N[x],C[x]);l.lineEnd(),l.areaEnd()}v&&(N[m]=+t(y,m,f),C[m]=+e(y,m,f),l.point(r?+r(y,m,f):N[m],n?+n(y,m,f):C[m]))}if(S)return l=null,S+""||null}function d(){return yX().defined(i).curve(o).context(s)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:Lr(+f),r=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Lr(+f),u):t},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Lr(+f),u):r},u.y=function(f){return arguments.length?(e=typeof f=="function"?f:Lr(+f),n=null,u):e},u.y0=function(f){return arguments.length?(e=typeof f=="function"?f:Lr(+f),u):e},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Lr(+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:Lr(!!f),u):i},u.curve=function(f){return arguments.length?(o=f,s!=null&&(l=o(s)),u):o},u.context=function(f){return arguments.length?(f==null?s=l=null:l=o(s=f),u):s},u}class vX{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 cMe(t){return new vX(t,!0)}function uMe(t){return new vX(t,!1)}const b4={draw(t,e){const n=Bl(e/uS);t.moveTo(n,0),t.arc(0,0,n,0,jN)}},dMe={draw(t,e){const n=Bl(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()}},_X=Bl(1/3),hMe=_X*2,fMe={draw(t,e){const n=Bl(e/hMe),r=n*_X;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},mMe={draw(t,e){const n=Bl(e),r=-n/2;t.rect(r,r,n,n)}},pMe=.8908130915292852,wX=cS(uS/10)/cS(7*uS/10),gMe=cS(jN/10)*wX,xMe=-mX(jN/10)*wX,bMe={draw(t,e){const n=Bl(e*pMe),r=gMe*n,i=xMe*n;t.moveTo(0,-n),t.lineTo(r,i);for(let s=1;s<5;++s){const o=jN*s/5,l=mX(o),c=cS(o);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},EA=Bl(3),yMe={draw(t,e){const n=-Bl(e/(EA*3));t.moveTo(0,n*2),t.lineTo(-EA*n,-n),t.lineTo(EA*n,-n),t.closePath()}},Lo=-.5,Io=Bl(3)/2,kP=1/Bl(12),vMe=(kP/2+1)*3,_Me={draw(t,e){const n=Bl(e/vMe),r=n/2,i=n*kP,s=r,o=n*kP+n,l=-s,c=o;t.moveTo(r,i),t.lineTo(s,o),t.lineTo(l,c),t.lineTo(Lo*r-Io*i,Io*r+Lo*i),t.lineTo(Lo*s-Io*o,Io*s+Lo*o),t.lineTo(Lo*l-Io*c,Io*l+Lo*c),t.lineTo(Lo*r+Io*i,Lo*i-Io*r),t.lineTo(Lo*s+Io*o,Lo*o-Io*s),t.lineTo(Lo*l+Io*c,Lo*c-Io*l),t.closePath()}};function wMe(t,e){let n=null,r=g4(i);t=typeof t=="function"?t:Lr(t||b4),e=typeof e=="function"?e:Lr(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:Lr(s),i):t},i.size=function(s){return arguments.length?(e=typeof s=="function"?s:Lr(+s),i):e},i.context=function(s){return arguments.length?(n=s??null,i):n},i}function dS(){}function hS(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 SX(t){this._context=t}SX.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:hS(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:hS(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function SMe(t){return new SX(t)}function NX(t){this._context=t}NX.prototype={areaStart:dS,areaEnd:dS,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:hS(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function NMe(t){return new NX(t)}function MX(t){this._context=t}MX.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:hS(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function MMe(t){return new MX(t)}function EX(t){this._context=t}EX.prototype={areaStart:dS,areaEnd:dS,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 EMe(t){return new EX(t)}function W6(t){return t<0?-1:1}function K6(t,e,n){var r=t._x1-t._x0,i=e-t._x1,s=(t._y1-t._y0)/(r||i<0&&-0),o=(n-t._y1)/(i||r<0&&-0),l=(s*i+o*r)/(r+i);return(W6(s)+W6(o))*Math.min(Math.abs(s),Math.abs(o),.5*Math.abs(l))||0}function X6(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function CA(t,e,n){var r=t._x0,i=t._y0,s=t._x1,o=t._y1,l=(s-r)/3;t._context.bezierCurveTo(r+l,i+l*e,s-l,o-l*n,s,o)}function fS(t){this._context=t}fS.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:CA(this,this._t0,X6(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,CA(this,X6(this,n=K6(this,t,e)),n);break;default:CA(this,this._t0,n=K6(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function CX(t){this._context=new TX(t)}(CX.prototype=Object.create(fS.prototype)).point=function(t,e){fS.prototype.point.call(this,e,t)};function TX(t){this._context=t}TX.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 CMe(t){return new fS(t)}function TMe(t){return new CX(t)}function AX(t){this._context=t}AX.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=Y6(t),i=Y6(e),s=0,o=1;o<n;++s,++o)this._context.bezierCurveTo(r[0][s],i[0][s],r[1][s],i[1][s],t[o],e[o]);(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 Y6(t){var e,n=t.length-1,r,i=new Array(n),s=new Array(n),o=new Array(n);for(i[0]=0,s[0]=2,o[0]=t[0]+2*t[1],e=1;e<n-1;++e)i[e]=1,s[e]=4,o[e]=4*t[e]+2*t[e+1];for(i[n-1]=2,s[n-1]=7,o[n-1]=8*t[n-1]+t[n],e=1;e<n;++e)r=i[e]/s[e-1],s[e]-=r,o[e]-=r*o[e-1];for(i[n-1]=o[n-1]/s[n-1],e=n-2;e>=0;--e)i[e]=(o[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 AMe(t){return new AX(t)}function RN(t,e){this._context=t,this._t=e}RN.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 kMe(t){return new RN(t,.5)}function jMe(t){return new RN(t,0)}function PMe(t){return new RN(t,1)}function Zg(t,e){if((o=t.length)>1)for(var n=1,r,i,s=t[e[0]],o,l=s.length;n<o;++n)for(i=s,s=t[e[n]],r=0;r<l;++r)s[r][1]+=s[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function jP(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function RMe(t,e){return t[e]}function DMe(t){const e=[];return e.key=t,e}function OMe(){var t=Lr([]),e=jP,n=Zg,r=RMe;function i(s){var o=Array.from(t.apply(this,arguments),DMe),l,c=o.length,u=-1,d;for(const f of s)for(l=0,++u;l<c;++l)(o[l][u]=[0,+r(f,o[l].key,u,s)]).data=f;for(l=0,d=x4(e(o));l<c;++l)o[d[l]].index=l;return n(o,d),o}return i.keys=function(s){return arguments.length?(t=typeof s=="function"?s:Lr(Array.from(s)),i):t},i.value=function(s){return arguments.length?(r=typeof s=="function"?s:Lr(+s),i):r},i.order=function(s){return arguments.length?(e=s==null?jP:typeof s=="function"?s:Lr(Array.from(s)),i):e},i.offset=function(s){return arguments.length?(n=s??Zg,i):n},i}function LMe(t,e){if((r=t.length)>0){for(var n,r,i=0,s=t[0].length,o;i<s;++i){for(o=n=0;n<r;++n)o+=t[n][i][1]||0;if(o)for(n=0;n<r;++n)t[n][i][1]/=o}Zg(t,e)}}function IMe(t,e){if((i=t.length)>0){for(var n=0,r=t[e[0]],i,s=r.length;n<s;++n){for(var o=0,l=0;o<i;++o)l+=t[o][n][1]||0;r[n][1]+=r[n][0]=-l/2}Zg(t,e)}}function FMe(t,e){if(!(!((o=t.length)>0)||!((s=(i=t[e[0]]).length)>0))){for(var n=0,r=1,i,s,o;r<s;++r){for(var l=0,c=0,u=0;l<o;++l){for(var d=t[e[l]],f=d[r][1]||0,m=d[r-1][1]||0,p=(f-m)/2,x=0;x<l;++x){var b=t[e[x]],y=b[r][1]||0,v=b[r-1][1]||0;p+=y-v}c+=f,u+=p*f}i[r-1][1]+=i[r-1][0]=n,c&&(n-=u/c)}i[r-1][1]+=i[r-1][0]=n,Zg(t,e)}}var TA={},AA={},Q6;function UMe(){return Q6||(Q6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(AA)),AA}var kA={},Z6;function kX(){return Z6||(Z6=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})(kA)),kA}var jA={},J6;function y4(){return J6||(J6=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})(jA)),jA}var PA={},RA={},e$;function zMe(){return e$||(e$=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})(RA)),RA}var t$;function v4(){return t$||(t$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=zMe(),n=y4();function r(i){if(Array.isArray(i))return i.map(n.toKey);if(typeof i=="symbol")return[i];i=e.toString(i);const s=[],o=i.length;if(o===0)return s;let l=0,c="",u="",d=!1;for(i.charCodeAt(0)===46&&(s.push(""),l++);l<o;){const f=i[l];u?f==="\\"&&l+1<o?(l++,c+=i[l]):f===u?u="":c+=f:d?f==='"'||f==="'"?u=f:f==="]"?(d=!1,s.push(c),c=""):c+=f:f==="["?(d=!0,c&&(s.push(c),c="")):f==="."?c&&(s.push(c),c=""):c+=f,l++}return c&&s.push(c),s}t.toPath=r})(PA)),PA}var n$;function _4(){return n$||(n$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=UMe(),n=kX(),r=y4(),i=v4();function s(l,c,u){if(l==null)return u;switch(typeof c){case"string":{if(e.isUnsafeProperty(c))return u;const d=l[c];return d===void 0?n.isDeepKey(c)?s(l,i.toPath(c),u):u:d}case"number":case"symbol":{typeof c=="number"&&(c=r.toKey(c));const d=l[c];return d===void 0?u:d}default:{if(Array.isArray(c))return o(l,c,u);if(Object.is(c?.valueOf(),-0)?c="-0":c=String(c),e.isUnsafeProperty(c))return u;const d=l[c];return d===void 0?u:d}}}function o(l,c,u){if(c.length===0)return u;let d=l;for(let f=0;f<c.length;f++){if(d==null||e.isUnsafeProperty(c[f]))return u;d=d[c[f]]}return d===void 0?u:d}t.get=s})(TA)),TA}var DA,r$;function BMe(){return r$||(r$=1,DA=_4().get),DA}var $Me=BMe();const mm=ul($Me);var ga=t=>t===0?0:t>0?1:-1,Gs=t=>typeof t=="number"&&t!=+t,Iu=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Bt=t=>(typeof t=="number"||t instanceof Number)&&!Gs(t),ol=t=>Bt(t)||typeof t=="string",HMe=0,ay=t=>{var e=++HMe;return"".concat(t||"").concat(e)},Za=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(!Bt(e)&&typeof e!="string")return r;var s;if(Iu(e)){if(n==null)return r;var o=e.indexOf("%");s=n*parseFloat(e.slice(0,o))/100}else s=+e;return Gs(s)&&(s=r),i&&n!=null&&s>n&&(s=n),s},jX=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 ur(t,e,n){return Bt(t)&&Bt(e)?t+n*(e-t):e}function PX(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):mm(r,e))===n)}var Gr=t=>t===null||typeof t>"u",Hy=t=>Gr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function VMe(t){return t!=null}function Vy(){}var GMe=["type","size","sizeType"];function PP(){return PP=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},PP.apply(null,arguments)}function i$(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?i$(Object(n),!0).forEach(function(r){qMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function qMe(t,e,n){return(e=WMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function WMe(t){var e=KMe(t,"string");return typeof e=="symbol"?e:e+""}function KMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function XMe(t,e){if(t==null)return{};var n,r,i=YMe(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 YMe(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 RX={symbolCircle:b4,symbolCross:dMe,symbolDiamond:fMe,symbolSquare:mMe,symbolStar:bMe,symbolTriangle:yMe,symbolWye:_Me},QMe=Math.PI/180,ZMe=t=>{var e="symbol".concat(Hy(t));return RX[e]||b4},JMe=(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*QMe;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}},eEe=(t,e)=>{RX["symbol".concat(Hy(t))]=e},w4=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=XMe(t,GMe),s=a$(a$({},i),{},{type:e,size:n,sizeType:r}),o="circle";typeof e=="string"&&(o=e);var l=()=>{var m=ZMe(o),p=wMe().type(m).size(JMe(n,r,o)),x=p();if(x!==null)return x},{className:c,cx:u,cy:d}=s,f=La(s);return Bt(u)&&Bt(d)&&Bt(n)?w.createElement("path",PP({},f,{className:Zn("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:l()})):null};w4.registerSymbol=eEe;var DX=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,S4=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(w.isValidElement(t)&&(n=t.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{m4(i)&&(r[i]=(s=>n[i](n,s)))}),r},tEe=(t,e,n)=>r=>(t(e,n,r),null),Gy=(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];m4(i)&&typeof s=="function"&&(r||(r={}),r[i]=tEe(s,e,n))}),r};function s$(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 nEe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?s$(Object(n),!0).forEach(function(r){rEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):s$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function rEe(t,e,n){return(e=iEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function iEe(t){var e=aEe(t,"string");return typeof e=="symbol"?e:e+""}function aEe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ri(t,e){var n=nEe({},t),r=e,i=Object.keys(e),s=i.reduce((o,l)=>(o[l]===void 0&&r[l]!==void 0&&(o[l]=r[l]),o),n);return s}function mS(){return mS=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},mS.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 sEe(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){oEe(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 oEe(t,e,n){return(e=lEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lEe(t){var e=cEe(t,"string");return typeof e=="symbol"?e:e+""}function cEe(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 zo=32,uEe={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function dEe(t){var{data:e,iconType:n,inactiveColor:r}=t,i=zo/2,s=zo/6,o=zo/3,l=e.inactive?r:e.color,c=n??e.type;if(c==="none")return null;if(c==="plainline"){var u;return w.createElement("line",{strokeWidth:4,fill:"none",stroke:l,strokeDasharray:(u=e.payload)===null||u===void 0?void 0:u.strokeDasharray,x1:0,y1:i,x2:zo,y2:i,className:"recharts-legend-icon"})}if(c==="line")return w.createElement("path",{strokeWidth:4,fill:"none",stroke:l,d:"M0,".concat(i,"h").concat(o,`
  8062. A`).concat(s,",").concat(s,",0,1,1,").concat(2*o,",").concat(i,`
  8063. H`).concat(zo,"M").concat(2*o,",").concat(i,`
  8064. A`).concat(s,",").concat(s,",0,1,1,").concat(o,",").concat(i),className:"recharts-legend-icon"});if(c==="rect")return w.createElement("path",{stroke:"none",fill:l,d:"M0,".concat(zo/8,"h").concat(zo,"v").concat(zo*3/4,"h").concat(-zo,"z"),className:"recharts-legend-icon"});if(w.isValidElement(e.legendIcon)){var d=sEe({},e);return delete d.legendIcon,w.cloneElement(e.legendIcon,d)}return w.createElement(w4,{fill:l,cx:i,cy:i,size:zo,sizeType:"diameter",type:c})}function hEe(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:s,iconType:o}=t,l={x:0,y:0,width:zo,height:zo},c={display:r==="horizontal"?"inline-block":"block",marginRight:10},u={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,f)=>{var m=d.formatter||i,p=Zn({"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,b=m?m(d.value,d,f):d.value;return w.createElement("li",mS({className:p,style:c,key:"legend-item-".concat(f)},Gy(t,d,f)),w.createElement(p4,{width:n,height:n,viewBox:l,style:u,"aria-label":"".concat(b," legend icon")},w.createElement(dEe,{data:d,iconType:o,inactiveColor:s})),w.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},b))})}var fEe=t=>{var e=ri(t,uEe),{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 w.createElement("ul",{className:"recharts-default-legend",style:s},w.createElement(hEe,mS({},e,{payload:n})))},OA={},LA={},l$;function mEe(){return l$||(l$=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 o=n[s],l=r(o);i.has(l)||i.set(l,o)}return Array.from(i.values())}t.uniqBy=e})(LA)),LA}var IA={},c$;function OX(){return c$||(c$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(IA)),IA}var FA={},UA={},zA={},u$;function pEe(){return u$||(u$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(zA)),zA}var d$;function N4(){return d$||(d$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=pEe();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(UA)),UA}var BA={},h$;function gEe(){return h$||(h$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(BA)),BA}var f$;function xEe(){return f$||(f$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=N4(),n=gEe();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(FA)),FA}var $A={},HA={},m$;function bEe(){return m$||(m$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=_4();function n(r){return function(i){return e.get(i,r)}}t.property=n})(HA)),HA}var VA={},GA={},qA={},WA={},p$;function LX(){return p$||(p$=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})(WA)),WA}var KA={},g$;function IX(){return g$||(g$=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})(KA)),KA}var XA={},x$;function FX(){return x$||(x$=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})(XA)),XA}var b$;function yEe(){return b$||(b$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=LX(),n=IX(),r=FX();function i(d,f,m){return typeof m!="function"?i(d,f,()=>{}):s(d,f,function p(x,b,y,v,S,N){const C=m(x,b,y,v,S,N);return C!==void 0?!!C:s(x,b,p,N)},new Map)}function s(d,f,m,p){if(f===d)return!0;switch(typeof f){case"object":return o(d,f,m,p);case"function":return Object.keys(f).length>0?s(d,{...f},m,p):r.eq(d,f);default:return e.isObject(d)?typeof f=="string"?f==="":!0:r.eq(d,f)}}function o(d,f,m,p){if(f==null)return!0;if(Array.isArray(f))return c(d,f,m,p);if(f instanceof Map)return l(d,f,m,p);if(f instanceof Set)return u(d,f,m,p);const x=Object.keys(f);if(d==null)return x.length===0;if(x.length===0)return!0;if(p?.has(f))return p.get(f)===d;p?.set(f,d);try{for(let b=0;b<x.length;b++){const y=x[b];if(!n.isPrimitive(d)&&!(y in d)||f[y]===void 0&&d[y]!==void 0||f[y]===null&&d[y]!==null||!m(d[y],f[y],y,d,f,p))return!1}return!0}finally{p?.delete(f)}}function l(d,f,m,p){if(f.size===0)return!0;if(!(d instanceof Map))return!1;for(const[x,b]of f.entries()){const y=d.get(x);if(m(y,b,x,d,f,p)===!1)return!1}return!0}function c(d,f,m,p){if(f.length===0)return!0;if(!Array.isArray(d))return!1;const x=new Set;for(let b=0;b<f.length;b++){const y=f[b];let v=!1;for(let S=0;S<d.length;S++){if(x.has(S))continue;const N=d[S];let C=!1;if(m(N,y,b,d,f,p)&&(C=!0),C){x.add(S),v=!0;break}}if(!v)return!1}return!0}function u(d,f,m,p){return f.size===0?!0:d instanceof Set?c([...d],[...f],m,p):!1}t.isMatchWith=i,t.isSetMatch=u})(qA)),qA}var y$;function UX(){return y$||(y$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=yEe();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(GA)),GA}var YA={},QA={},ZA={},v$;function vEe(){return v$||(v$=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})(ZA)),ZA}var JA={},_$;function zX(){return _$||(_$=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})(JA)),JA}var ek={},w$;function BX(){return w$||(w$=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]",o="[object Symbol]",l="[object Date]",c="[object Map]",u="[object Set]",d="[object Array]",f="[object Function]",m="[object ArrayBuffer]",p="[object Object]",x="[object Error]",b="[object DataView]",y="[object Uint8Array]",v="[object Uint8ClampedArray]",S="[object Uint16Array]",N="[object Uint32Array]",C="[object BigUint64Array]",T="[object Int8Array]",k="[object Int16Array]",E="[object Int32Array]",D="[object BigInt64Array]",A="[object Float32Array]",R="[object Float64Array]";t.argumentsTag=s,t.arrayBufferTag=m,t.arrayTag=d,t.bigInt64ArrayTag=D,t.bigUint64ArrayTag=C,t.booleanTag=i,t.dataViewTag=b,t.dateTag=l,t.errorTag=x,t.float32ArrayTag=A,t.float64ArrayTag=R,t.functionTag=f,t.int16ArrayTag=k,t.int32ArrayTag=E,t.int8ArrayTag=T,t.mapTag=c,t.numberTag=r,t.objectTag=p,t.regexpTag=e,t.setTag=u,t.stringTag=n,t.symbolTag=o,t.uint16ArrayTag=S,t.uint32ArrayTag=N,t.uint8ArrayTag=y,t.uint8ClampedArrayTag=v})(ek)),ek}var tk={},S$;function _Ee(){return S$||(S$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(tk)),tk}var N$;function $X(){return N$||(N$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=vEe(),n=zX(),r=BX(),i=IX(),s=_Ee();function o(d,f){return l(d,void 0,d,new Map,f)}function l(d,f,m,p=new Map,x=void 0){const b=x?.(d,f,m,p);if(b!==void 0)return b;if(i.isPrimitive(d))return d;if(p.has(d))return p.get(d);if(Array.isArray(d)){const y=new Array(d.length);p.set(d,y);for(let v=0;v<d.length;v++)y[v]=l(d[v],v,m,p,x);return Object.hasOwn(d,"index")&&(y.index=d.index),Object.hasOwn(d,"input")&&(y.input=d.input),y}if(d instanceof Date)return new Date(d.getTime());if(d instanceof RegExp){const y=new RegExp(d.source,d.flags);return y.lastIndex=d.lastIndex,y}if(d instanceof Map){const y=new Map;p.set(d,y);for(const[v,S]of d)y.set(v,l(S,v,m,p,x));return y}if(d instanceof Set){const y=new Set;p.set(d,y);for(const v of d)y.add(l(v,void 0,m,p,x));return y}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(s.isTypedArray(d)){const y=new(Object.getPrototypeOf(d)).constructor(d.length);p.set(d,y);for(let v=0;v<d.length;v++)y[v]=l(d[v],v,m,p,x);return y}if(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer)return d.slice(0);if(d instanceof DataView){const y=new DataView(d.buffer.slice(0),d.byteOffset,d.byteLength);return p.set(d,y),c(y,d,m,p,x),y}if(typeof File<"u"&&d instanceof File){const y=new File([d],d.name,{type:d.type});return p.set(d,y),c(y,d,m,p,x),y}if(typeof Blob<"u"&&d instanceof Blob){const y=new Blob([d],{type:d.type});return p.set(d,y),c(y,d,m,p,x),y}if(d instanceof Error){const y=new d.constructor;return p.set(d,y),y.message=d.message,y.name=d.name,y.stack=d.stack,y.cause=d.cause,c(y,d,m,p,x),y}if(d instanceof Boolean){const y=new Boolean(d.valueOf());return p.set(d,y),c(y,d,m,p,x),y}if(d instanceof Number){const y=new Number(d.valueOf());return p.set(d,y),c(y,d,m,p,x),y}if(d instanceof String){const y=new String(d.valueOf());return p.set(d,y),c(y,d,m,p,x),y}if(typeof d=="object"&&u(d)){const y=Object.create(Object.getPrototypeOf(d));return p.set(d,y),c(y,d,m,p,x),y}return d}function c(d,f,m=d,p,x){const b=[...Object.keys(f),...e.getSymbols(f)];for(let y=0;y<b.length;y++){const v=b[y],S=Object.getOwnPropertyDescriptor(d,v);(S==null||S.writable)&&(d[v]=l(f[v],v,m,p,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=o,t.cloneDeepWithImpl=l,t.copyProperties=c})(QA)),QA}var M$;function wEe(){return M$||(M$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$X();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(YA)),YA}var E$;function SEe(){return E$||(E$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=UX(),n=wEe();function r(i){return i=n.cloneDeep(i),s=>e.isMatch(s,i)}t.matches=r})(VA)),VA}var nk={},rk={},ik={},C$;function NEe(){return C$||(C$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$X(),n=BX();function r(i,s){return e.cloneDeepWith(i,(o,l,c,u)=>{const d=s?.(o,l,c,u);if(d!==void 0)return d;if(typeof i=="object")switch(Object.prototype.toString.call(i)){case n.numberTag:case n.stringTag:case n.booleanTag:{const f=new i.constructor(i?.valueOf());return e.copyProperties(f,i),f}case n.argumentsTag:{const f={};return e.copyProperties(f,i),f.length=i.length,f[Symbol.iterator]=i[Symbol.iterator],f}default:return}})}t.cloneDeepWith=r})(ik)),ik}var T$;function MEe(){return T$||(T$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=NEe();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(rk)),rk}var ak={},sk={},A$;function HX(){return A$||(A$=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})(sk)),sk}var ok={},k$;function EEe(){return k$||(k$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=zX();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(ok)),ok}var j$;function CEe(){return j$||(j$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=kX(),n=HX(),r=EEe(),i=v4();function s(o,l){let c;if(Array.isArray(l)?c=l:typeof l=="string"&&e.isDeepKey(l)&&o?.[l]==null?c=i.toPath(l):c=[l],c.length===0)return!1;let u=o;for(let d=0;d<c.length;d++){const f=c[d];if((u==null||!Object.hasOwn(u,f))&&!((Array.isArray(u)||r.isArguments(u))&&n.isIndex(f)&&f<u.length))return!1;u=u[f]}return!0}t.has=s})(ak)),ak}var P$;function TEe(){return P$||(P$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=UX(),n=y4(),r=MEe(),i=_4(),s=CEe();function o(l,c){switch(typeof l){case"object":{Object.is(l?.valueOf(),-0)&&(l="-0");break}case"number":{l=n.toKey(l);break}}return c=r.cloneDeep(c),function(u){const d=i.get(u,l);return d===void 0?s.has(u,l):c===void 0?d===void 0:e.isMatch(d,c)}}t.matchesProperty=o})(nk)),nk}var R$;function AEe(){return R$||(R$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=OX(),n=bEe(),r=SEe(),i=TEe();function s(o){if(o==null)return e.identity;switch(typeof o){case"function":return o;case"object":return Array.isArray(o)&&o.length===2?i.matchesProperty(o[0],o[1]):r.matches(o);case"string":case"symbol":case"number":return n.property(o)}}t.iteratee=s})($A)),$A}var D$;function kEe(){return D$||(D$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=mEe(),n=OX(),r=xEe(),i=AEe();function s(o,l=n.identity){return r.isArrayLikeObject(o)?e.uniqBy(Array.from(o),i.iteratee(l)):[]}t.uniqBy=s})(OA)),OA}var lk,O$;function jEe(){return O$||(O$=1,lk=kEe().uniqBy),lk}var PEe=jEe();const L$=ul(PEe);function VX(t,e,n){return e===!0?L$(t,n):typeof e=="function"?L$(t,e):t}var ck={exports:{}},uk={};var I$;function REe(){if(I$)return uk;I$=1;var t=px(),e=jq();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,o=t.useEffect,l=t.useMemo,c=t.useDebugValue;return uk.useSyncExternalStoreWithSelector=function(u,d,f,m,p){var x=s(null);if(x.current===null){var b={hasValue:!1,value:null};x.current=b}else b=x.current;x=l(function(){function v(k){if(!S){if(S=!0,N=k,k=m(k),p!==void 0&&b.hasValue){var E=b.value;if(p(E,k))return C=E}return C=k}if(E=C,r(N,k))return E;var D=m(k);return p!==void 0&&p(E,D)?(N=k,E):(N=k,C=D)}var S=!1,N,C,T=f===void 0?null:f;return[function(){return v(d())},T===null?void 0:function(){return v(T())}]},[d,f,m,p]);var y=i(u,x[0],x[1]);return o(function(){b.hasValue=!0,b.value=y},[y]),c(y),y},uk}var F$;function DEe(){return F$||(F$=1,ck.exports=REe()),ck.exports}var GX=DEe(),M4=w.createContext(null),OEe=t=>t,Or=()=>{var t=w.useContext(M4);return t?t.store.dispatch:OEe},C1=()=>{},LEe=()=>C1,IEe=(t,e)=>t===e;function Ut(t){var e=w.useContext(M4);return GX.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:LEe,e?e.store.getState:C1,e?e.store.getState:C1,e?t:C1,IEe)}function FEe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function UEe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function zEe(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 U$=t=>Array.isArray(t)?t:[t];function BEe(t){const e=Array.isArray(t[0])?t[0]:t;return zEe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function $Ee(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var HEe=class{constructor(t){this.value=t}deref(){return this.value}},VEe=typeof WeakRef<"u"?WeakRef:HEe,GEe=0,z$=1;function Lw(){return{s:GEe,v:void 0,o:null,p:null}}function qX(t,e={}){let n=Lw();const{resultEqualityCheck:r}=e;let i,s=0;function o(){let l=n;const{length:c}=arguments;for(let f=0,m=c;f<m;f++){const p=arguments[f];if(typeof p=="function"||typeof p=="object"&&p!==null){let x=l.o;x===null&&(l.o=x=new WeakMap);const b=x.get(p);b===void 0?(l=Lw(),x.set(p,l)):l=b}else{let x=l.p;x===null&&(l.p=x=new Map);const b=x.get(p);b===void 0?(l=Lw(),x.set(p,l)):l=b}}const u=l;let d;if(l.s===z$)d=l.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 VEe(d):d}return u.s=z$,u.v=d,d}return o.clearCache=()=>{n=Lw(),o.resetResultsCount()},o.resultsCount=()=>s,o.resetResultsCount=()=>{s=0},o}function qEe(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,r=(...i)=>{let s=0,o=0,l,c={},u=i.pop();typeof u=="object"&&(c=u,u=i.pop()),FEe(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:f,memoizeOptions:m=[],argsMemoize:p=qX,argsMemoizeOptions:x=[]}=d,b=U$(m),y=U$(x),v=BEe(i),S=f(function(){return s++,u.apply(null,arguments)},...b),N=p(function(){o++;const T=$Ee(v,arguments);return l=S.apply(null,T),l},...y);return Object.assign(N,{resultFunc:u,memoizedResultFunc:S,dependencies:v,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>l,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:f,argsMemoize:p})};return Object.assign(r,{withTypes:()=>r}),r}var et=qEe(qX),WEe=Object.assign((t,e=et)=>{UEe(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((o,l,c)=>(o[n[c]]=l,o),{}))},{withTypes:()=>WEe}),dk={},hk={},fk={},B$;function KEe(){return B$||(B$=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 o=e(r),l=e(i);if(o===l&&o===0){if(r<i)return s==="desc"?1:-1;if(r>i)return s==="desc"?-1:1}return s==="desc"?l-o:o-l}return 0};t.compareValues=n})(fk)),fk}var mk={},pk={},$$;function WX(){return $$||($$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(pk)),pk}var H$;function XEe(){return H$||(H$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=WX(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(s,o){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))||o!=null&&Object.hasOwn(o,s)}t.isKey=i})(mk)),mk}var V$;function YEe(){return V$||(V$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=KEe(),n=XEe(),r=v4();function i(s,o,l,c){if(s==null)return[];l=c?void 0:l,Array.isArray(s)||(s=Object.values(s)),Array.isArray(o)||(o=o==null?[null]:[o]),o.length===0&&(o=[null]),Array.isArray(l)||(l=l==null?[]:[l]),l=l.map(p=>String(p));const u=(p,x)=>{let b=p;for(let y=0;y<x.length&&b!=null;++y)b=b[x[y]];return b},d=(p,x)=>x==null||p==null?x:typeof p=="object"&&"key"in p?Object.hasOwn(x,p.key)?x[p.key]:u(x,p.path):typeof p=="function"?p(x):Array.isArray(p)?u(x,p):typeof x=="object"?x[p]:x,f=o.map(p=>(Array.isArray(p)&&p.length===1&&(p=p[0]),p==null||typeof p=="function"||Array.isArray(p)||n.isKey(p)?p:{key:p,path:r.toPath(p)}));return s.map(p=>({original:p,criteria:f.map(x=>d(x,p))})).slice().sort((p,x)=>{for(let b=0;b<f.length;b++){const y=e.compareValues(p.criteria[b],x.criteria[b],l[b]);if(y!==0)return y}return 0}).map(p=>p.original)}t.orderBy=i})(hk)),hk}var gk={},G$;function QEe(){return G$||(G$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r=1){const i=[],s=Math.floor(r),o=(l,c)=>{for(let u=0;u<l.length;u++){const d=l[u];Array.isArray(d)&&c<s?o(d,c+1):i.push(d)}};return o(n,0),i}t.flatten=e})(gk)),gk}var xk={},q$;function KX(){return q$||(q$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=HX(),n=N4(),r=LX(),i=FX();function s(o,l,c){return r.isObject(c)&&(typeof l=="number"&&n.isArrayLike(c)&&e.isIndex(l)&&l<c.length||typeof l=="string"&&l in c)?i.eq(c[l],o):!1}t.isIterateeCall=s})(xk)),xk}var W$;function ZEe(){return W$||(W$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=YEe(),n=QEe(),r=KX();function i(s,...o){const l=o.length;return l>1&&r.isIterateeCall(s,o[0],o[1])?o=[]:l>2&&r.isIterateeCall(o[0],o[1],o[2])&&(o=[o[0]]),e.orderBy(s,n.flatten(o),["asc"])}t.sortBy=i})(dk)),dk}var bk,K$;function JEe(){return K$||(K$=1,bk=ZEe().sortBy),bk}var eCe=JEe();const DN=ul(eCe);var XX=t=>t.legend.settings,tCe=t=>t.legend.size,nCe=t=>t.legend.payload,rCe=et([nCe,XX],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?DN(r,n):r});function iCe(){return Ut(rCe)}var Iw=1;function YX(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=w.useState({height:0,left:0,top:0,width:0}),r=w.useCallback(i=>{if(i!=null){var s=i.getBoundingClientRect(),o={height:s.height,left:s.left,top:s.top,width:s.width};(Math.abs(o.height-e.height)>Iw||Math.abs(o.left-e.left)>Iw||Math.abs(o.top-e.top)>Iw||Math.abs(o.width-e.width)>Iw)&&n({height:o.height,left:o.left,top:o.top,width:o.width})}},[e.width,e.height,e.top,e.left,...t]);return[e,r]}function Ta(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 aCe=typeof Symbol=="function"&&Symbol.observable||"@@observable",X$=aCe,yk=()=>Math.random().toString(36).substring(7).split("").join("."),sCe={INIT:`@@redux/INIT${yk()}`,REPLACE:`@@redux/REPLACE${yk()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${yk()}`},pS=sCe;function E4(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 QX(t,e,n){if(typeof t!="function")throw new Error(Ta(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Ta(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Ta(1));return n(QX)(t,e)}let r=t,i=e,s=new Map,o=s,l=0,c=!1;function u(){o===s&&(o=new Map,s.forEach((y,v)=>{o.set(v,y)}))}function d(){if(c)throw new Error(Ta(3));return i}function f(y){if(typeof y!="function")throw new Error(Ta(4));if(c)throw new Error(Ta(5));let v=!0;u();const S=l++;return o.set(S,y),function(){if(v){if(c)throw new Error(Ta(6));v=!1,u(),o.delete(S),s=null}}}function m(y){if(!E4(y))throw new Error(Ta(7));if(typeof y.type>"u")throw new Error(Ta(8));if(typeof y.type!="string")throw new Error(Ta(17));if(c)throw new Error(Ta(9));try{c=!0,i=r(i,y)}finally{c=!1}return(s=o).forEach(S=>{S()}),y}function p(y){if(typeof y!="function")throw new Error(Ta(10));r=y,m({type:pS.REPLACE})}function x(){const y=f;return{subscribe(v){if(typeof v!="object"||v===null)throw new Error(Ta(11));function S(){const C=v;C.next&&C.next(d())}return S(),{unsubscribe:y(S)}},[X$](){return this}}}return m({type:pS.INIT}),{dispatch:m,subscribe:f,getState:d,replaceReducer:p,[X$]:x}}function oCe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:pS.INIT})>"u")throw new Error(Ta(12));if(typeof n(void 0,{type:pS.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Ta(13))})}function ZX(t){const e=Object.keys(t),n={};for(let s=0;s<e.length;s++){const o=e[s];typeof t[o]=="function"&&(n[o]=t[o])}const r=Object.keys(n);let i;try{oCe(n)}catch(s){i=s}return function(o={},l){if(i)throw i;let c=!1;const u={};for(let d=0;d<r.length;d++){const f=r[d],m=n[f],p=o[f],x=m(p,l);if(typeof x>"u")throw l&&l.type,new Error(Ta(14));u[f]=x,c=c||x!==p}return c=c||r.length!==Object.keys(o).length,c?u:o}}function gS(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function lCe(...t){return e=>(n,r)=>{const i=e(n,r);let s=()=>{throw new Error(Ta(15))};const o={getState:i.getState,dispatch:(c,...u)=>s(c,...u)},l=t.map(c=>c(o));return s=gS(...l)(i.dispatch),{...i,dispatch:s}}}function JX(t){return E4(t)&&"type"in t&&typeof t.type=="string"}var eY=Symbol.for("immer-nothing"),Y$=Symbol.for("immer-draftable"),ws=Symbol.for("immer-state");function Tl(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var ho=Object,Jg=ho.getPrototypeOf,xS="constructor",ON="prototype",RP="configurable",bS="enumerable",T1="writable",sy="value",Fu=t=>!!t&&!!t[ws];function Fl(t){return t?tY(t)||LN(t)||!!t[Y$]||!!t[xS]?.[Y$]||IN(t)||FN(t):!1}var cCe=ho[ON][xS].toString(),Q$=new WeakMap;function tY(t){if(!t||!C4(t))return!1;const e=Jg(t);if(e===null||e===ho[ON])return!0;const n=ho.hasOwnProperty.call(e,xS)&&e[xS];if(n===Object)return!0;if(!sg(n))return!1;let r=Q$.get(n);return r===void 0&&(r=Function.toString.call(n),Q$.set(n,r)),r===cCe}function qy(t,e,n=!0){Wy(t)===0?(n?Reflect.ownKeys(t):ho.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function Wy(t){const e=t[ws];return e?e.type_:LN(t)?1:IN(t)?2:FN(t)?3:0}var Z$=(t,e,n=Wy(t))=>n===2?t.has(e):ho[ON].hasOwnProperty.call(t,e),DP=(t,e,n=Wy(t))=>n===2?t.get(e):t[e],yS=(t,e,n,r=Wy(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function uCe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var LN=Array.isArray,IN=t=>t instanceof Map,FN=t=>t instanceof Set,C4=t=>typeof t=="object",sg=t=>typeof t=="function",vk=t=>typeof t=="boolean",du=t=>t.copy_||t.base_,T4=t=>t.modified_?t.copy_:t.base_;function OP(t,e){if(IN(t))return new Map(t);if(FN(t))return new Set(t);if(LN(t))return Array[ON].slice.call(t);const n=tY(t);if(e===!0||e==="class_only"&&!n){const r=ho.getOwnPropertyDescriptors(t);delete r[ws];let i=Reflect.ownKeys(r);for(let s=0;s<i.length;s++){const o=i[s],l=r[o];l[T1]===!1&&(l[T1]=!0,l[RP]=!0),(l.get||l.set)&&(r[o]={[RP]:!0,[T1]:!0,[bS]:l[bS],[sy]:t[o]})}return ho.create(Jg(t),r)}else{const r=Jg(t);if(r!==null&&n)return{...t};const i=ho.create(r);return ho.assign(i,t)}}function A4(t,e=!1){return UN(t)||Fu(t)||!Fl(t)||(Wy(t)>1&&ho.defineProperties(t,{set:Fw,add:Fw,clear:Fw,delete:Fw}),ho.freeze(t),e&&qy(t,(n,r)=>{A4(r,!0)},!1)),t}function dCe(){Tl(2)}var Fw={[sy]:dCe};function UN(t){return t===null||!C4(t)?!0:ho.isFrozen(t)}var vS="MapSet",LP="Patches",nY={};function ex(t){const e=nY[t];return e||Tl(0,t),e}var hCe=t=>!!nY[t],oy,rY=()=>oy,fCe=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:hCe(vS)?ex(vS):void 0});function J$(t,e){e&&(t.patchPlugin_=ex(LP),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function IP(t){FP(t),t.drafts_.forEach(mCe),t.drafts_=null}function FP(t){t===oy&&(oy=t.parent_)}var eH=t=>oy=fCe(oy,t);function mCe(t){const e=t[ws];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function tH(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[ws].modified_&&(IP(e),Tl(4)),Fl(t)&&(t=nH(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[ws].base_,t,e)}else t=nH(e,n);return pCe(e,t,!0),IP(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==eY?t:void 0}function nH(t,e){if(UN(e))return e;const n=e[ws];if(!n)return k4(e,t.handledSet_,t);if(!zN(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);sY(n,t)}return n.copy_}function pCe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&A4(e,n)}function iY(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var zN=(t,e)=>t.scope_===e,gCe=[];function aY(t,e,n,r){const i=du(t),s=t.type_;if(r!==void 0&&DP(i,r,s)===e){yS(i,r,n,s);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;qy(i,(c,u)=>{if(Fu(u)){const d=l.get(u)||[];d.push(c),l.set(u,d)}})}const o=t.draftLocations_.get(e)??gCe;for(const l of o)yS(i,l,n,s)}function xCe(t,e,n){t.callbacks_.push(function(i){const s=e;if(!s||!zN(s,i))return;i.mapSetPlugin_?.fixSetContents(s);const o=T4(s);aY(t,s.draft_??s,o,n),sY(s,i)})}function sY(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)}iY(t)}}function bCe(t,e,n){const{scope_:r}=t;if(Fu(n)){const i=n[ws];zN(i,r)&&i.callbacks_.push(function(){A1(t);const o=T4(i);aY(t,n,o,e)})}else Fl(n)&&t.callbacks_.push(function(){const s=du(t);DP(s,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&k4(DP(t.copy_,e,t.type_),r.handledSet_,r)})}function k4(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Fu(t)||e.has(t)||!Fl(t)||UN(t)||(e.add(t),qy(t,(r,i)=>{if(Fu(i)){const s=i[ws];if(zN(s,n)){const o=T4(s);yS(t,r,o,t.type_),iY(s)}}else Fl(i)&&k4(i,e,n)})),t}function yCe(t,e){const n=LN(t),r={type_:n?1:0,scope_:e?e.scope_:rY(),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=j4;n&&(i=[r],s=ly);const{revoke:o,proxy:l}=Proxy.revocable(i,s);return r.draft_=l,r.revoke_=o,[l,r]}var j4={get(t,e){if(e===ws)return t;const n=du(t);if(!Z$(n,e,t.type_))return vCe(t,n,e);const r=n[e];if(t.finalized_||!Fl(r))return r;if(r===_k(t.base_,e)){A1(t);const i=t.type_===1?+e:e,s=zP(t.scope_,r,t,i);return t.copy_[i]=s}return r},has(t,e){return e in du(t)},ownKeys(t){return Reflect.ownKeys(du(t))},set(t,e,n){const r=oY(du(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=_k(du(t),e),s=i?.[ws];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(uCe(n,i)&&(n!==void 0||Z$(t.base_,e,t.type_)))return!0;A1(t),UP(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),bCe(t,e,n)),!0},deleteProperty(t,e){return A1(t),_k(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),UP(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=du(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[T1]:!0,[RP]:t.type_!==1||e!=="length",[bS]:r[bS],[sy]:n[e]}},defineProperty(){Tl(11)},getPrototypeOf(t){return Jg(t.base_)},setPrototypeOf(){Tl(12)}},ly={};qy(j4,(t,e)=>{ly[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});ly.deleteProperty=function(t,e){return ly.set.call(this,t,e,void 0)};ly.set=function(t,e,n){return j4.set.call(this,t[0],e,n,t[0])};function _k(t,e){const n=t[ws];return(n?du(n):t)[e]}function vCe(t,e,n){const r=oY(e,n);return r?sy in r?r[sy]:r.get?.call(t.draft_):void 0}function oY(t,e){if(!(e in t))return;let n=Jg(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=Jg(n)}}function UP(t){t.modified_||(t.modified_=!0,t.parent_&&UP(t.parent_))}function A1(t){t.copy_||(t.assigned_=new Map,t.copy_=OP(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var _Ce=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(sg(n)&&!sg(r)){const o=r;r=n;const l=this;return function(u=o,...d){return l.produce(u,f=>r.call(this,f,...d))}}sg(r)||Tl(6),i!==void 0&&!sg(i)&&Tl(7);let s;if(Fl(n)){const o=eH(this),l=zP(o,n,void 0);let c=!0;try{s=r(l),c=!1}finally{c?IP(o):FP(o)}return J$(o,i),tH(s,o)}else if(!n||!C4(n)){if(s=r(n),s===void 0&&(s=n),s===eY&&(s=void 0),this.autoFreeze_&&A4(s,!0),i){const o=[],l=[];ex(LP).generateReplacementPatches_(n,s,{patches_:o,inversePatches_:l}),i(o,l)}return s}else Tl(1,n)},this.produceWithPatches=(n,r)=>{if(sg(n))return(l,...c)=>this.produceWithPatches(l,u=>n(u,...c));let i,s;return[this.produce(n,r,(l,c)=>{i=l,s=c}),i,s]},vk(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),vk(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),vk(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Fl(e)||Tl(8),Fu(e)&&(e=Ol(e));const n=eH(this),r=zP(n,e,void 0);return r[ws].isManual_=!0,FP(n),r}finishDraft(e,n){const r=e&&e[ws];(!r||!r.isManual_)&&Tl(9);const{scope_:i}=r;return J$(i,n),tH(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=ex(LP).applyPatches_;return Fu(e)?i(e,n):this.produce(e,s=>i(s,n))}};function zP(t,e,n,r){const[i,s]=IN(e)?ex(vS).proxyMap_(e,n):FN(e)?ex(vS).proxySet_(e,n):yCe(e,n);return(n?.scope_??rY()).drafts_.push(i),s.callbacks_=n?.callbacks_??[],s.key_=r,n&&r!==void 0?xCe(n,s,r):s.callbacks_.push(function(c){c.mapSetPlugin_?.fixSetContents(s);const{patchPlugin_:u}=c;s.modified_&&u&&u.generatePatches_(s,[],c)}),i}function Ol(t){return Fu(t)||Tl(10,t),lY(t)}function lY(t){if(!Fl(t)||UN(t))return t;const e=t[ws];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 qy(n,(i,s)=>{yS(n,i,lY(s))},r),e&&(e.finalized_=!1),n}var wCe=new _Ce,cY=wCe.produce;function uY(t){return({dispatch:n,getState:r})=>i=>s=>typeof s=="function"?s(n,r,t):i(s)}var SCe=uY(),NCe=uY,MCe=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?gS:gS.apply(null,arguments)};function ll(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(xo(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=>JX(r)&&r.type===t,n}var dY=class l0 extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,l0.prototype)}static get[Symbol.species](){return l0}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new l0(...e[0].concat(this)):new l0(...e.concat(this))}};function rH(t){return Fl(t)?cY(t,()=>{}):t}function Uw(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function ECe(t){return typeof t=="boolean"}var CCe=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:s=!0}=e??{};let o=new dY;return n&&(ECe(n)?o.push(SCe):o.push(NCe(n.extraArgument))),o},hY="RTK_autoBatch",Wr=()=>t=>({payload:t,meta:{[hY]:!0}}),iH=t=>e=>{setTimeout(e,t)},fY=(t={type:"raf"})=>e=>(...n)=>{const r=e(...n);let i=!0,s=!1,o=!1;const l=new Set,c=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:iH(10):t.type==="callback"?t.queueNotification:iH(t.timeout),u=()=>{o=!1,s&&(s=!1,l.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const f=()=>i&&d(),m=r.subscribe(f);return l.add(d),()=>{m(),l.delete(d)}},dispatch(d){try{return i=!d?.meta?.[hY],s=!i,s&&(o||(o=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},TCe=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new dY(t);return r&&i.push(fY(typeof r=="object"?r:void 0)),i};function ACe(t){const e=CCe(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:s=void 0,enhancers:o=void 0}=t||{};let l;if(typeof n=="function")l=n;else if(E4(n))l=ZX(n);else throw new Error(xo(1));let c;typeof r=="function"?c=r(e):c=e();let u=gS;i&&(u=MCe({trace:!1,...typeof i=="object"&&i}));const d=lCe(...c),f=TCe(d);let m=typeof o=="function"?o(f):f();const p=u(...m);return QX(l,s,p)}function mY(t){const e={},n=[];let r;const i={addCase(s,o){const l=typeof s=="string"?s:s.type;if(!l)throw new Error(xo(28));if(l in e)throw new Error(xo(29));return e[l]=o,i},addAsyncThunk(s,o){return o.pending&&(e[s.pending.type]=o.pending),o.rejected&&(e[s.rejected.type]=o.rejected),o.fulfilled&&(e[s.fulfilled.type]=o.fulfilled),o.settled&&n.push({matcher:s.settled,reducer:o.settled}),i},addMatcher(s,o){return n.push({matcher:s,reducer:o}),i},addDefaultCase(s){return r=s,i}};return t(i),[e,n,r]}function kCe(t){return typeof t=="function"}function jCe(t,e){let[n,r,i]=mY(e),s;if(kCe(t))s=()=>rH(t());else{const l=rH(t);s=()=>l}function o(l=s(),c){let u=[n[c.type],...r.filter(({matcher:d})=>d(c)).map(({reducer:d})=>d)];return u.filter(d=>!!d).length===0&&(u=[i]),u.reduce((d,f)=>{if(f)if(Fu(d)){const p=f(d,c);return p===void 0?d:p}else{if(Fl(d))return cY(d,m=>f(m,c));{const m=f(d,c);if(m===void 0){if(d===null)return d;throw Error("A case reducer on a non-draftable value must not return undefined")}return m}}return d},l)}return o.getInitialState=s,o}var PCe="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",RCe=(t=21)=>{let e="",n=t;for(;n--;)e+=PCe[Math.random()*64|0];return e},DCe=Symbol.for("rtk-slice-createasyncthunk");function OCe(t,e){return`${t}/${e}`}function LCe({creators:t}={}){const e=t?.asyncThunk?.[DCe];return function(r){const{name:i,reducerPath:s=i}=r;if(!i)throw new Error(xo(11));const o=(typeof r.reducers=="function"?r.reducers(FCe()):r.reducers)||{},l=Object.keys(o),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(N,C){const T=typeof N=="string"?N:N.type;if(!T)throw new Error(xo(12));if(T in c.sliceCaseReducersByType)throw new Error(xo(13));return c.sliceCaseReducersByType[T]=C,u},addMatcher(N,C){return c.sliceMatchers.push({matcher:N,reducer:C}),u},exposeAction(N,C){return c.actionCreators[N]=C,u},exposeCaseReducer(N,C){return c.sliceCaseReducersByName[N]=C,u}};l.forEach(N=>{const C=o[N],T={reducerName:N,type:OCe(i,N),createNotation:typeof r.reducers=="function"};zCe(C)?$Ce(T,C,u,e):UCe(T,C,u)});function d(){const[N={},C=[],T=void 0]=typeof r.extraReducers=="function"?mY(r.extraReducers):[r.extraReducers],k={...N,...c.sliceCaseReducersByType};return jCe(r.initialState,E=>{for(let D in k)E.addCase(D,k[D]);for(let D of c.sliceMatchers)E.addMatcher(D.matcher,D.reducer);for(let D of C)E.addMatcher(D.matcher,D.reducer);T&&E.addDefaultCase(T)})}const f=N=>N,m=new Map,p=new WeakMap;let x;function b(N,C){return x||(x=d()),x(N,C)}function y(){return x||(x=d()),x.getInitialState()}function v(N,C=!1){function T(E){let D=E[N];return typeof D>"u"&&C&&(D=Uw(p,T,y)),D}function k(E=f){const D=Uw(m,C,()=>new WeakMap);return Uw(D,E,()=>{const A={};for(const[R,F]of Object.entries(r.selectors??{}))A[R]=ICe(F,E,()=>Uw(p,E,y),C);return A})}return{reducerPath:N,getSelectors:k,get selectors(){return k(T)},selectSlice:T}}const S={name:i,reducer:b,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:y,...v(s),injectInto(N,{reducerPath:C,...T}={}){const k=C??s;return N.inject({reducerPath:k,reducer:b},T),{...S,...v(k,!0)}}};return S}}function ICe(t,e,n,r){function i(s,...o){let l=e(s);return typeof l>"u"&&r&&(l=n()),t(l,...o)}return i.unwrapped=t,i}var qs=LCe();function FCe(){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 UCe({type:t,reducerName:e,createNotation:n},r,i){let s,o;if("reducer"in r){if(n&&!BCe(r))throw new Error(xo(17));s=r.reducer,o=r.prepare}else s=r;i.addCase(t,s).exposeCaseReducer(e,s).exposeAction(e,o?ll(t,o):ll(t))}function zCe(t){return t._reducerDefinitionType==="asyncThunk"}function BCe(t){return t._reducerDefinitionType==="reducerWithPrepare"}function $Ce({type:t,reducerName:e},n,r,i){if(!i)throw new Error(xo(18));const{payloadCreator:s,fulfilled:o,pending:l,rejected:c,settled:u,options:d}=n,f=i(t,s,d);r.exposeAction(e,f),o&&r.addCase(f.fulfilled,o),l&&r.addCase(f.pending,l),c&&r.addCase(f.rejected,c),u&&r.addMatcher(f.settled,u),r.exposeCaseReducer(e,{fulfilled:o||zw,pending:l||zw,rejected:c||zw,settled:u||zw})}function zw(){}var HCe="task",pY="listener",gY="completed",P4="cancelled",VCe=`task-${P4}`,GCe=`task-${gY}`,BP=`${pY}-${P4}`,qCe=`${pY}-${gY}`,BN=class{constructor(t){this.code=t,this.message=`${HCe} ${P4} (reason: ${t})`}name="TaskAbortError";message},R4=(t,e)=>{if(typeof t!="function")throw new TypeError(xo(32))},_S=()=>{},xY=(t,e=_S)=>(t.catch(e),t),bY=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),Vf=(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))},Gf=t=>{if(t.aborted){const{reason:e}=t;throw new BN(e)}};function yY(t,e){let n=_S;return new Promise((r,i)=>{const s=()=>i(new BN(t.reason));if(t.aborted){s();return}n=bY(t,s),e.finally(()=>n()).then(r,i)}).finally(()=>{n=_S})}var WCe=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof BN?"cancelled":"rejected",error:n}}finally{e?.()}},wS=t=>e=>xY(yY(t,e).then(n=>(Gf(t),n))),vY=t=>{const e=wS(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:jg}=Object,aH={},$N="listenerMiddleware",KCe=(t,e)=>{const n=r=>bY(t,()=>Vf(r,t.reason));return(r,i)=>{R4(r);const s=new AbortController;n(s);const o=WCe(async()=>{Gf(t),Gf(s.signal);const l=await r({pause:wS(s.signal),delay:vY(s.signal),signal:s.signal});return Gf(s.signal),l},()=>Vf(s,GCe));return i?.autoJoin&&e.push(o.catch(_S)),{result:wS(t)(o),cancel(){Vf(s,VCe)}}}},XCe=(t,e)=>{const n=async(r,i)=>{Gf(e);let s=()=>{};const l=[new Promise((c,u)=>{let d=t({predicate:r,effect:(f,m)=>{m.unsubscribe(),c([f,m.getState(),m.getOriginalState()])}});s=()=>{d(),u()}})];i!=null&&l.push(new Promise(c=>setTimeout(c,i,null)));try{const c=await yY(e,Promise.race(l));return Gf(e),c}finally{s()}};return(r,i)=>xY(n(r,i))},_Y=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:s}=t;if(e)i=ll(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(xo(21));return R4(s),{predicate:i,type:e,effect:s}},wY=jg(t=>{const{type:e,predicate:n,effect:r}=_Y(t);return{id:RCe(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(xo(22))}}},{withTypes:()=>wY}),sH=(t,e)=>{const{type:n,effect:r,predicate:i}=_Y(e);return Array.from(t.values()).find(s=>(typeof n=="string"?s.type===n:s.predicate===i)&&s.effect===r)},$P=t=>{t.pending.forEach(e=>{Vf(e,BP)})},YCe=(t,e)=>()=>{for(const n of e.keys())$P(n);t.clear()},oH=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},SY=jg(ll(`${$N}/add`),{withTypes:()=>SY}),QCe=ll(`${$N}/removeAll`),NY=jg(ll(`${$N}/remove`),{withTypes:()=>NY}),ZCe=(...t)=>{console.error(`${$N}/error`,...t)},Ky=(t={})=>{const e=new Map,n=new Map,r=p=>{const x=n.get(p)??0;n.set(p,x+1)},i=p=>{const x=n.get(p)??1;x===1?n.delete(p):n.set(p,x-1)},{extra:s,onError:o=ZCe}=t;R4(o);const l=p=>(p.unsubscribe=()=>e.delete(p.id),e.set(p.id,p),x=>{p.unsubscribe(),x?.cancelActive&&$P(p)}),c=p=>{const x=sH(e,p)??wY(p);return l(x)};jg(c,{withTypes:()=>c});const u=p=>{const x=sH(e,p);return x&&(x.unsubscribe(),p.cancelActive&&$P(x)),!!x};jg(u,{withTypes:()=>u});const d=async(p,x,b,y)=>{const v=new AbortController,S=XCe(c,v.signal),N=[];try{p.pending.add(v),r(p),await Promise.resolve(p.effect(x,jg({},b,{getOriginalState:y,condition:(C,T)=>S(C,T).then(Boolean),take:S,delay:vY(v.signal),pause:wS(v.signal),extra:s,signal:v.signal,fork:KCe(v.signal,N),unsubscribe:p.unsubscribe,subscribe:()=>{e.set(p.id,p)},cancelActiveListeners:()=>{p.pending.forEach((C,T,k)=>{C!==v&&(Vf(C,BP),k.delete(C))})},cancel:()=>{Vf(v,BP),p.pending.delete(v)},throwIfCancelled:()=>{Gf(v.signal)}})))}catch(C){C instanceof BN||oH(o,C,{raisedBy:"effect"})}finally{await Promise.all(N),Vf(v,qCe),i(p),p.pending.delete(v)}},f=YCe(e,n);return{middleware:p=>x=>b=>{if(!JX(b))return x(b);if(SY.match(b))return c(b.payload);if(QCe.match(b)){f();return}if(NY.match(b))return u(b.payload);let y=p.getState();const v=()=>{if(y===aH)throw new Error(xo(23));return y};let S;try{if(S=x(b),e.size>0){const N=p.getState(),C=Array.from(e.values());for(const T of C){let k=!1;try{k=T.predicate(b,N,y)}catch(E){k=!1,oH(o,E,{raisedBy:"predicate"})}k&&d(T,b,p,v)}}}finally{y=aH}return S},startListening:c,stopListening:u,clearListeners:f}};function xo(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 JCe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},MY=qs({name:"chartLayout",initialState:JCe,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:eTe,setLayout:tTe,setChartSize:nTe,setScale:rTe}=MY.actions,iTe=MY.reducer;function EY(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function lH(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 xg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?lH(Object(n),!0).forEach(function(r){aTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):lH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function aTe(t,e,n){return(e=sTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sTe(t){var e=oTe(t,"string");return typeof e=="symbol"?e:e+""}function oTe(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 gr(t,e,n){return Gr(t)||Gr(e)?n:ol(e)?mm(t,e,n):typeof e=="function"?e(t):n}var lTe=(t,e,n)=>{if(e&&n){var{width:r,height:i}=n,{align:s,verticalAlign:o,layout:l}=e;if((l==="vertical"||l==="horizontal"&&o==="middle")&&s!=="center"&&Bt(t[s]))return xg(xg({},t),{},{[s]:t[s]+(r||0)});if((l==="horizontal"||l==="vertical"&&s==="center")&&o!=="middle"&&Bt(t[o]))return xg(xg({},t),{},{[o]:t[o]+(i||0)})}return t},Ec=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",CY=(t,e,n,r)=>{if(r)return t.map(l=>l.coordinate);var i,s,o=t.map(l=>(l.coordinate===e&&(i=!0),l.coordinate===n&&(s=!0),l.coordinate));return i||o.push(e),s||o.push(n),o},TY=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:s,scale:o,realScaleType:l,isCategorical:c,categoricalDomain:u,tickCount:d,ticks:f,niceTicks:m,axisType:p}=t;if(!o)return null;var x=l==="scaleBand"&&o.bandwidth?o.bandwidth()/2:2,b=i==="category"&&o.bandwidth?o.bandwidth()/x:0;if(b=p==="angleAxis"&&s&&s.length>=2?ga(s[0]-s[1])*2*b:b,f||m){var y=(f||m||[]).map((v,S)=>{var N=r?r.indexOf(v):v;return{coordinate:o(N)+b,value:v,offset:b,index:S}});return y.filter(v=>!Gs(v.coordinate))}return c&&u?u.map((v,S)=>({coordinate:o(v)+b,value:v,index:S,offset:b})):o.ticks&&d!=null?o.ticks(d).map((v,S)=>({coordinate:o(v)+b,value:v,offset:b,index:S})):o.domain().map((v,S)=>({coordinate:o(v)+b,value:r?r[v]:v,index:S,offset:b}))},cH=1e-4,cTe=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-cH,s=Math.max(r[0],r[1])+cH,o=t(e[0]),l=t(e[n-1]);(o<i||o>s||l<i||l>s)&&t.domain([e[0],e[n-1]])}},uTe=(t,e)=>{if(!e||e.length!==2||!Bt(e[0])||!Bt(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(!Bt(t[0])||t[0]<n)&&(i[0]=n),(!Bt(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},dTe=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,o=0;o<e;++o){var l=Gs(t[o][n][1])?t[o][n][0]:t[o][n][1];l>=0?(t[o][n][0]=i,t[o][n][1]=i+l,i=t[o][n][1]):(t[o][n][0]=s,t[o][n][1]=s+l,s=t[o][n][1])}},hTe=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 o=Gs(t[s][n][1])?t[s][n][0]:t[s][n][1];o>=0?(t[s][n][0]=i,t[s][n][1]=i+o,i=t[s][n][1]):(t[s][n][0]=0,t[s][n][1]=0)}},fTe={sign:dTe,expand:LMe,none:Zg,silhouette:IMe,wiggle:FMe,positive:hTe},mTe=(t,e,n)=>{var r=fTe[n],i=OMe().keys(e).value((s,o)=>Number(gr(s,o,0))).order(jP).offset(r);return i(t)};function AY(t){return t==null?void 0:String(t)}function SS(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:s,dataKey:o}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!Gr(i[e.dataKey])){var l=PX(n,"value",i[e.dataKey]);if(l)return l.coordinate+r/2}return n[s]?n[s].coordinate+r/2:null}var c=gr(i,Gr(o)?e.dataKey:o);return Gr(c)?null:e.scale(c)}var uH=t=>{var{axis:e,ticks:n,offset:r,bandSize:i,entry:s,index:o}=t;if(e.type==="category")return n[o]?n[o].coordinate+r:null;var l=gr(s,e.dataKey,e.scale.domain()[o]);return Gr(l)?null:e.scale(l)-i/2+r},pTe=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]},gTe=t=>{var e=t.flat(2).filter(Bt);return[Math.min(...e),Math.max(...e)]},xTe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],bTe=(t,e,n)=>{if(t!=null)return xTe(Object.keys(t).reduce((r,i)=>{var s=t[i],{stackedData:o}=s,l=o.reduce((c,u)=>{var d=EY(u,e,n),f=gTe(d);return[Math.min(c[0],f[0]),Math.max(c[1],f[1])]},[1/0,-1/0]);return[Math.min(l[0],r[0]),Math.max(l[1],r[1])]},[1/0,-1/0]))},dH=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,hH=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Mh=(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=DN(e,d=>d.coordinate),s=1/0,o=1,l=i.length;o<l;o++){var c=i[o],u=i[o-1];s=Math.min((c.coordinate||0)-(u.coordinate||0),s)}return s===1/0?0:s}return n?void 0:0};function fH(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:s}=t;return xg(xg({},e),{},{dataKey:n,payload:r,value:i,name:s})}function Lh(t,e){if(t)return String(t);if(typeof e=="string")return e}var yTe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},vTe=(t,e)=>e==="centric"?t.angle:t.radius,Gu=t=>t.layout.width,qu=t=>t.layout.height,_Te=t=>t.layout.scale,kY=t=>t.layout.margin,HN=et(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),VN=et(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),jY="data-recharts-item-index",PY="data-recharts-item-data-key",Xy=60;function mH(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 Bw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?mH(Object(n),!0).forEach(function(r){wTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):mH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function wTe(t,e,n){return(e=STe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function STe(t){var e=NTe(t,"string");return typeof e=="symbol"?e:e+""}function NTe(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 MTe=t=>t.brush.height;function ETe(t){var e=VN(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Xy;return n+i}return n},0)}function CTe(t){var e=VN(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Xy;return n+i}return n},0)}function TTe(t){var e=HN(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function ATe(t){var e=HN(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var Ji=et([Gu,qu,kY,MTe,ETe,CTe,TTe,ATe,XX,tCe],(t,e,n,r,i,s,o,l,c,u)=>{var d={left:(n.left||0)+i,right:(n.right||0)+s},f={top:(n.top||0)+o,bottom:(n.bottom||0)+l},m=Bw(Bw({},f),d),p=m.bottom;m.bottom+=r,m=lTe(m,c,u);var x=t-m.left-m.right,b=e-m.top-m.bottom;return Bw(Bw({brushBottom:p},m),{},{width:Math.max(x,0),height:Math.max(b,0)})}),kTe=et(Ji,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),D4=et(Gu,qu,(t,e)=>({x:0,y:0,width:t,height:e})),jTe=w.createContext(null),ea=()=>w.useContext(jTe)!=null,GN=t=>t.brush,qN=et([GN,Ji,kY],(t,e,n)=>({height:t.height,x:Bt(t.x)?t.x:e.left,y:Bt(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Bt(t.width)?t.width:e.width})),wk={},Sk={},Nk={},pH;function PTe(){return pH||(pH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:s}={}){let o,l=null;const c=s!=null&&s.includes("leading"),u=s==null||s.includes("trailing"),d=()=>{l!==null&&(n.apply(o,l),o=void 0,l=null)},f=()=>{u&&d(),b()};let m=null;const p=()=>{m!=null&&clearTimeout(m),m=setTimeout(()=>{m=null,f()},r)},x=()=>{m!==null&&(clearTimeout(m),m=null)},b=()=>{x(),o=void 0,l=null},y=()=>{d()},v=function(...S){if(i?.aborted)return;o=this,l=S;const N=m==null;p(),c&&N&&d()};return v.schedule=p,v.cancel=b,v.flush=y,i?.addEventListener("abort",b,{once:!0}),v}t.debounce=e})(Nk)),Nk}var gH;function RTe(){return gH||(gH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=PTe();function n(r,i=0,s={}){typeof s!="object"&&(s={});const{leading:o=!1,trailing:l=!0,maxWait:c}=s,u=Array(2);o&&(u[0]="leading"),l&&(u[1]="trailing");let d,f=null;const m=e.debounce(function(...b){d=r.apply(this,b),f=null},i,{edges:u}),p=function(...b){return c!=null&&(f===null&&(f=Date.now()),Date.now()-f>=c)?(d=r.apply(this,b),f=Date.now(),m.cancel(),m.schedule(),d):(m.apply(this,b),d)},x=()=>(m.flush(),d);return p.cancel=m.cancel,p.flush=x,p}t.debounce=n})(Sk)),Sk}var xH;function DTe(){return xH||(xH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=RTe();function n(r,i=0,s={}){const{leading:o=!0,trailing:l=!0}=s;return e.debounce(r,i,{leading:o,maxWait:i,trailing:l})}t.throttle=n})(wk)),wk}var Mk,bH;function OTe(){return bH||(bH=1,Mk=DTe().throttle),Mk}var LTe=OTe();const ITe=ul(LTe);var NS=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 o=0;console.warn(n.replace(/%s/g,()=>i[o++]))}},RY=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:s,maxHeight:o}=n,l=Iu(r)?t:Number(r),c=Iu(i)?e:Number(i);return s&&s>0&&(l?c=l/s:c&&(l=c*s),o&&c!=null&&c>o&&(c=o)),{calculatedWidth:l,calculatedHeight:c}},FTe={width:0,height:0,overflow:"visible"},UTe={width:0,overflowX:"visible"},zTe={height:0,overflowY:"visible"},BTe={},$Te=t=>{var{width:e,height:n}=t,r=Iu(e),i=Iu(n);return r&&i?FTe:r?UTe:i?zTe:BTe};function HTe(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 xr(t){return Number.isFinite(t)}function xc(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function HP(){return HP=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},HP.apply(null,arguments)}function yH(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 vH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?yH(Object(n),!0).forEach(function(r){VTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):yH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function VTe(t,e,n){return(e=GTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function GTe(t){var e=qTe(t,"string");return typeof e=="symbol"?e:e+""}function qTe(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 DY=w.createContext({width:-1,height:-1});function WTe(t){return xc(t.width)&&xc(t.height)}function OY(t){var{children:e,width:n,height:r}=t,i=w.useMemo(()=>({width:n,height:r}),[n,r]);return WTe(i)?w.createElement(DY.Provider,{value:i},e):null}var O4=()=>w.useContext(DY),KTe=w.forwardRef((t,e)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:s,minWidth:o=0,minHeight:l,maxHeight:c,children:u,debounce:d=0,id:f,className:m,onResize:p,style:x={}}=t,b=w.useRef(null),y=w.useRef();y.current=p,w.useImperativeHandle(e,()=>b.current);var[v,S]=w.useState({containerWidth:r.width,containerHeight:r.height}),N=w.useCallback((D,A)=>{S(R=>{var F=Math.round(D),O=Math.round(A);return R.containerWidth===F&&R.containerHeight===O?R:{containerWidth:F,containerHeight:O}})},[]);w.useEffect(()=>{if(b.current==null||typeof ResizeObserver>"u")return Vy;var D=O=>{var H,{width:j,height:G}=O[0].contentRect;N(j,G),(H=y.current)===null||H===void 0||H.call(y,j,G)};d>0&&(D=ITe(D,d,{trailing:!0,leading:!1}));var A=new ResizeObserver(D),{width:R,height:F}=b.current.getBoundingClientRect();return N(R,F),A.observe(b.current),()=>{A.disconnect()}},[N,d]);var{containerWidth:C,containerHeight:T}=v;NS(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:k,calculatedHeight:E}=RY(C,T,{width:i,height:s,aspect:n,maxHeight:c});return NS(k!=null&&k>0||E!=null&&E>0,`The width(%s) and height(%s) of chart should be greater than 0,
  8065. please check the style of container, or the props width(%s) and height(%s),
  8066. or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
  8067. height and width.`,k,E,i,s,o,l,n),w.createElement("div",{id:f?"".concat(f):void 0,className:Zn("recharts-responsive-container",m),style:vH(vH({},x),{},{width:i,height:s,minWidth:o,minHeight:l,maxHeight:c}),ref:b},w.createElement("div",{style:$Te({width:i,height:s})},w.createElement(OY,{width:k,height:E},u)))}),k1=w.forwardRef((t,e)=>{var n=O4();if(xc(n.width)&&xc(n.height))return t.children;var{width:r,height:i}=HTe({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:s,calculatedHeight:o}=RY(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Bt(s)&&Bt(o)?w.createElement(OY,{width:s,height:o},t.children):w.createElement(KTe,HP({},t,{width:r,height:i,ref:e}))});function LY(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 Yy=()=>{var t,e=ea(),n=Ut(kTe),r=Ut(qN),i=(t=Ut(GN))===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}},XTe={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},IY=()=>{var t;return(t=Ut(Ji))!==null&&t!==void 0?t:XTe},L4=()=>Ut(Gu),I4=()=>Ut(qu),YTe=()=>Ut(t=>t.layout.margin),zn=t=>t.layout.layoutType,Tm=()=>Ut(zn),QTe=()=>{var t=Tm();if(t==="horizontal"||t==="vertical")return t},ZTe=()=>{var t=Tm();return t!==void 0},WN=t=>{var e=Or(),n=ea(),{width:r,height:i}=t,s=O4(),o=r,l=i;return s&&(o=s.width>0?s.width:r,l=s.height>0?s.height:i),w.useEffect(()=>{!n&&xc(o)&&xc(l)&&e(nTe({width:o,height:l}))},[e,n,o,l]),null},FY=Symbol.for("immer-nothing"),_H=Symbol.for("immer-draftable"),_o=Symbol.for("immer-state");function Al(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var cy=Object.getPrototypeOf;function tx(t){return!!t&&!!t[_o]}function pm(t){return t?UY(t)||Array.isArray(t)||!!t[_H]||!!t.constructor?.[_H]||Qy(t)||XN(t):!1}var JTe=Object.prototype.constructor.toString(),wH=new WeakMap;function UY(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=wH.get(n);return r===void 0&&(r=Function.toString.call(n),wH.set(n,r)),r===JTe}function MS(t,e,n=!0){KN(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 KN(t){const e=t[_o];return e?e.type_:Array.isArray(t)?1:Qy(t)?2:XN(t)?3:0}function VP(t,e){return KN(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function zY(t,e,n){const r=KN(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function eAe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function Qy(t){return t instanceof Map}function XN(t){return t instanceof Set}function wf(t){return t.copy_||t.base_}function GP(t,e){if(Qy(t))return new Map(t);if(XN(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=UY(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[_o];let i=Reflect.ownKeys(r);for(let s=0;s<i.length;s++){const o=i[s],l=r[o];l.writable===!1&&(l.writable=!0,l.configurable=!0),(l.get||l.set)&&(r[o]={configurable:!0,writable:!0,enumerable:l.enumerable,value:t[o]})}return Object.create(cy(t),r)}else{const r=cy(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function F4(t,e=!1){return YN(t)||tx(t)||!pm(t)||(KN(t)>1&&Object.defineProperties(t,{set:$w,add:$w,clear:$w,delete:$w}),Object.freeze(t),e&&Object.values(t).forEach(n=>F4(n,!0))),t}function tAe(){Al(2)}var $w={value:tAe};function YN(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var nAe={};function gm(t){const e=nAe[t];return e||Al(0,t),e}var uy;function BY(){return uy}function rAe(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function SH(t,e){e&&(gm("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function qP(t){WP(t),t.drafts_.forEach(iAe),t.drafts_=null}function WP(t){t===uy&&(uy=t.parent_)}function NH(t){return uy=rAe(uy,t)}function iAe(t){const e=t[_o];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];return t!==void 0&&t!==n?(n[_o].modified_&&(qP(e),Al(4)),pm(t)&&(t=ES(e,t),e.parent_||CS(e,t)),e.patches_&&gm("Patches").generateReplacementPatches_(n[_o].base_,t,e.patches_,e.inversePatches_)):t=ES(e,n,[]),qP(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==FY?t:void 0}function ES(t,e,n){if(YN(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[_o];if(!i)return MS(e,(s,o)=>EH(t,i,e,s,o,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return CS(t,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const s=i.copy_;let o=s,l=!1;i.type_===3&&(o=new Set(s),s.clear(),l=!0),MS(o,(c,u)=>EH(t,i,s,c,u,n,l),r),CS(t,s,!1),n&&t.patches_&&gm("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function EH(t,e,n,r,i,s,o){if(i==null||typeof i!="object"&&!o)return;const l=YN(i);if(!(l&&!o)){if(tx(i)){const c=s&&e&&e.type_!==3&&!VP(e.assigned_,r)?s.concat(r):void 0,u=ES(t,i,c);if(zY(n,r,u),tx(u))t.canAutoFreeze_=!1;else return}else o&&n.add(i);if(pm(i)&&!l){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&l)return;ES(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(Qy(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&CS(t,i)}}}function CS(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&F4(e,n)}function aAe(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:BY(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,s=U4;n&&(i=[r],s=dy);const{revoke:o,proxy:l}=Proxy.revocable(i,s);return r.draft_=l,r.revoke_=o,l}var U4={get(t,e){if(e===_o)return t;const n=wf(t);if(!VP(n,e))return sAe(t,n,e);const r=n[e];return t.finalized_||!pm(r)?r:r===Ek(t.base_,e)?(Ck(t),t.copy_[e]=XP(r,t)):r},has(t,e){return e in wf(t)},ownKeys(t){return Reflect.ownKeys(wf(t))},set(t,e,n){const r=$Y(wf(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=Ek(wf(t),e),s=i?.[_o];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(eAe(n,i)&&(n!==void 0||VP(t.base_,e)))return!0;Ck(t),KP(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 Ek(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,Ck(t),KP(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=wf(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Al(11)},getPrototypeOf(t){return cy(t.base_)},setPrototypeOf(){Al(12)}},dy={};MS(U4,(t,e)=>{dy[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});dy.deleteProperty=function(t,e){return dy.set.call(this,t,e,void 0)};dy.set=function(t,e,n){return U4.set.call(this,t[0],e,n,t[0])};function Ek(t,e){const n=t[_o];return(n?wf(n):t)[e]}function sAe(t,e,n){const r=$Y(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function $Y(t,e){if(!(e in t))return;let n=cy(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=cy(n)}}function KP(t){t.modified_||(t.modified_=!0,t.parent_&&KP(t.parent_))}function Ck(t){t.copy_||(t.copy_=GP(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var oAe=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 o=this;return function(c=s,...u){return o.produce(c,d=>n.call(this,d,...u))}}typeof n!="function"&&Al(6),r!==void 0&&typeof r!="function"&&Al(7);let i;if(pm(e)){const s=NH(this),o=XP(e,void 0);let l=!0;try{i=n(o),l=!1}finally{l?qP(s):WP(s)}return SH(s,r),MH(i,s)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===FY&&(i=void 0),this.autoFreeze_&&F4(i,!0),r){const s=[],o=[];gm("Patches").generateReplacementPatches_(e,i,s,o),r(s,o)}return i}else Al(1,e)},this.produceWithPatches=(e,n)=>{if(typeof e=="function")return(o,...l)=>this.produceWithPatches(o,c=>e(c,...l));let r,i;return[this.produce(e,n,(o,l)=>{r=o,i=l}),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){pm(t)||Al(8),tx(t)&&(t=lAe(t));const e=NH(this),n=XP(t,void 0);return n[_o].isManual_=!0,WP(e),n}finishDraft(t,e){const n=t&&t[_o];(!n||!n.isManual_)&&Al(9);const{scope_:r}=n;return SH(r,e),MH(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=gm("Patches").applyPatches_;return tx(t)?r(t,e):this.produce(t,i=>r(i,e))}};function XP(t,e){const n=Qy(t)?gm("MapSet").proxyMap_(t,e):XN(t)?gm("MapSet").proxySet_(t,e):aAe(t,e);return(e?e.scope_:BY()).drafts_.push(n),n}function lAe(t){return tx(t)||Al(10,t),HY(t)}function HY(t){if(!pm(t)||YN(t))return t;const e=t[_o];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=GP(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=GP(t,!0);return MS(n,(i,s)=>{zY(n,i,HY(s))},r),e&&(e.finalized_=!1),n}var cAe=new oAe;cAe.produce;var uAe={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},VY=qs({name:"legend",initialState:uAe,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:Wr()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ol(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:Wr()},removeLegendPayload:{reducer(t,e){var n=Ol(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:Wr()}}}),{setLegendSize:CH,setLegendSettings:dAe,addLegendPayload:GY,replaceLegendPayload:qY,removeLegendPayload:WY}=VY.actions,hAe=VY.reducer,fAe=["contextPayload"];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 TH(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 nx(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?TH(Object(n),!0).forEach(function(r){mAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):TH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function mAe(t,e,n){return(e=pAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pAe(t){var e=gAe(t,"string");return typeof e=="symbol"?e:e+""}function gAe(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 xAe(t,e){if(t==null)return{};var n,r,i=bAe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function bAe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function yAe(t){return t.value}function vAe(t){var{contextPayload:e}=t,n=xAe(t,fAe),r=VX(e,t.payloadUniqBy,yAe),i=nx(nx({},n),{},{payload:r});return w.isValidElement(t.content)?w.cloneElement(t.content,i):typeof t.content=="function"?w.createElement(t.content,i):w.createElement(fEe,i)}function _Ae(t,e,n,r,i,s){var{layout:o,align:l,verticalAlign:c}=e,u,d;return(!t||(t.left===void 0||t.left===null)&&(t.right===void 0||t.right===null))&&(l==="center"&&o==="vertical"?u={left:((r||0)-s.width)/2}:u=l==="right"?{right:n&&n.right||0}:{left:n&&n.left||0}),(!t||(t.top===void 0||t.top===null)&&(t.bottom===void 0||t.bottom===null))&&(c==="middle"?d={top:((i||0)-s.height)/2}:d=c==="bottom"?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),nx(nx({},u),d)}function wAe(t){var e=Or();return w.useEffect(()=>{e(dAe(t))},[e,t]),null}function SAe(t){var e=Or();return w.useEffect(()=>(e(CH(t)),()=>{e(CH({width:0,height:0}))}),[e,t]),null}function NAe(t,e,n,r){return t==="vertical"&&Bt(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var MAe={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function z4(t){var e=ri(t,MAe),n=iCe(),r=aMe(),i=YTe(),{width:s,height:o,wrapperStyle:l,portal:c}=e,[u,d]=YX([n]),f=L4(),m=I4();if(f==null||m==null)return null;var p=f-(i?.left||0)-(i?.right||0),x=NAe(e.layout,o,s,p),b=c?l:nx(nx({position:"absolute",width:x?.width||s||"auto",height:x?.height||o||"auto"},_Ae(l,e,i,f,m,u)),l),y=c??r;if(y==null||n==null)return null;var v=w.createElement("div",{className:"recharts-legend-wrapper",style:b,ref:d},w.createElement(wAe,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&w.createElement(SAe,{width:u.width,height:u.height}),w.createElement(vAe,YP({},e,x,{margin:i,chartWidth:f,chartHeight:m,contextPayload:n})));return pu.createPortal(v,y)}z4.displayName="Legend";function QP(){return QP=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},QP.apply(null,arguments)}function AH(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 Tk(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?AH(Object(n),!0).forEach(function(r){EAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):AH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function EAe(t,e,n){return(e=CAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function CAe(t){var e=TAe(t,"string");return typeof e=="symbol"?e:e+""}function TAe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function AAe(t){return Array.isArray(t)&&ol(t[0])&&ol(t[1])?t.join(" ~ "):t}var kAe=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:s,formatter:o,itemSorter:l,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:f,accessibilityLayer:m=!1}=t,p=()=>{if(s&&s.length){var T={padding:0,margin:0},k=(l?DN(s,l):s).map((E,D)=>{if(E.type==="none")return null;var A=E.formatter||o||AAe,{value:R,name:F}=E,O=R,H=F;if(A){var j=A(R,F,E,D,s);if(Array.isArray(j))[O,H]=j;else if(j!=null)O=j;else return null}var G=Tk({display:"block",paddingTop:4,paddingBottom:4,color:E.color||"#000"},r);return w.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(D),style:G},ol(H)?w.createElement("span",{className:"recharts-tooltip-item-name"},H):null,ol(H)?w.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,w.createElement("span",{className:"recharts-tooltip-item-value"},O),w.createElement("span",{className:"recharts-tooltip-item-unit"},E.unit||""))});return w.createElement("ul",{className:"recharts-tooltip-item-list",style:T},k)}return null},x=Tk({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),b=Tk({margin:0},i),y=!Gr(d),v=y?d:"",S=Zn("recharts-default-tooltip",c),N=Zn("recharts-tooltip-label",u);y&&f&&s!==void 0&&s!==null&&(v=f(d,s));var C=m?{role:"status","aria-live":"assertive"}:{};return w.createElement("div",QP({className:S,style:x},C),w.createElement("p",{className:N,style:b},w.isValidElement(v)?v:"".concat(v)),p())},qb="recharts-tooltip-wrapper",jAe={visibility:"hidden"};function PAe(t){var{coordinate:e,translateX:n,translateY:r}=t;return Zn(qb,{["".concat(qb,"-right")]:Bt(n)&&e&&Bt(e.x)&&n>=e.x,["".concat(qb,"-left")]:Bt(n)&&e&&Bt(e.x)&&n<e.x,["".concat(qb,"-bottom")]:Bt(r)&&e&&Bt(e.y)&&r>=e.y,["".concat(qb,"-top")]:Bt(r)&&e&&Bt(e.y)&&r<e.y})}function kH(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:s,reverseDirection:o,tooltipDimension:l,viewBox:c,viewBoxDimension:u}=t;if(s&&Bt(s[r]))return s[r];var d=n[r]-l-(i>0?i:0),f=n[r]+i;if(e[r])return o[r]?d:f;var m=c[r];if(m==null)return 0;if(o[r]){var p=d,x=m;return p<x?Math.max(f,m):Math.max(d,m)}if(u==null)return 0;var b=f+l,y=m+u;return b>y?Math.max(d,m):Math.max(f,m)}function RAe(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 DAe(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:s,tooltipBox:o,useTranslate3d:l,viewBox:c}=t,u,d,f;return o.height>0&&o.width>0&&n?(d=kH({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:s,tooltipDimension:o.width,viewBox:c,viewBoxDimension:c.width}),f=kH({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:s,tooltipDimension:o.height,viewBox:c,viewBoxDimension:c.height}),u=RAe({translateX:d,translateY:f,useTranslate3d:l})):u=jAe,{cssProperties:u,cssClasses:PAe({translateX:d,translateY:f,coordinate:n})}}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 Hw(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){ZP(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 ZP(t,e,n){return(e=OAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function OAe(t){var e=LAe(t,"string");return typeof e=="symbol"?e:e+""}function LAe(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 IAe extends w.PureComponent{constructor(){super(...arguments),ZP(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),ZP(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:o,hasPayload:l,isAnimationActive:c,offset:u,position:d,reverseDirection:f,useTranslate3d:m,viewBox:p,wrapperStyle:x,lastBoundingBox:b,innerRef:y,hasPortalFromProps:v}=this.props,{cssClasses:S,cssProperties:N}=DAe({allowEscapeViewBox:n,coordinate:o,offsetTopLeft:u,position:d,reverseDirection:f,tooltipBox:{height:b.height,width:b.width},useTranslate3d:m,viewBox:p}),C=v?{}:Hw(Hw({transition:c&&e?"transform ".concat(r,"ms ").concat(i):void 0},N),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&l?"visible":"hidden",position:"absolute",top:0,left:0}),T=Hw(Hw({},C),{},{visibility:!this.state.dismissed&&e&&l?"visible":"hidden"},x);return w.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:S,style:T,ref:y},s)}}var KY=()=>{var t;return(t=Ut(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};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)}function PH(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 RH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?PH(Object(n),!0).forEach(function(r){FAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):PH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function FAe(t,e,n){return(e=UAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function UAe(t){var e=zAe(t,"string");return typeof e=="symbol"?e:e+""}function zAe(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 DH={curveBasisClosed:NMe,curveBasisOpen:MMe,curveBasis:SMe,curveBumpX:cMe,curveBumpY:uMe,curveLinearClosed:EMe,curveLinear:PN,curveMonotoneX:CMe,curveMonotoneY:TMe,curveNatural:AMe,curveStep:kMe,curveStepAfter:PMe,curveStepBefore:jMe},TS=t=>xr(t.x)&&xr(t.y),OH=t=>t.base!=null&&TS(t.base)&&TS(t),Wb=t=>t.x,Kb=t=>t.y,BAe=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(Hy(t));return(n==="curveMonotone"||n==="curveBump")&&e?DH["".concat(n).concat(e==="vertical"?"Y":"X")]:DH[n]||PN},$Ae=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:s=!1}=t,o=BAe(e,i),l=s?n.filter(TS):n,c;if(Array.isArray(r)){var u=n.map((p,x)=>RH(RH({},p),{},{base:r[x]}));i==="vertical"?c=Ow().y(Kb).x1(Wb).x0(p=>p.base.x):c=Ow().x(Wb).y1(Kb).y0(p=>p.base.y);var d=c.defined(OH).curve(o),f=s?u.filter(OH):u;return d(f)}i==="vertical"&&Bt(r)?c=Ow().y(Kb).x1(Wb).x0(r):Bt(r)?c=Ow().x(Wb).y1(Kb).y0(r):c=yX().x(Wb).y(Kb);var m=c.defined(TS).curve(o);return m(l)},Pg=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var s=n&&n.length?$Ae(t):r;return w.createElement("path",JP({},_s(t),S4(t),{className:Zn("recharts-curve",e),d:s===null?void 0:s,ref:i}))},HAe=["x","y","top","left","width","height","className"];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 LH(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 VAe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?LH(Object(n),!0).forEach(function(r){GAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):LH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function GAe(t,e,n){return(e=qAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function qAe(t){var e=WAe(t,"string");return typeof e=="symbol"?e:e+""}function WAe(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 KAe(t,e){if(t==null)return{};var n,r,i=XAe(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 XAe(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 YAe=(t,e,n,r,i,s)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(s,",").concat(e,"h").concat(n),QAe=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:s=0,height:o=0,className:l}=t,c=KAe(t,HAe),u=VAe({x:e,y:n,top:r,left:i,width:s,height:o},c);return!Bt(e)||!Bt(n)||!Bt(s)||!Bt(o)||!Bt(r)||!Bt(i)?null:w.createElement("path",eR({},La(u),{className:Zn("recharts-cross",l),d:YAe(e,n,s,o,r,i)}))};function ZAe(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 IH(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 FH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?IH(Object(n),!0).forEach(function(r){JAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):IH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function JAe(t,e,n){return(e=eke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function eke(t){var e=tke(t,"string");return typeof e=="symbol"?e:e+""}function tke(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 nke=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),XY=(t,e,n)=>t.map(r=>"".concat(nke(r)," ").concat(e,"ms ").concat(n)).join(","),rke=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),hy=(t,e)=>Object.keys(e).reduce((n,r)=>FH(FH({},n),{},{[r]:t(r,e[r])}),{});function UH(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 Vi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?UH(Object(n),!0).forEach(function(r){ike(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):UH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ike(t,e,n){return(e=ake(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ake(t){var e=ske(t,"string");return typeof e=="symbol"?e:e+""}function ske(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 AS=(t,e,n)=>t+(e-t)*n,tR=t=>{var{from:e,to:n}=t;return e!==n},YY=(t,e,n)=>{var r=hy((i,s)=>{if(tR(s)){var[o,l]=t(s.from,s.to,s.velocity);return Vi(Vi({},s),{},{from:o,velocity:l})}return s},e);return n<1?hy((i,s)=>tR(s)?Vi(Vi({},s),{},{velocity:AS(s.velocity,r[i].velocity,n),from:AS(s.from,r[i].from,n)}):s,e):YY(t,r,n-1)};function oke(t,e,n,r,i,s){var o,l=r.reduce((m,p)=>Vi(Vi({},m),{},{[p]:{from:t[p],velocity:0,to:e[p]}}),{}),c=()=>hy((m,p)=>p.from,l),u=()=>!Object.values(l).filter(tR).length,d=null,f=m=>{o||(o=m);var p=m-o,x=p/n.dt;l=YY(n,l,x),i(Vi(Vi(Vi({},t),e),c())),o=m,u()||(d=s.setTimeout(f))};return()=>(d=s.setTimeout(f),()=>{var m;(m=d)===null||m===void 0||m()})}function lke(t,e,n,r,i,s,o){var l=null,c=i.reduce((f,m)=>Vi(Vi({},f),{},{[m]:[t[m],e[m]]}),{}),u,d=f=>{u||(u=f);var m=(f-u)/r,p=hy((b,y)=>AS(...y,n(m)),c);if(s(Vi(Vi(Vi({},t),e),p)),m<1)l=o.setTimeout(d);else{var x=hy((b,y)=>AS(...y,n(1)),c);s(Vi(Vi(Vi({},t),e),x))}};return()=>(l=o.setTimeout(d),()=>{var f;(f=l)===null||f===void 0||f()})}const cke=(t,e,n,r,i,s)=>{var o=rke(t,e);return n==null?()=>(i(Vi(Vi({},t),e)),()=>{}):n.isStepper===!0?oke(t,e,n,o,i,s):lke(t,e,n,r,o,i,s)};var kS=1e-4,QY=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],ZY=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),zH=(t,e)=>n=>{var r=QY(t,e);return ZY(r,n)},uke=(t,e)=>n=>{var r=QY(t,e),i=[...r.map((s,o)=>s*o).slice(1),0];return ZY(i,n)},dke=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 o=s[1].split(")")[0].split(",").map(l=>parseFloat(l));return[o[0],o[1],o[2],o[3]]}}}return n.length===4?n:[0,0,1,1]},hke=(t,e,n,r)=>{var i=zH(t,n),s=zH(e,r),o=uke(t,n),l=u=>u>1?1:u<0?0:u,c=u=>{for(var d=u>1?1:u,f=d,m=0;m<8;++m){var p=i(f)-d,x=o(f);if(Math.abs(p-d)<kS||x<kS)return s(f);f=l(f-p/x)}return s(f)};return c.isStepper=!1,c},BH=function(){return hke(...dke(...arguments))},fke=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=e,s=(o,l,c)=>{var u=-(o-l)*n,d=c*r,f=c+(u-d)*i/1e3,m=c*i/1e3+o;return Math.abs(m-l)<kS&&Math.abs(f)<kS?[l,0]:[m,f]};return s.isStepper=!0,s.dt=i,s},mke=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return BH(t);case"spring":return fke();default:if(t.split("(")[0]==="cubic-bezier")return BH(t)}return typeof t=="function"?t:null};function pke(t){var e,n=()=>null,r=!1,i=null,s=o=>{if(!r){if(Array.isArray(o)){if(!o.length)return;var l=o,[c,...u]=l;if(typeof c=="number"){i=t.setTimeout(s.bind(null,u),c);return}s(c),i=t.setTimeout(s.bind(null,u));return}typeof o=="string"&&(e=o,n(e)),typeof o=="object"&&(e=o,n(e)),typeof o=="function"&&o()}};return{stop:()=>{r=!0},start:o=>{r=!1,i&&(i(),i=null),s(o)},subscribe:o=>(n=o,()=>{n=()=>null}),getTimeoutController:()=>t}}class gke{setTimeout(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=performance.now(),i=null,s=o=>{o-r>=n?e(o):typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(s))};return i=requestAnimationFrame(s),()=>{i!=null&&cancelAnimationFrame(i)}}}function xke(){return pke(new gke)}var bke=w.createContext(xke);function yke(t,e){var n=w.useContext(bke);return w.useMemo(()=>e??n(t),[t,e,n])}var vke=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Nx={devToolsEnabled:!1,isSsr:vke()},_ke={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},$H={t:0},Ak={t:1};function Mx(t){var e=ri(t,_ke),{isActive:n,canBegin:r,duration:i,easing:s,begin:o,onAnimationEnd:l,onAnimationStart:c,children:u}=e,d=n==="auto"?!Nx.isSsr:n,f=yke(e.animationId,e.animationManager),[m,p]=w.useState(d?$H:Ak),x=w.useRef(null);return w.useEffect(()=>{d||p(Ak)},[d]),w.useEffect(()=>{if(!d||!r)return Vy;var b=cke($H,Ak,mke(s),i,p,f.getTimeoutController()),y=()=>{x.current=b()};return f.start([c,o,y,i,l]),()=>{f.stop(),x.current&&x.current(),l()}},[d,r,i,s,o,c,l,f]),u(m.t)}function Ex(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=w.useRef(ay(e)),r=w.useRef(t);return r.current!==t&&(n.current=ay(e),r.current=t),n.current}var wke=["radius"],Ske=["radius"];function HH(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 VH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?HH(Object(n),!0).forEach(function(r){Nke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):HH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Nke(t,e,n){return(e=Mke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Mke(t){var e=Eke(t,"string");return typeof e=="symbol"?e:e+""}function Eke(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 jS(){return jS=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},jS.apply(null,arguments)}function GH(t,e){if(t==null)return{};var n,r,i=Cke(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 Cke(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 qH=(t,e,n,r,i)=>{var s=Math.min(Math.abs(n)/2,Math.abs(r)/2),o=r>=0?1:-1,l=n>=0?1:-1,c=r>=0&&n>=0||r<0&&n<0?1:0,u;if(s>0&&i instanceof Array){for(var d=[0,0,0,0],f=0,m=4;f<m;f++)d[f]=i[f]>s?s:i[f];u="M".concat(t,",").concat(e+o*d[0]),d[0]>0&&(u+="A ".concat(d[0],",").concat(d[0],",0,0,").concat(c,",").concat(t+l*d[0],",").concat(e)),u+="L ".concat(t+n-l*d[1],",").concat(e),d[1]>0&&(u+="A ".concat(d[1],",").concat(d[1],",0,0,").concat(c,`,
  8068. `).concat(t+n,",").concat(e+o*d[1])),u+="L ".concat(t+n,",").concat(e+r-o*d[2]),d[2]>0&&(u+="A ".concat(d[2],",").concat(d[2],",0,0,").concat(c,`,
  8069. `).concat(t+n-l*d[2],",").concat(e+r)),u+="L ".concat(t+l*d[3],",").concat(e+r),d[3]>0&&(u+="A ".concat(d[3],",").concat(d[3],",0,0,").concat(c,`,
  8070. `).concat(t,",").concat(e+r-o*d[3])),u+="Z"}else if(s>0&&i===+i&&i>0){var p=Math.min(s,i);u="M ".concat(t,",").concat(e+o*p,`
  8071. A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+l*p,",").concat(e,`
  8072. L `).concat(t+n-l*p,",").concat(e,`
  8073. A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+n,",").concat(e+o*p,`
  8074. L `).concat(t+n,",").concat(e+r-o*p,`
  8075. A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+n-l*p,",").concat(e+r,`
  8076. L `).concat(t+l*p,",").concat(e+r,`
  8077. A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t,",").concat(e+r-o*p," Z")}else u="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return u},WH={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},JY=t=>{var e=ri(t,WH),n=w.useRef(null),[r,i]=w.useState(-1);w.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var q=n.current.getTotalLength();q&&i(q)}catch{}},[]);var{x:s,y:o,width:l,height:c,radius:u,className:d}=e,{animationEasing:f,animationDuration:m,animationBegin:p,isAnimationActive:x,isUpdateAnimationActive:b}=e,y=w.useRef(l),v=w.useRef(c),S=w.useRef(s),N=w.useRef(o),C=w.useMemo(()=>({x:s,y:o,width:l,height:c,radius:u}),[s,o,l,c,u]),T=Ex(C,"rectangle-");if(s!==+s||o!==+o||l!==+l||c!==+c||l===0||c===0)return null;var k=Zn("recharts-rectangle",d);if(!b){var E=La(e),{radius:D}=E,A=GH(E,wke);return w.createElement("path",jS({},A,{radius:typeof u=="number"?u:void 0,className:k,d:qH(s,o,l,c,u)}))}var R=y.current,F=v.current,O=S.current,H=N.current,j="0px ".concat(r===-1?1:r,"px"),G="".concat(r,"px 0px"),$=XY(["strokeDasharray"],m,typeof f=="string"?f:WH.animationEasing);return w.createElement(Mx,{animationId:T,key:T,canBegin:r>0,duration:m,easing:f,isActive:b,begin:p},q=>{var Y=ur(R,l,q),Z=ur(F,c,q),oe=ur(O,s,q),B=ur(H,o,q);n.current&&(y.current=Y,v.current=Z,S.current=oe,N.current=B);var W;x?q>0?W={transition:$,strokeDasharray:G}:W={strokeDasharray:j}:W={strokeDasharray:G};var se=La(e),{radius:ne}=se,ce=GH(se,Ske);return w.createElement("path",jS({},ce,{radius:typeof u=="number"?u:void 0,className:k,d:qH(oe,B,Y,Z,u),ref:n,style:VH(VH({},W),e.style)}))})};function KH(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 XH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?KH(Object(n),!0).forEach(function(r){Tke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):KH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Tke(t,e,n){return(e=Ake(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ake(t){var e=kke(t,"string");return typeof e=="symbol"?e:e+""}function kke(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 PS=Math.PI/180,jke=t=>t*180/Math.PI,Oi=(t,e,n,r)=>({x:t+Math.cos(-PS*r)*n,y:e+Math.sin(-PS*r)*n}),eQ=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},Pke=(t,e)=>{var{x:n,y:r}=t,{x:i,y:s}=e;return Math.sqrt((n-i)**2+(r-s)**2)},Rke=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:s}=e,o=Pke({x:n,y:r},{x:i,y:s});if(o<=0)return{radius:o,angle:0};var l=(n-i)/o,c=Math.acos(l);return r>s&&(c=2*Math.PI-c),{radius:o,angle:jke(c),angleInRadian:c}},Dke=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}},Oke=(t,e)=>{var{startAngle:n,endAngle:r}=e,i=Math.floor(n/360),s=Math.floor(r/360),o=Math.min(i,s);return t+o*360},Lke=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:s}=Rke({x:n,y:r},e),{innerRadius:o,outerRadius:l}=e;if(i<o||i>l||i===0)return null;var{startAngle:c,endAngle:u}=Dke(e),d=s,f;if(c<=u){for(;d>u;)d-=360;for(;d<c;)d+=360;f=d>=c&&d<=u}else{for(;d>c;)d-=360;for(;d<u;)d+=360;f=d>=u&&d<=c}return f?XH(XH({},e),{},{radius:i,angle:Oke(d,e)}):null};function tQ(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:s}=t,o=Oi(e,n,r,i),l=Oi(e,n,r,s);return{points:[o,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:s}}function nR(){return nR=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},nR.apply(null,arguments)}var Ike=(t,e)=>{var n=ga(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},Vw=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:s,isExternal:o,cornerRadius:l,cornerIsExternal:c}=t,u=l*(o?1:-1)+r,d=Math.asin(l/u)/PS,f=c?i:i+s*d,m=Oi(e,n,u,f),p=Oi(e,n,r,f),x=c?i-s*d:i,b=Oi(e,n,u*Math.cos(d*PS),x);return{center:m,circleTangency:p,lineTangency:b,theta:d}},nQ=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:s,endAngle:o}=t,l=Ike(s,o),c=s+l,u=Oi(e,n,i,s),d=Oi(e,n,i,c),f="M ".concat(u.x,",").concat(u.y,`
  8078. A `).concat(i,",").concat(i,`,0,
  8079. `).concat(+(Math.abs(l)>180),",").concat(+(s>c),`,
  8080. `).concat(d.x,",").concat(d.y,`
  8081. `);if(r>0){var m=Oi(e,n,r,s),p=Oi(e,n,r,c);f+="L ".concat(p.x,",").concat(p.y,`
  8082. A `).concat(r,",").concat(r,`,0,
  8083. `).concat(+(Math.abs(l)>180),",").concat(+(s<=c),`,
  8084. `).concat(m.x,",").concat(m.y," Z")}else f+="L ".concat(e,",").concat(n," Z");return f},Fke=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:s,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u}=t,d=ga(u-c),{circleTangency:f,lineTangency:m,theta:p}=Vw({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:s,cornerIsExternal:l}),{circleTangency:x,lineTangency:b,theta:y}=Vw({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:s,cornerIsExternal:l}),v=l?Math.abs(c-u):Math.abs(c-u)-p-y;if(v<0)return o?"M ".concat(m.x,",").concat(m.y,`
  8085. a`).concat(s,",").concat(s,",0,0,1,").concat(s*2,`,0
  8086. a`).concat(s,",").concat(s,",0,0,1,").concat(-s*2,`,0
  8087. `):nQ({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var S="M ".concat(m.x,",").concat(m.y,`
  8088. A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(f.x,",").concat(f.y,`
  8089. A`).concat(i,",").concat(i,",0,").concat(+(v>180),",").concat(+(d<0),",").concat(x.x,",").concat(x.y,`
  8090. A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(b.x,",").concat(b.y,`
  8091. `);if(r>0){var{circleTangency:N,lineTangency:C,theta:T}=Vw({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:s,cornerIsExternal:l}),{circleTangency:k,lineTangency:E,theta:D}=Vw({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:s,cornerIsExternal:l}),A=l?Math.abs(c-u):Math.abs(c-u)-T-D;if(A<0&&s===0)return"".concat(S,"L").concat(e,",").concat(n,"Z");S+="L".concat(E.x,",").concat(E.y,`
  8092. A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(k.x,",").concat(k.y,`
  8093. A`).concat(r,",").concat(r,",0,").concat(+(A>180),",").concat(+(d>0),",").concat(N.x,",").concat(N.y,`
  8094. A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(C.x,",").concat(C.y,"Z")}else S+="L".concat(e,",").concat(n,"Z");return S},Uke={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},rQ=t=>{var e=ri(t,Uke),{cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:o,forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d,className:f}=e;if(s<i||u===d)return null;var m=Zn("recharts-sector",f),p=s-i,x=Za(o,p,0,!0),b;return x>0&&Math.abs(u-d)<360?b=Fke({cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:Math.min(x,p/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d}):b=nQ({cx:n,cy:r,innerRadius:i,outerRadius:s,startAngle:u,endAngle:d}),w.createElement("path",nR({},La(e),{className:m,d:b}))};function zke(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(DX(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:s,outerRadius:o,angle:l}=e,c=Oi(r,i,s,l),u=Oi(r,i,o,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return tQ(e)}}var kk={},jk={},Pk={},YH;function Bke(){return YH||(YH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=WX();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(Pk)),Pk}var QH;function $ke(){return QH||(QH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Bke();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})(jk)),jk}var ZH;function Hke(){return ZH||(ZH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=KX(),n=$ke();function r(i,s,o){o&&typeof o!="number"&&e.isIterateeCall(i,s,o)&&(s=o=void 0),i=n.toFinite(i),s===void 0?(s=i,i=0):s=n.toFinite(s),o=o===void 0?i<s?1:-1:n.toFinite(o);const l=Math.max(Math.ceil((s-i)/(o||1)),0),c=new Array(l);for(let u=0;u<l;u++)c[u]=i,i+=o;return c}t.range=r})(kk)),kk}var Rk,JH;function Vke(){return JH||(JH=1,Rk=Hke().range),Rk}var Gke=Vke();const iQ=ul(Gke);function dh(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function qke(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function B4(t){let e,n,r;t.length!==2?(e=dh,n=(l,c)=>dh(t(l),c),r=(l,c)=>t(l)-c):(e=t===dh||t===qke?t:Wke,n=t,r=t);function i(l,c,u=0,d=l.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(l[f],c)<0?u=f+1:d=f}while(u<d)}return u}function s(l,c,u=0,d=l.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(l[f],c)<=0?u=f+1:d=f}while(u<d)}return u}function o(l,c,u=0,d=l.length){const f=i(l,c,u,d-1);return f>u&&r(l[f-1],c)>-r(l[f],c)?f-1:f}return{left:i,center:o,right:s}}function Wke(){return 0}function aQ(t){return t===null?NaN:+t}function*Kke(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const Xke=B4(dh),Zy=Xke.right;B4(aQ).center;class eV extends Map{constructor(e,n=Zke){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(tV(this,e))}has(e){return super.has(tV(this,e))}set(e,n){return super.set(Yke(this,e),n)}delete(e){return super.delete(Qke(this,e))}}function tV({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function Yke({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function Qke({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function Zke(t){return t!==null&&typeof t=="object"?t.valueOf():t}function Jke(t=dh){if(t===dh)return sQ;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 sQ(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const eje=Math.sqrt(50),tje=Math.sqrt(10),nje=Math.sqrt(2);function RS(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),s=r/Math.pow(10,i),o=s>=eje?10:s>=tje?5:s>=nje?2:1;let l,c,u;return i<0?(u=Math.pow(10,-i)/o,l=Math.round(t*u),c=Math.round(e*u),l/u<t&&++l,c/u>e&&--c,u=-u):(u=Math.pow(10,i)*o,l=Math.round(t/u),c=Math.round(e/u),l*u<t&&++l,c*u>e&&--c),c<l&&.5<=n&&n<2?RS(t,e,n*2):[l,c,u]}function rR(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[i,s,o]=r?RS(e,t,n):RS(t,e,n);if(!(s>=i))return[];const l=s-i+1,c=new Array(l);if(r)if(o<0)for(let u=0;u<l;++u)c[u]=(s-u)/-o;else for(let u=0;u<l;++u)c[u]=(s-u)*o;else if(o<0)for(let u=0;u<l;++u)c[u]=(i+u)/-o;else for(let u=0;u<l;++u)c[u]=(i+u)*o;return c}function iR(t,e,n){return e=+e,t=+t,n=+n,RS(t,e,n)[2]}function aR(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?iR(e,t,n):iR(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function nV(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function rV(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function oQ(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?sQ:Jke(i);r>n;){if(r-n>600){const c=r-n+1,u=e-n+1,d=Math.log(c),f=.5*Math.exp(2*d/3),m=.5*Math.sqrt(d*f*(c-f)/c)*(u-c/2<0?-1:1),p=Math.max(n,Math.floor(e-u*f/c+m)),x=Math.min(r,Math.floor(e+(c-u)*f/c+m));oQ(t,e,p,x,i)}const s=t[e];let o=n,l=r;for(Xb(t,n,e),i(t[r],s)>0&&Xb(t,n,r);o<l;){for(Xb(t,o,l),++o,--l;i(t[o],s)<0;)++o;for(;i(t[l],s)>0;)--l}i(t[n],s)===0?Xb(t,n,l):(++l,Xb(t,l,r)),l<=e&&(n=l+1),e<=l&&(r=l-1)}return t}function Xb(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function rje(t,e,n){if(t=Float64Array.from(Kke(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return rV(t);if(e>=1)return nV(t);var r,i=(r-1)*e,s=Math.floor(i),o=nV(oQ(t,s).subarray(0,s+1)),l=rV(t.subarray(s+1));return o+(l-o)*(i-s)}}function ije(t,e,n=aQ){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),o=+n(t[s],s,t),l=+n(t[s+1],s+1,t);return o+(l-o)*(i-s)}}function aje(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 hl(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Wu(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 sR=Symbol("implicit");function $4(){var t=new eV,e=[],n=[],r=sR;function i(s){let o=t.get(s);if(o===void 0){if(r!==sR)return r;t.set(s,o=e.push(s)-1)}return n[o%n.length]}return i.domain=function(s){if(!arguments.length)return e.slice();e=[],t=new eV;for(const o of s)t.has(o)||t.set(o,e.push(o)-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 $4(e,n).unknown(r)},hl.apply(i,arguments),i}function H4(){var t=$4().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,s,o,l=!1,c=0,u=0,d=.5;delete t.unknown;function f(){var m=e().length,p=i<r,x=p?i:r,b=p?r:i;s=(b-x)/Math.max(1,m-c+u*2),l&&(s=Math.floor(s)),x+=(b-x-s*(m-c))*d,o=s*(1-c),l&&(x=Math.round(x),o=Math.round(o));var y=aje(m).map(function(v){return x+s*v});return n(p?y.reverse():y)}return t.domain=function(m){return arguments.length?(e(m),f()):e()},t.range=function(m){return arguments.length?([r,i]=m,r=+r,i=+i,f()):[r,i]},t.rangeRound=function(m){return[r,i]=m,r=+r,i=+i,l=!0,f()},t.bandwidth=function(){return o},t.step=function(){return s},t.round=function(m){return arguments.length?(l=!!m,f()):l},t.padding=function(m){return arguments.length?(c=Math.min(1,u=+m),f()):c},t.paddingInner=function(m){return arguments.length?(c=Math.min(1,m),f()):c},t.paddingOuter=function(m){return arguments.length?(u=+m,f()):u},t.align=function(m){return arguments.length?(d=Math.max(0,Math.min(1,m)),f()):d},t.copy=function(){return H4(e(),[r,i]).round(l).paddingInner(c).paddingOuter(u).align(d)},hl.apply(f(),arguments)}function lQ(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return lQ(e())},t}function sje(){return lQ(H4.apply(null,arguments).paddingInner(1))}function V4(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function cQ(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Jy(){}var fy=.7,DS=1/fy,Rg="\\s*([+-]?\\d+)\\s*",my="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",mc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",oje=/^#([0-9a-f]{3,8})$/,lje=new RegExp(`^rgb\\(${Rg},${Rg},${Rg}\\)$`),cje=new RegExp(`^rgb\\(${mc},${mc},${mc}\\)$`),uje=new RegExp(`^rgba\\(${Rg},${Rg},${Rg},${my}\\)$`),dje=new RegExp(`^rgba\\(${mc},${mc},${mc},${my}\\)$`),hje=new RegExp(`^hsl\\(${my},${mc},${mc}\\)$`),fje=new RegExp(`^hsla\\(${my},${mc},${mc},${my}\\)$`),iV={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};V4(Jy,py,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:aV,formatHex:aV,formatHex8:mje,formatHsl:pje,formatRgb:sV,toString:sV});function aV(){return this.rgb().formatHex()}function mje(){return this.rgb().formatHex8()}function pje(){return uQ(this).formatHsl()}function sV(){return this.rgb().formatRgb()}function py(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=oje.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?oV(e):n===3?new Fs(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?Gw(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?Gw(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=lje.exec(t))?new Fs(e[1],e[2],e[3],1):(e=cje.exec(t))?new Fs(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=uje.exec(t))?Gw(e[1],e[2],e[3],e[4]):(e=dje.exec(t))?Gw(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=hje.exec(t))?uV(e[1],e[2]/100,e[3]/100,1):(e=fje.exec(t))?uV(e[1],e[2]/100,e[3]/100,e[4]):iV.hasOwnProperty(t)?oV(iV[t]):t==="transparent"?new Fs(NaN,NaN,NaN,0):null}function oV(t){return new Fs(t>>16&255,t>>8&255,t&255,1)}function Gw(t,e,n,r){return r<=0&&(t=e=n=NaN),new Fs(t,e,n,r)}function gje(t){return t instanceof Jy||(t=py(t)),t?(t=t.rgb(),new Fs(t.r,t.g,t.b,t.opacity)):new Fs}function oR(t,e,n,r){return arguments.length===1?gje(t):new Fs(t,e,n,r??1)}function Fs(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}V4(Fs,oR,cQ(Jy,{brighter(t){return t=t==null?DS:Math.pow(DS,t),new Fs(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?fy:Math.pow(fy,t),new Fs(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Fs(qf(this.r),qf(this.g),qf(this.b),OS(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:lV,formatHex:lV,formatHex8:xje,formatRgb:cV,toString:cV}));function lV(){return`#${Rf(this.r)}${Rf(this.g)}${Rf(this.b)}`}function xje(){return`#${Rf(this.r)}${Rf(this.g)}${Rf(this.b)}${Rf((isNaN(this.opacity)?1:this.opacity)*255)}`}function cV(){const t=OS(this.opacity);return`${t===1?"rgb(":"rgba("}${qf(this.r)}, ${qf(this.g)}, ${qf(this.b)}${t===1?")":`, ${t})`}`}function OS(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function qf(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Rf(t){return t=qf(t),(t<16?"0":"")+t.toString(16)}function uV(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new kl(t,e,n,r)}function uQ(t){if(t instanceof kl)return new kl(t.h,t.s,t.l,t.opacity);if(t instanceof Jy||(t=py(t)),!t)return new kl;if(t instanceof kl)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),o=NaN,l=s-i,c=(s+i)/2;return l?(e===s?o=(n-r)/l+(n<r)*6:n===s?o=(r-e)/l+2:o=(e-n)/l+4,l/=c<.5?s+i:2-s-i,o*=60):l=c>0&&c<1?0:o,new kl(o,l,c,t.opacity)}function bje(t,e,n,r){return arguments.length===1?uQ(t):new kl(t,e,n,r??1)}function kl(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}V4(kl,bje,cQ(Jy,{brighter(t){return t=t==null?DS:Math.pow(DS,t),new kl(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?fy:Math.pow(fy,t),new kl(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 Fs(Dk(t>=240?t-240:t+120,i,r),Dk(t,i,r),Dk(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new kl(dV(this.h),qw(this.s),qw(this.l),OS(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=OS(this.opacity);return`${t===1?"hsl(":"hsla("}${dV(this.h)}, ${qw(this.s)*100}%, ${qw(this.l)*100}%${t===1?")":`, ${t})`}`}}));function dV(t){return t=(t||0)%360,t<0?t+360:t}function qw(t){return Math.max(0,Math.min(1,t||0))}function Dk(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 G4=t=>()=>t;function yje(t,e){return function(n){return t+n*e}}function vje(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 _je(t){return(t=+t)==1?dQ:function(e,n){return n-e?vje(e,n,t):G4(isNaN(e)?n:e)}}function dQ(t,e){var n=e-t;return n?yje(t,n):G4(isNaN(t)?e:t)}const hV=(function t(e){var n=_je(e);function r(i,s){var o=n((i=oR(i)).r,(s=oR(s)).r),l=n(i.g,s.g),c=n(i.b,s.b),u=dQ(i.opacity,s.opacity);return function(d){return i.r=o(d),i.g=l(d),i.b=c(d),i.opacity=u(d),i+""}}return r.gamma=t,r})(1);function wje(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 Sje(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Nje(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),s=new Array(n),o;for(o=0;o<r;++o)i[o]=Cx(t[o],e[o]);for(;o<n;++o)s[o]=e[o];return function(l){for(o=0;o<r;++o)s[o]=i[o](l);return s}}function Mje(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function LS(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Eje(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]=Cx(t[i],e[i]):r[i]=e[i];return function(s){for(i in n)r[i]=n[i](s);return r}}var lR=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ok=new RegExp(lR.source,"g");function Cje(t){return function(){return t}}function Tje(t){return function(e){return t(e)+""}}function Aje(t,e){var n=lR.lastIndex=Ok.lastIndex=0,r,i,s,o=-1,l=[],c=[];for(t=t+"",e=e+"";(r=lR.exec(t))&&(i=Ok.exec(e));)(s=i.index)>n&&(s=e.slice(n,s),l[o]?l[o]+=s:l[++o]=s),(r=r[0])===(i=i[0])?l[o]?l[o]+=i:l[++o]=i:(l[++o]=null,c.push({i:o,x:LS(r,i)})),n=Ok.lastIndex;return n<e.length&&(s=e.slice(n),l[o]?l[o]+=s:l[++o]=s),l.length<2?c[0]?Tje(c[0].x):Cje(e):(e=c.length,function(u){for(var d=0,f;d<e;++d)l[(f=c[d]).i]=f.x(u);return l.join("")})}function Cx(t,e){var n=typeof e,r;return e==null||n==="boolean"?G4(e):(n==="number"?LS:n==="string"?(r=py(e))?(e=r,hV):Aje:e instanceof py?hV:e instanceof Date?Mje:Sje(e)?wje:Array.isArray(e)?Nje:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Eje:LS)(t,e)}function q4(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function kje(t,e){e===void 0&&(e=t,t=Cx);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(o){var l=Math.max(0,Math.min(r-1,Math.floor(o*=r)));return s[l](o-l)}}function jje(t){return function(){return t}}function IS(t){return+t}var fV=[0,1];function ps(t){return t}function cR(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:jje(isNaN(e)?NaN:.5)}function Pje(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function Rje(t,e,n){var r=t[0],i=t[1],s=e[0],o=e[1];return i<r?(r=cR(i,r),s=n(o,s)):(r=cR(r,i),s=n(s,o)),function(l){return s(r(l))}}function Dje(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),s=new Array(r),o=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++o<r;)i[o]=cR(t[o],t[o+1]),s[o]=n(e[o],e[o+1]);return function(l){var c=Zy(t,l,1,r)-1;return s[c](i[c](l))}}function ev(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function QN(){var t=fV,e=fV,n=Cx,r,i,s,o=ps,l,c,u;function d(){var m=Math.min(t.length,e.length);return o!==ps&&(o=Pje(t[0],t[m-1])),l=m>2?Dje:Rje,c=u=null,f}function f(m){return m==null||isNaN(m=+m)?s:(c||(c=l(t.map(r),e,n)))(r(o(m)))}return f.invert=function(m){return o(i((u||(u=l(e,t.map(r),LS)))(m)))},f.domain=function(m){return arguments.length?(t=Array.from(m,IS),d()):t.slice()},f.range=function(m){return arguments.length?(e=Array.from(m),d()):e.slice()},f.rangeRound=function(m){return e=Array.from(m),n=q4,d()},f.clamp=function(m){return arguments.length?(o=m?!0:ps,d()):o!==ps},f.interpolate=function(m){return arguments.length?(n=m,d()):n},f.unknown=function(m){return arguments.length?(s=m,f):s},function(m,p){return r=m,i=p,d()}}function W4(){return QN()(ps,ps)}function Oje(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function FS(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 rx(t){return t=FS(Math.abs(t)),t?t[1]:NaN}function Lje(t,e){return function(n,r){for(var i=n.length,s=[],o=0,l=t[0],c=0;i>0&&l>0&&(c+l+1>r&&(l=Math.max(1,r-c)),s.push(n.substring(i-=l,i+l)),!((c+=l+1)>r));)l=t[o=(o+1)%t.length];return s.reverse().join(e)}}function Ije(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var Fje=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function gy(t){if(!(e=Fje.exec(t)))throw new Error("invalid format: "+t);var e;return new K4({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]})}gy.prototype=K4.prototype;function K4(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+""}K4.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 Uje(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 hQ;function zje(t,e){var n=FS(t,e);if(!n)return t+"";var r=n[0],i=n[1],s=i-(hQ=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return s===o?r:s>o?r+new Array(s-o+1).join("0"):s>0?r.slice(0,s)+"."+r.slice(s):"0."+new Array(1-s).join("0")+FS(t,Math.max(0,e+s-1))[0]}function mV(t,e){var n=FS(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 pV={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Oje,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)=>mV(t*100,e),r:mV,s:zje,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function gV(t){return t}var xV=Array.prototype.map,bV=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Bje(t){var e=t.grouping===void 0||t.thousands===void 0?gV:Lje(xV.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?gV:Ije(xV.call(t.numerals,String)),o=t.percent===void 0?"%":t.percent+"",l=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function u(f){f=gy(f);var m=f.fill,p=f.align,x=f.sign,b=f.symbol,y=f.zero,v=f.width,S=f.comma,N=f.precision,C=f.trim,T=f.type;T==="n"?(S=!0,T="g"):pV[T]||(N===void 0&&(N=12),C=!0,T="g"),(y||m==="0"&&p==="=")&&(y=!0,m="0",p="=");var k=b==="$"?n:b==="#"&&/[boxX]/.test(T)?"0"+T.toLowerCase():"",E=b==="$"?r:/[%p]/.test(T)?o:"",D=pV[T],A=/[defgprs%]/.test(T);N=N===void 0?6:/[gprs]/.test(T)?Math.max(1,Math.min(21,N)):Math.max(0,Math.min(20,N));function R(F){var O=k,H=E,j,G,$;if(T==="c")H=D(F)+H,F="";else{F=+F;var q=F<0||1/F<0;if(F=isNaN(F)?c:D(Math.abs(F),N),C&&(F=Uje(F)),q&&+F==0&&x!=="+"&&(q=!1),O=(q?x==="("?x:l:x==="-"||x==="("?"":x)+O,H=(T==="s"?bV[8+hQ/3]:"")+H+(q&&x==="("?")":""),A){for(j=-1,G=F.length;++j<G;)if($=F.charCodeAt(j),48>$||$>57){H=($===46?i+F.slice(j+1):F.slice(j))+H,F=F.slice(0,j);break}}}S&&!y&&(F=e(F,1/0));var Y=O.length+F.length+H.length,Z=Y<v?new Array(v-Y+1).join(m):"";switch(S&&y&&(F=e(Z+F,Z.length?v-H.length:1/0),Z=""),p){case"<":F=O+F+H+Z;break;case"=":F=O+Z+F+H;break;case"^":F=Z.slice(0,Y=Z.length>>1)+O+F+H+Z.slice(Y);break;default:F=Z+O+F+H;break}return s(F)}return R.toString=function(){return f+""},R}function d(f,m){var p=u((f=gy(f),f.type="f",f)),x=Math.max(-8,Math.min(8,Math.floor(rx(m)/3)))*3,b=Math.pow(10,-x),y=bV[8+x/3];return function(v){return p(b*v)+y}}return{format:u,formatPrefix:d}}var Ww,X4,fQ;$je({thousands:",",grouping:[3],currency:["$",""]});function $je(t){return Ww=Bje(t),X4=Ww.format,fQ=Ww.formatPrefix,Ww}function Hje(t){return Math.max(0,-rx(Math.abs(t)))}function Vje(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(rx(e)/3)))*3-rx(Math.abs(t)))}function Gje(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,rx(e)-rx(t))+1}function mQ(t,e,n,r){var i=aR(t,e,n),s;switch(r=gy(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(s=Vje(i,o))&&(r.precision=s),fQ(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(s=Gje(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=s-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(s=Hje(i))&&(r.precision=s-(r.type==="%")*2);break}}return X4(r)}function Ih(t){var e=t.domain;return t.ticks=function(n){var r=e();return rR(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return mQ(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,o=r[i],l=r[s],c,u,d=10;for(l<o&&(u=o,o=l,l=u,u=i,i=s,s=u);d-- >0;){if(u=iR(o,l,n),u===c)return r[i]=o,r[s]=l,e(r);if(u>0)o=Math.floor(o/u)*u,l=Math.ceil(l/u)*u;else if(u<0)o=Math.ceil(o*u)/u,l=Math.floor(l*u)/u;else break;c=u}return t},t}function pQ(){var t=W4();return t.copy=function(){return ev(t,pQ())},hl.apply(t,arguments),Ih(t)}function gQ(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,IS),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return gQ(t).unknown(e)},t=arguments.length?Array.from(t,IS):[0,1],Ih(n)}function xQ(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],s=t[r],o;return s<i&&(o=n,n=r,r=o,o=i,i=s,s=o),t[n]=e.floor(i),t[r]=e.ceil(s),t}function yV(t){return Math.log(t)}function vV(t){return Math.exp(t)}function qje(t){return-Math.log(-t)}function Wje(t){return-Math.exp(-t)}function Kje(t){return isFinite(t)?+("1e"+t):t<0?0:t}function Xje(t){return t===10?Kje:t===Math.E?Math.exp:e=>Math.pow(t,e)}function Yje(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 _V(t){return(e,n)=>-t(-e,n)}function Y4(t){const e=t(yV,vV),n=e.domain;let r=10,i,s;function o(){return i=Yje(r),s=Xje(r),n()[0]<0?(i=_V(i),s=_V(s),t(qje,Wje)):t(yV,vV),e}return e.base=function(l){return arguments.length?(r=+l,o()):r},e.domain=function(l){return arguments.length?(n(l),o()):n()},e.ticks=l=>{const c=n();let u=c[0],d=c[c.length-1];const f=d<u;f&&([u,d]=[d,u]);let m=i(u),p=i(d),x,b;const y=l==null?10:+l;let v=[];if(!(r%1)&&p-m<y){if(m=Math.floor(m),p=Math.ceil(p),u>0){for(;m<=p;++m)for(x=1;x<r;++x)if(b=m<0?x/s(-m):x*s(m),!(b<u)){if(b>d)break;v.push(b)}}else for(;m<=p;++m)for(x=r-1;x>=1;--x)if(b=m>0?x/s(-m):x*s(m),!(b<u)){if(b>d)break;v.push(b)}v.length*2<y&&(v=rR(u,d,y))}else v=rR(m,p,Math.min(p-m,y)).map(s);return f?v.reverse():v},e.tickFormat=(l,c)=>{if(l==null&&(l=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=gy(c)).precision==null&&(c.trim=!0),c=X4(c)),l===1/0)return c;const u=Math.max(1,r*l/e.ticks().length);return d=>{let f=d/s(Math.round(i(d)));return f*r<r-.5&&(f*=r),f<=u?c(d):""}},e.nice=()=>n(xQ(n(),{floor:l=>s(Math.floor(i(l))),ceil:l=>s(Math.ceil(i(l)))})),e}function bQ(){const t=Y4(QN()).domain([1,10]);return t.copy=()=>ev(t,bQ()).base(t.base()),hl.apply(t,arguments),t}function wV(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function SV(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function Q4(t){var e=1,n=t(wV(e),SV(e));return n.constant=function(r){return arguments.length?t(wV(e=+r),SV(e)):e},Ih(n)}function yQ(){var t=Q4(QN());return t.copy=function(){return ev(t,yQ()).constant(t.constant())},hl.apply(t,arguments)}function NV(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function Qje(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function Zje(t){return t<0?-t*t:t*t}function Z4(t){var e=t(ps,ps),n=1;function r(){return n===1?t(ps,ps):n===.5?t(Qje,Zje):t(NV(n),NV(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},Ih(e)}function J4(){var t=Z4(QN());return t.copy=function(){return ev(t,J4()).exponent(t.exponent())},hl.apply(t,arguments),t}function Jje(){return J4.apply(null,arguments).exponent(.5)}function MV(t){return Math.sign(t)*t*t}function e3e(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function vQ(){var t=W4(),e=[0,1],n=!1,r;function i(s){var o=e3e(t(s));return isNaN(o)?r:n?Math.round(o):o}return i.invert=function(s){return t.invert(MV(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,IS)).map(MV)),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 vQ(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},hl.apply(i,arguments),Ih(i)}function _Q(){var t=[],e=[],n=[],r;function i(){var o=0,l=Math.max(1,e.length);for(n=new Array(l-1);++o<l;)n[o-1]=ije(t,o/l);return s}function s(o){return o==null||isNaN(o=+o)?r:e[Zy(n,o)]}return s.invertExtent=function(o){var l=e.indexOf(o);return l<0?[NaN,NaN]:[l>0?n[l-1]:t[0],l<n.length?n[l]:t[t.length-1]]},s.domain=function(o){if(!arguments.length)return t.slice();t=[];for(let l of o)l!=null&&!isNaN(l=+l)&&t.push(l);return t.sort(dh),i()},s.range=function(o){return arguments.length?(e=Array.from(o),i()):e.slice()},s.unknown=function(o){return arguments.length?(r=o,s):r},s.quantiles=function(){return n.slice()},s.copy=function(){return _Q().domain(t).range(e).unknown(r)},hl.apply(s,arguments)}function wQ(){var t=0,e=1,n=1,r=[.5],i=[0,1],s;function o(c){return c!=null&&c<=c?i[Zy(r,c,0,n)]:s}function l(){var c=-1;for(r=new Array(n);++c<n;)r[c]=((c+1)*e-(c-n)*t)/(n+1);return o}return o.domain=function(c){return arguments.length?([t,e]=c,t=+t,e=+e,l()):[t,e]},o.range=function(c){return arguments.length?(n=(i=Array.from(c)).length-1,l()):i.slice()},o.invertExtent=function(c){var u=i.indexOf(c);return u<0?[NaN,NaN]:u<1?[t,r[0]]:u>=n?[r[n-1],e]:[r[u-1],r[u]]},o.unknown=function(c){return arguments.length&&(s=c),o},o.thresholds=function(){return r.slice()},o.copy=function(){return wQ().domain([t,e]).range(i).unknown(s)},hl.apply(Ih(o),arguments)}function SQ(){var t=[.5],e=[0,1],n,r=1;function i(s){return s!=null&&s<=s?e[Zy(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 o=e.indexOf(s);return[t[o-1],t[o]]},i.unknown=function(s){return arguments.length?(n=s,i):n},i.copy=function(){return SQ().domain(t).range(e).unknown(n)},hl.apply(i,arguments)}const Lk=new Date,Ik=new Date;function ta(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 o=i(s),l=i.ceil(s);return s-o<l-s?o:l},i.offset=(s,o)=>(e(s=new Date(+s),o==null?1:Math.floor(o)),s),i.range=(s,o,l)=>{const c=[];if(s=i.ceil(s),l=l==null?1:Math.floor(l),!(s<o)||!(l>0))return c;let u;do c.push(u=new Date(+s)),e(s,l),t(s);while(u<s&&s<o);return c},i.filter=s=>ta(o=>{if(o>=o)for(;t(o),!s(o);)o.setTime(o-1)},(o,l)=>{if(o>=o)if(l<0)for(;++l<=0;)for(;e(o,-1),!s(o););else for(;--l>=0;)for(;e(o,1),!s(o););}),n&&(i.count=(s,o)=>(Lk.setTime(+s),Ik.setTime(+o),t(Lk),t(Ik),Math.floor(n(Lk,Ik))),i.every=s=>(s=Math.floor(s),!isFinite(s)||!(s>0)?null:s>1?i.filter(r?o=>r(o)%s===0:o=>i.count(0,o)%s===0):i)),i}const US=ta(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);US.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?ta(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):US);US.range;const vu=1e3,Jo=vu*60,_u=Jo*60,Uu=_u*24,eO=Uu*7,EV=Uu*30,Fk=Uu*365,Df=ta(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*vu)},(t,e)=>(e-t)/vu,t=>t.getUTCSeconds());Df.range;const tO=ta(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*vu)},(t,e)=>{t.setTime(+t+e*Jo)},(t,e)=>(e-t)/Jo,t=>t.getMinutes());tO.range;const nO=ta(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*Jo)},(t,e)=>(e-t)/Jo,t=>t.getUTCMinutes());nO.range;const rO=ta(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*vu-t.getMinutes()*Jo)},(t,e)=>{t.setTime(+t+e*_u)},(t,e)=>(e-t)/_u,t=>t.getHours());rO.range;const iO=ta(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*_u)},(t,e)=>(e-t)/_u,t=>t.getUTCHours());iO.range;const tv=ta(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Jo)/Uu,t=>t.getDate()-1);tv.range;const ZN=ta(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Uu,t=>t.getUTCDate()-1);ZN.range;const NQ=ta(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Uu,t=>Math.floor(t/Uu));NQ.range;function Am(t){return ta(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())*Jo)/eO)}const JN=Am(0),zS=Am(1),t3e=Am(2),n3e=Am(3),ix=Am(4),r3e=Am(5),i3e=Am(6);JN.range;zS.range;t3e.range;n3e.range;ix.range;r3e.range;i3e.range;function km(t){return ta(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)/eO)}const eM=km(0),BS=km(1),a3e=km(2),s3e=km(3),ax=km(4),o3e=km(5),l3e=km(6);eM.range;BS.range;a3e.range;s3e.range;ax.range;o3e.range;l3e.range;const aO=ta(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());aO.range;const sO=ta(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());sO.range;const zu=ta(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());zu.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:ta(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)});zu.range;const Bu=ta(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());Bu.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:ta(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)});Bu.range;function MQ(t,e,n,r,i,s){const o=[[Df,1,vu],[Df,5,5*vu],[Df,15,15*vu],[Df,30,30*vu],[s,1,Jo],[s,5,5*Jo],[s,15,15*Jo],[s,30,30*Jo],[i,1,_u],[i,3,3*_u],[i,6,6*_u],[i,12,12*_u],[r,1,Uu],[r,2,2*Uu],[n,1,eO],[e,1,EV],[e,3,3*EV],[t,1,Fk]];function l(u,d,f){const m=d<u;m&&([u,d]=[d,u]);const p=f&&typeof f.range=="function"?f:c(u,d,f),x=p?p.range(u,+d+1):[];return m?x.reverse():x}function c(u,d,f){const m=Math.abs(d-u)/f,p=B4(([,,y])=>y).right(o,m);if(p===o.length)return t.every(aR(u/Fk,d/Fk,f));if(p===0)return US.every(Math.max(aR(u,d,f),1));const[x,b]=o[m/o[p-1][2]<o[p][2]/m?p-1:p];return x.every(b)}return[l,c]}const[c3e,u3e]=MQ(Bu,sO,eM,NQ,iO,nO),[d3e,h3e]=MQ(zu,aO,JN,tv,rO,tO);function Uk(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 zk(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 Yb(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function f3e(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,s=t.days,o=t.shortDays,l=t.months,c=t.shortMonths,u=Qb(i),d=Zb(i),f=Qb(s),m=Zb(s),p=Qb(o),x=Zb(o),b=Qb(l),y=Zb(l),v=Qb(c),S=Zb(c),N={a:q,A:Y,b:Z,B:oe,c:null,d:PV,e:PV,f:L3e,g:q3e,G:K3e,H:R3e,I:D3e,j:O3e,L:EQ,m:I3e,M:F3e,p:B,q:W,Q:OV,s:LV,S:U3e,u:z3e,U:B3e,V:$3e,w:H3e,W:V3e,x:null,X:null,y:G3e,Y:W3e,Z:X3e,"%":DV},C={a:se,A:ne,b:ce,B:fe,c:null,d:RV,e:RV,f:J3e,g:cPe,G:dPe,H:Y3e,I:Q3e,j:Z3e,L:TQ,m:ePe,M:tPe,p:ye,q:ge,Q:OV,s:LV,S:nPe,u:rPe,U:iPe,V:aPe,w:sPe,W:oPe,x:null,X:null,y:lPe,Y:uPe,Z:hPe,"%":DV},T={a:R,A:F,b:O,B:H,c:j,d:kV,e:kV,f:A3e,g:AV,G:TV,H:jV,I:jV,j:M3e,L:T3e,m:N3e,M:E3e,p:A,q:S3e,Q:j3e,s:P3e,S:C3e,u:b3e,U:y3e,V:v3e,w:x3e,W:_3e,x:G,X:$,y:AV,Y:TV,Z:w3e,"%":k3e};N.x=k(n,N),N.X=k(r,N),N.c=k(e,N),C.x=k(n,C),C.X=k(r,C),C.c=k(e,C);function k(xe,Pe){return function(Ue){var be=[],it=-1,U=0,K=xe.length,J,Q,z;for(Ue instanceof Date||(Ue=new Date(+Ue));++it<K;)xe.charCodeAt(it)===37&&(be.push(xe.slice(U,it)),(Q=CV[J=xe.charAt(++it)])!=null?J=xe.charAt(++it):Q=J==="e"?" ":"0",(z=Pe[J])&&(J=z(Ue,Q)),be.push(J),U=it+1);return be.push(xe.slice(U,it)),be.join("")}}function E(xe,Pe){return function(Ue){var be=Yb(1900,void 0,1),it=D(be,xe,Ue+="",0),U,K;if(it!=Ue.length)return null;if("Q"in be)return new Date(be.Q);if("s"in be)return new Date(be.s*1e3+("L"in be?be.L:0));if(Pe&&!("Z"in be)&&(be.Z=0),"p"in be&&(be.H=be.H%12+be.p*12),be.m===void 0&&(be.m="q"in be?be.q:0),"V"in be){if(be.V<1||be.V>53)return null;"w"in be||(be.w=1),"Z"in be?(U=zk(Yb(be.y,0,1)),K=U.getUTCDay(),U=K>4||K===0?BS.ceil(U):BS(U),U=ZN.offset(U,(be.V-1)*7),be.y=U.getUTCFullYear(),be.m=U.getUTCMonth(),be.d=U.getUTCDate()+(be.w+6)%7):(U=Uk(Yb(be.y,0,1)),K=U.getDay(),U=K>4||K===0?zS.ceil(U):zS(U),U=tv.offset(U,(be.V-1)*7),be.y=U.getFullYear(),be.m=U.getMonth(),be.d=U.getDate()+(be.w+6)%7)}else("W"in be||"U"in be)&&("w"in be||(be.w="u"in be?be.u%7:"W"in be?1:0),K="Z"in be?zk(Yb(be.y,0,1)).getUTCDay():Uk(Yb(be.y,0,1)).getDay(),be.m=0,be.d="W"in be?(be.w+6)%7+be.W*7-(K+5)%7:be.w+be.U*7-(K+6)%7);return"Z"in be?(be.H+=be.Z/100|0,be.M+=be.Z%100,zk(be)):Uk(be)}}function D(xe,Pe,Ue,be){for(var it=0,U=Pe.length,K=Ue.length,J,Q;it<U;){if(be>=K)return-1;if(J=Pe.charCodeAt(it++),J===37){if(J=Pe.charAt(it++),Q=T[J in CV?Pe.charAt(it++):J],!Q||(be=Q(xe,Ue,be))<0)return-1}else if(J!=Ue.charCodeAt(be++))return-1}return be}function A(xe,Pe,Ue){var be=u.exec(Pe.slice(Ue));return be?(xe.p=d.get(be[0].toLowerCase()),Ue+be[0].length):-1}function R(xe,Pe,Ue){var be=p.exec(Pe.slice(Ue));return be?(xe.w=x.get(be[0].toLowerCase()),Ue+be[0].length):-1}function F(xe,Pe,Ue){var be=f.exec(Pe.slice(Ue));return be?(xe.w=m.get(be[0].toLowerCase()),Ue+be[0].length):-1}function O(xe,Pe,Ue){var be=v.exec(Pe.slice(Ue));return be?(xe.m=S.get(be[0].toLowerCase()),Ue+be[0].length):-1}function H(xe,Pe,Ue){var be=b.exec(Pe.slice(Ue));return be?(xe.m=y.get(be[0].toLowerCase()),Ue+be[0].length):-1}function j(xe,Pe,Ue){return D(xe,e,Pe,Ue)}function G(xe,Pe,Ue){return D(xe,n,Pe,Ue)}function $(xe,Pe,Ue){return D(xe,r,Pe,Ue)}function q(xe){return o[xe.getDay()]}function Y(xe){return s[xe.getDay()]}function Z(xe){return c[xe.getMonth()]}function oe(xe){return l[xe.getMonth()]}function B(xe){return i[+(xe.getHours()>=12)]}function W(xe){return 1+~~(xe.getMonth()/3)}function se(xe){return o[xe.getUTCDay()]}function ne(xe){return s[xe.getUTCDay()]}function ce(xe){return c[xe.getUTCMonth()]}function fe(xe){return l[xe.getUTCMonth()]}function ye(xe){return i[+(xe.getUTCHours()>=12)]}function ge(xe){return 1+~~(xe.getUTCMonth()/3)}return{format:function(xe){var Pe=k(xe+="",N);return Pe.toString=function(){return xe},Pe},parse:function(xe){var Pe=E(xe+="",!1);return Pe.toString=function(){return xe},Pe},utcFormat:function(xe){var Pe=k(xe+="",C);return Pe.toString=function(){return xe},Pe},utcParse:function(xe){var Pe=E(xe+="",!0);return Pe.toString=function(){return xe},Pe}}}var CV={"-":"",_:" ",0:"0"},va=/^\s*\d+/,m3e=/^%/,p3e=/[\\^$*+?|[\]().{}]/g;function sr(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 g3e(t){return t.replace(p3e,"\\$&")}function Qb(t){return new RegExp("^(?:"+t.map(g3e).join("|")+")","i")}function Zb(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function x3e(t,e,n){var r=va.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function b3e(t,e,n){var r=va.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function y3e(t,e,n){var r=va.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function v3e(t,e,n){var r=va.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function _3e(t,e,n){var r=va.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function TV(t,e,n){var r=va.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function AV(t,e,n){var r=va.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function w3e(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 S3e(t,e,n){var r=va.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function N3e(t,e,n){var r=va.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function kV(t,e,n){var r=va.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function M3e(t,e,n){var r=va.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function jV(t,e,n){var r=va.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function E3e(t,e,n){var r=va.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function C3e(t,e,n){var r=va.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function T3e(t,e,n){var r=va.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function A3e(t,e,n){var r=va.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function k3e(t,e,n){var r=m3e.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function j3e(t,e,n){var r=va.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function P3e(t,e,n){var r=va.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function PV(t,e){return sr(t.getDate(),e,2)}function R3e(t,e){return sr(t.getHours(),e,2)}function D3e(t,e){return sr(t.getHours()%12||12,e,2)}function O3e(t,e){return sr(1+tv.count(zu(t),t),e,3)}function EQ(t,e){return sr(t.getMilliseconds(),e,3)}function L3e(t,e){return EQ(t,e)+"000"}function I3e(t,e){return sr(t.getMonth()+1,e,2)}function F3e(t,e){return sr(t.getMinutes(),e,2)}function U3e(t,e){return sr(t.getSeconds(),e,2)}function z3e(t){var e=t.getDay();return e===0?7:e}function B3e(t,e){return sr(JN.count(zu(t)-1,t),e,2)}function CQ(t){var e=t.getDay();return e>=4||e===0?ix(t):ix.ceil(t)}function $3e(t,e){return t=CQ(t),sr(ix.count(zu(t),t)+(zu(t).getDay()===4),e,2)}function H3e(t){return t.getDay()}function V3e(t,e){return sr(zS.count(zu(t)-1,t),e,2)}function G3e(t,e){return sr(t.getFullYear()%100,e,2)}function q3e(t,e){return t=CQ(t),sr(t.getFullYear()%100,e,2)}function W3e(t,e){return sr(t.getFullYear()%1e4,e,4)}function K3e(t,e){var n=t.getDay();return t=n>=4||n===0?ix(t):ix.ceil(t),sr(t.getFullYear()%1e4,e,4)}function X3e(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+sr(e/60|0,"0",2)+sr(e%60,"0",2)}function RV(t,e){return sr(t.getUTCDate(),e,2)}function Y3e(t,e){return sr(t.getUTCHours(),e,2)}function Q3e(t,e){return sr(t.getUTCHours()%12||12,e,2)}function Z3e(t,e){return sr(1+ZN.count(Bu(t),t),e,3)}function TQ(t,e){return sr(t.getUTCMilliseconds(),e,3)}function J3e(t,e){return TQ(t,e)+"000"}function ePe(t,e){return sr(t.getUTCMonth()+1,e,2)}function tPe(t,e){return sr(t.getUTCMinutes(),e,2)}function nPe(t,e){return sr(t.getUTCSeconds(),e,2)}function rPe(t){var e=t.getUTCDay();return e===0?7:e}function iPe(t,e){return sr(eM.count(Bu(t)-1,t),e,2)}function AQ(t){var e=t.getUTCDay();return e>=4||e===0?ax(t):ax.ceil(t)}function aPe(t,e){return t=AQ(t),sr(ax.count(Bu(t),t)+(Bu(t).getUTCDay()===4),e,2)}function sPe(t){return t.getUTCDay()}function oPe(t,e){return sr(BS.count(Bu(t)-1,t),e,2)}function lPe(t,e){return sr(t.getUTCFullYear()%100,e,2)}function cPe(t,e){return t=AQ(t),sr(t.getUTCFullYear()%100,e,2)}function uPe(t,e){return sr(t.getUTCFullYear()%1e4,e,4)}function dPe(t,e){var n=t.getUTCDay();return t=n>=4||n===0?ax(t):ax.ceil(t),sr(t.getUTCFullYear()%1e4,e,4)}function hPe(){return"+0000"}function DV(){return"%"}function OV(t){return+t}function LV(t){return Math.floor(+t/1e3)}var Xp,kQ,jQ;fPe({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 fPe(t){return Xp=f3e(t),kQ=Xp.format,Xp.parse,jQ=Xp.utcFormat,Xp.utcParse,Xp}function mPe(t){return new Date(t)}function pPe(t){return t instanceof Date?+t:+new Date(+t)}function oO(t,e,n,r,i,s,o,l,c,u){var d=W4(),f=d.invert,m=d.domain,p=u(".%L"),x=u(":%S"),b=u("%I:%M"),y=u("%I %p"),v=u("%a %d"),S=u("%b %d"),N=u("%B"),C=u("%Y");function T(k){return(c(k)<k?p:l(k)<k?x:o(k)<k?b:s(k)<k?y:r(k)<k?i(k)<k?v:S:n(k)<k?N:C)(k)}return d.invert=function(k){return new Date(f(k))},d.domain=function(k){return arguments.length?m(Array.from(k,pPe)):m().map(mPe)},d.ticks=function(k){var E=m();return t(E[0],E[E.length-1],k??10)},d.tickFormat=function(k,E){return E==null?T:u(E)},d.nice=function(k){var E=m();return(!k||typeof k.range!="function")&&(k=e(E[0],E[E.length-1],k??10)),k?m(xQ(E,k)):d},d.copy=function(){return ev(d,oO(t,e,n,r,i,s,o,l,c,u))},d}function gPe(){return hl.apply(oO(d3e,h3e,zu,aO,JN,tv,rO,tO,Df,kQ).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function xPe(){return hl.apply(oO(c3e,u3e,Bu,sO,eM,ZN,iO,nO,Df,jQ).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function tM(){var t=0,e=1,n,r,i,s,o=ps,l=!1,c;function u(f){return f==null||isNaN(f=+f)?c:o(i===0?.5:(f=(s(f)-n)*i,l?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?(l=!!f,u):l},u.interpolator=function(f){return arguments.length?(o=f,u):o};function d(f){return function(m){var p,x;return arguments.length?([p,x]=m,o=f(p,x),u):[o(0),o(1)]}}return u.range=d(Cx),u.rangeRound=d(q4),u.unknown=function(f){return arguments.length?(c=f,u):c},function(f){return s=f,n=f(t),r=f(e),i=n===r?0:1/(r-n),u}}function Fh(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function PQ(){var t=Ih(tM()(ps));return t.copy=function(){return Fh(t,PQ())},Wu.apply(t,arguments)}function RQ(){var t=Y4(tM()).domain([1,10]);return t.copy=function(){return Fh(t,RQ()).base(t.base())},Wu.apply(t,arguments)}function DQ(){var t=Q4(tM());return t.copy=function(){return Fh(t,DQ()).constant(t.constant())},Wu.apply(t,arguments)}function lO(){var t=Z4(tM());return t.copy=function(){return Fh(t,lO()).exponent(t.exponent())},Wu.apply(t,arguments)}function bPe(){return lO.apply(null,arguments).exponent(.5)}function OQ(){var t=[],e=ps;function n(r){if(r!=null&&!isNaN(r=+r))return e((Zy(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(dh),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)=>rje(t,s/r))},n.copy=function(){return OQ(e).domain(t)},Wu.apply(n,arguments)}function nM(){var t=0,e=.5,n=1,r=1,i,s,o,l,c,u=ps,d,f=!1,m;function p(b){return isNaN(b=+b)?m:(b=.5+((b=+d(b))-s)*(r*b<r*s?l:c),u(f?Math.max(0,Math.min(1,b)):b))}p.domain=function(b){return arguments.length?([t,e,n]=b,i=d(t=+t),s=d(e=+e),o=d(n=+n),l=i===s?0:.5/(s-i),c=s===o?0:.5/(o-s),r=s<i?-1:1,p):[t,e,n]},p.clamp=function(b){return arguments.length?(f=!!b,p):f},p.interpolator=function(b){return arguments.length?(u=b,p):u};function x(b){return function(y){var v,S,N;return arguments.length?([v,S,N]=y,u=kje(b,[v,S,N]),p):[u(0),u(.5),u(1)]}}return p.range=x(Cx),p.rangeRound=x(q4),p.unknown=function(b){return arguments.length?(m=b,p):m},function(b){return d=b,i=b(t),s=b(e),o=b(n),l=i===s?0:.5/(s-i),c=s===o?0:.5/(o-s),r=s<i?-1:1,p}}function LQ(){var t=Ih(nM()(ps));return t.copy=function(){return Fh(t,LQ())},Wu.apply(t,arguments)}function IQ(){var t=Y4(nM()).domain([.1,1,10]);return t.copy=function(){return Fh(t,IQ()).base(t.base())},Wu.apply(t,arguments)}function FQ(){var t=Q4(nM());return t.copy=function(){return Fh(t,FQ()).constant(t.constant())},Wu.apply(t,arguments)}function cO(){var t=Z4(nM());return t.copy=function(){return Fh(t,cO()).exponent(t.exponent())},Wu.apply(t,arguments)}function yPe(){return cO.apply(null,arguments).exponent(.5)}const c0=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:H4,scaleDiverging:LQ,scaleDivergingLog:IQ,scaleDivergingPow:cO,scaleDivergingSqrt:yPe,scaleDivergingSymlog:FQ,scaleIdentity:gQ,scaleImplicit:sR,scaleLinear:pQ,scaleLog:bQ,scaleOrdinal:$4,scalePoint:sje,scalePow:J4,scaleQuantile:_Q,scaleQuantize:wQ,scaleRadial:vQ,scaleSequential:PQ,scaleSequentialLog:RQ,scaleSequentialPow:lO,scaleSequentialQuantile:OQ,scaleSequentialSqrt:bPe,scaleSequentialSymlog:DQ,scaleSqrt:Jje,scaleSymlog:yQ,scaleThreshold:SQ,scaleTime:gPe,scaleUtc:xPe,tickFormat:mQ},Symbol.toStringTag,{value:"Module"}));var Uh=t=>t.chartData,uO=et([Uh],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),nv=(t,e,n,r)=>r?uO(t):Uh(t);function Eh(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(xr(e)&&xr(n))return!0}return!1}function IV(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function UQ(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,s;if(xr(n))i=n;else if(typeof n=="function")return;if(xr(r))s=r;else if(typeof r=="function")return;var o=[i,s];if(Eh(o))return o}}function vPe(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(Eh(r))return IV(r,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[i,s]=t,o,l;if(i==="auto")e!=null&&(o=Math.min(...e));else if(Bt(i))o=i;else if(typeof i=="function")try{e!=null&&(o=i(e?.[0]))}catch{}else if(typeof i=="string"&&dH.test(i)){var c=dH.exec(i);if(c==null||e==null)o=void 0;else{var u=+c[1];o=e[0]-u}}else o=e?.[0];if(s==="auto")e!=null&&(l=Math.max(...e));else if(Bt(s))l=s;else if(typeof s=="function")try{e!=null&&(l=s(e?.[1]))}catch{}else if(typeof s=="string"&&hH.test(s)){var d=hH.exec(s);if(d==null||e==null)l=void 0;else{var f=+d[1];l=e[1]+f}}else l=e?.[1];var m=[o,l];if(Eh(m))return e==null?m:IV(m,e,n)}}}var Tx=1e9,_Pe={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},hO,Qr=!0,cl="[DecimalError] ",Wf=cl+"Invalid argument: ",dO=cl+"Exponent out of range: ",Ax=Math.floor,Sf=Math.pow,wPe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,co,ha=1e7,Vr=7,zQ=9007199254740991,$S=Ax(zQ/Vr),Vt={};Vt.absoluteValue=Vt.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};Vt.comparedTo=Vt.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};Vt.decimalPlaces=Vt.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*Vr;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};Vt.dividedBy=Vt.div=function(t){return Tu(this,new this.constructor(t))};Vt.dividedToIntegerBy=Vt.idiv=function(t){var e=this,n=e.constructor;return Dr(Tu(e,new n(t),0,1),n.precision)};Vt.equals=Vt.eq=function(t){return!this.cmp(t)};Vt.exponent=function(){return Ui(this)};Vt.greaterThan=Vt.gt=function(t){return this.cmp(t)>0};Vt.greaterThanOrEqualTo=Vt.gte=function(t){return this.cmp(t)>=0};Vt.isInteger=Vt.isint=function(){return this.e>this.d.length-2};Vt.isNegative=Vt.isneg=function(){return this.s<0};Vt.isPositive=Vt.ispos=function(){return this.s>0};Vt.isZero=function(){return this.s===0};Vt.lessThan=Vt.lt=function(t){return this.cmp(t)<0};Vt.lessThanOrEqualTo=Vt.lte=function(t){return this.cmp(t)<1};Vt.logarithm=Vt.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(co))throw Error(cl+"NaN");if(n.s<1)throw Error(cl+(n.s?"NaN":"-Infinity"));return n.eq(co)?new r(0):(Qr=!1,e=Tu(xy(n,s),xy(t,s),s),Qr=!0,Dr(e,i))};Vt.minus=Vt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?HQ(e,t):BQ(e,(t.s=-t.s,t))};Vt.modulo=Vt.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(cl+"NaN");return n.s?(Qr=!1,e=Tu(n,t,0,1).times(t),Qr=!0,n.minus(e)):Dr(new r(n),i)};Vt.naturalExponential=Vt.exp=function(){return $Q(this)};Vt.naturalLogarithm=Vt.ln=function(){return xy(this)};Vt.negated=Vt.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Vt.plus=Vt.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?BQ(e,t):HQ(e,(t.s=-t.s,t))};Vt.precision=Vt.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Wf+t);if(e=Ui(i)+1,r=i.d.length-1,n=r*Vr+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};Vt.squareRoot=Vt.sqrt=function(){var t,e,n,r,i,s,o,l=this,c=l.constructor;if(l.s<1){if(!l.s)return new c(0);throw Error(cl+"NaN")}for(t=Ui(l),Qr=!1,i=Math.sqrt(+l),i==0||i==1/0?(e=uc(l.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=Ax((t+1)/2)-(t<0||t%2),i==1/0?e="5e"+t:(e=i.toExponential(),e=e.slice(0,e.indexOf("e")+1)+t),r=new c(e)):r=new c(i.toString()),n=c.precision,i=o=n+3;;)if(s=r,r=s.plus(Tu(l,s,o+2)).times(.5),uc(s.d).slice(0,o)===(e=uc(r.d)).slice(0,o)){if(e=e.slice(o-3,o+1),i==o&&e=="4999"){if(Dr(s,n+1,0),s.times(s).eq(l)){r=s;break}}else if(e!="9999")break;o+=4}return Qr=!0,Dr(r,n)};Vt.times=Vt.mul=function(t){var e,n,r,i,s,o,l,c,u,d=this,f=d.constructor,m=d.d,p=(t=new f(t)).d;if(!d.s||!t.s)return new f(0);for(t.s*=d.s,n=d.e+t.e,c=m.length,u=p.length,c<u&&(s=m,m=p,p=s,o=c,c=u,u=o),s=[],o=c+u,r=o;r--;)s.push(0);for(r=u;--r>=0;){for(e=0,i=c+r;i>r;)l=s[i]+p[r]*m[i-r-1]+e,s[i--]=l%ha|0,e=l/ha|0;s[i]=(s[i]+e)%ha|0}for(;!s[--o];)s.pop();return e?++n:s.shift(),t.d=s,t.e=n,Qr?Dr(t,f.precision):t};Vt.toDecimalPlaces=Vt.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(bc(t,0,Tx),e===void 0?e=r.rounding:bc(e,0,8),Dr(n,t+Ui(n)+1,e))};Vt.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=xm(r,!0):(bc(t,0,Tx),e===void 0?e=i.rounding:bc(e,0,8),r=Dr(new i(r),t+1,e),n=xm(r,!0,t+1)),n};Vt.toFixed=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?xm(i):(bc(t,0,Tx),e===void 0?e=s.rounding:bc(e,0,8),r=Dr(new s(i),t+Ui(i)+1,e),n=xm(r.abs(),!1,t+Ui(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};Vt.toInteger=Vt.toint=function(){var t=this,e=t.constructor;return Dr(new e(t),Ui(t)+1,e.rounding)};Vt.toNumber=function(){return+this};Vt.toPower=Vt.pow=function(t){var e,n,r,i,s,o,l=this,c=l.constructor,u=12,d=+(t=new c(t));if(!t.s)return new c(co);if(l=new c(l),!l.s){if(t.s<1)throw Error(cl+"Infinity");return l}if(l.eq(co))return l;if(r=c.precision,t.eq(co))return Dr(l,r);if(e=t.e,n=t.d.length-1,o=e>=n,s=l.s,o){if((n=d<0?-d:d)<=zQ){for(i=new c(co),e=Math.ceil(r/Vr+4),Qr=!1;n%2&&(i=i.times(l),UV(i.d,e)),n=Ax(n/2),n!==0;)l=l.times(l),UV(l.d,e);return Qr=!0,t.s<0?new c(co).div(i):Dr(i,r)}}else if(s<0)throw Error(cl+"NaN");return s=s<0&&t.d[Math.max(e,n)]&1?-1:1,l.s=1,Qr=!1,i=t.times(xy(l,r+u)),Qr=!0,i=$Q(i),i.s=s,i};Vt.toPrecision=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?(n=Ui(i),r=xm(i,n<=s.toExpNeg||n>=s.toExpPos)):(bc(t,1,Tx),e===void 0?e=s.rounding:bc(e,0,8),i=Dr(new s(i),t,e),n=Ui(i),r=xm(i,t<=n||n<=s.toExpNeg,t)),r};Vt.toSignificantDigits=Vt.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(bc(t,1,Tx),e===void 0?e=r.rounding:bc(e,0,8)),Dr(new r(n),t,e)};Vt.toString=Vt.valueOf=Vt.val=Vt.toJSON=Vt[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=Ui(t),n=t.constructor;return xm(t,e<=n.toExpNeg||e>=n.toExpPos)};function BQ(t,e){var n,r,i,s,o,l,c,u,d=t.constructor,f=d.precision;if(!t.s||!e.s)return e.s||(e=new d(t)),Qr?Dr(e,f):e;if(c=t.d,u=e.d,o=t.e,i=e.e,c=c.slice(),s=o-i,s){for(s<0?(r=c,s=-s,l=u.length):(r=u,i=o,l=c.length),o=Math.ceil(f/Vr),l=o>l?o+1:l+1,s>l&&(s=l,r.length=1),r.reverse();s--;)r.push(0);r.reverse()}for(l=c.length,s=u.length,l-s<0&&(s=l,r=u,u=c,c=r),n=0;s;)n=(c[--s]=c[s]+u[s]+n)/ha|0,c[s]%=ha;for(n&&(c.unshift(n),++i),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=i,Qr?Dr(e,f):e}function bc(t,e,n){if(t!==~~t||t<e||t>n)throw Error(Wf+t)}function uc(t){var e,n,r,i=t.length-1,s="",o=t[0];if(i>0){for(s+=o,e=1;e<i;e++)r=t[e]+"",n=Vr-r.length,n&&(s+=zd(n)),s+=r;o=t[e],r=o+"",n=Vr-r.length,n&&(s+=zd(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}var Tu=(function(){function t(r,i){var s,o=0,l=r.length;for(r=r.slice();l--;)s=r[l]*i+o,r[l]=s%ha|0,o=s/ha|0;return o&&r.unshift(o),r}function e(r,i,s,o){var l,c;if(s!=o)c=s>o?1:-1;else for(l=c=0;l<s;l++)if(r[l]!=i[l]){c=r[l]>i[l]?1:-1;break}return c}function n(r,i,s){for(var o=0;s--;)r[s]-=o,o=r[s]<i[s]?1:0,r[s]=o*ha+r[s]-i[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,s,o){var l,c,u,d,f,m,p,x,b,y,v,S,N,C,T,k,E,D,A=r.constructor,R=r.s==i.s?1:-1,F=r.d,O=i.d;if(!r.s)return new A(r);if(!i.s)throw Error(cl+"Division by zero");for(c=r.e-i.e,E=O.length,T=F.length,p=new A(R),x=p.d=[],u=0;O[u]==(F[u]||0);)++u;if(O[u]>(F[u]||0)&&--c,s==null?S=s=A.precision:o?S=s+(Ui(r)-Ui(i))+1:S=s,S<0)return new A(0);if(S=S/Vr+2|0,u=0,E==1)for(d=0,O=O[0],S++;(u<T||d)&&S--;u++)N=d*ha+(F[u]||0),x[u]=N/O|0,d=N%O|0;else{for(d=ha/(O[0]+1)|0,d>1&&(O=t(O,d),F=t(F,d),E=O.length,T=F.length),C=E,b=F.slice(0,E),y=b.length;y<E;)b[y++]=0;D=O.slice(),D.unshift(0),k=O[0],O[1]>=ha/2&&++k;do d=0,l=e(O,b,E,y),l<0?(v=b[0],E!=y&&(v=v*ha+(b[1]||0)),d=v/k|0,d>1?(d>=ha&&(d=ha-1),f=t(O,d),m=f.length,y=b.length,l=e(f,b,m,y),l==1&&(d--,n(f,E<m?D:O,m))):(d==0&&(l=d=1),f=O.slice()),m=f.length,m<y&&f.unshift(0),n(b,f,y),l==-1&&(y=b.length,l=e(O,b,E,y),l<1&&(d++,n(b,E<y?D:O,y))),y=b.length):l===0&&(d++,b=[0]),x[u++]=d,l&&b[0]?b[y++]=F[C]||0:(b=[F[C]],y=1);while((C++<T||b[0]!==void 0)&&S--)}return x[0]||x.shift(),p.e=c,Dr(p,o?s+Ui(p)+1:s)}})();function $Q(t,e){var n,r,i,s,o,l,c=0,u=0,d=t.constructor,f=d.precision;if(Ui(t)>16)throw Error(dO+Ui(t));if(!t.s)return new d(co);for(Qr=!1,l=f,o=new d(.03125);t.abs().gte(.1);)t=t.times(o),u+=5;for(r=Math.log(Sf(2,u))/Math.LN10*2+5|0,l+=r,n=i=s=new d(co),d.precision=l;;){if(i=Dr(i.times(t),l),n=n.times(++c),o=s.plus(Tu(i,n,l)),uc(o.d).slice(0,l)===uc(s.d).slice(0,l)){for(;u--;)s=Dr(s.times(s),l);return d.precision=f,e==null?(Qr=!0,Dr(s,f)):s}s=o}}function Ui(t){for(var e=t.e*Vr,n=t.d[0];n>=10;n/=10)e++;return e}function Bk(t,e,n){if(e>t.LN10.sd())throw Qr=!0,n&&(t.precision=n),Error(cl+"LN10 precision limit exceeded");return Dr(new t(t.LN10),e)}function zd(t){for(var e="";t--;)e+="0";return e}function xy(t,e){var n,r,i,s,o,l,c,u,d,f=1,m=10,p=t,x=p.d,b=p.constructor,y=b.precision;if(p.s<1)throw Error(cl+(p.s?"NaN":"-Infinity"));if(p.eq(co))return new b(0);if(e==null?(Qr=!1,u=y):u=e,p.eq(10))return e==null&&(Qr=!0),Bk(b,u);if(u+=m,b.precision=u,n=uc(x),r=n.charAt(0),s=Ui(p),Math.abs(s)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)p=p.times(t),n=uc(p.d),r=n.charAt(0),f++;s=Ui(p),r>1?(p=new b("0."+n),s++):p=new b(r+"."+n.slice(1))}else return c=Bk(b,u+2,y).times(s+""),p=xy(new b(r+"."+n.slice(1)),u-m).plus(c),b.precision=y,e==null?(Qr=!0,Dr(p,y)):p;for(l=o=p=Tu(p.minus(co),p.plus(co),u),d=Dr(p.times(p),u),i=3;;){if(o=Dr(o.times(d),u),c=l.plus(Tu(o,new b(i),u)),uc(c.d).slice(0,u)===uc(l.d).slice(0,u))return l=l.times(2),s!==0&&(l=l.plus(Bk(b,u+2,y).times(s+""))),l=Tu(l,new b(f),u),b.precision=y,e==null?(Qr=!0,Dr(l,y)):l;l=c,i+=2}}function FV(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=Ax(n/Vr),t.d=[],r=(n+1)%Vr,n<0&&(r+=Vr),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=Vr;r<i;)t.d.push(+e.slice(r,r+=Vr));e=e.slice(r),r=Vr-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),Qr&&(t.e>$S||t.e<-$S))throw Error(dO+n)}else t.s=0,t.e=0,t.d=[0];return t}function Dr(t,e,n){var r,i,s,o,l,c,u,d,f=t.d;for(o=1,s=f[0];s>=10;s/=10)o++;if(r=e-o,r<0)r+=Vr,i=e,u=f[d=0];else{if(d=Math.ceil((r+1)/Vr),s=f.length,d>=s)return t;for(u=s=f[d],o=1;s>=10;s/=10)o++;r%=Vr,i=r-Vr+o}if(n!==void 0&&(s=Sf(10,o-i-1),l=u/s%10|0,c=e<0||f[d+1]!==void 0||u%s,c=n<4?(l||c)&&(n==0||n==(t.s<0?3:2)):l>5||l==5&&(n==4||c||n==6&&(r>0?i>0?u/Sf(10,o-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return c?(s=Ui(t),f.length=1,e=e-s-1,f[0]=Sf(10,(Vr-e%Vr)%Vr),t.e=Ax(-e/Vr)||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=Sf(10,Vr-r),f[d]=i>0?(u/Sf(10,o-i)%Sf(10,i)|0)*s:0),c)for(;;)if(d==0){(f[0]+=s)==ha&&(f[0]=1,++t.e);break}else{if(f[d]+=s,f[d]!=ha)break;f[d--]=0,s=1}for(r=f.length;f[--r]===0;)f.pop();if(Qr&&(t.e>$S||t.e<-$S))throw Error(dO+Ui(t));return t}function HQ(t,e){var n,r,i,s,o,l,c,u,d,f,m=t.constructor,p=m.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new m(t),Qr?Dr(e,p):e;if(c=t.d,f=e.d,r=e.e,u=t.e,c=c.slice(),o=u-r,o){for(d=o<0,d?(n=c,o=-o,l=f.length):(n=f,r=u,l=c.length),i=Math.max(Math.ceil(p/Vr),l)+2,o>i&&(o=i,n.length=1),n.reverse(),i=o;i--;)n.push(0);n.reverse()}else{for(i=c.length,l=f.length,d=i<l,d&&(l=i),i=0;i<l;i++)if(c[i]!=f[i]){d=c[i]<f[i];break}o=0}for(d&&(n=c,c=f,f=n,e.s=-e.s),l=c.length,i=f.length-l;i>0;--i)c[l++]=0;for(i=f.length;i>o;){if(c[--i]<f[i]){for(s=i;s&&c[--s]===0;)c[s]=ha-1;--c[s],c[i]+=ha}c[i]-=f[i]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--r;return c[0]?(e.d=c,e.e=r,Qr?Dr(e,p):e):new m(0)}function xm(t,e,n){var r,i=Ui(t),s=uc(t.d),o=s.length;return e?(n&&(r=n-o)>0?s=s.charAt(0)+"."+s.slice(1)+zd(r):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(i<0?"e":"e+")+i):i<0?(s="0."+zd(-i-1)+s,n&&(r=n-o)>0&&(s+=zd(r))):i>=o?(s+=zd(i+1-o),n&&(r=n-i-1)>0&&(s=s+"."+zd(r))):((r=i+1)<o&&(s=s.slice(0,r)+"."+s.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(s+="."),s+=zd(r))),t.s<0?"-"+s:s}function UV(t,e){if(t.length>e)return t.length=e,!0}function VQ(t){var e,n,r;function i(s){var o=this;if(!(o instanceof i))return new i(s);if(o.constructor=i,s instanceof i){o.s=s.s,o.e=s.e,o.d=(s=s.d)?s.slice():s;return}if(typeof s=="number"){if(s*0!==0)throw Error(Wf+s);if(s>0)o.s=1;else if(s<0)s=-s,o.s=-1;else{o.s=0,o.e=0,o.d=[0];return}if(s===~~s&&s<1e7){o.e=0,o.d=[s];return}return FV(o,s.toString())}else if(typeof s!="string")throw Error(Wf+s);if(s.charCodeAt(0)===45?(s=s.slice(1),o.s=-1):o.s=1,wPe.test(s))FV(o,s);else throw Error(Wf+s)}if(i.prototype=Vt,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=VQ,i.config=i.set=SPe,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 SPe(t){if(!t||typeof t!="object")throw Error(cl+"Object expected");var e,n,r,i=["precision",1,Tx,"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(Ax(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(Wf+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Wf+n+": "+r);return this}var hO=VQ(_Pe);co=new hO(1);const pr=hO;var NPe=t=>t,GQ={},qQ=t=>t===GQ,zV=t=>function e(){return arguments.length===0||arguments.length===1&&qQ(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},WQ=(t,e)=>t===1?e:zV(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var s=r.filter(o=>o!==GQ).length;return s>=t?e(...r):WQ(t-s,zV(function(){for(var o=arguments.length,l=new Array(o),c=0;c<o;c++)l[c]=arguments[c];var u=r.map(d=>qQ(d)?l.shift():d);return e(...u,...l)}))}),MPe=t=>WQ(t.length,t),uR=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},EPe=MPe((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),CPe=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return NPe;var i=n.reverse(),s=i[0],o=i.slice(1);return function(){return o.reduce((l,c)=>c(l),s(...arguments))}},dR=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function KQ(t){var e;return t===0?e=1:e=Math.floor(new pr(t).abs().log(10).toNumber())+1,e}function XQ(t,e,n){for(var r=new pr(t),i=0,s=[];r.lt(e)&&i<1e5;)s.push(r.toNumber()),r=r.add(n),i++;return s}var YQ=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},QQ=(t,e,n)=>{if(t.lte(0))return new pr(0);var r=KQ(t.toNumber()),i=new pr(10).pow(r),s=t.div(i),o=r!==1?.05:.1,l=new pr(Math.ceil(s.div(o).toNumber())).add(n).mul(o),c=l.mul(i);return e?new pr(c.toNumber()):new pr(Math.ceil(c.toNumber()))},TPe=(t,e,n)=>{var r=new pr(1),i=new pr(t);if(!i.isint()&&n){var s=Math.abs(t);s<1?(r=new pr(10).pow(KQ(t)-1),i=new pr(Math.floor(i.div(r).toNumber())).mul(r)):s>1&&(i=new pr(Math.floor(t)))}else t===0?i=new pr(Math.floor((e-1)/2)):n||(i=new pr(Math.floor(t)));var o=Math.floor((e-1)/2),l=CPe(EPe(c=>i.add(new pr(c-o).mul(r)).toNumber()),uR);return l(0,e)},ZQ=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 pr(0),tickMin:new pr(0),tickMax:new pr(0)};var o=QQ(new pr(n).sub(e).div(r-1),i,s),l;e<=0&&n>=0?l=new pr(0):(l=new pr(e).add(n).div(2),l=l.sub(new pr(l).mod(o)));var c=Math.ceil(l.sub(e).div(o).toNumber()),u=Math.ceil(new pr(n).sub(l).div(o).toNumber()),d=c+u+1;return d>r?ZQ(e,n,r,i,s+1):(d<r&&(u=n>0?u+(r-d):u,c=n>0?c:c+(r-d)),{step:o,tickMin:l.sub(new pr(c).mul(o)),tickMax:l.add(new pr(u).mul(o))})},APe=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,o=Math.max(i,2),[l,c]=YQ([n,r]);if(l===-1/0||c===1/0){var u=c===1/0?[l,...uR(0,i-1).map(()=>1/0)]:[...uR(0,i-1).map(()=>-1/0),c];return n>r?dR(u):u}if(l===c)return TPe(l,i,s);var{step:d,tickMin:f,tickMax:m}=ZQ(l,c,o,s,0),p=XQ(f,m.add(new pr(.1).mul(d)),d);return n>r?dR(p):p},kPe=function(e,n){var[r,i]=e,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[o,l]=YQ([r,i]);if(o===-1/0||l===1/0)return[r,i];if(o===l)return[o];var c=Math.max(n,2),u=QQ(new pr(l).sub(o).div(c-1),s,0),d=[...XQ(new pr(o),new pr(l),u),l];return s===!1&&(d=d.map(f=>Math.round(f))),r>i?dR(d):d},JQ=t=>t.rootProps.maxBarSize,jPe=t=>t.rootProps.barGap,eZ=t=>t.rootProps.barCategoryGap,PPe=t=>t.rootProps.barSize,rv=t=>t.rootProps.stackOffset,tZ=t=>t.rootProps.reverseStackOrder,fO=t=>t.options.chartName,mO=t=>t.rootProps.syncId,nZ=t=>t.rootProps.syncMethod,pO=t=>t.options.eventEmitter,RPe=t=>t.rootProps.baseValue,mi={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},fu={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},oo={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},rM=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},DPe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:fu.angleAxisId,includeHidden:!1,name:void 0,reversed:fu.reversed,scale:fu.scale,tick:fu.tick,tickCount:void 0,ticks:void 0,type:fu.type,unit:void 0},OPe={allowDataOverflow:oo.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:oo.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:oo.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:oo.scale,tick:oo.tick,tickCount:oo.tickCount,ticks:void 0,type:oo.type,unit:void 0},LPe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:fu.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:fu.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:fu.scale,tick:fu.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},IPe={allowDataOverflow:oo.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:oo.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:oo.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:oo.scale,tick:oo.tick,tickCount:oo.tickCount,ticks:void 0,type:"category",unit:void 0},gO=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?LPe:DPe,xO=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?IPe:OPe,iM=t=>t.polarOptions,bO=et([Gu,qu,Ji],eQ),rZ=et([iM,bO],(t,e)=>{if(t!=null)return Za(t.innerRadius,e,0)}),iZ=et([iM,bO],(t,e)=>{if(t!=null)return Za(t.outerRadius,e,e*.8)}),FPe=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},aZ=et([iM],FPe);et([gO,aZ],rM);var sZ=et([bO,rZ,iZ],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});et([xO,sZ],rM);var oZ=et([zn,iM,rZ,iZ,Gu,qu],(t,e,n,r,i,s)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:o,cy:l,startAngle:c,endAngle:u}=e;return{cx:Za(o,i,i/2),cy:Za(l,s,s/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),Jr=(t,e)=>e,iv=(t,e,n)=>n;function aM(t){return t?.id}function lZ(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:s}=n,o=new Map;return t.forEach(l=>{var c,u=(c=l.data)!==null&&c!==void 0?c:r;if(!(u==null||u.length===0)){var d=aM(l);u.forEach((f,m)=>{var p=s==null||i?m:String(gr(f,s,null)),x=gr(f,l.dataKey,0),b;o.has(p)?b=o.get(p):b={},Object.assign(b,{[d]:x}),o.set(p,b)})}}),Array.from(o.values())}function sM(t){return t.stackId!=null&&t.dataKey!=null}var oM=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function lM(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function UPe(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 na=t=>{var e=zn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},kx=t=>t.tooltip.settings.axisId;function BV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function HS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?BV(Object(n),!0).forEach(function(r){zPe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):BV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function zPe(t,e,n){return(e=BPe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function BPe(t){var e=$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 hR=[0,"auto"],ua={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},cZ=(t,e)=>t.cartesianAxis.xAxis[e],Cc=(t,e)=>{var n=cZ(t,e);return n??ua},da={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:hR,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:Xy},uZ=(t,e)=>t.cartesianAxis.yAxis[e],Tc=(t,e)=>{var n=uZ(t,e);return n??da},HPe={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:""},yO=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??HPe},ii=(t,e,n)=>{switch(e){case"xAxis":return Cc(t,n);case"yAxis":return Tc(t,n);case"zAxis":return yO(t,n);case"angleAxis":return gO(t,n);case"radiusAxis":return xO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},VPe=(t,e,n)=>{switch(e){case"xAxis":return Cc(t,n);case"yAxis":return Tc(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},av=(t,e,n)=>{switch(e){case"xAxis":return Cc(t,n);case"yAxis":return Tc(t,n);case"angleAxis":return gO(t,n);case"radiusAxis":return xO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},dZ=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function vO(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 sv=t=>t.graphicalItems.cartesianItems,GPe=et([Jr,iv],vO),_O=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),ov=et([sv,ii,GPe],_O,{memoizeOptions:{resultEqualityCheck:lM}}),hZ=et([ov],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(sM)),fZ=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),qPe=et([ov],fZ),wO=t=>t.map(e=>e.data).filter(Boolean).flat(1),WPe=et([ov],wO,{memoizeOptions:{resultEqualityCheck:lM}}),SO=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},NO=et([WPe,nv],SO),MO=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:gr(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:gr(i,r)}))):t.map(r=>({value:r})),cM=et([NO,ii,ov],MO);function mZ(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function j1(t){if(ol(t)||t instanceof Date){var e=Number(t);if(xr(e))return e}}function $V(t){if(Array.isArray(t)){var e=[j1(t[0]),j1(t[1])];return Eh(e)?e:void 0}var n=j1(t);if(n!=null)return[n,n]}function $u(t){return t.map(j1).filter(VMe)}function KPe(t,e,n){return!n||typeof e!="number"||Gs(e)?[]:n.length?$u(n.flatMap(r=>{var i=gr(t,r.dataKey),s,o;if(Array.isArray(i)?[s,o]=i:s=o=i,!(!xr(s)||!xr(o)))return[e-s,e+o]})):[]}var ra=t=>{var e=na(t),n=kx(t);return av(t,e,n)},lv=et([ra],t=>t?.dataKey),XPe=et([hZ,nv,ra],lZ),pZ=(t,e,n,r)=>{var i={},s=e.reduce((o,l)=>(l.stackId==null||(o[l.stackId]==null&&(o[l.stackId]=[]),o[l.stackId].push(l)),o),i);return Object.fromEntries(Object.entries(s).map(o=>{var[l,c]=o,u=r?[...c].reverse():c,d=u.map(aM);return[l,{stackedData:mTe(t,d,n),graphicalItems:u}]}))},by=et([XPe,hZ,rv,tZ],pZ),gZ=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:s}=e;if(r==null&&n!=="zAxis"){var o=bTe(t,i,s);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},YPe=et([ii],t=>t.allowDataOverflow),EO=t=>{var e;if(t==null||!("domain"in t))return hR;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=$u(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:hR},CO=et([ii],EO),TO=et([CO,YPe],UQ),QPe=et([by,Uh,Jr,TO],gZ,{memoizeOptions:{resultEqualityCheck:oM}}),uM=t=>t.errorBars,ZPe=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>mZ(n,r)),VS=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(),o=Math.min(...s),l=Math.max(...s);return[o,l]}},AO=(t,e,n,r,i)=>{var s,o;if(n.length>0&&t.forEach(l=>{n.forEach(c=>{var u,d,f=(u=r[c.id])===null||u===void 0?void 0:u.filter(v=>mZ(i,v)),m=gr(l,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),p=KPe(l,m,f);if(p.length>=2){var x=Math.min(...p),b=Math.max(...p);(s==null||x<s)&&(s=x),(o==null||b>o)&&(o=b)}var y=$V(m);y!=null&&(s=s==null?y[0]:Math.min(s,y[0]),o=o==null?y[1]:Math.max(o,y[1]))})}),e?.dataKey!=null&&t.forEach(l=>{var c=$V(gr(l,e.dataKey));c!=null&&(s=s==null?c[0]:Math.min(s,c[0]),o=o==null?c[1]:Math.max(o,c[1]))}),xr(s)&&xr(o))return[s,o]},JPe=et([NO,ii,qPe,uM,Jr],AO,{memoizeOptions:{resultEqualityCheck:oM}});function eRe(t){var{value:e}=t;if(ol(e)||e instanceof Date)return e}var tRe=(t,e,n)=>{var r=t.map(eRe).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&jX(r))?iQ(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},xZ=t=>t.referenceElements.dots,jx=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),nRe=et([xZ,Jr,iv],jx),bZ=t=>t.referenceElements.areas,rRe=et([bZ,Jr,iv],jx),yZ=t=>t.referenceElements.lines,iRe=et([yZ,Jr,iv],jx),vZ=(t,e)=>{var n=$u(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},aRe=et(nRe,Jr,vZ),_Z=(t,e)=>{var n=$u(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)]},sRe=et([rRe,Jr],_Z);function oRe(t){var e;if(t.x!=null)return $u([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:$u(n)}function lRe(t){var e;if(t.y!=null)return $u([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:$u(n)}var wZ=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?oRe(r):lRe(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},cRe=et([iRe,Jr],wZ),uRe=et(aRe,cRe,sRe,(t,e,n)=>VS(t,n,e)),kO=(t,e,n,r,i,s,o,l)=>{if(n!=null)return n;var c=o==="vertical"&&l==="xAxis"||o==="horizontal"&&l==="yAxis",u=c?VS(r,s,i):VS(s,i);return vPe(e,u,t.allowDataOverflow)},dRe=et([ii,CO,TO,QPe,JPe,uRe,zn,Jr],kO,{memoizeOptions:{resultEqualityCheck:oM}}),hRe=[0,1],jO=(t,e,n,r,i,s,o)=>{if(!((t==null||n==null||n.length===0)&&o===void 0)){var{dataKey:l,type:c}=t,u=Ec(e,s);if(u&&l==null){var d;return iQ(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?tRe(r,t,u):i==="expand"?hRe:o}},PO=et([ii,zn,NO,cM,rv,Jr,dRe],jO),SZ=(t,e,n,r,i)=>{if(t!=null){var{scale:s,type:o}=t;if(s==="auto")return e==="radial"&&i==="radiusAxis"?"band":e==="radial"&&i==="angleAxis"?"linear":o==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?"point":o==="category"?"band":"linear";if(typeof s=="string"){var l="scale".concat(Hy(s));return l in c0?l:"point"}}},Px=et([ii,zn,dZ,fO,Jr],SZ);function fRe(t){if(t!=null){if(t in c0)return c0[t]();var e="scale".concat(Hy(t));if(e in c0)return c0[e]()}}function RO(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=fRe(e);if(i!=null){var s=i.domain(n).range(r);return cTe(s),s}}}var DO=(t,e,n)=>{var r=EO(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&Eh(t))return APe(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&Eh(t))return kPe(t,e.tickCount,e.allowDecimals)}},OO=et([PO,av,Px],DO),LO=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&Eh(e)&&Array.isArray(n)&&n.length>0){var i=e[0],s=n[0],o=e[1],l=n[n.length-1];return[Math.min(i,s),Math.max(o,l)]}return e},mRe=et([ii,PO,OO,Jr],LO),pRe=et(cM,ii,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from($u(t.map(l=>l.value))).sort((l,c)=>l-c);if(r.length<2)return 1/0;var i=r[r.length-1]-r[0];if(i===0)return 1/0;for(var s=0;s<r.length-1;s++){var o=r[s+1]-r[s];n=Math.min(n,o)}return n/i}}),NZ=et(pRe,zn,eZ,Ji,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!xr(t))return 0;var s=e==="vertical"?r.height:r.width;if(i==="gap")return t*s/2;if(i==="no-gap"){var o=Za(n,t*s),l=t*s/2;return l-o-(l-o)/s*o}return 0}),gRe=(t,e)=>{var n=Cc(t,e);return n==null||typeof n.padding!="string"?0:NZ(t,"xAxis",e,n.padding)},xRe=(t,e)=>{var n=Tc(t,e);return n==null||typeof n.padding!="string"?0:NZ(t,"yAxis",e,n.padding)},bRe=et(Cc,gRe,(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}}),yRe=et(Tc,xRe,(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}}),vRe=et([Ji,bRe,qN,GN,(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]}),_Re=et([Ji,zn,yRe,qN,GN,(t,e,n)=>n],(t,e,n,r,i,s)=>{var{padding:o}=i;return s?[r.height-o.bottom,o.top]:e==="horizontal"?[t.top+t.height-n.bottom,t.top+n.top]:[t.top+n.top,t.top+t.height-n.bottom]}),cv=(t,e,n,r)=>{var i;switch(e){case"xAxis":return vRe(t,n,r);case"yAxis":return _Re(t,n,r);case"zAxis":return(i=yO(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return aZ(t);case"radiusAxis":return sZ(t,n);default:return}},MZ=et([ii,cv],rM),Ch=et([ii,Px,mRe,MZ],RO);et([ov,uM,Jr],ZPe);function EZ(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var dM=(t,e)=>e,hM=(t,e,n)=>n,wRe=et(HN,dM,hM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(EZ)),SRe=et(VN,dM,hM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(EZ)),CZ=(t,e)=>({width:t.width,height:e.height}),NRe=(t,e)=>{var n=typeof e.width=="number"?e.width:Xy;return{width:n,height:t.height}},TZ=et(Ji,Cc,CZ),MRe=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},ERe=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},CRe=et(qu,Ji,wRe,dM,hM,(t,e,n,r,i)=>{var s={},o;return n.forEach(l=>{var c=CZ(e,l);o==null&&(o=MRe(e,r,t));var u=r==="top"&&!i||r==="bottom"&&i;s[l.id]=o-Number(u)*c.height,o+=(u?-1:1)*c.height}),s}),TRe=et(Gu,Ji,SRe,dM,hM,(t,e,n,r,i)=>{var s={},o;return n.forEach(l=>{var c=NRe(e,l);o==null&&(o=ERe(e,r,t));var u=r==="left"&&!i||r==="right"&&i;s[l.id]=o-Number(u)*c.width,o+=(u?-1:1)*c.width}),s}),ARe=(t,e)=>{var n=Cc(t,e);if(n!=null)return CRe(t,n.orientation,n.mirror)},kRe=et([Ji,Cc,ARe,(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}}}),jRe=(t,e)=>{var n=Tc(t,e);if(n!=null)return TRe(t,n.orientation,n.mirror)},PRe=et([Ji,Tc,jRe,(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}}}),AZ=et(Ji,Tc,(t,e)=>{var n=typeof e.width=="number"?e.width:Xy;return{width:n,height:t.height}}),HV=(t,e,n)=>{switch(e){case"xAxis":return TZ(t,n).width;case"yAxis":return AZ(t,n).height;default:return}},kZ=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:s,dataKey:o}=n,l=Ec(t,r),c=e.map(u=>u.value);if(o&&l&&s==="category"&&i&&jX(c))return c}},IO=et([zn,cM,ii,Jr],kZ),jZ=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:s}=n,o=Ec(t,r);if(o&&(i==="number"||s!=="auto"))return e.map(l=>l.value)}},FO=et([zn,cM,av,Jr],jZ),VV=et([zn,VPe,Px,Ch,IO,FO,cv,OO,Jr],(t,e,n,r,i,s,o,l,c)=>{if(e!=null){var u=Ec(t,c);return{angle:e.angle,interval:e.interval,minTickGap:e.minTickGap,orientation:e.orientation,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit,axisType:c,categoricalDomain:s,duplicateDomain:i,isCategorical:u,niceTicks:l,range:o,realScaleType:n,scale:r}}}),RRe=(t,e,n,r,i,s,o,l,c)=>{if(!(e==null||r==null)){var u=Ec(t,c),{type:d,ticks:f,tickCount:m}=e,p=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,x=d==="category"&&r.bandwidth?r.bandwidth()/p:0;x=c==="angleAxis"&&s!=null&&s.length>=2?ga(s[0]-s[1])*2*x:x;var b=f||i;if(b){var y=b.map((v,S)=>{var N=o?o.indexOf(v):v;return{index:S,coordinate:r(N)+x,value:v,offset:x}});return y.filter(v=>xr(v.coordinate))}return u&&l?l.map((v,S)=>({coordinate:r(v)+x,value:v,index:S,offset:x})).filter(v=>xr(v.coordinate)):r.ticks?r.ticks(m).map(v=>({coordinate:r(v)+x,value:v,offset:x})):r.domain().map((v,S)=>({coordinate:r(v)+x,value:o?o[v]:v,index:S,offset:x}))}},PZ=et([zn,av,Px,Ch,OO,cv,IO,FO,Jr],RRe),DRe=(t,e,n,r,i,s,o)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var l=Ec(t,o),{tickCount:c}=e,u=0;return u=o==="angleAxis"&&r?.length>=2?ga(r[0]-r[1])*2*u:u,l&&s?s.map((d,f)=>({coordinate:n(d)+u,value:d,index:f,offset:u})):n.ticks?n.ticks(c).map(d=>({coordinate:n(d)+u,value:d,offset:u})):n.domain().map((d,f)=>({coordinate:n(d)+u,value:i?i[d]:d,index:f,offset:u}))}},yc=et([zn,av,Ch,cv,IO,FO,Jr],DRe),vc=et(ii,Ch,(t,e)=>{if(!(t==null||e==null))return HS(HS({},t),{},{scale:e})}),ORe=et([ii,Px,PO,MZ],RO);et((t,e,n)=>yO(t,n),ORe,(t,e)=>{if(!(t==null||e==null))return HS(HS({},t),{},{scale:e})});var LRe=et([zn,HN,VN],(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}}),RZ=t=>t.options.defaultTooltipEventType,DZ=t=>t.options.validateTooltipEventTypes;function OZ(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function UO(t,e){var n=RZ(t),r=DZ(t);return OZ(e,n,r)}function IRe(t){return Ut(e=>UO(e,t))}var LZ=(t,e)=>{var n,r=Number(e);if(!(Gs(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},FRe=t=>t.tooltip.settings,Wd={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},URe={itemInteraction:{click:Wd,hover:Wd},axisInteraction:{click:Wd,hover:Wd},keyboardInteraction:Wd,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}},IZ=qs({name:"tooltip",initialState:URe,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:Wr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ol(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:Wr()},removeTooltipEntrySettings:{reducer(t,e){var n=Ol(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:Wr()},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:zRe,replaceTooltipEntrySettings:BRe,removeTooltipEntrySettings:$Re,setTooltipSettingsState:HRe,setActiveMouseOverItemIndex:FZ,mouseLeaveItem:VRe,mouseLeaveChart:UZ,setActiveClickItemIndex:GRe,setMouseOverAxisIndex:zZ,setMouseClickAxisIndex:qRe,setSyncInteraction:fR,setKeyboardInteraction:mR}=IZ.actions,WRe=IZ.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 Kw(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){KRe(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 KRe(t,e,n){return(e=XRe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function XRe(t){var e=YRe(t,"string");return typeof e=="symbol"?e:e+""}function YRe(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 QRe(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function ZRe(t){return t.index!=null}var BZ=(t,e,n,r)=>{if(e==null)return Wd;var i=QRe(t,e,n);if(i==null)return Wd;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(ZRe(i)){if(s)return Kw(Kw({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return Kw(Kw({},Wd),{},{coordinate:i.coordinate})};function JRe(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 eDe(t,e){var n=JRe(t),r=e[0],i=e[1];if(n===void 0)return!1;var s=Math.min(r,i),o=Math.max(r,i);return n>=s&&n<=o}function tDe(t,e,n){if(n==null||e==null)return!0;var r=gr(t,e);return r==null||!Eh(n)?!0:eDe(r,n)}var zO=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var s=Number(i);if(!xr(s))return i;var o=0,l=1/0;e.length>0&&(l=e.length-1);var c=Math.max(o,Math.min(s,l)),u=e[c];return u==null||tDe(u,n,r)?String(c):null},$Z=(t,e,n,r,i,s,o,l)=>{if(!(s==null||l==null)){var c=o[0],u=c==null?void 0:l(c.positions,s);if(u!=null)return u;var d=i?.[Number(s)];if(d)switch(n){case"horizontal":return{x:d.coordinate,y:(r.top+e)/2};default:return{x:(r.left+t)/2,y:d.coordinate}}}},HZ=(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 o;return((o=s.settings)===null||o===void 0?void 0:o.dataKey)===i})},uv=t=>t.options.tooltipPayloadSearcher,Rx=t=>t.tooltip;function qV(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 WV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?qV(Object(n),!0).forEach(function(r){nDe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function nDe(t,e,n){return(e=rDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rDe(t){var e=iDe(t,"string");return typeof e=="symbol"?e:e+""}function iDe(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 aDe(t,e){return t??e}var VZ=(t,e,n,r,i,s,o)=>{if(!(e==null||s==null)){var{chartData:l,computedData:c,dataStartIndex:u,dataEndIndex:d}=n,f=[];return t.reduce((m,p)=>{var x,{dataDefinedOnItem:b,settings:y}=p,v=aDe(b,l),S=Array.isArray(v)?EY(v,u,d):v,N=(x=y?.dataKey)!==null&&x!==void 0?x:r,C=y?.nameKey,T;if(r&&Array.isArray(S)&&!Array.isArray(S[0])&&o==="axis"?T=PX(S,r,i):T=s(S,e,c,C),Array.isArray(T))T.forEach(E=>{var D=WV(WV({},y),{},{name:E.name,unit:E.unit,color:void 0,fill:void 0});m.push(fH({tooltipEntrySettings:D,dataKey:E.dataKey,payload:E.payload,value:gr(E.payload,E.dataKey),name:E.name}))});else{var k;m.push(fH({tooltipEntrySettings:y,dataKey:N,payload:T,value:gr(T,N),name:(k=gr(T,C))!==null&&k!==void 0?k:y?.name}))}return m},f)}},BO=et([ra,zn,dZ,fO,na],SZ),sDe=et([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),oDe=et([na,kx],vO),dv=et([sDe,ra,oDe],_O,{memoizeOptions:{resultEqualityCheck:lM}}),lDe=et([dv],t=>t.filter(sM)),cDe=et([dv],wO,{memoizeOptions:{resultEqualityCheck:lM}}),Dx=et([cDe,Uh],SO),uDe=et([lDe,Uh,ra],lZ),$O=et([Dx,ra,dv],MO),GZ=et([ra],EO),dDe=et([ra],t=>t.allowDataOverflow),qZ=et([GZ,dDe],UQ),hDe=et([dv],t=>t.filter(sM)),fDe=et([uDe,hDe,rv,tZ],pZ),mDe=et([fDe,Uh,na,qZ],gZ),pDe=et([dv],fZ),gDe=et([Dx,ra,pDe,uM,na],AO,{memoizeOptions:{resultEqualityCheck:oM}}),xDe=et([xZ,na,kx],jx),bDe=et([xDe,na],vZ),yDe=et([bZ,na,kx],jx),vDe=et([yDe,na],_Z),_De=et([yZ,na,kx],jx),wDe=et([_De,na],wZ),SDe=et([bDe,wDe,vDe],VS),NDe=et([ra,GZ,qZ,mDe,gDe,SDe,zn,na],kO),hv=et([ra,zn,Dx,$O,rv,na,NDe],jO),MDe=et([hv,ra,BO],DO),EDe=et([ra,hv,MDe,na],LO),WZ=t=>{var e=na(t),n=kx(t),r=!1;return cv(t,e,n,r)},KZ=et([ra,WZ],rM),XZ=et([ra,BO,EDe,KZ],RO),CDe=et([zn,$O,ra,na],kZ),TDe=et([zn,$O,ra,na],jZ),ADe=(t,e,n,r,i,s,o,l)=>{if(e){var{type:c}=e,u=Ec(t,l);if(r){var d=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,f=c==="category"&&r.bandwidth?r.bandwidth()/d:0;return f=l==="angleAxis"&&i!=null&&i?.length>=2?ga(i[0]-i[1])*2*f:f,u&&o?o.map((m,p)=>({coordinate:r(m)+f,value:m,index:p,offset:f})):r.domain().map((m,p)=>({coordinate:r(m)+f,value:s?s[m]:m,index:p,offset:f}))}}},Ku=et([zn,ra,BO,XZ,WZ,CDe,TDe,na],ADe),HO=et([RZ,DZ,FRe],(t,e,n)=>OZ(n.shared,t,e)),YZ=t=>t.tooltip.settings.trigger,VO=t=>t.tooltip.settings.defaultIndex,fv=et([Rx,HO,YZ,VO],BZ),Th=et([fv,Dx,lv,hv],zO),QZ=et([Ku,Th],LZ),GO=et([fv],t=>{if(t)return t.dataKey}),kDe=et([fv],t=>{if(t)return t.graphicalItemId}),ZZ=et([Rx,HO,YZ,VO],HZ),jDe=et([Gu,qu,zn,Ji,Ku,VO,ZZ,uv],$Z),PDe=et([fv,jDe],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),RDe=et([fv],t=>t.active),DDe=et([ZZ,Th,Uh,lv,QZ,uv,HO],VZ),ODe=et([DDe],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function KV(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 XV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?KV(Object(n),!0).forEach(function(r){LDe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):KV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function LDe(t,e,n){return(e=IDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function IDe(t){var e=FDe(t,"string");return typeof e=="symbol"?e:e+""}function FDe(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 UDe=()=>Ut(ra),zDe=()=>{var t=UDe(),e=Ut(Ku),n=Ut(XZ);return Mh(!t||!n?void 0:XV(XV({},t),{},{scale:n}),e)};function YV(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 Yp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?YV(Object(n),!0).forEach(function(r){BDe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):YV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function BDe(t,e,n){return(e=$De(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $De(t){var e=HDe(t,"string");return typeof e=="symbol"?e:e+""}function HDe(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 VDe=(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}},GDe=(t,e,n,r)=>{var i=e.find(u=>u&&u.index===n);if(i){if(t==="centric"){var s=i.coordinate,{radius:o}=r;return Yp(Yp(Yp({},r),Oi(r.cx,r.cy,o,s)),{},{angle:s,radius:o})}var l=i.coordinate,{angle:c}=r;return Yp(Yp(Yp({},r),Oi(r.cx,r.cy,l,c)),{},{angle:c,radius:l})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function qDe(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 JZ=(t,e,n,r,i)=>{var s,o=-1,l=(s=e?.length)!==null&&s!==void 0?s:0;if(l<=1||t==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var c=0;c<l;c++){var u=c>0?n[c-1].coordinate:n[l-1].coordinate,d=n[c].coordinate,f=c>=l-1?n[0].coordinate:n[c+1].coordinate,m=void 0;if(ga(d-u)!==ga(f-d)){var p=[];if(ga(f-d)===ga(i[1]-i[0])){m=f;var x=d+i[1]-i[0];p[0]=Math.min(x,(x+u)/2),p[1]=Math.max(x,(x+u)/2)}else{m=u;var b=f+i[1]-i[0];p[0]=Math.min(d,(b+d)/2),p[1]=Math.max(d,(b+d)/2)}var y=[Math.min(d,(m+d)/2),Math.max(d,(m+d)/2)];if(t>y[0]&&t<=y[1]||t>=p[0]&&t<=p[1]){({index:o}=n[c]);break}}else{var v=Math.min(u,f),S=Math.max(u,f);if(t>(v+d)/2&&t<=(S+d)/2){({index:o}=n[c]);break}}}else if(e){for(var N=0;N<l;N++)if(N===0&&t<=(e[N].coordinate+e[N+1].coordinate)/2||N>0&&N<l-1&&t>(e[N].coordinate+e[N-1].coordinate)/2&&t<=(e[N].coordinate+e[N+1].coordinate)/2||N===l-1&&t>(e[N].coordinate+e[N-1].coordinate)/2){({index:o}=e[N]);break}}return o},eJ=()=>Ut(fO),qO=(t,e)=>e,tJ=(t,e,n)=>n,WO=(t,e,n,r)=>r,WDe=et(Ku,t=>DN(t,e=>e.coordinate)),KO=et([Rx,qO,tJ,WO],BZ),XO=et([KO,Dx,lv,hv],zO),KDe=(t,e,n)=>{if(e!=null){var r=Rx(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},nJ=et([Rx,qO,tJ,WO],HZ),GS=et([Gu,qu,zn,Ji,Ku,WO,nJ,uv],$Z),XDe=et([KO,GS],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),rJ=et([Ku,XO],LZ),YDe=et([nJ,XO,Uh,lv,rJ,uv,qO],VZ),QDe=et([KO,XO],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),ZDe=(t,e,n,r,i,s,o)=>{if(!(!t||!n||!r||!i)&&qDe(t,o)){var l=yTe(t,e),c=JZ(l,s,i,n,r),u=VDe(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},JDe=(t,e,n,r,i,s,o)=>{if(!(!t||!r||!i||!s||!n)){var l=Lke(t,n);if(l){var c=vTe(l,e),u=JZ(c,o,s,r,i),d=GDe(e,s,u,l);return{activeIndex:String(u),activeCoordinate:d}}}},e4e=(t,e,n,r,i,s,o,l)=>{if(!(!t||!e||!r||!i||!s))return e==="horizontal"||e==="vertical"?ZDe(t,e,r,i,s,o,l):JDe(t,e,n,r,i,s,o)},t4e=et(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}}),n4e=et(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(mi)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:UPe}});function QV(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 ZV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?QV(Object(n),!0).forEach(function(r){r4e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):QV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function r4e(t,e,n){return(e=i4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i4e(t){var e=a4e(t,"string");return typeof e=="symbol"?e:e+""}function a4e(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 s4e={},o4e={zIndexMap:Object.values(mi).reduce((t,e)=>ZV(ZV({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),s4e)},l4e=new Set(Object.values(mi));function c4e(t){return l4e.has(t)}var iJ=qs({name:"zIndex",initialState:o4e,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:Wr()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!c4e(n)&&delete t.zIndexMap[n])},prepare:Wr()},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:Wr()},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:Wr()}}}),{registerZIndexPortal:u4e,unregisterZIndexPortal:d4e,registerZIndexPortalId:h4e,unregisterZIndexPortalId:f4e}=iJ.actions,m4e=iJ.reducer;function es(t){var{zIndex:e,children:n}=t,r=ZTe(),i=r&&e!==void 0&&e!==0,s=ea(),o=Or();w.useLayoutEffect(()=>i?(o(u4e({zIndex:e})),()=>{o(d4e({zIndex:e}))}):Vy,[o,e,i]);var l=Ut(u=>t4e(u,e,s));if(!i)return n;if(!l)return null;var c=document.getElementById(l);return c?pu.createPortal(n,c):null}function pR(){return pR=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},pR.apply(null,arguments)}function JV(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?JV(Object(n),!0).forEach(function(r){p4e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):JV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function p4e(t,e,n){return(e=g4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function g4e(t){var e=x4e(t,"string");return typeof e=="symbol"?e:e+""}function x4e(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 b4e(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return w.isValidElement(e)?w.cloneElement(e,r):w.createElement(n,r)}function y4e(t){var e,{coordinate:n,payload:r,index:i,offset:s,tooltipAxisBandSize:o,layout:l,cursor:c,tooltipEventType:u,chartName:d}=t,f=n,m=r,p=i;if(!c||!f||d!=="ScatterChart"&&u!=="axis")return null;var x,b,y;if(d==="ScatterChart")x=f,b=QAe,y=mi.cursorLine;else if(d==="BarChart")x=ZAe(l,f,s,o),b=JY,y=mi.cursorRectangle;else if(l==="radial"&&DX(f)){var{cx:v,cy:S,radius:N,startAngle:C,endAngle:T}=tQ(f);x={cx:v,cy:S,startAngle:C,endAngle:T,innerRadius:N,outerRadius:N},b=rQ,y=mi.cursorLine}else x={points:zke(l,f,s)},b=Pg,y=mi.cursorLine;var k=typeof c=="object"&&"className"in c?c.className:void 0,E=Xw(Xw(Xw(Xw({stroke:"#ccc",pointerEvents:"none"},s),x),fm(c)),{},{payload:m,payloadIndex:p,className:Zn("recharts-tooltip-cursor",k)});return w.createElement(es,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:y},w.createElement(b4e,{cursor:c,cursorComp:b,cursorProps:E}))}function v4e(t){var e=zDe(),n=IY(),r=Tm(),i=eJ();return e==null||n==null||r==null||i==null?null:w.createElement(y4e,pR({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var aJ=w.createContext(null),_4e=()=>w.useContext(aJ),$k={exports:{}},e7;function w4e(){return e7||(e7=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function s(c,u,d,f,m){if(typeof d!="function")throw new TypeError("The listener must be a function");var p=new i(d,f||c,m),x=n?n+u:u;return c._events[x]?c._events[x].fn?c._events[x]=[c._events[x],p]:c._events[x].push(p):(c._events[x]=p,c._eventsCount++),c}function o(c,u){--c._eventsCount===0?c._events=new r:delete c._events[u]}function l(){this._events=new r,this._eventsCount=0}l.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},l.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 m=0,p=f.length,x=new Array(p);m<p;m++)x[m]=f[m].fn;return x},l.prototype.listenerCount=function(u){var d=n?n+u:u,f=this._events[d];return f?f.fn?1:f.length:0},l.prototype.emit=function(u,d,f,m,p,x){var b=n?n+u:u;if(!this._events[b])return!1;var y=this._events[b],v=arguments.length,S,N;if(y.fn){switch(y.once&&this.removeListener(u,y.fn,void 0,!0),v){case 1:return y.fn.call(y.context),!0;case 2:return y.fn.call(y.context,d),!0;case 3:return y.fn.call(y.context,d,f),!0;case 4:return y.fn.call(y.context,d,f,m),!0;case 5:return y.fn.call(y.context,d,f,m,p),!0;case 6:return y.fn.call(y.context,d,f,m,p,x),!0}for(N=1,S=new Array(v-1);N<v;N++)S[N-1]=arguments[N];y.fn.apply(y.context,S)}else{var C=y.length,T;for(N=0;N<C;N++)switch(y[N].once&&this.removeListener(u,y[N].fn,void 0,!0),v){case 1:y[N].fn.call(y[N].context);break;case 2:y[N].fn.call(y[N].context,d);break;case 3:y[N].fn.call(y[N].context,d,f);break;case 4:y[N].fn.call(y[N].context,d,f,m);break;default:if(!S)for(T=1,S=new Array(v-1);T<v;T++)S[T-1]=arguments[T];y[N].fn.apply(y[N].context,S)}}return!0},l.prototype.on=function(u,d,f){return s(this,u,d,f,!1)},l.prototype.once=function(u,d,f){return s(this,u,d,f,!0)},l.prototype.removeListener=function(u,d,f,m){var p=n?n+u:u;if(!this._events[p])return this;if(!d)return o(this,p),this;var x=this._events[p];if(x.fn)x.fn===d&&(!m||x.once)&&(!f||x.context===f)&&o(this,p);else{for(var b=0,y=[],v=x.length;b<v;b++)(x[b].fn!==d||m&&!x[b].once||f&&x[b].context!==f)&&y.push(x[b]);y.length?this._events[p]=y.length===1?y[0]:y:o(this,p)}return this},l.prototype.removeAllListeners=function(u){var d;return u?(d=n?n+u:u,this._events[d]&&o(this,d)):(this._events=new r,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=n,l.EventEmitter=l,t.exports=l})($k)),$k.exports}var S4e=w4e();const N4e=ul(S4e);var yy=new N4e,gR="recharts.syncEvent.tooltip",t7="recharts.syncEvent.brush";function fM(t,e){if(e){var n=Number.parseInt(e,10);if(!Gs(n))return t?.[n]}}var M4e={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},sJ=qs({name:"options",initialState:M4e,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),E4e=sJ.reducer,{createEventEmitter:C4e}=sJ.actions;function T4e(t){return t.tooltip.syncInteraction}var A4e={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},oJ=qs({name:"chartData",initialState:A4e,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:n7,setDataStartEndIndexes:k4e,setComputedData:GYe}=oJ.actions,j4e=oJ.reducer,P4e=["x","y"];function r7(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Qp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?r7(Object(n),!0).forEach(function(r){R4e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function R4e(t,e,n){return(e=D4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function D4e(t){var e=O4e(t,"string");return typeof e=="symbol"?e:e+""}function O4e(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 L4e(t,e){if(t==null)return{};var n,r,i=I4e(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 I4e(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 F4e(){var t=Ut(mO),e=Ut(pO),n=Or(),r=Ut(nZ),i=Ut(Ku),s=Tm(),o=Yy(),l=Ut(c=>c.rootProps.className);w.useEffect(()=>{if(t==null)return Vy;var c=(u,d,f)=>{if(e!==f&&t===u){if(r==="index"){var m;if(o&&d!==null&&d!==void 0&&(m=d.payload)!==null&&m!==void 0&&m.coordinate&&d.payload.sourceViewBox){var p=d.payload.coordinate,{x,y:b}=p,y=L4e(p,P4e),{x:v,y:S,width:N,height:C}=d.payload.sourceViewBox,T=Qp(Qp({},y),{},{x:o.x+(N?(x-v)/N:0)*o.width,y:o.y+(C?(b-S)/C:0)*o.height});n(Qp(Qp({},d),{},{payload:Qp(Qp({},d.payload),{},{coordinate:T})}))}else n(d);return}if(i!=null){var k;if(typeof r=="function"){var E={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},D=r(i,E);k=i[D]}else r==="value"&&(k=i.find($=>String($.value)===d.payload.label));var{coordinate:A}=d.payload;if(k==null||d.payload.active===!1||A==null||o==null){n(fR({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:R,y:F}=A,O=Math.min(R,o.x+o.width),H=Math.min(F,o.y+o.height),j={x:s==="horizontal"?k.coordinate:O,y:s==="horizontal"?H:k.coordinate},G=fR({active:d.payload.active,coordinate:j,dataKey:d.payload.dataKey,index:String(k.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n(G)}}};return yy.on(gR,c),()=>{yy.off(gR,c)}},[l,n,e,t,r,i,s,o])}function U4e(){var t=Ut(mO),e=Ut(pO),n=Or();w.useEffect(()=>{if(t==null)return Vy;var r=(i,s,o)=>{e!==o&&t===i&&n(k4e(s))};return yy.on(t7,r),()=>{yy.off(t7,r)}},[n,e,t])}function z4e(){var t=Or();w.useEffect(()=>{t(C4e())},[t]),F4e(),U4e()}function B4e(t,e,n,r,i,s){var o=Ut(p=>KDe(p,t,e)),l=Ut(pO),c=Ut(mO),u=Ut(nZ),d=Ut(T4e),f=d?.active,m=Yy();w.useEffect(()=>{if(!f&&c!=null&&l!=null){var p=fR({active:s,coordinate:n,dataKey:o,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:m,graphicalItemId:void 0});yy.emit(gR,c,p,l)}},[f,n,o,i,r,l,c,u,s,m])}function i7(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 a7(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?i7(Object(n),!0).forEach(function(r){$4e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $4e(t,e,n){return(e=H4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function H4e(t){var e=V4e(t,"string");return typeof e=="symbol"?e:e+""}function V4e(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 G4e(t){return t.dataKey}function q4e(t,e){return w.isValidElement(t)?w.cloneElement(t,e):typeof t=="function"?w.createElement(t,e):w.createElement(kAe,e)}var s7=[],W4e={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 P1(t){var e,n,r=ri(t,W4e),{active:i,allowEscapeViewBox:s,animationDuration:o,animationEasing:l,content:c,filterNull:u,isAnimationActive:d,offset:f,payloadUniqBy:m,position:p,reverseDirection:x,useTranslate3d:b,wrapperStyle:y,cursor:v,shared:S,trigger:N,defaultIndex:C,portal:T,axisId:k}=r,E=Or(),D=typeof C=="number"?String(C):C;w.useEffect(()=>{E(HRe({shared:S,trigger:N,axisId:k,active:i,defaultIndex:D}))},[E,S,N,k,i,D]);var A=Yy(),R=KY(),F=IRe(S),{activeIndex:O,isActive:H}=(e=Ut(ye=>QDe(ye,F,N,D)))!==null&&e!==void 0?e:{},j=Ut(ye=>YDe(ye,F,N,D)),G=Ut(ye=>rJ(ye,F,N,D)),$=Ut(ye=>XDe(ye,F,N,D)),q=j,Y=_4e(),Z=(n=i??H)!==null&&n!==void 0?n:!1,[oe,B]=YX([q,Z]),W=F==="axis"?G:void 0;B4e(F,N,$,W,O,Z);var se=T??Y;if(se==null||A==null||F==null)return null;var ne=q??s7;Z||(ne=s7),u&&ne.length&&(ne=VX(ne.filter(ye=>ye.value!=null&&(ye.hide!==!0||r.includeHidden)),m,G4e));var ce=ne.length>0,fe=w.createElement(IAe,{allowEscapeViewBox:s,animationDuration:o,animationEasing:l,isAnimationActive:d,active:Z,coordinate:$,hasPayload:ce,offset:f,position:p,reverseDirection:x,useTranslate3d:b,viewBox:A,wrapperStyle:y,lastBoundingBox:oe,innerRef:B,hasPortalFromProps:!!T},q4e(c,a7(a7({},r),{},{payload:ne,label:W,active:Z,activeIndex:O,coordinate:$,accessibilityLayer:R})));return w.createElement(w.Fragment,null,pu.createPortal(fe,se),Z&&w.createElement(v4e,{cursor:v,tooltipEventType:F,coordinate:$,payload:ne,index:O}))}var mv=t=>null;mv.displayName="Cell";function K4e(t,e,n){return(e=X4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function X4e(t){var e=Y4e(t,"string");return typeof e=="symbol"?e:e+""}function Y4e(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 Q4e{constructor(e){K4e(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 o7(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 Z4e(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?o7(Object(n),!0).forEach(function(r){J4e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function J4e(t,e,n){return(e=eOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function eOe(t){var e=tOe(t,"string");return typeof e=="symbol"?e:e+""}function tOe(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 nOe={cacheSize:2e3,enableCache:!0},lJ=Z4e({},nOe),l7=new Q4e(lJ.cacheSize),rOe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},c7="recharts_measurement_span";function iOe(t,e){var n=e.fontSize||"",r=e.fontFamily||"",i=e.fontWeight||"",s=e.fontStyle||"",o=e.letterSpacing||"",l=e.textTransform||"";return"".concat(t,"|").concat(n,"|").concat(r,"|").concat(i,"|").concat(s,"|").concat(o,"|").concat(l)}var u7=(t,e)=>{try{var n=document.getElementById(c7);n||(n=document.createElement("span"),n.setAttribute("id",c7),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,rOe,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},M0=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Nx.isSsr)return{width:0,height:0};if(!lJ.enableCache)return u7(e,n);var r=iOe(e,n),i=l7.get(r);if(i)return i;var s=u7(e,n);return l7.set(r,s),s},d7=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,h7=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,aOe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,sOe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,cJ={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},oOe=Object.keys(cJ),bg="NaN";function lOe(t,e){return t*cJ[e]}class Ds{static parse(e){var n,[,r,i]=(n=sOe.exec(e))!==null&&n!==void 0?n:[];return new Ds(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,Gs(e)&&(this.unit=""),n!==""&&!aOe.test(n)&&(this.num=NaN,this.unit=""),oOe.includes(n)&&(this.num=lOe(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new Ds(NaN,""):new Ds(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new Ds(NaN,""):new Ds(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Ds(NaN,""):new Ds(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Ds(NaN,""):new Ds(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return Gs(this.num)}}function uJ(t){if(t.includes(bg))return bg;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,s]=(n=d7.exec(e))!==null&&n!==void 0?n:[],o=Ds.parse(r??""),l=Ds.parse(s??""),c=i==="*"?o.multiply(l):o.divide(l);if(c.isNaN())return bg;e=e.replace(d7,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,m]=(u=h7.exec(e))!==null&&u!==void 0?u:[],p=Ds.parse(d??""),x=Ds.parse(m??""),b=f==="+"?p.add(x):p.subtract(x);if(b.isNaN())return bg;e=e.replace(h7,b.toString())}return e}var f7=/\(([^()]*)\)/;function cOe(t){for(var e=t,n;(n=f7.exec(e))!=null;){var[,r]=n;e=e.replace(f7,uJ(r))}return e}function uOe(t){var e=t.replace(/\s+/g,"");return e=cOe(e),e=uJ(e),e}function dOe(t){try{return uOe(t)}catch{return bg}}function Hk(t){var e=dOe(t.slice(5,-1));return e===bg?"":e}var hOe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],fOe=["dx","dy","angle","className","breakAll"];function xR(){return xR=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},xR.apply(null,arguments)}function m7(t,e){if(t==null)return{};var n,r,i=mOe(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 mOe(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 dJ=/[ \f\n\r\t\v\u2028\u2029]+/,hJ=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];Gr(e)||(n?i=e.toString().split(""):i=e.toString().split(dJ));var s=i.map(l=>({word:l,width:M0(l,r).width})),o=n?0:M0(" ",r).width;return{wordsWithComputedWidth:s,spaceWidth:o}}catch{return null}};function pOe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var fJ=(t,e,n,r)=>t.reduce((i,s)=>{var{word:o,width:l}=s,c=i[i.length-1];if(c&&l!=null&&(e==null||r||c.width+l+n<Number(e)))c.words.push(o),c.width+=l+n;else{var u={words:[o],width:l};i.push(u)}return i},[]),mJ=t=>t.reduce((e,n)=>e.width>n.width?e:n),gOe="…",p7=(t,e,n,r,i,s,o,l)=>{var c=t.slice(0,e),u=hJ({breakAll:n,style:r,children:c+gOe});if(!u)return[!1,[]];var d=fJ(u.wordsWithComputedWidth,s,o,l),f=d.length>i||mJ(d).width>Number(s);return[f,d]},xOe=(t,e,n,r,i)=>{var{maxLines:s,children:o,style:l,breakAll:c}=t,u=Bt(s),d=String(o),f=fJ(e,r,n,i);if(!u||i)return f;var m=f.length>s||mJ(f).width>Number(r);if(!m)return f;for(var p=0,x=d.length-1,b=0,y;p<=x&&b<=d.length-1;){var v=Math.floor((p+x)/2),S=v-1,[N,C]=p7(d,S,c,l,s,r,n,i),[T]=p7(d,v,c,l,s,r,n,i);if(!N&&!T&&(p=v+1),N&&T&&(x=v-1),!N&&T){y=C;break}b++}return y||f},g7=t=>{var e=Gr(t)?[]:t.toString().split(dJ);return[{words:e,width:void 0}]},bOe=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:s,maxLines:o}=t;if((e||n)&&!Nx.isSsr){var l,c,u=hJ({breakAll:s,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;l=d,c=f}else return g7(r);return xOe({breakAll:s,children:r,maxLines:o,style:i},l,c,e,!!n)}return g7(r)},pJ="#808080",yOe={angle:0,breakAll:!1,capHeight:"0.71em",fill:pJ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},mM=w.forwardRef((t,e)=>{var n=ri(t,yOe),{x:r,y:i,lineHeight:s,capHeight:o,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=m7(n,hOe),m=w.useMemo(()=>bOe({breakAll:f.breakAll,children:f.children,maxLines:f.maxLines,scaleToFit:c,style:f.style,width:f.width}),[f.breakAll,f.children,f.maxLines,c,f.style,f.width]),{dx:p,dy:x,angle:b,className:y,breakAll:v}=f,S=m7(f,fOe);if(!ol(r)||!ol(i)||m.length===0)return null;var N=Number(r)+(Bt(p)?p:0),C=Number(i)+(Bt(x)?x:0);if(!xr(N)||!xr(C))return null;var T;switch(d){case"start":T=Hk("calc(".concat(o,")"));break;case"middle":T=Hk("calc(".concat((m.length-1)/2," * -").concat(s," + (").concat(o," / 2))"));break;default:T=Hk("calc(".concat(m.length-1," * -").concat(s,")"));break}var k=[];if(c){var E=m[0].width,{width:D}=f;k.push("scale(".concat(Bt(D)&&Bt(E)?D/E:1,")"))}return b&&k.push("rotate(".concat(b,", ").concat(N,", ").concat(C,")")),k.length&&(S.transform=k.join(" ")),w.createElement("text",xR({},La(S),{ref:e,x:N,y:C,className:Zn("recharts-text",y),textAnchor:u,fill:l.includes("url")?pJ:l}),m.map((A,R)=>{var F=A.words.join(v?"":" ");return w.createElement("tspan",{x:N,dy:R===0?T:s,key:"".concat(F,"-").concat(R)},F)}))});mM.displayName="Text";var vOe=["labelRef"];function _Oe(t,e){if(t==null)return{};var n,r,i=wOe(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 wOe(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 x7(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 vi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?x7(Object(n),!0).forEach(function(r){SOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):x7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function SOe(t,e,n){return(e=NOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function NOe(t){var e=MOe(t,"string");return typeof e=="symbol"?e:e+""}function MOe(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 mu(){return mu=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},mu.apply(null,arguments)}var gJ=w.createContext(null),xJ=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:o,children:l}=t,c=w.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:o}),[e,n,r,i,s,o]);return w.createElement(gJ.Provider,{value:c},l)},bJ=()=>{var t=w.useContext(gJ),e=Yy();return t||LY(e)},EOe=w.createContext(null),COe=()=>{var t=w.useContext(EOe),e=Ut(oZ);return t||e},TOe=t=>{var{value:e,formatter:n}=t,r=Gr(t.children)?e:t.children;return typeof n=="function"?n(r):r},YO=t=>t!=null&&typeof t=="function",AOe=(t,e)=>{var n=ga(e-t),r=Math.min(Math.abs(e-t),360);return n*r},kOe=(t,e,n,r,i)=>{var{offset:s,className:o}=t,{cx:l,cy:c,innerRadius:u,outerRadius:d,startAngle:f,endAngle:m,clockWise:p}=i,x=(u+d)/2,b=AOe(f,m),y=b>=0?1:-1,v,S;switch(e){case"insideStart":v=f+y*s,S=p;break;case"insideEnd":v=m-y*s,S=!p;break;case"end":v=m+y*s,S=p;break;default:throw new Error("Unsupported position ".concat(e))}S=b<=0?S:!S;var N=Oi(l,c,x,v),C=Oi(l,c,x,v+(S?1:-1)*359),T="M".concat(N.x,",").concat(N.y,`
  8095. A`).concat(x,",").concat(x,",0,1,").concat(S?0:1,`,
  8096. `).concat(C.x,",").concat(C.y),k=Gr(t.id)?ay("recharts-radial-line-"):t.id;return w.createElement("text",mu({},r,{dominantBaseline:"central",className:Zn("recharts-radial-bar-label",o)}),w.createElement("defs",null,w.createElement("path",{id:k,d:T})),w.createElement("textPath",{xlinkHref:"#".concat(k)},n))},jOe=(t,e,n)=>{var{cx:r,cy:i,innerRadius:s,outerRadius:o,startAngle:l,endAngle:c}=t,u=(l+c)/2;if(n==="outside"){var{x:d,y:f}=Oi(r,i,o+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 m=(s+o)/2,{x:p,y:x}=Oi(r,i,m,u);return{x:p,y:x,textAnchor:"middle",verticalAnchor:"middle"}},bR=t=>"cx"in t&&Bt(t.cx),POe=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,s;n!=null&&!bR(n)&&(s=n);var{x:o,y:l,upperWidth:c,lowerWidth:u,height:d}=e,f=o,m=o+(c-u)/2,p=(f+m)/2,x=(c+u)/2,b=f+c/2,y=d>=0?1:-1,v=y*r,S=y>0?"end":"start",N=y>0?"start":"end",C=c>=0?1:-1,T=C*r,k=C>0?"end":"start",E=C>0?"start":"end";if(i==="top"){var D={x:f+c/2,y:l-v,textAnchor:"middle",verticalAnchor:S};return vi(vi({},D),s?{height:Math.max(l-s.y,0),width:c}:{})}if(i==="bottom"){var A={x:m+u/2,y:l+d+v,textAnchor:"middle",verticalAnchor:N};return vi(vi({},A),s?{height:Math.max(s.y+s.height-(l+d),0),width:u}:{})}if(i==="left"){var R={x:p-T,y:l+d/2,textAnchor:k,verticalAnchor:"middle"};return vi(vi({},R),s?{width:Math.max(R.x-s.x,0),height:d}:{})}if(i==="right"){var F={x:p+x+T,y:l+d/2,textAnchor:E,verticalAnchor:"middle"};return vi(vi({},F),s?{width:Math.max(s.x+s.width-F.x,0),height:d}:{})}var O=s?{width:x,height:d}:{};return i==="insideLeft"?vi({x:p+T,y:l+d/2,textAnchor:E,verticalAnchor:"middle"},O):i==="insideRight"?vi({x:p+x-T,y:l+d/2,textAnchor:k,verticalAnchor:"middle"},O):i==="insideTop"?vi({x:f+c/2,y:l+v,textAnchor:"middle",verticalAnchor:N},O):i==="insideBottom"?vi({x:m+u/2,y:l+d-v,textAnchor:"middle",verticalAnchor:S},O):i==="insideTopLeft"?vi({x:f+T,y:l+v,textAnchor:E,verticalAnchor:N},O):i==="insideTopRight"?vi({x:f+c-T,y:l+v,textAnchor:k,verticalAnchor:N},O):i==="insideBottomLeft"?vi({x:m+T,y:l+d-v,textAnchor:E,verticalAnchor:S},O):i==="insideBottomRight"?vi({x:m+u-T,y:l+d-v,textAnchor:k,verticalAnchor:S},O):i&&typeof i=="object"&&(Bt(i.x)||Iu(i.x))&&(Bt(i.y)||Iu(i.y))?vi({x:o+Za(i.x,x),y:l+Za(i.y,d),textAnchor:"end",verticalAnchor:"end"},O):vi({x:b,y:l+d/2,textAnchor:"middle",verticalAnchor:"middle"},O)},ROe={angle:0,offset:5,zIndex:mi.label,position:"middle",textBreakAll:!1};function Bd(t){var e=ri(t,ROe),{viewBox:n,position:r,value:i,children:s,content:o,className:l="",textBreakAll:c,labelRef:u}=e,d=COe(),f=bJ(),m=r==="center"?f:d??f,p,x,b;if(n==null?p=m:bR(n)?p=n:p=LY(n),!p||Gr(i)&&Gr(s)&&!w.isValidElement(o)&&typeof o!="function")return null;var y=vi(vi({},e),{},{viewBox:p});if(w.isValidElement(o)){var{labelRef:v}=y,S=_Oe(y,vOe);return w.cloneElement(o,S)}if(typeof o=="function"){if(x=w.createElement(o,y),w.isValidElement(x))return x}else x=TOe(e);var N=La(e);if(bR(p)){if(r==="insideStart"||r==="insideEnd"||r==="end")return kOe(e,r,x,N,p);b=jOe(p,e.offset,e.position)}else b=POe(e,p);return w.createElement(es,{zIndex:e.zIndex},w.createElement(mM,mu({ref:u,className:Zn("recharts-label",l)},N,b,{textAnchor:pOe(N.textAnchor)?N.textAnchor:b.textAnchor,breakAll:c}),x))}Bd.displayName="Label";var DOe=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?w.createElement(Bd,mu({key:"label-implicit"},r)):ol(t)?w.createElement(Bd,mu({key:"label-implicit",value:t},r)):w.isValidElement(t)?t.type===Bd?w.cloneElement(t,vi({key:"label-implicit"},r)):w.createElement(Bd,mu({key:"label-implicit",content:t},r)):YO(t)?w.createElement(Bd,mu({key:"label-implicit",content:t},r)):t&&typeof t=="object"?w.createElement(Bd,mu({},t,{key:"label-implicit"},r)):null};function yJ(t){var{label:e,labelRef:n}=t,r=bJ();return DOe(e,r,n)||null}var Vk={},Gk={},b7;function OOe(){return b7||(b7=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(Gk)),Gk}var qk={},y7;function LOe(){return y7||(y7=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(qk)),qk}var v7;function IOe(){return v7||(v7=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=OOe(),n=LOe(),r=N4();function i(s){if(r.isArrayLike(s))return e.last(n.toArray(s))}t.last=i})(Vk)),Vk}var Wk,_7;function FOe(){return _7||(_7=1,Wk=IOe().last),Wk}var UOe=FOe();const zOe=ul(UOe);var BOe=["valueAccessor"],$Oe=["dataKey","clockWise","id","textBreakAll","zIndex"];function qS(){return qS=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},qS.apply(null,arguments)}function w7(t,e){if(t==null)return{};var n,r,i=HOe(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 HOe(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 VOe=t=>Array.isArray(t.value)?zOe(t.value):t.value,vJ=w.createContext(void 0),QO=vJ.Provider,_J=w.createContext(void 0),GOe=_J.Provider;function qOe(){return w.useContext(vJ)}function WOe(){return w.useContext(_J)}function R1(t){var{valueAccessor:e=VOe}=t,n=w7(t,BOe),{dataKey:r,clockWise:i,id:s,textBreakAll:o,zIndex:l}=n,c=w7(n,$Oe),u=qOe(),d=WOe(),f=u||d;return!f||!f.length?null:w.createElement(es,{zIndex:l??mi.label},w.createElement(ni,{className:"recharts-label-list"},f.map((m,p)=>{var x,b=Gr(r)?e(m,p):gr(m&&m.payload,r),y=Gr(s)?{}:{id:"".concat(s,"-").concat(p)};return w.createElement(Bd,qS({key:"label-".concat(p)},La(m),c,y,{fill:(x=n.fill)!==null&&x!==void 0?x:m.fill,parentViewBox:m.parentViewBox,value:b,textBreakAll:o,viewBox:m.viewBox,index:p,zIndex:0}))})))}R1.displayName="LabelList";function pM(t){var{label:e}=t;return e?e===!0?w.createElement(R1,{key:"labelList-implicit"}):w.isValidElement(e)||YO(e)?w.createElement(R1,{key:"labelList-implicit",content:e}):typeof e=="object"?w.createElement(R1,qS({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function yR(){return yR=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},yR.apply(null,arguments)}var wJ=t=>{var{cx:e,cy:n,r,className:i}=t,s=Zn("recharts-dot",i);return Bt(e)&&Bt(n)&&Bt(r)?w.createElement("circle",yR({},_s(t),S4(t),{className:s,cx:e,cy:n,r})):null},SJ=t=>t.graphicalItems.polarItems,KOe=et([Jr,iv],vO),gM=et([SJ,ii,KOe],_O),XOe=et([gM],wO),xM=et([XOe,uO],SO),YOe=et([xM,ii,gM],MO);et([xM,ii,gM],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var s,o=gr(r,(s=e.dataKey)!==null&&s!==void 0?s:i.dataKey);return{value:o,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:gr(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var S7=()=>{},QOe=et([xM,ii,gM,uM,Jr],AO),ZOe=et([ii,CO,TO,S7,QOe,S7,zn,Jr],kO),NJ=et([ii,zn,xM,YOe,rv,Jr,ZOe],jO),JOe=et([NJ,ii,Px],DO);et([ii,NJ,JOe,Jr],LO);var eLe={radiusAxis:{},angleAxis:{}},MJ=qs({name:"polarAxis",initialState:eLe,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:qYe,removeRadiusAxis:WYe,addAngleAxis:KYe,removeAngleAxis:XYe}=MJ.actions,tLe=MJ.reducer;function N7(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 M7(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?N7(Object(n),!0).forEach(function(r){nLe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):N7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function nLe(t,e,n){return(e=rLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rLe(t){var e=iLe(t,"string");return typeof e=="symbol"?e:e+""}function iLe(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 aLe=(t,e)=>e,ZO=et([SJ,aLe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),sLe=[],JO=(t,e,n)=>n?.length===0?sLe:n,EJ=et([uO,ZO,JO],(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=>M7(M7({},e.presentationProps),s.props))),i!=null)return i}}),oLe=et([EJ,ZO,JO],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var s,o=gr(r,e.nameKey,e.name),l;return n!=null&&(s=n[i])!==null&&s!==void 0&&(s=s.props)!==null&&s!==void 0&&s.fill?l=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?l=r.fill:l=e.fill,{value:Lh(o,e.dataKey),color:l,payload:r,type:e.legendType}})}),lLe=et([EJ,ZO,JO,Ji],(t,e,n,r)=>{if(!(e==null||t==null))return c5e({offset:r,pieSettings:e,displayedData:t,cells:n})}),Kk={exports:{}},wr={};var E7;function cLe(){if(E7)return wr;E7=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"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),m=Symbol.for("react.view_transition"),p=Symbol.for("react.client.reference");function x(b){if(typeof b=="object"&&b!==null){var y=b.$$typeof;switch(y){case t:switch(b=b.type,b){case n:case i:case r:case c:case u:case m:return b;default:switch(b=b&&b.$$typeof,b){case o:case l:case f:case d:return b;case s:return b;default:return y}}case e:return y}}}return wr.ContextConsumer=s,wr.ContextProvider=o,wr.Element=t,wr.ForwardRef=l,wr.Fragment=n,wr.Lazy=f,wr.Memo=d,wr.Portal=e,wr.Profiler=i,wr.StrictMode=r,wr.Suspense=c,wr.SuspenseList=u,wr.isContextConsumer=function(b){return x(b)===s},wr.isContextProvider=function(b){return x(b)===o},wr.isElement=function(b){return typeof b=="object"&&b!==null&&b.$$typeof===t},wr.isForwardRef=function(b){return x(b)===l},wr.isFragment=function(b){return x(b)===n},wr.isLazy=function(b){return x(b)===f},wr.isMemo=function(b){return x(b)===d},wr.isPortal=function(b){return x(b)===e},wr.isProfiler=function(b){return x(b)===i},wr.isStrictMode=function(b){return x(b)===r},wr.isSuspense=function(b){return x(b)===c},wr.isSuspenseList=function(b){return x(b)===u},wr.isValidElementType=function(b){return typeof b=="string"||typeof b=="function"||b===n||b===i||b===r||b===c||b===u||typeof b=="object"&&b!==null&&(b.$$typeof===f||b.$$typeof===d||b.$$typeof===o||b.$$typeof===s||b.$$typeof===l||b.$$typeof===p||b.getModuleId!==void 0)},wr.typeOf=x,wr}var C7;function uLe(){return C7||(C7=1,Kk.exports=cLe()),Kk.exports}var dLe=uLe(),T7=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",A7=null,Xk=null,CJ=t=>{if(t===A7&&Array.isArray(Xk))return Xk;var e=[];return w.Children.forEach(t,n=>{Gr(n)||(dLe.isFragment(n)?e=e.concat(CJ(n.props.children)):e.push(n))}),Xk=e,A7=t,e};function eL(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>T7(i)):r=[T7(e)],CJ(t).forEach(i=>{var s=mm(i,"type.displayName")||mm(i,"type.name");s&&r.indexOf(s)!==-1&&n.push(i)}),n}var tL=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,Yk={},k7;function hLe(){return k7||(k7=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})(Yk)),Yk}var Qk,j7;function fLe(){return j7||(j7=1,Qk=hLe().isPlainObject),Qk}var mLe=fLe();const pLe=ul(mLe);function P7(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 R7(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?P7(Object(n),!0).forEach(function(r){gLe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):P7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gLe(t,e,n){return(e=xLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xLe(t){var e=bLe(t,"string");return typeof e=="symbol"?e:e+""}function bLe(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 WS(){return WS=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},WS.apply(null,arguments)}var D7=(t,e,n,r,i)=>{var s=n-r,o;return o="M ".concat(t,",").concat(e),o+="L ".concat(t+n,",").concat(e),o+="L ".concat(t+n-s/2,",").concat(e+i),o+="L ".concat(t+n-s/2-r,",").concat(e+i),o+="L ".concat(t,",").concat(e," Z"),o},yLe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},vLe=t=>{var e=ri(t,yLe),{x:n,y:r,upperWidth:i,lowerWidth:s,height:o,className:l}=e,{animationEasing:c,animationDuration:u,animationBegin:d,isUpdateAnimationActive:f}=e,m=w.useRef(null),[p,x]=w.useState(-1),b=w.useRef(i),y=w.useRef(s),v=w.useRef(o),S=w.useRef(n),N=w.useRef(r),C=Ex(t,"trapezoid-");if(w.useEffect(()=>{if(m.current&&m.current.getTotalLength)try{var j=m.current.getTotalLength();j&&x(j)}catch{}},[]),n!==+n||r!==+r||i!==+i||s!==+s||o!==+o||i===0&&s===0||o===0)return null;var T=Zn("recharts-trapezoid",l);if(!f)return w.createElement("g",null,w.createElement("path",WS({},La(e),{className:T,d:D7(n,r,i,s,o)})));var k=b.current,E=y.current,D=v.current,A=S.current,R=N.current,F="0px ".concat(p===-1?1:p,"px"),O="".concat(p,"px 0px"),H=XY(["strokeDasharray"],u,c);return w.createElement(Mx,{animationId:C,key:C,canBegin:p>0,duration:u,easing:c,isActive:f,begin:d},j=>{var G=ur(k,i,j),$=ur(E,s,j),q=ur(D,o,j),Y=ur(A,n,j),Z=ur(R,r,j);m.current&&(b.current=G,y.current=$,v.current=q,S.current=Y,N.current=Z);var oe=j>0?{transition:H,strokeDasharray:O}:{strokeDasharray:F};return w.createElement("path",WS({},La(e),{className:T,d:D7(Y,Z,G,$,q),ref:m,style:R7(R7({},oe),e.style)}))})},_Le=["option","shapeType","propTransformer","activeClassName"];function wLe(t,e){if(t==null)return{};var n,r,i=SLe(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 SLe(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 O7(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 KS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?O7(Object(n),!0).forEach(function(r){NLe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):O7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function NLe(t,e,n){return(e=MLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function MLe(t){var e=ELe(t,"string");return typeof e=="symbol"?e:e+""}function ELe(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 CLe(t,e){return KS(KS({},e),t)}function TLe(t,e){return t==="symbols"}function L7(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return w.createElement(JY,n);case"trapezoid":return w.createElement(vLe,n);case"sector":return w.createElement(rQ,n);case"symbols":if(TLe(e))return w.createElement(w4,n);break;case"curve":return w.createElement(Pg,n);default:return null}}function ALe(t){return w.isValidElement(t)?t.props:t}function nL(t){var{option:e,shapeType:n,propTransformer:r=CLe,activeClassName:i="recharts-active-shape"}=t,s=wLe(t,_Le),o;if(w.isValidElement(e))o=w.cloneElement(e,KS(KS({},s),ALe(e)));else if(typeof e=="function")o=e(s,s.index);else if(pLe(e)&&typeof e!="boolean"){var l=r(e,s);o=w.createElement(L7,{shapeType:n,elementProps:l})}else{var c=s;o=w.createElement(L7,{shapeType:n,elementProps:c})}return s.isActive?w.createElement(ni,{className:i},o):o}var rL=(t,e,n)=>{var r=Or();return(i,s)=>o=>{t?.(i,s,o),r(FZ({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},iL=t=>{var e=Or();return(n,r)=>i=>{t?.(n,r,i),e(VRe())}},aL=(t,e,n)=>{var r=Or();return(i,s)=>o=>{t?.(i,s,o),r(GRe({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function bM(t){var{tooltipEntrySettings:e}=t,n=Or(),r=ea(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(zRe(e)):i.current!==e&&n(BRe({prev:i.current,next:e})),i.current=e)},[e,n,r]),w.useLayoutEffect(()=>()=>{i.current&&(n($Re(i.current)),i.current=null)},[n]),null}function sL(t){var{legendPayload:e}=t,n=Or(),r=ea(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(GY(e)):i.current!==e&&n(qY({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(WY(i.current)),i.current=null)},[n]),null}function kLe(t){var{legendPayload:e}=t,n=Or(),r=Ut(zn),i=w.useRef(null);return w.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(GY(e)):i.current!==e&&n(qY({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(WY(i.current)),i.current=null)},[n]),null}var Zk,jLe=()=>{var[t]=w.useState(()=>ay("uid-"));return t},PLe=(Zk=zae.useId)!==null&&Zk!==void 0?Zk:jLe;function TJ(t,e){var n=PLe();return e||(t?"".concat(t,"-").concat(n):n)}var RLe=w.createContext(void 0),yM=t=>{var{id:e,type:n,children:r}=t,i=TJ("recharts-".concat(n),e);return w.createElement(RLe.Provider,{value:i},r(i))},DLe={cartesianItems:[],polarItems:[]},AJ=qs({name:"graphicalItems",initialState:DLe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:Wr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ol(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:Wr()},removeCartesianGraphicalItem:{reducer(t,e){var n=Ol(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:Wr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:Wr()},removePolarGraphicalItem:{reducer(t,e){var n=Ol(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:Wr()}}}),{addCartesianGraphicalItem:OLe,replaceCartesianGraphicalItem:LLe,removeCartesianGraphicalItem:ILe,addPolarGraphicalItem:FLe,removePolarGraphicalItem:ULe}=AJ.actions,zLe=AJ.reducer,BLe=t=>{var e=Or(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(OLe(t)):n.current!==t&&e(LLe({prev:n.current,next:t})),n.current=t},[e,t]),w.useLayoutEffect(()=>()=>{n.current&&(e(ILe(n.current)),n.current=null)},[e]),null},oL=w.memo(BLe);function $Le(t){var e=Or();return w.useLayoutEffect(()=>(e(FLe(t)),()=>{e(ULe(t))}),[e,t]),null}var HLe=["key"],VLe=["onMouseEnter","onClick","onMouseLeave"],GLe=["id"],qLe=["id"];function I7(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 di(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?I7(Object(n),!0).forEach(function(r){WLe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):I7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function WLe(t,e,n){return(e=KLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function KLe(t){var e=XLe(t,"string");return typeof e=="symbol"?e:e+""}function XLe(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 Ah(){return Ah=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},Ah.apply(null,arguments)}function vM(t,e){if(t==null)return{};var n,r,i=YLe(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 YLe(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 QLe(t){var e=w.useMemo(()=>eL(t.children,mv),[t.children]),n=Ut(r=>oLe(r,t.id,e));return n==null?null:w.createElement(kLe,{legendPayload:n})}var ZLe=w.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:s,fill:o,name:l,hide:c,tooltipType:u}=t,d={dataDefinedOnItem:r.map(f=>f.tooltipPayload),positions:r.map(f=>f.tooltipPosition),settings:{stroke:i,strokeWidth:s,fill:o,dataKey:e,nameKey:n,name:Lh(l,e),hide:c,type:u,color:o,unit:""}};return w.createElement(bM,{tooltipEntrySettings:d})}),JLe=(t,e)=>t>e?"start":t<e?"end":"middle",e5e=(t,e,n)=>Za(typeof e=="function"?e(t):e,n,n*.8),t5e=(t,e,n)=>{var{top:r,left:i,width:s,height:o}=e,l=eQ(s,o),c=i+Za(t.cx,s,s/2),u=r+Za(t.cy,o,o/2),d=Za(t.innerRadius,l,0),f=e5e(n,t.outerRadius,l),m=t.maxRadius||Math.sqrt(s*s+o*o)/2;return{cx:c,cy:u,innerRadius:d,outerRadius:f,maxRadius:m}},n5e=(t,e)=>{var n=ga(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function r5e(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var i5e=(t,e)=>{if(w.isValidElement(t))return w.cloneElement(t,e);if(typeof t=="function")return t(e);var n=Zn("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=vM(e,HLe);return w.createElement(Pg,Ah({},i,{type:"linear",className:n}))},a5e=(t,e,n)=>{if(w.isValidElement(t))return w.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),w.isValidElement(r)))return r;var i=Zn("recharts-pie-label-text",r5e(t));return w.createElement(mM,Ah({},e,{alignmentBaseline:"middle",className:i}),r)};function s5e(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:s,dataKey:o}=n;if(!r||!i||!e)return null;var l=_s(n),c=fm(i),u=fm(s),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,f=e.map((m,p)=>{var x=(m.startAngle+m.endAngle)/2,b=Oi(m.cx,m.cy,m.outerRadius+d,x),y=di(di(di(di({},l),m),{},{stroke:"none"},c),{},{index:p,textAnchor:JLe(b.x,m.cx)},b),v=di(di(di(di({},l),m),{},{fill:"none",stroke:m.fill},u),{},{index:p,points:[Oi(m.cx,m.cy,m.outerRadius,x),b],key:"line"});return w.createElement(es,{zIndex:mi.label,key:"label-".concat(m.startAngle,"-").concat(m.endAngle,"-").concat(m.midAngle,"-").concat(p)},w.createElement(ni,null,s&&i5e(s,v),a5e(i,y,gr(m,o))))});return w.createElement(ni,{className:"recharts-pie-labels"},f)}function o5e(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?w.createElement(pM,{label:i}):w.createElement(s5e,{sectors:e,props:n,showLabels:r})}function l5e(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:s,id:o}=t,l=Ut(Th),c=Ut(GO),u=Ut(kDe),{onMouseEnter:d,onClick:f,onMouseLeave:m}=i,p=vM(i,VLe),x=rL(d,i.dataKey,o),b=iL(m),y=aL(f,i.dataKey,o);return e==null||e.length===0?null:w.createElement(w.Fragment,null,e.map((v,S)=>{if(v?.startAngle===0&&v?.endAngle===0&&e.length!==1)return null;var N=u==null||u===o,C=String(S)===l&&(c==null||i.dataKey===c)&&N,T=l?r:null,k=n&&C?n:T,E=di(di({},v),{},{stroke:v.stroke,tabIndex:-1,[jY]:S,[PY]:i.dataKey});return w.createElement(ni,Ah({key:"sector-".concat(v?.startAngle,"-").concat(v?.endAngle,"-").concat(v.midAngle,"-").concat(S),tabIndex:-1,className:"recharts-pie-sector"},Gy(p,v,S),{onMouseEnter:x(v,S),onMouseLeave:b(v,S),onClick:y(v,S)}),w.createElement(nL,Ah({option:s??k,index:S,shapeType:"sector",isActive:C},E)))}))}function c5e(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:s}=t,{cornerRadius:o,startAngle:l,endAngle:c,dataKey:u,nameKey:d,tooltipType:f}=n,m=Math.abs(n.minAngle),p=n5e(l,c),x=Math.abs(p),b=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,y=r.filter(k=>gr(k,u,0)!==0).length,v=(x>=360?y:y-1)*b,S=x-y*m-v,N=r.reduce((k,E)=>{var D=gr(E,u,0);return k+(Bt(D)?D:0)},0),C;if(N>0){var T;C=r.map((k,E)=>{var D=gr(k,u,0),A=gr(k,d,E),R=t5e(n,s,k),F=(Bt(D)?D:0)/N,O,H=di(di({},k),i&&i[E]&&i[E].props);E?O=T.endAngle+ga(p)*b*(D!==0?1:0):O=l;var j=O+ga(p)*((D!==0?m:0)+F*S),G=(O+j)/2,$=(R.innerRadius+R.outerRadius)/2,q=[{name:A,value:D,payload:H,dataKey:u,type:f}],Y=Oi(R.cx,R.cy,$,G);return T=di(di(di(di({},n.presentationProps),{},{percent:F,cornerRadius:typeof o=="string"?parseFloat(o):o,name:A,tooltipPayload:q,midAngle:G,middleRadius:$,tooltipPosition:Y},H),R),{},{value:D,dataKey:u,startAngle:O,endAngle:j,payload:H,paddingAngle:ga(p)*b}),T})}return C}function u5e(t){var{showLabels:e,sectors:n,children:r}=t,i=w.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 w.createElement(GOe,{value:e?i:void 0},r)}function d5e(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:s,animationBegin:o,animationDuration:l,animationEasing:c,activeShape:u,inactiveShape:d,onAnimationStart:f,onAnimationEnd:m}=e,p=Ex(e,"recharts-pie-"),x=n.current,[b,y]=w.useState(!1),v=w.useCallback(()=>{typeof m=="function"&&m(),y(!1)},[m]),S=w.useCallback(()=>{typeof f=="function"&&f(),y(!0)},[f]);return w.createElement(u5e,{showLabels:!b,sectors:i},w.createElement(Mx,{animationId:p,begin:o,duration:l,isActive:s,easing:c,onAnimationStart:S,onAnimationEnd:v,key:p},N=>{var C=[],T=i&&i[0],k=T?.startAngle;return i?.forEach((E,D)=>{var A=x&&x[D],R=D>0?mm(E,"paddingAngle",0):0;if(A){var F=ur(A.endAngle-A.startAngle,E.endAngle-E.startAngle,N),O=di(di({},E),{},{startAngle:k+R,endAngle:k+F+R});C.push(O),k=O.endAngle}else{var{endAngle:H,startAngle:j}=E,G=ur(0,H-j,N),$=di(di({},E),{},{startAngle:k+R,endAngle:k+G+R});C.push($),k=$.endAngle}}),n.current=C,w.createElement(ni,null,w.createElement(l5e,{sectors:C,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),w.createElement(o5e,{showLabels:!b,sectors:i,props:e}),e.children)}var h5e={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:mi.area};function f5e(t){var{id:e}=t,n=vM(t,GLe),{hide:r,className:i,rootTabIndex:s}=t,o=w.useMemo(()=>eL(t.children,mv),[t.children]),l=Ut(d=>lLe(d,e,o)),c=w.useRef(null),u=Zn("recharts-pie",i);return r||l==null?(c.current=null,w.createElement(ni,{tabIndex:s,className:u})):w.createElement(es,{zIndex:t.zIndex},w.createElement(ZLe,{dataKey:t.dataKey,nameKey:t.nameKey,sectors:l,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,tooltipType:t.tooltipType}),w.createElement(ni,{tabIndex:s,className:u},w.createElement(d5e,{props:di(di({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function kJ(t){var e=ri(t,h5e),{id:n}=e,r=vM(e,qLe),i=_s(r);return w.createElement(yM,{id:n,type:"pie"},s=>w.createElement(w.Fragment,null,w.createElement($Le,{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}),w.createElement(QLe,Ah({},r,{id:s})),w.createElement(f5e,Ah({},r,{id:s}))))}kJ.displayName="Pie";var m5e=["points"];function F7(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 Jk(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?F7(Object(n),!0).forEach(function(r){p5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):F7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function p5e(t,e,n){return(e=g5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function g5e(t){var e=x5e(t,"string");return typeof e=="symbol"?e:e+""}function x5e(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 XS(){return XS=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},XS.apply(null,arguments)}function b5e(t,e){if(t==null)return{};var n,r,i=y5e(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 y5e(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 v5e(t){var{option:e,dotProps:n,className:r}=t;if(w.isValidElement(e))return w.cloneElement(e,n);if(typeof e=="function")return e(n);var i=Zn(r,typeof e!="boolean"?e.className:""),s=n??{},{points:o}=s,l=b5e(s,m5e);return w.createElement(wJ,XS({},l,{className:i}))}function _5e(t,e){return t==null?!1:e?!0:t.length===1}function jJ(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:s,baseProps:o,needClip:l,clipPathId:c,zIndex:u=mi.scatter}=t;if(!_5e(e,n))return null;var d=tL(n),f=ZNe(n),m=e.map((x,b)=>{var y,v,S=Jk(Jk(Jk({r:3},o),f),{},{index:b,cx:(y=x.x)!==null&&y!==void 0?y:void 0,cy:(v=x.y)!==null&&v!==void 0?v:void 0,dataKey:s,value:x.value,payload:x.payload,points:e});return w.createElement(v5e,{key:"dot-".concat(b),option:n,dotProps:S,className:i})}),p={};return l&&c!=null&&(p.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(c,")")),w.createElement(es,{zIndex:u},w.createElement(ni,XS({className:r},p),m))}function U7(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 z7(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?U7(Object(n),!0).forEach(function(r){w5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):U7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function w5e(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=N5e(t,"string");return typeof e=="symbol"?e:e+""}function N5e(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 M5e={xAxis:{},yAxis:{},zAxis:{}},PJ=qs({name:"cartesianAxis",initialState:M5e,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:Wr()},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:Wr()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:Wr()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:Wr()},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:Wr()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:Wr()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:Wr()},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:Wr()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:Wr()},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 o=[...s,r].slice(-3);t.yAxis[n]=z7(z7({},t.yAxis[n]),{},{width:r,widthHistory:o})}}}}),{addXAxis:E5e,replaceXAxis:C5e,removeXAxis:T5e,addYAxis:A5e,replaceYAxis:k5e,removeYAxis:j5e,addZAxis:YYe,replaceZAxis:QYe,removeZAxis:ZYe,updateYAxisWidth:P5e}=PJ.actions,R5e=PJ.reducer,D5e=et([Ji],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),O5e=et([D5e,Gu,qu],(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)}}),_M=()=>Ut(O5e),L5e=()=>Ut(ODe);function B7(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 ej(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?B7(Object(n),!0).forEach(function(r){I5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):B7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function I5e(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=U5e(t,"string");return typeof e=="symbol"?e:e+""}function U5e(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 z5e=t=>{var{point:e,childIndex:n,mainColor:r,activeDot:i,dataKey:s,clipPath:o}=t;if(i===!1||e.x==null||e.y==null)return null;var l={index:n,dataKey:s,cx:e.x,cy:e.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:e.payload,value:e.value},c=ej(ej(ej({},l),fm(i)),S4(i)),u;return w.isValidElement(i)?u=w.cloneElement(i,c):typeof i=="function"?u=i(c):u=w.createElement(wJ,c),w.createElement(ni,{className:"recharts-active-dot",clipPath:o},u)};function vR(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:s,zIndex:o=mi.activeDot}=t,l=Ut(Th),c=L5e();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return Gr(u)?null:w.createElement(es,{zIndex:o},w.createElement(z5e,{point:u,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:s}))}var B5e="Invariant failed";function $5e(t,e){throw new Error(B5e)}var H5e=["x","y"];function _R(){return _R=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},_R.apply(null,arguments)}function $7(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Jb(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$7(Object(n),!0).forEach(function(r){V5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function V5e(t,e,n){return(e=G5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function G5e(t){var e=q5e(t,"string");return typeof e=="symbol"?e:e+""}function q5e(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 W5e(t,e){if(t==null)return{};var n,r,i=K5e(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 K5e(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 X5e(t,e){var{x:n,y:r}=t,i=W5e(t,H5e),s="".concat(n),o=parseInt(s,10),l="".concat(r),c=parseInt(l,10),u="".concat(e.height||i.height),d=parseInt(u,10),f="".concat(e.width||i.width),m=parseInt(f,10);return Jb(Jb(Jb(Jb(Jb({},e),i),o?{x:o}:{}),c?{y:c}:{}),{},{height:d,width:m,name:e.name,radius:e.radius})}function YS(t){return w.createElement(nL,_R({shapeType:"rectangle",propTransformer:X5e,activeClassName:"recharts-active-bar"},t))}var Y5e=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Bt(e))return e;var s=Bt(r)||Gr(r);return s?e(r,i):(s||$5e(),n)}},Q5e={},RJ=qs({name:"errorBars",initialState:Q5e,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:JYe,replaceErrorBar:eQe,removeErrorBar:tQe}=RJ.actions,Z5e=RJ.reducer,J5e=["children"];function eIe(t,e){if(t==null)return{};var n,r,i=tIe(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 tIe(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 nIe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},rIe=w.createContext(nIe);function DJ(t){var{children:e}=t,n=eIe(t,J5e);return w.createElement(rIe.Provider,{value:n},e)}function wM(t,e){var n,r,i=Ut(u=>Cc(u,t)),s=Ut(u=>Tc(u,e)),o=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:ua.allowDataOverflow,l=(r=s?.allowDataOverflow)!==null&&r!==void 0?r:da.allowDataOverflow,c=o||l;return{needClip:c,needClipX:o,needClipY:l}}function lL(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=_M(),{needClipX:s,needClipY:o,needClip:l}=wM(e,n);if(!l||!i)return null;var{x:c,y:u,width:d,height:f}=i;return w.createElement("clipPath",{id:"clipPath-".concat(r)},w.createElement("rect",{x:s?c:c-d/2,y:o?u:u-f/2,width:s?d:d*2,height:o?f:f*2}))}function iIe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&xr(t.zIndex)?t.zIndex:e}var tj={exports:{}},nj={};var H7;function aIe(){if(H7)return nj;H7=1;var t=px();function e(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,i=t.useRef,s=t.useEffect,o=t.useMemo,l=t.useDebugValue;return nj.useSyncExternalStoreWithSelector=function(c,u,d,f,m){var p=i(null);if(p.current===null){var x={hasValue:!1,value:null};p.current=x}else x=p.current;p=o(function(){function y(T){if(!v){if(v=!0,S=T,T=f(T),m!==void 0&&x.hasValue){var k=x.value;if(m(k,T))return N=k}return N=T}if(k=N,n(S,T))return k;var E=f(T);return m!==void 0&&m(k,E)?(S=T,k):(S=T,N=E)}var v=!1,S,N,C=d===void 0?null:d;return[function(){return y(u())},C===null?void 0:function(){return y(C())}]},[u,d,f,m]);var b=r(c,p[0],p[1]);return s(function(){x.hasValue=!0,x.value=b},[b]),l(b),b},nj}var V7;function sIe(){return V7||(V7=1,tj.exports=aIe()),tj.exports}sIe();function oIe(t){t()}function lIe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){oIe(()=>{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 G7={notify(){},get:()=>[]};function cIe(t,e){let n,r=G7,i=0,s=!1;function o(b){d();const y=r.subscribe(b);let v=!1;return()=>{v||(v=!0,y(),f())}}function l(){r.notify()}function c(){x.onStateChange&&x.onStateChange()}function u(){return s}function d(){i++,n||(n=t.subscribe(c),r=lIe())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=G7)}function m(){s||(s=!0,d())}function p(){s&&(s=!1,f())}const x={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:u,trySubscribe:m,tryUnsubscribe:p,getListeners:()=>r};return x}var uIe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",dIe=uIe(),hIe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",fIe=hIe(),mIe=()=>dIe||fIe?w.useLayoutEffect:w.useEffect,pIe=mIe();function q7(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function gIe(t,e){if(q7(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])||!q7(t[n[i]],e[n[i]]))return!1;return!0}var xIe=Symbol.for("react-redux-context"),bIe=typeof globalThis<"u"?globalThis:{};function yIe(){if(!w.createContext)return{};const t=bIe[xIe]??=new Map;let e=t.get(w.createContext);return e||(e=w.createContext(null),t.set(w.createContext,e)),e}var vIe=yIe();function _Ie(t){const{children:e,context:n,serverState:r,store:i}=t,s=w.useMemo(()=>{const c=cIe(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),o=w.useMemo(()=>i.getState(),[i]);pIe(()=>{const{subscription:c}=s;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),o!==i.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[s,o]);const l=n||vIe;return w.createElement(l.Provider,{value:s},e)}var wIe=_Ie,SIe=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function NIe(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function pv(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(SIe.has(r)){if(t[r]==null&&e[r]==null)continue;if(!gIe(t[r],e[r]))return!1}else if(!NIe(t[r],e[r]))return!1;return!0}var MIe=["onMouseEnter","onMouseLeave","onClick"],EIe=["value","background","tooltipPosition"],CIe=["id"],TIe=["onMouseEnter","onClick","onMouseLeave"];function Hu(){return Hu=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},Hu.apply(null,arguments)}function W7(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function hs(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?W7(Object(n),!0).forEach(function(r){AIe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):W7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function AIe(t,e,n){return(e=kIe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function kIe(t){var e=jIe(t,"string");return typeof e=="symbol"?e:e+""}function jIe(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 QS(t,e){if(t==null)return{};var n,r,i=PIe(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 PIe(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 RIe=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:s}=t;return[{inactive:s,dataKey:e,type:i,color:r,value:Lh(n,e),payload:t}]},DIe=w.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:s,hide:o,unit:l,tooltipType:c}=t,u={dataDefinedOnItem:void 0,positions:void 0,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:Lh(s,e),hide:o,type:c,color:i,unit:l}};return w.createElement(bM,{tooltipEntrySettings:u})});function OIe(t){var e=Ut(Th),{data:n,dataKey:r,background:i,allOtherBarProps:s}=t,{onMouseEnter:o,onMouseLeave:l,onClick:c}=s,u=QS(s,MIe),d=rL(o,r),f=iL(l),m=aL(c,r);if(!i||n==null)return null;var p=fm(i);return w.createElement(es,{zIndex:iIe(i,mi.barBackground)},n.map((x,b)=>{var{value:y,background:v,tooltipPosition:S}=x,N=QS(x,EIe);if(!v)return null;var C=d(x,b),T=f(x,b),k=m(x,b),E=hs(hs(hs(hs(hs({option:i,isActive:String(b)===e},N),{},{fill:"#eee"},v),p),Gy(u,x,b)),{},{onMouseEnter:C,onMouseLeave:T,onClick:k,dataKey:r,index:b,className:"recharts-bar-background-rectangle"});return w.createElement(YS,Hu({key:"background-bar-".concat(b)},E))}))}function LIe(t){var{showLabels:e,children:n,rects:r}=t,i=r?.map(s=>{var o={x:s.x,y:s.y,width:s.width,lowerWidth:s.width,upperWidth:s.width,height:s.height};return hs(hs({},o),{},{value:s.value,payload:s.payload,parentViewBox:s.parentViewBox,viewBox:o,fill:s.fill})});return w.createElement(QO,{value:e?i:void 0},n)}function IIe(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:s,dataKey:o}=t,l=Ut(Th),c=Ut(GO),u=n&&String(s)===l&&(c==null||o===c),d=u?n:e;return u?w.createElement(es,{zIndex:mi.activeBar},w.createElement(YS,Hu({},r,{name:String(r.name)},i,{isActive:u,option:d,index:s,dataKey:o}))):w.createElement(YS,Hu({},r,{name:String(r.name)},i,{isActive:u,option:d,index:s,dataKey:o}))}function FIe(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:s}=t;return w.createElement(YS,Hu({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:s}))}function UIe(t){var e,{data:n,props:r}=t,i=(e=_s(r))!==null&&e!==void 0?e:{},{id:s}=i,o=QS(i,CIe),{shape:l,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:m}=r,p=QS(r,TIe),x=rL(d,c),b=iL(m),y=aL(f,c);return n?w.createElement(w.Fragment,null,n.map((v,S)=>w.createElement(ni,Hu({key:"rectangle-".concat(v?.x,"-").concat(v?.y,"-").concat(v?.value,"-").concat(S),className:"recharts-bar-rectangle"},Gy(p,v,S),{onMouseEnter:x(v,S),onMouseLeave:b(v,S),onClick:y(v,S)}),u?w.createElement(IIe,{shape:l,activeBar:u,baseProps:o,entry:v,index:S,dataKey:c}):w.createElement(FIe,{shape:l,baseProps:o,entry:v,index:S,dataKey:c})))):null}function zIe(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:s,animationBegin:o,animationDuration:l,animationEasing:c,onAnimationEnd:u,onAnimationStart:d}=e,f=n.current,m=Ex(e,"recharts-bar-"),[p,x]=w.useState(!1),b=!p,y=w.useCallback(()=>{typeof u=="function"&&u(),x(!1)},[u]),v=w.useCallback(()=>{typeof d=="function"&&d(),x(!0)},[d]);return w.createElement(LIe,{showLabels:b,rects:r},w.createElement(Mx,{animationId:m,begin:o,duration:l,isActive:s,easing:c,onAnimationEnd:y,onAnimationStart:v,key:m},S=>{var N=S===1?r:r?.map((C,T)=>{var k=f&&f[T];if(k)return hs(hs({},C),{},{x:ur(k.x,C.x,S),y:ur(k.y,C.y,S),width:ur(k.width,C.width,S),height:ur(k.height,C.height,S)});if(i==="horizontal"){var E=ur(0,C.height,S),D=ur(C.stackedBarStart,C.y,S);return hs(hs({},C),{},{y:D,height:E})}var A=ur(0,C.width,S),R=ur(C.stackedBarStart,C.x,S);return hs(hs({},C),{},{width:A,x:R})});return S>0&&(n.current=N??null),N==null?null:w.createElement(ni,null,w.createElement(UIe,{props:e,data:N}))}),w.createElement(pM,{label:e.label}),e.children)}function BIe(t){var e=w.useRef(null);return w.createElement(zIe,{previousRectanglesRef:e,props:t})}var OJ=0,$Ie=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:gr(t,e)}};class HIe extends w.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:s,yAxisId:o,needClip:l,background:c,id:u}=this.props;if(e||n==null)return null;var d=Zn("recharts-bar",i),f=u;return w.createElement(ni,{className:d,id:u},l&&w.createElement("defs",null,w.createElement(lL,{clipPathId:f,xAxisId:s,yAxisId:o})),w.createElement(ni,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(f,")"):void 0},w.createElement(OIe,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),w.createElement(BIe,this.props)))}}var VIe={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:OJ,xAxisId:0,yAxisId:0,zIndex:mi.bar};function GIe(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d}=t,{needClip:f}=wM(e,n),m=Tm(),p=ea(),x=eL(t.children,mv),b=Ut(S=>yFe(S,e,n,p,t.id,x));if(m!=="vertical"&&m!=="horizontal")return null;var y,v=b?.[0];return v==null||v.height==null||v.width==null?y=0:y=m==="vertical"?v.height/2:v.width/2,w.createElement(DJ,{xAxisId:e,yAxisId:n,data:b,dataPointFormatter:$Ie,errorBarOffset:y},w.createElement(HIe,Hu({},t,{layout:m,needClip:f,data:b,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d})))}function qIe(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:s,xAxis:o,yAxis:l,xAxisTicks:c,yAxisTicks:u,stackedData:d,displayedData:f,offset:m,cells:p,parentViewBox:x,dataStartIndex:b}=t,y=e==="horizontal"?l:o,v=d?y.scale.domain():null,S=pTe({numericAxis:y}),N=y.scale(S);return f.map((C,T)=>{var k,E,D,A,R,F;d?k=uTe(d[T+b],v):(k=gr(C,n),Array.isArray(k)||(k=[S,k]));var O=Y5e(r,OJ)(k[1],T);if(e==="horizontal"){var H,[j,G]=[l.scale(k[0]),l.scale(k[1])];E=uH({axis:o,ticks:c,bandSize:s,offset:i.offset,entry:C,index:T}),D=(H=G??j)!==null&&H!==void 0?H:void 0,A=i.size;var $=j-G;if(R=Gs($)?0:$,F={x:E,y:m.top,width:A,height:m.height},Math.abs(O)>0&&Math.abs(R)<Math.abs(O)){var q=ga(R||O)*(Math.abs(O)-Math.abs(R));D-=q,R+=q}}else{var[Y,Z]=[o.scale(k[0]),o.scale(k[1])];if(E=Y,D=uH({axis:l,ticks:u,bandSize:s,offset:i.offset,entry:C,index:T}),A=Z-Y,R=i.size,F={x:m.left,y:D,width:m.width,height:R},Math.abs(O)>0&&Math.abs(A)<Math.abs(O)){var oe=ga(A||O)*(Math.abs(O)-Math.abs(A));A+=oe}}if(E==null||D==null||A==null||R==null)return null;var B=hs(hs({},C),{},{stackedBarStart:N,x:E,y:D,width:A,height:R,value:d?k:k[1],payload:C,background:F,tooltipPosition:{x:E+A/2,y:D+R/2},parentViewBox:x},p&&p[T]&&p[T].props);return B}).filter(Boolean)}function WIe(t){var e=ri(t,VIe),n=ea();return w.createElement(yM,{id:e.id,type:"bar"},r=>w.createElement(w.Fragment,null,w.createElement(sL,{legendPayload:RIe(e)}),w.createElement(DIe,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),w.createElement(oL,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:AY(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),w.createElement(es,{zIndex:e.zIndex},w.createElement(GIe,Hu({},e,{id:r})))))}var LJ=w.memo(WIe,pv);LJ.displayName="Bar";function K7(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 Yw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?K7(Object(n),!0).forEach(function(r){KIe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):K7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function KIe(t,e,n){return(e=XIe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function XIe(t){var e=YIe(t,"string");return typeof e=="symbol"?e:e+""}function YIe(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 QIe=(t,e)=>e,ZIe=(t,e,n)=>n,JIe=(t,e,n,r)=>r,eFe=(t,e,n,r,i)=>i,gv=et([sv,eFe],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),tFe=et([gv],t=>t?.maxBarSize),nFe=(t,e,n,r,i,s)=>s,X7=(t,e,n)=>{var r=n??t;if(!Gr(r))return Za(r,e,0)},rFe=et([zn,sv,QIe,ZIe,JIe],(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")),iFe=(t,e,n,r)=>{var i=zn(t);return i==="horizontal"?by(t,"yAxis",n,r):by(t,"xAxis",e,r)},aFe=(t,e,n)=>{var r=zn(t);return r==="horizontal"?HV(t,"xAxis",e):HV(t,"yAxis",n)},sFe=(t,e,n)=>{var r={},i=t.filter(sM),s=t.filter(u=>u.stackId==null),o=i.reduce((u,d)=>(u[d.stackId]||(u[d.stackId]=[]),u[d.stackId].push(d),u),r),l=Object.entries(o).map(u=>{var[d,f]=u,m=f.map(x=>x.dataKey),p=X7(e,n,f[0].barSize);return{stackId:d,dataKeys:m,barSize:p}}),c=s.map(u=>{var d=[u.dataKey].filter(m=>m!=null),f=X7(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...l,...c]},oFe=et([rFe,PPe,aFe],sFe),lFe=(t,e,n,r,i)=>{var s,o,l=gv(t,e,n,r,i);if(l!=null){var c=zn(t),u=JQ(t),{maxBarSize:d}=l,f=Gr(d)?u:d,m,p;return c==="horizontal"?(m=vc(t,"xAxis",e,r),p=yc(t,"xAxis",e,r)):(m=vc(t,"yAxis",n,r),p=yc(t,"yAxis",n,r)),(s=(o=Mh(m,p,!0))!==null&&o!==void 0?o:f)!==null&&s!==void 0?s:0}},IJ=(t,e,n,r)=>{var i=zn(t),s,o;return i==="horizontal"?(s=vc(t,"xAxis",e,r),o=yc(t,"xAxis",e,r)):(s=vc(t,"yAxis",n,r),o=yc(t,"yAxis",n,r)),Mh(s,o)};function cFe(t,e,n,r,i){var s=r.length;if(!(s<1)){var o=Za(t,n,0,!0),l,c=[];if(xr(r[0].barSize)){var u=!1,d=n/s,f=r.reduce((v,S)=>v+(S.barSize||0),0);f+=(s-1)*o,f>=n&&(f-=(s-1)*o,o=0),f>=n&&d>0&&(u=!0,d*=.9,f=s*d);var m=(n-f)/2>>0,p={offset:m-o,size:0};l=r.reduce((v,S)=>{var N,C={stackId:S.stackId,dataKeys:S.dataKeys,position:{offset:p.offset+p.size+o,size:u?d:(N=S.barSize)!==null&&N!==void 0?N:0}},T=[...v,C];return p=T[T.length-1].position,T},c)}else{var x=Za(e,n,0,!0);n-2*x-(s-1)*o<=0&&(o=0);var b=(n-2*x-(s-1)*o)/s;b>1&&(b>>=0);var y=xr(i)?Math.min(b,i):b;l=r.reduce((v,S,N)=>[...v,{stackId:S.stackId,dataKeys:S.dataKeys,position:{offset:x+(b+o)*N+(b-y)/2,size:y}}],c)}return l}}var uFe=(t,e,n,r,i,s,o)=>{var l=Gr(o)?e:o,c=cFe(n,r,i!==s?i:s,t,l);return i!==s&&c!=null&&(c=c.map(u=>Yw(Yw({},u),{},{position:Yw(Yw({},u.position),{},{offset:u.position.offset-i/2})}))),c},dFe=et([oFe,JQ,jPe,eZ,lFe,IJ,tFe],uFe),hFe=(t,e,n,r)=>vc(t,"xAxis",e,r),fFe=(t,e,n,r)=>vc(t,"yAxis",n,r),mFe=(t,e,n,r)=>yc(t,"xAxis",e,r),pFe=(t,e,n,r)=>yc(t,"yAxis",n,r),gFe=et([dFe,gv],(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}}),xFe=(t,e)=>{var n=aM(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(o=>o.key===n)}}}},bFe=et([iFe,gv],xFe),yFe=et([Ji,D4,hFe,fFe,mFe,pFe,gFe,zn,nv,IJ,bFe,gv,nFe],(t,e,n,r,i,s,o,l,c,u,d,f,m)=>{var{chartData:p,dataStartIndex:x,dataEndIndex:b}=c;if(!(f==null||o==null||e==null||l!=="horizontal"&&l!=="vertical"||n==null||r==null||i==null||s==null||u==null)){var{data:y}=f,v;if(y!=null&&y.length>0?v=y:v=p?.slice(x,b+1),v!=null)return qIe({layout:l,barSettings:f,pos:o,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:s,stackedData:d,displayedData:v,offset:t,cells:m,dataStartIndex:x})}}),FJ=t=>{var{chartData:e}=t,n=Or(),r=ea();return w.useEffect(()=>r?()=>{}:(n(n7(e)),()=>{n(n7(void 0))}),[e,n,r]),null},Y7={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},UJ=qs({name:"brush",initialState:Y7,reducers:{setBrushSettings(t,e){return e.payload==null?Y7:e.payload}}}),{setBrushSettings:nQe}=UJ.actions,vFe=UJ.reducer;function Q7(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 Qw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Q7(Object(n),!0).forEach(function(r){zJ(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Q7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function zJ(t,e,n){return(e=_Fe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _Fe(t){var e=wFe(t,"string");return typeof e=="symbol"?e:e+""}function wFe(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 SFe=(t,e)=>{var{x:n,y:r}=t,{x:i,y:s}=e;return{x:Math.min(n,i),y:Math.min(r,s),width:Math.abs(i-n),height:Math.abs(s-r)}},NFe=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return SFe({x:e,y:n},{x:r,y:i})};class SM{static create(e){return new SM(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 o=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+o}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}}zJ(SM,"EPS",1e-4);var MFe=t=>{var e=Object.keys(t).reduce((n,r)=>Qw(Qw({},n),{},{[r]:SM.create(t[r])}),{});return Qw(Qw({},e),{},{apply(n){var{bandAware:r,position:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Object.fromEntries(Object.entries(n).map(s=>{var[o,l]=s;return[o,e[o].apply(l,{bandAware:r,position:i})]}))},isInRange(n){return Object.keys(n).every(r=>e[r].isInRange(n[r]))}})};function EFe(t){return(t%180+180)%180}var CFe=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=EFe(i),o=s*Math.PI/180,l=Math.atan(r/n),c=o>l&&o<Math.PI-l?r/Math.sin(o):n/Math.cos(o);return Math.abs(c)},TFe={dots:[],areas:[],lines:[]},BJ=qs({name:"referenceElements",initialState:TFe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=Ol(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=Ol(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=Ol(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:rQe,removeDot:iQe,addArea:aQe,removeArea:sQe,addLine:AFe,removeLine:kFe}=BJ.actions,jFe=BJ.reducer,$J=w.createContext(void 0),PFe=t=>{var{children:e}=t,[n]=w.useState("".concat(ay("recharts"),"-clip")),r=_M();if(r==null)return null;var{x:i,y:s,width:o,height:l}=r;return w.createElement($J.Provider,{value:n},w.createElement("defs",null,w.createElement("clipPath",{id:n},w.createElement("rect",{x:i,y:s,height:l,width:o}))),e)},RFe=()=>w.useContext($J);function Z7(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 J7(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Z7(Object(n),!0).forEach(function(r){DFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Z7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function DFe(t,e,n){return(e=OFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function OFe(t){var e=LFe(t,"string");return typeof e=="symbol"?e:e+""}function LFe(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 ZS(){return ZS=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},ZS.apply(null,arguments)}var IFe=(t,e)=>{var n;if(w.isValidElement(t))n=w.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!xr(e.x1)||!xr(e.y1)||!xr(e.x2)||!xr(e.y2))return null;n=w.createElement("line",ZS({},e,{className:"recharts-reference-line-line"}))}return n},FFe=(t,e,n,r,i,s)=>{var{x:o,width:l}=s,c=i.y.apply(t,{position:n});if(Gs(c)||e==="discard"&&!i.y.isInRange(c))return null;var u=[{x:o+l,y:c},{x:o,y:c}];return r==="left"?u.reverse():u},UFe=(t,e,n,r,i,s)=>{var{y:o,height:l}=s,c=i.x.apply(t,{position:n});if(Gs(c)||e==="discard"&&!i.x.isInRange(c))return null;var u=[{x:c,y:o+l},{x:c,y:o}];return r==="top"?u.reverse():u},zFe=(t,e,n,r)=>{var i=t.map(s=>r.apply(s,{position:n}));return e==="discard"&&i.some(s=>!r.isInRange(s))?null:i},BFe=(t,e,n,r,i,s)=>{var{x:o,y:l,segment:c,ifOverflow:u}=s,d=ol(o),f=ol(l);return f?FFe(l,u,n,i,t,e):d?UFe(o,u,n,r,t,e):c!=null&&c.length===2?zFe(c,u,n,t):null};function $Fe(t){var e=Or();return w.useEffect(()=>(e(AFe(t)),()=>{e(kFe(t))})),null}function HFe(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:s}=t,o=ea(),l=RFe(),c=Ut(k=>Cc(k,e)),u=Ut(k=>Tc(k,n)),d=Ut(k=>Ch(k,"xAxis",e,o)),f=Ut(k=>Ch(k,"yAxis",n,o)),m=Yy();if(!l||!m||c==null||u==null||d==null||f==null)return null;var p=MFe({x:d,y:f}),x=BFe(p,m,t.position,c.orientation,u.orientation,t);if(!x)return null;var[{x:b,y},{x:v,y:S}]=x,N=s==="hidden"?"url(#".concat(l,")"):void 0,C=J7(J7({clipPath:N},La(t)),{},{x1:b,y1:y,x2:v,y2:S}),T=NFe({x1:b,y1:y,x2:v,y2:S});return w.createElement(es,{zIndex:t.zIndex},w.createElement(ni,{className:Zn("recharts-reference-line",i)},IFe(r,C),w.createElement(xJ,ZS({},T,{lowerWidth:T.width,upperWidth:T.width}),w.createElement(yJ,{label:t.label}),t.children)))}var VFe={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:mi.line};function u0(t){var e=ri(t,VFe);return w.createElement(w.Fragment,null,w.createElement($Fe,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),w.createElement(HFe,e))}u0.displayName="ReferenceLine";function HJ(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 GFe(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return CFe(r,n)}function qFe(t,e,n){var r=n==="width",{x:i,y:s,width:o,height:l}=t;return e===1?{start:r?i:s,end:r?i+o:s+l}:{start:r?i+o:s+l,end:r?i:s}}function JS(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 WFe(t,e){return HJ(t,e+1)}function KFe(t,e,n,r,i){for(var s=(r||[]).slice(),{start:o,end:l}=e,c=0,u=1,d=o,f=function(){var x=r?.[c];if(x===void 0)return{v:HJ(r,u)};var b=c,y,v=()=>(y===void 0&&(y=n(x,b)),y),S=x.coordinate,N=c===0||JS(t,S,v,d,l);N||(c=0,d=o,u+=1),N&&(d=S+t*(v()/2+i),c+=u)},m;u<=s.length;)if(m=f(),m)return m.v;return[]}function eG(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 qa(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?eG(Object(n),!0).forEach(function(r){XFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):eG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function XFe(t,e,n){return(e=YFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function YFe(t){var e=QFe(t,"string");return typeof e=="symbol"?e:e+""}function QFe(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 ZFe(t,e,n,r,i){for(var s=(r||[]).slice(),o=s.length,{start:l}=e,{end:c}=e,u=function(m){var p=s[m],x,b=()=>(x===void 0&&(x=n(p,m)),x);if(m===o-1){var y=t*(p.coordinate+t*b()/2-c);s[m]=p=qa(qa({},p),{},{tickCoord:y>0?p.coordinate-y*t:p.coordinate})}else s[m]=p=qa(qa({},p),{},{tickCoord:p.coordinate});if(p.tickCoord!=null){var v=JS(t,p.tickCoord,b,l,c);v&&(c=p.tickCoord-t*(b()/2+i),s[m]=qa(qa({},p),{},{isShow:!0}))}},d=o-1;d>=0;d--)u(d);return s}function JFe(t,e,n,r,i,s){var o=(r||[]).slice(),l=o.length,{start:c,end:u}=e;if(s){var d=r[l-1],f=n(d,l-1),m=t*(d.coordinate+t*f/2-u);if(o[l-1]=d=qa(qa({},d),{},{tickCoord:m>0?d.coordinate-m*t:d.coordinate}),d.tickCoord!=null){var p=JS(t,d.tickCoord,()=>f,c,u);p&&(u=d.tickCoord-t*(f/2+i),o[l-1]=qa(qa({},d),{},{isShow:!0}))}}for(var x=s?l-1:l,b=function(S){var N=o[S],C,T=()=>(C===void 0&&(C=n(N,S)),C);if(S===0){var k=t*(N.coordinate-t*T()/2-c);o[S]=N=qa(qa({},N),{},{tickCoord:k<0?N.coordinate-k*t:N.coordinate})}else o[S]=N=qa(qa({},N),{},{tickCoord:N.coordinate});if(N.tickCoord!=null){var E=JS(t,N.tickCoord,T,c,u);E&&(c=N.tickCoord+t*(T()/2+i),o[S]=qa(qa({},N),{},{isShow:!0}))}},y=0;y<x;y++)b(y);return o}function cL(t,e,n){var{tick:r,ticks:i,viewBox:s,minTickGap:o,orientation:l,interval:c,tickFormatter:u,unit:d,angle:f}=t;if(!i||!i.length||!r)return[];if(Bt(c)||Nx.isSsr){var m;return(m=WFe(i,Bt(c)?c:0))!==null&&m!==void 0?m:[]}var p=[],x=l==="top"||l==="bottom"?"width":"height",b=d&&x==="width"?M0(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},y=(N,C)=>{var T=typeof u=="function"?u(N.value,C):N.value;return x==="width"?GFe(M0(T,{fontSize:e,letterSpacing:n}),b,f):M0(T,{fontSize:e,letterSpacing:n})[x]},v=i.length>=2?ga(i[1].coordinate-i[0].coordinate):1,S=qFe(s,v,x);return c==="equidistantPreserveStart"?KFe(v,S,y,i,o):(c==="preserveStart"||c==="preserveStartEnd"?p=JFe(v,S,y,i,o,c==="preserveStartEnd"):p=ZFe(v,S,y,i,o),p.filter(N=>N.isShow))}var eUe=t=>{var{ticks:e,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:s=0}=t,o=0;if(e){Array.from(e).forEach(d=>{if(d){var f=d.getBoundingClientRect();f.width>o&&(o=f.width)}});var l=n?n.getBoundingClientRect().width:0,c=i+s,u=o+c+l+(n?r:0);return Math.round(u)}return 0},tUe=["axisLine","width","height","className","hide","ticks","axisType"];function nUe(t,e){if(t==null)return{};var n,r,i=rUe(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 rUe(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 bm(){return bm=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},bm.apply(null,arguments)}function tG(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 ji(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?tG(Object(n),!0).forEach(function(r){iUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):tG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function iUe(t,e,n){return(e=aUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function aUe(t){var e=sUe(t,"string");return typeof e=="symbol"?e:e+""}function sUe(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 Au={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:mi.axis};function oUe(t){var{x:e,y:n,width:r,height:i,orientation:s,mirror:o,axisLine:l,otherSvgProps:c}=t;if(!l)return null;var u=ji(ji(ji({},c),_s(l)),{},{fill:"none"});if(s==="top"||s==="bottom"){var d=+(s==="top"&&!o||s==="bottom"&&o);u=ji(ji({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var f=+(s==="left"&&!o||s==="right"&&o);u=ji(ji({},u),{},{x1:e+f*r,y1:n,x2:e+f*r,y2:n+i})}return w.createElement("line",bm({},u,{className:Zn("recharts-cartesian-axis-line",mm(l,"className"))}))}function lUe(t,e,n,r,i,s,o,l,c){var u,d,f,m,p,x,b=l?-1:1,y=t.tickSize||o,v=Bt(t.tickCoord)?t.tickCoord:t.coordinate;switch(s){case"top":u=d=t.coordinate,m=n+ +!l*i,f=m-b*y,x=f-b*c,p=v;break;case"left":f=m=t.coordinate,d=e+ +!l*r,u=d-b*y,p=u-b*c,x=v;break;case"right":f=m=t.coordinate,d=e+ +l*r,u=d+b*y,p=u+b*c,x=v;break;default:u=d=t.coordinate,m=n+ +l*i,f=m+b*y,x=f+b*c,p=v;break}return{line:{x1:u,y1:f,x2:d,y2:m},tick:{x:p,y:x}}}function cUe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function uUe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function dUe(t){var{option:e,tickProps:n,value:r}=t,i,s=Zn(n.className,"recharts-cartesian-axis-tick-value");if(w.isValidElement(e))i=w.cloneElement(e,ji(ji({},n),{},{className:s}));else if(typeof e=="function")i=e(ji(ji({},n),{},{className:s}));else{var o="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(o=Zn(o,e?.className)),i=w.createElement(mM,bm({},n,{className:o}),r)}return i}var hUe=w.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:s,tickFormatter:o,unit:l,padding:c,tickTextProps:u,orientation:d,mirror:f,x:m,y:p,width:x,height:b,tickSize:y,tickMargin:v,fontSize:S,letterSpacing:N,getTicksConfig:C,events:T,axisType:k}=t,E=cL(ji(ji({},C),{},{ticks:n}),S,N),D=cUe(d,f),A=uUe(d,f),R=_s(C),F=fm(r),O={};typeof i=="object"&&(O=i);var H=ji(ji({},R),{},{fill:"none"},O),j=E.map(q=>ji({entry:q},lUe(q,m,p,x,b,d,y,f,v))),G=j.map(q=>{var{entry:Y,line:Z}=q;return w.createElement(ni,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(Y.value,"-").concat(Y.coordinate,"-").concat(Y.tickCoord)},i&&w.createElement("line",bm({},H,Z,{className:Zn("recharts-cartesian-axis-tick-line",mm(i,"className"))})))}),$=j.map((q,Y)=>{var{entry:Z,tick:oe}=q,B=ji(ji(ji(ji({textAnchor:D,verticalAnchor:A},R),{},{stroke:"none",fill:s},F),oe),{},{index:Y,payload:Z,visibleTicksCount:E.length,tickFormatter:o,padding:c},u);return w.createElement(ni,bm({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(Z.value,"-").concat(Z.coordinate,"-").concat(Z.tickCoord)},Gy(T,Z,Y)),r&&w.createElement(dUe,{option:r,tickProps:B,value:"".concat(typeof o=="function"?o(Z.value,Y):Z.value).concat(l||"")}))});return w.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(k,"-ticks")},$.length>0&&w.createElement(es,{zIndex:mi.label},w.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(k,"-tick-labels"),ref:e},$)),G.length>0&&w.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(k,"-tick-lines")},G))}),fUe=w.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:s,hide:o,ticks:l,axisType:c}=t,u=nUe(t,tUe),[d,f]=w.useState(""),[m,p]=w.useState(""),x=w.useRef(null);w.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var y;return eUe({ticks:x.current,label:(y=t.labelRef)===null||y===void 0?void 0:y.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var b=w.useCallback(y=>{if(y){var v=y.getElementsByClassName("recharts-cartesian-axis-tick-value");x.current=v;var S=v[0];if(S){var N=window.getComputedStyle(S),C=N.fontSize,T=N.letterSpacing;(C!==d||T!==m)&&(f(C),p(T))}}},[d,m]);return o||r!=null&&r<=0||i!=null&&i<=0?null:w.createElement(es,{zIndex:t.zIndex},w.createElement(ni,{className:Zn("recharts-cartesian-axis",s)},w.createElement(oUe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:_s(t)}),w.createElement(hUe,{ref:b,axisType:c,events:u,fontSize:d,getTicksConfig:t,height:t.height,letterSpacing:m,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:l,unit:t.unit,width:t.width,x:t.x,y:t.y}),w.createElement(xJ,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},w.createElement(yJ,{label:t.label,labelRef:t.labelRef}),t.children)))}),uL=w.forwardRef((t,e)=>{var n=ri(t,Au);return w.createElement(fUe,bm({},n,{ref:e}))});uL.displayName="CartesianAxis";var mUe=["x1","y1","x2","y2","key"],pUe=["offset"],gUe=["xAxisId","yAxisId"],xUe=["xAxisId","yAxisId"];function nG(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 Xa(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?nG(Object(n),!0).forEach(function(r){bUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):nG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function bUe(t,e,n){return(e=yUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yUe(t){var e=vUe(t,"string");return typeof e=="symbol"?e:e+""}function vUe(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 Of(){return Of=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},Of.apply(null,arguments)}function e2(t,e){if(t==null)return{};var n,r,i=_Ue(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 _Ue(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 wUe=t=>{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:s,height:o,ry:l}=t;return w.createElement("rect",{x:r,y:i,ry:l,width:s,height:o,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function VJ(t){var{option:e,lineItemProps:n}=t,r;if(w.isValidElement(e))r=w.cloneElement(e,n);else if(typeof e=="function")r=e(n);else{var i,{x1:s,y1:o,x2:l,y2:c,key:u}=n,d=e2(n,mUe),f=(i=_s(d))!==null&&i!==void 0?i:{},{offset:m}=f,p=e2(f,pUe);r=w.createElement("line",Of({},p,{x1:s,y1:o,x2:l,y2:c,fill:"none",key:u}))}return r}function SUe(t){var{x:e,width:n,horizontal:r=!0,horizontalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:s,yAxisId:o}=t,l=e2(t,gUe),c=i.map((u,d)=>{var f=Xa(Xa({},l),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return w.createElement(VJ,{key:"line-".concat(d),option:r,lineItemProps:f})});return w.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function NUe(t){var{y:e,height:n,vertical:r=!0,verticalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:s,yAxisId:o}=t,l=e2(t,xUe),c=i.map((u,d)=>{var f=Xa(Xa({},l),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return w.createElement(VJ,{option:r,lineItemProps:f,key:"line-".concat(d)})});return w.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function MUe(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:s,height:o,horizontalPoints:l,horizontal:c=!0}=t;if(!c||!e||!e.length||l==null)return null;var u=l.map(f=>Math.round(f+i-i)).sort((f,m)=>f-m);i!==u[0]&&u.unshift(0);var d=u.map((f,m)=>{var p=!u[m+1],x=p?i+o-f:u[m+1]-f;if(x<=0)return null;var b=m%e.length;return w.createElement("rect",{key:"react-".concat(m),y:f,x:r,height:x,width:s,stroke:"none",fill:e[b],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return w.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function EUe(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:s,width:o,height:l,verticalPoints:c}=t;if(!e||!n||!n.length)return null;var u=c.map(f=>Math.round(f+i-i)).sort((f,m)=>f-m);i!==u[0]&&u.unshift(0);var d=u.map((f,m)=>{var p=!u[m+1],x=p?i+o-f:u[m+1]-f;if(x<=0)return null;var b=m%n.length;return w.createElement("rect",{key:"react-".concat(m),x:f,y:s,width:x,height:l,stroke:"none",fill:n[b],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return w.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var CUe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:s}=t;return CY(cL(Xa(Xa(Xa({},Au),n),{},{ticks:TY(n),viewBox:{x:0,y:0,width:r,height:i}})),s.left,s.left+s.width,e)},TUe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:s}=t;return CY(cL(Xa(Xa(Xa({},Au),n),{},{ticks:TY(n),viewBox:{x:0,y:0,width:r,height:i}})),s.top,s.top+s.height,e)},AUe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:mi.grid};function t2(t){var e=L4(),n=I4(),r=IY(),i=Xa(Xa({},ri(t,AUe)),{},{x:Bt(t.x)?t.x:r.left,y:Bt(t.y)?t.y:r.top,width:Bt(t.width)?t.width:r.width,height:Bt(t.height)?t.height:r.height}),{xAxisId:s,yAxisId:o,x:l,y:c,width:u,height:d,syncWithTicks:f,horizontalValues:m,verticalValues:p}=i,x=ea(),b=Ut(A=>VV(A,"xAxis",s,x)),y=Ut(A=>VV(A,"yAxis",o,x));if(!xc(u)||!xc(d)||!Bt(l)||!Bt(c))return null;var v=i.verticalCoordinatesGenerator||CUe,S=i.horizontalCoordinatesGenerator||TUe,{horizontalPoints:N,verticalPoints:C}=i;if((!N||!N.length)&&typeof S=="function"){var T=m&&m.length,k=S({yAxis:y?Xa(Xa({},y),{},{ticks:T?m:y.ticks}):void 0,width:e??u,height:n??d,offset:r},T?!0:f);NS(Array.isArray(k),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof k,"]")),Array.isArray(k)&&(N=k)}if((!C||!C.length)&&typeof v=="function"){var E=p&&p.length,D=v({xAxis:b?Xa(Xa({},b),{},{ticks:E?p:b.ticks}):void 0,width:e??u,height:n??d,offset:r},E?!0:f);NS(Array.isArray(D),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof D,"]")),Array.isArray(D)&&(C=D)}return w.createElement(es,{zIndex:i.zIndex},w.createElement("g",{className:"recharts-cartesian-grid"},w.createElement(wUe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),w.createElement(MUe,Of({},i,{horizontalPoints:N})),w.createElement(EUe,Of({},i,{verticalPoints:C})),w.createElement(SUe,Of({},i,{offset:r,horizontalPoints:N,xAxis:b,yAxis:y})),w.createElement(NUe,Of({},i,{offset:r,verticalPoints:C,xAxis:b,yAxis:y}))))}t2.displayName="CartesianGrid";var GJ=(t,e,n,r)=>vc(t,"xAxis",e,r),qJ=(t,e,n,r)=>yc(t,"xAxis",e,r),WJ=(t,e,n,r)=>vc(t,"yAxis",n,r),KJ=(t,e,n,r)=>yc(t,"yAxis",n,r),kUe=et([zn,GJ,WJ,qJ,KJ],(t,e,n,r,i)=>Ec(t,"xAxis")?Mh(e,r,!1):Mh(n,i,!1)),jUe=(t,e,n,r,i)=>i;function PUe(t){return t.type==="line"}var RUe=et([sv,jUe],(t,e)=>t.filter(PUe).find(n=>n.id===e)),DUe=et([zn,GJ,WJ,qJ,KJ,RUe,kUe,nv],(t,e,n,r,i,s,o,l)=>{var{chartData:c,dataStartIndex:u,dataEndIndex:d}=l;if(!(s==null||e==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||t!=="horizontal"&&t!=="vertical")){var{dataKey:f,data:m}=s,p;if(m!=null&&m.length>0?p=m:p=c?.slice(u,d+1),p!=null)return eze({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:f,bandSize:o,displayedData:p})}});function XJ(t){var e=fm(t),n=3,r=2;if(e!=null){var{r:i,strokeWidth:s}=e,o=Number(i),l=Number(s);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(l)||l<0)&&(l=r),{r:o,strokeWidth:l}}return{r:n,strokeWidth:r}}var OUe=["id"],LUe=["type","layout","connectNulls","needClip","shape"],IUe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function vy(){return vy=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},vy.apply(null,arguments)}function rG(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 rc(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?rG(Object(n),!0).forEach(function(r){FUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):rG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function FUe(t,e,n){return(e=UUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function UUe(t){var e=zUe(t,"string");return typeof e=="symbol"?e:e+""}function zUe(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 dL(t,e){if(t==null)return{};var n,r,i=BUe(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 BUe(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 $Ue=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:s}=t;return[{inactive:s,dataKey:e,type:i,color:r,value:Lh(n,e),payload:t}]},HUe=w.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:s,name:o,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:s,dataKey:e,nameKey:void 0,name:Lh(o,e),hide:l,type:u,color:r,unit:c}};return w.createElement(bM,{tooltipEntrySettings:d})}),YJ=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function VUe(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var GUe=(t,e,n)=>{var r=n.reduce((f,m)=>f+m);if(!r)return YJ(e,t);for(var i=Math.floor(t/r),s=t%r,o=e-t,l=[],c=0,u=0;c<n.length;u+=n[c],++c)if(u+n[c]>s){l=[...n.slice(0,c),s-u];break}var d=l.length%2===0?[0,o]:[o];return[...VUe(n,i),...l,...d].map(f=>"".concat(f,"px")).join(", ")};function qUe(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:s,needClip:o}=r,{id:l}=r,c=dL(r,OUe),u=_s(c);return w.createElement(jJ,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:s,baseProps:u,needClip:o,clipPathId:e})}function WUe(t){var{showLabels:e,children:n,points:r}=t,i=w.useMemo(()=>r?.map(s=>{var o,l,c={x:(o=s.x)!==null&&o!==void 0?o:0,y:(l=s.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return rc(rc({},c),{},{value:s.value,payload:s.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return w.createElement(QO,{value:e?i:void 0},n)}function iG(t){var{clipPathId:e,pathRef:n,points:r,strokeDasharray:i,props:s}=t,{type:o,layout:l,connectNulls:c,needClip:u,shape:d}=s,f=dL(s,LUe),m=rc(rc({},La(f)),{},{fill:"none",className:"recharts-line-curve",clipPath:u?"url(#clipPath-".concat(e,")"):void 0,points:r,type:o,layout:l,connectNulls:c,strokeDasharray:i??s.strokeDasharray});return w.createElement(w.Fragment,null,r?.length>1&&w.createElement(nL,vy({shapeType:"curve",option:d},m,{pathRef:n})),w.createElement(qUe,{points:r,clipPathId:e,props:s}))}function KUe(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function XUe(t){var{clipPathId:e,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:s}=t,{points:o,strokeDasharray:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,animateNewValues:m,width:p,height:x,onAnimationEnd:b,onAnimationStart:y}=n,v=i.current,S=Ex(o,"recharts-line-"),N=w.useRef(S),[C,T]=w.useState(!1),k=!C,E=w.useCallback(()=>{typeof b=="function"&&b(),T(!1)},[b]),D=w.useCallback(()=>{typeof y=="function"&&y(),T(!0)},[y]),A=KUe(r.current),R=w.useRef(0);N.current!==S&&(R.current=s.current,N.current=S);var F=R.current;return w.createElement(WUe,{points:o,showLabels:k},n.children,w.createElement(Mx,{animationId:S,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:E,onAnimationStart:D,key:S},O=>{var H=ur(F,A+F,O),j=Math.min(H,A),G;if(c)if(l){var $="".concat(l).split(/[,\s]+/gim).map(Z=>parseFloat(Z));G=GUe(j,A,$)}else G=YJ(A,j);else G=l==null?void 0:String(l);if(O>0&&A>0&&(i.current=o,s.current=Math.max(s.current,j)),v){var q=v.length/o.length,Y=O===1?o:o.map((Z,oe)=>{var B=Math.floor(oe*q);if(v[B]){var W=v[B];return rc(rc({},Z),{},{x:ur(W.x,Z.x,O),y:ur(W.y,Z.y,O)})}return m?rc(rc({},Z),{},{x:ur(p*2,Z.x,O),y:ur(x/2,Z.y,O)}):rc(rc({},Z),{},{x:Z.x,y:Z.y})});return i.current=Y,w.createElement(iG,{props:n,points:Y,clipPathId:e,pathRef:r,strokeDasharray:G})}return w.createElement(iG,{props:n,points:o,clipPathId:e,pathRef:r,strokeDasharray:G})}),w.createElement(pM,{label:n.label}))}function YUe(t){var{clipPathId:e,props:n}=t,r=w.useRef(null),i=w.useRef(0),s=w.useRef(null);return w.createElement(XUe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:s})}var QUe=(t,e)=>{var n,r;return{x:(n=t.x)!==null&&n!==void 0?n:void 0,y:(r=t.y)!==null&&r!==void 0?r:void 0,value:t.value,errorVal:gr(t.payload,e)}};class ZUe extends w.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:s,yAxisId:o,top:l,left:c,width:u,height:d,id:f,needClip:m,zIndex:p}=this.props;if(e)return null;var x=Zn("recharts-line",i),b=f,{r:y,strokeWidth:v}=XJ(n),S=tL(n),N=y*2+v,C=m?"url(#clipPath-".concat(S?"":"dots-").concat(b,")"):void 0;return w.createElement(es,{zIndex:p},w.createElement(ni,{className:x},m&&w.createElement("defs",null,w.createElement(lL,{clipPathId:b,xAxisId:s,yAxisId:o}),!S&&w.createElement("clipPath",{id:"clipPath-dots-".concat(b)},w.createElement("rect",{x:c-N/2,y:l-N/2,width:u+N,height:d+N}))),w.createElement(DJ,{xAxisId:s,yAxisId:o,data:r,dataPointFormatter:QUe,errorBarOffset:0},w.createElement(YUe,{props:this.props,clipPathId:b}))),w.createElement(vR,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:C}))}}var QJ={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!0,fill:"#fff",hide:!1,isAnimationActive:"auto",label:!1,legendType:"line",stroke:"#3182bd",strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:mi.line,type:"linear"};function JUe(t){var e=ri(t,QJ),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:s,animationEasing:o,connectNulls:l,dot:c,hide:u,isAnimationActive:d,label:f,legendType:m,xAxisId:p,yAxisId:x,id:b}=e,y=dL(e,IUe),{needClip:v}=wM(p,x),S=_M(),N=Tm(),C=ea(),T=Ut(R=>DUe(R,p,x,C,b));if(N!=="horizontal"&&N!=="vertical"||T==null||S==null)return null;var{height:k,width:E,x:D,y:A}=S;return w.createElement(ZUe,vy({},y,{id:b,connectNulls:l,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:s,animationEasing:o,isAnimationActive:d,hide:u,label:f,legendType:m,xAxisId:p,yAxisId:x,points:T,layout:N,height:k,width:E,left:D,top:A,needClip:v}))}function eze(t){var{layout:e,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:s,dataKey:o,bandSize:l,displayedData:c}=t;return c.map((u,d)=>{var f=gr(u,o);if(e==="horizontal"){var m=SS({axis:n,ticks:i,bandSize:l,entry:u,index:d}),p=Gr(f)?null:r.scale(f);return{x:m,y:p,value:f,payload:u}}var x=Gr(f)?null:n.scale(f),b=SS({axis:r,ticks:s,bandSize:l,entry:u,index:d});return x==null||b==null?null:{x,y:b,value:f,payload:u}}).filter(Boolean)}function tze(t){var e=ri(t,QJ),n=ea();return w.createElement(yM,{id:e.id,type:"line"},r=>w.createElement(w.Fragment,null,w.createElement(sL,{legendPayload:$Ue(e)}),w.createElement(HUe,{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}),w.createElement(oL,{type:"line",id:r,data:e.data,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,hide:e.hide,isPanorama:n}),w.createElement(JUe,vy({},e,{id:r}))))}var ZJ=w.memo(tze,pv);ZJ.displayName="Line";var JJ=(t,e,n,r)=>vc(t,"xAxis",e,r),eee=(t,e,n,r)=>yc(t,"xAxis",e,r),tee=(t,e,n,r)=>vc(t,"yAxis",n,r),nee=(t,e,n,r)=>yc(t,"yAxis",n,r),nze=et([zn,JJ,tee,eee,nee],(t,e,n,r,i)=>Ec(t,"xAxis")?Mh(e,r,!1):Mh(n,i,!1)),rze=(t,e,n,r,i)=>i,ree=et([sv,rze],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),ize=(t,e,n,r,i)=>{var s,o=ree(t,e,n,r,i);if(o!=null){var l=zn(t),c=Ec(l,"xAxis"),u;if(c?u=by(t,"yAxis",n,r):u=by(t,"xAxis",e,r),u!=null){var{stackId:d}=o,f=aM(o);if(!(d==null||f==null)){var m=(s=u[d])===null||s===void 0?void 0:s.stackedData;return m?.find(p=>p.key===f)}}}},aze=et([zn,JJ,tee,eee,nee,ize,nv,nze,ree,RPe],(t,e,n,r,i,s,o,l,c,u)=>{var{chartData:d,dataStartIndex:f,dataEndIndex:m}=o;if(!(c==null||t!=="horizontal"&&t!=="vertical"||e==null||n==null||r==null||i==null||r.length===0||i.length===0||l==null)){var{data:p}=c,x;if(p&&p.length>0?x=p:x=d?.slice(f,m+1),x!=null)return Nze({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:s,displayedData:x,chartBaseValue:u,bandSize:l})}}),sze=["id"],oze=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Kf(){return Kf=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},Kf.apply(null,arguments)}function iee(t,e){if(t==null)return{};var n,r,i=lze(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 lze(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 aG(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 yg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?aG(Object(n),!0).forEach(function(r){cze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):aG(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)}function n2(t,e){return t&&t!=="none"?t:e}var hze=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:s,hide:o}=t;return[{inactive:o,dataKey:e,type:s,color:n2(r,i),value:Lh(n,e),payload:t}]},fze=w.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:s,name:o,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:s,dataKey:e,nameKey:void 0,name:Lh(o,e),hide:l,type:u,color:n2(r,s),unit:c}};return w.createElement(bM,{tooltipEntrySettings:d})});function mze(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:s,dataKey:o}=r,l=_s(r);return w.createElement(jJ,{points:n,dot:s,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:i,clipPathId:e})}function pze(t){var{showLabels:e,children:n,points:r}=t,i=r.map(s=>{var o,l,c={x:(o=s.x)!==null&&o!==void 0?o:0,y:(l=s.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return yg(yg({},c),{},{value:s.value,payload:s.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return w.createElement(QO,{value:e?i:void 0},n)}function sG(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:s}=t,{layout:o,type:l,stroke:c,connectNulls:u,isRange:d}=s,{id:f}=s,m=iee(s,sze),p=_s(m),x=La(m);return w.createElement(w.Fragment,null,e?.length>1&&w.createElement(ni,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},w.createElement(Pg,Kf({},x,{id:f,points:e,connectNulls:u,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),c!=="none"&&w.createElement(Pg,Kf({},p,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&w.createElement(Pg,Kf({},p,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:n}))),w.createElement(mze,{points:e,props:m,clipPathId:i}))}function gze(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].y,o=r[r.length-1].y;if(!xr(s)||!xr(o))return null;var l=e*Math.abs(s-o),c=Math.max(...r.map(u=>u.x||0));return Bt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.x||0),c)),Bt(c)?w.createElement("rect",{x:0,y:s<o?s:s-l,width:c+(i?parseInt("".concat(i),10):1),height:Math.floor(l)}):null}function xze(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].x,o=r[r.length-1].x;if(!xr(s)||!xr(o))return null;var l=e*Math.abs(s-o),c=Math.max(...r.map(u=>u.y||0));return Bt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.y||0),c)),Bt(c)?w.createElement("rect",{x:s<o?s:s-l,y:0,width:l,height:Math.floor(c+(i?parseInt("".concat(i),10):1))}):null}function bze(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:s}=t;return n==="vertical"?w.createElement(gze,{alpha:e,points:r,baseLine:i,strokeWidth:s}):w.createElement(xze,{alpha:e,points:r,baseLine:i,strokeWidth:s})}function yze(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s}=t,{points:o,baseLine:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,onAnimationStart:m,onAnimationEnd:p}=r,x=w.useMemo(()=>({points:o,baseLine:l}),[o,l]),b=Ex(x,"recharts-area-"),y=QTe(),[v,S]=w.useState(!1),N=!v,C=w.useCallback(()=>{typeof p=="function"&&p(),S(!1)},[p]),T=w.useCallback(()=>{typeof m=="function"&&m(),S(!0)},[m]);if(y==null)return null;var k=i.current,E=s.current;return w.createElement(pze,{showLabels:N,points:o},r.children,w.createElement(Mx,{animationId:b,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:C,onAnimationStart:T,key:b},D=>{if(k){var A=k.length/o.length,R=D===1?o:o.map((O,H)=>{var j=Math.floor(H*A);if(k[j]){var G=k[j];return yg(yg({},O),{},{x:ur(G.x,O.x,D),y:ur(G.y,O.y,D)})}return O}),F;return Bt(l)?F=ur(E,l,D):Gr(l)||Gs(l)?F=ur(E,0,D):F=l.map((O,H)=>{var j=Math.floor(H*A);if(Array.isArray(E)&&E[j]){var G=E[j];return yg(yg({},O),{},{x:ur(G.x,O.x,D),y:ur(G.y,O.y,D)})}return O}),D>0&&(i.current=R,s.current=F),w.createElement(sG,{points:R,baseLine:F,needClip:e,clipPathId:n,props:r})}return D>0&&(i.current=o,s.current=l),w.createElement(ni,null,c&&w.createElement("defs",null,w.createElement("clipPath",{id:"animationClipPath-".concat(n)},w.createElement(bze,{alpha:D,points:o,baseLine:l,layout:y,strokeWidth:r.strokeWidth}))),w.createElement(ni,{clipPath:"url(#animationClipPath-".concat(n,")")},w.createElement(sG,{points:o,baseLine:l,needClip:e,clipPathId:n,props:r})))}),w.createElement(pM,{label:r.label}))}function vze(t){var{needClip:e,clipPathId:n,props:r}=t,i=w.useRef(null),s=w.useRef();return w.createElement(yze,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s})}class _ze extends w.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:s,left:o,needClip:l,xAxisId:c,yAxisId:u,width:d,height:f,id:m,baseLine:p,zIndex:x}=this.props;if(e)return null;var b=Zn("recharts-area",i),y=m,{r:v,strokeWidth:S}=XJ(n),N=tL(n),C=v*2+S,T=l?"url(#clipPath-".concat(N?"":"dots-").concat(y,")"):void 0;return w.createElement(es,{zIndex:x},w.createElement(ni,{className:b},l&&w.createElement("defs",null,w.createElement(lL,{clipPathId:y,xAxisId:c,yAxisId:u}),!N&&w.createElement("clipPath",{id:"clipPath-dots-".concat(y)},w.createElement("rect",{x:o-C/2,y:s-C/2,width:d+C,height:f+C}))),w.createElement(vze,{needClip:l,clipPathId:y,props:this.props})),w.createElement(vR,{points:r,mainColor:n2(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}),this.props.isRange&&Array.isArray(p)&&w.createElement(vR,{points:p,mainColor:n2(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}))}}var aee={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:mi.area};function wze(t){var e,n=ri(t,aee),{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:o,connectNulls:l,dot:c,fill:u,fillOpacity:d,hide:f,isAnimationActive:m,legendType:p,stroke:x,xAxisId:b,yAxisId:y}=n,v=iee(n,oze),S=Tm(),N=eJ(),{needClip:C}=wM(b,y),T=ea(),{points:k,isRange:E,baseLine:D}=(e=Ut(j=>aze(j,b,y,T,t.id)))!==null&&e!==void 0?e:{},A=_M();if(S!=="horizontal"&&S!=="vertical"||A==null||N!=="AreaChart"&&N!=="ComposedChart")return null;var{height:R,width:F,x:O,y:H}=A;return!k||!k.length?null:w.createElement(_ze,Kf({},v,{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:o,baseLine:D,connectNulls:l,dot:c,fill:u,fillOpacity:d,height:R,hide:f,layout:S,isAnimationActive:m==="auto"?!Nx.isSsr:m,isRange:E,legendType:p,needClip:C,points:k,stroke:x,width:F,left:O,top:H,xAxisId:b,yAxisId:y}))}var Sze=(t,e,n,r,i)=>{var s=n??e;if(Bt(s))return s;var o=t==="horizontal"?i:r,l=o.scale.domain();if(o.type==="number"){var c=Math.max(l[0],l[1]),u=Math.min(l[0],l[1]);return s==="dataMin"?u:s==="dataMax"||c<0?c:Math.max(Math.min(l[0],l[1]),0)}return s==="dataMin"?l[0]:s==="dataMax"?l[1]:l[0]};function Nze(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:s,chartBaseValue:o,xAxis:l,yAxis:c,displayedData:u,dataStartIndex:d,xAxisTicks:f,yAxisTicks:m,bandSize:p}=t,x=i&&i.length,b=Sze(s,o,n,l,c),y=s==="horizontal",v=!1,S=u.map((C,T)=>{var k;x?k=i[d+T]:(k=gr(C,r),Array.isArray(k)?v=!0:k=[b,k]);var E=k[1]==null||x&&!e&&gr(C,r)==null;return y?{x:SS({axis:l,ticks:f,bandSize:p,entry:C,index:T}),y:E?null:c.scale(k[1]),value:k,payload:C}:{x:E?null:l.scale(k[1]),y:SS({axis:c,ticks:m,bandSize:p,entry:C,index:T}),value:k,payload:C}}),N;return x||v?N=S.map(C=>{var T=Array.isArray(C.value)?C.value[0]:null;return y?{x:C.x,y:T!=null&&C.y!=null?c.scale(T):null,payload:C.payload}:{x:T!=null?l.scale(T):null,y:C.y,payload:C.payload}}):N=y?c.scale(b):l.scale(b),{points:S,baseLine:N,isRange:v}}function Mze(t){var e=ri(t,aee),n=ea();return w.createElement(yM,{id:e.id,type:"area"},r=>w.createElement(w.Fragment,null,w.createElement(sL,{legendPayload:hze(e)}),w.createElement(fze,{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}),w.createElement(oL,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:AY(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),w.createElement(wze,Kf({},e,{id:r}))))}var see=w.memo(Mze,pv);see.displayName="Area";var Eze=["domain","range"],Cze=["domain","range"];function oG(t,e){if(t==null)return{};var n,r,i=Tze(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 Tze(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 lG(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 oee(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=oG(t,Eze),{domain:s,range:o}=e,l=oG(e,Cze);return!lG(n,s)||!lG(r,o)?!1:pv(i,l)}var Aze=["dangerouslySetInnerHTML","ticks"],kze=["id"];function wR(){return wR=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},wR.apply(null,arguments)}function cG(t,e){if(t==null)return{};var n,r,i=jze(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 jze(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 Pze(t){var e=Or(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(E5e(t)):n.current!==t&&e(C5e({prev:n.current,next:t})),n.current=t},[t,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(T5e(n.current)),n.current=null)},[e]),null}var Rze=t=>{var{xAxisId:e,className:n}=t,r=Ut(D4),i=ea(),s="xAxis",o=Ut(y=>Ch(y,s,e,i)),l=Ut(y=>PZ(y,s,e,i)),c=Ut(y=>TZ(y,e)),u=Ut(y=>kRe(y,e)),d=Ut(y=>cZ(y,e));if(c==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:f,ticks:m}=t,p=cG(t,Aze),{id:x}=d,b=cG(d,kze);return w.createElement(uL,wR({},p,b,{scale:o,x:u.x,y:u.y,width:c.width,height:c.height,className:Zn("recharts-".concat(s," ").concat(s),n),viewBox:r,ticks:l,axisType:s}))},Dze={allowDataOverflow:ua.allowDataOverflow,allowDecimals:ua.allowDecimals,allowDuplicatedCategory:ua.allowDuplicatedCategory,angle:ua.angle,axisLine:Au.axisLine,height:ua.height,hide:!1,includeHidden:ua.includeHidden,interval:ua.interval,minTickGap:ua.minTickGap,mirror:ua.mirror,orientation:ua.orientation,padding:ua.padding,reversed:ua.reversed,scale:ua.scale,tick:ua.tick,tickCount:ua.tickCount,tickLine:Au.tickLine,tickSize:Au.tickSize,type:ua.type,xAxisId:0},Oze=t=>{var e=ri(t,Dze);return w.createElement(w.Fragment,null,w.createElement(Pze,{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}),w.createElement(Rze,e))},r2=w.memo(Oze,oee);r2.displayName="XAxis";var Lze=["dangerouslySetInnerHTML","ticks"],Ize=["id"];function SR(){return SR=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},SR.apply(null,arguments)}function uG(t,e){if(t==null)return{};var n,r,i=Fze(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 Fze(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 Uze(t){var e=Or(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(A5e(t)):n.current!==t&&e(k5e({prev:n.current,next:t})),n.current=t},[t,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(j5e(n.current)),n.current=null)},[e]),null}var zze=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,s=w.useRef(null),o=w.useRef(null),l=Ut(D4),c=ea(),u=Or(),d="yAxis",f=Ut(T=>Ch(T,d,e,c)),m=Ut(T=>AZ(T,e)),p=Ut(T=>PRe(T,e)),x=Ut(T=>PZ(T,d,e,c)),b=Ut(T=>uZ(T,e));if(w.useLayoutEffect(()=>{if(!(r!=="auto"||!m||YO(i)||w.isValidElement(i)||b==null)){var T=s.current;if(T){var k=T.getCalculatedWidth();Math.round(m.width)!==Math.round(k)&&u(P5e({id:e,width:k}))}}},[x,m,u,i,e,r,b]),m==null||p==null||b==null)return null;var{dangerouslySetInnerHTML:y,ticks:v}=t,S=uG(t,Lze),{id:N}=b,C=uG(b,Ize);return w.createElement(uL,SR({},S,C,{ref:s,labelRef:o,scale:f,x:p.x,y:p.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:m.width,height:m.height,className:Zn("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:x,axisType:d}))},Bze={allowDataOverflow:da.allowDataOverflow,allowDecimals:da.allowDecimals,allowDuplicatedCategory:da.allowDuplicatedCategory,angle:da.angle,axisLine:Au.axisLine,hide:!1,includeHidden:da.includeHidden,interval:da.interval,minTickGap:da.minTickGap,mirror:da.mirror,orientation:da.orientation,padding:da.padding,reversed:da.reversed,scale:da.scale,tick:da.tick,tickCount:da.tickCount,tickLine:Au.tickLine,tickSize:Au.tickSize,type:da.type,width:da.width,yAxisId:0},$ze=t=>{var e=ri(t,Bze);return w.createElement(w.Fragment,null,w.createElement(Uze,{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}),w.createElement(zze,e))},i2=w.memo($ze,oee);i2.displayName="YAxis";var Hze=(t,e)=>e,hL=et([Hze,zn,oZ,na,KZ,Ku,WDe,Ji],e4e),fL=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)}},lee=ll("mouseClick"),cee=Ky();cee.startListening({actionCreator:lee,effect:(t,e)=>{var n=t.payload,r=hL(e.getState(),fL(n));r?.activeIndex!=null&&e.dispatch(qRe({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var NR=ll("mouseMove"),uee=Ky(),Zw=null;uee.startListening({actionCreator:NR,effect:(t,e)=>{var n=t.payload;Zw!==null&&cancelAnimationFrame(Zw);var r=fL(n);Zw=requestAnimationFrame(()=>{var i=e.getState(),s=UO(i,i.tooltip.settings.shared);if(s==="axis"){var o=hL(i,r);o?.activeIndex!=null?e.dispatch(zZ({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate})):e.dispatch(UZ())}Zw=null})}});var dG={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},dee=qs({name:"rootProps",initialState:dG,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:dG.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}}}),Vze=dee.reducer,{updateOptions:Gze}=dee.actions,hee=qs({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:qze}=hee.actions,Wze=hee.reducer,fee=ll("keyDown"),mee=ll("focus"),mL=Ky();mL.startListening({actionCreator:fee,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 o=zO(i,Dx(n),lv(n),hv(n)),l=o==null?-1:Number(o);if(!(!Number.isFinite(l)||l<0)){var c=Ku(n);if(s==="Enter"){var u=GS(n,"axis","hover",String(i.index));e.dispatch(mR({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:u}));return}var d=LRe(n),f=d==="left-to-right"?1:-1,m=s==="ArrowRight"?1:-1,p=l+m*f;if(!(c==null||p>=c.length||p<0)){var x=GS(n,"axis","hover",String(p));e.dispatch(mR({active:!0,activeIndex:p.toString(),activeDataKey:void 0,activeCoordinate:x}))}}}}}});mL.startListening({actionCreator:mee,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",o=GS(n,"axis","hover",String(s));e.dispatch(mR({activeDataKey:void 0,active:!0,activeIndex:s,activeCoordinate:o}))}}}});var Uo=ll("externalEvent"),pee=Ky(),rj=new Map;pee.startListening({actionCreator:Uo,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,s=rj.get(i);s!==void 0&&cancelAnimationFrame(s);var o=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:PDe(l),activeDataKey:GO(l),activeIndex:Th(l),activeLabel:QZ(l),activeTooltipIndex:Th(l),isTooltipActive:RDe(l)};n(c,r)}finally{rj.delete(i)}});rj.set(i,o)}}});var Kze=et([Rx],t=>t.tooltipItemPayloads),Xze=et([Kze,uv,(t,e,n)=>e,(t,e,n)=>n],(t,e,n,r)=>{var i=t.find(l=>l.settings.dataKey===r);if(i!=null){var{positions:s}=i;if(s!=null){var o=e(s,n);return o}}}),gee=ll("touchMove"),xee=Ky();xee.startListening({actionCreator:gee,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=UO(r,r.tooltip.settings.shared);if(i==="axis"){var s=hL(r,fL({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));s?.activeIndex!=null&&e.dispatch(zZ({activeIndex:s.activeIndex,activeDataKey:void 0,activeCoordinate:s.activeCoordinate}))}else if(i==="item"){var o,l=n.touches[0];if(document.elementFromPoint==null)return;var c=document.elementFromPoint(l.clientX,l.clientY);if(!c||!c.getAttribute)return;var u=c.getAttribute(jY),d=(o=c.getAttribute(PY))!==null&&o!==void 0?o:void 0,f=Xze(e.getState(),u,d);e.dispatch(FZ({activeDataKey:d,activeIndex:u,activeCoordinate:f}))}}}});var Yze=ZX({brush:vFe,cartesianAxis:R5e,chartData:j4e,errorBars:Z5e,graphicalItems:zLe,layout:iTe,legend:hAe,options:E4e,polarAxis:tLe,polarOptions:Wze,referenceElements:jFe,rootProps:Vze,tooltip:WRe,zIndex:m4e}),Qze=function(e){return ACe({reducer:Yze,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([cee.middleware,uee.middleware,mL.middleware,pee.middleware,xee.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(fY({type:"raf"}))},devTools:Nx.devToolsEnabled})};function bee(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=ea(),s=w.useRef(null);if(i)return n;s.current==null&&(s.current=Qze(e));var o=M4;return w.createElement(wIe,{context:o,store:s.current},n)}function Zze(t){var{layout:e,margin:n}=t,r=Or(),i=ea();return w.useEffect(()=>{i||(r(tTe(e)),r(eTe(n)))},[r,i,e,n]),null}var yee=w.memo(Zze,pv);function vee(t){var e=Or();return w.useEffect(()=>{e(Gze(t))},[e,t]),null}function hG(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=TJ("".concat(r).concat(e)),s=Or();return w.useLayoutEffect(()=>(s(h4e({zIndex:e,elementId:i,isPanorama:n})),()=>{s(f4e({zIndex:e,isPanorama:n}))}),[s,e,i,n]),w.createElement("g",{tabIndex:-1,id:i})}function fG(t){var{children:e,isPanorama:n}=t,r=Ut(n4e);if(!r||r.length===0)return e;var i=r.filter(o=>o<0),s=r.filter(o=>o>0);return w.createElement(w.Fragment,null,i.map(o=>w.createElement(hG,{key:o,zIndex:o,isPanorama:n})),e,s.map(o=>w.createElement(hG,{key:o,zIndex:o,isPanorama:n})))}var Jze=["children"];function eBe(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}function a2(){return a2=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},a2.apply(null,arguments)}var nBe={width:"100%",height:"100%",display:"block"},rBe=w.forwardRef((t,e)=>{var n=L4(),r=I4(),i=KY();if(!xc(n)||!xc(r))return null;var{children:s,otherAttributes:o,title:l,desc:c}=t,u,d;return o!=null&&(typeof o.tabIndex=="number"?u=o.tabIndex:u=i?0:void 0,typeof o.role=="string"?d=o.role:d=i?"application":void 0),w.createElement(p4,a2({},o,{title:l,desc:c,role:d,tabIndex:u,width:n,height:r,style:nBe,ref:e}),s)}),iBe=t=>{var{children:e}=t,n=Ut(qN);if(!n)return null;var{width:r,height:i,y:s,x:o}=n;return w.createElement(p4,{width:r,height:i,x:o,y:s},e)},mG=w.forwardRef((t,e)=>{var{children:n}=t,r=eBe(t,Jze),i=ea();return i?w.createElement(iBe,null,w.createElement(fG,{isPanorama:!0},n)):w.createElement(rBe,a2({ref:e},r),w.createElement(fG,{isPanorama:!1},n))});function aBe(){var t=Or(),[e,n]=w.useState(null),r=Ut(_Te);return w.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),s=i.width/e.offsetWidth;xr(s)&&s!==r&&t(rTe(s))}},[e,t,r]),n}function pG(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 sBe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?pG(Object(n),!0).forEach(function(r){oBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):pG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function oBe(t,e,n){return(e=lBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lBe(t){var e=cBe(t,"string");return typeof e=="symbol"?e:e+""}function cBe(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 ym(){return ym=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},ym.apply(null,arguments)}var uBe=()=>(z4e(),null);function s2(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var dBe=w.forwardRef((t,e)=>{var n,r,i=w.useRef(null),[s,o]=w.useState({containerWidth:s2((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:s2((r=t.style)===null||r===void 0?void 0:r.height)}),l=w.useCallback((u,d)=>{o(f=>{var m=Math.round(u),p=Math.round(d);return f.containerWidth===m&&f.containerHeight===p?f:{containerWidth:m,containerHeight:p}})},[]),c=w.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:f}=u.getBoundingClientRect();l(d,f);var m=x=>{var{width:b,height:y}=x[0].contentRect;l(b,y)},p=new ResizeObserver(m);p.observe(u),i.current=p}},[e,l]);return w.useEffect(()=>()=>{var u=i.current;u?.disconnect()},[l]),w.createElement(w.Fragment,null,w.createElement(WN,{width:s.containerWidth,height:s.containerHeight}),w.createElement("div",ym({ref:c},t)))}),hBe=w.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,s]=w.useState({containerWidth:s2(n),containerHeight:s2(r)}),o=w.useCallback((c,u)=>{s(d=>{var f=Math.round(c),m=Math.round(u);return d.containerWidth===f&&d.containerHeight===m?d:{containerWidth:f,containerHeight:m}})},[]),l=w.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null){var{width:u,height:d}=c.getBoundingClientRect();o(u,d)}},[e,o]);return w.createElement(w.Fragment,null,w.createElement(WN,{width:i.containerWidth,height:i.containerHeight}),w.createElement("div",ym({ref:l},t)))}),fBe=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return w.createElement(w.Fragment,null,w.createElement(WN,{width:n,height:r}),w.createElement("div",ym({ref:e},t)))}),mBe=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return Iu(n)||Iu(r)?w.createElement(hBe,ym({},t,{ref:e})):w.createElement(fBe,ym({},t,{ref:e}))});function pBe(t){return t===!0?dBe:mBe}var gBe=w.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:s,onContextMenu:o,onDoubleClick:l,onMouseDown:c,onMouseEnter:u,onMouseLeave:d,onMouseMove:f,onMouseUp:m,onTouchEnd:p,onTouchMove:x,onTouchStart:b,style:y,width:v,responsive:S,dispatchTouchEvents:N=!0}=t,C=w.useRef(null),T=Or(),[k,E]=w.useState(null),[D,A]=w.useState(null),R=aBe(),F=O4(),O=F?.width>0?F.width:v,H=F?.height>0?F.height:i,j=w.useCallback(xe=>{R(xe),typeof e=="function"&&e(xe),E(xe),A(xe),xe!=null&&(C.current=xe)},[R,e,E,A]),G=w.useCallback(xe=>{T(lee(xe)),T(Uo({handler:s,reactEvent:xe}))},[T,s]),$=w.useCallback(xe=>{T(NR(xe)),T(Uo({handler:u,reactEvent:xe}))},[T,u]),q=w.useCallback(xe=>{T(UZ()),T(Uo({handler:d,reactEvent:xe}))},[T,d]),Y=w.useCallback(xe=>{T(NR(xe)),T(Uo({handler:f,reactEvent:xe}))},[T,f]),Z=w.useCallback(()=>{T(mee())},[T]),oe=w.useCallback(xe=>{T(fee(xe.key))},[T]),B=w.useCallback(xe=>{T(Uo({handler:o,reactEvent:xe}))},[T,o]),W=w.useCallback(xe=>{T(Uo({handler:l,reactEvent:xe}))},[T,l]),se=w.useCallback(xe=>{T(Uo({handler:c,reactEvent:xe}))},[T,c]),ne=w.useCallback(xe=>{T(Uo({handler:m,reactEvent:xe}))},[T,m]),ce=w.useCallback(xe=>{T(Uo({handler:b,reactEvent:xe}))},[T,b]),fe=w.useCallback(xe=>{N&&T(gee(xe)),T(Uo({handler:x,reactEvent:xe}))},[T,N,x]),ye=w.useCallback(xe=>{T(Uo({handler:p,reactEvent:xe}))},[T,p]),ge=pBe(S);return w.createElement(aJ.Provider,{value:k},w.createElement(fX.Provider,{value:D},w.createElement(ge,{width:O??y?.width,height:H??y?.height,className:Zn("recharts-wrapper",r),style:sBe({position:"relative",cursor:"default",width:O,height:H},y),onClick:G,onContextMenu:B,onDoubleClick:W,onFocus:Z,onKeyDown:oe,onMouseDown:se,onMouseEnter:$,onMouseLeave:q,onMouseMove:Y,onMouseUp:ne,onTouchEnd:ye,onTouchMove:fe,onTouchStart:ce,ref:j},w.createElement(uBe,null),n)))}),xBe=["width","height","responsive","children","className","style","compact","title","desc"];function bBe(t,e){if(t==null)return{};var n,r,i=yBe(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 yBe(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 _ee=w.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:s,className:o,style:l,compact:c,title:u,desc:d}=t,f=bBe(t,xBe),m=_s(f);return c?w.createElement(w.Fragment,null,w.createElement(WN,{width:n,height:r}),w.createElement(mG,{otherAttributes:m,title:u,desc:d},s)):w.createElement(gBe,{className:o,style:l,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},w.createElement(mG,{otherAttributes:m,title:u,desc:d,ref:e},w.createElement(PFe,null,s)))});function MR(){return MR=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},MR.apply(null,arguments)}var vBe={top:5,right:5,bottom:5,left:5},_Be={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:vBe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},pL=w.forwardRef(function(e,n){var r,i=ri(e.categoricalChartProps,_Be),{chartName:s,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,categoricalChartProps:u}=e,d={chartName:s,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,eventEmitter:void 0};return w.createElement(bee,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:s},w.createElement(FJ,{chartData:u.data}),w.createElement(yee,{layout:i.layout,margin:i.margin}),w.createElement(vee,{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}),w.createElement(_ee,MR({},i,{ref:n})))}),wBe=["axis"],SBe=w.forwardRef((t,e)=>w.createElement(pL,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:wBe,tooltipPayloadSearcher:fM,categoricalChartProps:t,ref:e})),NBe=["axis","item"],MBe=w.forwardRef((t,e)=>w.createElement(pL,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:NBe,tooltipPayloadSearcher:fM,categoricalChartProps:t,ref:e}));function EBe(t){var e=Or();return w.useEffect(()=>{e(qze(t))},[e,t]),null}var CBe=["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 TBe(t,e){if(t==null)return{};var n,r,i=ABe(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 ABe(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 kBe={top:5,right:5,bottom:5,left:5},wee={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:kBe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},jBe=w.forwardRef(function(e,n){var r,i=ri(e.categoricalChartProps,wee),{layout:s}=i,o=TBe(i,CBe),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return w.createElement(bee,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},w.createElement(FJ,{chartData:i.data}),w.createElement(yee,{layout:s,margin:i.margin}),w.createElement(vee,{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}),w.createElement(EBe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),w.createElement(_ee,ER({},o,{ref:n})))});function gG(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 xG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?gG(Object(n),!0).forEach(function(r){PBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):gG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function PBe(t,e,n){return(e=RBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function RBe(t){var e=DBe(t,"string");return typeof e=="symbol"?e:e+""}function DBe(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 OBe=["item"],LBe=xG(xG({},wee),{},{layout:"centric",startAngle:0,endAngle:360}),IBe=w.forwardRef((t,e)=>{var n=ri(t,LBe);return w.createElement(jBe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:OBe,tooltipPayloadSearcher:fM,categoricalChartProps:n,ref:e})}),FBe=["axis"],UBe=w.forwardRef((t,e)=>w.createElement(pL,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:FBe,tooltipPayloadSearcher:fM,categoricalChartProps:t,ref:e}));const bG=[{value:"6h",label:"6h",hours:6},{value:"24h",label:"24h",hours:24},{value:"48h",label:"48h",hours:48},{value:"7d",label:"7d",hours:168}];function zBe({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:s,initialMode:o="humidity",thresholds:l}){const{t:c}=Oy(),{mode:u}=Oh(),[d,f]=w.useState("24h"),[m,p]=w.useState(o),x=u==="dark",{data:b}=at({queryKey:["settings"],queryFn:ue.getSettings}),y=b?.time_format||"system";w.useEffect(()=>{if(!t)return;const ne=ce=>{ce.key==="Escape"&&e()};return window.addEventListener("keydown",ne),()=>window.removeEventListener("keydown",ne)},[t,e]);const v=bG.find(ne=>ne.value===d)?.hours||24,{data:S,isLoading:N,error:C}=at({queryKey:["ams-history",n,i,v],queryFn:()=>ue.getAMSHistory(n,i,v),enabled:t,refetchInterval:6e4});if(!t)return null;const T=S?.data.map(ne=>{const ce=Ri(ne.recorded_at)||new Date,fe={hour:"2-digit",minute:"2-digit",...v>24?{day:"numeric",month:"short"}:{}};return{time:ce.getTime(),humidity:ne.humidity,temperature:ne.temperature,timeLabel:ce.toLocaleTimeString([],y0(fe,y))}})||[],k=l?.humidityGood||40,E=l?.humidityFair||60,D=l?.tempGood||30,A=l?.tempFair||35,R=T[T.length-1],F=R?.humidity,O=R?.temperature,H=ne=>{const ce=ne.filter(Ue=>Ue!=null);if(ce.length<4)return"stable";const fe=ce.slice(0,Math.floor(ce.length/4)),ye=ce.slice(-Math.floor(ce.length/4)),ge=fe.reduce((Ue,be)=>Ue+be,0)/fe.length,Pe=ye.reduce((Ue,be)=>Ue+be,0)/ye.length-ge;return Math.abs(Pe)<2?"stable":Pe>0?"up":"down"},j=H(T.map(ne=>ne.humidity)),G=H(T.map(ne=>ne.temperature)),$=({trend:ne})=>ne==="up"?a.jsx(v3,{className:"w-4 h-4 text-red-400"}):ne==="down"?a.jsx(DW,{className:"w-4 h-4 text-green-400"}):a.jsx(b3,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),q=ne=>ne==null?"#9ca3af":ne<=k?"#22a352":ne<=E?"#d4a017":"#c62828",Y=ne=>ne==null?"#9ca3af":ne<=D?"#22a352":ne<=A?"#d4a017":"#c62828",Z=x?"#2d2d2d":"#ffffff",oe=x?"#1d1d1d":"#f3f4f6",B=x?"#3d3d3d":"#e5e7eb",W=x?"#ffffff":"#111827",se=x?"#9ca3af":"#4b5563";return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:a.jsxs("div",{className:"rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl",style:{backgroundColor:Z},onClick:ne=>ne.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:B},children:[a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold",style:{color:W},children:[s," ",c("common.history","History")]}),a.jsx("p",{className:"text-sm",style:{color:se},children:r})]}),a.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:se},children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:oe},children:[a.jsxs("button",{onClick:()=>p("humidity"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${m==="humidity"?"bg-blue-600 text-white":""}`,style:m!=="humidity"?{color:se}:void 0,children:[a.jsx(kD,{className:"w-4 h-4"}),c("common.humidity","Humidity")]}),a.jsxs("button",{onClick:()=>p("temperature"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${m==="temperature"?"bg-orange-600 text-white":""}`,style:m!=="temperature"?{color:se}:void 0,children:[a.jsx(yN,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),a.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:oe},children:bG.map(ne=>a.jsx("button",{onClick:()=>f(ne.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===ne.value?"bg-bambu-green text-white":""}`,style:d!==ne.value?{color:se}:void 0,children:ne.label},ne.value))})]}),a.jsx("div",{className:"grid grid-cols-4 gap-4",children:m==="humidity"?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:oe},children:[a.jsx("p",{className:"text-xs",style:{color:se},children:c("common.current","Current")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("p",{className:"text-2xl font-bold",style:{color:q(F)},children:F!=null?`${F}%`:"—"}),a.jsx($,{trend:j})]})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:oe},children:[a.jsx("p",{className:"text-xs",style:{color:se},children:c("common.average","Average")}),a.jsx("p",{className:"text-2xl font-bold",style:{color:W},children:S?.avg_humidity!=null?`${S.avg_humidity}%`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:oe},children:[a.jsx("p",{className:"text-xs",style:{color:se},children:c("common.min","Min")}),a.jsx("p",{className:"text-2xl font-bold text-green-500",children:S?.min_humidity!=null?`${S.min_humidity}%`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:oe},children:[a.jsx("p",{className:"text-xs",style:{color:se},children:c("common.max","Max")}),a.jsx("p",{className:"text-2xl font-bold text-red-500",children:S?.max_humidity!=null?`${S.max_humidity}%`:"—"})]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:oe},children:[a.jsx("p",{className:"text-xs",style:{color:se},children:c("common.current","Current")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("p",{className:"text-2xl font-bold",style:{color:Y(O)},children:O!=null?`${O}°C`:"—"}),a.jsx($,{trend:G})]})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:oe},children:[a.jsx("p",{className:"text-xs",style:{color:se},children:c("common.average","Average")}),a.jsx("p",{className:"text-2xl font-bold",style:{color:W},children:S?.avg_temperature!=null?`${S.avg_temperature}°C`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:oe},children:[a.jsx("p",{className:"text-xs",style:{color:se},children:c("common.min","Min")}),a.jsx("p",{className:"text-2xl font-bold text-blue-500",children:S?.min_temperature!=null?`${S.min_temperature}°C`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:oe},children:[a.jsx("p",{className:"text-xs",style:{color:se},children:c("common.max","Max")}),a.jsx("p",{className:"text-2xl font-bold text-red-500",children:S?.max_temperature!=null?`${S.max_temperature}°C`:"—"})]})]})}),a.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:oe},children:N?a.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:se},children:c("common.loading","Loading...")}):C?a.jsx("div",{className:"h-[300px] flex items-center justify-center text-red-500",children:c("common.error","Error loading data")}):T.length===0?a.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:se},children:c("common.noData","No data available for this time range")}):a.jsx(k1,{width:"100%",height:300,children:a.jsxs(SBe,{data:T,children:[a.jsx(t2,{strokeDasharray:"3 3",stroke:x?"#3d3d3d":"#e5e7eb"}),a.jsx(r2,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:ne=>{const ce=new Date(ne);return v>24?ce.toLocaleDateString([],{day:"numeric",month:"short"}):ce.toLocaleTimeString([],y0({hour:"2-digit",minute:"2-digit"},y))},stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12}}),a.jsx(i2,{stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:m==="humidity"?[0,100]:["auto","auto"],tickFormatter:ne=>m==="humidity"?`${ne}%`:`${ne}°C`}),a.jsx(P1,{contentStyle:{backgroundColor:x?"#2d2d2d":"#ffffff",border:`1px solid ${x?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:x?"#fff":"#000"},labelFormatter:ne=>new Date(ne).toLocaleString(void 0,y0({year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},y)),formatter:ne=>[m==="humidity"?`${ne??0}%`:`${ne??0}°C`,m==="humidity"?"Humidity":"Temperature"]}),a.jsx(z4,{}),m==="humidity"?a.jsxs(a.Fragment,{children:[a.jsx(u0,{y:k,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),a.jsx(u0,{y:E,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):a.jsxs(a.Fragment,{children:[a.jsx(u0,{y:D,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),a.jsx(u0,{y:A,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),a.jsx(ZJ,{type:"monotone",dataKey:m,name:m==="humidity"?"Humidity":"Temperature",stroke:m==="humidity"?"#3b82f6":"#f97316",strokeWidth:2,dot:!1,activeDot:{r:4}})]})})}),a.jsx("div",{className:"text-xs text-center",style:{color:se},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function ij({data:t,children:e,disabled:n,className:r="",spoolman:i,configureSlot:s}){const[o,l]=w.useState(!1),[c,u]=w.useState("top"),[d,f]=w.useState(!1),m=w.useRef(null),p=w.useRef(null),x=w.useRef(null),b=()=>{const k=t.trayUuid;k&&(navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(k).then(()=>{f(!0),setTimeout(()=>f(!1),2e3)}).catch(()=>{y(k)}):y(k))},y=k=>{const E=document.createElement("textarea");E.value=k,E.style.position="fixed",E.style.opacity="0",document.body.appendChild(E),E.select();try{document.execCommand("copy"),f(!0),setTimeout(()=>f(!1),2e3)}catch{console.error("Failed to copy to clipboard")}document.body.removeChild(E)};w.useEffect(()=>{if(o&&m.current&&p.current){const k=m.current.getBoundingClientRect(),E=p.current.offsetHeight,D=k.top,A=window.innerHeight-k.bottom;D<E+12&&A>D?u("bottom"):u("top")}},[o]);const v=()=>{n||(x.current&&clearTimeout(x.current),x.current=setTimeout(()=>l(!0),80))},S=()=>{x.current&&clearTimeout(x.current),x.current=setTimeout(()=>l(!1),100)};w.useEffect(()=>()=>{x.current&&clearTimeout(x.current)},[]);const N=k=>k<=15?"#ef4444":k<=30?"#f97316":k<=50?"#eab308":"#22c55e",C=k=>{if(!k)return!1;const E=k.replace("#",""),D=parseInt(E.slice(0,2),16),A=parseInt(E.slice(2,4),16),R=parseInt(E.slice(4,6),16);return(.299*D+.587*A+.114*R)/255>.6},T=t.colorHex?`#${t.colorHex.replace("#","")}`:null;return a.jsxs("div",{ref:m,className:`relative ${r}`,onMouseEnter:v,onMouseLeave:S,children:[e,o&&a.jsxs("div",{ref:p,className:`
  8097. absolute left-1/2 -translate-x-1/2 z-50
  8098. ${c==="top"?"bottom-full mb-2":"top-full mt-2"}
  8099. animate-in fade-in-0 zoom-in-95 duration-150
  8100. `,style:{maxWidth:"calc(100vw - 24px)"},children:[a.jsxs("div",{className:`
  8101. w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary
  8102. rounded-lg shadow-xl overflow-hidden
  8103. backdrop-blur-sm
  8104. `,children:[a.jsxs("div",{className:"h-12 relative overflow-hidden",style:{backgroundColor:T||"#3d3d3d"},children:[a.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10 to-transparent"}),a.jsx("div",{className:`
  8105. absolute inset-0 flex items-center justify-center
  8106. font-semibold text-sm tracking-wide
  8107. ${C(T)?"text-black/80":"text-white/90"}
  8108. `,children:t.colorName}),a.jsx("div",{className:`
  8109. absolute top-1.5 right-1.5 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider
  8110. ${t.vendor==="Bambu Lab"?"bg-black/60 text-white":"bg-black/50 text-white/90"}
  8111. `,children:t.vendor==="Bambu Lab"?"BBL":"GEN"})]}),a.jsxs("div",{className:"p-3 space-y-2.5",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Profile"}),a.jsx("span",{className:"text-xs text-white font-semibold truncate max-w-[120px]",children:t.profile})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"K Factor"}),a.jsx("span",{className:"text-xs text-bambu-green font-mono font-bold",children:t.kFactor})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium flex items-center gap-1",children:[a.jsx(kD,{className:"w-3 h-3"}),"Fill"]}),a.jsx("span",{className:"text-xs text-white font-semibold",children:t.fillLevel!==null?`${t.fillLevel}%`:"—"})]}),a.jsx("div",{className:"h-1.5 bg-black/40 rounded-full overflow-hidden",children:t.fillLevel!==null?a.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${t.fillLevel}%`,backgroundColor:N(t.fillLevel)}}):a.jsx("div",{className:"h-full w-full bg-bambu-gray/30 rounded-full"})})]}),i?.enabled&&t.trayUuid&&a.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Spool ID"}),a.jsxs("button",{onClick:k=>{k.stopPropagation(),b()},className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",title:"Copy spool UUID",children:[a.jsxs("span",{className:"font-mono text-[10px] truncate max-w-[80px]",children:[t.trayUuid.slice(0,8),"..."]}),d?a.jsx(Wi,{className:"w-3 h-3 text-bambu-green"}):a.jsx(Ll,{className:"w-3 h-3"})]})]}),i.onLinkSpool&&a.jsxs("button",{onClick:k=>{k.stopPropagation(),i.hasUnlinkedSpools!==!1&&i.onLinkSpool?.(t.trayUuid)},disabled:i.hasUnlinkedSpools===!1,className:`w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors ${i.hasUnlinkedSpools===!1?"bg-bambu-gray/10 text-bambu-gray cursor-not-allowed":"bg-bambu-green/20 hover:bg-bambu-green/30 text-bambu-green"}`,title:i.hasUnlinkedSpools===!1?"No unlinked spools available":"Link this spool to a Spoolman spool",children:[a.jsx(dc,{className:"w-3.5 h-3.5"}),"Link to Spoolman"]})]}),s?.enabled&&a.jsx("div",{className:`${i?.enabled&&t.trayUuid?"":"pt-2 mt-2 border-t border-bambu-dark-tertiary"}`,children:a.jsxs("button",{onClick:k=>{k.stopPropagation(),s.onConfigure?.()},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 hover:bg-bambu-blue/30 text-bambu-blue",title:"Configure slot with filament profile and K value",children:[a.jsx(bh,{className:"w-3.5 h-3.5"}),"Configure"]})})]})]}),a.jsx("div",{className:`
  8112. absolute left-1/2 -translate-x-1/2 w-0 h-0
  8113. border-l-[6px] border-l-transparent
  8114. border-r-[6px] border-r-transparent
  8115. ${c==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
  8116. `})]})]})}function yG({children:t,className:e="",configureSlot:n}){const[r,i]=w.useState(!1),s=w.useRef(null),o=()=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>i(!0),80)},l=()=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>i(!1),100)};return w.useEffect(()=>()=>{s.current&&clearTimeout(s.current)},[]),a.jsxs("div",{className:`relative ${e}`,onMouseEnter:o,onMouseLeave:l,children:[t,r&&a.jsxs("div",{className:`
  8117. absolute left-1/2 -translate-x-1/2 bottom-full mb-2 z-50
  8118. animate-in fade-in-0 zoom-in-95 duration-150
  8119. `,children:[a.jsxs("div",{className:`
  8120. bg-bambu-dark-secondary border border-bambu-dark-tertiary
  8121. rounded-md shadow-lg overflow-hidden
  8122. `,children:[a.jsx("div",{className:"px-3 py-1.5 text-xs text-bambu-gray whitespace-nowrap",children:"Empty slot"}),n?.enabled&&a.jsx("div",{className:"px-2 pb-2",children:a.jsxs("button",{onClick:c=>{c.stopPropagation(),n.onConfigure?.()},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 hover:bg-bambu-blue/30 text-bambu-blue",title:"Configure slot with filament profile and K value",children:[a.jsx(bh,{className:"w-3.5 h-3.5"}),"Configure"]})})]}),a.jsx("div",{className:`
  8123. absolute left-1/2 -translate-x-1/2 top-full w-0 h-0
  8124. border-l-[5px] border-l-transparent
  8125. border-r-[5px] border-r-transparent
  8126. border-t-[5px] border-t-bambu-dark-tertiary
  8127. `})]})]})}function BBe({isOpen:t,onClose:e,trayUuid:n,trayInfo:r}){const i=on(),[s,o]=w.useState(null),{data:l,isLoading:c}=at({queryKey:["unlinked-spools"],queryFn:ue.getUnlinkedSpools,enabled:t}),u=mt({mutationFn:f=>ue.linkSpool(f,n),onSuccess:()=>{i.invalidateQueries({queryKey:["unlinked-spools"]}),i.invalidateQueries({queryKey:["spoolman-status"]}),e()}});if(!t)return null;const d=()=>{s&&u.mutate(s)};return a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),a.jsxs("div",{className:"relative w-full max-w-md mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(dc,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Link to Spoolman"})]}),a.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[r&&a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Linking AMS tray:"}),a.jsxs("div",{className:"flex items-center gap-2",children:[r.color&&a.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${r.color}`}}),a.jsx("span",{className:"text-white font-medium",children:r.type}),a.jsxs("span",{className:"text-bambu-gray",children:["(",r.location,")"]})]})]}),a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Spool UUID:"}),a.jsx("code",{className:"text-xs text-bambu-green font-mono break-all",children:n})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Select a Spoolman spool to link:"}),c?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(ct,{className:"w-6 h-6 text-bambu-green animate-spin"})}):l&&l.length>0?a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-2",children:l.map(f=>a.jsx("button",{onClick:()=>o(f.id),className:`w-full p-3 rounded-lg border text-left transition-colors ${s===f.id?"bg-bambu-green/20 border-bambu-green":"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:a.jsxs("div",{className:"flex items-center gap-2",children:[f.filament_color_hex&&a.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:`#${f.filament_color_hex}`}}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-white font-medium truncate",children:f.filament_name||"Unknown filament"}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[f.filament_material||"Unknown",f.remaining_weight!==null&&` - ${Math.round(f.remaining_weight)}g`,f.location&&` - ${f.location}`]})]}),s===f.id&&a.jsx(Wi,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]})},f.id))}):a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx("p",{children:"No unlinked spools found in Spoolman."}),a.jsx("p",{className:"text-xs mt-1",children:"All spools are already linked to AMS trays."})]})]})]}),a.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Ne,{variant:"secondary",onClick:e,children:"Cancel"}),a.jsx(Ne,{onClick:d,disabled:!s||u.isPending,children:u.isPending?a.jsxs(a.Fragment,{children:[a.jsx(ct,{className:"w-4 h-4 animate-spin"}),"Linking..."]}):a.jsxs(a.Fragment,{children:[a.jsx(dc,{className:"w-4 h-4"}),"Link Spool"]})})]}),u.isError&&a.jsx("div",{className:"mx-4 mb-4 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:u.error.message})]})]})}function $Be(t,e){if(t===255)return"External";let n,r=!1;t>=128&&t<=135?(n=t-128,r=!0):t>=0&&t<=3?(n=t,r=e===1):n=0,n=Math.max(0,Math.min(n,7));const i=String.fromCharCode(65+n);return r?`HT-${i}`:`AMS-${i}`}function vG(t){const e=t.includes("_")?t.split("_")[0]:t;return e.startsWith("GFS")?"GF"+e.slice(3):(e.startsWith("PFUS")||e.startsWith("PFSP"),e)}const HBe=["PLA","PETG","ABS","ASA","TPU","PC","PA","NYLON","PVA","HIPS","PP","PET"];function _G(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const i of HBe){const s=new RegExp(`\\b${i}\\b`,"i");if(s.test(n)){const o=e.split(s),l=o[0]?.trim()||"",c=o[1]?.trim()||"";return{material:i,brand:l,variant:c}}}const r=e.split(/\s+/);return r.length>=2?{material:r[1],brand:r[0],variant:r.slice(2).join(" ")}:{material:e,brand:"",variant:""}}function aj(t){return!t.startsWith("GF")&&!t.startsWith("P1")}const VBe={white:"FFFFFF",black:"000000",red:"FF0000",green:"00FF00",blue:"0000FF",yellow:"FFFF00",cyan:"00FFFF",magenta:"FF00FF",orange:"FFA500",purple:"800080",pink:"FFC0CB",brown:"8B4513",gray:"808080",grey:"808080","jade white":"FFFEF2",ivory:"FFFFF0",beige:"F5F5DC",cream:"FFFDD0",silver:"C0C0C0",gold:"FFD700",bronze:"CD7F32",copper:"B87333",navy:"000080",teal:"008080",olive:"808000",maroon:"800000",coral:"FF7F50",salmon:"FA8072",lime:"32CD32",mint:"98FF98","forest green":"228B22","sky blue":"87CEEB","royal blue":"4169E1",turquoise:"40E0D0",lavender:"E6E6FA",violet:"EE82EE",plum:"DDA0DD",tan:"D2B48C",chocolate:"D2691E",charcoal:"36454F",slate:"708090",transparent:"000000",natural:"F5F5DC",wood:"DEB887"},GBe=[{name:"White",hex:"FFFFFF"},{name:"Black",hex:"000000"},{name:"Red",hex:"FF0000"},{name:"Blue",hex:"0000FF"},{name:"Green",hex:"00AA00"},{name:"Yellow",hex:"FFFF00"},{name:"Orange",hex:"FFA500"},{name:"Gray",hex:"808080"}],qBe=[{name:"Cyan",hex:"00FFFF"},{name:"Magenta",hex:"FF00FF"},{name:"Purple",hex:"800080"},{name:"Pink",hex:"FFC0CB"},{name:"Brown",hex:"8B4513"},{name:"Beige",hex:"F5F5DC"},{name:"Navy",hex:"000080"},{name:"Teal",hex:"008080"},{name:"Lime",hex:"32CD32"},{name:"Gold",hex:"FFD700"},{name:"Silver",hex:"C0C0C0"},{name:"Maroon",hex:"800000"},{name:"Olive",hex:"808000"},{name:"Coral",hex:"FF7F50"},{name:"Salmon",hex:"FA8072"},{name:"Turquoise",hex:"40E0D0"},{name:"Violet",hex:"EE82EE"},{name:"Indigo",hex:"4B0082"},{name:"Chocolate",hex:"D2691E"},{name:"Tan",hex:"D2B48C"},{name:"Slate",hex:"708090"},{name:"Charcoal",hex:"36454F"},{name:"Ivory",hex:"FFFFF0"},{name:"Cream",hex:"FFFDD0"}];function WBe(t){const e=t.toLowerCase().trim();return VBe[e]||null}function KBe({isOpen:t,onClose:e,printerId:n,slotInfo:r,nozzleDiameter:i="0.4",onSuccess:s}){const[o,l]=w.useState(""),[c,u]=w.useState(null),[d,f]=w.useState(""),[m,p]=w.useState(""),[x,b]=w.useState(""),[y,v]=w.useState(!1),[S,N]=w.useState(!1),{data:C,isLoading:T}=at({queryKey:["cloudSettings"],queryFn:()=>ue.getCloudSettings(),enabled:t}),{data:k,isLoading:E}=at({queryKey:["kprofiles",n,i],queryFn:()=>ue.getKProfiles(n,i),enabled:t&&!!n}),D=mt({mutationFn:async()=>{if(!o)throw new Error("No filament preset selected");const Y=C?.filament.find(xe=>xe.setting_id===o);if(!Y)throw new Error("Selected preset not found");const Z=_G(Y.name),oe=c?.slot_id??-1,B=d||r.trayColor?.slice(0,6)||"FFFFFF",W=Y.name.replace(/@.+$/,"").trim();let se=vG(o);if(!o.startsWith("GFS"))try{const xe=await ue.getCloudSettingDetail(o);xe.filament_id?se=xe.filament_id:xe.base_id&&(se=vG(xe.base_id),console.log(`Derived tray_info_idx from base_id: ${xe.base_id} -> ${se}`))}catch(xe){console.warn("Failed to fetch preset detail for filament_id:",xe)}let ne=190,ce=230;const fe=Z.material.toUpperCase();fe.includes("PLA")?(ne=190,ce=230):fe.includes("PETG")?(ne=220,ce=260):fe.includes("ABS")||fe.includes("ASA")?(ne=240,ce=280):fe.includes("TPU")?(ne=200,ce=240):fe.includes("PC")?(ne=260,ce=300):(fe.includes("PA")||fe.includes("NYLON"))&&(ne=250,ce=290);const ye=c?.k_value?parseFloat(c.k_value):0,ge=await ue.configureAmsSlot(n,r.amsId,r.trayId,{tray_info_idx:se,tray_type:Z.material||"PLA",tray_sub_brands:W,tray_color:B+"FF",nozzle_temp_min:ne,nozzle_temp_max:ce,cali_idx:oe,nozzle_diameter:i,setting_id:o,kprofile_filament_id:c?.filament_id,kprofile_setting_id:c?.setting_id||void 0,k_value:ye});try{await ue.saveSlotPreset(n,r.amsId,r.trayId,o,W)}catch(xe){console.warn("Failed to save slot preset mapping:",xe)}return ge},onSuccess:()=>{v(!0),s?.(),setTimeout(()=>{v(!1),e()},1500)}}),A=mt({mutationFn:async()=>ue.resetAmsSlot(n,r.amsId,r.trayId),onSuccess:()=>{v(!0),s?.(),setTimeout(()=>{v(!1),e()},1500)}}),R=w.useMemo(()=>{if(!C?.filament)return[];const Y=x.toLowerCase();return C.filament.filter(Z=>Y?Z.name.toLowerCase().includes(Y):!0).sort((Z,oe)=>{const B=aj(Z.setting_id),W=aj(oe.setting_id);return B&&!W?-1:!B&&W?1:Z.name.localeCompare(oe.name)})},[C?.filament,x]),F=w.useMemo(()=>{if(!o||!C?.filament)return null;const Y=C.filament.find(B=>B.setting_id===o);if(!Y)return null;let Z=Y.name.replace(/@.+$/,"").trim();Z.startsWith("# ")&&(Z=Z.slice(2).trim());const oe=_G(Z);return{fullName:Z,material:oe.material,brand:oe.brand}},[o,C?.filament]),O=F?.fullName||"",H=w.useMemo(()=>{if(!k?.profiles||!F)return[];const{fullName:Y,material:Z,brand:oe}=F,B=Y.toUpperCase(),W=Z.toUpperCase(),se=oe.toUpperCase();if(!W||W.length<2)return[];const ne=k.profiles.filter(fe=>{const ye=fe.name.toUpperCase();if(se)return!(!ye.includes(se)||!ye.includes(W));if(ye.includes(B)||ye.includes(W))return!0;const xe={NYLON:["PA","PA-CF","PA6"],PA:["NYLON"]}[W]||[];for(const Pe of xe)if(ye.includes(Pe))return!0;return!1}),ce=new Map;for(const fe of ne){const ye=`${fe.name}|${fe.k_value}`,ge=ce.get(ye);ge?fe.extruder_id===1&&ge.extruder_id===0&&ce.set(ye,fe):ce.set(ye,fe)}return Array.from(ce.values())},[k?.profiles,F]);w.useEffect(()=>{if(t&&C?.filament){if(r.trayInfoIdx){const Y=C.filament.find(Z=>Z.setting_id===r.trayInfoIdx);Y&&l(Y.setting_id)}}else t||(l(""),u(null),f(""),p(""),b(""),v(!1))},[t,C?.filament,r.trayInfoIdx]),w.useEffect(()=>{H.length>0?u(H[0]):u(null)},[o,H]);const j=w.useCallback(Y=>{Y.key==="Escape"&&e()},[e]);if(w.useEffect(()=>{if(t)return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[t,j]),!t)return null;const G=T||E,$=o&&!D.isPending,q=d||r.trayColor?.slice(0,6)||"FFFFFF";return a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),a.jsxs("div",{className:"relative w-full max-w-lg mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(bh,{className:"w-5 h-5 text-bambu-blue"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Configure AMS Slot"})]}),a.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-4 max-h-[60vh] overflow-y-auto",children:[y&&a.jsx("div",{className:"absolute inset-0 bg-bambu-dark-secondary/95 z-10 flex items-center justify-center rounded-xl",children:a.jsxs("div",{className:"text-center space-y-3",children:[a.jsx(oN,{className:"w-16 h-16 text-bambu-green mx-auto"}),a.jsx("p",{className:"text-lg font-semibold text-white",children:"Slot Configured!"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Settings sent to printer"})]})}),a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Configuring slot:"}),a.jsxs("div",{className:"flex items-center gap-2",children:[r.trayColor&&a.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${r.trayColor.slice(0,6)}`}}),a.jsxs("span",{className:"text-white font-medium",children:[$Be(r.amsId,r.trayCount)," Slot ",r.trayId+1]}),r.traySubBrands&&a.jsxs("span",{className:"text-bambu-gray",children:["(",r.traySubBrands,")"]})]})]}),G?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(ct,{className:"w-6 h-6 text-bambu-green animate-spin"})}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["Filament Profile ",a.jsx("span",{className:"text-red-400",children:"*"})]}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"text",placeholder:"Search presets...",value:x,onChange:Y=>b(Y.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none mb-2"}),a.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:R.length===0?a.jsx("p",{className:"text-center py-4 text-bambu-gray",children:C?.filament?.length===0?"No cloud presets. Login to Bambu Cloud to sync.":"No matching presets found."}):R.map(Y=>a.jsx("button",{onClick:()=>l(Y.setting_id),className:`w-full p-2 rounded-lg border text-left transition-colors ${o===Y.setting_id?"bg-bambu-green/20 border-bambu-green":"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-white text-sm truncate",children:Y.name}),aj(Y.setting_id)&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bambu-blue/20 text-bambu-blue",children:"Custom"})]})},Y.setting_id))})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["K Profile (Pressure Advance)",O&&a.jsxs("span",{className:"ml-2 text-xs text-bambu-blue",children:["Filtering for: ",O]})]}),H.length>0?a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:c?.name||"",onChange:Y=>{const Z=H.find(oe=>oe.name===Y.target.value);u(Z||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 appearance-none pr-10",children:[a.jsx("option",{value:"",children:"No K profile (use default 0.020)"}),H.map(Y=>a.jsxs("option",{value:Y.name,children:[Y.name," (K=",Y.k_value,")"]},`${Y.name}-${Y.extruder_id}`))]}),a.jsx(Xr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}):o?a.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:"No matching K profiles found. Default K=0.020 will be used."}):a.jsx("span",{className:"inline-block text-xs px-2 py-1 rounded bg-amber-500/20 text-amber-400 border border-amber-500/30",children:"Select a filament profile first"}),c&&a.jsxs("p",{className:"text-xs text-bambu-green mt-1",children:["K=",c.k_value," from printer calibration"]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Custom Color (optional)"}),a.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[GBe.map(Y=>a.jsx("button",{onClick:()=>{f(Y.hex),p(Y.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===Y.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${Y.hex}`},title:Y.name},Y.hex)),a.jsx("button",{onClick:()=>N(!S),className:"w-7 h-7 rounded-md border-2 border-white/20 hover:border-white/40 flex items-center justify-center text-white/60 hover:text-white/80 transition-all text-xs",title:S?"Show less colors":"Show more colors",children:S?"−":"+"})]}),S&&a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:qBe.map(Y=>a.jsx("button",{onClick:()=>{f(Y.hex),p(Y.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===Y.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${Y.hex}`},title:Y.name},Y.hex))}),a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg border-2 border-white/20 flex-shrink-0",style:{backgroundColor:`#${q}`}}),a.jsx("input",{type:"text",placeholder:"Color name or hex (e.g., brown, FF8800)",value:m,onChange:Y=>{const Z=Y.target.value;p(Z);const oe=WBe(Z);if(oe)f(oe);else{const B=Z.replace(/[^0-9A-Fa-f]/g,"").toUpperCase();B.length===6?f(B):B.length===3&&f(B.split("").map(W=>W+W).join(""))}},className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none text-sm"}),d&&a.jsx("button",{onClick:()=>{f(""),p("")},className:"px-2 py-1 text-xs text-bambu-gray hover:text-white bg-bambu-dark-tertiary rounded",title:"Clear custom color",children:"Clear"})]}),d&&a.jsxs("p",{className:"text-xs text-bambu-gray mt-1.5",children:["Hex: #",d]})]})]})]}),a.jsxs("div",{className:"flex justify-between p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Ne,{variant:"secondary",onClick:()=>A.mutate(),disabled:A.isPending||D.isPending,className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:A.isPending?a.jsxs(a.Fragment,{children:[a.jsx(ct,{className:"w-4 h-4 animate-spin"}),"Resetting..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Dh,{className:"w-4 h-4"}),"Reset Slot"]})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ne,{variant:"secondary",onClick:e,children:"Cancel"}),a.jsx(Ne,{onClick:()=>D.mutate(),disabled:!$,children:D.isPending?a.jsxs(a.Fragment,{children:[a.jsx(ct,{className:"w-4 h-4 animate-spin"}),"Configuring..."]}):a.jsxs(a.Fragment,{children:[a.jsx(bh,{className:"w-4 h-4"}),"Configure Slot"]})})]})]}),(D.isError||A.isError)&&a.jsx("div",{className:"mx-4 mb-4 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:D.error?.message||A.error?.message})]})]})}function XBe({on:t,className:e="w-5 h-5"}){const n=t?"#facc15":"none",r=t?"#78350f":"currentColor",i=t?1:0;return a.jsxs("svg",{viewBox:"0 0 32 32",fill:"none",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[a.jsxs("g",{stroke:r,opacity:i,children:[a.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),a.jsx("line",{x1:"6.1",y1:"6.1",x2:"8.9",y2:"8.9"}),a.jsx("line",{x1:"25.9",y1:"6.1",x2:"23.1",y2:"8.9"}),a.jsx("line",{x1:"2",y1:"16",x2:"6",y2:"16"}),a.jsx("line",{x1:"30",y1:"16",x2:"26",y2:"16"})]}),a.jsx("path",{d:"M12 24v-2.3c0-.9-.4-1.7-1-2.3C9.2 17.6 8 15.4 8 13c0-4.4 3.6-8 8-8s8 3.6 8 8c0 2.4-1.2 4.6-3 6.4-.6.6-1 1.4-1 2.3V24",fill:n,stroke:r}),a.jsx("path",{d:"M12 24h8",stroke:r}),a.jsx("path",{d:"M12 27h8",stroke:r}),a.jsx("path",{d:"M13 30h6",stroke:r})]})}const wG=({className:t})=>a.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[a.jsx("rect",{x:"2",y:"15",width:"5",height:"5",rx:"0.5"}),a.jsx("rect",{x:"9.5",y:"15",width:"5",height:"5",rx:"0.5",fill:"currentColor",opacity:"0.3"}),a.jsx("rect",{x:"17",y:"15",width:"5",height:"5",rx:"0.5"}),a.jsx("path",{d:"M4 12 C4 6, 14 6, 14 12"}),a.jsx("polyline",{points:"12,10 14,12 12,14"})]}),SG={"A00-W1":"Jade White","A00-P0":"Beige","A00-D2":"Light Gray","A00-Y0":"Yellow","A00-Y2":"Sunflower Yellow","A00-A1":"Pumpkin Orange","A00-A0":"Orange","A00-Y4":"Gold","A00-G3":"Bright Green","A00-G1":"Bambu Green","A00-G2":"Mistletoe Green","A00-R3":"Hot Pink","A00-P6":"Magenta","A00-R0":"Red","A00-R2":"Maroon Red","A00-P5":"Purple","A00-P2":"Indigo Purple","A00-B5":"Turquoise","A00-B8":"Cyan","A00-B3":"Cobalt Blue","A00-N0":"Brown","A00-N1":"Cocoa Brown","A00-Y3":"Bronze","A00-D0":"Gray","A00-D1":"Silver","A00-B1":"Blue Grey","A00-D3":"Dark Gray","A00-K0":"Black","A00-M3":"Pink Citrus","A00-M6":"Dusk Glare","A00-M0":"Arctic Whisper","A00-M1":"Solar Breeze","A00-M5":"Blueberry Bubblegum","A00-M4":"Mint Lime","A00-M2":"Ocean to Meadow","A00-M7":"Cotton Candy Cloud","A18-K0":"Black","A18-D0":"Gray","A18-W0":"White","A18-R0":"Red","A18-Y0":"Yellow","A18-B0":"Cyan","A18-B1":"Blue","A18-P0":"Matte Beige","A01-W2":"Ivory White","A01-W3":"Bone White","A01-Y2":"Lemon Yellow","A01-A2":"Mandarin Orange","A01-P3":"Sakura Pink","A01-P4":"Lilac Purple","A01-R3":"Plum","A01-R1":"Scarlet Red","A01-R4":"Dark Red","A01-G0":"Apple Green","A01-G1":"Grass Green","A01-G7":"Dark Green","A01-B4":"Ice Blue","A01-B0":"Sky Blue","A01-B3":"Marine Blue","A01-B6":"Dark Blue","A01-Y3":"Desert Tan","A01-N1":"Latte Brown","A01-N3":"Caramel","A01-R2":"Terracotta","A01-N2":"Dark Brown","A01-N0":"Dark Chocolate","A01-D3":"Ash Gray","A01-D0":"Nardo Gray","A01-K1":"Charcoal","A12-G0":"Green","A12-R0":"Pink","A12-A0":"Orange","A12-Y0":"Yellow","A12-B0":"Blue","A07-R5":"Red Granite","A07-D4":"White Marble","A11-W0":"White","A11-K0":"Black","A08-G3":"Alpine Green Sparkle","A08-D5":"Slate Gray Sparkle","A08-B7":"Royal Purple Sparkle","A08-R2":"Crimson Red Sparkle","A08-K2":"Onyx Black Sparkle","A08-Y1":"Classic Gold Sparkle","A02-B2":"Cobalt Blue Metallic","A02-G2":"Oxide Green Metallic","A02-Y1":"Iridium Gold Metallic","A02-D2":"Iron Gray Metallic","A17-B1":"Blue","A17-A0":"Orange","A17-P0":"Purple","A06-Y1":"Gold","A06-D0":"Titan Gray","A06-D1":"Silver","A06-W0":"White","A06-R0":"Candy Red","A06-G0":"Candy Green","A06-G1":"Mint","A06-B1":"Blue","A06-B0":"Baby Blue","A06-P0":"Purple","A06-R1":"Rose Gold","A06-R2":"Pink","A06-Y0":"Champagne","A05-M8":"Dawn Radiance","A05-M4":"Aurora Purple","A05-M1":"South Beach","A05-T3":"Neon City","A05-T2":"Midnight Blaze","A05-T1":"Gilded Rose","A05-T4":"Blue Hawaii","A05-T5":"Velvet Eclipse","A15-B0":"Purple","A15-G0":"Green","A15-G1":"Nebulae","A15-R0":"Brown","A16-K0":"Black Walnut","A16-R0":"Rosewood","A16-N0":"Clay Brown","A16-G0":"Classic Birch","A16-W0":"White Oak","A16-Y0":"Ochre Yellow","A50-D6":"Lava Gray","A50-K0":"Black","A50-B6":"Royal Blue","A10-W0":"White","A10-D0":"Gray","A09-B5":"Lavender Blue","A09-B4":"Light Blue","A09-A0":"Orange","A09-D1":"Silver","A09-R3":"Vermilion Red","A09-Y0":"Yellow","G02-K0":"Black","G02-W0":"White","G02-R0":"Red","G02-D0":"Gray","G02-D1":"Dark Gray","G02-Y1":"Cream","G02-Y0":"Yellow","G02-A0":"Orange","G02-N1":"Peanut Brown","G02-G1":"Lime Green","G02-G0":"Green","G02-G2":"Forest Green","G02-B1":"Lake Blue","G02-B0":"Blue","G01-G1":"Translucent Teal","G01-B0":"Translucent Light Blue","G01-C0":"Clear","G01-D0":"Translucent Gray","G01-G0":"Translucent Olive","G01-N0":"Translucent Brown","G01-A0":"Translucent Orange","G01-P1":"Translucent Pink","G01-P0":"Translucent Purple","G50-P7":"Violet Purple","G50-K0":"Black","B00-D1":"Silver","B00-K0":"Black","B00-W0":"White","B00-G6":"Bambu Green","B00-G7":"Olive","B00-Y1":"Tangerine Yellow","B00-A0":"Orange","B00-R0":"Red","B00-B4":"Azure","B00-B0":"Blue","B00-B6":"Navy Blue","B50-A0":"Orange","B50-K0":"Black","B01-W0":"White","B01-K0":"Black","B01-D0":"Gray","B02-W0":"White","C00-C1":"Transparent","C00-C0":"Clear Black","C00-K0":"Black","C00-W0":"White","C01-K0":"Black","U02-B0":"Blue","U02-D0":"Gray","U02-K0":"Black","N04-K0":"Black","N08-K0":"Black","S02-W0":"Nature","S02-W1":"White","S05-C0":"Black","S06-W0":"White","S03-G1":"Green","S04-Y0":"Clear"},YBe={W0:"White",W1:"Jade White",W2:"Ivory White",W3:"Bone White",Y0:"Yellow",Y1:"Gold",Y2:"Sunflower Yellow",Y3:"Bronze",Y4:"Gold",A0:"Orange",A1:"Pumpkin Orange",A2:"Mandarin Orange",R0:"Red",R1:"Scarlet Red",R2:"Maroon Red",R3:"Hot Pink",R4:"Dark Red",R5:"Red Granite",P0:"Beige",P1:"Pink",P2:"Indigo Purple",P3:"Sakura Pink",P4:"Lilac Purple",P5:"Purple",P6:"Magenta",P7:"Violet Purple",B0:"Blue",B1:"Blue Grey",B2:"Cobalt Blue",B3:"Cobalt Blue",B4:"Ice Blue",B5:"Turquoise",B6:"Navy Blue",B7:"Royal Purple",B8:"Cyan",G0:"Green",G1:"Grass Green",G2:"Mistletoe Green",G3:"Bright Green",G6:"Bambu Green",G7:"Dark Green",N0:"Brown",N1:"Peanut Brown",N2:"Dark Brown",N3:"Caramel",D0:"Gray",D1:"Silver",D2:"Light Gray",D3:"Dark Gray",D4:"White Marble",D5:"Slate Gray",D6:"Lava Gray",K0:"Black",K1:"Charcoal",K2:"Onyx Black",C0:"Clear Black",C1:"Transparent",M0:"Arctic Whisper",M1:"Solar Breeze",M2:"Ocean to Meadow",M3:"Pink Citrus",M4:"Aurora Purple",M5:"Blueberry Bubblegum",M6:"Dusk Glare",M7:"Cotton Candy Cloud",M8:"Dawn Radiance",T1:"Gilded Rose",T2:"Midnight Blaze",T3:"Neon City",T4:"Blue Hawaii",T5:"Velvet Eclipse"};function sj(t){if(!t)return null;if(SG[t])return SG[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return YBe[n]||null}function oj(t){if(!t||t.length<6)return"Unknown";const e=parseInt(t.substring(0,2),16),n=parseInt(t.substring(2,4),16),r=parseInt(t.substring(4,6),16),i=Math.max(e,n,r)/255,s=Math.min(e,n,r)/255,o=(i+s)/2;let l=0,c=0;if(i!==s){const u=i-s;c=o>.5?u/(2-i-s):u/(i+s);const d=e/255,f=n/255,m=r/255;i===d?l=((f-m)/u+(f<m?6:0))/6:i===f?l=((m-d)/u+2)/6:l=((d-f)/u+4)/6}return l=l*360,o<.15?"Black":o>.85?"White":c<.15?o<.4?"Dark Gray":o>.6?"Light Gray":"Gray":l>=15&&l<45&&o<.45||l>=45&&l<70&&o<.4?"Brown":l<15||l>=345?"Red":l<45?"Orange":l<70?"Yellow":l<150?"Green":l<200?"Cyan":l<260?"Blue":l<290?"Purple":l<345?"Pink":"Unknown"}function lj(t){return(t??.02).toFixed(3)}function NG({side:t}){const{mode:e}=Oh(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return a.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 MG({className:t}){return a.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:a.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 QBe({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.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"}),a.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 ZBe({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.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"}),a.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 JBe({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.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"}),a.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function e8e({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("rect",{x:"4.5",y:"8",width:"3",height:"4.5",fill:"#d4a017",rx:"0.5"}),a.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#d4a017"}),a.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 t8e({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:"#c62828",rx:"0.5"}),a.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#c62828"}),a.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 cj({className:t,color:e,isHeating:n}){const i={"text-orange-400":"#fb923c","text-blue-400":"#60a5fa","text-green-400":"#4ade80"}[e]||"#888",s=n?{filter:`drop-shadow(0 0 4px ${i}) drop-shadow(0 0 8px ${i})`}:{};return n?a.jsxs("svg",{className:t,style:s,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:i,rx:"0.5"}),a.jsx("circle",{cx:"6",cy:"15",r:"2",fill:i}),a.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:i,strokeWidth:"1",fill:"none"})]}):a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.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:i,strokeWidth:"1",fill:"none"}),a.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:i,strokeWidth:"1",fill:"none"})]})}function EG({humidity:t,goodThreshold:e=40,fairThreshold:n=60,onClick:r,compact:i}){const s=typeof t=="string"?parseInt(t,10):t,o=typeof e=="number"?e:40,l=typeof n=="number"?n:60;let c,u;isNaN(s)?(c="#C3C2C1",u="Unknown"):s<=o?(c="#22a352",u="Good"):s<=l?(c="#d4a017",u="Fair"):(c="#c62828",u="Bad");let d;return isNaN(s)||s<=o?d=MG:s<=l?d=QBe:d=ZBe,a.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Humidity: ${s}% - ${u}${r?" (click for history)":""}`,children:[a.jsx(d,{className:i?"w-2.5 h-3":"w-3 h-4"}),a.jsxs("span",{className:`font-medium tabular-nums ${i?"text-[10px]":"text-xs"}`,style:{color:c},children:[s,"%"]})]})}function CG({temp:t,goodThreshold:e=28,fairThreshold:n=35,onClick:r,compact:i}){const s=typeof e=="number"?e:28,o=typeof n=="number"?n:35;let l,c,u;return t<=s?(l="#22a352",c="Good",u=JBe):t<=o?(l="#d4a017",c="Fair",u=e8e):(l="#c62828",c="Bad",u=t8e),a.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Temperature: ${t}°C - ${c}${r?" (click for history)":""}`,children:[a.jsx(u,{className:i?"w-2.5 h-3":"w-3 h-4"}),a.jsxs("span",{className:`tabular-nums text-right ${i?"text-[10px] w-8":"w-12"}`,style:{color:l},children:[t,"°C"]})]})}function Dd(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,o=String.fromCharCode(65+s);return i?`HT-${o}`:`AMS-${o}`}function TG(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function n8e(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function r8e(t,e="system"){const n=new Date,r=new Date(n.getTime()+t*60*1e3),i=new Date;i.setHours(0,0,0,0);const s=new Date(r);s.setHours(0,0,0,0);const o={hour:"2-digit",minute:"2-digit"};e==="12h"?o.hour12=!0:e==="24h"&&(o.hour12=!1);const l=r.toLocaleTimeString([],o),c=Math.floor((s.getTime()-i.getTime())/(1e3*60*60*24));return c===0?l:c===1?`Tomorrow ${l}`:r.toLocaleDateString([],{weekday:"short"})+" "+l}function i8e(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 a8e(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 uj(t){return t?!!(t.tray_info_idx&&t.tray_info_idx.startsWith("GF")||t.tray_uuid&&t.tray_uuid!=="00000000000000000000000000000000"||t.tag_uid&&t.tag_uid!=="0000000000000000"):!1}function s8e({url:t,printName:e}){const[n,r]=w.useState(!1),[i,s]=w.useState(!1),[o,l]=w.useState(!1);return a.jsxs(a.Fragment,{children:[a.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&&l(!0),children:t&&!i?a.jsxs(a.Fragment,{children:[a.jsx("img",{src:t,alt:"Print preview",className:`w-full h-full object-cover ${n?"block":"hidden"}`,onLoad:()=>r(!0),onError:()=>s(!0)}),!n&&a.jsx(Pi,{className:"w-8 h-8 text-bambu-gray"})]}):a.jsx(Pi,{className:"w-8 h-8 text-bambu-gray"})}),o&&t&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>l(!1),children:a.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[a.jsx("img",{src:t,alt:"Print preview",className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&a.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function o8e({printers:t}){const e=on(),n=w.useMemo(()=>{let i=0,s=0,o=0,l=0;return t?.forEach(c=>{const u=e.getQueryData(["printerStatus",c.id]);u===void 0?l++:u.connected?u.state==="RUNNING"?i++:s++:o++}),{printing:i,idle:s,offline:o,loading:l,total:t?.length||0}},[t,e]),[,r]=w.useState(0);return w.useEffect(()=>{let i=!1;const s=e.getQueryCache().subscribe(()=>{i||(i=!0,requestAnimationFrame(()=>{r(o=>o+1),i=!1}))});return()=>s()},[e]),t?.length?a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[n.printing>0&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white font-medium",children:n.printing})," printing"]})]}),n.idle>0&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white font-medium",children:n.idle})," idle"]})]}),n.offline>0&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white font-medium",children:n.offline})," offline"]})]})]}):null}function AG(t,e){if(e)return e;switch(t){case"RUNNING":return"Printing";case"PAUSE":return"Paused";case"FINISH":return"Finished";case"FAILED":return"Failed";case"IDLE":return"Idle";default:return t?t.charAt(0)+t.slice(1).toLowerCase():"Idle"}}function kG({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",cardSize:i=2,amsThresholds:s,spoolmanEnabled:o=!1,hasUnlinkedSpools:l=!1,timeFormat:c="system",cameraViewMode:u="window",onOpenEmbeddedCamera:d,checkPrinterFirmware:f=!0}){const m=on(),p=Mc(),{showToast:x}=Vn(),{hasPermission:b}=Si(),[y,v]=w.useState(!1),[S,N]=w.useState(!1),[C,T]=w.useState(!0),[k,E]=w.useState(!1),[D,A]=w.useState(!1),[R,F]=w.useState(!1),[O,H]=w.useState(!1),[j,G]=w.useState(!1),[$,q]=w.useState(!1),[Y,Z]=w.useState(!1),[oe,B]=w.useState(!1),[W,se]=w.useState(!1),[ne,ce]=w.useState(!1),[fe,ye]=w.useState(null),[ge,xe]=w.useState(null),[Pe,Ue]=w.useState(null),[be,it]=w.useState(!1),[U,K]=w.useState(null),[J,Q]=w.useState(!1),[z,re]=w.useState(!1),[Ee,_e]=w.useState(null),[Te,V]=w.useState(!1),[L,X]=w.useState(!1),{data:te}=at({queryKey:["printerStatus",t.id],queryFn:()=>ue.getPrinterStatus(t.id),refetchInterval:3e4}),{data:Me}=at({queryKey:["firmwareUpdate",t.id],queryFn:()=>x1.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3,enabled:f}),ie=w.useMemo(()=>{const Qe=new Set;if(te?.ams)for(const Tt of te.ams)for(const qt of Tt.tray||[])qt.tray_info_idx&&Qe.add(qt.tray_info_idx);return te?.vt_tray?.tray_info_idx&&Qe.add(te.vt_tray.tray_info_idx),Array.from(Qe)},[te?.ams,te?.vt_tray]),{data:De}=at({queryKey:["filamentInfo",ie],queryFn:()=>ue.getFilamentInfo(ie),enabled:ie.length>0,staleTime:300*1e3}),{data:Le}=at({queryKey:["slotPresets",t.id],queryFn:()=>ue.getSlotPresets(t.id),staleTime:120*1e3}),[$e,Ze]=w.useState(null);w.useEffect(()=>{te?.wifi_signal!=null&&Ze(te.wifi_signal)},[te?.wifi_signal]);const Ie=te?.wifi_signal??$e,ae=w.useRef(void 0);w.useEffect(()=>{te?.connected!==void 0&&(ae.current=te.connected)},[te?.connected]);const He=te?.connected??ae.current,Se=w.useRef({});w.useEffect(()=>{te?.ams_extruder_map&&Object.keys(te.ams_extruder_map).length>0&&(Se.current=te.ams_extruder_map)},[te?.ams_extruder_map]);const Be=te?.ams_extruder_map&&Object.keys(te.ams_extruder_map).length>0?te.ams_extruder_map:Se.current,ft=w.useRef([]);w.useEffect(()=>{te?.ams&&te.ams.length>0&&(ft.current=te.ams)},[te?.ams]);const we=te?.ams&&te.ams.length>0?te.ams:ft.current,tt=w.useRef(255),ke=te?.tray_now;ke!==void 0&&ke!==255&&(tt.current=ke);const We=ke===void 0||ke===255?tt.current:ke,{data:pe}=at({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>ue.getSmartPlugByPrinter(t.id)}),{data:Ce}=at({queryKey:["scriptPlugsByPrinter",t.id],queryFn:()=>ue.getScriptPlugsByPrinter(t.id)}),{data:de}=at({queryKey:["smartPlugStatus",pe?.id],queryFn:()=>pe?ue.getSmartPlugStatus(pe.id):null,enabled:!!pe,refetchInterval:1e4}),{data:Ve}=at({queryKey:["queue",t.id,"pending"],queryFn:()=>ue.getQueue(t.id,"pending")}),yt=Ve?.length||0,{data:ut}=at({queryKey:["queue",t.id,"printing"],queryFn:()=>ue.getQueue(t.id,"printing"),enabled:te?.state==="RUNNING"}),{data:It}=at({queryKey:["currentPrintUser",t.id],queryFn:()=>ue.getCurrentPrintUser(t.id),enabled:te?.state==="RUNNING"}),Ft=ut?.[0]?.created_by_username||It?.username,{data:vn}=at({queryKey:["archives",t.id,"last"],queryFn:()=>ue.getArchives(t.id,1,0),enabled:te?.connected&&te?.state!=="RUNNING"}),Kt=vn?.[0],cr=e&&He===!1,dr=mt({mutationFn:Qe=>ue.deletePrinter(t.id,Qe.deleteArchives),onSuccess:()=>{m.invalidateQueries({queryKey:["printers"]}),m.invalidateQueries({queryKey:["archives"]}),m.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:Qe=>x(Qe.message||"Failed to delete printer","error")}),Jn=mt({mutationFn:()=>ue.connectPrinter(t.id),onSuccess:()=>{m.invalidateQueries({queryKey:["printerStatus",t.id]})}}),ln=mt({mutationFn:Qe=>pe?ue.controlSmartPlug(pe.id,Qe):Promise.reject("No plug"),onSuccess:()=>{m.invalidateQueries({queryKey:["smartPlugStatus",pe?.id]})}}),Gn=mt({mutationFn:Qe=>pe?ue.updateSmartPlug(pe.id,{auto_off:Qe}):Promise.reject("No plug"),onSuccess:()=>{m.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),m.invalidateQueries({queryKey:["smart-plugs"]})}}),nr=mt({mutationFn:Qe=>ue.controlSmartPlug(Qe,"on"),onSuccess:()=>{x("Script triggered")},onError:Qe=>x(Qe.message||"Failed to run script","error")}),er=mt({mutationFn:()=>ue.stopPrint(t.id),onSuccess:()=>{x("Print stopped"),m.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:Qe=>x(Qe.message||"Failed to stop print","error")}),bn=mt({mutationFn:()=>ue.pausePrint(t.id),onSuccess:()=>{x("Print paused"),m.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:Qe=>x(Qe.message||"Failed to pause print","error")}),xi=mt({mutationFn:()=>ue.resumePrint(t.id),onSuccess:()=>{x("Print resumed"),m.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:Qe=>x(Qe.message||"Failed to resume print","error")}),Ia=mt({mutationFn:Qe=>ue.setChamberLight(t.id,Qe),onMutate:async Qe=>{await m.cancelQueries({queryKey:["printerStatus",t.id]});const Tt=m.getQueryData(["printerStatus",t.id]);return m.setQueryData(["printerStatus",t.id],qt=>({...qt,chamber_light:Qe})),{previousStatus:Tt}},onSuccess:(Qe,Tt)=>{x(`Chamber light ${Tt?"on":"off"}`)},onError:(Qe,Tt,qt)=>{qt?.previousStatus&&m.setQueryData(["printerStatus",t.id],qt.previousStatus),x(Qe.message||"Failed to control chamber light","error")}}),Ae=mt({mutationFn:Qe=>ue.updatePrinter(t.id,{plate_detection_enabled:Qe}),onSuccess:()=>{m.invalidateQueries({queryKey:["printers"]}),x(Ae.variables?"Plate check enabled":"Plate check disabled")},onError:Qe=>x(Qe.message||"Failed to update setting","error")}),Xe=(te?.state==="RUNNING"||te?.state==="PAUSE"||te?.state==="PAUSED")&&(te?.printable_objects_count??0)>=2,{data:Je,refetch:dt}=at({queryKey:["printableObjects",t.id],queryFn:()=>ue.getPrintableObjects(t.id),enabled:ne||Xe,refetchInterval:ne?5e3:Xe?3e4:!1}),st=mt({mutationFn:Qe=>ue.skipObjects(t.id,Qe),onSuccess:Qe=>{x(Qe.message||"Objects skipped"),dt()},onError:Qe=>x(Qe.message||"Failed to skip objects","error")}),[jt,he]=w.useState(null),me=w.useRef(!1),Fe=w.useRef(null),Oe=w.useRef(!1),je=mt({mutationFn:({amsId:Qe,slotId:Tt})=>ue.refreshAmsSlot(t.id,Qe,Tt),onMutate:({amsId:Qe,slotId:Tt})=>{Fe.current&&clearTimeout(Fe.current),me.current=!1,Oe.current=!1,he({amsId:Qe,slotId:Tt}),setTimeout(()=>{Oe.current=!0},2e3),Fe.current=setTimeout(()=>{he(null)},3e4)},onSuccess:Qe=>{x(Qe.message||"RFID re-read initiated")},onError:Qe=>{x(Qe.message||"Failed to re-read RFID","error"),Fe.current&&clearTimeout(Fe.current),he(null)}}),[ht,Nt]=w.useState(null),[Ct,At]=w.useState(null),Lt=async()=>{try{const Qe=await ue.getPlateReferences(t.id);Nt(Qe)}catch{}},Rt=()=>{Ae.mutate(!t.plate_detection_enabled)},Mt=async()=>{Q(!0),K(null);const Qe=te?.chamber_light===!1;X(Qe),Qe&&(await ue.setChamberLight(t.id,!0),await new Promise(Tt=>setTimeout(Tt,2500)));try{const Tt=await ue.checkPlateEmpty(t.id,{includeDebugImage:!0});K(Tt),Lt()}catch(Tt){x(Tt instanceof Error?Tt.message:"Failed to check plate","error"),Qe&&(await ue.setChamberLight(t.id,!1),X(!1))}finally{Q(!1)}},Zt=w.useCallback(async()=>{K(null),L&&(await ue.setChamberLight(t.id,!1),X(!1))},[L,t.id]),$t=async Qe=>{re(!0);try{const Tt=await ue.calibratePlateDetection(t.id,{label:Qe});if(Tt.success){x(Tt.message||"Calibration saved!","success"),Lt();const qt=await ue.checkPlateEmpty(t.id,{includeDebugImage:!0});K(qt)}else x(Tt.message||"Calibration failed","error")}catch(Tt){x(Tt instanceof Error?Tt.message:"Calibration failed","error")}finally{re(!1)}},un=async(Qe,Tt)=>{try{await ue.updatePlateReferenceLabel(t.id,Qe,Tt),At(null),Lt()}catch(qt){x(qt instanceof Error?qt.message:"Failed to update label","error")}},_n=async Qe=>{try{await ue.deletePlateReference(t.id,Qe),x("Reference deleted","success"),Lt();const Tt=await ue.checkPlateEmpty(t.id,{includeDebugImage:!0});K(Tt)}catch(Tt){x(Tt instanceof Error?Tt.message:"Failed to delete reference","error")}},Mn=async()=>{if(Ee){V(!0);try{await ue.updatePrinter(t.id,{plate_detection_roi:Ee}),x("Detection area saved","success"),_e(null);const Qe=await ue.checkPlateEmpty(t.id,{includeDebugImage:!0});K(Qe)}catch(Qe){x(Qe instanceof Error?Qe.message:"Failed to save detection area","error")}finally{V(!1)}}};w.useEffect(()=>{const Qe=Tt=>{Tt.key==="Escape"&&U&&Zt()};return window.addEventListener("keydown",Qe),()=>window.removeEventListener("keydown",Qe)},[U,Zt]);const Ht=w.useRef(null);w.useEffect(()=>{if(!jt)return;const Qe=te?.ams_status_main??0;return Qe!==0&&(me.current=!0,Ht.current&&(clearTimeout(Ht.current),Ht.current=null)),me.current&&Qe===0&&(Oe.current?(Fe.current&&clearTimeout(Fe.current),he(null)):Ht.current||(Ht.current=setTimeout(()=>{Fe.current&&clearTimeout(Fe.current),he(null)},2e3))),()=>{Ht.current&&clearTimeout(Ht.current)}},[te?.ams_status_main,jt]);const[Xt,tn]=w.useState(null);if(cr)return null;const cn=()=>{switch(i){case 1:return"w-10 h-10";case 2:return"w-14 h-14";case 3:return"w-16 h-16";case 4:return"w-20 h-20";default:return"w-14 h-14"}},Ur=()=>{switch(i){case 1:return"text-base truncate";case 2:return"text-lg";case 3:return"text-xl";case 4:return"text-2xl";default:return"text-lg"}},qn=()=>{switch(i){case 1:return"mb-2";case 2:return"mb-4";case 3:return"mb-5";case 4:return"mb-6";default:return"mb-4"}};return a.jsxs(wt,{className:"relative",children:[a.jsxs(St,{className:i>=3?"p-5":"",children:[a.jsxs("div",{className:qn(),children:[a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx("img",{src:i8e(t.model),alt:t.model||"Printer",className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${cn()}`}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h3",{className:`font-semibold text-white ${Ur()}`,children:t.name}),r==="compact"&&a.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${te?.connected?"bg-status-ok":"bg-status-error"}`,title:te?.connected?"Connected":"Offline"})]}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&te?.nozzles&&te.nozzles[0]?.nozzle_diameter&&a.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:te.nozzles[0].nozzle_type||"Nozzle",children:["• ",te.nozzles[0].nozzle_diameter,"mm"]}),r==="expanded"&&n&&n.total_print_hours>0&&a.jsxs("span",{className:"ml-2 text-bambu-gray",children:[a.jsx(Qn,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),a.jsxs("div",{className:"relative flex-shrink-0",children:[a.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>v(!y),children:a.jsx(rh,{className:"w-4 h-4"})}),y&&a.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:[a.jsxs("button",{className:`w-full px-4 py-2 text-left text-sm flex items-center gap-2 ${b("printers:update")?"hover:bg-bambu-dark-tertiary":"opacity-50 cursor-not-allowed"}`,onClick:()=>{b("printers:update")&&(E(!0),v(!1))},title:b("printers:update")?void 0:"You do not have permission to edit printers",children:[a.jsx(Ki,{className:"w-4 h-4"}),"Edit"]}),a.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{Jn.mutate(),v(!1)},children:[a.jsx(Pr,{className:"w-4 h-4"}),"Reconnect"]}),a.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{F(!0),v(!1)},children:[a.jsx(RW,{className:"w-4 h-4"}),"MQTT Debug"]}),a.jsxs("button",{className:`w-full px-4 py-2 text-left text-sm flex items-center gap-2 ${b("printers:delete")?"text-red-400 hover:bg-bambu-dark-tertiary":"text-red-400/50 cursor-not-allowed"}`,onClick:()=>{b("printers:delete")&&(N(!0),v(!1))},title:b("printers:delete")?void 0:"You do not have permission to delete printers",children:[a.jsx(an,{className:"w-4 h-4"}),"Delete"]})]})]})]}),r==="expanded"&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[a.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${te?.connected?"bg-status-ok/20 text-status-ok":"bg-status-error/20 text-status-error"}`,children:[te?.connected?a.jsx(Fy,{className:"w-3 h-3"}):a.jsx(OD,{className:"w-3 h-3"}),te?.connected?"Connected":"Offline"]}),te?.connected&&Ie!=null&&a.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${Ie>=-50||Ie>=-60?"bg-status-ok/20 text-status-ok":Ie>=-70?"bg-status-warning/20 text-status-warning":Ie>=-80?"bg-orange-500/20 text-orange-600":"bg-status-error/20 text-status-error"}`,title:`WiFi: ${Ie} dBm - ${a8e(Ie).label}`,children:[a.jsx(jhe,{className:"w-3 h-3"}),Ie,"dBm"]}),te?.connected&&(()=>{const Qe=te.hms_errors?VNe(te.hms_errors):[];return a.jsxs("button",{onClick:()=>q(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${Qe.length>0?Qe.some(Tt=>Tt.severity<=2)?"bg-status-error/20 text-status-error":"bg-status-warning/20 text-status-warning":"bg-status-ok/20 text-status-ok"}`,title:"Click to view HMS errors",children:[a.jsx(jn,{className:"w-3 h-3"}),Qe.length>0?Qe.length:"OK"]})})(),n&&a.jsxs("button",{onClick:()=>p("/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-status-error/20 text-status-error":n.warning_count>0?"bg-status-warning/20 text-status-warning":"bg-status-ok/20 text-status-ok"}`,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:[a.jsx(om,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),yt>0&&a.jsxs("button",{onClick:()=>p("/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:`${yt} print${yt>1?"s":""} in queue`,children:[a.jsx(xs,{className:"w-3 h-3"}),yt]}),Me?.update_available&&a.jsxs("button",{onClick:()=>it(!0),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-orange-500/20 text-orange-400 hover:opacity-80 transition-opacity",title:`Firmware update available: ${Me.current_version} → ${Me.latest_version}`,children:[a.jsx(pi,{className:"w-3 h-3"}),"Update"]})]})]}),S&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsx(wt,{className:"w-full max-w-md mx-4",children:a.jsxs(St,{children:[a.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[a.jsx("div",{className:"p-2 rounded-full bg-red-500/20",children:a.jsx(jn,{className:"w-5 h-5 text-red-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Printer"}),a.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:['Are you sure you want to delete "',t.name,'"? This will remove all connection settings.']})]})]}),a.jsx("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:a.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:C,onChange:Qe=>T(Qe.target.checked),className:"mt-0.5 w-4 h-4 rounded border-bambu-gray bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-white",children:"Delete print archives"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:C?"All print history for this printer will be permanently deleted.":"Print history will be kept but no longer associated with this printer."})]})]})}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Ne,{variant:"secondary",onClick:()=>{N(!1),T(!0)},children:"Cancel"}),a.jsx(Ne,{variant:"danger",onClick:()=>{dr.mutate({deleteArchives:C}),N(!1),T(!0)},children:"Delete"})]})]})})}),te?.connected&&a.jsxs(a.Fragment,{children:[r==="compact"?a.jsx("div",{className:"mt-2",children:te.state==="RUNNING"?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:a.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${te.progress||0}%`}})}),a.jsxs("span",{className:"text-xs text-white",children:[Math.round(te.progress||0),"%"]})]}):a.jsx("p",{className:"text-xs text-bambu-gray",children:AG(te.state,te.stg_cur_name)})}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg relative",children:[a.jsxs("button",{onClick:()=>ce(!0),disabled:!(te.state==="RUNNING"||te.state==="PAUSE"||te.state==="PAUSED")||(te.printable_objects_count??0)<2||!b("printers:control"),className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${(te.state==="RUNNING"||te.state==="PAUSE"||te.state==="PAUSED")&&(te.printable_objects_count??0)>=2&&b("printers:control")?"text-bambu-gray hover:text-white hover:bg-white/10":"text-bambu-gray/30 cursor-not-allowed"}`,title:b("printers:control")?te.state==="RUNNING"||te.state==="PAUSE"||te.state==="PAUSED"?(te.printable_objects_count??0)>=2?"Skip objects":"Skip objects (requires 2+ objects)":"Skip objects (only while printing)":"You do not have permission to control printers",children:[a.jsx(wG,{className:"w-4 h-4"}),Je&&Je.skipped_count>0&&a.jsx("span",{className:"absolute -top-1 -right-1 min-w-[16px] h-4 px-1 flex items-center justify-center text-[10px] font-bold bg-red-500 text-white rounded-full",children:Je.skipped_count})]}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(s8e,{url:te.state==="RUNNING"?te.cover_url:null,printName:te.state==="RUNNING"&&(te.subtask_name||te.current_print)||void 0}),a.jsx("div",{className:"flex-1 min-w-0",children:te.current_print&&te.state==="RUNNING"?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:te.stg_cur_name||"Printing"}),a.jsx("p",{className:"text-white text-sm mb-2 truncate",children:te.subtask_name||te.current_print}),a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:a.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${te.progress||0}%`}})}),a.jsxs("span",{className:"text-white",children:[Math.round(te.progress||0),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[te.remaining_time!=null&&te.remaining_time>0&&a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Qn,{className:"w-3 h-3"}),n8e(te.remaining_time*60)]}),a.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",r8e(te.remaining_time,c)]})]}),te.layer_num!=null&&te.total_layers!=null&&te.total_layers>0&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(xs,{className:"w-3 h-3"}),te.layer_num,"/",te.total_layers]}),Ft&&a.jsxs("span",{className:"flex items-center gap-1",title:`Started by ${Ft}`,children:[a.jsx(am,{className:"w-3 h-3"}),Ft]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Status"}),a.jsx("p",{className:"text-white text-sm mb-2",children:AG(te.state,te.stg_cur_name)}),a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:a.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),a.jsx("span",{className:"text-bambu-gray",children:"—"})]}),Kt?a.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:Kt.print_name||Kt.filename,children:["Last: ",Kt.print_name||Kt.filename,Kt.completed_at&&a.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",Bg(Kt.completed_at,{month:"short",day:"numeric"})]})]}):a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})]}),te.state!=="RUNNING"&&a.jsx(KNe,{printerId:t.id})]}),te.temperatures&&r==="expanded"&&(()=>{const Qe=te.temperatures.nozzle_heating||te.temperatures.nozzle_2_heating||!1,Tt=te.temperatures.bed_heating||!1,qt=te.temperatures.chamber_heating||!1,xt=t.nozzle_count===2||te.temperatures.nozzle_2!==void 0,nn=te.active_extruder===1?"L":"R";return a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[a.jsx(cj,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-orange-400",isHeating:Qe}),te.temperatures.nozzle_2!==void 0?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-[9px] text-bambu-gray",children:"L / R"}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(te.temperatures.nozzle||0),"° / ",Math.round(te.temperatures.nozzle_2||0),"°"]})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Nozzle"}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(te.temperatures.nozzle||0),"°C"]})]})]}),a.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[a.jsx(cj,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-blue-400",isHeating:Tt}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Bed"}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(te.temperatures.bed||0),"°C"]})]}),te.temperatures.chamber!==void 0&&a.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[a.jsx(cj,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-green-400",isHeating:qt}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Chamber"}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(te.temperatures.chamber||0),"°C"]})]}),xt&&a.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg",title:`Active: ${nn==="L"?"Left":"Right"} nozzle`,children:[a.jsx("p",{className:`text-[11px] font-bold ${nn==="L"?"text-amber-400":"text-gray-500"}`,children:"L"}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Nozzle"}),a.jsx("p",{className:`text-[11px] font-bold ${nn==="R"?"text-amber-400":"text-gray-500"}`,children:"R"})]})]})})(),r==="expanded"&&(()=>{const Qe=te.state==="RUNNING",Tt=te.state==="PAUSED"||te.state==="PAUSE",qt=Qe||Tt,xt=er.isPending||bn.isPending||xi.isPending,nn=te.cooling_fan_speed,gn=te.big_fan1_speed,tr=te.big_fan2_speed;return a.jsxs("div",{className:"mt-3",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Controls"}),a.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${nn&&nn>0?"bg-cyan-500/10":"bg-bambu-dark"}`,title:"Part Cooling Fan",children:[a.jsx(_W,{className:`w-3.5 h-3.5 ${nn&&nn>0?"text-cyan-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${nn&&nn>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[nn??0,"%"]})]}),a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${gn&&gn>0?"bg-blue-500/10":"bg-bambu-dark"}`,title:"Auxiliary Fan",children:[a.jsx(OW,{className:`w-3.5 h-3.5 ${gn&&gn>0?"text-blue-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${gn&&gn>0?"text-blue-400":"text-bambu-gray/50"}`,children:[gn??0,"%"]})]}),a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${tr&&tr>0?"bg-green-500/10":"bg-bambu-dark"}`,title:"Chamber Fan",children:[a.jsx(cce,{className:`w-3.5 h-3.5 ${tr&&tr>0?"text-green-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${tr&&tr>0?"text-green-400":"text-bambu-gray/50"}`,children:[tr??0,"%"]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{onClick:()=>Z(!0),disabled:!qt||xt||!b("printers:control"),className:`
  8128. flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
  8129. transition-colors
  8130. ${qt&&b("printers:control")?"bg-red-500/20 text-red-400 hover:bg-red-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}
  8131. `,title:b("printers:control")?"Stop print":"You do not have permission to control printers",children:[a.jsx(il,{className:"w-3 h-3"}),"Stop"]}),a.jsxs("button",{onClick:()=>Tt?se(!0):B(!0),disabled:!qt||xt||!b("printers:control"),className:`
  8132. flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
  8133. transition-colors
  8134. ${qt&&b("printers:control")?Tt?"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30":"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}
  8135. `,title:b("printers:control")?Tt?"Resume print":"Pause print":"You do not have permission to control printers",children:[Tt?a.jsx(Us,{className:"w-3 h-3"}):a.jsx(jD,{className:"w-3 h-3"}),Tt?"Resume":"Pause"]})]})]})]})})(),we&&we.length>0&&r==="expanded"&&(()=>{const Qe=we.filter(xt=>xt.tray.length>1),Tt=we.filter(xt=>xt.tray.length===1),qt=t.nozzle_count===2||te?.temperatures?.nozzle_2!==void 0;return a.jsxs("div",{className:"mt-3",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Filaments"}),a.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),a.jsxs("div",{className:"space-y-3",children:[Qe.length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-3",children:Qe.map(xt=>{const nn=Be[String(xt.id)],gn=xt.id>=128?xt.id-128:xt.id,tr=nn!==void 0?nn:gn,br=tr===1,Fa=tr===0;return a.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"text-[10px] text-white font-medium",children:Dd(xt.id,xt.tray.length)}),qt&&(br||Fa)&&a.jsx(NG,{side:br?"L":"R"})]}),(xt.humidity!=null||xt.temp!=null)&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[xt.humidity!=null&&a.jsx(EG,{humidity:xt.humidity,goodThreshold:s?.humidityGood,fairThreshold:s?.humidityFair,onClick:()=>ye({amsId:xt.id,amsLabel:Dd(xt.id,xt.tray.length),mode:"humidity"}),compact:!0}),xt.temp!=null&&a.jsx(CG,{temp:xt.temp,goodThreshold:s?.tempGood,fairThreshold:s?.tempFair,onClick:()=>ye({amsId:xt.id,amsLabel:Dd(xt.id,xt.tray.length),mode:"temperature"}),compact:!0})]})]}),a.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:[0,1,2,3].map(sn=>{const Sn=xt.tray[sn]||xt.tray.find(Bi=>Bi.id===sn),ns=Sn?.tray_type&&Sn.remain>=0,So=!Sn?.tray_type,aa=xt.id*4+sn,rs=We===aa,fl=Sn?.tray_info_idx?De?.[Sn.tray_info_idx]:null,is=Le?.[aa],si=Sn?.tray_type?{vendor:uj(Sn)?"Bambu Lab":"Generic",profile:fl?.name||is?.preset_name||Sn.tray_sub_brands||Sn.tray_type,colorName:sj(Sn.tray_id_name)||oj(Sn.tray_color),colorHex:Sn.tray_color||null,kFactor:lj(Sn.k),fillLevel:ns?Sn.remain:null,trayUuid:Sn.tray_uuid||null}:null,Ua=jt?.amsId===xt.id&&jt?.slotId===sn,$l=a.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${So?"opacity-50":""} ${rs?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[a.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:Sn?.tray_color?`#${Sn.tray_color}`:Sn?.tray_type?"#333":"transparent",borderColor:So?"#666":"rgba(255,255,255,0.1)",borderStyle:So?"dashed":"solid"}}),a.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:Sn?.tray_type||"—"}),a.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:ns&&Sn?a.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Sn.remain}%`,backgroundColor:TG(Sn.remain)}}):Sn?.tray_type?a.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return a.jsxs("div",{className:"relative group",children:[Ua&&a.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:a.jsx(Pr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),te?.state!=="RUNNING"&&a.jsx("button",{onClick:Bi=>{Bi.stopPropagation(),tn(Xt?.amsId===xt.id&&Xt?.slotId===sn?null:{amsId:xt.id,slotId:sn})},className:"absolute -top-1 -right-1 w-4 h-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:bg-bambu-dark-tertiary",title:"Slot options",children:a.jsx(rh,{className:"w-2.5 h-2.5 text-bambu-gray"})}),te?.state!=="RUNNING"&&Xt?.amsId===xt.id&&Xt?.slotId===sn&&a.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-xs flex items-center gap-2 ${b("printers:ams_rfid")?"text-white hover:bg-bambu-dark-tertiary":"text-bambu-gray/50 cursor-not-allowed"}`,onClick:Bi=>{Bi.stopPropagation(),b("printers:ams_rfid")&&(je.mutate({amsId:xt.id,slotId:sn}),tn(null))},disabled:Ua||!b("printers:ams_rfid"),title:b("printers:ams_rfid")?void 0:"You do not have permission to re-read AMS RFID",children:[a.jsx(Pr,{className:`w-3 h-3 ${Ua?"animate-spin":""}`}),"Re-read RFID"]})}),si?a.jsx(ij,{data:si,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&si.trayUuid?Bi=>{xe({trayUuid:Bi,trayInfo:{type:si.profile,color:si.colorHex||"",location:`${Dd(xt.id,xt.tray.length)} Slot ${sn+1}`}})}:void 0},configureSlot:{enabled:b("printers:control"),onConfigure:()=>Ue({amsId:xt.id,trayId:sn,trayCount:xt.tray.length,trayType:Sn?.tray_type||void 0,trayColor:Sn?.tray_color||void 0,traySubBrands:Sn?.tray_sub_brands||void 0,trayInfoIdx:Sn?.tray_info_idx||void 0})},children:$l}):a.jsx(yG,{configureSlot:{enabled:b("printers:control"),onConfigure:()=>Ue({amsId:xt.id,trayId:sn,trayCount:xt.tray.length})},children:$l})]},sn)})})]},xt.id)})}),(Tt.length>0||te.vt_tray&&te.vt_tray.tray_type)&&a.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[Tt.map(xt=>{const nn=Be[String(xt.id)],gn=xt.id>=128?xt.id-128:xt.id,tr=nn!==void 0?nn:gn,br=tr===1,Fa=tr===0,sn=xt.tray[0],Sn=sn?.tray_type&&sn.remain>=0,ns=!sn?.tray_type,So=xt.id*4+(sn?.id??0),aa=We===So,rs=sn?.tray_info_idx?De?.[sn.tray_info_idx]:null,fl=Le?.[So],is=sn?.tray_type?{vendor:uj(sn)?"Bambu Lab":"Generic",profile:rs?.name||fl?.preset_name||sn.tray_sub_brands||sn.tray_type,colorName:sj(sn.tray_id_name)||oj(sn.tray_color),colorHex:sn.tray_color||null,kFactor:lj(sn.k),fillLevel:Sn?sn.remain:null,trayUuid:sn.tray_uuid||null}:null,si=sn?.id??0,Ua=jt?.amsId===xt.id&&jt?.slotId===si,$l=a.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${ns?"opacity-50":""} ${aa?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[a.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:sn?.tray_color?`#${sn.tray_color}`:sn?.tray_type?"#333":"transparent",borderColor:ns?"#666":"rgba(255,255,255,0.1)",borderStyle:ns?"dashed":"solid"}}),a.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:sn?.tray_type||"—"}),a.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Sn?a.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${sn.remain}%`,backgroundColor:TG(sn.remain)}}):sn?.tray_type?a.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return a.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[a.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[a.jsx("span",{className:"text-[10px] text-white font-medium",children:Dd(xt.id,xt.tray.length)}),qt&&(br||Fa)&&a.jsx(NG,{side:br?"L":"R"})]}),a.jsxs("div",{className:"flex gap-1.5",children:[a.jsxs("div",{className:"relative group flex-1",children:[Ua&&a.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:a.jsx(Pr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),te?.state!=="RUNNING"&&a.jsx("button",{onClick:Bi=>{Bi.stopPropagation(),tn(Xt?.amsId===xt.id&&Xt?.slotId===si?null:{amsId:xt.id,slotId:si})},className:"absolute -top-1 -right-1 w-4 h-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:bg-bambu-dark-tertiary",title:"Slot options",children:a.jsx(rh,{className:"w-2.5 h-2.5 text-bambu-gray"})}),te?.state!=="RUNNING"&&Xt?.amsId===xt.id&&Xt?.slotId===si&&a.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-xs flex items-center gap-2 ${b("printers:ams_rfid")?"text-white hover:bg-bambu-dark-tertiary":"text-bambu-gray/50 cursor-not-allowed"}`,onClick:Bi=>{Bi.stopPropagation(),b("printers:ams_rfid")&&(je.mutate({amsId:xt.id,slotId:si}),tn(null))},disabled:Ua||!b("printers:ams_rfid"),title:b("printers:ams_rfid")?void 0:"You do not have permission to re-read AMS RFID",children:[a.jsx(Pr,{className:`w-3 h-3 ${Ua?"animate-spin":""}`}),"Re-read RFID"]})}),is?a.jsx(ij,{data:is,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&is.trayUuid?Bi=>{xe({trayUuid:Bi,trayInfo:{type:is.profile,color:is.colorHex||"",location:Dd(xt.id,xt.tray.length)}})}:void 0},configureSlot:{enabled:b("printers:control"),onConfigure:()=>Ue({amsId:xt.id,trayId:si,trayCount:xt.tray.length,trayType:sn?.tray_type||void 0,trayColor:sn?.tray_color||void 0,traySubBrands:sn?.tray_sub_brands||void 0,trayInfoIdx:sn?.tray_info_idx||void 0})},children:$l}):a.jsx(yG,{configureSlot:{enabled:b("printers:control"),onConfigure:()=>Ue({amsId:xt.id,trayId:si,trayCount:xt.tray.length})},children:$l})]}),(xt.humidity!=null||xt.temp!=null)&&a.jsxs("div",{className:"flex flex-col justify-center gap-1 shrink-0",children:[xt.temp!=null&&a.jsx(CG,{temp:xt.temp,goodThreshold:s?.tempGood,fairThreshold:s?.tempFair,onClick:()=>ye({amsId:xt.id,amsLabel:Dd(xt.id,xt.tray.length),mode:"temperature"}),compact:!0}),xt.humidity!=null&&a.jsx(EG,{humidity:xt.humidity,goodThreshold:s?.humidityGood,fairThreshold:s?.humidityFair,onClick:()=>ye({amsId:xt.id,amsLabel:Dd(xt.id,xt.tray.length),mode:"humidity"}),compact:!0})]})]})]},xt.id)}),te.vt_tray&&te.vt_tray.tray_type&&(()=>{const xt=te.vt_tray,nn=We===254,gn=xt.tray_info_idx?De?.[xt.tray_info_idx]:null,tr=Le?.[1020],br={vendor:uj(xt)?"Bambu Lab":"Generic",profile:gn?.name||tr?.preset_name||xt.tray_sub_brands||xt.tray_type||"Unknown",colorName:sj(xt.tray_id_name)||oj(xt.tray_color),colorHex:xt.tray_color||null,kFactor:lj(xt.k),fillLevel:null,trayUuid:xt.tray_uuid||null},Fa=a.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center cursor-default ${nn?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[a.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:xt.tray_color?`#${xt.tray_color}`:"#333",borderColor:nn?"var(--accent)":"rgba(255,255,255,0.1)"}}),a.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:xt.tray_type||"Spool"}),a.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"})})]});return a.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[a.jsx("div",{className:"flex items-center gap-1 mb-2",children:a.jsx("span",{className:"text-[10px] text-white font-medium",children:"External"})}),a.jsx(ij,{data:br,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&br.trayUuid?sn=>{xe({trayUuid:sn,trayInfo:{type:br.profile,color:br.colorHex||"",location:"External Spool"}})}:void 0},configureSlot:{enabled:b("printers:control"),onConfigure:()=>Ue({amsId:255,trayId:0,trayCount:1,trayType:xt.tray_type||void 0,trayColor:xt.tray_color||void 0,traySubBrands:xt.tray_sub_brands||void 0,trayInfoIdx:xt.tray_info_idx||void 0})},children:Fa})]})})()]})]})]})})()]}),pe&&r==="expanded"&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx(vh,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"text-sm text-white truncate",children:pe.name}),de&&a.jsxs("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${de.state==="ON"?"bg-bambu-green/20 text-bambu-green":de.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:[de.state||"?",de.state==="ON"&&de.energy?.power!=null&&a.jsxs("span",{className:"text-yellow-400 ml-1.5",children:["· ",de.energy.power,"W"]})]})]}),a.jsx("div",{className:"flex-1"}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs("button",{onClick:()=>H(!0),disabled:ln.isPending||de?.state==="ON"||!b("smart_plugs:control"),className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${b("smart_plugs:control")?de?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}`,title:b("smart_plugs:control")?void 0:"You do not have permission to control smart plugs",children:[a.jsx(Vu,{className:"w-3 h-3"}),"On"]}),a.jsxs("button",{onClick:()=>G(!0),disabled:ln.isPending||de?.state==="OFF"||!b("smart_plugs:control"),className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${b("smart_plugs:control")?de?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}`,title:b("smart_plugs:control")?void 0:"You do not have permission to control smart plugs",children:[a.jsx(xN,{className:"w-3 h-3"}),"Off"]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx("span",{className:`text-xs hidden sm:inline ${pe.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:pe.auto_off_executed?"Auto-off done":"Auto-off"}),a.jsx("button",{onClick:()=>Gn.mutate(!pe.auto_off),disabled:Gn.isPending||pe.auto_off_executed||!b("smart_plugs:control"),title:b("smart_plugs:control")?pe.auto_off_executed?"Auto-off was executed - turn printer on to reset":"Auto power-off after print":"You do not have permission to control smart plugs",className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${b("smart_plugs:control")?pe.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":pe.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary":"bg-bambu-dark-tertiary/50 cursor-not-allowed"}`,children:a.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${pe.auto_off||pe.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]}),Ce&&Ce.length>0&&a.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-bambu-dark-tertiary/50",children:[a.jsx(Us,{className:"w-3.5 h-3.5 text-blue-400 flex-shrink-0"}),a.jsx("span",{className:"text-xs text-bambu-gray",children:"Scripts:"}),a.jsx("div",{className:"flex flex-wrap gap-1",children:Ce.map(Qe=>a.jsxs("button",{onClick:()=>nr.mutate(Qe.id),disabled:nr.isPending,title:`Run ${Qe.ha_entity_id}`,className:"px-2 py-0.5 text-xs bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 rounded transition-colors flex items-center gap-1",children:[a.jsx(Us,{className:"w-2.5 h-2.5"}),Qe.name]},Qe.id))})]})]}),r==="expanded"&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[a.jsxs("div",{className:"text-xs text-bambu-gray",children:[a.jsx("p",{children:t.ip_address}),a.jsx("p",{className:"truncate",children:t.serial_number})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx(Ne,{variant:"secondary",size:"sm",onClick:()=>Ia.mutate(!te?.chamber_light),disabled:!te?.connected||Ia.isPending||!b("printers:control"),title:b("printers:control")?te?.chamber_light?"Turn off chamber light":"Turn on chamber light":"You do not have permission to control printers",className:te?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30 border-yellow-500/30":"",children:a.jsx(XBe,{on:te?.chamber_light??!1,className:"w-4 h-4"})}),a.jsx(Ne,{variant:"secondary",size:"sm",onClick:()=>{if(u==="embedded"&&d)d(t.id,t.name);else{const Qe=localStorage.getItem("cameraWindowState"),Tt=Qe?JSON.parse(Qe):{width:640,height:400},qt=[`width=${Tt.width}`,`height=${Tt.height}`,Tt.left!==void 0?`left=${Tt.left}`:"",Tt.top!==void 0?`top=${Tt.top}`:"","menubar=no,toolbar=no,location=no,status=no,noopener"].filter(Boolean).join(",");window.open(`/camera/${t.id}`,`camera-${t.id}`,qt)}},disabled:!te?.connected,title:u==="embedded"?"Open camera overlay":"Open camera in new window",children:a.jsx(LD,{className:"w-4 h-4"})}),a.jsxs("div",{className:`inline-flex rounded-md ${t.plate_detection_enabled?"ring-1 ring-green-500":""}`,children:[a.jsx(Ne,{variant:"secondary",size:"sm",onClick:Rt,disabled:!te?.connected||Ae.isPending||!b("printers:update"),title:b("printers:update")?t.plate_detection_enabled?"Plate check enabled - Click to disable":"Plate check disabled - Click to enable":"You do not have permission to update printers",className:`!rounded-r-none !border-r-0 ${t.plate_detection_enabled?"!border-green-500 !text-green-400 hover:!bg-green-500/20":""}`,children:Ae.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(X1,{className:"w-4 h-4"})}),a.jsx(Ne,{variant:"secondary",size:"sm",onClick:Mt,disabled:!te?.connected||J||!b("printers:update"),title:b("printers:update")?"Manage plate detection calibration":"You do not have permission to update printers",className:`!rounded-l-none !px-1.5 ${t.plate_detection_enabled?"!border-green-500 !text-green-400 hover:!bg-green-500/20":""}`,children:J?a.jsx(ct,{className:"w-3 h-3 animate-spin"}):a.jsx(Xr,{className:"w-3 h-3"})})]}),a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>A(!0),disabled:!b("printers:files"),title:b("printers:files")?"Browse printer files":"You do not have permission to access printer files",children:[a.jsx(fN,{className:"w-4 h-4"}),"Files"]})]})]})]}),D&&a.jsx(LNe,{printerId:t.id,printerName:t.name,onClose:()=>A(!1)}),R&&a.jsx($Ne,{printerId:t.id,printerName:t.name,onClose:()=>F(!1)}),U&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>Zt(),children:a.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-w-lg w-full",onClick:Qe=>Qe.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[U.needs_calibration?a.jsx(X1,{className:"w-5 h-5 text-blue-500"}):U.is_empty?a.jsx(Tr,{className:"w-5 h-5 text-green-500"}):a.jsx(qi,{className:"w-5 h-5 text-yellow-500"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Build Plate Check"}),U.reference_count!==void 0&&U.max_references&&a.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded",children:[U.reference_count,"/",U.max_references," refs"]})]}),a.jsx("button",{onClick:()=>Zt(),className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[U.needs_calibration?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"p-3 rounded-lg bg-blue-500/20 border border-blue-500/50",children:[a.jsx("p",{className:"font-medium text-blue-400",children:"Calibration Required"}),a.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:["Please ensure the build plate is ",a.jsx("strong",{children:"completely empty"}),", then click Calibrate."]})]}),a.jsxs("div",{className:"text-sm text-bambu-gray space-y-2",children:[a.jsx("p",{children:"Calibration captures a reference image of the empty plate. Future checks will compare against this reference to detect objects."}),a.jsxs("p",{children:[a.jsx("strong",{children:"Tip:"})," You can store up to 5 calibrations for different plates. The system automatically uses the best match when checking."]})]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:`p-3 rounded-lg ${U.is_empty?"bg-green-500/20 border border-green-500/50":"bg-yellow-500/20 border border-yellow-500/50"}`,children:[a.jsx("p",{className:`font-medium ${U.is_empty?"text-green-400":"text-yellow-400"}`,children:U.is_empty?"Plate appears empty":"Objects detected on plate"}),a.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:["Confidence: ",Math.round(U.confidence*100),"% | Difference: ",U.difference_percent.toFixed(1),"%"]})]}),U.debug_image_url&&a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Analysis preview:"}),a.jsx("img",{src:U.debug_image_url,alt:"Plate detection analysis",className:"w-full rounded-lg border border-bambu-dark-tertiary"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Green box = detection area, Red overlay = differences from calibration"})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:U.message})]}),ht&&ht.references.length>0&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("p",{className:"text-sm font-medium text-white mb-2",children:["Saved References (",ht.references.length,"/",ht.max_references,")"]}),a.jsx("div",{className:"grid grid-cols-5 gap-2",children:ht.references.map(Qe=>a.jsxs("div",{className:"relative group",children:[a.jsx("img",{src:ue.getPlateReferenceThumbnailUrl(t.id,Qe.index),alt:Qe.label||`Reference ${Qe.index+1}`,className:"w-full aspect-video object-cover rounded border border-bambu-dark-tertiary"}),a.jsx("button",{onClick:()=>_n(Qe.index),className:"absolute top-1 right-1 p-0.5 bg-red-500/80 rounded opacity-0 group-hover:opacity-100 transition-opacity",title:"Delete reference",children:a.jsx(Dt,{className:"w-3 h-3 text-white"})}),Ct?.index===Qe.index?a.jsx("input",{type:"text",value:Ct.label,onChange:Tt=>At({...Ct,label:Tt.target.value}),onBlur:()=>un(Qe.index,Ct.label),onKeyDown:Tt=>{Tt.key==="Enter"&&un(Qe.index,Ct.label),Tt.key==="Escape"&&At(null)},className:"w-full mt-1 px-1 py-0.5 text-xs bg-bambu-dark-tertiary border border-bambu-green rounded text-white",autoFocus:!0,placeholder:"Label..."}):a.jsx("p",{className:"text-xs text-bambu-gray mt-1 truncate cursor-pointer hover:text-white",onClick:()=>At({index:Qe.index,label:Qe.label}),title:Qe.label?`${Qe.label} - Click to edit`:"Click to add label",children:Qe.label||a.jsx("span",{className:"italic opacity-50",children:"No label"})}),a.jsx("p",{className:"text-[10px] text-bambu-gray/60",children:Qe.timestamp?new Date(Qe.timestamp).toLocaleDateString():""})]},Qe.index))})]}),!U.needs_calibration&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:"Detection Area (ROI)"}),Ee?a.jsxs("div",{className:"flex gap-1",children:[a.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>_e(null),disabled:Te,children:"Cancel"}),a.jsx(Ne,{size:"sm",onClick:Mn,disabled:Te,children:Te?a.jsx(ct,{className:"w-3 h-3 animate-spin"}):"Save"})]}):a.jsxs(Ne,{variant:"ghost",size:"sm",onClick:()=>_e(U.roi||{x:.15,y:.35,w:.7,h:.55}),children:[a.jsx(Ki,{className:"w-3 h-3 mr-1"}),"Edit"]})]}),Ee?a.jsxs("div",{className:"space-y-3 bg-bambu-dark-tertiary/50 p-3 rounded-lg",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray",children:"X Start"}),a.jsx("input",{type:"range",min:"0",max:"0.9",step:"0.01",value:Ee.x,onChange:Qe=>_e({...Ee,x:parseFloat(Qe.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(Ee.x*100),"%"]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray",children:"Y Start"}),a.jsx("input",{type:"range",min:"0",max:"0.9",step:"0.01",value:Ee.y,onChange:Qe=>_e({...Ee,y:parseFloat(Qe.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(Ee.y*100),"%"]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray",children:"Width"}),a.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.01",value:Ee.w,onChange:Qe=>_e({...Ee,w:parseFloat(Qe.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(Ee.w*100),"%"]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray",children:"Height"}),a.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.01",value:Ee.h,onChange:Qe=>_e({...Ee,h:parseFloat(Qe.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(Ee.h*100),"%"]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Adjust the detection area to focus on the build plate. The green box in the preview shows the current area."})]}):a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Current: X=",Math.round((U.roi?.x||.15)*100),"%, Y=",Math.round((U.roi?.y||.35)*100),"%, W=",Math.round((U.roi?.w||.7)*100),"%, H=",Math.round((U.roi?.h||.55)*100),"%"]})]})]}),a.jsx("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:U.needs_calibration?a.jsxs(a.Fragment,{children:[a.jsx(Ne,{variant:"ghost",onClick:()=>Zt(),children:"Cancel"}),a.jsx(Ne,{onClick:()=>$t(),disabled:z,children:z?a.jsxs(a.Fragment,{children:[a.jsx(ct,{className:"w-4 h-4 mr-2 animate-spin"}),"Calibrating..."]}):"Calibrate Empty Plate"})]}):a.jsxs(a.Fragment,{children:[a.jsx(Ne,{variant:"ghost",onClick:()=>$t(),disabled:z,children:z?"Adding...":`Add Reference (${ht?.references.length||0}/${ht?.max_references||5})`}),a.jsx(Ne,{onClick:()=>Zt(),children:"Close"})]})})]})}),O&&pe&&a.jsx(Yn,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{ln.mutate("on"),H(!1)},onCancel:()=>H(!1)}),j&&pe&&a.jsx(Yn,{title:"Power Off Printer",message:te?.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:()=>{ln.mutate("off"),G(!1)},onCancel:()=>G(!1)}),Y&&a.jsx(Yn,{title:"Stop Print",message:`Are you sure you want to stop the current print on "${t.name}"? This will cancel the print job.`,confirmText:"Stop Print",variant:"danger",onConfirm:()=>{er.mutate(),Z(!1)},onCancel:()=>Z(!1)}),oe&&a.jsx(Yn,{title:"Pause Print",message:`Are you sure you want to pause the current print on "${t.name}"?`,confirmText:"Pause Print",variant:"default",onConfirm:()=>{bn.mutate(),B(!1)},onCancel:()=>B(!1)}),W&&a.jsx(Yn,{title:"Resume Print",message:`Are you sure you want to resume the print on "${t.name}"?`,confirmText:"Resume Print",variant:"default",onConfirm:()=>{xi.mutate(),se(!1)},onCancel:()=>se(!1)}),ne&&a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>ce(!1),onKeyDown:Qe=>Qe.key==="Escape"&&ce(!1),tabIndex:-1,ref:Qe=>Qe?.focus(),children:[a.jsx("div",{className:"absolute inset-0 bg-black/50 z-0"}),a.jsxs("div",{className:"relative z-10 bg-white dark:bg-bambu-dark border border-gray-200 dark:border-bambu-dark-tertiary rounded-xl shadow-2xl w-[560px] max-h-[85vh] flex flex-col overflow-hidden",onClick:Qe=>Qe.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary bg-gray-50 dark:bg-bambu-dark",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(wG,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Skip Objects"})]}),a.jsx("button",{onClick:()=>ce(!1),className:"p-1 text-gray-500 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white rounded transition-colors",children:a.jsx(Dt,{className:"w-4 h-4"})})]}),Je?Je.objects.length===0?a.jsxs("div",{className:"text-center py-8 px-4 text-bambu-gray",children:[a.jsx("p",{className:"text-sm",children:"No objects found"}),a.jsx("p",{className:"text-xs mt-1 opacity-70",children:"Objects are loaded when a print starts"})]}):a.jsxs("div",{className:"flex flex-col overflow-hidden",children:[a.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 bg-blue-50 dark:bg-blue-500/10 border-b border-gray-200 dark:border-bambu-dark-tertiary",children:[a.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-lg bg-blue-100 dark:bg-blue-500/20 flex items-center justify-center",children:a.jsx(Kde,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-300",children:"Match IDs with your printer display"}),a.jsx("p",{className:"text-[10px] text-blue-500/70 dark:text-blue-300/60",children:"The printer screen shows object IDs on the build plate"})]}),a.jsxs("div",{className:"flex-shrink-0 text-xs text-gray-500 dark:text-bambu-gray",children:[Je.skipped_count,"/",Je.total," skipped"]})]}),(te?.layer_num??0)<=1&&a.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-amber-50 dark:bg-amber-500/10 border-b border-gray-200 dark:border-bambu-dark-tertiary",children:[a.jsx(Ii,{className:"w-4 h-4 text-amber-500 dark:text-amber-400 flex-shrink-0"}),a.jsxs("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:["Wait for layer 2+ to skip objects (currently layer ",te?.layer_num??0,")"]})]}),a.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[a.jsx("div",{className:"w-52 flex-shrink-0 p-4 border-r border-gray-200 dark:border-bambu-dark-tertiary bg-gray-50 dark:bg-bambu-dark-secondary overflow-y-auto",children:a.jsxs("div",{className:"relative",children:[te?.cover_url?a.jsx("img",{src:`${te.cover_url}?view=top`,alt:"Print preview",className:"w-full aspect-square object-contain rounded-lg bg-gray-900 dark:bg-gray-900 border border-gray-300 dark:border-gray-600"}):a.jsx("div",{className:"w-full aspect-square rounded-lg bg-gray-100 dark:bg-bambu-dark flex items-center justify-center",children:a.jsx(Pi,{className:"w-8 h-8 text-gray-300 dark:text-bambu-gray/30"})}),Je.objects.length>0&&a.jsx("div",{className:"absolute inset-0 pointer-events-none",children:Je.objects.map((Qe,Tt)=>{let qt,xt;if(Qe.x!=null&&Qe.y!=null&&Je.bbox_all){const[nn,gn,tr,br]=Je.bbox_all,Fa=tr-nn,sn=br-gn,Sn=8,ns=100-Sn*2;qt=Sn+(Qe.x-nn)/Fa*ns,xt=Sn+(br-Qe.y)/sn*ns,qt=Math.max(5,Math.min(95,qt)),xt=Math.max(5,Math.min(95,xt))}else if(Qe.x!=null&&Qe.y!=null)qt=Qe.x/256*100,xt=100-Qe.y/256*100,qt=Math.max(5,Math.min(95,qt)),xt=Math.max(5,Math.min(95,xt));else{const nn=Math.ceil(Math.sqrt(Je.objects.length)),gn=Math.floor(Tt/nn),tr=Tt%nn,br=Math.ceil(Je.objects.length/nn);qt=15+tr*(70/nn)+35/nn,xt=15+gn*(70/br)+35/br}return a.jsx("div",{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${Qe.skipped?"bg-red-500 text-white line-through":"bg-bambu-green text-black"}`,style:{left:`${qt}%`,top:`${xt}%`,transform:"translate(-50%, -50%)"},title:Qe.name,children:Qe.id},Qe.id)})}),a.jsxs("div",{className:"absolute bottom-2 right-2 px-2 py-1 bg-white/90 dark:bg-black/80 rounded text-[10px] text-gray-700 dark:text-white shadow-sm",children:[Je.objects.filter(Qe=>!Qe.skipped).length," active"]})]})}),a.jsx("div",{className:"flex-1 min-w-0 overflow-y-auto",children:Je.objects.map(Qe=>a.jsxs("div",{className:`
  8136. flex items-center gap-3 px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary/50 last:border-0
  8137. ${Qe.skipped?"bg-red-50 dark:bg-red-500/10":"hover:bg-gray-50 dark:hover:bg-bambu-dark/50"}
  8138. `,children:[a.jsxs("div",{className:`
  8139. w-12 h-12 flex-shrink-0 rounded-lg flex flex-col items-center justify-center
  8140. ${Qe.skipped?"bg-red-100 dark:bg-red-500/20 border border-red-300 dark:border-red-500/40":"bg-green-100 dark:bg-bambu-green/20 border border-green-300 dark:border-bambu-green/40"}
  8141. `,children:[a.jsx("span",{className:`text-lg font-mono font-bold ${Qe.skipped?"text-red-500 dark:text-red-400":"text-green-600 dark:text-bambu-green"}`,children:Qe.id}),a.jsx("span",{className:`text-[8px] uppercase tracking-wider ${Qe.skipped?"text-red-400/60":"text-green-500/60 dark:text-bambu-green/60"}`,children:"ID"})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("span",{className:`block text-sm truncate ${Qe.skipped?"text-red-500 dark:text-red-400 line-through":"text-gray-900 dark:text-white"}`,children:Qe.name}),Qe.skipped&&a.jsx("span",{className:"text-[10px] text-red-400/60",children:"Will be skipped"})]}),Qe.skipped?a.jsx("span",{className:"px-4 py-2 text-xs text-red-500 dark:text-red-400/70 bg-red-100 dark:bg-red-500/10 rounded-lg",children:"Skipped"}):a.jsx("button",{onClick:()=>st.mutate([Qe.id]),disabled:st.isPending||(te?.layer_num??0)<=1||!b("printers:control"),className:`px-4 py-2 text-xs font-medium rounded-lg transition-colors ${(te?.layer_num??0)<=1||!b("printers:control")?"bg-gray-100 dark:bg-bambu-dark text-gray-400 dark:text-bambu-gray/50 cursor-not-allowed":"bg-red-100 dark:bg-red-500/20 text-red-600 dark:text-red-400 hover:bg-red-200 dark:hover:bg-red-500/30 border border-red-300 dark:border-red-500/30"}`,title:b("printers:control")?(te?.layer_num??0)<=1?"Wait for layer 2+":"Skip this object":"You do not have permission to control printers",children:"Skip"})]},Qe.id))})]})]}):a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(ct,{className:"w-5 h-5 animate-spin text-bambu-gray"})})]})]}),$&&a.jsx(qNe,{printerName:t.name,errors:te?.hms_errors||[],onClose:()=>q(!1)}),fe&&a.jsx(zBe,{isOpen:!!fe,onClose:()=>ye(null),printerId:t.id,printerName:t.name,amsId:fe.amsId,amsLabel:fe.amsLabel,initialMode:fe.mode,thresholds:s}),ge&&a.jsx(BBe,{isOpen:!!ge,onClose:()=>xe(null),trayUuid:ge.trayUuid,trayInfo:ge.trayInfo}),Pe&&a.jsx(KBe,{isOpen:!!Pe,onClose:()=>Ue(null),printerId:t.id,slotInfo:Pe,onSuccess:()=>{m.invalidateQueries({queryKey:["slotPresets",t.id]}),m.invalidateQueries({queryKey:["printerStatus",t.id]})}}),k&&a.jsx(u8e,{printer:t,onClose:()=>E(!1)}),be&&Me&&a.jsx(c8e,{printer:t,firmwareInfo:Me,onClose:()=>it(!1)}),Xt&&a.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>tn(null)})]})}function l8e({onClose:t,onAdd:e,existingSerials:n}){const[r,i]=w.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",auto_archive:!0}),[s,o]=w.useState(!1),[l,c]=w.useState([]),[u,d]=w.useState(""),[f,m]=w.useState(!1),[p,x]=w.useState(!1),[b,y]=w.useState("192.168.1.0/24"),[v,S]=w.useState({scanned:0,total:0});w.useEffect(()=>{Xl.getInfo().then(E=>{x(E.is_docker)}).catch(()=>{})},[]);const N=l.filter(E=>!n.includes(E.serial)),C=async()=>{d(""),c([]),o(!0),m(!1),S({scanned:0,total:0});try{if(p){await Xl.startSubnetScan(b);const E=setInterval(async()=>{try{const D=await Xl.getScanStatus();S({scanned:D.scanned,total:D.total});const A=await Xl.getDiscoveredPrinters();c(A),D.running||(clearInterval(E),o(!1),m(!0))}catch(D){console.error("Failed to get scan status:",D)}},500)}else{await Xl.startDiscovery(10);const E=setInterval(async()=>{try{const D=await Xl.getDiscoveredPrinters();c(D)}catch(D){console.error("Failed to get discovered printers:",D)}},1e3);setTimeout(async()=>{clearInterval(E);try{await Xl.stopDiscovery()}catch{}o(!1),m(!0);try{const D=await Xl.getDiscoveredPrinters();c(D)}catch(D){console.error("Failed to get final discovered printers:",D)}},1e4)}}catch(E){console.error("Failed to start discovery:",E),d(E instanceof Error?E.message:"Failed to start discovery"),o(!1),m(!0)}},T=E=>E?{O1D:"H2D",O1E:"H2D Pro",O2D:"H2D Pro",O1C:"H2C",O1S:"H2S","BL-P001":"X1C","BL-P002":"X1","BL-P003":"X1E",C11:"P1S",C12:"P1P",C13:"P2S",N2S:"A1",N1:"A1 Mini",X1C:"X1C",X1:"X1",X1E:"X1E",P1S:"P1S",P1P:"P1P",P2S:"P2S",A1:"A1","A1 Mini":"A1 Mini",H2D:"H2D","H2D Pro":"H2D Pro",H2C:"H2C",H2S:"H2S"}[E]||E:"",k=E=>{const D=E.serial.startsWith("unknown-")?"":E.serial;i({...r,name:E.name||"",serial_number:D,ip_address:E.ip_address,model:T(E.model)}),c([])};return w.useEffect(()=>()=>{Xl.stopDiscovery().catch(()=>{}),Xl.stopSubnetScan().catch(()=>{})},[]),w.useEffect(()=>{const E=D=>{D.key==="Escape"&&t()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[t]),a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:a.jsx(wt,{className:"w-full max-w-md",onClick:E=>E.stopPropagation(),children:a.jsxs(St,{children:[a.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Add Printer"}),a.jsxs("div",{className:"mb-4 pb-4 border-b border-bambu-dark-tertiary",children:[p&&a.jsxs("div",{className:"mb-3",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Subnet to scan"}),a.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 text-sm",value:b,onChange:E=>y(E.target.value),placeholder:"192.168.1.0/24",disabled:s}),a.jsxs("p",{className:"mt-1 text-xs text-bambu-gray",children:["Docker detected. Enter your printer's subnet in CIDR notation. Requires ",a.jsx("code",{className:"text-bambu-green",children:"network_mode: host"})," in docker-compose.yml."]})]}),a.jsx(Ne,{type:"button",variant:"secondary",onClick:C,disabled:s,className:"w-full",children:s?a.jsxs(a.Fragment,{children:[a.jsx(ct,{className:"w-4 h-4 animate-spin"}),p&&v.total>0?`Scanning... ${v.scanned}/${v.total}`:"Scanning..."]}):a.jsxs(a.Fragment,{children:[a.jsx(pa,{className:"w-4 h-4"}),p?"Scan Subnet for Printers":"Discover Printers on Network"]})}),u&&a.jsx("div",{className:"mt-2 text-sm text-red-400",children:u}),N.length>0&&a.jsx("div",{className:"mt-3 space-y-2 max-h-40 overflow-y-auto",children:N.map(E=>a.jsxs("div",{className:"flex items-center justify-between p-2 bg-bambu-dark rounded-lg hover:bg-bambu-dark-secondary cursor-pointer transition-colors",onClick:()=>k(E),children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"font-medium text-white text-sm truncate",children:E.name||E.serial}),a.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[T(E.model)||"Unknown"," • ",E.ip_address,E.serial.startsWith("unknown-")&&a.jsx("span",{className:"text-yellow-500",children:" • Serial required"})]})]}),a.jsx(Xr,{className:"w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2"})]},E.serial))}),s&&a.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:p?"Scanning subnet for Bambu printers...":"Scanning network..."}),f&&!s&&l.length===0&&a.jsxs("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:["No printers found",p?" in the specified subnet":" on the network","."]}),f&&!s&&l.length>0&&N.length===0&&a.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:"All discovered printers are already configured."})]}),a.jsxs("form",{onSubmit:E=>{E.preventDefault(),e(r)},className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),a.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:E=>i({...r,name:E.target.value}),placeholder:"My Printer"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),a.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:E=>i({...r,ip_address:E.target.value}),placeholder:"192.168.1.100"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),a.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.serial_number,onChange:E=>i({...r,serial_number:E.target.value}),placeholder:"01P00A000000000"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),a.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:r.access_code,onChange:E=>i({...r,access_code:E.target.value}),placeholder:"From printer settings"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model (optional)"}),a.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:E=>i({...r,model:E.target.value}),children:[a.jsx("option",{value:"",children:"Select model..."}),a.jsxs("optgroup",{label:"H2 Series",children:[a.jsx("option",{value:"H2C",children:"H2C"}),a.jsx("option",{value:"H2D",children:"H2D"}),a.jsx("option",{value:"H2D Pro",children:"H2D Pro"}),a.jsx("option",{value:"H2S",children:"H2S"})]}),a.jsxs("optgroup",{label:"X1 Series",children:[a.jsx("option",{value:"X1E",children:"X1E"}),a.jsx("option",{value:"X1C",children:"X1 Carbon"}),a.jsx("option",{value:"X1",children:"X1"})]}),a.jsxs("optgroup",{label:"P Series",children:[a.jsx("option",{value:"P2S",children:"P2S"}),a.jsx("option",{value:"P1S",children:"P1S"}),a.jsx("option",{value:"P1P",children:"P1P"})]}),a.jsxs("optgroup",{label:"A1 Series",children:[a.jsx("option",{value:"A1",children:"A1"}),a.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"checkbox",id:"auto_archive",checked:r.auto_archive,onChange:E=>i({...r,auto_archive:E.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),a.jsxs("div",{className:"flex gap-3 pt-4",children:[a.jsx(Ne,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),a.jsx(Ne,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function c8e({printer:t,firmwareInfo:e,onClose:n}){const r=on(),{showToast:i}=Vn(),[s,o]=w.useState(null),[l,c]=w.useState(!1),[u,d]=w.useState(null),{data:f,isLoading:m}=at({queryKey:["firmwarePrepare",t.id],queryFn:()=>x1.prepareUpload(t.id),staleTime:3e4}),p=mt({mutationFn:()=>x1.startUpload(t.id),onSuccess:()=>{c(!0);const b=setInterval(async()=>{try{const y=await x1.getUploadStatus(t.id);o(y),(y.status==="complete"||y.status==="error")&&(clearInterval(b),d(null),c(!1),y.status==="complete"&&(i("Firmware uploaded! Trigger update from printer screen.","success"),r.invalidateQueries({queryKey:["firmwareUpdate",t.id]})))}catch{}},2e3);d(b)},onError:b=>{i(`Failed to start upload: ${b.message}`,"error"),c(!1)}});w.useEffect(()=>()=>{u&&clearInterval(u)},[u]);const x=()=>{o(null),p.mutate()};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsx(wt,{className:"w-full max-w-md mx-4",children:a.jsxs(St,{children:[a.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[a.jsx("div",{className:"p-2 rounded-full bg-orange-500/20",children:a.jsx(pi,{className:"w-5 h-5 text-orange-400"})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Firmware Update"}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:t.name})]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:[a.jsxs("div",{className:"flex justify-between items-center text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:"Current:"}),a.jsx("span",{className:"text-white font-mono",children:e.current_version||"Unknown"})]}),a.jsxs("div",{className:"flex justify-between items-center text-sm mt-1",children:[a.jsx("span",{className:"text-bambu-gray",children:"Latest:"}),a.jsx("span",{className:"text-orange-400 font-mono",children:e.latest_version})]}),e.release_notes&&a.jsxs("details",{className:"mt-3 text-sm",children:[a.jsx("summary",{className:"text-orange-400 cursor-pointer hover:underline",children:"Release Notes"}),a.jsx("div",{className:"mt-2 text-bambu-gray text-xs max-h-40 overflow-y-auto whitespace-pre-wrap",children:e.release_notes})]})]}),m?a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm mb-4",children:[a.jsx(ct,{className:"w-4 h-4 animate-spin"}),"Checking prerequisites..."]}):f&&!l&&!s?a.jsx("div",{className:"mb-4",children:f.can_proceed?a.jsxs("div",{className:"flex items-center gap-2 text-bambu-green text-sm",children:[a.jsx(Pi,{className:"w-4 h-4"}),"SD card ready. Click below to upload firmware."]}):a.jsx("div",{className:"space-y-1",children:f.errors.map((b,y)=>a.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[a.jsx(Ii,{className:"w-4 h-4 flex-shrink-0"}),b]},y))})}):null,(l||s)&&s&&a.jsxs("div",{className:"mb-4",children:[a.jsxs("div",{className:"flex items-center justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-bambu-gray capitalize",children:s.status}),a.jsxs("span",{className:"text-white",children:[s.progress,"%"]})]}),a.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:a.jsx("div",{className:`h-2 rounded-full transition-all ${s.status==="error"?"bg-status-error":s.status==="complete"?"bg-status-ok":"bg-orange-500"} ${s.status==="uploading"?"animate-pulse":""}`,style:{width:`${s.progress}%`}})}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:s.message}),s.error&&a.jsx("p",{className:"text-xs text-red-400 mt-1",children:s.error})]}),s?.status==="complete"&&a.jsxs("div",{className:"bg-bambu-green/10 border border-bambu-green/30 rounded-lg p-3 mb-4",children:[a.jsx("p",{className:"text-sm text-bambu-green font-medium mb-2",children:"Firmware uploaded to SD card!"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"To apply the update on your printer:"}),a.jsxs("ol",{className:"text-xs text-bambu-gray mt-1 list-decimal list-inside space-y-1",children:[a.jsxs("li",{children:["On the printer's touchscreen, go to ",a.jsx("strong",{className:"text-white",children:"Settings"})]}),a.jsxs("li",{children:["Navigate to ",a.jsx("strong",{className:"text-white",children:"Firmware"})]}),a.jsxs("li",{children:["Select ",a.jsx("strong",{className:"text-white",children:"Update from SD card"})]}),a.jsx("li",{children:"The update will take 10-20 minutes"})]})]}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx(Ne,{variant:"secondary",onClick:n,children:s?.status==="complete"?"Done":"Cancel"}),f?.can_proceed&&!l&&s?.status!=="complete"&&a.jsx(Ne,{onClick:x,disabled:p.isPending,children:p.isPending?a.jsxs(a.Fragment,{children:[a.jsx(ct,{className:"w-4 h-4 animate-spin mr-2"}),"Starting..."]}):a.jsxs(a.Fragment,{children:[a.jsx(pi,{className:"w-4 h-4 mr-2"}),"Upload Firmware"]})})]})]})})})}function u8e({printer:t,onClose:e}){const n=on(),{showToast:r}=Vn(),[i,s]=w.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),o=mt({mutationFn:c=>ue.updatePrinter(t.id,c),onSuccess:()=>{n.invalidateQueries({queryKey:["printers"]}),n.invalidateQueries({queryKey:["printerStatus",t.id]}),e()},onError:c=>r(c.message||"Failed to update printer","error")});w.useEffect(()=>{const c=u=>{u.key==="Escape"&&e()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[e]);const l=c=>{c.preventDefault();const u={name:i.name,ip_address:i.ip_address,model:i.model||void 0,location:i.location||void 0,auto_archive:i.auto_archive};i.access_code&&(u.access_code=i.access_code),o.mutate(u)};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:a.jsx(wt,{className:"w-full max-w-md",onClick:c=>c.stopPropagation(),children:a.jsxs(St,{children:[a.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Edit Printer"}),a.jsxs("form",{onSubmit:l,className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),a.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:i.name,onChange:c=>s({...i,name:c.target.value}),placeholder:"My Printer"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),a.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:i.ip_address,onChange:c=>s({...i,ip_address:c.target.value}),placeholder:"192.168.1.100"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),a.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}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Serial number cannot be changed"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),a.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:i.access_code,onChange:c=>s({...i,access_code:c.target.value}),placeholder:"Leave empty to keep current"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model"}),a.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:i.model,onChange:c=>s({...i,model:c.target.value}),children:[a.jsx("option",{value:"",children:"Select model..."}),a.jsxs("optgroup",{label:"H2 Series",children:[a.jsx("option",{value:"H2C",children:"H2C"}),a.jsx("option",{value:"H2D",children:"H2D"}),a.jsx("option",{value:"H2D Pro",children:"H2D Pro"}),a.jsx("option",{value:"H2S",children:"H2S"})]}),a.jsxs("optgroup",{label:"X1 Series",children:[a.jsx("option",{value:"X1E",children:"X1E"}),a.jsx("option",{value:"X1C",children:"X1 Carbon"}),a.jsx("option",{value:"X1",children:"X1"})]}),a.jsxs("optgroup",{label:"P Series",children:[a.jsx("option",{value:"P2S",children:"P2S"}),a.jsx("option",{value:"P1S",children:"P1S"}),a.jsx("option",{value:"P1P",children:"P1P"})]}),a.jsxs("optgroup",{label:"A1 Series",children:[a.jsx("option",{value:"A1",children:"A1"}),a.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Location / Group"}),a.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:i.location,onChange:c=>s({...i,location:c.target.value}),placeholder:"e.g., Workshop, Office, Basement"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Used to group printers on the dashboard"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"checkbox",id:"edit_auto_archive",checked:i.auto_archive,onChange:c=>s({...i,auto_archive:c.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),a.jsxs("div",{className:"flex gap-3 pt-4",children:[a.jsx(Ne,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsx(Ne,{type:"submit",className:"flex-1",disabled:o.isPending,children:o.isPending?"Saving...":"Save Changes"})]})]})]})})})}function d8e(t){const{data:e}=at({queryKey:["printerStatus",t],queryFn:()=>ue.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function h8e({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=d8e(t.id),{data:s}=at({queryKey:["smartPlugStatus",e.id],queryFn:()=>ue.getSmartPlugStatus(e.id),refetchInterval:1e4});return i?a.jsxs("div",{className:"flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:t.name}),s&&a.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||"?"})]}),a.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:[a.jsx(Vu,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function f8e(){const[t,e]=w.useState(!1),[n,r]=w.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[i,s]=w.useState(!1),[o,l]=w.useState(null),[c,u]=w.useState(()=>localStorage.getItem("printerSortBy")||"name"),[d,f]=w.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[m,p]=w.useState(()=>{const ne=localStorage.getItem("printerCardSize");return ne?parseInt(ne,10):2}),x=m===1?"compact":"expanded",b=on(),{showToast:y}=Vn(),{hasPermission:v}=Si(),[S,N]=w.useState(()=>{const ne=localStorage.getItem("openEmbeddedCameras");if(ne)try{const ce=JSON.parse(ne);return new Map(ce.map(fe=>[fe.id,fe]))}catch{return new Map}return new Map});w.useEffect(()=>{const ne=Array.from(S.values());ne.length>0?localStorage.setItem("openEmbeddedCameras",JSON.stringify(ne)):localStorage.removeItem("openEmbeddedCameras")},[S]);const{data:C,isLoading:T}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:k}=at({queryKey:["settings"],queryFn:ue.getSettings});w.useEffect(()=>{k?.camera_view_mode==="window"&&S.size>0&&N(new Map)},[k?.camera_view_mode,S.size]);const{data:E}=at({queryKey:["smart-plugs"],queryFn:ue.getSmartPlugs}),{data:D}=at({queryKey:["maintenanceOverview"],queryFn:ue.getMaintenanceOverview,staleTime:60*1e3}),{data:A}=at({queryKey:["spoolman-status"],queryFn:ue.getSpoolmanStatus,staleTime:60*1e3}),R=A?.enabled&&A?.connected,{data:F}=at({queryKey:["unlinked-spools"],queryFn:ue.getUnlinkedSpools,enabled:!!R,staleTime:30*1e3}),O=F&&F.length>0,H=D?.reduce((ne,ce)=>(ne[ce.printer_id]={due_count:ce.due_count,warning_count:ce.warning_count,total_print_hours:ce.total_print_hours},ne),{})||{},j=E?.reduce((ne,ce)=>(ce.printer_id&&(ne[ce.printer_id]=ce),ne),{})||{},G=mt({mutationFn:ue.createPrinter,onSuccess:()=>{b.invalidateQueries({queryKey:["printers"]}),b.invalidateQueries({queryKey:["maintenanceOverview"]}),e(!1)},onError:ne=>y(ne.message||"Failed to add printer","error")}),$=mt({mutationFn:ne=>ue.controlSmartPlug(ne,"on"),onSuccess:()=>{b.invalidateQueries({queryKey:["smart-plugs"]}),l(null)},onError:()=>{l(null)}}),q=()=>{const ne=!n;r(ne),localStorage.setItem("hideDisconnectedPrinters",String(ne))},Y=ne=>{u(ne),localStorage.setItem("printerSortBy",ne)},Z=()=>{const ne=!d;f(ne),localStorage.setItem("printerSortAsc",String(ne))},oe=()=>{switch(m){case 1:return"grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5";case 2:return"grid-cols-1 md:grid-cols-2 xl:grid-cols-3";case 3:return"grid-cols-1 lg:grid-cols-2";case 4:return"grid-cols-1";default:return"grid-cols-1 md:grid-cols-2 xl:grid-cols-3"}},B=["S","M","L","XL"],W=w.useMemo(()=>{if(!C)return[];const ne=[...C];switch(c){case"name":ne.sort((ce,fe)=>ce.name.localeCompare(fe.name));break;case"model":ne.sort((ce,fe)=>(ce.model||"").localeCompare(fe.model||""));break;case"location":ne.sort((ce,fe)=>{const ye=ce.location||"",ge=fe.location||"";return!ye&&ge?1:ye&&!ge?-1:ye.localeCompare(ge)||ce.name.localeCompare(fe.name)});break;case"status":ne.sort((ce,fe)=>{const ye=b.getQueryData(["printerStatus",ce.id]),ge=b.getQueryData(["printerStatus",fe.id]),xe=Pe=>Pe?.connected?Pe.state==="RUNNING"?0:1:2;return xe(ye)-xe(ge)});break}return d||ne.reverse(),ne},[C,c,d,b]),se=w.useMemo(()=>{if(c!=="location")return null;const ne={};return W.forEach(ce=>{const fe=ce.location||"Ungrouped";ne[fe]||(ne[fe]=[]),ne[fe].push(ce)}),ne},[c,W]);return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:"Printers"}),a.jsx(o8e,{printers:C})]}),a.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 flex-wrap",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs("select",{value:c,onChange:ne=>Y(ne.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:[a.jsx("option",{value:"name",children:"Name"}),a.jsx("option",{value:"status",children:"Status"}),a.jsx("option",{value:"model",children:"Model"}),a.jsx("option",{value:"location",children:"Location"})]}),a.jsx("button",{onClick:Z,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:d?"Sort descending":"Sort ascending",children:d?a.jsx(Fg,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(G0,{className:"w-4 h-4 text-bambu-gray"})})]}),a.jsx("div",{className:"flex items-center bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:B.map((ne,ce)=>{const fe=ce+1,ye=m===fe;return a.jsx("button",{onClick:()=>{p(fe),localStorage.setItem("printerCardSize",String(fe))},className:`px-2 py-1.5 text-xs font-medium transition-colors ${ce===0?"rounded-l-lg":""} ${ce===B.length-1?"rounded-r-lg":""} ${ye?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white"}`,title:`${ne==="S"?"Small":ne==="M"?"Medium":ne==="L"?"Large":"Extra large"} cards`,children:ne},ne)})}),a.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:n,onChange:q,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Hide offline"]}),n&&Object.keys(j).length>0&&a.jsxs("div",{className:"relative",children:[a.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:[a.jsx(Vu,{className:"w-4 h-4"}),"Power On",a.jsx(Xr,{className:`w-3 h-3 transition-transform ${i?"rotate-180":""}`})]}),i&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>s(!1)}),a.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:[a.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"}),C?.filter(ne=>j[ne.id]).map(ne=>a.jsx(h8e,{printer:ne,plug:j[ne.id],onPowerOn:ce=>{l(ce),$.mutate(ce)},isPowering:o===j[ne.id]?.id},ne.id)),C?.filter(ne=>j[ne.id]).length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),a.jsxs(Ne,{onClick:()=>e(!0),disabled:!v("printers:create"),title:v("printers:create")?void 0:"You do not have permission to add printers",children:[a.jsx(lr,{className:"w-4 h-4"}),"Add Printer"]})]})]}),T?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):C?.length===0?a.jsx(wt,{children:a.jsxs(St,{className:"text-center py-12",children:[a.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),a.jsxs(Ne,{onClick:()=>e(!0),disabled:!v("printers:create"),title:v("printers:create")?void 0:"You do not have permission to add printers",children:[a.jsx(lr,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):se?a.jsx("div",{className:"space-y-6",children:Object.entries(se).map(([ne,ce])=>a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[a.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),ne,a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",ce.length,")"]})]}),a.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${oe()}`,children:ce.map(fe=>a.jsx(kG,{printer:fe,hideIfDisconnected:n,maintenanceInfo:H[fe.id],viewMode:x,cardSize:m,amsThresholds:k?{humidityGood:Number(k.ams_humidity_good)||40,humidityFair:Number(k.ams_humidity_fair)||60,tempGood:Number(k.ams_temp_good)||28,tempFair:Number(k.ams_temp_fair)||35}:void 0,spoolmanEnabled:R,hasUnlinkedSpools:O,timeFormat:k?.time_format||"system",cameraViewMode:k?.camera_view_mode||"window",onOpenEmbeddedCamera:(ye,ge)=>N(xe=>new Map(xe).set(ye,{id:ye,name:ge})),checkPrinterFirmware:k?.check_printer_firmware!==!1},fe.id))})]},ne))}):a.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${oe()}`,children:W.map(ne=>a.jsx(kG,{printer:ne,hideIfDisconnected:n,maintenanceInfo:H[ne.id],viewMode:x,cardSize:m,spoolmanEnabled:R,hasUnlinkedSpools:O,amsThresholds:k?{humidityGood:Number(k.ams_humidity_good)||40,humidityFair:Number(k.ams_humidity_fair)||60,tempGood:Number(k.ams_temp_good)||28,tempFair:Number(k.ams_temp_fair)||35}:void 0,timeFormat:k?.time_format||"system",cameraViewMode:k?.camera_view_mode||"window",onOpenEmbeddedCamera:(ce,fe)=>N(ye=>new Map(ye).set(ce,{id:ce,name:fe})),checkPrinterFirmware:k?.check_printer_firmware!==!1},ne.id))}),t&&a.jsx(l8e,{onClose:()=>e(!1),onAdd:ne=>G.mutate(ne),existingSerials:C?.map(ne=>ne.serial_number)||[]}),Array.from(S.values()).map((ne,ce)=>a.jsx(BNe,{printerId:ne.id,printerName:ne.name,viewerIndex:ce,onClose:()=>N(fe=>{const ye=new Map(fe);return ye.delete(ne.id),ye})},ne.id))]})}function m8e(){const t=navigator.userAgent.toLowerCase(),e=navigator.platform?.toLowerCase()||"";return t.includes("win")||e.includes("win")?"windows":t.includes("mac")||e.includes("mac")?"macos":t.includes("linux")||e.includes("linux")?"linux":"unknown"}function p8e(){switch(m8e()){case"windows":return"bambustudio://";case"macos":case"linux":default:return"bambustudioopen://"}}function sc(t){const e=p8e();window.location.href=`${e}${encodeURIComponent(t)}`}function gL({archiveId:t,libraryFileId:e,title:n,fileType:r,onClose:i}){const s=e!=null,[o,l]=w.useState(null),[c,u]=w.useState(null),[d,f]=w.useState(!0),[m,p]=w.useState(null),[x,b]=w.useState(!1),[y,v]=w.useState(null);w.useEffect(()=>{const E=D=>{D.key==="Escape"&&i()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[i]),w.useEffect(()=>{if(f(!0),s){const E=(r||"").toLowerCase(),D=E==="3mf"||E==="stl",A=E==="gcode"||E==="3mf";u({has_model:D,has_gcode:A,has_source:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),l(D?"3d":A?"gcode":null),f(!1);return}if(!t){u(null),l(null),f(!1);return}ue.getArchiveCapabilities(t).then(E=>{u(E),E.has_model?l("3d"):E.has_gcode&&l("gcode"),f(!1)}).catch(()=>{u({has_model:!0,has_gcode:!1,has_source:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),l("3d"),f(!1)})},[t,r,s]),w.useEffect(()=>{if(b(!0),v(null),s){const E=(r||"").toLowerCase();if(!e||E!=="3mf"){p(null),b(!1);return}ue.getLibraryFilePlates(e).then(D=>p(D)).catch(()=>p(null)).finally(()=>b(!1));return}if(!t){p(null),b(!1);return}ue.getArchivePlates(t).then(E=>p(E)).catch(()=>p(null)).finally(()=>b(!1))},[t,r,s,e]);const S=m?.plates??[],N=(m?.is_multi_plate??!1)&&S.length>1,C=y==null?null:S.find(E=>E.index===y)??null,T=s?(r||"").toLowerCase()==="3mf":!0,k=()=>{if(!T)return;const E=n||"model";if(s){const A=`${window.location.origin}${ue.getLibraryFileDownloadUrl(e)}`;sc(A);return}const D=`${window.location.origin}${ue.getArchiveForSlicer(t,E)}`;sc(D)};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:i,children:a.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:E=>E.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:n}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:k,disabled:!T,children:[a.jsx(Yr,{className:"w-4 h-4"}),"Open in Slicer"]}),a.jsx(Ne,{variant:"ghost",size:"sm",onClick:i,children:a.jsx(Dt,{className:"w-5 h-5"})})]})]}),c&&a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[a.jsxs("button",{onClick:()=>c.has_model&&l("3d"),disabled:!c.has_model,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${o==="3d"?"text-bambu-green border-b-2 border-bambu-green":c.has_model?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[a.jsx(Pi,{className:"w-4 h-4"}),"3D Model",!c.has_model&&a.jsx("span",{className:"text-xs",children:"(not available)"})]}),a.jsxs("button",{onClick:()=>c.has_gcode&&l("gcode"),disabled:!c.has_gcode,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${o==="gcode"?"text-bambu-green border-b-2 border-bambu-green":c.has_gcode?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[a.jsx(oue,{className:"w-4 h-4"}),"G-code Preview",!c.has_gcode&&a.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),a.jsx("div",{className:"flex-1 overflow-hidden p-4",children:d?a.jsx("div",{className:"w-full h-full flex items-center justify-center",children:a.jsx(ct,{className:"w-8 h-8 animate-spin text-bambu-green"})}):o==="3d"&&c?a.jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[N&&a.jsxs("div",{className:"rounded-lg border border-bambu-dark-tertiary bg-bambu-dark p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray mb-2",children:[a.jsx(xs,{className:"w-4 h-4"}),"Plates",x&&a.jsx(ct,{className:"w-3 h-3 animate-spin"})]}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2",children:[a.jsxs("button",{type:"button",onClick:()=>v(null),className:`flex items-center gap-2 rounded-lg border p-2 text-left transition-colors ${y==null?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray"}`,children:[a.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:a.jsx(xs,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm text-white font-medium truncate",children:"All Plates"}),a.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[S.length," plate",S.length!==1?"s":""]})]}),y==null&&a.jsx(Wi,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]}),S.map(E=>a.jsxs("button",{type:"button",onClick:()=>v(E.index),className:`flex items-center gap-2 rounded-lg border p-2 text-left transition-colors ${y===E.index?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray"}`,children:[E.has_thumbnail&&E.thumbnail_url?a.jsx("img",{src:E.thumbnail_url,alt:`Plate ${E.index}`,className:"w-10 h-10 rounded object-cover bg-bambu-dark-tertiary"}):a.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:a.jsx(xs,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm text-white font-medium truncate",children:E.name||`Plate ${E.index}`}),a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:E.objects.length>0?E.objects.slice(0,2).join(", ")+(E.objects.length>2?"…":""):`${E.filaments.length} filament${E.filaments.length!==1?"s":""}`})]}),y===E.index&&a.jsx(Wi,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},E.index))]}),C&&a.jsxs("div",{className:"mt-3 text-xs text-bambu-gray flex flex-wrap gap-x-4 gap-y-1",children:[a.jsxs("span",{children:["Plate ",C.index]}),C.print_time_seconds!=null&&a.jsxs("span",{children:["ETA ",Math.round(C.print_time_seconds/60)," min"]}),C.filament_used_grams!=null&&a.jsxs("span",{children:[C.filament_used_grams.toFixed(1)," g"]}),C.filaments.length>0&&a.jsxs("span",{children:[C.filaments.length," filament",C.filaments.length!==1?"s":""]})]})]}),a.jsx("div",{className:"flex-1",children:a.jsx(CK,{url:s?ue.getLibraryFileDownloadUrl(e):c.has_source?ue.getSource3mfDownloadUrl(t):ue.getArchiveDownload(t),fileType:r,buildVolume:c.build_volume,filamentColors:c.filament_colors,selectedPlateId:y,className:"w-full h-full"})})]}):o==="gcode"&&c?a.jsx(cX,{gcodeUrl:s?ue.getLibraryFileGcodeUrl(e):ue.getArchiveGcode(t),filamentColors:c.filament_colors,className:"w-full h-full"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}const jG={"000000":"Black","001489":"Blue","002e96":"Blue","0047bb":"Blue","00482b":"Pine Green","004ea8":"Blue","0056b8":"Cobalt Blue","0069b1":"Lake Blue","0072ce":"Blue","0078bf":"Marine Blue","0085ad":"Light Blue","0086d6":"Cyan","008bda":"Blue","009639":"Green","009bd8":"Cyan","009fa1":"Teal","00a6a0":"Green","00ae42":"Bambu Green","00b1b7":"Turquoise","00bb31":"Green","018814":"Candy Green","042f56":"Dark Blue","0a2989":"Blue","0a2ca5":"Blue","0c2340":"Navy Blue","0c3b95":"Blue",101820:"Black","147bd1":"Blue","164b35":"Green","16b08e":"Malachite Green","1d7c6a":"Oxide Green Metallic","1f79e5":"Lake Blue","2140b4":"Blue","25282a":"Black","2842ad":"Royal Blue","2d2b28":"Onyx Black Sparkle",324585:"Indigo Blue",353533:"Gray","39541a":"Forest Green","39699e":"Cobalt Blue Metallic","3b665e":"Green","3f5443":"Alpine Green Sparkle","3f8e43":"Mistletoe Green",424379:"Nebulae","43403d":"Iron Gray Metallic",482960:"Indigo Purple","483d8b":"Royal Purple Sparkle","489fdf":"Azure","4c241c":"Rosewood","4ce4a0":"Green","4d3324":"Dark Chocolate","4d5054":"Lava Gray","4dafda":"Cyan","4f3f24":"Black Walnut",515151:"Dark Gray","515a6c":"Gray",545454:"Dark Gray",565656:"Titan Gray","56b7e6":"Sky Blue",583061:"Violet Purple","5898dd":"Blue",594177:"Purple","5b492f":"Brown","5b6579":"Blue Gray","5c9748":"Matcha Green","5e43b7":"Purple","5e4b3c":"Copper","5f6367":"Titan Gray","61b0ff":"Translucent Light Blue","61bf36":"Green","61c680":"Grass Green","6667ab":"Lavender Blue","684a43":"Brown",686865:"Black","68724d":"Dark Green",688197:"Blue Gray","69398e":"Iris Purple","6e88bc":"Jeans Blue","6ee53c":"Lime Green","6f5034":"Cocoa Brown","7248bd":"Lavender","748c45":"Translucent Olive",757575:"Nardo Gray","75aed8":"Blue","77edd7":"Translucent Teal","789d4a":"Olive","792b36":"Crimson Red Sparkle","7ac0e9":"Glow Blue","7ae1bf":"Mint","7cd82b":"Lime Green","7d6556":"Dark Brown","8344b0":"Purple","847d48":"Bronze","854ce4":"Purple","8671cb":"Purple",875718:"Peanut Brown","87909a":"Silver","898d8d":"Gray","8a949e":"Gray","8e8e8e":"Translucent Gray","8e9089":"Gray","90ff1a":"Neon Green",918669:"Classic Birch",939393:"Gray",950051:"Plum","951e23":"Burgundy Red",959698:"Silver","96d8af":"Light Jade","96dcb9":"Mint","995f11":"Clay Brown","999d9d":"Gray","9b9ea0":"Ash Gray","9d2235":"Maroon Red","9d432c":"Brown","9e007e":"Purple","9ea2a2":"Gray","9f332a":"Brick Red",a1ffac:"Glow Green",a3d8e1:"Ice Blue",a6a9aa:"Silver",a8a8aa:"Gray",a8c6ee:"Baby Blue",aa6443:"Copper Brown Metallic",ad4e38:"Red Granite",adb1b2:"Gray",ae835b:"Caramel",ae96d4:"Lilac Purple",af1685:"Purple",afb1ae:"Gray",b15533:"Terracotta",b28b33:"Gold",b39b84:"Iridium Gold Metallic",b50011:"Red",b8acd6:"Lavender",b8cde9:"Ice Blue",ba9594:"Rose Gold",bb3d43:"Dark Red",bc0900:"Red",becf00:"Bright Green",c0df16:"Green",c12e1f:"Red",c2e189:"Apple Green",c3e2d6:"Light Cyan",c5ed48:"Lime",c6001a:"Red",c6c6c6:"Gray",c8102e:"Red",c8c8c8:"Silver",c98935:"Ochre Yellow",c9a381:"Translucent Brown",cbc6b8:"Bone White",cdceca:"Gray",cea629:"Classic Gold Sparkle",d02727:"Candy Red",d1d3d5:"Light Gray",d32941:"Red",d3b7a7:"Latte Brown",d6001c:"Red",d6abff:"Translucent Purple",d6cca3:"White Oak",dc3a27:"Orange",dd3c22:"Vermilion Red",de4343:"Scarlet Red",dfd1a7:"Beige",e02928:"Red",e4bd68:"Gold",e5b03d:"Gold",e83100:"Red",e8afcf:"Sakura Pink",e8dbb7:"Desert Tan",eaeae4:"White",eaeceb:"Silver",ec008c:"Magenta",ed0000:"Red",eeb1c1:"Pink",efe255:"Yellow",f0f1a8:"Clear",f17b8f:"Glow Pink",f3cfb2:"Champagne",f3e600:"Yellow",f48438:"Orange",f4a925:"Gold",f4d53f:"Yellow",f4ee2a:"Yellow",f5547c:"Hot Pink",f55a74:"Pink",f5b6cd:"Cherry Pink",f5dbab:"Mellow Yellow",f5f1dd:"White",f68b1b:"Neon Orange",f74e02:"Orange",f75403:"Orange",f7ada6:"Pink",f7d959:"Lemon Yellow",f7e6de:"Beige",f7f3f0:"White Marble",f8ff80:"Glow Yellow",f99963:"Mandarin Orange",f9c1bd:"Translucent Pink",f9dfb9:"Cream",f9ef41:"Yellow",f9f7f2:"Nature",f9f7f4:"White",fce300:"Yellow",fce900:"Yellow",fec600:"Sunflower Yellow",fedb00:"Yellow",ff4800:"Orange",ff671f:"Orange",ff6a13:"Orange",ff7f41:"Orange",ff9016:"Pumpkin Orange",ff911a:"Translucent Orange",ff9d5b:"Glow Orange",ffb549:"Sunflower Yellow",ffc72c:"Tangerine Yellow",ffce00:"Yellow",ffd00b:"Yellow",ffe133:"Yellow",fffaf2:"White",ffffff:"White"};function g8e(t){if(!t||t.length<6)return"Unknown";const e=t.replace("#",""),n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16),s=Math.max(n,r,i)/255,o=Math.min(n,r,i)/255,l=(s+o)/2;let c=0,u=0;if(s!==o){const d=s-o;u=l>.5?d/(2-s-o):d/(s+o);const f=n/255,m=r/255,p=i/255;s===f?c=((m-p)/d+(m<p?6:0))/6:s===m?c=((p-f)/d+2)/6:c=((f-m)/d+4)/6}return c=c*360,l<.15?"Black":l>.85?"White":u<.15?l<.4?"Dark Gray":l>.6?"Light Gray":"Gray":c<15||c>=345?"Red":c<45?"Orange":c<70?"Yellow":c<150?"Green":c<200?"Cyan":c<260?"Blue":c<290?"Purple":c<345?"Pink":"Unknown"}function sx(t){const e=t.replace("#","").toLowerCase().substring(0,6);return jG[e]?jG[e]:g8e(t)}function o2(t){return t?`#${t.replace("#","").substring(0,6)}`:"#808080"}function xa(t){return t?t.replace("#","").toLowerCase().substring(0,6):""}function kh(t,e,n=40){const r=xa(t),i=xa(e);if(!r||!i||r.length<6||i.length<6)return!1;const s=parseInt(r.substring(0,2),16),o=parseInt(r.substring(2,4),16),l=parseInt(r.substring(4,6),16),c=parseInt(i.substring(0,2),16),u=parseInt(i.substring(2,4),16),d=parseInt(i.substring(4,6),16);return Math.abs(s-c)<=n&&Math.abs(o-u)<=n&&Math.abs(l-d)<=n}function See(t,e,n,r){const i=String.fromCharCode(65+(t>=128?t-128:t));return n?`HT-${i}`:`AMS-${i} Slot ${e+1}`}function Nee(t,e,n){return t*4+e}function x8e(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 b8e(){const t=new Date;return t.setMinutes(t.getMinutes()+1),t.toISOString().slice(0,16)}function PG(t){if(!t)return!1;const e=Date.now()+4320*60*60*1e3;return new Date(t).getTime()>e}function xL(t){const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const s=o2(i.tray_color);e.push({type:i.tray_type,color:s,colorName:sx(s),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:See(n.id,i.id,r),globalTrayId:Nee(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=o2(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:sx(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e}function RG(t,e){if(!t?.filaments||t.filaments.length===0)return;const n=xL(e);if(n.length===0)return;const r=new Set,i=t.filaments.map(l=>{const c=n.find(m=>!r.has(m.globalTrayId)&&m.type?.toUpperCase()===l.type?.toUpperCase()&&xa(m.color)===xa(l.color)),u=!c&&n.find(m=>!r.has(m.globalTrayId)&&m.type?.toUpperCase()===l.type?.toUpperCase()&&kh(m.color,l.color)),d=!c&&!u&&n.find(m=>!r.has(m.globalTrayId)&&m.type?.toUpperCase()===l.type?.toUpperCase()),f=c||u||d||void 0;return f&&r.add(f.globalTrayId),{slot_id:l.slot_id,globalTrayId:f?.globalTrayId??-1}}),s=Math.max(...i.map(l=>l.slot_id||0));if(s<=0)return;const o=new Array(s).fill(-1);return i.forEach(l=>{l.slot_id&&l.slot_id>0&&(o[l.slot_id-1]=l.globalTrayId)}),o}function y8e(t){return w.useMemo(()=>{const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const s=o2(i.tray_color);e.push({type:i.tray_type,color:s,colorName:sx(s),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:See(n.id,i.id,r),globalTrayId:Nee(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=o2(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:sx(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e},[t])}function Mee(t,e,n){const r=y8e(e),i=w.useMemo(()=>{if(!t?.filaments||t.filaments.length===0)return[];const c=new Set(Object.values(n));return t.filaments.map(u=>{const d=u.slot_id||0;if(d>0&&n[d]!==void 0){const N=n[d],C=r.find(T=>T.globalTrayId===N);if(C){const T=C.type?.toUpperCase()===u.type?.toUpperCase(),k=xa(C.color)===xa(u.color)||kh(C.color,u.color);let E;return T&&k?E="match":T?E="type_only":E="mismatch",{...u,loaded:C,hasFilament:!0,typeMatch:T,colorMatch:k,status:E,isManual:!0}}}const f=r.find(N=>!c.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase()&&xa(N.color)===xa(u.color)),m=!f&&r.find(N=>!c.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase()&&kh(N.color,u.color)),p=!f&&!m&&r.find(N=>!c.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase()),x=f||m||p||void 0;x&&c.add(x.globalTrayId);const b=!!x,y=b,v=!!f||!!m;let S;return f||m?S="match":p?S="type_only":S="mismatch",{...u,loaded:x,hasFilament:b,typeMatch:y,colorMatch:v,status:S,isManual:!1}})},[t,r,n]),s=w.useMemo(()=>{if(i.length===0)return;const c=Math.max(...i.map(d=>d.slot_id||0));if(c<=0)return;const u=new Array(c).fill(-1);return i.forEach(d=>{d.slot_id&&d.slot_id>0&&(u[d.slot_id-1]=d.loaded?.globalTrayId??-1)}),u},[i]),o=i.some(c=>c.status==="mismatch"),l=i.some(c=>c.status==="type_only");return{loadedFilaments:r,filamentComparison:i,amsMapping:s,hasTypeMismatch:o,hasColorMismatch:l}}function v8e(t,e,n){if(!t||t.length===0)return{exactMatches:0,typeOnlyMatches:0,missingTypes:0,totalSlots:0,status:"full"};let r=0,i=0,s=0;const o=new Set(Object.values(n));for(const u of t){const d=u.slot_id||0;if(d>0&&n[d]!==void 0){const b=n[d],y=e.find(v=>v.globalTrayId===b);if(y){const v=y.type?.toUpperCase()===u.type?.toUpperCase(),S=xa(y.color)===xa(u.color)||kh(y.color,u.color);v&&S?r++:v?i++:s++;continue}}const f=e.find(b=>!o.has(b.globalTrayId)&&b.type?.toUpperCase()===u.type?.toUpperCase()&&xa(b.color)===xa(u.color)),m=f?void 0:e.find(b=>!o.has(b.globalTrayId)&&b.type?.toUpperCase()===u.type?.toUpperCase()&&kh(b.color,u.color)),p=f||m?void 0:e.find(b=>!o.has(b.globalTrayId)&&b.type?.toUpperCase()===u.type?.toUpperCase()),x=f??m??p;x&&o.add(x.globalTrayId),f||m?r++:p?i++:s++}const l=t.length;let c="full";return s>0?c="missing":i>0&&(c="partial"),{exactMatches:r,typeOnlyMatches:i,missingTypes:s,totalSlots:l,status:c}}function _8e(t,e,n){if(!t?.filaments||t.filaments.length===0)return;const r=xL(e);if(r.length===0)return;const i=new Set(Object.values(n)),s=[];for(const c of t.filaments){const u=c.slot_id||0;if(u>0&&n[u]!==void 0){s.push({slot_id:u,globalTrayId:n[u]});continue}const d=r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()&&xa(x.color)===xa(c.color)),f=d?void 0:r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()&&kh(x.color,c.color)),m=d||f?void 0:r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()),p=d??f??m;p&&i.add(p.globalTrayId),s.push({slot_id:u,globalTrayId:p?.globalTrayId??-1})}const o=Math.max(...s.map(c=>c.slot_id||0));if(o<=0)return;const l=new Array(o).fill(-1);return s.forEach(c=>{c.slot_id&&c.slot_id>0&&(l[c.slot_id-1]=c.globalTrayId)}),l}const DG={useDefault:!0,manualMappings:{},autoConfigured:!1};function w8e(t,e,n,r,i,s){const o=gW({queries:t.map(x=>({queryKey:["printer-status",x],queryFn:()=>ue.getPrinterStatus(x),enabled:t.length>0,staleTime:5e3}))}),l=w.useMemo(()=>t.map((x,b)=>{const y=o[b],v=y?.data,N=e?.find(R=>R.id===x)?.name||`Printer ${x}`,C=xL(v),T=i[x]||DG,k=RG(n,v),E=T.useDefault?r:T.manualMappings,D=_8e(n,v,E),A=v8e(n?.filaments,C,E);return{printerId:x,printerName:N,status:v,isLoading:y?.isLoading??!1,loadedFilaments:C,autoMapping:k,finalMapping:D,matchStatus:A.status,exactMatches:A.exactMatches,typeOnlyMatches:A.typeOnlyMatches,missingTypes:A.missingTypes,totalSlots:A.totalSlots,config:T}}),[t,o,e,n,i,r]),c=o.some(x=>x.isLoading),u=(x,b)=>{s(y=>({...y,[x]:{...y[x]||DG,...b}}))},d=x=>{const b=l.find(S=>S.printerId===x);if(!b||!b.status||!n?.filaments)return;const y=RG(n,b.status);if(!y)return;const v={};y.forEach((S,N)=>{S!==-1&&(v[N+1]=S)}),u(x,{useDefault:!1,manualMappings:v,autoConfigured:!0})},f=()=>{for(const x of t)d(x)},m=x=>l.find(y=>y.printerId===x)?.finalMapping,p=l.every(x=>x.matchStatus!=="missing");return{printerResults:l,isLoading:c,perPrinterConfigs:i,updatePrinterConfig:u,autoConfigureAll:f,autoConfigurePrinter:d,getFinalMapping:m,allPrintersReady:p}}function S8e({printerResult:t,filamentReqs:e,onUpdateConfig:n}){const r=on(),[i,s]=w.useState(!1),o=(u,d)=>{if(u<=0)return;const f={...t.config.manualMappings};d===""?delete f[u]:f[u]=parseInt(d,10),n({useDefault:!1,manualMappings:f,autoConfigured:!1})},l=async()=>{s(!0);try{await ue.refreshPrinterStatus(t.printerId),await new Promise(u=>setTimeout(u,500)),await r.refetchQueries({queryKey:["printer-status",t.printerId]})}finally{s(!1)}},c=e.map(u=>{const d=u.slot_id||0,f=t.config.manualMappings[d];let m,p=!1;if(f!==void 0)m=t.loadedFilaments.find(b=>b.globalTrayId===f),p=!0;else{const b=new Set(Object.values(t.config.manualMappings)),y=t.loadedFilaments.find(N=>!b.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase()&&xa(N.color)===xa(u.color)),v=y?void 0:t.loadedFilaments.find(N=>!b.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase()&&kh(N.color,u.color)),S=y||v?void 0:t.loadedFilaments.find(N=>!b.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase());m=y??v??S}let x="mismatch";if(m){const b=m.type?.toUpperCase()===u.type?.toUpperCase(),y=xa(m.color)===xa(u.color)||kh(m.color,u.color);b&&y?x="match":b&&(x="type_only")}return{req:u,loaded:m,status:x,isManual:p}});return a.jsxs("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Custom slot mapping"}),a.jsxs("button",{type:"button",onClick:l,className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",disabled:i,children:[a.jsx(Pr,{className:`w-3 h-3 ${i?"animate-spin":""}`}),a.jsx("span",{children:"Re-read"})]})]}),c.map(({req:u,loaded:d,status:f,isManual:m},p)=>a.jsxs("div",{className:"grid items-center gap-2 text-xs",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 16px"},children:[a.jsx("span",{title:`Required: ${u.type} - ${sx(u.color)}`,children:a.jsx(h3,{className:"w-3 h-3",fill:u.color,stroke:u.color})}),a.jsxs("span",{className:"text-white truncate",children:[u.type," ",a.jsxs("span",{className:"text-bambu-gray",children:["(",u.used_grams,"g)"]})]}),a.jsx("span",{className:"text-bambu-gray",children:"→"}),a.jsxs("select",{value:d?.globalTrayId??"",onChange:x=>o(u.slot_id||0,x.target.value),className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${f==="match"?"border-bambu-green/50 text-bambu-green":f==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${m?"ring-1 ring-blue-400/50":""}`,title:m?"Manually selected":"Auto-matched",children:[a.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),t.loadedFilaments.map(x=>a.jsxs("option",{value:x.globalTrayId,className:"bg-bambu-dark text-white",children:[x.label,": ",x.type," (",x.colorName,")"]},x.globalTrayId))]}),f==="match"?a.jsx(Wi,{className:"w-3 h-3 text-bambu-green"}):f==="type_only"?a.jsx("span",{title:"Same type, different color",children:a.jsx(jn,{className:"w-3 h-3 text-yellow-400"})}):a.jsx("span",{title:"Filament type not loaded",children:a.jsx(jn,{className:"w-3 h-3 text-orange-400"})})]},p))]})}function N8e({printers:t,selectedPrinterIds:e,onMultiSelect:n,isLoading:r=!1,allowMultiple:i=!1,showInactive:s=!1,printerMappingResults:o,filamentReqs:l,onAutoConfigurePrinter:c,onUpdatePrinterConfig:u,assignmentMode:d="printer",onAssignmentModeChange:f,targetModel:m,onTargetModelChange:p,slicedForModel:x}){const[b,y]=w.useState(!1),v=s?t:t.filter(j=>j.is_active),S=w.useMemo(()=>{if(d!=="printer"||!x||b)return v;const j=v.filter(G=>G.model===x);return j.length>0?j:v},[v,d,x,b]),N=v.length-S.length,C=w.useMemo(()=>{const j=v.map(G=>G.model).filter(G=>!!G);return[...new Set(j)].sort()},[v]),T=f&&p&&C.length>0,k=i&&e.length>1&&o&&l?.filaments&&l.filaments.length>0&&c&&u;if(r)return a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(ct,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(S.length===0)return a.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm mb-4",children:[a.jsx(Ii,{className:"w-4 h-4"}),"No ",s?"":"active ","printers available"]});const E=j=>{i?e.includes(j)?n(e.filter(G=>G!==j)):n([...e,j]):n([j])},D=()=>{n(S.map(j=>j.id))},A=()=>{n([])},R=(j,G,$)=>{$.stopPropagation(),!(!c||!u)&&(G?c(j):u(j,{useDefault:!0,manualMappings:{},autoConfigured:!1}))},F=j=>e.includes(j),O=e.length,H=j=>o?.find(G=>G.printerId===j);return a.jsxs("div",{className:"space-y-2 mb-6",children:[T&&a.jsxs("div",{className:"flex gap-2 mb-4",children:[a.jsxs("button",{type:"button",onClick:()=>{f("printer"),p(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${d==="printer"?"border-bambu-green bg-bambu-green/10 text-white":"border-bambu-dark-tertiary bg-bambu-dark text-bambu-gray hover:border-bambu-gray"}`,children:[a.jsx(Ir,{className:"w-4 h-4"}),a.jsx("span",{className:"text-sm",children:"Specific Printer"})]}),a.jsxs("button",{type:"button",onClick:()=>{f("model"),n([]);const j=x&&C.includes(x)?x:C[0];p(j)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${d==="model"?"border-bambu-green bg-bambu-green/10 text-white":"border-bambu-dark-tertiary bg-bambu-dark text-bambu-gray hover:border-bambu-gray"}`,children:[a.jsx(fg,{className:"w-4 h-4"}),a.jsxs("span",{className:"text-sm",children:["Any ",x||"Model"]})]})]}),d==="model"&&T&&m&&a.jsxs("p",{className:"text-xs text-bambu-gray mb-4",children:["Scheduler will assign to first available idle ",m," printer"]}),d==="printer"&&i&&S.length>1&&a.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray mb-2",children:[a.jsx("span",{children:O===0?"Select printers":`${O} printer${O!==1?"s":""} selected`}),a.jsxs("div",{className:"flex gap-2",children:[O<S.length&&a.jsx("button",{type:"button",onClick:D,className:"text-bambu-green hover:text-bambu-green/80 transition-colors",children:"Select all"}),O>0&&a.jsx("button",{type:"button",onClick:A,className:"text-bambu-gray hover:text-white transition-colors",children:"Clear"})]})]}),d==="printer"&&S.map(j=>{const G=F(j.id),$=H(j.id),q=$&&!$.config.useDefault;return a.jsxs("div",{children:[a.jsxs("button",{type:"button",onClick:()=>E(j.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${G?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"} ${j.is_active?"":"opacity-60"}`,children:[a.jsx("div",{className:`p-2 rounded-lg ${G?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:a.jsx(Ir,{className:`w-5 h-5 ${G?"text-bambu-green":"text-bambu-gray"}`})}),a.jsxs("div",{className:"text-left flex-1",children:[a.jsxs("p",{className:"text-white font-medium",children:[j.name,!j.is_active&&a.jsx("span",{className:"text-bambu-gray text-xs ml-2",children:"(inactive)"})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[j.model||"Unknown model"," • ",j.ip_address]})]}),i&&a.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${G?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:G&&a.jsx(Wi,{className:"w-3 h-3 text-white"})})]}),G&&k&&$&&a.jsxs("div",{className:"ml-4 mt-2 mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",onClick:Y=>Y.stopPropagation(),children:[a.jsx("input",{type:"checkbox",checked:q,onChange:Y=>R(j.id,Y.target.checked,Y),className:"w-3.5 h-3.5 rounded border-bambu-gray/30 bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),a.jsx("span",{className:"text-xs text-bambu-gray",children:"Custom mapping"})]}),a.jsxs("span",{className:`text-xs ml-2 ${$.matchStatus==="full"?"text-bambu-green":$.matchStatus==="partial"?"text-yellow-400":"text-orange-400"}`,children:["(",$.exactMatches,"/",$.totalSlots," matched)"]}),$.isLoading&&a.jsx(Pr,{className:"w-3 h-3 text-bambu-gray animate-spin"}),q&&a.jsxs("button",{type:"button",onClick:Y=>{Y.stopPropagation(),c(j.id)},className:"ml-auto flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",children:[a.jsx(xfe,{className:"w-3 h-3"}),"Auto"]})]}),q&&a.jsx(S8e,{printerResult:$,filamentReqs:l.filaments,onUpdateConfig:Y=>u(j.id,Y)})]})]},j.id)}),d==="printer"&&N>0&&!b&&a.jsxs("button",{type:"button",onClick:()=>y(!0),className:"text-xs text-bambu-gray hover:text-white transition-colors mt-2 flex items-center gap-1",children:[a.jsx(jn,{className:"w-3 h-3 text-yellow-400"}),N," other printer",N>1?"s":""," hidden (different model) —",a.jsx("span",{className:"underline",children:"show all"})]}),d==="printer"&&b&&x&&a.jsx("button",{type:"button",onClick:()=>y(!1),className:"text-xs text-bambu-gray hover:text-white transition-colors mt-2",children:a.jsxs("span",{className:"underline",children:["Show only ",x," printers"]})}),d==="printer"&&O===0&&a.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[a.jsx(Ii,{className:"w-3 h-3"}),"Select at least one printer"]}),d==="model"&&!m&&a.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[a.jsx(Ii,{className:"w-3 h-3"}),"Select a target printer model"]})]})}function M8e({plates:t,isMultiPlate:e,selectedPlate:n,onSelect:r}){return!e||t.length<=1?null:a.jsxs("div",{className:"mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(xs,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:"Select Plate to Print"}),!n&&a.jsxs("span",{className:"text-xs text-orange-400 flex items-center gap-1",children:[a.jsx(jn,{className:"w-3 h-3"}),"Selection required"]})]}),a.jsx("div",{className:"grid grid-cols-2 gap-2",children:t.map(i=>a.jsxs("button",{type:"button",onClick:()=>r(i.index),className:`flex items-center gap-2 p-2 rounded-lg border transition-colors text-left ${n===i.index?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[i.has_thumbnail&&i.thumbnail_url!=null?a.jsx("img",{src:i.thumbnail_url,alt:`Plate ${i.index}`,className:"w-10 h-10 rounded object-cover bg-bambu-dark-tertiary"}):a.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:a.jsx(xs,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm text-white font-medium truncate",children:i.name||`Plate ${i.index}`}),a.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[i.objects.length>0?i.objects.slice(0,3).join(", ")+(i.objects.length>3?"...":""):`${i.filaments.length} filament${i.filaments.length!==1?"s":""}`,i.print_time_seconds!=null?` • ${x8e(i.print_time_seconds)}`:""]})]}),n===i.index&&a.jsx(Wi,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},i.index))})]})}function E8e({printerId:t,filamentReqs:e,manualMappings:n,onManualMappingChange:r,defaultExpanded:i=!1}){const s=on(),[o,l]=w.useState(!1),[c,u]=w.useState(i),{data:d}=at({queryKey:["printer-status",t],queryFn:()=>ue.getPrinterStatus(t),enabled:!!t}),{loadedFilaments:f,filamentComparison:m,hasTypeMismatch:p,hasColorMismatch:x}=Mee(e,d,n);if(!(e?.filaments&&e.filaments.length>0)||!d)return null;const y=p?"#f97316":x?"#facc15":"#00ae42",v=(N,C)=>{if(N>0)if(C===""){const T={...n};delete T[N],r(T)}else r({...n,[N]:parseInt(C,10)})},S=async()=>{l(!0);try{await ue.refreshPrinterStatus(t),await new Promise(N=>setTimeout(N,500)),await s.refetchQueries({queryKey:["printer-status",t]})}finally{l(!1)}};return a.jsxs("div",{className:"mb-4",children:[a.jsxs("button",{type:"button",onClick:()=>u(!c),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[a.jsx(h3,{className:"w-4 h-4",fill:y,stroke:"none"}),a.jsx("span",{children:"Filament Mapping"}),p?a.jsx("span",{className:"text-xs text-orange-400",children:"(Type not found)"}):x?a.jsx("span",{className:"text-xs text-yellow-400",children:"(Color mismatch)"}):a.jsx("span",{className:"text-xs text-bambu-green",children:"(Ready)"}),c?a.jsx(xh,{className:"w-4 h-4 ml-auto"}):a.jsx(Xr,{className:"w-4 h-4 ml-auto"})]}),c&&a.jsxs("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Click to change slot assignment"}),a.jsxs("button",{type:"button",onClick:S,className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",disabled:o,children:[a.jsx(Pr,{className:`w-3 h-3 ${o?"animate-spin":""}`}),a.jsx("span",{children:"Re-read"})]})]}),m.map((N,C)=>a.jsxs("div",{className:"grid items-center gap-2 text-xs",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 16px"},children:[a.jsx("span",{title:`Required: ${N.type} - ${sx(N.color)}`,children:a.jsx(h3,{className:"w-3 h-3",fill:N.color,stroke:N.color})}),a.jsxs("span",{className:"text-white truncate",children:[N.type," ",a.jsxs("span",{className:"text-bambu-gray",children:["(",N.used_grams,"g)"]})]}),a.jsx("span",{className:"text-bambu-gray",children:"→"}),a.jsxs("select",{value:N.loaded?.globalTrayId??"",onChange:T=>v(N.slot_id||0,T.target.value),className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${N.status==="match"?"border-bambu-green/50 text-bambu-green":N.status==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${N.isManual?"ring-1 ring-blue-400/50":""}`,title:N.isManual?"Manually selected":"Auto-matched",children:[a.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),f.map(T=>a.jsxs("option",{value:T.globalTrayId,className:"bg-bambu-dark text-white",children:[T.label,": ",T.type," (",T.colorName,")"]},T.globalTrayId))]}),N.status==="match"?a.jsx(Wi,{className:"w-3 h-3 text-bambu-green"}):N.status==="type_only"?a.jsx("span",{title:"Same type, different color",children:a.jsx(jn,{className:"w-3 h-3 text-yellow-400"})}):a.jsx("span",{title:"Filament type not loaded",children:a.jsx(jn,{className:"w-3 h-3 text-orange-400"})})]},C)),p&&a.jsx("p",{className:"text-xs text-orange-400 mt-2",children:"Required filament type not found in printer."})]})]})}const C8e=[{key:"bed_levelling",label:"Bed Levelling",desc:"Auto-level bed before print"},{key:"flow_cali",label:"Flow Calibration",desc:"Calibrate extrusion flow"},{key:"vibration_cali",label:"Vibration Calibration",desc:"Reduce ringing artifacts"},{key:"layer_inspect",label:"First Layer Inspection",desc:"AI inspection of first layer"},{key:"timelapse",label:"Timelapse",desc:"Record timelapse video"}];function T8e({options:t,onChange:e,defaultExpanded:n=!1}){const[r,i]=w.useState(n),s=o=>{e({...t,[o]:!t[o]})};return a.jsxs("div",{className:"mb-4",children:[a.jsxs("button",{type:"button",onClick:()=>i(!r),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[a.jsx(bN,{className:"w-4 h-4"}),a.jsx("span",{children:"Print Options"}),r?a.jsx(xh,{className:"w-4 h-4 ml-auto"}):a.jsx(Xr,{className:"w-4 h-4 ml-auto"})]}),r&&a.jsx("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:C8e.map(({key:o,label:l,desc:c})=>a.jsxs("label",{className:"flex items-center justify-between cursor-pointer group",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-white",children:l}),a.jsx("p",{className:"text-xs text-bambu-gray",children:c})]}),a.jsx("div",{className:`relative w-10 h-5 rounded-full transition-colors ${t[o]?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,onClick:()=>s(o),children:a.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white transition-transform ${t[o]?"translate-x-5":"translate-x-0.5"}`})})]},o))})]})}function A8e({options:t,onChange:e}){const n=r=>{e({...t,scheduleType:r})};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${t.scheduleType==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>n("asap"),children:[a.jsx(Qn,{className:"w-4 h-4"}),"ASAP"]}),a.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${t.scheduleType==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>n("scheduled"),children:[a.jsx(ti,{className:"w-4 h-4"}),"Scheduled"]}),a.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${t.scheduleType==="manual"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>n("manual"),children:[a.jsx(SW,{className:"w-4 h-4"}),"Queue Only"]})]})]}),t.scheduleType==="scheduled"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),a.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:t.scheduledTime,onChange:r=>e({...t,scheduledTime:r.target.value}),min:b8e(),required:!0})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"checkbox",id:"requirePrevious",checked:t.requirePreviousSuccess,onChange:r=>e({...t,requirePreviousSuccess:r.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:t.autoOffAfter,onChange:r=>e({...t,autoOffAfter:r.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[a.jsx(Vu,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:t.scheduleType==="asap"?"Print will start as soon as the printer is idle.":t.scheduleType==="scheduled"?"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available.":"Print will be staged but won't start automatically. Use the Start button to release it to the queue."})]})}const Zp={bed_levelling:!0,flow_cali:!1,vibration_cali:!0,layer_inspect:!1,timelapse:!1},k8e={scheduleType:"asap",scheduledTime:"",requirePreviousSuccess:!1,autoOffAfter:!1};function jh({mode:t,archiveId:e,libraryFileId:n,archiveName:r,queueItem:i,onClose:s,onSuccess:o}){const l=on(),{showToast:c}=Vn(),u=!!n&&!e,[d,f]=w.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[m,p]=w.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[x,b]=w.useState(()=>t==="edit-queue-item"&&i?{bed_levelling:i.bed_levelling??Zp.bed_levelling,flow_cali:i.flow_cali??Zp.flow_cali,vibration_cali:i.vibration_cali??Zp.vibration_cali,layer_inspect:i.layer_inspect??Zp.layer_inspect,timelapse:i.timelapse??Zp.timelapse}:Zp),[y,v]=w.useState(()=>{if(t==="edit-queue-item"&&i){let De="asap";i.manual_start?De="manual":i.scheduled_time&&!PG(i.scheduled_time)&&(De="scheduled");let Le="";return i.scheduled_time&&!PG(i.scheduled_time)&&(Le=new Date(i.scheduled_time).toISOString().slice(0,16)),{scheduleType:De,scheduledTime:Le,requirePreviousSuccess:i.require_previous_success,autoOffAfter:i.auto_off_after}}return k8e}),[S,N]=w.useState(()=>{if(t==="edit-queue-item"&&i?.ams_mapping&&Array.isArray(i.ams_mapping)){const De={};return i.ams_mapping.forEach((Le,$e)=>{Le!==-1&&(De[$e+1]=Le)}),De}return{}}),[C,T]=w.useState({}),[k,E]=w.useState(()=>t==="edit-queue-item"&&i?.target_model?"model":"printer"),[D,A]=w.useState(()=>t==="edit-queue-item"&&i?.target_model?i.target_model:null),[R]=w.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[F]=w.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[O,H]=w.useState(!1),[j,G]=w.useState({current:0,total:0}),[$,q]=w.useState(new Set),Y=d.length,Z=d.length>0?d[0]:null,{data:oe}=at({queryKey:["settings"],queryFn:ue.getSettings}),{data:B,isLoading:W}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:se}=at({queryKey:["archive",e],queryFn:()=>ue.getArchive(e),enabled:!!e&&!u}),ne=se?.sliced_for_model||null,{data:ce,isError:fe}=at({queryKey:["archive-plates",e],queryFn:()=>ue.getArchivePlates(e),enabled:!!e&&!u,retry:!1}),{data:ye}=at({queryKey:["library-file-plates",n],queryFn:()=>ue.getLibraryFilePlates(n),enabled:u&&!!n}),ge=u?ye:ce,{data:xe,isError:Pe}=at({queryKey:["archive-filaments",e,m],queryFn:()=>ue.getArchiveFilamentRequirements(e,m??void 0),enabled:!!e&&!u&&(m!==null||!ge?.is_multi_plate),retry:!1}),{data:Ue}=at({queryKey:["library-file-filaments",n,m],queryFn:()=>ue.getLibraryFileFilamentRequirements(n,m??void 0),enabled:u&&!!n&&(m!==null||!ge?.is_multi_plate)}),be=!u&&(fe||Pe),it=u?Ue:xe,{data:U}=at({queryKey:["printer-status",Z],queryFn:()=>ue.getPrinterStatus(Z),enabled:!!Z}),{amsMapping:K}=Mee(it,U,S),J=w8e(d,B,it,S,C,T);w.useEffect(()=>{ge?.plates?.length===1&&!m&&p(ge.plates[0].index)},[ge,m]),w.useEffect(()=>{if(t==="edit-queue-item")return;const De=B?.filter(Le=>Le.is_active)||[];De.length===1&&d.length===0&&f([De[0].id])},[t,B,d.length]),w.useEffect(()=>{t==="edit-queue-item"?(JSON.stringify(d.sort())!==JSON.stringify(R.sort())||m!==F)&&(N({}),T({}),q(new Set)):(N({}),T({}),q(new Set))},[t,d,m,R,F]),w.useEffect(()=>{if(!oe?.per_printer_mapping_expanded||d.length<=1)return;const De=d.filter(Le=>{if($.has(Le))return!1;const $e=J.printerResults.find(Ze=>Ze.printerId===Le);return $e&&$e.status&&!$e.isLoading});De.length>0&&(q(Le=>{const $e=new Set(Le);return De.forEach(Ze=>$e.add(Ze)),$e}),De.forEach(Le=>{J.autoConfigurePrinter(Le)}))},[oe?.per_printer_mapping_expanded,d,$,J]),w.useEffect(()=>{const De=Le=>{Le.key==="Escape"&&!O&&s()};return window.addEventListener("keydown",De),()=>window.removeEventListener("keydown",De)},[s,O]);const Q=ge?.is_multi_plate??!1,z=ge?.plates??[],re=mt({mutationFn:De=>ue.addToQueue(De)}),Ee=mt({mutationFn:De=>ue.updateQueueItem(i.id,De),onSuccess:()=>{l.invalidateQueries({queryKey:["queue"]}),c("Queue item updated"),o?.(),s()},onError:De=>{c(De.message||"Failed to update queue item","error")}}),_e=async De=>{if(De?.preventDefault(),k==="printer"&&d.length===0){c("Please select at least one printer","error");return}if(k==="model"&&!D){c("Please select a target printer model","error");return}H(!0);const Le=k==="model"?1:d.length;G({current:0,total:Le});const $e={success:0,failed:0,errors:[]},Ze=ae=>{if(d.length>1){const He=C[ae];if(He&&!He.useDefault)return J.getFinalMapping(ae)}return K},Ie=ae=>({printer_id:k==="printer"?ae:null,target_model:k==="model"?D:null,archive_id:u?void 0:e,library_file_id:u?n:void 0,require_previous_success:y.requirePreviousSuccess,auto_off_after:y.autoOffAfter,manual_start:y.scheduleType==="manual",ams_mapping:ae?Ze(ae):void 0,plate_id:m,scheduled_time:y.scheduleType==="scheduled"&&y.scheduledTime?new Date(y.scheduledTime).toISOString():void 0,...x});if(k==="model"){G({current:1,total:1});try{if(t==="reprint"){c("Model-based assignment only works with queue mode","error"),H(!1);return}else if(t==="edit-queue-item"){const ae={printer_id:null,target_model:D,require_previous_success:y.requirePreviousSuccess,auto_off_after:y.autoOffAfter,manual_start:y.scheduleType==="manual",ams_mapping:void 0,plate_id:m,scheduled_time:y.scheduleType==="scheduled"&&y.scheduledTime?new Date(y.scheduledTime).toISOString():null,...x};await Ee.mutateAsync(ae)}else await re.mutateAsync(Ie(null));$e.success++}catch(ae){$e.failed++,$e.errors.push(ae.message)}}else for(let ae=0;ae<d.length;ae++){const He=d[ae];G({current:ae+1,total:d.length});try{if(t==="reprint"){const Se=Ze(He);u?await ue.printLibraryFile(n,He,{ams_mapping:Se,...x}):await ue.reprintArchive(e,He,{plate_id:m??void 0,ams_mapping:Se,...x})}else if(t==="edit-queue-item"&&ae===0){const Se=Ze(He),Be={printer_id:He,target_model:null,require_previous_success:y.requirePreviousSuccess,auto_off_after:y.autoOffAfter,manual_start:y.scheduleType==="manual",ams_mapping:Se,plate_id:m,scheduled_time:y.scheduleType==="scheduled"&&y.scheduledTime?new Date(y.scheduledTime).toISOString():null,...x};await Ee.mutateAsync(Be)}else await re.mutateAsync(Ie(He));$e.success++}catch(Se){$e.failed++;const Be=B?.find(ft=>ft.id===He)?.name||`Printer ${He}`;$e.errors.push(`${Be}: ${Se.message}`)}}if(H(!1),$e.failed===0){if(k==="model")c(t==="edit-queue-item"?"Queue item updated":`Queued for any ${D}`);else{const ae=t==="reprint"?"sent to":t==="edit-queue-item"?"updated/queued for":"queued for";$e.success===1?c(t==="edit-queue-item"?"Queue item updated":`Print ${ae} printer`):c(`Print ${ae} ${$e.success} printers`)}l.invalidateQueries({queryKey:["queue"]}),o?.(),s()}else $e.success===0?c(`Failed: ${$e.errors[0]}`,"error"):(c(`${$e.success} succeeded, ${$e.failed} failed`,"error"),l.invalidateQueries({queryKey:["queue"]}))},Te=O||Ee.isPending,V=w.useMemo(()=>!(Te||k==="printer"&&d.length===0||k==="model"&&!D||k==="model"&&t==="reprint"||!u&&Q&&!m),[d.length,k,D,t,Q,m,Te,u]),X=(()=>{const De=d.length;return t==="reprint"?{title:u?"Print":"Re-print",icon:Ir,submitText:De>1?`Print to ${De} Printers`:"Print",submitIcon:Ir,loadingText:j.total>1?`Sending ${j.current}/${j.total}...`:"Sending..."}:t==="add-to-queue"?{title:"Schedule Print",icon:ti,submitText:De>1?`Queue to ${De} Printers`:"Add to Queue",submitIcon:ti,loadingText:j.total>1?`Adding ${j.current}/${j.total}...`:"Adding..."}:{title:"Edit Queue Item",icon:Ki,submitText:"Save",submitIcon:Ki,loadingText:j.total>1?`Saving ${j.current}/${j.total}...`:"Saving..."}})(),te=X.icon,Me=X.submitIcon,ie=Z&&(u||(Q?m!==null:!0));return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:O?void 0:s,children:a.jsx(wt,{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto",onClick:De=>De.stopPropagation(),children:a.jsxs(St,{className:t==="reprint"?"":"p-0",children:[a.jsxs("div",{className:`flex items-center justify-between ${t==="reprint"?"mb-4":"p-4 border-b border-bambu-dark-tertiary"}`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(te,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:X.title})]}),a.jsx(Ne,{variant:"ghost",size:"sm",onClick:s,disabled:O,children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:_e,className:t==="reprint"?"":"p-4 space-y-4",children:[a.jsx("p",{className:`text-sm text-bambu-gray ${t==="reprint"?"mb-4":""}`,children:t==="reprint"?a.jsxs(a.Fragment,{children:["Send ",a.jsx("span",{className:"text-white",children:r})," to printer(s)"]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"block text-bambu-gray mb-1",children:"Print Job"}),a.jsx("span",{className:"text-white font-medium truncate block",children:r})]})}),a.jsx(M8e,{plates:z,isMultiPlate:Q,selectedPlate:m,onSelect:p}),a.jsx(N8e,{printers:B||[],selectedPrinterIds:d,onMultiSelect:f,isLoading:W,allowMultiple:!0,showInactive:t==="edit-queue-item",printerMappingResults:J.printerResults,filamentReqs:it,onAutoConfigurePrinter:J.autoConfigurePrinter,onUpdatePrinterConfig:J.updatePrinterConfig,assignmentMode:t==="reprint"?"printer":k,onAssignmentModeChange:t!=="reprint"?E:void 0,targetModel:D,onTargetModelChange:t!=="reprint"?A:void 0,slicedForModel:ne}),ne&&k==="printer"&&d.length===1&&(()=>{const De=B?.find(Le=>Le.id===d[0]);return De&&De.model&&ne!==De.model?a.jsxs("div",{className:"p-3 mb-2 bg-yellow-500/10 border border-yellow-500/30 rounded-lg flex items-center gap-2",children:[a.jsx(jn,{className:"w-4 h-4 text-yellow-400 flex-shrink-0"}),a.jsxs("span",{className:"text-sm text-yellow-400",children:["File was sliced for ",ne,", but printing on ",De.model]})]}):null})(),be&&a.jsxs("div",{className:"flex items-start gap-2 p-3 mb-2 bg-orange-500/10 border border-orange-500/30 rounded-lg text-sm",children:[a.jsx(Ii,{className:"w-4 h-4 text-orange-400 mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-orange-400",children:"Archive data unavailable. The source file may have been deleted. Filament mapping is disabled."})]}),ie&&!be&&d.length===1&&a.jsx(E8e,{printerId:Z,filamentReqs:it,manualMappings:S,onManualMappingChange:N,defaultExpanded:oe?.per_printer_mapping_expanded??!1}),(t==="reprint"||Y>0||k==="model"&&D)&&a.jsx(T8e,{options:x,onChange:b}),t!=="reprint"&&a.jsx(A8e,{options:y,onChange:v}),Ee.isError&&a.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:Ee.error?.message||"Failed to complete operation"}),a.jsxs("div",{className:`flex gap-3 ${t==="reprint"?"":"pt-2"}`,children:[a.jsx(Ne,{type:"button",variant:"secondary",onClick:s,className:"flex-1",disabled:O,children:"Cancel"}),a.jsx(Ne,{type:"submit",disabled:!V,className:"flex-1",children:Te?a.jsxs(a.Fragment,{children:[a.jsx(ct,{className:"w-4 h-4 animate-spin"}),X.loadingText]}):a.jsxs(a.Fragment,{children:[a.jsx(Me,{className:"w-4 h-4"}),X.submitText]})})]})]})]})})})}function j8e({onClose:t,initialFiles:e}){const n=on(),{showToast:r}=Vn(),i=w.useRef(null),[s,o]=w.useState(()=>e?.filter(C=>C.name.endsWith(".3mf")).map(C=>({file:C,status:"pending"}))||[]),[l,c]=w.useState(!1),[u,d]=w.useState(null);w.useEffect(()=>{const C=T=>{T.key==="Escape"&&t()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[t]);const f=mt({mutationFn:C=>ue.uploadArchivesBulk(C),onSuccess:C=>{d(C),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),o(T=>T.map(k=>{const E=C.results.find(A=>A.filename===k.file.name),D=C.errors.find(A=>A.filename===k.file.name);return E?{...k,status:"success",archiveId:E.id}:D?{...k,status:"error",error:D.error}:k})),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:()=>{o(C=>C.map(T=>({...T,status:"error",error:"Upload failed"}))),r("Upload failed","error")}}),m=w.useCallback(C=>{C.preventDefault(),c(!0)},[]),p=w.useCallback(C=>{C.preventDefault(),c(!1)},[]),x=w.useCallback(C=>{C.preventDefault(),c(!1);const T=Array.from(C.dataTransfer.files).filter(k=>k.name.endsWith(".3mf"));T.length>0&&o(k=>[...k,...T.map(E=>({file:E,status:"pending"}))])},[]),b=w.useCallback(C=>{const T=Array.from(C.target.files||[]).filter(k=>k.name.endsWith(".3mf"));T.length>0&&o(k=>[...k,...T.map(E=>({file:E,status:"pending"}))]),i.current&&(i.current.value="")},[]),y=w.useCallback(C=>{o(T=>T.filter((k,E)=>E!==C))},[]),v=()=>{if(s.length===0)return;const C=s.filter(T=>T.status==="pending");C.length!==0&&(o(T=>T.map(k=>k.status==="pending"?{...k,status:"uploading"}:k)),f.mutate(C.map(T=>T.file)))},S=s.filter(C=>C.status==="pending").length,N=f.isPending;return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(wt,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:a.jsxs(St,{className:"p-0 flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:"Upload 3MF Files"}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"p-4",children:a.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${l?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:m,onDragLeave:p,onDrop:x,children:[a.jsx(Oa,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),a.jsx("p",{className:"text-white mb-2",children:"Drag & drop .3mf files here"}),a.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:"or"}),a.jsx(Ne,{variant:"secondary",onClick:()=>i.current?.click(),disabled:N,children:"Browse Files"}),a.jsx("input",{ref:i,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:b})]})}),a.jsx("div",{className:"px-4 pb-4",children:a.jsx("p",{className:"text-xs text-bambu-gray",children:"The printer model will be automatically extracted from the 3MF file metadata."})}),s.length>0&&a.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:a.jsx("div",{className:"space-y-2",children:s.map((C,T)=>a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[a.jsx(uN,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"flex-1 text-white text-sm truncate",children:C.file.name}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[(C.file.size/(1024*1024)).toFixed(1)," MB"]}),C.status==="pending"&&a.jsx("button",{onClick:()=>y(T),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:N,children:a.jsx(Dt,{className:"w-4 h-4"})}),C.status==="uploading"&&a.jsx(ct,{className:"w-4 h-4 text-bambu-green animate-spin"}),C.status==="success"&&a.jsx(Tr,{className:"w-4 h-4 text-bambu-green"}),C.status==="error"&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs text-red-400",children:C.error}),a.jsx(Ii,{className:"w-4 h-4 text-red-400"})]})]},`${C.file.name}-${T}`))})}),u&&a.jsx("div",{className:"px-4 pb-4",children:a.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:a.jsxs("p",{className:"text-sm text-white",children:[a.jsx("span",{className:"text-bambu-green",children:u.uploaded})," uploaded",u.failed>0&&a.jsxs(a.Fragment,{children:[", ",a.jsx("span",{className:"text-red-400",children:u.failed})," failed"]})]})})}),a.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Ne,{variant:"secondary",onClick:t,className:"flex-1",children:u?"Close":"Cancel"}),!u&&a.jsx(Ne,{onClick:v,disabled:S===0||N,className:"flex-1",children:N?a.jsxs(a.Fragment,{children:[a.jsx(ct,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Oa,{className:"w-4 h-4"}),"Upload ",S>0&&`(${S})`]})})]})]})})})}const P8e=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"],R8e=[{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"aborted",label:"Cancelled"},{value:"printing",label:"Printing"}];function Eee({archive:t,onClose:e,existingTags:n=[]}){w.useEffect(()=>{const ge=xe=>{xe.key==="Escape"&&e()};return window.addEventListener("keydown",ge),()=>window.removeEventListener("keydown",ge)},[e]);const r=on(),[i,s]=w.useState(t.print_name||""),[o,l]=w.useState(t.printer_id),[c,u]=w.useState(t.project_id??null),[d,f]=w.useState(t.notes||""),[m,p]=w.useState(t.tags||""),[x,b]=w.useState(t.failure_reason||""),[y,v]=w.useState(t.status),[S,N]=w.useState(t.quantity??1),[C,T]=w.useState(t.photos||[]),[k,E]=w.useState(t.external_url||""),[D,A]=w.useState(!1),[R,F]=w.useState(!1),O=w.useRef(null),H=w.useRef(null),j=w.useRef(null),{data:G}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:$}=at({queryKey:["projects"],queryFn:()=>ue.getProjects()}),{data:q}=at({queryKey:["tags"],queryFn:ue.getTags,enabled:n.length===0}),Y=n.length>0?n:q?.map(ge=>ge.name)||[],Z=m.split(",").map(ge=>ge.trim()).filter(Boolean),oe=m.includes(",")?m.substring(m.lastIndexOf(",")+1).trim().toLowerCase():m.trim().toLowerCase(),B=Y.filter(ge=>!Z.includes(ge)&&(oe===""||ge.toLowerCase().includes(oe))),W=ge=>{let xe;if(oe&&!Y.includes(oe)?xe=m.includes(",")?m.substring(0,m.lastIndexOf(",")).split(",").map(Pe=>Pe.trim()).filter(Boolean):[]:xe=Z,!xe.includes(ge)){const Pe=[...xe,ge].join(", ");p(Pe)}j.current!==null&&clearTimeout(j.current),O.current?.focus()},se=ge=>{const xe=Z.filter(Pe=>Pe!==ge).join(", ");p(xe)},ne=mt({mutationFn:ge=>ue.updateArchive(t.id,ge),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["projects"]}),e()}}),ce=async ge=>{const xe=ge.target.files?.[0];if(xe){A(!0);try{const Pe=await ue.uploadArchivePhoto(t.id,xe);T(Pe.photos),r.invalidateQueries({queryKey:["archives"]})}catch(Pe){console.error("Failed to upload photo:",Pe)}finally{A(!1),H.current&&(H.current.value="")}}},fe=async ge=>{try{const xe=await ue.deleteArchivePhoto(t.id,ge);T(xe.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(xe){console.error("Failed to delete photo:",xe)}},ye=ge=>{ge.preventDefault();const xe={print_name:i||void 0,printer_id:o,project_id:c,notes:d||void 0,tags:m||void 0,quantity:S,external_url:k||null};y!==t.status&&(xe.status=y),y==="failed"||y==="aborted"?xe.failure_reason=x||void 0:(t.status==="failed"||t.status==="aborted")&&(xe.failure_reason=null),ne.mutate(xe)};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:a.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:ge=>ge.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Edit Archive"}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:ye,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),a.jsx("input",{type:"text",value:i,onChange:ge=>s(ge.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),a.jsxs("select",{value:o??"",onChange:ge=>l(ge.target.value?Number(ge.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:[a.jsx("option",{value:"",children:"No printer"}),G?.map(ge=>a.jsx("option",{value:ge.id,children:ge.name},ge.id))]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(Qa,{className:"w-4 h-4 inline mr-1"}),"Project"]}),a.jsxs("select",{value:c??"",onChange:ge=>u(ge.target.value?Number(ge.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:[a.jsx("option",{value:"",children:"No project"}),$?.map(ge=>a.jsx("option",{value:ge.id,children:ge.name},ge.id))]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(sde,{className:"w-4 h-4 inline mr-1"}),"Items Printed"]}),a.jsx("input",{type:"number",min:1,value:S,onChange:ge=>N(Math.max(1,parseInt(ge.target.value)||1)),className:"w-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:"1"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Number of items produced in this print job"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),a.jsx("textarea",{value:d,onChange:ge=>f(ge.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..."})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(Fy,{className:"w-4 h-4 inline mr-1"}),"External Link"]}),a.jsx("input",{type:"url",value:k,onChange:ge=>E(ge.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:"https://printables.com/model/..."}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Link to Printables, Thingiverse, or other source"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),Z.length>0&&a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:Z.map(ge=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[a.jsx(yh,{className:"w-3 h-3"}),ge,a.jsx("button",{type:"button",onClick:()=>se(ge),className:"ml-0.5 text-bambu-gray hover:text-white",children:a.jsx(Dt,{className:"w-3 h-3"})})]},ge))}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{ref:O,type:"text",value:m,onChange:ge=>p(ge.target.value),onFocus:()=>{j.current!==null&&clearTimeout(j.current),F(!0)},onBlur:()=>{j.current=window.setTimeout(()=>F(!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:Z.length>0?"Add more tags...":"Add tags..."}),R&&B.length>0&&a.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:[a.jsxs("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:[oe?`Matching "${oe}"`:"Existing tags"," (click to add)"]}),a.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:B.map(ge=>a.jsx("button",{type:"button",onClick:()=>W(ge),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:ge},ge))})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Status"}),a.jsx("select",{value:y,onChange:ge=>{v(ge.target.value),ge.target.value==="completed"&&b("")},className:"w-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:R8e.map(ge=>a.jsx("option",{value:ge.value,children:ge.label},ge.value))})]}),(y==="failed"||y==="aborted")&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Failure Reason"}),a.jsxs("select",{value:x,onChange:ge=>b(ge.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:[a.jsx("option",{value:"",children:"Select reason..."}),P8e.map(ge=>a.jsx("option",{value:ge,children:ge},ge))]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(Ug,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),a.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[C.map(ge=>a.jsxs("div",{className:"relative group",children:[a.jsx("img",{src:ue.getArchivePhotoUrl(t.id,ge),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),a.jsx("button",{type:"button",onClick:()=>fe(ge),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx(an,{className:"w-3 h-3 text-white"})})]},ge)),a.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:[a.jsx("input",{ref:H,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:ce,className:"hidden",disabled:D}),D?a.jsx(ct,{className:"w-6 h-6 text-bambu-gray animate-spin"}):a.jsx(lr,{className:"w-6 h-6 text-bambu-gray"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Click + to add photos of your printed result"})]}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Ne,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Ne,{type:"submit",disabled:ne.isPending,className:"flex-1",children:[a.jsx(ms,{className:"w-4 h-4"}),ne.isPending?"Saving...":"Save"]})]})]})]})})}function Cee({x:t,y:e,items:n,onClose:r}){const i=w.useRef(null),[s,o]=w.useState(null),l=w.useRef(null),[c,u]=w.useState({x:t,y:e,visible:!1}),[d,f]=w.useState(!1),[m,p]=w.useState({});w.useEffect(()=>{const y=N=>{i.current&&!i.current.contains(N.target)&&r()},v=N=>{N.key==="Escape"&&r()},S=()=>{r()};return document.addEventListener("mousedown",y),document.addEventListener("keydown",v),document.addEventListener("scroll",S,!0),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",v),document.removeEventListener("scroll",S,!0),l.current&&clearTimeout(l.current)}},[r]),w.useLayoutEffect(()=>{if(i.current){i.current.style.visibility="hidden",i.current.style.display="block";const y=i.current.getBoundingClientRect(),v=window.innerWidth,S=window.innerHeight,N=8;let C=t,T=e;t+y.width>v-N&&(C=Math.max(N,v-y.width-N)),C<N&&(C=N),e+y.height>S-N&&(T=Math.max(N,S-y.height-N)),T<N&&(T=N);const k=180,E=v-C-y.width,D=C;f(E<k&&D>k),u({x:C,y:T,visible:!0})}},[t,e]);const x=(y,v)=>{l.current&&(clearTimeout(l.current),l.current=null);const S=v.getBoundingClientRect(),N=window.innerHeight,C=300,E=N-S.top-8<C&&S.top>C;p(D=>({...D,[y]:E?"bottom":"top"})),o(y)},b=()=>{l.current=window.setTimeout(()=>{o(null)},150)};return a.jsx("div",{ref:i,className:"fixed z-50 min-w-[180px] max-w-[280px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1",style:{left:c.x,top:c.y,visibility:c.visible?"visible":"hidden"},children:n.map((y,v)=>{if(y.divider)return a.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},v);const S=y.submenu&&y.submenu.length>0;return a.jsxs("div",{className:"relative",onMouseEnter:N=>S&&x(v,N.currentTarget),onMouseLeave:()=>S&&b(),children:[a.jsxs("button",{onMouseEnter:N=>S&&x(v,N.currentTarget.parentElement),onClick:()=>{S?o(s===v?null:v):y.disabled||(y.onClick(),r())},disabled:y.disabled,title:y.title,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${y.disabled?"text-bambu-gray cursor-not-allowed":y.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"} ${S&&s===v?"bg-bambu-dark-tertiary":""}`,children:[y.icon&&a.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:y.icon}),a.jsx("span",{className:"flex-1",children:y.label}),S&&a.jsx(vs,{className:"w-4 h-4 text-bambu-gray"})]}),S&&s===v&&a.jsx("div",{className:`absolute min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 overflow-hidden max-h-[300px] overflow-y-auto z-[60] ${d?"right-full mr-1":"left-full ml-1"} ${m[v]==="bottom"?"bottom-0":"top-0"}`,onMouseEnter:()=>{l.current&&(clearTimeout(l.current),l.current=null)},onMouseLeave:()=>b(),children:y.submenu.map((N,C)=>a.jsxs("button",{onClick:()=>{N.disabled||(N.onClick(),r())},disabled:N.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${N.disabled?"text-bambu-gray cursor-not-allowed":N.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[N.icon&&a.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:N.icon}),N.label]},C))})]},v)})})}function D8e({selectedIds:t,existingTags:e,onClose:n}){const r=on(),{showToast:i}=Vn(),[s,o]=w.useState(""),[l,c]=w.useState(new Set),[u,d]=w.useState("add");w.useEffect(()=>{const b=y=>{y.key==="Escape"&&n()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[n]);const f=mt({mutationFn:async()=>{const b=Array.from(l);let y=0;for(const v of t)try{const S=await ue.getArchive(v),N=S.tags?S.tags.split(",").map(T=>T.trim()).filter(Boolean):[];let C;u==="add"?C=[...new Set([...N,...b])]:C=N.filter(T=>!l.has(T)),await ue.updateArchive(v,{tags:C.join(", ")}),y++}catch(S){throw console.error(`Failed to update archive ${v}:`,S),new Error(`Failed on archive ${v}: ${S instanceof Error?S.message:"Unknown error"}`)}return{count:y,mode:u,tags:b}},onSuccess:({count:b,mode:y,tags:v})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${y==="add"?"Added":"Removed"} ${v.length} tag${v.length!==1?"s":""} ${y==="add"?"to":"from"} ${b} archive${b!==1?"s":""}`),n()},onError:b=>{i(b.message||"Failed to update tags","error")}}),m=b=>{c(y=>{const v=new Set(y);return v.has(b)?v.delete(b):v.add(b),v})},p=()=>{s.trim()&&!l.has(s.trim())&&(c(b=>new Set([...b,s.trim()])),o(""))},x=b=>{b.key==="Enter"&&(b.preventDefault(),p())};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(wt,{className:"w-full max-w-md",children:a.jsxs(St,{className:"p-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(yh,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-xl font-semibold text-white",children:u==="add"?"Add Tags":"Remove Tags"})]}),a.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsxs("p",{className:"text-sm text-bambu-gray",children:[u==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ne,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),a.jsx(Ne,{size:"sm",variant:u==="remove"?"primary":"secondary",onClick:()=>d("remove"),children:"Remove Tags"})]}),u==="add"&&a.jsxs("div",{className:"flex gap-2",children:[a.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:b=>o(b.target.value),onKeyDown:x}),a.jsx(Ne,{size:"sm",variant:"secondary",onClick:p,disabled:!s.trim(),children:a.jsx(lr,{className:"w-4 h-4"})})]}),e.length>0&&a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(b=>a.jsx("button",{onClick:()=>m(b),className:`px-2 py-1 rounded text-sm transition-colors ${l.has(b)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:b},b))})]}),l.size>0&&a.jsxs("div",{children:[a.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",u==="add"?"add":"remove",":"]}),a.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(l).map(b=>a.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:[b,a.jsx("button",{onClick:()=>m(b),className:"hover:opacity-70",children:a.jsx(Dt,{className:"w-3 h-3"})})]},b))})]})]}),a.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Ne,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),a.jsx(Ne,{onClick:()=>f.mutate(),disabled:l.size===0||f.isPending,className:"flex-1",children:f.isPending?a.jsxs(a.Fragment,{children:[a.jsx(ct,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(yh,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function O8e({selectedIds:t,onClose:e}){const n=on(),{showToast:r}=Vn(),{data:i,isLoading:s}=at({queryKey:["projects"],queryFn:()=>ue.getProjects()});w.useEffect(()=>{const d=f=>{f.key==="Escape"&&e()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[e]);const o=()=>{n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["projects"]}),n.invalidateQueries({queryKey:["project"]}),n.invalidateQueries({queryKey:["project-archives"]})},l=mt({mutationFn:async d=>(await ue.addArchivesToProject(d,t),d),onSuccess:d=>{const f=i?.find(m=>m.id===d);o(),r(`Added ${t.length} archive${t.length!==1?"s":""} to "${f?.name}"`),e()},onError:()=>{r("Failed to assign project","error")}}),c=mt({mutationFn:async()=>{for(const d of t)await ue.updateArchive(d,{project_id:null});return t.length},onSuccess:d=>{o(),r(`Removed ${d} archive${d!==1?"s":""} from project`),e()},onError:()=>{r("Failed to remove from project","error")}}),u=l.isPending||c.isPending;return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(wt,{className:"w-full max-w-md max-h-[80vh] flex flex-col",children:a.jsxs(St,{className:"p-0 flex flex-col min-h-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Qa,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-xl font-semibold text-white",children:"Assign to Project"})]}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",disabled:u,children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-3 overflow-y-auto min-h-0",children:[a.jsxs("p",{className:"text-sm text-bambu-gray",children:["Assign ",t.length," selected archive",t.length!==1?"s":""," to a project"]}),s?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(ct,{className:"w-6 h-6 animate-spin text-bambu-gray"})}):a.jsxs("div",{className:"space-y-2",children:[a.jsxs("button",{onClick:()=>c.mutate(),disabled:u,className:"w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary transition-colors text-left disabled:opacity-50",children:[a.jsx("div",{className:"w-8 h-8 rounded-full bg-red-500/20 flex items-center justify-center shrink-0",children:a.jsx(qi,{className:"w-4 h-4 text-red-400"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-white font-medium",children:"Remove from project"}),a.jsx("p",{className:"text-sm text-bambu-gray truncate",children:"Clear project assignment"})]}),c.isPending&&a.jsx(ct,{className:"w-4 h-4 animate-spin text-bambu-gray shrink-0"})]}),i&&i.length>0&&a.jsxs("div",{className:"flex items-center gap-2 py-2",children:[a.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary"}),a.jsx("span",{className:"text-xs text-bambu-gray",children:"or assign to"}),a.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary"})]}),i?.map(d=>a.jsxs("button",{onClick:()=>l.mutate(d.id),disabled:u,className:"w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary transition-colors text-left disabled:opacity-50",children:[a.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center shrink-0",style:{backgroundColor:d.color?`${d.color}20`:"rgb(var(--bambu-green) / 0.2)"},children:a.jsx(Qa,{className:"w-4 h-4",style:{color:d.color||"rgb(var(--bambu-green))"}})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-white font-medium truncate",children:d.name}),a.jsxs("p",{className:"text-sm text-bambu-gray truncate",children:[d.archive_count," archive",d.archive_count!==1?"s":"",d.status&&` • ${d.status}`]})]}),l.isPending&&l.variables===d.id&&a.jsx(ct,{className:"w-4 h-4 animate-spin text-bambu-gray shrink-0"})]},d.id)),(!i||i.length===0)&&a.jsx("p",{className:"text-center text-bambu-gray py-4",children:"No projects yet. Create one from the Projects page."})]})]}),a.jsx("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary shrink-0",children:a.jsx(Ne,{variant:"secondary",onClick:e,className:"flex-1",disabled:u,children:"Cancel"})})]})})})}function L8e(t,e){return new Date(t,e+1,0).getDate()}function I8e(t,e){return new Date(t,e,1).getDay()}const F8e=["January","February","March","April","May","June","July","August","September","October","November","December"],U8e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function z8e({archives:t,onArchiveClick:e,highlightedArchiveId:n}){const r=new Date,[i,s]=w.useState(r.getMonth()),[o,l]=w.useState(r.getFullYear()),[c,u]=w.useState(null),[d,f]=w.useState(null),m=w.useMemo(()=>{const T=new Map;return t.forEach(k=>{const E=Ri(k.completed_at||k.created_at)||new Date,D=`${E.getFullYear()}-${String(E.getMonth()+1).padStart(2,"0")}-${String(E.getDate()).padStart(2,"0")}`,A=T.get(D)||[];A.push(k),T.set(D,A)}),T},[t]),p=L8e(o,i),x=I8e(o,i),b=()=>{i===0?(s(11),l(o-1)):s(i-1)},y=()=>{i===11?(s(0),l(o+1)):s(i+1)},v=()=>{s(r.getMonth()),l(r.getFullYear())},S=[];for(let T=0;T<x;T++)S.push(null);for(let T=1;T<=p;T++)S.push(T);const N=c?m.get(c)||[]:[],C=T=>{T!==c&&f(null),u(T)};return a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("button",{onClick:b,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(gh,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white",children:[F8e[i]," ",o]}),a.jsx("button",{onClick:v,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"})]}),a.jsx("button",{onClick:y,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(vs,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:U8e.map(T=>a.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:T},T))}),a.jsx("div",{className:"grid grid-cols-7 gap-1",children:S.map((T,k)=>{if(T===null)return a.jsx("div",{className:"aspect-square"},`empty-${k}`);const E=`${o}-${String(i+1).padStart(2,"0")}-${String(T).padStart(2,"0")}`,D=m.get(E)||[],A=D.length>0,R=T===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),F=E===c,O=D.filter(j=>j.status==="completed").length,H=D.filter(j=>j.status==="failed").length;return a.jsxs("button",{onClick:()=>C(F?null:E),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${F?"bg-bambu-green text-white":R?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":A?"bg-bambu-dark-tertiary hover:bg-bambu-dark-tertiary/70 text-white":"hover:bg-bambu-dark-tertiary/50 text-bambu-gray"}`,children:[a.jsx("span",{className:`text-sm font-medium ${R&&!F?"text-bambu-green":""}`,children:T}),A&&a.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[a.jsx("div",{className:`w-2 h-2 rounded-full ${H>0&&O===0?"bg-red-400":H>0?"bg-yellow-400":"bg-green-400"}`}),a.jsx("span",{className:"text-xs font-medium",children:D.length})]})]},T)})}),a.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:a.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-2xl font-bold text-white",children:t.filter(T=>{const k=new Date(T.completed_at||T.created_at);return k.getMonth()===i&&k.getFullYear()===o}).length}),a.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(T=>{const k=new Date(T.completed_at||T.created_at);return k.getMonth()===i&&k.getFullYear()===o&&T.status==="completed"}).length}),a.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-2xl font-bold text-red-400",children:t.filter(T=>{const k=new Date(T.completed_at||T.created_at);return k.getMonth()===i&&k.getFullYear()===o&&T.status==="failed"}).length}),a.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),a.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:c?a.jsxs(a.Fragment,{children:[a.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:new Date(c+"T12:00:00").toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}),N.length>0?a.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:N.map(T=>{const k=T.id===d||T.id===n;return a.jsxs("button",{onClick:()=>{f(T.id),e?.(T)},className:`w-full flex items-center gap-3 p-2 rounded-lg transition-colors text-left ${k?"":"hover:bg-bambu-dark-tertiary"}`,style:k?{outline:"4px solid #facc15",outlineOffset:"2px"}:void 0,children:[T.thumbnail_path?a.jsx("img",{src:ue.getArchiveThumbnail(T.id),alt:"",className:"w-12 h-12 rounded object-cover"}):a.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:a.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:T.print_name||T.filename}),a.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:T.status==="failed"?"text-red-400":"text-green-400",children:T.status==="failed"?"Failed":"Completed"}),T.filament_color&&a.jsx("div",{className:"flex gap-0.5",children:T.filament_color.split(",").map((E,D)=>a.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:E}},D))})]})]})]},T.id)})}):a.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):a.jsx("div",{className:"text-center py-8",children:a.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function Tee({archiveId:t,archiveName:e,onClose:n}){const r=ue.getArchiveQRCodeUrl(t,300);w.useEffect(()=>{const s=o=>{o.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 a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:s=>s.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),a.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-6 flex flex-col items-center",children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),a.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:a.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),a.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),a.jsxs(Ne,{onClick:i,className:"w-full",children:[a.jsx(pi,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function Aee({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[s,o]=w.useState(0),[l,c]=w.useState(!1);if(w.useEffect(()=>{const p=x=>{x.key==="Escape"&&r(),x.key==="ArrowLeft"&&o(b=>Math.max(0,b-1)),x.key==="ArrowRight"&&o(b=>Math.min(n.length-1,b+1))};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r,n.length]),w.useEffect(()=>{s>=n.length&&o(Math.max(0,n.length-1))},[n.length,s]),n.length===0)return r(),null;const u=n[s],d=ue.getArchivePhotoUrl(t,u),f=()=>{const p=document.createElement("a");p.href=d,p.download=`${e}_photo_${s+1}.jpg`,p.click()},m=()=>{i&&c(!0)};return a.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[a.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:p=>p.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",s+1," of ",n.length]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:f,children:[a.jsx(pi,{className:"w-4 h-4"}),"Download"]}),i&&a.jsx(Ne,{variant:"secondary",size:"sm",onClick:m,className:"text-red-400 hover:text-red-300",children:a.jsx(an,{className:"w-4 h-4"})}),a.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:a.jsx(Dt,{className:"w-6 h-6"})})]})]}),a.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[s>0&&a.jsx("button",{onClick:()=>o(p=>p-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:a.jsx(gh,{className:"w-8 h-8 text-white"})}),a.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&&a.jsx("button",{onClick:()=>o(p=>p+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:a.jsx(vs,{className:"w-8 h-8 text-white"})})]}),n.length>1&&a.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((p,x)=>a.jsx("button",{onClick:()=>o(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:a.jsx("img",{src:ue.getArchivePhotoUrl(t,p),alt:`Thumbnail ${x+1}`,className:"w-full h-full object-cover"})},p))})]}),l&&a.jsx(Yn,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),c(!1)},onCancel:()=>c(!1)})]})}function Aa(t){this.content=t}Aa.prototype={constructor:Aa,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 Aa(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 Aa(n)},addToStart:function(t,e){return new Aa([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Aa(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 Aa(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=Aa.from(t),t.size?new Aa(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Aa.from(t),t.size?new Aa(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Aa.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}};Aa.from=function(t){if(t instanceof Aa)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Aa(e)};function kee(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 o=0;i.text[o]==s.text[o];o++)n++;return n}if(i.content.size||s.content.size){let o=kee(i.content,s.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function jee(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 o=t.child(--i),l=e.child(--s),c=o.nodeSize;if(o==l){n-=c,r-=c;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let u=0,d=Math.min(o.text.length,l.text.length);for(;u<d&&o.text[o.text.length-u-1]==l.text[l.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(o.content.size||l.content.size){let u=jee(o.content,l.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class Et{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 o=0,l=0;l<n;o++){let c=this.content[o],u=l+c.nodeSize;if(u>e&&r(c,i+l,s||null,o)!==!1&&c.content.size){let d=l+1;c.nodesBetween(Math.max(0,e-d),Math.min(c.content.size,n-d),r,i+d)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let s="",o=!0;return this.nodesBetween(e,n,(l,c)=>{let u=l.isText?l.text.slice(Math.max(e,c)-c,n-c):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&r&&(o?o=!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 Et(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,o=0;o<n;s++){let l=this.content[s],c=o+l.nodeSize;c>e&&((o<e||c>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),i+=l.nodeSize),o=c}return new Et(r,i)}cutByIndex(e,n){return e==n?Et.empty:e==0&&n==this.content.length?this:new Et(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 Et(i,s)}addToStart(e){return new Et([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Et(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 kee(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return jee(this,e,n,r)}findIndex(e){if(e==0)return Jw(0,e);if(e==this.size)return Jw(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?Jw(n+1,s):Jw(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 Et.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Et(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Et.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 Et(n||e,r)}static from(e){if(!e)return Et.empty;if(e instanceof Et)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Et([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Et.empty=new Et([],0);const dj={index:0,offset:0};function Jw(t,e){return dj.index=t,dj.offset=e,dj}function l2(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(!l2(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!l2(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Rr=class CR{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&&l2(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 CR.none;if(e instanceof CR)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};Rr.none=[];class c2 extends Error{}class zt{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=Ree(this.content,e+this.openStart,n);return r&&new zt(r,this.openStart,this.openEnd)}removeBetween(e,n){return new zt(Pee(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 zt.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 zt(Et.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 zt(e,r,i)}}zt.empty=new zt(Et.empty,0,0);function Pee(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(i==e||s.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(Pee(s.content,e-i-1,n-i-1)))}function Ree(t,e,n,r){let{index:i,offset:s}=t.findIndex(e),o=t.maybeChild(i);if(s==e||o.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=Ree(o.content,e-s-1,n,o);return l&&t.replaceChild(i,o.copy(l))}function B8e(t,e,n){if(n.openStart>t.depth)throw new c2("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new c2("Inconsistent open depths");return Dee(t,e,n,0)}function Dee(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=Dee(t,e,n,r+1);return s.copy(s.content.replaceChild(i,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,l=o.content;return Yf(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=$8e(n,t);return Yf(s,Lee(t,o,l,e,r))}else return Yf(s,u2(t,e,r))}function Oee(t,e){if(!e.type.compatibleContent(t.type))throw new c2("Cannot join "+e.type.name+" onto "+t.type.name)}function TR(t,e,n){let r=t.node(n);return Oee(r,e.node(n)),r}function Xf(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 E0(t,e,n,r){let i=(e||t).node(n),s=0,o=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(Xf(t.nodeAfter,r),s++));for(let l=s;l<o;l++)Xf(i.child(l),r);e&&e.depth==n&&e.textOffset&&Xf(e.nodeBefore,r)}function Yf(t,e){return t.type.checkContent(e),t.copy(e)}function Lee(t,e,n,r,i){let s=t.depth>i&&TR(t,e,i+1),o=r.depth>i&&TR(n,r,i+1),l=[];return E0(null,t,i,l),s&&o&&e.index(i)==n.index(i)?(Oee(s,o),Xf(Yf(s,Lee(t,e,n,r,i+1)),l)):(s&&Xf(Yf(s,u2(t,e,i+1)),l),E0(e,n,i,l),o&&Xf(Yf(o,u2(n,r,i+1)),l)),E0(r,null,i,l),new Et(l)}function u2(t,e,n){let r=[];if(E0(null,t,n,r),t.depth>n){let i=TR(t,e,n+1);Xf(Yf(i,u2(t,e,n+1)),r)}return E0(e,null,n,r),new Et(r)}function $8e(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(Et.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class _y{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 Rr.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let l=r;r=i,i=l}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].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 d2(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 o=e;;){let{index:l,offset:c}=o.content.findIndex(s),u=s-c;if(r.push(o,l,i+c),!u||(o=o.child(l),o.isText))break;s=u-1,i+=c+1}return new _y(n,r,s)}static resolveCached(e,n){let r=OG.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==n)return o}else OG.set(e,r=new H8e);let i=r.elts[r.i]=_y.resolve(e,n);return r.i=(r.i+1)%V8e,i}}class H8e{constructor(){this.elts=[],this.i=0}}const V8e=12,OG=new WeakMap;class d2{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 G8e=Object.create(null);let hh=class AR{constructor(e,n,r,i=Rr.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||Et.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&&l2(this.attrs,n||e.defaultAttrs||G8e)&&Rr.sameSet(this.marks,r||Rr.none)}copy(e=null){return e==this.content?this:new AR(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new AR(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 zt.empty;let i=this.resolve(e),s=this.resolve(n),o=r?0:i.sharedDepth(n),l=i.start(o),u=i.node(o).content.cut(i.pos-l,s.pos-l);return new zt(u,i.depth-o,s.depth-o)}replace(e,n,r){return B8e(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 _y.resolveCached(this,e)}resolveNoCache(e){return _y.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()+")"),Iee(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=Et.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let c=i;c<s;c++)if(!this.type.allowsMarks(r.child(c).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,n);return o?o.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=Rr.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(!Rr.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=Et.fromJSON(e,n.content),s=e.nodeType(n.type).create(n.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};hh.prototype.text=void 0;class h2 extends hh{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):Iee(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 h2(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new h2(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 Iee(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class vm{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new q8e(e,n);if(r.next==null)return vm.empty;let i=Fee(r);r.next&&r.err("Unexpected trailing text");let s=J8e(Z8e(i));return e6e(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(o,l){let c=o.matchFragment(e,r);if(c&&(!n||c.validEnd))return Et.from(l.map(u=>u.createAndFill()));for(let u=0;u<o.next.length;u++){let{type:d,next:f}=o.next[u];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let m=s(f,l.concat(d));if(m)return m}}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 o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:c}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!i.type||c.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),n[l.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 o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
  8142. `)}}vm.empty=new vm(!0);class q8e{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 Fee(t){let e=[];do e.push(W8e(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function W8e(t){let e=[];do e.push(K8e(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function K8e(t){let e=Q8e(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=X8e(t,e);else break;return e}function LG(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function X8e(t,e){let n=LG(t),r=n;return t.eat(",")&&(t.next!="}"?r=LG(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Y8e(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let s in n){let o=n[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function Q8e(t){if(t.eat("(")){let e=Fee(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=Y8e(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 Z8e(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function r(o,l,c){let u={term:c,to:l};return e[o].push(u),u}function i(o,l){o.forEach(c=>c.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((c,u)=>c.concat(s(u,l)),[]);if(o.type=="seq")for(let c=0;;c++){let u=s(o.exprs[c],l);if(c==o.exprs.length-1)return u;i(u,l=n())}else if(o.type=="star"){let c=n();return r(l,c),i(s(o.expr,c),c),[r(c)]}else if(o.type=="plus"){let c=n();return i(s(o.expr,l),c),i(s(o.expr,c),c),[r(c)]}else{if(o.type=="opt")return[r(l)].concat(s(o.expr,l));if(o.type=="range"){let c=l;for(let u=0;u<o.min;u++){let d=n();i(s(o.expr,c),d),c=d}if(o.max==-1)i(s(o.expr,c),c);else for(let u=o.min;u<o.max;u++){let d=n();r(c,d),i(s(o.expr,c),d),c=d}return[r(c)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Uee(t,e){return e-t}function IG(t,e){let n=[];return r(e),n.sort(Uee);function r(i){let s=t[i];if(s.length==1&&!s[0].term)return r(s[0].to);n.push(i);for(let o=0;o<s.length;o++){let{term:l,to:c}=s[o];!l&&n.indexOf(c)==-1&&r(c)}}}function J8e(t){let e=Object.create(null);return n(IG(t,0));function n(r){let i=[];r.forEach(o=>{t[o].forEach(({term:l,to:c})=>{if(!l)return;let u;for(let d=0;d<i.length;d++)i[d][0]==l&&(u=i[d][1]);IG(t,c).forEach(d=>{u||i.push([l,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let s=e[r.join(",")]=new vm(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Uee);s.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return s}}function e6e(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:c,next:u}=i.next[l];o.push(c.name),s&&!(c.isText||c.hasRequiredAttrs())&&(s=!1),r.indexOf(u)==-1&&r.push(u)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function zee(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 Bee(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 $ee(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 Hee(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new n6e(t,r,e[r]);return n}let FG=class Vee{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=Hee(e,r.attrs),this.defaultAttrs=zee(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==vm.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:Bee(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new hh(this,this.computeAttrs(e),Et.from(n),Rr.setFrom(r))}createChecked(e=null,n,r){return n=Et.from(n),this.checkContent(n),new hh(this,this.computeAttrs(e),n,Rr.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=Et.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let i=this.contentMatch.matchFragment(n),s=i&&i.fillBefore(Et.empty,!0);return s?new hh(this,e,n.append(s),Rr.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){$ee(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:Rr.none:e}static compile(e,n){let r=Object.create(null);e.forEach((s,o)=>r[s]=new Vee(s,n,o));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 t6e(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 n6e{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?t6e(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class NM{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=Hee(e,i.attrs),this.excluded=null;let s=zee(this.attrs);this.instance=s?new Rr(this,s):null}create(e=null){return!e&&this.instance?this.instance:new Rr(this,Bee(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new NM(s,i++,n,o)),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){$ee(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Gee{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=Aa.from(e.nodes),n.marks=Aa.from(e.marks||{}),this.nodes=FG.compile(this.spec.nodes,this),this.marks=NM.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],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=vm.parse(o,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=l=="_"?null:l?UG(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:UG(this,o.split(" "))}this.nodeFromJSON=i=>hh.fromJSON(this,i),this.markFromJSON=i=>Rr.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 FG){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 h2(r,r.defaultAttrs,e,Rr.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 UG(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],s=t.marks[i],o=s;if(s)n.push(s);else for(let l in t.marks){let c=t.marks[l];(i=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=c)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function r6e(t){return t.tag!=null}function i6e(t){return t.style!=null}let C0=class kR{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(r6e(i))this.tags.push(i);else if(i6e(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 BG(this,n,!1);return r.addAll(e,Rr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new BG(this,n,!0);return r.addAll(e,Rr.none,n.from,n.to),zt.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(o6e(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||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 o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(o.getAttrs){let c=o.getAttrs(n);if(c===!1)continue;o.attrs=c||void 0}return o}}}static schemaRules(e){let n=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<s)break}n.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=$G(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=$G(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new kR(e,kR.schemaRules(e)))}};const qee={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},a6e={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Wee={ol:!0,ul:!0},wy=1,jR=2,T0=4;function zG(t,e,n){return e!=null?(e?wy:0)|(e==="full"?jR:0):t&&t.whitespace=="pre"?wy|jR:n&~T0}class e1{constructor(e,n,r,i,s,o){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=Rr.none,this.match=s||(o&T0?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Et.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&wy)){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=Et.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Et.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&&!qee.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class BG{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,s,o=zG(null,n.preserveWhitespace,0)|(r?T0:0);i?s=new e1(i.type,i.attrs,Rr.none,!0,n.topMatch||i.type.contentMatch,o):r?s=new e1(null,null,Rr.none,!0,null,o):s=new e1(e.schema.topNodeType,null,Rr.none,!0,null,o),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&jR?"full":this.localPreserveWS||(i.options&wy)>0,{schema:o}=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,`
  8143. `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let c=0;c<l.length;c++)c&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[c]&&this.insertNode(o.text(l[c]),n,!/\S/.test(l[c]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],c=e.previousSibling;(!l||c&&c.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.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 o=e.nodeName.toLowerCase(),l;Wee.hasOwnProperty(o)&&this.parser.normalizeLists&&s6e(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:a6e.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!c||c.skip||c.closeParent){c&&c.closeParent?this.open=Math.max(0,this.open-1):c&&c.skip.nodeType&&(e=c.skip);let u,d=this.needsBlock;if(qee.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),u=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=c&&c.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),u&&this.sync(s),this.needsBlock=d}else{let u=this.readStyles(e,n);u&&this.addElementByRule(e,c,u,c.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
  8144. `),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],o=r.getPropertyValue(s);if(o)for(let l=void 0;;){let c=this.parser.matchStyle(s,o,this,l);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(u=>!c.clearMark(u)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)l=c;else break}}return n}addElementByRule(e,n,r,i){let s,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let c=this.enter(o,n.attrs||null,r,n.preserveWhitespace);c&&(s=!0,r=c)}else{let c=this.parser.schema.marks[n.mark];r=r.concat(c.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,r,!1));else{let c=e;typeof n.contentElement=="string"?c=e.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(e):n.contentElement&&(c=n.contentElement),this.findAround(e,c,!0),this.addAll(c,r),this.findAround(e,c,!1)}s&&this.sync(l)&&this.open--}addAll(e,n,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,n);this.findAtPoint(e,s)}findPlace(e,n,r){let i,s;for(let o=this.open,l=0;o>=0;o--){let c=this.nodes[o],u=c.findWrapping(e);if(u&&(!i||i.length>u.length+l)&&(i=u,s=c,!u.length))break;if(c.solid){if(r)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)n=this.enterInner(i[o],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 o=Rr.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):HG(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!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 o=this.top;o.match=o.match&&o.match.matchType(e);let l=zG(e,s,o.options);o.options&T0&&o.content.length==0&&(l|=T0);let c=Rr.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):HG(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new e1(e,n,c,i,null,l)),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|=wy)}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),o=(l,c)=>{for(;l>=0;l--){let u=n[l];if(u==""){if(l==n.length-1||l==0)continue;for(;c>=s;c--)if(o(l-1,c))return!0;return!1}else{let d=c>0||c==0&&i?this.nodes[c].type:r&&c>=s?r.node(c-s).type:null;if(!d||d.name!=u&&!d.isInGroup(u))return!1;c--}}return!0};return o(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 s6e(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Wee.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function o6e(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function $G(t){let e={};for(let n in t)e[n]=t[n];return e}function HG(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],o=l=>{s.push(l);for(let c=0;c<l.edgeCount;c++){let{type:u,next:d}=l.edge(c);if(u==e||s.indexOf(d)<0&&o(d))return!0}};if(o(i.contentMatch))return!0}}class jm{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=hj(n).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,c=0;for(;l<s.length&&c<o.marks.length;){let u=o.marks[c];if(!this.marks[u.type.name]){c++;continue}if(!u.eq(s[l][0])||u.type.spec.spanning===!1)break;l++,c++}for(;l<s.length;)i=s.pop()[1];for(;c<o.marks.length;){let u=o.marks[c++],d=this.serializeMark(u,o.isInline,n);d&&(s.push([u,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=D1(hj(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&&D1(hj(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return D1(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new jm(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=VG(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return VG(e.marks)}}function VG(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function hj(t){return t.document||window.document}const GG=new WeakMap;function l6e(t){let e=GG.get(t);return e===void 0&&GG.set(t,e=c6e(t)),e}function c6e(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 D1(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=l6e(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 o=i.indexOf(" ");o>0&&(n=i.slice(0,o),i=i.slice(o+1));let l,c=n?t.createElementNS(n,i):t.createElement(i),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let f in u)if(u[f]!=null){let m=f.indexOf(" ");m>0?c.setAttributeNS(f.slice(0,m),f.slice(m+1),u[f]):f=="style"&&c.style?c.style.cssText=u[f]:c.setAttribute(f,u[f])}}for(let f=d;f<e.length;f++){let m=e[f];if(m===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:p,contentDOM:x}=D1(t,m,n,r);if(c.appendChild(p),x){if(l)throw new RangeError("Multiple content holes");l=x}}}return{dom:c,contentDOM:l}}const Kee=65535,Xee=Math.pow(2,16);function u6e(t,e){return t+e*Xee}function qG(t){return t&Kee}function d6e(t){return(t-(t&Kee))/Xee}const Yee=1,Qee=2,O1=4,Zee=8;class PR{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Zee)>0}get deletedBefore(){return(this.delInfo&(Yee|O1))>0}get deletedAfter(){return(this.delInfo&(Qee|O1))>0}get deletedAcross(){return(this.delInfo&O1)>0}}class uo{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&uo.empty)return uo.empty}recover(e){let n=0,r=qG(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+d6e(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,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?i:0);if(c>e)break;let u=this.ranges[l+s],d=this.ranges[l+o],f=c+u;if(e<=f){let m=u?e==c?-1:e==f?1:n:n,p=c+i+(m<0?0:d);if(r)return p;let x=e==(n<0?c:f)?null:u6e(l/3,e-c),b=e==c?Qee:e==f?Yee:O1;return(n<0?e!=c:e!=f)&&(b|=Zee),new PR(p,b,x)}i+=d-u}return r?e+i:new PR(e+i,0,null)}touches(e,n){let r=0,i=qG(n),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?r:0);if(c>e)break;let u=this.ranges[l+s],d=c+u;if(e<=d&&l==i*3)return!0;r+=this.ranges[l+o]-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 o=this.ranges[i],l=o-(this.inverted?s:0),c=o+(this.inverted?0:s),u=this.ranges[i+n],d=this.ranges[i+r];e(l,l+u,c,c+d),s+=d-u}}invert(){return new uo(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?uo.empty:new uo(e<0?[0,-e,0]:[0,0,e])}}uo.empty=new uo([]);class Sy{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 Sy(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 Sy;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 o=this._maps[s],l=o.mapResult(e,n);if(l.recover!=null){let c=this.getMirror(s);if(c!=null&&c>s&&c<this.to){s=c,e=this._maps[c].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new PR(e,i,null)}}const fj=Object.create(null);class ts{getMap(){return uo.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=fj[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 fj)throw new RangeError("Duplicate use of step JSON ID "+e);return fj[e]=n,n.prototype.jsonID=e,n}}class Li{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Li(e,null)}static fail(e){return new Li(null,e)}static fromReplace(e,n,r,i){try{return Li.ok(e.replace(n,r,i))}catch(s){if(s instanceof c2)return Li.fail(s.message);throw s}}}function bL(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(bL(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return Et.fromArray(r)}class Jd extends ts{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 zt(bL(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),n.openStart,n.openEnd);return Li.fromReplace(e,this.from,this.to,s)}invert(){return new Dl(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 Jd(n.pos,r.pos,this.mark)}merge(e){return e instanceof Jd&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Jd(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 Jd(n.from,n.to,e.markFromJSON(n.mark))}}ts.jsonID("addMark",Jd);class Dl extends ts{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 zt(bL(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return Li.fromReplace(e,this.from,this.to,r)}invert(){return new Jd(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 Dl(n.pos,r.pos,this.mark)}merge(e){return e instanceof Dl&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Dl(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 Dl(n.from,n.to,e.markFromJSON(n.mark))}}ts.jsonID("removeMark",Dl);class eh extends ts{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Li.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Li.fromReplace(e,this.pos,this.pos+1,new zt(Et.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 eh(this.pos,n.marks[i]);return new eh(this.pos,this.mark)}}return new _m(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new eh(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 eh(n.pos,e.markFromJSON(n.mark))}}ts.jsonID("addNodeMark",eh);class _m extends ts{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Li.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Li.fromReplace(e,this.pos,this.pos+1,new zt(Et.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new eh(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new _m(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 _m(n.pos,e.markFromJSON(n.mark))}}ts.jsonID("removeNodeMark",_m);class ma extends ts{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&RR(e,this.from,this.to)?Li.fail("Structure replace would overwrite content"):Li.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new uo([this.from,this.to-this.from,this.slice.size])}invert(e){return new ma(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 ma(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ma)||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?zt.empty:new zt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ma(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?zt.empty:new zt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ma(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 ma(n.from,n.to,zt.fromJSON(e,n.slice),!!n.structure)}}ts.jsonID("replace",ma);class ba extends ts{constructor(e,n,r,i,s,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(RR(e,this.from,this.gapFrom)||RR(e,this.gapTo,this.to)))return Li.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Li.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Li.fromReplace(e,this.from,this.to,r):Li.fail("Content does not fit in gap")}getMap(){return new uo([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 ba(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 ba(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 ba(n.from,n.to,n.gapFrom,n.gapTo,zt.fromJSON(e,n.slice),n.insert,!!n.structure)}}ts.jsonID("replaceAround",ba);function RR(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 o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function h6e(t,e,n,r){let i=[],s=[],o,l;t.doc.nodesBetween(e,n,(c,u,d)=>{if(!c.isInline)return;let f=c.marks;if(!r.isInSet(f)&&d.type.allowsMarkType(r.type)){let m=Math.max(u,e),p=Math.min(u+c.nodeSize,n),x=r.addToSet(f);for(let b=0;b<f.length;b++)f[b].isInSet(x)||(o&&o.to==m&&o.mark.eq(f[b])?o.to=p:i.push(o=new Dl(m,p,f[b])));l&&l.to==m?l.to=p:s.push(l=new Jd(m,p,r))}}),i.forEach(c=>t.step(c)),s.forEach(c=>t.step(c))}function f6e(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;s++;let c=null;if(r instanceof NM){let u=o.marks,d;for(;d=r.isInSet(u);)(c||(c=[])).push(d),u=d.removeFromSet(u)}else r?r.isInSet(o.marks)&&(c=[r]):c=o.marks;if(c&&c.length){let u=Math.min(l+o.nodeSize,n);for(let d=0;d<c.length;d++){let f=c[d],m;for(let p=0;p<i.length;p++){let x=i[p];x.step==s-1&&f.eq(i[p].style)&&(m=x)}m?(m.to=u,m.step=s):i.push({style:f,from:Math.max(l,e),to:u,step:s})}}}),i.forEach(o=>t.step(new Dl(o.from,o.to,o.style)))}function yL(t,e,n,r=n.contentMatch,i=!0){let s=t.doc.nodeAt(e),o=[],l=e+1;for(let c=0;c<s.childCount;c++){let u=s.child(c),d=l+u.nodeSize,f=r.matchType(u.type);if(!f)o.push(new ma(l,d,zt.empty));else{r=f;for(let m=0;m<u.marks.length;m++)n.allowsMarkType(u.marks[m].type)||t.step(new Dl(l,d,u.marks[m]));if(i&&u.isText&&n.whitespace!="pre"){let m,p=/\r?\n|\r/g,x;for(;m=p.exec(u.text);)x||(x=new zt(Et.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),o.push(new ma(l+m.index,l+m.index+m[0].length,x))}}l=d}if(!r.validEnd){let c=r.fillBefore(Et.empty,!0);t.replace(l,l,new zt(c,0,0))}for(let c=o.length-1;c>=0;c--)t.step(o[c])}function m6e(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Ox(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,s=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+i,c=t.$to.indexAfter(r)-s;if(r<t.depth&&o.canReplace(l,c,n))return r;if(r==0||o.type.spec.isolating||!m6e(o,l,c))break;l&&(i=1),c<o.childCount&&(s=1)}return null}function p6e(t,e,n){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),l=i.after(s+1),c=o,u=l,d=Et.empty,f=0;for(let x=s,b=!1;x>n;x--)b||r.index(x)>0?(b=!0,d=Et.from(r.node(x).copy(d)),f++):c--;let m=Et.empty,p=0;for(let x=s,b=!1;x>n;x--)b||i.after(x+1)<i.end(x)?(b=!0,m=Et.from(i.node(x).copy(m)),p++):u++;t.step(new ba(c,u,o,l,new zt(d.append(m),f,p),d.size-f,!0))}function vL(t,e,n=null,r=t){let i=g6e(t,e),s=i&&x6e(r,e);return s?i.map(WG).concat({type:e,attrs:n}).concat(s.map(WG)):null}function WG(t){return{type:t,attrs:null}}function g6e(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return n.canReplaceWith(r,i,o)?s:null}function x6e(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let c=(o.length?o[o.length-1]:e).contentMatch;for(let u=r;c&&u<i;u++)c=c.matchType(n.child(u).type);return!c||!c.validEnd?null:o}function b6e(t,e,n){let r=Et.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let l=n[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=Et.from(n[o].type.create(n[o].attrs,r))}let i=e.start,s=e.end;t.step(new ba(i,s,i,s,new zt(r,0,0),n.length,!0))}function y6e(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,(o,l)=>{let c=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,c)&&v6e(t.doc,t.mapping.slice(s).map(l),r)){let u=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",x=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!x?u=!1:!p&&x&&(u=!0)}u===!1&&ete(t,o,l,s),yL(t,t.mapping.slice(s).map(l,1),r,void 0,u===null);let d=t.mapping.slice(s),f=d.map(l,1),m=d.map(l+o.nodeSize,1);return t.step(new ba(f,m,f+1,m-1,new zt(Et.from(r.create(c,null,o.marks)),0,0),1,!0)),u===!0&&Jee(t,o,l,s),!1}})}function Jee(t,e,n,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let c=t.mapping.slice(r).map(n+1+s+o.index);t.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function ete(t,e,n,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+s);t.replaceWith(o,o+1,e.type.schema.text(`
  8145. `))}})}function v6e(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function _6e(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 o=n.create(r,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,o);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new ba(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new zt(Et.from(o),0,0),1,!0))}function ku(t,e,n=1,r){let i=t.resolve(e),s=i.depth-n,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.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),m=i.index(u);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(m,f.childCount),x=r&&r[d+1];x&&(p=p.replaceChild(0,x.type.create(x.attrs)));let b=r&&r[d]||f;if(!f.canReplace(m+1,f.childCount)||!b.type.validContent(p))return!1}let l=i.indexAfter(s),c=r&&r[0];return i.node(s).canReplaceWith(l,l,c?c.type:i.node(s+1).type)}function w6e(t,e,n=1,r){let i=t.doc.resolve(e),s=Et.empty,o=Et.empty;for(let l=i.depth,c=i.depth-n,u=n-1;l>c;l--,u--){s=Et.from(i.node(l).copy(s));let d=r&&r[u];o=Et.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}t.step(new ma(e,e,new zt(s.append(o),n,n),!0))}function zh(t,e){let n=t.resolve(e),r=n.index();return tte(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function S6e(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),o=s.type==r?t.type.schema.nodes.text:s.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(s.marks))return!1}return n.validEnd}function tte(t,e){return!!(t&&e&&!t.isLeaf&&S6e(t,e))}function MM(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let s,o,l=r.index(i);if(i==r.depth?(s=r.nodeBefore,o=r.nodeAfter):n>0?(s=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(s=r.node(i).maybeChild(l-1),o=r.node(i+1)),s&&!s.isTextblock&&tte(s,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function N6e(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,s=t.doc.resolve(e-n),o=s.node().type;if(i&&o.inlineContent){let d=o.whitespace=="pre",f=!!o.contentMatch.matchType(i);d&&!f?r=!1:!d&&f&&(r=!0)}let l=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);ete(t,d.node(),d.before(),l)}o.inlineContent&&yL(t,e+n-1,o,s.node().contentMatchAt(s.index()),r==null);let c=t.mapping.slice(l),u=c.map(e-n);if(t.step(new ma(u,c.map(e+n,-1),zt.empty,!0)),r===!0){let d=t.doc.resolve(u);Jee(t,d.node(),d.before(),t.steps.length)}return t}function M6e(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 nte(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 o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,c=r.index(o)+(l>0?1:0),u=r.node(o),d=!1;if(s==1)d=u.canReplace(c,c,i);else{let f=u.contentMatchAt(c).findWrapping(i.firstChild.type);d=f&&u.canReplaceWith(c,c,f[0])}if(d)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function EM(t,e,n=e,r=zt.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return rte(i,s,r)?new ma(e,n,r):new E6e(i,s,r).fit()}function rte(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class E6e{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=Et.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=Et.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,o=r.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let c=new zt(s,o,l);return e>-1?new ba(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new ma(r.pos,i.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=n.firstChild;if(n.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}n=s.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=mj(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:u}=this.frontier[l],d,f=null;if(n==1&&(o?u.matchType(o.type)||(f=u.fillBefore(Et.from(o),!1)):s&&c.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:f};if(n==2&&o&&(d=u.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:d};if(s&&u.matchType(s.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=mj(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new zt(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=mj(e,n);if(i.childCount<=1&&n>0){let s=e.size-n<=n+i.size;this.unplaced=new zt(d0(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new zt(d0(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 b=0;b<s.length;b++)this.openFrontierNode(s[b]);let o=this.unplaced,l=r?r.content:o.content,c=o.openStart-e,u=0,d=[],{match:f,type:m}=this.frontier[n];if(i){for(let b=0;b<i.childCount;b++)d.push(i.child(b));f=f.matchFragment(i)}let p=l.size+e-(o.content.size-o.openEnd);for(;u<l.childCount;){let b=l.child(u),y=f.matchType(b.type);if(!y)break;u++,(u>1||c==0||b.content.size)&&(f=y,d.push(ite(b.mark(m.allowedMarks(b.marks)),u==1?c:0,u==l.childCount?p:-1)))}let x=u==l.childCount;x||(p=-1),this.placed=h0(this.placed,n,Et.from(d)),this.frontier[n].match=f,x&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let b=0,y=l;b<p;b++){let v=y.lastChild;this.frontier.push({type:v.type,match:v.contentMatchAt(v.childCount)}),y=v.content}this.unplaced=x?e==0?zt.empty:new zt(d0(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new zt(d0(o.content,e,u),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!pj(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)),o=pj(e,n,i,r,s);if(o){for(let l=n-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=pj(e,l,u,c,!0);if(!d||d.childCount)continue e}return{depth:n,fit:o,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=h0(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=h0(this.placed,this.depth,Et.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Et.empty,!0);n.childCount&&(this.placed=h0(this.placed,this.frontier.length,n))}}function d0(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(d0(t.firstChild.content,e-1,n)))}function h0(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(h0(t.lastChild.content,e-1,n)))}function mj(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function ite(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,ite(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(Et.empty,!0)))),t.copy(r)}function pj(t,e,n,r,i){let s=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==s.childCount&&!n.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!C6e(n,s.content,o)?l:null}function C6e(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function T6e(t){return t.spec.defining||t.spec.definingForContent}function A6e(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(rte(i,s,r))return t.step(new ma(e,n,r));let o=ste(i,s);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let m=i.depth,p=i.pos-1;m>0;m--,p--){let x=i.node(m).type.spec;if(x.defining||x.definingAsContext||x.isolating)break;o.indexOf(m)>-1?l=m:i.before(m)==p&&o.splice(1,0,-m)}let c=o.indexOf(l),u=[],d=r.openStart;for(let m=r.content,p=0;;p++){let x=m.firstChild;if(u.push(x),p==r.openStart)break;m=x.content}for(let m=d-1;m>=0;m--){let p=u[m],x=T6e(p.type);if(x&&!p.sameMarkup(i.node(Math.abs(l)-1)))d=m;else if(x||!p.type.isTextblock)break}for(let m=r.openStart;m>=0;m--){let p=(m+d+1)%(r.openStart+1),x=u[p];if(x)for(let b=0;b<o.length;b++){let y=o[(b+c)%o.length],v=!0;y<0&&(v=!1,y=-y);let S=i.node(y-1),N=i.index(y-1);if(S.canReplaceWith(N,N,x.type,x.marks))return t.replace(i.before(y),v?s.after(y):n,new zt(ate(r.content,0,r.openStart,p),p,r.openEnd))}}let f=t.steps.length;for(let m=o.length-1;m>=0&&(t.replace(e,n,r),!(t.steps.length>f));m--){let p=o[m];p<0||(e=i.before(p),n=s.after(p))}}function ate(t,e,n,r,i){if(e<n){let s=t.firstChild;t=t.replaceChild(0,s.copy(ate(s.content,e+1,n,r,s)))}if(e>r){let s=i.contentMatchAt(0),o=s.fillBefore(t).append(t);t=o.append(s.matchFragment(o).fillBefore(Et.empty,!0))}return t}function k6e(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=M6e(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new zt(Et.from(r),0,0))}function j6e(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),s=ste(r,i);for(let o=0;o<s.length;o++){let l=s[o],c=o==s.length-1;if(c&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),i.end(l));if(l>0&&(c||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return t.delete(r.before(l),i.after(l))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&i.end(o)-n!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function ste(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 Dg extends ts{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 Li.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 Li.fromReplace(e,this.pos,this.pos+1,new zt(Et.from(i),0,n.isLeaf?0:1))}getMap(){return uo.empty}invert(e){return new Dg(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 Dg(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 Dg(n.pos,n.attr,n.value)}}ts.jsonID("attr",Dg);class Ny extends ts{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 Li.ok(r)}getMap(){return uo.empty}invert(e){return new Ny(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 Ny(n.attr,n.value)}}ts.jsonID("docAttr",Ny);let ox=class extends Error{};ox=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};ox.prototype=Object.create(Error.prototype);ox.prototype.constructor=ox;ox.prototype.name="TransformError";class ote{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Sy}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new ox(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=zt.empty){let i=EM(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new zt(Et.from(r),0,0))}delete(e,n){return this.replace(e,n,zt.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return A6e(this,e,n,r),this}replaceRangeWith(e,n,r){return k6e(this,e,n,r),this}deleteRange(e,n){return j6e(this,e,n),this}lift(e,n){return p6e(this,e,n),this}join(e,n=1){return N6e(this,e,n),this}wrap(e,n){return b6e(this,e,n),this}setBlockType(e,n=e,r,i=null){return y6e(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return _6e(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Dg(e,n,r)),this}setDocAttribute(e,n){return this.step(new Ny(e,n)),this}addNodeMark(e,n){return this.step(new eh(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 Rr)n.isInSet(r.marks)&&this.step(new _m(e,n));else{let i=r.marks,s,o=[];for(;s=n.isInSet(i);)o.push(new _m(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return w6e(this,e,n,r),this}addMark(e,n,r){return h6e(this,e,n,r),this}removeMark(e,n,r){return f6e(this,e,n,r),this}clearIncompatible(e,n,r){return yL(this,e,n,r),this}}const gj=Object.create(null);class kn{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new P6e(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=zt.empty){let r=n.content.lastChild,i=null;for(let l=0;l<n.openEnd;l++)i=r,r=r.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:c,$to:u}=o[l],d=e.mapping.slice(s);e.replaceRange(d.map(c.pos),d.map(u.pos),l?zt.empty:n),l==0&&YG(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:o,$to:l}=i[s],c=e.mapping.slice(r),u=c.map(o.pos),d=c.map(l.pos);s?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),YG(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new pn(e):og(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 o=n<0?og(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):og(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new bo(e.node(0))}static atStart(e){return og(e,e,0,0,1)||new bo(e)}static atEnd(e){return og(e,e,e.content.size,e.childCount,-1)||new bo(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=gj[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 gj)throw new RangeError("Duplicate use of selection JSON ID "+e);return gj[e]=n,n.prototype.jsonID=e,n}getBookmark(){return pn.between(this.$anchor,this.$head).getBookmark()}}kn.prototype.visible=!0;class P6e{constructor(e,n){this.$from=e,this.$to=n}}let KG=!1;function XG(t){!KG&&!t.parent.inlineContent&&(KG=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class pn extends kn{constructor(e,n=e){XG(e),XG(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 kn.near(r);let i=e.resolve(n.map(this.anchor));return new pn(i.parent.inlineContent?i:r,r)}replace(e,n=zt.empty){if(super.replace(e,n),n==zt.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof pn&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new CM(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 pn(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=kn.findFrom(n,r,!0)||kn.findFrom(n,-r,!0);if(s)n=s.$head;else return kn.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(kn.findFrom(e,-r,!0)||kn.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new pn(e,n)}}kn.jsonID("text",pn);class CM{constructor(e,n){this.anchor=e,this.head=n}map(e){return new CM(e.map(this.anchor),e.map(this.head))}resolve(e){return pn.between(e.resolve(this.anchor),e.resolve(this.head))}}class Jt extends kn{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?kn.near(s):new Jt(s)}content(){return new zt(Et.from(this.node),0,0)}eq(e){return e instanceof Jt&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new _L(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Jt(e.resolve(n.anchor))}static create(e,n){return new Jt(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Jt.prototype.visible=!1;kn.jsonID("node",Jt);class _L{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new CM(r,r):new _L(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Jt.isSelectable(r)?new Jt(n):kn.near(n)}}class bo extends kn{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=zt.empty){if(n==zt.empty){e.delete(0,e.doc.content.size);let r=kn.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new bo(e)}map(e){return new bo(e)}eq(e){return e instanceof bo}getBookmark(){return R6e}}kn.jsonID("all",bo);const R6e={map(){return this},resolve(t){return new bo(t)}};function og(t,e,n,r,i,s=!1){if(e.inlineContent)return pn.create(t,n);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&Jt.isSelectable(l))return Jt.create(t,n-(i<0?l.nodeSize:0))}else{let c=og(t,l,n+i,i<0?l.childCount:0,i,s);if(c)return c}n+=l.nodeSize*i}return null}function YG(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof ma||i instanceof ba))return;let s=t.mapping.maps[r],o;s.forEach((l,c,u,d)=>{o==null&&(o=d)}),t.setSelection(kn.near(t.doc.resolve(o),n))}const QG=1,t1=2,ZG=4;class D6e extends ote{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|QG)&~t1,this.storedMarks=null,this}get selectionSet(){return(this.updated&QG)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=t1,this}ensureMarks(e){return Rr.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&t1)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~t1,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)||Rr.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 o=this.doc.resolve(n);s=r==n?o.marks():o.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(kn.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|=ZG,this}get scrolledIntoView(){return(this.updated&ZG)>0}}function JG(t,e){return!e||!t?t:t.bind(e)}class f0{constructor(e,n,r){this.name=e,this.init=JG(n.init,r),this.apply=JG(n.apply,r)}}const O6e=[new f0("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new f0("selection",{init(t,e){return t.selection||kn.atStart(e.doc)},apply(t){return t.selection}}),new f0("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new f0("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class xj{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=O6e.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 f0(r.key,r.spec.state,r))})}}class vg{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 o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let c=i?i[o].n:0,u=i?i[o].state:this,d=c<n.length&&l.spec.appendTransaction.call(l,c?n.slice(c):n,u,r);if(d&&r.filterTransaction(d,o)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<o?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),s=!0}i&&(i[o]={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 vg(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 D6e(this)}static create(e){let n=new xj(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new vg(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 xj(this.schema,e.plugins),r=n.fields,i=new vg(n);for(let s=0;s<r.length;s++){let o=r[s].name;i[o]=this.hasOwnProperty(o)?this[o]: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 xj(e.schema,e.plugins),s=new vg(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=hh.fromJSON(e.schema,n.doc);else if(o.name=="selection")s.selection=kn.fromJSON(s.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(s.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let c=r[l],u=c.spec.state;if(c.key==o.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){s[o.name]=u.fromJSON.call(c,e,n[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function lte(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=lte(i,e,{})),n[r]=i}return n}class ai{constructor(e){this.spec=e,this.props={},e.props&&lte(e.props,this,this.props),this.key=e.key?e.key.key:cte("plugin")}getState(e){return e[this.key]}}const bj=Object.create(null);function cte(t){return t in bj?t+"$"+ ++bj[t]:(bj[t]=0,t+"$")}class ia{constructor(e="key"){this.key=cte(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const wL=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function ute(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const dte=(t,e,n)=>{let r=ute(t,n);if(!r)return!1;let i=SL(r);if(!i){let o=r.blockRange(),l=o&&Ox(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(vte(t,i,e,-1))return!0;if(r.parent.content.size==0&&(lx(s,"end")||Jt.isSelectable(s)))for(let o=r.depth;;o--){let l=EM(t.doc,r.before(o),r.after(o),zt.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(lx(s,"end")?kn.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):Jt.create(c.doc,i.pos-s.nodeSize)),e(c.scrollIntoView())}return!0}if(o==1||r.node(o-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},L6e=(t,e,n)=>{let r=ute(t,n);if(!r)return!1;let i=SL(r);return i?hte(t,i,e):!1},I6e=(t,e,n)=>{let r=mte(t,n);if(!r)return!1;let i=NL(r);return i?hte(t,i,e):!1};function hte(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 o=e.nodeAfter,l=o,c=e.pos+1;for(;!l.isTextblock;c++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let u=EM(t.doc,s,c,zt.empty);if(!u||u.from!=s||u instanceof ma&&u.slice.size>=c-s)return!1;if(n){let d=t.tr.step(u);d.setSelection(pn.create(d.doc,s)),n(d.scrollIntoView())}return!0}function lx(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 fte=(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=SL(r)}let o=s&&s.nodeBefore;return!o||!Jt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Jt.create(t.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function SL(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 mte(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const pte=(t,e,n)=>{let r=mte(t,n);if(!r)return!1;let i=NL(r);if(!i)return!1;let s=i.nodeAfter;if(vte(t,i,e,1))return!0;if(r.parent.content.size==0&&(lx(s,"start")||Jt.isSelectable(s))){let o=EM(t.doc,r.before(),r.after(),zt.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(lx(s,"start")?kn.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):Jt.create(l.doc,l.mapping.map(i.pos))),e(l.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},gte=(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=NL(r)}let o=s&&s.nodeAfter;return!o||!Jt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Jt.create(t.doc,s.pos)).scrollIntoView()),!0)};function NL(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 F6e=(t,e)=>{let n=t.selection,r=n instanceof Jt,i;if(r){if(n.node.isTextblock||!zh(t.doc,n.from))return!1;i=n.from}else if(i=MM(t.doc,n.from,-1),i==null)return!1;if(e){let s=t.tr.join(i);r&&s.setSelection(Jt.create(s.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},U6e=(t,e)=>{let n=t.selection,r;if(n instanceof Jt){if(n.node.isTextblock||!zh(t.doc,n.to))return!1;r=n.to}else if(r=MM(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},z6e=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&Ox(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},xte=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
  8146. `).scrollIntoView()),!0)};function ML(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 B6e=(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),o=ML(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=n.after(),c=t.tr.replaceWith(l,l,o.createAndFill());c.setSelection(kn.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},bte=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof bo||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=ML(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=t.tr.insert(o,s.createAndFill());l.setSelection(pn.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},yte=(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(ku(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Ox(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function $6e(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Jt&&e.selection.node.isBlock)return!r.parentOffset||!ku(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],o,l,c=!1,u=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){c=r.end(p)==r.pos+(r.depth-p),u=r.start(p)==r.pos-(r.depth-p),l=ML(r.node(p-1).contentMatchAt(r.indexAfter(p-1))),s.unshift(c&&l?{type:l}:null),o=p;break}else{if(p==1)return!1;s.unshift(null)}let d=e.tr;(e.selection instanceof pn||e.selection instanceof bo)&&d.deleteSelection();let f=d.mapping.map(r.pos),m=ku(d.doc,f,s.length,s);if(m||(s[0]=l?{type:l}:null,m=ku(d.doc,f,s.length,s)),!m)return!1;if(d.split(f,s.length,s),!c&&u&&r.node(o).type!=l){let p=d.mapping.map(r.before(o)),x=d.doc.resolve(p);l&&r.node(o-1).canReplaceWith(x.index(),x.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(o)),l)}return n&&n(d.scrollIntoView()),!0}}const H6e=$6e(),V6e=(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(Jt.create(t.doc,i))),!0)};function G6e(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||zh(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function vte(t,e,n,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,c=i.type.spec.isolating||s.type.spec.isolating;if(!c&&G6e(t,e,n))return!0;let u=!c&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(n){let p=e.pos+s.nodeSize,x=Et.empty;for(let v=o.length-1;v>=0;v--)x=Et.from(o[v].create(null,x));x=Et.from(i.copy(x));let b=t.tr.step(new ba(e.pos-1,p,e.pos,p,new zt(x,1,0),o.length,!0)),y=b.doc.resolve(p+2*o.length);y.nodeAfter&&y.nodeAfter.type==i.type&&zh(b.doc,y.pos)&&b.join(y.pos),n(b.scrollIntoView())}return!0}let d=s.type.spec.isolating||r>0&&c?null:kn.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),m=f&&Ox(f);if(m!=null&&m>=e.depth)return n&&n(t.tr.lift(f,m).scrollIntoView()),!0;if(u&&lx(s,"start",!0)&&lx(i,"end")){let p=i,x=[];for(;x.push(p),!p.isTextblock;)p=p.lastChild;let b=s,y=1;for(;!b.isTextblock;b=b.firstChild)y++;if(p.canReplace(p.childCount,p.childCount,b.content)){if(n){let v=Et.empty;for(let N=x.length-1;N>=0;N--)v=Et.from(x[N].copy(v));let S=t.tr.step(new ba(e.pos-x.length,e.pos+s.nodeSize,e.pos+y,e.pos+s.nodeSize-y,new zt(v,x.length,0),0,!0));n(S.scrollIntoView())}return!0}}return!1}function _te(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(pn.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}const q6e=_te(-1),W6e=_te(1);function K6e(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),l=o&&vL(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function e9(t,e=null){return function(n,r){let i=!1;for(let s=0;s<n.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[s];n.doc.nodesBetween(o,l,(c,u)=>{if(i)return!1;if(!(!c.isTextblock||c.hasMarkup(t,e)))if(c.type==t)i=!0;else{let d=n.doc.resolve(u),f=d.index();i=d.parent.canReplaceWith(f,f+1,t)}})}if(!i)return!1;if(r){let s=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:c}}=n.selection.ranges[o];s.setBlockType(l,c,t,e)}r(s.scrollIntoView())}return!0}}function EL(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}EL(wL,dte,fte);EL(wL,pte,gte);EL(xte,bte,yte,H6e);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function X6e(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s);if(!o)return!1;let l=r?n.tr:null;return Y6e(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Y6e(t,e,n,r=null){let i=!1,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let c=o.resolve(e.start-2);s=new d2(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new d2(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=vL(s,n,r,e);return l?(t&&Q6e(t,e,l,i,n),!0):!1}function Q6e(t,e,n,r,i){let s=Et.empty;for(let d=n.length-1;d>=0;d--)s=Et.from(n[d].type.create(n[d].attrs,s));t.step(new ba(e.start-(r?2:0),e.end,e.start,e.end,new zt(s,0,0),n.length,!0));let o=0;for(let d=0;d<n.length;d++)n[d].type==i&&(o=d+1);let l=n.length-o,c=e.start+n.length-(r?2:0),u=e.parent;for(let d=e.startIndex,f=e.endIndex,m=!0;d<f;d++,m=!1)!m&&ku(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=u.child(d).nodeSize;return t}function Z6e(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==t);return s?n?r.node(s.depth-1).type==t?J6e(e,n,t,s):e$e(e,n,s):!0:!1}}function J6e(t,e,n,r){let i=t.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new ba(s-1,o,s,o,new zt(Et.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new d2(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=Ox(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(s,-1)-1);return zh(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function e$e(t,e,n){let r=t.tr,i=n.parent;for(let p=n.end,x=n.endIndex-1,b=n.startIndex;x>b;x--)p-=i.child(x).nodeSize,r.delete(p-1,p+1);let s=r.doc.resolve(n.start),o=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,c=n.endIndex==i.childCount,u=s.node(-1),d=s.index(-1);if(!u.canReplace(d+(l?0:1),d+1,o.content.append(c?Et.empty:Et.from(i))))return!1;let f=s.pos,m=f+o.nodeSize;return r.step(new ba(f-(l?1:0),m+(c?1:0),f+1,m-1,new zt((l?Et.empty:Et.from(i.copy(Et.empty))).append(c?Et.empty:Et.from(i.copy(Et.empty))),l?0:1,c?0:1),l?0:1)),e(r.scrollIntoView()),!0}function t$e(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 o=s.startIndex;if(o==0)return!1;let l=s.parent,c=l.child(o-1);if(c.type!=t)return!1;if(n){let u=c.lastChild&&c.lastChild.type==l.type,d=Et.from(u?t.create():null),f=new zt(Et.from(t.create(null,Et.from(l.type.create(null,d)))),u?3:1,0),m=s.start,p=s.end;n(e.tr.step(new ba(m-(u?3:1),p,m,p,f,1,!0)).scrollIntoView())}return!0}}const Ra=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},cx=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let DR=null;const uu=function(t,e,n){let r=DR||(DR=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},n$e=function(){DR=null},wm=function(t,e,n,r){return n&&(t9(t,e,n,r,-1)||t9(t,e,n,r,1))},r$e=/^(img|br|input|textarea|hr)$/i;function t9(t,e,n,r,i){for(var s;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Yo(t))){let o=t.parentNode;if(!o||o.nodeType!=1||xv(t)||r$e.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ra(t)+(i<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else t=o,e=i<0?Yo(t):0}else return!1}}function Yo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function i$e(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=Yo(t)}else if(t.parentNode&&!xv(t))e=Ra(t),t=t.parentNode;else return null}}function a$e(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&&!xv(t))e=Ra(t)+1,t=t.parentNode;else return null}}function s$e(t,e,n){for(let r=e==0,i=e==Yo(t);r||i;){if(t==n)return!0;let s=Ra(t);if(t=t.parentNode,!t)return!1;r=r&&s==0,i=i&&s==Yo(t)}}function xv(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 TM=function(t){return t.focusNode&&wm(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Af(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function o$e(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function l$e(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Yo(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Yo(r.startContainer),r.startOffset)}}}const _c=typeof navigator<"u"?navigator:null,n9=typeof document<"u"?document:null,Bh=_c&&_c.userAgent||"",OR=/Edge\/(\d+)/.exec(Bh),wte=/MSIE \d/.exec(Bh),LR=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Bh),Hs=!!(wte||LR||OR),fh=wte?document.documentMode:LR?+LR[1]:OR?+OR[1]:0,nl=!Hs&&/gecko\/(\d+)/i.test(Bh);nl&&+(/Firefox\/(\d+)/.exec(Bh)||[0,0])[1];const IR=!Hs&&/Chrome\/(\d+)/.exec(Bh),Ya=!!IR,Ste=IR?+IR[1]:0,Ss=!Hs&&!!_c&&/Apple Computer/.test(_c.vendor),ux=Ss&&(/Mobile\/\w+/.test(Bh)||!!_c&&_c.maxTouchPoints>2),Vo=ux||(_c?/Mac/.test(_c.platform):!1),c$e=_c?/Win/.test(_c.platform):!1,wu=/Android \d/.test(Bh),bv=!!n9&&"webkitFontSmoothing"in n9.documentElement.style,u$e=bv?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function d$e(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 ru(t,e){return typeof t=="number"?t:t[e]}function h$e(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 r9(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=cx(o);continue}let l=o,c=l==s.body,u=c?d$e(s):h$e(l),d=0,f=0;if(e.top<u.top+ru(r,"top")?f=-(u.top-e.top+ru(i,"top")):e.bottom>u.bottom-ru(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+ru(i,"top")-u.top:e.bottom-u.bottom+ru(i,"bottom")),e.left<u.left+ru(r,"left")?d=-(u.left-e.left+ru(i,"left")):e.right>u.right-ru(r,"right")&&(d=e.right-u.right+ru(i,"right")),d||f)if(c)s.defaultView.scrollBy(d,f);else{let p=l.scrollLeft,x=l.scrollTop;f&&(l.scrollTop+=f),d&&(l.scrollLeft+=d);let b=l.scrollLeft-p,y=l.scrollTop-x;e={left:e.left-b,top:e.top-y,right:e.right-b,bottom:e.bottom-y}}let m=c?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(m))break;o=m=="absolute"?o.offsetParent:cx(o)}}function f$e(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(s,o);if(!l||l==t.dom||!t.dom.contains(l))continue;let c=l.getBoundingClientRect();if(c.top>=n-20){r=l,i=c.top;break}}return{refDOM:r,refTop:i,stack:Nte(t.dom)}}function Nte(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=cx(r));return e}function m$e({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Mte(n,r==0?0:r-e)}function Mte(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 Jp=null;function p$e(t){if(t.setActive)return t.setActive();if(Jp)return t.focus(Jp);let e=Nte(t);t.focus(Jp==null?{get preventScroll(){return Jp={preventScroll:!0},!0}}:void 0),Jp||(Jp=!1,Mte(e,0))}function Ete(t,e){let n,r=2e8,i,s=0,o=e.top,l=e.top,c,u;for(let d=t.firstChild,f=0;d;d=d.nextSibling,f++){let m;if(d.nodeType==1)m=d.getClientRects();else if(d.nodeType==3)m=uu(d).getClientRects();else continue;for(let p=0;p<m.length;p++){let x=m[p];if(x.top<=o&&x.bottom>=l){o=Math.max(x.bottom,o),l=Math.min(x.top,l);let b=x.left>e.left?x.left-e.left:x.right<e.left?e.left-x.right:0;if(b<r){n=d,r=b,i=b&&n.nodeType==3?{left:x.right<e.left?x.right:x.left,top:e.top}:e,d.nodeType==1&&b&&(s=f+(e.left>=(x.left+x.right)/2?1:0));continue}}else x.top>e.top&&!c&&x.left<=e.left&&x.right>=e.left&&(c=d,u={left:Math.max(x.left,Math.min(x.right,e.left)),top:x.top});!n&&(e.left>=x.right&&e.top>=x.top||e.left>=x.left&&e.top>=x.bottom)&&(s=f+1)}}return!n&&c&&(n=c,i=u,r=0),n&&n.nodeType==3?g$e(n,i):!n||r&&n.nodeType==1?{node:t,offset:s}:Ete(n,i)}function g$e(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=Id(r,1);if(s.top!=s.bottom&&CL(e,s))return{node:t,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:t,offset:0}}function CL(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function x$e(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function b$e(t,e,n){let{node:r,offset:i}=Ete(e,n),s=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();s=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,i,s)}function y$e(t,e,n,r){let i=-1;for(let s=e,o=!1;s!=t.dom;){let l=t.docView.nearestDesc(s,!0),c;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((c=l.dom.getBoundingClientRect()).width||c.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&c.left>r.left||c.top>r.top?i=l.posBefore:(!o&&c.right<r.left||c.bottom<r.top)&&(i=l.posAfter),o=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(c.top+c.bottom)/2:r.left<(c.left+c.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function Cte(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 o=t.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let c=0;c<l.length;c++){let u=l[c];if(CL(e,u))return Cte(o,e,u)}}if((s=(s+1)%r)==i)break}return t}function v$e(t,e){let n=t.dom.ownerDocument,r,i=0,s=l$e(n,e.left,e.top);s&&({node:r,offset:i}=s);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let u=t.dom.getBoundingClientRect();if(!CL(e,u)||(o=Cte(t.dom,e,u),!o))return null}if(Ss)for(let u=o;r&&u;u=cx(u))u.draggable&&(r=void 0);if(o=x$e(o,e),r){if(nl&&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;bv&&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?l=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=y$e(t,r,i,e))}l==null&&(l=b$e(t,o,e));let c=t.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function i9(t){return t.top<t.bottom||t.left<t.right}function Id(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(i9(r))return r}return Array.prototype.find.call(n,i9)||t.getBoundingClientRect()}const _$e=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Tte(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),o=bv||nl;if(r.nodeType==3)if(o&&(_$e.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=Id(uu(r,i,i),n);if(nl&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=Id(uu(r,i-1,i-1),-1);if(u.top==c.top){let d=Id(uu(r,i,i+1),-1);if(d.top!=c.top)return e0(d,d.left<u.left)}}return c}else{let c=i,u=i,d=n<0?1:-1;return n<0&&!i?(u++,d=-1):n>=0&&i==r.nodeValue.length?(c--,d=1):n<0?c--:u++,e0(Id(uu(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==Yo(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return yj(c.getBoundingClientRect(),!1)}if(s==null&&i<Yo(r)){let c=r.childNodes[i];if(c.nodeType==1)return yj(c.getBoundingClientRect(),!0)}return yj(r.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==Yo(r))){let c=r.childNodes[i-1],u=c.nodeType==3?uu(c,Yo(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return e0(Id(u,1),!1)}if(s==null&&i<Yo(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?uu(c,0,o?0:1):c.nodeType==1?c:null:null;if(u)return e0(Id(u,-1),!0)}return e0(Id(r.nodeType==3?uu(r):r,-n),n>=0)}function e0(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 yj(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 Ate(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 w$e(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return Ate(t,e,()=>{let{node:s}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=Tte(t,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let c;if(l.nodeType==1)c=l.getClientRects();else if(l.nodeType==3)c=uu(l,0,l.nodeValue.length).getClientRects();else continue;for(let u=0;u<c.length;u++){let d=c[u];if(d.bottom>d.top+1&&(n=="up"?o.top-d.top>(d.bottom-o.top)*2:d.bottom-o.bottom>(o.bottom-d.top)*2))return!1}}return!0})}const S$e=/[\u0590-\u08ac]/;function N$e(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,l=t.domSelection();return l?!S$e.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?s:o:Ate(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:f}=t.domSelectionRange(),m=l.caretBidiLevel;l.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:x,focusOffset:b}=t.domSelectionRange(),y=x&&!p.contains(x.nodeType==1?x:x.parentNode)||c==x&&u==b;try{l.collapse(d,f),c&&(c!=d||u!=f)&&l.extend&&l.extend(c,u)}catch{}return m!=null&&(l.caretBidiLevel=m),y}):r.pos==r.start()||r.pos==r.end()}let a9=null,s9=null,o9=!1;function M$e(t,e,n){return a9==e&&s9==n?o9:(a9=e,s9=n,o9=n=="up"||n=="down"?w$e(t,e,n):N$e(t,e,n))}const rl=0,l9=1,Lf=2,wc=3;class yv{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=rl,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,o;if(e==this.contentDOM)s=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>Ra(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),o;if(s&&(!n||s.node))if(r&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==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 o=0;o<i.children.length;o++){let l=i.children[o];if(l.size){i=l;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 o=this.children[r],l=s+o.size;if(l>e||o instanceof jte){i=e-s;break}s=l}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 kte&&s.side>=0;r--);if(n<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&n&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,n):{node:this.contentDOM,offset:s?Ra(s.dom)+1:0}}else{let s,o=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,n):{node:this.contentDOM,offset:s?Ra(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 o=r,l=0;;l++){let c=this.children[l],u=o+c.size;if(i==-1&&e<=u){let d=o+c.border;if(e>=d&&n<=u-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,n,d);e=o;for(let f=l;f>0;f--){let m=this.children[f-1];if(m.size&&m.dom.parentNode==this.contentDOM&&!m.emptyChildAt(1)){i=Ra(m.dom)+1;break}e-=m.size}i==-1&&(i=0)}if(i>-1&&(u>n||l==this.children.length-1)){n=u;for(let d=l+1;d<this.children.length;d++){let f=this.children[d];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){s=Ra(f.dom);break}n+=f.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=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),o=Math.max(e,n);for(let p=0,x=0;p<this.children.length;p++){let b=this.children[p],y=x+b.size;if(s>x&&o<y)return b.setSelection(e-x-b.border,n-x-b.border,r,i);x=y}let l=this.domFromPos(e,e?-1:1),c=n==e?l:this.domFromPos(n,n?-1:1),u=r.root.getSelection(),d=r.domSelectionRange(),f=!1;if((nl||Ss)&&e==n){let{node:p,offset:x}=l;if(p.nodeType==3){if(f=!!(x&&p.nodeValue[x-1]==`
  8147. `),f&&x==p.nodeValue.length)for(let b=p,y;b;b=b.parentNode){if(y=b.nextSibling){y.nodeName=="BR"&&(l=c={node:y.parentNode,offset:Ra(y)+1});break}let v=b.pmViewDesc;if(v&&v.node&&v.node.isBlock)break}}else{let b=p.childNodes[x-1];f=b&&(b.nodeName=="BR"||b.contentEditable=="false")}}if(nl&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let p=d.focusNode.childNodes[d.focusOffset];p&&p.contentEditable=="false"&&(i=!0)}if(!(i||f&&Ss)&&wm(l.node,l.offset,d.anchorNode,d.anchorOffset)&&wm(c.node,c.offset,d.focusNode,d.focusOffset))return;let m=!1;if((u.extend||e==n)&&!(f&&nl)){u.collapse(l.node,l.offset);try{e!=n&&u.extend(c.node,c.offset),m=!0}catch{}}if(!m){if(e>n){let x=l;l=c,c=x}let p=document.createRange();p.setEnd(c.node,c.offset),p.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(p)}}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],o=r+s.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+s.border,c=o-s.border;if(e>=l&&n<=c){this.dirty=e==r||n==o?Lf:l9,e==l&&n==c&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=wc:s.markDirty(e-l,n-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?Lf:wc}r=o}this.dirty=Lf}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Lf:l9;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class kte extends yv{constructor(e,n,r,i){let s,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!n.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,s=this}matchesWidget(e){return this.dirty==rl&&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 E$e extends yv{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 Sm extends yv{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],o=s&&s(n,i,r);return(!o||!o.dom)&&(o=jm.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Sm(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&wc||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=wc&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=rl){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=rl}}slice(e,n,r){let i=Sm.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;n<o&&(s=UR(s,n,o,r)),e>0&&(s=UR(s,0,e,r));for(let l=0;l<s.length;l++)s[l].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 mh extends yv{constructor(e,n,r,i,s,o,l,c,u){super(e,[],s,o),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,n,r,i,s,o){let l=s.nodeViews[n.type.name],c,u=l&&l(n,s,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),d=u&&u.dom,f=u&&u.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:f}=jm.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 m=d;return d=Dte(d,r,n),u?c=new C$e(e,n,r,i,d,f||null,m,u,s,o+1):n.isText?new AM(e,n,r,i,d,m,s):new mh(e,n,r,i,d,f||null,m,s,o+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=()=>Et.empty)}return e}matchesNode(e,n,r){return this.dirty==rl&&e.eq(this.node)&&f2(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,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,c=new A$e(this,o&&o.node,e);P$e(this.node,this.innerDeco,(u,d,f)=>{u.spec.marks?c.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!f&&c.syncToMarks(d==this.node.childCount?Rr.none:this.node.child(d).marks,r,e),c.placeWidget(u,e,i)},(u,d,f,m)=>{c.syncToMarks(u.marks,r,e);let p;c.findNodeMatch(u,d,f,m)||l&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(p=c.findIndexWithChild(s.node))>-1&&c.updateNodeAt(u,d,f,p,e)||c.updateNextNode(u,d,f,e,m,i)||c.addNode(u,d,f,e,i),i+=u.nodeSize}),c.syncToMarks([],r,e),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==Lf)&&(o&&this.protectLocalComposition(e,o),Pte(this.contentDOM,this.children,e),ux&&R$e(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof pn)||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 o=s.nodeValue,l=D$e(this.node.content,o,r-n,i-n);return l<0?null:{node:s,pos:l,text:o}}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 o=new E$e(this,s,n,i);e.input.compositionNodes.push(o),this.children=UR(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==wc||!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=rl}updateOuterDeco(e){if(f2(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Rte(this.dom,this.nodeDOM,FR(this.outerDeco,this.node,n),FR(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 c9(t,e,n,r,i){Dte(r,e,t);let s=new mh(void 0,t,e,n,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class AM extends mh{constructor(e,n,r,i,s,o,l){super(e,n,r,i,s,null,o,l,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==wc||this.dirty!=rl&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=rl||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=rl,!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 AM(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=wc)}get domAtom(){return!1}isText(e){return this.node.text==e}}class jte extends yv{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==rl&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class C$e extends mh{constructor(e,n,r,i,s,o,l,c,u,d){super(e,n,r,i,s,o,l,u,d),this.spec=c}update(e,n,r,i){if(this.dirty==wc)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 Pte(t,e,n){let r=t.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=u9(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof Sm){let c=r?r.previousSibling:t.lastChild;Pte(o.contentDOM,o.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=u9(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const A0=function(t){t&&(this.nodeName=t)};A0.prototype=Object.create(null);const If=[new A0];function FR(t,e,n){if(t.length==0)return If;let r=n?If[0]:new A0,i=[r];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(o){o.nodeName&&i.push(r=new A0(o.nodeName));for(let l in o){let c=o[l];c!=null&&(n&&i.length==1&&i.push(r=new A0(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+c:l=="style"?r.style=(r.style?r.style+";":"")+c:l!="nodeName"&&(r[l]=c))}}}return i}function Rte(t,e,n,r){if(n==If&&r==If)return e;let i=e;for(let s=0;s<r.length;s++){let o=r[s],l=n[s];if(s){let c;l&&l.nodeName==o.nodeName&&i!=t&&(c=i.parentNode)&&c.nodeName.toLowerCase()==o.nodeName||(c=document.createElement(o.nodeName),c.pmIsDeco=!0,c.appendChild(i),l=If[0]),i=c}T$e(i,l||If[0],o)}return i}function T$e(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 Dte(t,e,n){return Rte(t,t,If,FR(e,n,t.nodeType!=1))}function f2(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 u9(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class A$e{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=k$e(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,o=Math.min(s,e.length);for(;i<o&&(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=rl,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let c=this.index;c<Math.min(this.index+3,this.top.children.length);c++){let u=this.top.children[c];if(u.matchesMark(e[s])&&!this.isLocked(u.dom)){l=c;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let c=Sm.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))s=this.top.children.indexOf(o,this.index);else for(let l=this.index,c=Math.min(this.top.children.length,l+5);l<c;l++){let u=this.top.children[l];if(u.matchesNode(e,n,r)&&!this.preMatch.matched.has(u)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,n,r,i,s){let o=this.top.children[i];return o.dirty==wc&&o.dom==o.contentDOM&&(o.dirty=Lf),o.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,o){for(let l=this.index;l<this.top.children.length;l++){let c=this.top.children[l];if(c instanceof mh){let u=this.preMatch.matched.get(c);if(u!=null&&u!=s)return!1;let d=c.dom,f,m=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=wc&&f2(n,c.outerDeco));if(!m&&c.update(e,n,r,i))return this.destroyBetween(this.index,l),c.dom!=d&&(this.changed=!0),this.index++,!0;if(!m&&(f=this.recreateWrapper(c,e,n,r,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=Lf,f.updateChildren(i,o+1),f.dirty=rl),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,s,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!f2(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=mh.create(this.top,n,r,i,s,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let c of l.children)c.parent=l}return e.destroy(),l}addNode(e,n,r,i,s){let o=mh.create(this.top,e,n,r,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),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 kte(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 Sm;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof AM)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ss||Ya)&&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 jte(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 k$e(t,e){let n=e,r=n.children.length,i=t.childCount,s=new Map,o=[];e:for(;i>0;){let l;for(;;)if(r){let u=n.children[r-1];if(u instanceof Sm)n=u,r=u.children.length;else{l=u,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let c=l.node;if(c){if(c!=t.child(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function j$e(t,e){return t.type.side-e.type.side}function P$e(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 o=0,l=[],c=null;for(let u=0;;){let d,f;for(;o<i.length&&i[o].to==s;){let y=i[o++];y.widget&&(d?(f||(f=[d])).push(y):d=y)}if(d)if(f){f.sort(j$e);for(let y=0;y<f.length;y++)n(f[y],u,!!c)}else n(d,u,!!c);let m,p;if(c)p=-1,m=c,c=null;else if(u<t.childCount)p=u,m=t.child(u++);else break;for(let y=0;y<l.length;y++)l[y].to<=s&&l.splice(y--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let x=s+m.nodeSize;if(m.isText){let y=x;o<i.length&&i[o].from<y&&(y=i[o].from);for(let v=0;v<l.length;v++)l[v].to<y&&(y=l[v].to);y<x&&(c=m.cut(y-s),m=m.cut(0,y-s),x=y,p=-1)}else for(;o<i.length&&i[o].to<x;)o++;let b=m.isInline&&!m.isLeaf?l.filter(y=>!y.inline):l.slice();r(m,b,e.forChild(s,m),p),s=x}}function R$e(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 D$e(t,e,n,r){for(let i=0,s=0;i<t.childCount&&s<=r;){let o=t.child(i++),l=s;if(s+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<t.childCount;){let u=t.child(i++);if(s+=u.nodeSize,!u.isText)break;c+=u.text}if(s>=n){if(s>=r&&c.slice(r-e.length-l,r-l)==e)return r-e.length;let u=l<r?c.lastIndexOf(e,r-l-1):-1;if(u>=0&&u+e.length+l>=n)return l+u;if(n==r&&c.length>=r+e.length-l&&c.slice(r-l,r-l+e.length)==e)return r}}return-1}function UR(t,e,n,r,i){let s=[];for(let o=0,l=0;o<t.length;o++){let c=t[o],u=l,d=l+=c.size;u>=n||d<=e?s.push(c):(u<e&&s.push(c.slice(0,e-u,r)),i&&(s.push(i),i=void 0),d>n&&s.push(c.slice(n-u,c.size,r)))}return s}function TL(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,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),c,u;if(TM(n)){for(c=o;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&Jt.isSelectable(f)&&i.parent&&!(f.isInline&&s$e(n.focusNode,n.focusOffset,i.dom))){let m=i.posBefore;u=new Jt(o==m?l:r.resolve(m))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=o,m=o;for(let p=0;p<n.rangeCount;p++){let x=n.getRangeAt(p);f=Math.min(f,t.docView.posFromDOM(x.startContainer,x.startOffset,1)),m=Math.max(m,t.docView.posFromDOM(x.endContainer,x.endOffset,-1))}if(f<0)return null;[c,o]=m==t.state.selection.anchor?[m,f]:[f,m],l=r.resolve(o)}else c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let d=r.resolve(c);if(!u){let f=e=="pointer"||t.state.selection.head<l.pos&&!s?1:-1;u=AL(t,d,l,f)}return u}function Ote(t){return t.editable?t.hasFocus():Ite(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function ju(t,e=!1){let n=t.state.selection;if(Lte(t,n),!!Ote(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Ya){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&wm(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)L$e(t);else{let{anchor:r,head:i}=n,s,o;d9&&!(n instanceof pn)&&(n.$from.parent.inlineContent||(s=h9(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=h9(t,n.to))),t.docView.setSelection(r,i,t,e),d9&&(s&&f9(s),o&&f9(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&O$e(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const d9=Ss||Ya&&Ste<63;function h9(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(Ss&&i&&i.contentEditable=="false")return vj(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return vj(i);if(s)return vj(s)}}function vj(t){return t.contentEditable="true",Ss&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function f9(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function O$e(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(()=>{(!Ote(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function L$e(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Ra(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Hs&&fh<=11&&(n.disabled=!0,n.disabled=!1)}function Lte(t,e){if(e instanceof Jt){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(m9(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else m9(t)}function m9(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function AL(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||pn.between(e,n,r)}function p9(t){return t.editable&&!t.hasFocus()?!1:Ite(t)}function Ite(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 I$e(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return wm(e.node,e.offset,n.anchorNode,n.anchorOffset)}function zR(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&&kn.findFrom(s,e)}function $d(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function g9(t,e,n){let r=t.state.selection;if(r instanceof pn)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 o=t.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return $d(t,new pn(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=zR(t.state,e);return i&&i instanceof Jt?$d(t,i):!1}else if(!(Vo&&n.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?Jt.isSelectable(s)?$d(t,new Jt(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):bv?$d(t,new pn(t.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Jt&&r.node.isInline)return $d(t,new pn(e>0?r.$to:r.$from));{let i=zR(t.state,e);return i?$d(t,i):!1}}}function m2(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function k0(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function eg(t,e){return e<0?F$e(t):U$e(t)}function F$e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=!1;for(nl&&n.nodeType==1&&r<m2(n)&&k0(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(k0(l,-1))i=n,s=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Fte(n))break;{let l=n.previousSibling;for(;l&&k0(l,-1);)i=n.parentNode,s=Ra(l),l=l.previousSibling;if(l)n=l,r=m2(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?BR(t,n,r):i&&BR(t,i,s)}function U$e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=m2(n),s,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(k0(l,1))s=n,o=++r;else break}else{if(Fte(n))break;{let l=n.nextSibling;for(;l&&k0(l,1);)s=l.parentNode,o=Ra(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=m2(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}s&&BR(t,s,o)}function Fte(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function z$e(t,e){for(;t&&e==t.childNodes.length&&!xv(t);)e=Ra(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 B$e(t,e){for(;t&&!e&&!xv(t);)e=Ra(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 BR(t,e,n){if(e.nodeType!=3){let s,o;(o=z$e(e,n))?(e=o,n=0):(s=B$e(e,n))&&(e=s,n=s.nodeValue.length)}let r=t.domSelection();if(!r)return;if(TM(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&&ju(t)},50)}function x9(t,e){let n=t.state.doc.resolve(e);if(!(Ya||c$e)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let s=t.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<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),o=(s.top+s.bottom)/2;if(o>i.top&&o<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 b9(t,e,n){let r=t.state.selection;if(r instanceof pn&&!r.empty||n.indexOf("s")>-1||Vo&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=zR(t.state,e);if(o&&o instanceof Jt)return $d(t,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof bo?kn.near(o,e):kn.findFrom(o,e);return l?$d(t,l):!1}return!1}function y9(t,e){if(!(t.state.selection instanceof pn))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 o=t.state.tr;return e<0?o.delete(n.pos-s.nodeSize,n.pos):o.delete(n.pos,n.pos+s.nodeSize),t.dispatch(o),!0}return!1}function v9(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function $$e(t){if(!Ss||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;v9(t,r,"true"),setTimeout(()=>v9(t,r,"false"),20)}return!1}function H$e(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function V$e(t,e){let n=e.keyCode,r=H$e(e);if(n==8||Vo&&n==72&&r=="c")return y9(t,-1)||eg(t,-1);if(n==46&&!e.shiftKey||Vo&&n==68&&r=="c")return y9(t,1)||eg(t,1);if(n==13||n==27)return!0;if(n==37||Vo&&n==66&&r=="c"){let i=n==37?x9(t,t.state.selection.from)=="ltr"?-1:1:-1;return g9(t,i,r)||eg(t,i)}else if(n==39||Vo&&n==70&&r=="c"){let i=n==39?x9(t,t.state.selection.from)=="ltr"?1:-1:1;return g9(t,i,r)||eg(t,i)}else{if(n==38||Vo&&n==80&&r=="c")return b9(t,-1,r)||eg(t,-1);if(n==40||Vo&&n==78&&r=="c")return $$e(t)||b9(t,1,r)||eg(t,1);if(r==(Vo?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function kL(t,e){t.someProp("transformCopied",p=>{e=p(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 p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let o=t.someProp("clipboardSerializer")||jm.fromSchema(t.state.schema),l=Vte(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let u=c.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=Hte[u.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let x=l.createElement(d[p]);for(;c.firstChild;)x.appendChild(c.firstChild);c.appendChild(x),f++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${s}${f?` -${f}`:""} ${JSON.stringify(n)}`);let m=t.someProp("clipboardTextSerializer",p=>p(e,t))||e.content.textBetween(0,e.content.size,`
  8148. `);return{dom:c,text:m,slice:e}}function Ute(t,e,n,r,i){let s=i.parent.type.spec.code,o,l;if(!n&&!e)return null;let c=!!e&&(r||s||!n);if(c){if(t.someProp("transformPastedText",m=>{e=m(e,s||r,t)}),s)return l=new zt(Et.from(t.state.schema.text(e.replace(/\r\n?/g,`
  8149. `))),0,0),t.someProp("transformPasted",m=>{l=m(l,t,!0)}),l;let f=t.someProp("clipboardTextParser",m=>m(e,i,r,t));if(f)l=f;else{let m=i.marks(),{schema:p}=t.state,x=jm.fromSchema(p);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let y=o.appendChild(document.createElement("p"));b&&y.appendChild(x.serializeNode(p.text(b,m)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),o=K$e(n),bv&&X$e(o);let u=o&&o.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 m=o.firstChild;for(;m&&m.nodeType!=1;)m=m.nextSibling;if(!m)break;o=m}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||C0.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(m){return m.nodeName=="BR"&&!m.nextSibling&&m.parentNode&&!G$e.test(m.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Y$e(_9(l,+d[1],+d[2]),d[4]);else if(l=zt.maxOpen(q$e(l.content,i),!0),l.openStart||l.openEnd){let f=0,m=0;for(let p=l.content.firstChild;f<l.openStart&&!p.type.spec.isolating;f++,p=p.firstChild);for(let p=l.content.lastChild;m<l.openEnd&&!p.type.spec.isolating;m++,p=p.lastChild);l=_9(l,f,m)}return t.someProp("transformPasted",f=>{l=f(l,t,c)}),l}const G$e=/^(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 q$e(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,o=[];if(t.forEach(l=>{if(!o)return;let c=i.findWrapping(l.type),u;if(!c)return o=null;if(u=o.length&&s.length&&Bte(c,s,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=$te(o[o.length-1],s.length));let d=zte(l,c);o.push(d),i=i.matchType(d.type),s=c}}),o)return Et.from(o)}return t}function zte(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,Et.from(t));return t}function Bte(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=Bte(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(Et.from(zte(n,t,i+1))))}}function $te(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,$te(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(Et.empty,!0);return t.copy(n.append(r))}function $R(t,e,n,r,i,s){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(s=0),i<r-1&&(l=$R(l,e,n,r,i+1,s)),i>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(Et.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function _9(t,e,n){return e<t.openStart&&(t=new zt($R(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new zt($R(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Hte={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 w9=null;function Vte(){return w9||(w9=document.implementation.createHTMLDocument("title"))}let _j=null;function W$e(t){let e=window.trustedTypes;return e?(_j||(_j=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),_j.createHTML(t)):t}function K$e(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Vte().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&Hte[r[1].toLowerCase()])&&(t=i.map(s=>"<"+s+">").join("")+t+i.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=W$e(t),i)for(let s=0;s<i.length;s++)n=n.querySelector(i[s])||n;return n}function X$e(t){let e=t.querySelectorAll(Ya?"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 Y$e(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:o}=t;for(let l=r.length-2;l>=0;l-=2){let c=n.nodes[r[l]];if(!c||c.hasRequiredAttrs())break;i=Et.from(c.create(r[l+1],i)),s++,o++}return new zt(i,s,o)}const Ns={},Ms={},Q$e={touchstart:!0,touchmove:!0};class Z$e{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 J$e(t){for(let e in Ns){let n=Ns[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{tHe(t,r)&&!jL(t,r)&&(t.editable||!(r.type in Ms))&&n(t,r)},Q$e[e]?{passive:!0}:void 0)}Ss&&t.dom.addEventListener("input",()=>null),HR(t)}function th(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function eHe(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 HR(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>jL(t,r))})}function jL(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function tHe(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 nHe(t,e){!jL(t,e)&&Ns[e.type]&&(t.editable||!(e.type in Ms))&&Ns[e.type](t,e)}Ms.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!qte(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(wu&&Ya&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),ux&&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,Af(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||V$e(t,n)?n.preventDefault():th(t,"key")};Ms.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ms.keypress=(t,e)=>{let n=e;if(qte(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Vo&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof pn)||!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",o=>o(t,r.$from.pos,r.$to.pos,i,s))&&t.dispatch(s()),n.preventDefault()}};function kM(t){return{left:t.clientX,top:t.clientY}}function rHe(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function PL(t,e,n,r,i){if(r==-1)return!1;let s=t.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(t.someProp(e,l=>o>s.depth?l(t,n,s.nodeAfter,s.before(o),i,!0):l(t,n,s.node(o),s.before(o),i,!1)))return!0;return!1}function Og(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 iHe(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Jt.isSelectable(r)?(Og(t,new Jt(n)),!0):!1}function aHe(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Jt&&(r=n.node);let s=t.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(Jt.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?i=s.before(n.$from.depth):i=s.before(o);break}}return i!=null?(Og(t,Jt.create(t.state.doc,i)),!0):!1}function sHe(t,e,n,r,i){return PL(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(i?aHe(t,n):iHe(t,n))}function oHe(t,e,n,r){return PL(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function lHe(t,e,n,r){return PL(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||cHe(t,n,r)}function cHe(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Og(t,pn.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)Og(t,pn.create(r,l+1,l+1+o.content.size));else if(Jt.isSelectable(o))Og(t,Jt.create(r,l));else continue;return!0}}function RL(t){return p2(t)}const Gte=Vo?"metaKey":"ctrlKey";Ns.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=RL(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&rHe(n,t.input.lastClick)&&!n[Gte]&&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 o=t.posAtCoords(kM(n));o&&(s=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new uHe(t,o,n,!!r)):(s=="doubleClick"?oHe:lHe)(t,o.pos,o.inside,n)?n.preventDefault():th(t,"pointer"))};class uHe{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[Gte],this.allowDefault=r.shiftKey;let s,o;if(n.inside>-1)s=e.state.doc.nodeAt(n.inside),o=n.inside;else{let d=e.state.doc.resolve(n.pos);s=d.parent,o=d.depth?d.before():0}const l=i?null:r.target,c=l?e.docView.nearestDesc(l,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:u}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||u instanceof Jt&&u.from<=o&&u.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&nl&&!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)),th(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(()=>ju(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(kM(e))),this.updateAllowDefault(e),this.allowDefault||!n?th(this.view,"pointer"):sHe(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ss&&this.mightDrag&&!this.mightDrag.node.isAtom||Ya&&!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)?(Og(this.view,kn.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):th(this.view,"pointer")}move(e){this.updateAllowDefault(e),th(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)}}Ns.touchstart=t=>{t.input.lastTouch=Date.now(),RL(t),th(t,"pointer")};Ns.touchmove=t=>{t.input.lastTouch=Date.now(),th(t,"pointer")};Ns.contextmenu=t=>RL(t);function qte(t,e){return t.composing?!0:Ss&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const dHe=wu?5e3:-1;Ms.compositionstart=Ms.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof pn&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),p2(t,!0),t.markCursor=null;else if(p2(t,!e.selection.empty),nl&&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 o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}t.input.composing=!0}Wte(t,dHe)};Ms.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++,Wte(t,20))};function Wte(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>p2(t),e))}function Kte(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=fHe());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function hHe(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=i$e(e.focusNode,e.focusOffset),r=a$e(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 o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function fHe(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function p2(t,e=!1){if(!(wu&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Kte(t),e||t.docView&&t.docView.dirty){let n=TL(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 mHe(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 My=Hs&&fh<15||ux&&u$e<604;Ns.copy=Ms.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=My?null:n.clipboardData,o=r.content(),{dom:l,text:c}=kL(t,o);s?(n.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",c)):mHe(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function pHe(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function gHe(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?Ey(t,r.value,null,i,e):Ey(t,r.textContent,r.innerHTML,i,e)},50)}function Ey(t,e,n,r,i){let s=Ute(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,s||zt.empty)))return!0;if(!s)return!1;let o=pHe(s),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(s);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Xte(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," "):""}Ms.paste=(t,e)=>{let n=e;if(t.composing&&!wu)return;let r=My?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Ey(t,Xte(r),r.getData("text/html"),i,n)?n.preventDefault():gHe(t,n)};class Yte{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const xHe=Vo?"altKey":"ctrlKey";function Qte(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[xHe]}Ns.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(kM(n)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof Jt?i.to-1:i.to))){if(r&&r.mightDrag)o=Jt.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&&(o=Jt.create(t.state.doc,f.posBefore))}}let l=(o||t.state.selection).content(),{dom:c,text:u,slice:d}=kL(t,l);(!n.dataTransfer.files.length||!Ya||Ste>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(My?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",My||n.dataTransfer.setData("text/plain",u),t.dragging=new Yte(d,Qte(t,n),o)};Ns.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ms.dragover=Ms.dragenter=(t,e)=>e.preventDefault();Ms.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(kM(n));if(!i)return;let s=t.state.doc.resolve(i.pos),o=r&&r.slice;o?t.someProp("transformPasted",x=>{o=x(o,t,!1)}):o=Ute(t,Xte(n.dataTransfer),My?null:n.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&Qte(t,n));if(t.someProp("handleDrop",x=>x(t,n,o||zt.empty,l))){n.preventDefault();return}if(!o)return;n.preventDefault();let c=o?nte(t.state.doc,s.pos,o):s.pos;c==null&&(c=s.pos);let u=t.state.tr;if(l){let{node:x}=r;x?x.replace(u):u.deleteSelection()}let d=u.mapping.map(c),f=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,m=u.doc;if(f?u.replaceRangeWith(d,d,o.content.firstChild):u.replaceRange(d,d,o),u.doc.eq(m))return;let p=u.doc.resolve(d);if(f&&Jt.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))u.setSelection(new Jt(p));else{let x=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((b,y,v,S)=>x=S),u.setSelection(AL(t,p,u.doc.resolve(x)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};Ns.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())&&ju(t)},20))};Ns.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)};Ns.beforeinput=(t,e)=>{if(Ya&&wu&&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,Af(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 Ms)Ns[t]=Ms[t];function Cy(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 g2{constructor(e,n){this.toDOM=e,this.spec=n||Qf,this.side=this.spec.side||0}map(e,n,r,i){let{pos:s,deleted:o}=e.mapResult(n.from+i,this.side<0?-1:1);return o?null:new gs(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof g2&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Cy(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ph{constructor(e,n){this.attrs=e,this.spec=n||Qf}map(e,n,r,i){let s=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new gs(s,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof ph&&Cy(this.attrs,e.attrs)&&Cy(this.spec,e.spec)}static is(e){return e.type instanceof ph}destroy(){}}class DL{constructor(e,n){this.attrs=e,this.spec=n||Qf}map(e,n,r,i){let s=e.mapResult(n.from+i,1);if(s.deleted)return null;let o=e.mapResult(n.to+i,-1);return o.deleted||o.pos<=s.pos?null:new gs(s.pos-r,o.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 DL&&Cy(this.attrs,e.attrs)&&Cy(this.spec,e.spec)}destroy(){}}class gs{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new gs(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 gs(e,e,new g2(n,r))}static inline(e,n,r,i){return new gs(e,n,new ph(r,i))}static node(e,n,r,i){return new gs(e,n,new DL(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof ph}get widget(){return this.type instanceof g2}}const lg=[],Qf={};class ei{constructor(e,n){this.local=e.length?e:lg,this.children=n.length?n:lg}static create(e,n){return n.length?x2(n,e,0,Qf):Wa}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 o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,i+l,s)}}map(e,n,r){return this==Wa||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Qf)}mapInner(e,n,r,i,s){let o;for(let l=0;l<this.local.length;l++){let c=this.local[l].map(e,r,i);c&&c.type.valid(n,c)?(o||(o=[])).push(c):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?bHe(this.children,o||[],e,n,r,i,s):o?new ei(o.sort(Zf),lg):Wa}add(e,n){return n.length?this==Wa?ei.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,s=0;e.forEach((l,c)=>{let u=c+r,d;if(d=Jte(n,l,u)){for(i||(i=this.children.slice());s<i.length&&i[s]<c;)s+=3;i[s]==c?i[s+2]=i[s+2].addInner(l,d,u+1):i.splice(s,0,c,c+l.nodeSize,x2(d,l,u+1,Qf)),s+=3}});let o=Zte(s?ene(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new ei(o.length?this.local.concat(o).sort(Zf):this.local,i||this.children)}remove(e){return e.length==0||this==Wa?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 o,l=r[s]+n,c=r[s+1]+n;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>l&&f.to<c&&(e[d]=null,(o||(o=[])).push(f));if(!o)continue;r==this.children&&(r=this.children.slice());let u=r[s+2].removeInner(o,l+1);u!=Wa?r[s+2]=u:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,n)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new ei(i,r):Wa}forChild(e,n){if(this==Wa)return this;if(n.isLeaf)return ei.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,o=s+n.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<o&&c.to>s&&c.type instanceof ph){let u=Math.max(s,c.from)-s,d=Math.min(o,c.to)-s;u<d&&(i||(i=[])).push(c.copy(u,d))}}if(i){let l=new ei(i.sort(Zf),lg);return r?new Kd([l,r]):l}return r||Wa}eq(e){if(this==e)return!0;if(!(e instanceof ei)||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 OL(this.localsInner(e))}localsInner(e){if(this==Wa)return lg;if(e.inlineContent||!this.local.some(ph.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof ph||n.push(this.local[r]);return n}forEachSet(e){e(this)}}ei.empty=new ei([],[]);ei.removeOverlap=OL;const Wa=ei.empty;class Kd{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,Qf));return Kd.from(r)}forChild(e,n){if(n.isLeaf)return ei.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,n);s!=Wa&&(s instanceof Kd?r=r.concat(s.members):r.push(s))}return Kd.from(r)}eq(e){if(!(e instanceof Kd)||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 o=0;o<s.length;o++)n.push(s[o])}}return n?OL(r?n:n.sort(Zf)):lg}static from(e){switch(e.length){case 0:return Wa;case 1:return e[0];default:return new Kd(e.every(n=>n instanceof ei)?e:e.reduce((n,r)=>n.concat(r instanceof ei?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function bHe(t,e,n,r,i,s,o){let l=t.slice();for(let u=0,d=s;u<n.maps.length;u++){let f=0;n.maps[u].forEach((m,p,x,b)=>{let y=b-x-(p-m);for(let v=0;v<l.length;v+=3){let S=l[v+1];if(S<0||m>S+d-f)continue;let N=l[v]+d-f;p>=N?l[v+1]=m<=N?-2:-1:m>=d&&y&&(l[v]+=y,l[v+1]+=y)}f+=y}),d=n.maps[u].map(d,-1)}let c=!1;for(let u=0;u<l.length;u+=3)if(l[u+1]<0){if(l[u+1]==-2){c=!0,l[u+1]=-1;continue}let d=n.map(t[u]+s),f=d-i;if(f<0||f>=r.content.size){c=!0;continue}let m=n.map(t[u+1]+s,-1),p=m-i,{index:x,offset:b}=r.content.findIndex(f),y=r.maybeChild(x);if(y&&b==f&&b+y.nodeSize==p){let v=l[u+2].mapInner(n,y,d+1,t[u]+s+1,o);v!=Wa?(l[u]=f,l[u+1]=p,l[u+2]=v):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=yHe(l,t,e,n,i,s,o),d=x2(u,r,0,o);e=d.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,m=0;f<d.children.length;f+=3){let p=d.children[f];for(;m<l.length&&l[m]<p;)m+=3;l.splice(m,0,d.children[f],d.children[f+1],d.children[f+2])}}return new ei(e.sort(Zf),l)}function Zte(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 gs(i.from+e,i.to+e,i.type))}return n}function yHe(t,e,n,r,i,s,o){function l(c,u){for(let d=0;d<c.local.length;d++){let f=c.local[d].map(r,i,u);f?n.push(f):o.onRemove&&o.onRemove(c.local[d].spec)}for(let d=0;d<c.children.length;d+=3)l(c.children[d+2],c.children[d]+u+1)}for(let c=0;c<t.length;c+=3)t[c+1]==-1&&l(t[c+2],e[c]+s+1);return n}function Jte(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let s=0,o;s<t.length;s++)(o=t[s])&&o.from>n&&o.to<r&&((i||(i=[])).push(o),t[s]=null);return i}function ene(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function x2(t,e,n,r){let i=[],s=!1;e.forEach((l,c)=>{let u=Jte(t,l,c+n);if(u){s=!0;let d=x2(u,l,n+c+1,r);d!=Wa&&i.push(c,c+l.nodeSize,d)}});let o=Zte(s?ene(t):t,-n).sort(Zf);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new ei(o,i):Wa}function Zf(t,e){return t.from-e.from||t.to-e.to}function OL(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),S9(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),S9(e,i,r.copy(s.from,r.to)));break}}}return e}function S9(t,e,n){for(;e<t.length&&Zf(n,t[e])>0;)e++;t.splice(e,0,n)}function wj(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Wa&&e.push(r)}),t.cursorWrapper&&e.push(ei.create(t.state.doc,[t.cursorWrapper.deco])),Kd.from(e)}const vHe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},_He=Hs&&fh<=11;class wHe{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 SHe{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new wHe,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]);Hs&&fh<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),_He&&(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,vHe)),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(p9(this.view)){if(this.suppressingSelectionUpdates)return ju(this.view);if(Hs&&fh<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&wm(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=cx(s))n.add(s);for(let s=e.anchorNode;s;s=cx(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)&&p9(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,l=!1,c=[];if(e.editable)for(let d=0;d<n.length;d++){let f=this.registerMutation(n[d],c);f&&(s=s<0?f.from:Math.min(f.from,s),o=o<0?f.to:Math.max(f.to,o),f.typeOver&&(l=!0))}if(nl&&c.length){let d=c.filter(f=>f.nodeName=="BR");if(d.length==2){let[f,m]=d;f.parentNode&&f.parentNode.parentNode==m.parentNode?m.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let m of d){let p=m.parentNode;p&&p.nodeName=="LI"&&(!f||EHe(e,f)!=p)&&m.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&&TM(r)&&(u=TL(e))&&u.eq(kn.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ju(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),NHe(e)),this.handleDOMChange(s,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||ju(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(Hs&&fh<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:f,nextSibling:m}=e.addedNodes[d];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!m||Array.prototype.indexOf.call(e.addedNodes,m)<0)&&(s=m)}let o=i&&i.parentNode==e.target?Ra(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=s&&s.parentNode==e.target?Ra(s):e.target.childNodes.length,u=r.localPosFromDOM(e.target,c,1);return{from:l,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 N9=new WeakMap,M9=!1;function NHe(t){if(!N9.has(t)&&(N9.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=nl,M9)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."),M9=!0}}function E9(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return wm(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function MHe(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return E9(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?E9(t,n):null}function EHe(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 CHe(t,e,n){let{node:r,fromOffset:i,toOffset:s,from:o,to:l}=t.docView.parseRange(e,n),c=t.domSelectionRange(),u,d=c.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(u=[{node:d,offset:c.anchorOffset}],TM(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Ya&&t.input.lastKeyCode===8)for(let y=s;y>i;y--){let v=r.childNodes[y-1],S=v.pmViewDesc;if(v.nodeName=="BR"&&!S){s=y;break}if(!S||S.size)break}let f=t.state.doc,m=t.someProp("domParser")||C0.fromSchema(t.state.schema),p=f.resolve(o),x=null,b=m.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:s,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:THe,context:p});if(u&&u[0].pos!=null){let y=u[0].pos,v=u[1]&&u[1].pos;v==null&&(v=y),x={anchor:y+o,head:v+o}}return{doc:b,sel:x,from:o,to:l}}function THe(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ss&&/^(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||Ss&&/^(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 AHe=/^(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 kHe(t,e,n,r,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let E=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,D=TL(t,E);if(D&&!t.state.selection.eq(D)){if(Ya&&wu&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",R=>R(t,Af(13,"Enter"))))return;let A=t.state.tr.setSelection(D);E=="pointer"?A.setMeta("pointer",!0):E=="key"&&A.scrollIntoView(),s&&A.setMeta("composition",s),t.dispatch(A)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(n);e=o.before(l+1),n=t.state.doc.resolve(n).after(l+1);let c=t.state.selection,u=CHe(t,e,n),d=t.state.doc,f=d.slice(u.from,u.to),m,p;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(m=t.state.selection.to,p="end"):(m=t.state.selection.from,p="start"),t.input.lastKeyCode=null;let x=RHe(f.content,u.doc.content,u.from,m,p);if(x&&t.input.domChangeCount++,(ux&&t.input.lastIOSEnter>Date.now()-225||wu)&&i.some(E=>E.nodeType==1&&!AHe.test(E.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",E=>E(t,Af(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&c instanceof pn&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))x={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let E=C9(t,t.state.doc,u.sel);if(E&&!E.eq(t.state.selection)){let D=t.state.tr.setSelection(E);s&&D.setMeta("composition",s),t.dispatch(D)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof pn&&(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)),Hs&&fh<=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 b=u.doc.resolveNoCache(x.start-u.from),y=u.doc.resolveNoCache(x.endB-u.from),v=d.resolve(x.start),S=b.sameParent(y)&&b.parent.inlineContent&&v.end()>=x.endA;if((ux&&t.input.lastIOSEnter>Date.now()-225&&(!S||i.some(E=>E.nodeName=="DIV"||E.nodeName=="P"))||!S&&b.pos<u.doc.content.size&&(!b.sameParent(y)||!b.parent.inlineContent)&&b.pos<y.pos&&!/\S/.test(u.doc.textBetween(b.pos,y.pos,"","")))&&t.someProp("handleKeyDown",E=>E(t,Af(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&PHe(d,x.start,x.endA,b,y)&&t.someProp("handleKeyDown",E=>E(t,Af(8,"Backspace")))){wu&&Ya&&t.domObserver.suppressSelectionUpdates();return}Ya&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),wu&&!S&&b.start()!=y.start()&&y.parentOffset==0&&b.depth==y.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==x.endA&&(x.endB-=2,y=u.doc.resolveNoCache(x.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(E){return E(t,Af(13,"Enter"))})},20));let N=x.start,C=x.endA,T=E=>{let D=E||t.state.tr.replace(N,C,u.doc.slice(x.start-u.from,x.endB-u.from));if(u.sel){let A=C9(t,D.doc,u.sel);A&&!(Ya&&t.composing&&A.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(A.head==N||A.head==D.mapping.map(C)-1)||Hs&&A.empty&&A.head==N)&&D.setSelection(A)}return s&&D.setMeta("composition",s),D.scrollIntoView()},k;if(S)if(b.pos==y.pos){Hs&&fh<=11&&b.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>ju(t),20));let E=T(t.state.tr.delete(N,C)),D=d.resolve(x.start).marksAcross(d.resolve(x.endA));D&&E.ensureMarks(D),t.dispatch(E)}else if(x.endA==x.endB&&(k=jHe(b.parent.content.cut(b.parentOffset,y.parentOffset),v.parent.content.cut(v.parentOffset,x.endA-v.start())))){let E=T(t.state.tr);k.type=="add"?E.addMark(N,C,k.mark):E.removeMark(N,C,k.mark),t.dispatch(E)}else if(b.parent.child(b.index()).isText&&b.index()==y.index()-(y.textOffset?0:1)){let E=b.parent.textBetween(b.parentOffset,y.parentOffset),D=()=>T(t.state.tr.insertText(E,N,C));t.someProp("handleTextInput",A=>A(t,N,C,E,D))||t.dispatch(D())}else t.dispatch(T());else t.dispatch(T())}function C9(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:AL(t,e.resolve(n.anchor),e.resolve(n.head))}function jHe(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,s=r,o,l,c;for(let d=0;d<r.length;d++)i=r[d].removeFromSet(i);for(let d=0;d<n.length;d++)s=n[d].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",c=d=>d.mark(l.addToSet(d.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",c=d=>d.mark(l.removeFromSet(d.marks));else return null;let u=[];for(let d=0;d<e.childCount;d++)u.push(c(e.child(d)));if(Et.from(u).eq(t))return{mark:l,type:o}}function PHe(t,e,n,r,i){if(n-e<=i.pos-r.pos||Sj(r,!0,!1)<i.pos)return!1;let s=t.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&n==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=t.resolve(Sj(s,!0,!0));return!o.parent.isTextblock||o.pos>n||Sj(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Sj(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 RHe(t,e,n,r,i){let s=t.findDiffStart(e,n);if(s==null)return null;let{a:o,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let c=Math.max(0,s-Math.min(o,l));r-=o+c-s}if(o<s&&t.size<e.size){let c=r<=s&&r>=o?s-r:0;s-=c,s&&s<e.size&&T9(e.textBetween(s-1,s+1))&&(s+=c?1:-1),l=s+(l-o),o=s}else if(l<s){let c=r<=s&&r>=l?s-r:0;s-=c,s&&s<t.size&&T9(t.textBetween(s-1,s+1))&&(s+=c?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function T9(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 tne{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 Z$e,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(R9),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=j9(this),k9(this),this.nodeViews=P9(this),this.docView=c9(this.state.doc,A9(this),wj(this),this.dom,this),this.domObserver=new SHe(this,(r,i,s,o)=>kHe(this,r,i,s,o)),this.domObserver.start(),J$e(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&&HR(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(R9),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,o=!1;e.storedMarks&&this.composing&&(Kte(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let p=P9(this);OHe(p,this.nodeViews)&&(this.nodeViews=p,s=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&HR(this),this.editable=j9(this),k9(this);let c=wj(this),u=A9(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=s||!this.docView.matchesNode(e.doc,u,c);(f||!e.selection.eq(i.selection))&&(o=!0);let m=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&f$e(this);if(o){this.domObserver.stop();let p=f&&(Hs||Ya)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&DHe(i.selection,e.selection);if(f){let x=Ya?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=hHe(this)),(s||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=c9(e.doc,u,c,this.dom,this)),x&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&I$e(this))?ju(this,p):(Lte(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():m&&m$e(m)}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 Jt){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&r9(this,n.getBoundingClientRect(),e)}else r9(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 Yte(e.slice,e.move,i<0?void 0:Jt.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 o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=n?n(l):l))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if(Hs){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&&p$e(this.dom),ju(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 v$e(this,e)}coordsAtPos(e,n=1){return Tte(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 M$e(this,n||this.state,e)}pasteHTML(e,n){return Ey(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Ey(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return kL(this,e)}destroy(){this.docView&&(eHe(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],wj(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,n$e())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return nHe(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ss&&this.root.nodeType===11&&o$e(this.dom.ownerDocument)==this.dom&&MHe(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}tne.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function A9(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"),[gs.node(0,t.state.doc.content.size,e)]}function k9(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:gs.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function j9(t){return!t.someProp("editable",e=>e(t.state)===!1)}function DHe(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 P9(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 OHe(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 R9(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 Ph={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:"'"},b2={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},LHe=typeof navigator<"u"&&/Mac/.test(navigator.platform),IHe=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Da=0;Da<10;Da++)Ph[48+Da]=Ph[96+Da]=String(Da);for(var Da=1;Da<=24;Da++)Ph[Da+111]="F"+Da;for(var Da=65;Da<=90;Da++)Ph[Da]=String.fromCharCode(Da+32),b2[Da]=String.fromCharCode(Da);for(var Nj in Ph)b2.hasOwnProperty(Nj)||(b2[Nj]=Ph[Nj]);function FHe(t){var e=LHe&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||IHe&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?b2:Ph)[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 UHe=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),zHe=typeof navigator<"u"&&/Win/.test(navigator.platform);function BHe(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,s,o;for(let l=0;l<e.length-1;l++){let c=e[l];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))UHe?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),o&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function $He(t){let e=Object.create(null);for(let n in t)e[BHe(n)]=t[n];return e}function Mj(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 HHe(t){return new ai({props:{handleKeyDown:nne(t)}})}function nne(t){let e=$He(t);return function(n,r){let i=FHe(r),s,o=e[Mj(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Mj(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(zHe&&r.ctrlKey&&r.altKey)&&(s=Ph[r.keyCode])&&s!=i){let l=e[Mj(s,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var VHe=Object.defineProperty,LL=(t,e)=>{for(var n in e)VHe(t,n,{get:e[n],enumerable:!0})};function jM(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 PM=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(([o,l])=>[o,(...u)=>{const d=l(...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,o=[],l=!!t,c=t||i.tr,u=()=>(!l&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),o.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(n).map(([f,m])=>[f,(...x)=>{const b=this.buildProps(c,e),y=m(...x)(b);return o.push(y),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(([l,c])=>[l,(...u)=>c(...u)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o={tr:t,editor:r,view:s,state:jM({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(([l,c])=>[l,(...u)=>c(...u)(o)]))}};return o}},rne={};LL(rne,{blur:()=>GHe,clearContent:()=>qHe,clearNodes:()=>WHe,command:()=>KHe,createParagraphNear:()=>XHe,cut:()=>YHe,deleteCurrentNode:()=>QHe,deleteNode:()=>ZHe,deleteRange:()=>JHe,deleteSelection:()=>eVe,enter:()=>tVe,exitCode:()=>nVe,extendMarkRange:()=>rVe,first:()=>iVe,focus:()=>sVe,forEach:()=>oVe,insertContent:()=>lVe,insertContentAt:()=>dVe,joinBackward:()=>mVe,joinDown:()=>fVe,joinForward:()=>pVe,joinItemBackward:()=>gVe,joinItemForward:()=>xVe,joinTextblockBackward:()=>bVe,joinTextblockForward:()=>yVe,joinUp:()=>hVe,keyboardShortcut:()=>_Ve,lift:()=>wVe,liftEmptyBlock:()=>SVe,liftListItem:()=>NVe,newlineInCode:()=>MVe,resetAttributes:()=>EVe,scrollIntoView:()=>CVe,selectAll:()=>TVe,selectNodeBackward:()=>AVe,selectNodeForward:()=>kVe,selectParentNode:()=>jVe,selectTextblockEnd:()=>PVe,selectTextblockStart:()=>RVe,setContent:()=>DVe,setMark:()=>ZVe,setMeta:()=>JVe,setNode:()=>e7e,setNodeSelection:()=>t7e,setTextDirection:()=>n7e,setTextSelection:()=>r7e,sinkListItem:()=>i7e,splitBlock:()=>a7e,splitListItem:()=>s7e,toggleList:()=>o7e,toggleMark:()=>l7e,toggleNode:()=>c7e,toggleWrap:()=>u7e,undoInputRule:()=>d7e,unsetAllMarks:()=>h7e,unsetMark:()=>f7e,unsetTextDirection:()=>m7e,updateAttributes:()=>p7e,wrapIn:()=>g7e,wrapInList:()=>x7e});var GHe=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),qHe=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),WHe=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:s,$to:o})=>{t.doc.nodesBetween(s.pos,o.pos,(l,c)=>{if(l.type.isText)return;const{doc:u,mapping:d}=e,f=u.resolve(d.map(c)),m=u.resolve(d.map(c+l.nodeSize)),p=f.blockRange(m);if(!p)return;const x=Ox(p);if(l.type.isTextblock){const{defaultType:b}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(p.start,b)}(x||x===0)&&e.lift(p,x)})}),!0},KHe=t=>e=>t(e),XHe=()=>({state:t,dispatch:e})=>bte(t,e),YHe=(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 o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new pn(r.doc.resolve(Math.max(o-1,0)))),!0},QHe=()=>({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 l=i.before(s),c=i.after(s);t.delete(l,c).scrollIntoView()}return!0}return!1};function zi(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 ZHe=t=>({tr:e,state:n,dispatch:r})=>{const i=zi(t,n.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(r){const c=s.before(o),u=s.after(o);e.delete(c,u).scrollIntoView()}return!0}return!1},JHe=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},eVe=()=>({state:t,dispatch:e})=>wL(t,e),tVe=()=>({commands:t})=>t.keyboardShortcut("Enter"),nVe=()=>({state:t,dispatch:e})=>B6e(t,e);function IL(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function y2(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:IL(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function ine(t,e,n={}){return t.find(r=>r.type===e&&y2(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function D9(t,e,n={}){return!!ine(t,e,n)}function FL(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),!ine([...i.node.marks],e,n)))return;let o=i.index,l=t.start()+i.offset,c=o+1,u=l+i.node.nodeSize;for(;o>0&&D9([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;c<t.parent.childCount&&D9([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function Xu(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 rVe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const s=Xu(t,r.schema),{doc:o,selection:l}=n,{$from:c,from:u,to:d}=l;if(i){const f=FL(c,s,e);if(f&&f.from<=u&&f.to>=d){const m=pn.create(o,f.from,f.to);n.setSelection(m)}}return!0},iVe=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 ane(t){return t instanceof pn}function Ff(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function sne(t,e=null){if(!e)return null;const n=kn.atStart(t),r=kn.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,s=r.to;return e==="all"?pn.create(t,Ff(0,i,s),Ff(t.content.size,i,s)):pn.create(t,Ff(e,i,s),Ff(e,i,s))}function aVe(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function UL(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var sVe=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(UL()||aVe())&&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&&!ane(n.state.selection))return o(),!0;const l=sne(i.doc,t)||n.state.selection,c=n.state.selection.eq(l);return s&&(c||i.setSelection(l),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},oVe=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),lVe=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),one=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&&one(r)}return t};function n1(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 one(n)}function Ty(t,e,n){if(t instanceof hh||t instanceof Et)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 Et.fromArray(t.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}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),Ty("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const c=new Gee({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=>(o=!0,l=typeof u=="string"?u:u.outerHTML,null)}]}})});if(n.slice?C0.fromSchema(c).parseSlice(n1(t),n.parseOptions):C0.fromSchema(c).parse(n1(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=C0.fromSchema(e);return n.slice?s.parseSlice(n1(t),n.parseOptions).content:s.parse(n1(t),n.parseOptions)}return Ty("",e,n)}function cVe(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof ma||i instanceof ba))return;const s=t.mapping.maps[r];let o=0;s.forEach((l,c,u,d)=>{o===0&&(o=d)}),t.setSelection(kn.near(t.doc.resolve(o),n))}var uVe=t=>!("type"in t),dVe=(t,e,n)=>({tr:r,dispatch:i,editor:s})=>{var o;if(i){n={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const c=y=>{s.emit("contentError",{editor:s,error:y,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{Ty(e,s.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(y){c(y)}try{l=Ty(e,s.schema,{parseOptions:u,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(y){return c(y),!1}let{from:d,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},m=!0,p=!0;if((uVe(l)?l:[l]).forEach(y=>{y.check(),m=m?y.isText&&y.marks.length===0:!1,p=p?y.isBlock:!1}),d===f&&p){const{parent:y}=r.doc.resolve(d);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(d-=1,f+=1)}let b;if(m){if(Array.isArray(e))b=e.map(y=>y.text||"").join("");else if(e instanceof Et){let y="";e.forEach(v=>{v.text&&(y+=v.text)}),b=y}else typeof e=="object"&&e&&e.text?b=e.text:b=e;r.insertText(b,d,f)}else{b=l;const y=r.doc.resolve(d),v=y.node(),S=y.parentOffset===0,N=v.isText||v.isTextblock,C=v.content.size>0;S&&N&&C&&(d=Math.max(0,d-1)),r.replaceWith(d,f,b)}n.updateSelection&&cVe(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:b}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:b})}return!0},hVe=()=>({state:t,dispatch:e})=>F6e(t,e),fVe=()=>({state:t,dispatch:e})=>U6e(t,e),mVe=()=>({state:t,dispatch:e})=>dte(t,e),pVe=()=>({state:t,dispatch:e})=>pte(t,e),gVe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=MM(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},xVe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=MM(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},bVe=()=>({state:t,dispatch:e})=>L6e(t,e),yVe=()=>({state:t,dispatch:e})=>I6e(t,e);function lne(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function vVe(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,s,o;for(let l=0;l<e.length-1;l+=1){const c=e[l];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))UL()||lne()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),s&&(n=`Shift-${n}`),n}var _Ve=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=vVe(t).split(/-(?!$)/),o=s.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{n.someProp("handleKeyDown",u=>u(n,l))});return c?.steps.forEach(u=>{const d=u.map(r.mapping);d&&i&&r.maybeStep(d)}),!0};function Rh(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,o=e?zi(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(f,m)=>{if(f.isText)return;const p=Math.max(r,m),x=Math.min(i,m+f.nodeSize);l.push({node:f,from:p,to:x})});const c=i-r,u=l.filter(f=>o?o.name===f.node.type.name:!0).filter(f=>y2(f.node.attrs,n,{strict:!1}));return s?!!u.length:u.reduce((f,m)=>f+m.to-m.from,0)>=c}var wVe=(t,e={})=>({state:n,dispatch:r})=>{const i=zi(t,n.schema);return Rh(n,i,e)?z6e(n,r):!1},SVe=()=>({state:t,dispatch:e})=>yte(t,e),NVe=t=>({state:e,dispatch:n})=>{const r=zi(t,e.schema);return Z6e(r)(e,n)},MVe=()=>({state:t,dispatch:e})=>xte(t,e);function RM(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function O9(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 EVe=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=RM(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(s=zi(t,r.schema)),l==="mark"&&(o=Xu(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,f)=>{s&&s===d.type&&(c=!0,i&&n.setNodeMarkup(f,void 0,O9(d.attrs,e))),o&&d.marks.length&&d.marks.forEach(m=>{o===m.type&&(c=!0,i&&n.addMark(f,f+d.nodeSize,o.create(O9(m.attrs,e))))})})}),c},CVe=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),TVe=()=>({tr:t,dispatch:e})=>{if(e){const n=new bo(t.doc);t.setSelection(n)}return!0},AVe=()=>({state:t,dispatch:e})=>fte(t,e),kVe=()=>({state:t,dispatch:e})=>gte(t,e),jVe=()=>({state:t,dispatch:e})=>V6e(t,e),PVe=()=>({state:t,dispatch:e})=>W6e(t,e),RVe=()=>({state:t,dispatch:e})=>q6e(t,e);function VR(t,e,n={},r={}){return Ty(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var DVe=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{const{doc:c}=s;if(r.preserveWhitespace!=="full"){const u=VR(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&s.replaceWith(0,c.content.size,u).setMeta("preventUpdate",!n),!0}return o&&s.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:c.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function cne(t,e){const n=Xu(e,t.schema),{from:r,to:i,empty:s}=t.selection,o=[];s?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,c=>{o.push(...c.marks)});const l=o.find(c=>c.type.name===n.name);return l?{...l.attrs}:{}}function une(t,e){const n=new ote(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function OVe(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 LVe(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,s)=>{n(i)&&r.push({node:i,pos:s})}),r}function IVe(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 DM(t){return e=>IVe(e.$from,t)}function Qt(t,e,n){return t.config[e]===void 0&&t.parent?Qt(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Qt(t.parent,e,n):null}):t.config[e]}function zL(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Qt(e,"addExtensions",n);return r?[e,...zL(r())]:e}).flat(10)}function BL(t,e){const n=jm.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function dne(t){return typeof t=="function"}function mr(t,e=void 0,...n){return dne(t)?e?t.bind(e)(...n):t(...n):t}function FVe(t={}){return Object.keys(t).length===0&&t.constructor===Object}function dx(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 hne(t){const e=[],{nodeExtensions:n,markExtensions:r}=dx(t),i=[...n,...r],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage,extensions:i},c=Qt(o,"addGlobalAttributes",l);if(!c)return;c().forEach(d=>{d.types.forEach(f=>{Object.entries(d.attributes).forEach(([m,p])=>{e.push({type:f,name:m,attribute:{...s,...p}})})})})}),i.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},c=Qt(o,"addAttributes",l);if(!c)return;const u=c();Object.entries(u).forEach(([d,f])=>{const m={...s,...f};typeof m?.default=="function"&&(m.default=m.default()),m?.isRequired&&m?.default===void 0&&delete m.default,e.push({type:o.name,name:d,attribute:m})})}),e}function gi(...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 l=s?String(s).split(" "):[],c=r[i]?r[i].split(" "):[],u=l.filter(d=>!c.includes(d));r[i]=[...c,...u].join(" ")}else if(i==="style"){const l=s?s.split(";").map(d=>d.trim()).filter(Boolean):[],c=r[i]?r[i].split(";").map(d=>d.trim()).filter(Boolean):[],u=new Map;c.forEach(d=>{const[f,m]=d.split(":").map(p=>p.trim());u.set(f,m)}),l.forEach(d=>{const[f,m]=d.split(":").map(p=>p.trim());u.set(f,m)}),r[i]=Array.from(u.entries()).map(([d,f])=>`${d}: ${f}`).join("; ")}else r[i]=s}),r},{})}function v2(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)=>gi(n,r),{})}function UVe(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function L9(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,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):UVe(n.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...r,...i}}}}function I9(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&FVe(n)?!1:n!=null))}function F9(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 zVe(t,e){var n;const r=hne(t),{nodeExtensions:i,markExtensions:s}=dx(t),o=(n=i.find(u=>Qt(u,"topNode")))==null?void 0:n.name,l=Object.fromEntries(i.map(u=>{const d=r.filter(v=>v.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},m=t.reduce((v,S)=>{const N=Qt(S,"extendNodeSchema",f);return{...v,...N?N(u):{}}},{}),p=I9({...m,content:mr(Qt(u,"content",f)),marks:mr(Qt(u,"marks",f)),group:mr(Qt(u,"group",f)),inline:mr(Qt(u,"inline",f)),atom:mr(Qt(u,"atom",f)),selectable:mr(Qt(u,"selectable",f)),draggable:mr(Qt(u,"draggable",f)),code:mr(Qt(u,"code",f)),whitespace:mr(Qt(u,"whitespace",f)),linebreakReplacement:mr(Qt(u,"linebreakReplacement",f)),defining:mr(Qt(u,"defining",f)),isolating:mr(Qt(u,"isolating",f)),attrs:Object.fromEntries(d.map(F9))}),x=mr(Qt(u,"parseHTML",f));x&&(p.parseDOM=x.map(v=>L9(v,d)));const b=Qt(u,"renderHTML",f);b&&(p.toDOM=v=>b({node:v,HTMLAttributes:v2(v,d)}));const y=Qt(u,"renderText",f);return y&&(p.toText=y),[u.name,p]})),c=Object.fromEntries(s.map(u=>{const d=r.filter(y=>y.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},m=t.reduce((y,v)=>{const S=Qt(v,"extendMarkSchema",f);return{...y,...S?S(u):{}}},{}),p=I9({...m,inclusive:mr(Qt(u,"inclusive",f)),excludes:mr(Qt(u,"excludes",f)),group:mr(Qt(u,"group",f)),spanning:mr(Qt(u,"spanning",f)),code:mr(Qt(u,"code",f)),attrs:Object.fromEntries(d.map(F9))}),x=mr(Qt(u,"parseHTML",f));x&&(p.parseDOM=x.map(y=>L9(y,d)));const b=Qt(u,"renderHTML",f);return b&&(p.toDOM=y=>b({mark:y,HTMLAttributes:v2(y,d)})),[u.name,p]}));return new Gee({topNode:o,nodes:l,marks:c})}function BVe(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function $L(t){return t.sort((n,r)=>{const i=Qt(n,"priority")||100,s=Qt(r,"priority")||100;return i>s?-1:i<s?1:0})}function fne(t){const e=$L(zL(t)),n=BVe(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 mne(t,e,n){const{from:r,to:i}=e,{blockSeparator:s=`
  8150. `,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,i,(c,u,d,f)=>{var m;c.isBlock&&u>r&&(l+=s);const p=o?.[c.type.name];if(p)return d&&(l+=p({node:c,pos:u,parent:d,index:f,range:e})),!1;c.isText&&(l+=(m=c?.text)==null?void 0:m.slice(Math.max(r,u)-u,i-u))}),l}function $Ve(t,e){const n={from:0,to:t.content.size};return mne(t,n,e)}function pne(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function HVe(t,e){const n=zi(e,t.schema),{from:r,to:i}=t.selection,s=[];t.doc.nodesBetween(r,i,l=>{s.push(l)});const o=s.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function gne(t,e){const n=RM(typeof e=="string"?e:e.name,t.schema);return n==="node"?HVe(t,e):n==="mark"?cne(t,e):{}}function VVe(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 GVe(t){const e=VVe(t);return e.length===1?e:e.filter((n,r)=>!e.filter((s,o)=>o!==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 xne(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((l,c)=>{o.push({from:l,to:c})});else{const{from:l,to:c}=n[s];if(l===void 0||c===void 0)return;o.push({from:l,to:c})}o.forEach(({from:l,to:c})=>{const u=e.slice(s).map(l,-1),d=e.slice(s).map(c),f=e.invert().map(u,-1),m=e.invert().map(d);r.push({oldRange:{from:f,to:m},newRange:{from:u,to:d}})})}),GVe(r)}function HL(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const s=n.resolve(t),o=FL(s,i.type);o&&r.push({mark:i,...o})}):n.nodesBetween(t,e,(i,s)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),r}var qVe=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let s=r,o=null;for(;s>0&&o===null;){const l=i.node(s);l?.type.name===e?o=l:s-=1}return[o,s]};function Ej(t,e){return e.nodes[t]||e.marks[t]||null}function L1(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 WVe=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,s,o,l)=>{var c,u;const d=((u=(c=i.type.spec).toText)==null?void 0:u.call(c,{node:i,pos:s,parent:o,index:l}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-s))}),n};function GR(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?Xu(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>s?s.name===f.type.name:!0).find(f=>y2(f.attrs,n,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:f,$to:m})=>{const p=f.pos,x=m.pos;t.doc.nodesBetween(p,x,(b,y)=>{if(!b.isText&&!b.marks.length)return;const v=Math.max(p,y),S=Math.min(x,y+b.nodeSize),N=S-v;o+=N,l.push(...b.marks.map(C=>({mark:C,from:v,to:S})))})}),o===0)return!1;const c=l.filter(f=>s?s.name===f.mark.type.name:!0).filter(f=>y2(f.mark.attrs,n,{strict:!1})).reduce((f,m)=>f+m.to-m.from,0),u=l.filter(f=>s?f.mark.type!==s&&f.mark.type.excludes(s):!0).reduce((f,m)=>f+m.to-m.from,0);return(c>0?c+u:c)>=o}function KVe(t,e,n={}){if(!e)return Rh(t,null,n)||GR(t,null,n);const r=RM(e,t.schema);return r==="node"?Rh(t,e,n):r==="mark"?GR(t,e,n):!1}var XVe=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const s=DM(l=>l.type.name===e)(t.selection);if(!s)return!1;const o=t.doc.resolve(s.pos+1);return i.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},YVe=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function U9(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function z9(t,e){const{nodeExtensions:n}=dx(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=mr(Qt(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function OM(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&&(OM(s,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function bne(t){return t instanceof Jt}function QVe(t,e,n){var r;const{selection:i}=e;let s=null;if(ane(i)&&(s=i.$cursor),s){const l=(r=t.storedMarks)!=null?r:s.marks();return s.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(u=>u.type.excludes(n)))}const{ranges:o}=i;return o.some(({$from:l,$to:c})=>{let u=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,c.pos,(d,f,m)=>{if(u)return!1;if(d.isInline){const p=!m||m.type.allowsMarkType(n),x=!!n.isInSet(d.marks)||!d.marks.some(b=>b.type.excludes(n));u=p&&x}return!u}),u})}var ZVe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:o,ranges:l}=s,c=Xu(t,r.schema);if(i)if(o){const u=cne(r,c);n.addStoredMark(c.create({...u,...e}))}else l.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;r.doc.nodesBetween(d,f,(m,p)=>{const x=Math.max(p,d),b=Math.min(p+m.nodeSize,f);m.marks.find(v=>v.type===c)?m.marks.forEach(v=>{c===v.type&&n.addMark(x,b,c.create({...v.attrs,...e}))}):n.addMark(x,b,c.create(e))})});return QVe(r,n,c)},JVe=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),e7e=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=zi(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:l})=>e9(s,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>e9(s,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},t7e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=Ff(t,0,r.content.size),s=Jt.create(r,i);e.setSelection(s)}return!0},n7e=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=r;let o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=s.from,l=s.to),i&&n.doc.nodesBetween(o,l,(c,u)=>{c.isText||n.setNodeMarkup(u,void 0,{...c.attrs,dir:t})}),!0},r7e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:s}=typeof t=="number"?{from:t,to:t}:t,o=pn.atStart(r).from,l=pn.atEnd(r).to,c=Ff(i,o,l),u=Ff(s,o,l),d=pn.create(r,c,u);e.setSelection(d)}return!0},i7e=t=>({state:e,dispatch:n})=>{const r=zi(t,e.schema);return t$e(r)(e,n)};function B9(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 a7e=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:c}=s,u=i.extensionManager.attributes,d=L1(u,l.node().type.name,l.node().attrs);if(s instanceof Jt&&s.node.isBlock)return!l.parentOffset||!ku(o,l.pos)?!1:(r&&(t&&B9(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,m=l.depth===0?void 0:OVe(l.node(-1).contentMatchAt(l.indexAfter(-1)));let p=f&&m?[{type:m,attrs:d}]:void 0,x=ku(e.doc,e.mapping.map(l.pos),1,p);if(!p&&!x&&ku(e.doc,e.mapping.map(l.pos),1,m?[{type:m}]:void 0)&&(x=!0,p=m?[{type:m,attrs:d}]:void 0),r){if(x&&(s instanceof pn&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,p),m&&!f&&!l.parentOffset&&l.parent.type!==m)){const b=e.mapping.map(l.before()),y=e.doc.resolve(b);l.node(-1).canReplaceWith(y.index(),y.index()+1,m)&&e.setNodeMarkup(e.mapping.map(l.before()),m)}t&&B9(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},s7e=(t,e={})=>({tr:n,state:r,dispatch:i,editor:s})=>{var o;const l=zi(t,r.schema),{$from:c,$to:u}=r.selection,d=r.selection.node;if(d&&d.isBlock||c.depth<2||!c.sameParent(u))return!1;const f=c.node(-1);if(f.type!==l)return!1;const m=s.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(i){let v=Et.empty;const S=c.index(-1)?1:c.index(-2)?2:3;for(let D=c.depth-S;D>=c.depth-3;D-=1)v=Et.from(c.node(D).copy(v));const N=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,C={...L1(m,c.node().type.name,c.node().attrs),...e},T=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(C))||void 0;v=v.append(Et.from(l.createAndFill(null,T)||void 0));const k=c.before(c.depth-(S-1));n.replace(k,c.after(-N),new zt(v,4-S,0));let E=-1;n.doc.nodesBetween(k,n.doc.content.size,(D,A)=>{if(E>-1)return!1;D.isTextblock&&D.content.size===0&&(E=A+1)}),E>-1&&n.setSelection(pn.near(n.doc.resolve(E))),n.scrollIntoView()}return!0}const p=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,x={...L1(m,f.type.name,f.attrs),...e},b={...L1(m,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,u.pos);const y=p?[{type:l,attrs:x},{type:p,attrs:b}]:[{type:l,attrs:x}];if(!ku(n.doc,c.pos,2))return!1;if(i){const{selection:v,storedMarks:S}=r,{splittableMarks:N}=s.extensionManager,C=S||v.$to.parentOffset&&v.$from.marks();if(n.split(c.pos,2,y).scrollIntoView(),!C||!i)return!0;const T=C.filter(k=>N.includes(k.type.name));n.ensureMarks(T)}return!0},Cj=(t,e)=>{const n=DM(o=>o.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&&zh(t.doc,n.pos)&&t.join(n.pos),!0},Tj=(t,e)=>{const n=DM(o=>o.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&&zh(t.doc,r)&&t.join(r),!0},o7e=(t,e,n,r={})=>({editor:i,tr:s,state:o,dispatch:l,chain:c,commands:u,can:d})=>{const{extensions:f,splittableMarks:m}=i.extensionManager,p=zi(t,o.schema),x=zi(e,o.schema),{selection:b,storedMarks:y}=o,{$from:v,$to:S}=b,N=v.blockRange(S),C=y||b.$to.parentOffset&&b.$from.marks();if(!N)return!1;const T=DM(k=>z9(k.type.name,f))(b);if(N.depth>=1&&T&&N.depth-T.depth<=1){if(T.node.type===p)return u.liftListItem(x);if(z9(T.node.type.name,f)&&p.validContent(T.node.content)&&l)return c().command(()=>(s.setNodeMarkup(T.pos,p),!0)).command(()=>Cj(s,p)).command(()=>Tj(s,p)).run()}return!n||!C||!l?c().command(()=>d().wrapInList(p,r)?!0:u.clearNodes()).wrapInList(p,r).command(()=>Cj(s,p)).command(()=>Tj(s,p)).run():c().command(()=>{const k=d().wrapInList(p,r),E=C.filter(D=>m.includes(D.type.name));return s.ensureMarks(E),k?!0:u.clearNodes()}).wrapInList(p,r).command(()=>Cj(s,p)).command(()=>Tj(s,p)).run()},l7e=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,o=Xu(t,r.schema);return GR(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},c7e=(t,e,n={})=>({state:r,commands:i})=>{const s=zi(t,r.schema),o=zi(e,r.schema),l=Rh(r,s,n);let c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),l?i.setNode(o,c):i.setNode(s,{...c,...n})},u7e=(t,e={})=>({state:n,commands:r})=>{const i=zi(t,n.schema);return Rh(n,i,e)?r.lift(i):r.wrapIn(i,e)},d7e=()=>({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 o=t.tr,l=s.transform;for(let c=l.steps.length-1;c>=0;c-=1)o.step(l.steps[c].invert(l.docs[c]));if(s.text){const c=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,t.schema.text(s.text,c))}else o.delete(s.from,s.to)}return!0}}return!1},h7e=()=>({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},f7e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,c=Xu(t,r.schema),{$from:u,empty:d,ranges:f}=l;if(!i)return!0;if(d&&o){let{from:m,to:p}=l;const x=(s=u.marks().find(y=>y.type===c))==null?void 0:s.attrs,b=FL(u,c,x);b&&(m=b.from,p=b.to),n.removeMark(m,p,c)}else f.forEach(m=>{n.removeMark(m.$from.pos,m.$to.pos,c)});return n.removeStoredMark(c),!0},m7e=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let s,o;return typeof t=="number"?(s=t,o=t):t&&"from"in t&&"to"in t?(s=t.from,o=t.to):(s=i.from,o=i.to),r&&e.doc.nodesBetween(s,o,(l,c)=>{if(l.isText)return;const u={...l.attrs};delete u.dir,e.setNodeMarkup(c,void 0,u)}),!0},p7e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=RM(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(s=zi(t,r.schema)),l==="mark"&&(o=Xu(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;let m,p,x,b;n.selection.empty?r.doc.nodesBetween(d,f,(y,v)=>{s&&s===y.type&&(c=!0,x=Math.max(v,d),b=Math.min(v+y.nodeSize,f),m=v,p=y)}):r.doc.nodesBetween(d,f,(y,v)=>{v<d&&s&&s===y.type&&(c=!0,x=Math.max(v,d),b=Math.min(v+y.nodeSize,f),m=v,p=y),v>=d&&v<=f&&(s&&s===y.type&&(c=!0,i&&n.setNodeMarkup(v,void 0,{...y.attrs,...e})),o&&y.marks.length&&y.marks.forEach(S=>{if(o===S.type&&(c=!0,i)){const N=Math.max(v,d),C=Math.min(v+y.nodeSize,f);n.addMark(N,C,o.create({...S.attrs,...e}))}}))}),p&&(m!==void 0&&i&&n.setNodeMarkup(m,void 0,{...p.attrs,...e}),o&&p.marks.length&&p.marks.forEach(y=>{o===y.type&&i&&n.addMark(x,b,o.create({...y.attrs,...e}))}))}),c},g7e=(t,e={})=>({state:n,dispatch:r})=>{const i=zi(t,n.schema);return K6e(i,e)(n,r)},x7e=(t,e={})=>({state:n,dispatch:r})=>{const i=zi(t,n.schema);return X6e(i,e)(n,r)},b7e=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},LM=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},y7e=(t,e)=>{if(IL(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 r1(t){var e;const{editor:n,from:r,to:i,text:s,rules:o,plugin:l}=t,{view:c}=n;if(c.composing)return!1;const u=c.state.doc.resolve(r);if(u.parent.type.spec.code||(e=u.nodeBefore||u.nodeAfter)!=null&&e.marks.find(m=>m.type.spec.code))return!1;let d=!1;const f=WVe(u)+s;return o.forEach(m=>{if(d)return;const p=y7e(f,m.find);if(!p)return;const x=c.state.tr,b=jM({state:c.state,transaction:x}),y={from:r-(p[0].length-s.length),to:i},{commands:v,chain:S,can:N}=new PM({editor:n,state:b});m.handler({state:b,range:y,match:p,commands:v,chain:S,can:N})===null||!x.steps.length||(m.undoable&&x.setMeta(l,{transform:x,from:r,to:i,text:s}),c.dispatch(x),d=!0)}),d}function v7e(t){const{editor:e,rules:n}=t,r=new ai({state:{init(){return null},apply(i,s,o){const l=i.getMeta(r);if(l)return l;const c=i.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:d}=c;typeof d=="string"?d=d:d=BL(Et.from(d),o.schema);const{from:f}=c,m=f+d.length;r1({editor:e,from:f,to:m,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,l){return r1({editor:e,from:s,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&r1({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:o}=i.state.selection;return o?r1({editor:e,from:o.pos,to:o.pos,text:`
  8151. `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function _7e(t){return Object.prototype.toString.call(t).slice(8,-1)}function i1(t){return _7e(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function yne(t,e){const n={...t};return i1(t)&&i1(e)&&Object.keys(e).forEach(r=>{i1(e[r])&&i1(t[r])?n[r]=yne(t[r],e[r]):n[r]=e[r]}),n}var VL=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{...mr(Qt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...mr(Qt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>yne(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}},$h=class vne extends VL{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new vne(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(u=>u?.type.name===n.name))return!1;const c=o.find(u=>u?.type.name===n.name);return c&&r.removeStoredMark(c),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function w7e(t){return typeof t=="number"}var S7e=class{constructor(t){this.find=t.find,this.handler=t.handler}},N7e=(t,e,n)=>{if(IL(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 M7e(t){const{editor:e,state:n,from:r,to:i,rule:s,pasteEvent:o,dropEvent:l}=t,{commands:c,chain:u,can:d}=new PM({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(p,x)=>{var b,y,v,S,N;if((y=(b=p.type)==null?void 0:b.spec)!=null&&y.code||!(p.isText||p.isTextblock||p.isInline))return;const C=(N=(S=(v=p.content)==null?void 0:v.size)!=null?S:p.nodeSize)!=null?N:0,T=Math.max(r,x),k=Math.min(i,x+C);if(T>=k)return;const E=p.isText?p.text||"":p.textBetween(T-x,k-x,void 0,"");N7e(E,s.find,o).forEach(A=>{if(A.index===void 0)return;const R=T+A.index+1,F=R+A[0].length,O={from:n.tr.mapping.map(R),to:n.tr.mapping.map(F)},H=s.handler({state:n,range:O,match:A,commands:c,chain:u,can:d,pasteEvent:o,dropEvent:l});f.push(H)})}),f.every(p=>p!==null)}var a1=null,E7e=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function C7e(t){const{editor:e,rules:n}=t;let r=null,i=!1,s=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const c=({state:d,from:f,to:m,rule:p,pasteEvt:x})=>{const b=d.tr,y=jM({state:d,transaction:b});if(!(!M7e({editor:e,state:y,from:Math.max(f-1,0),to:m.b-1,rule:p,pasteEvent:x,dropEvent:l})||!b.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,b}};return n.map(d=>new ai({view(f){const m=x=>{var b;r=(b=f.dom.parentElement)!=null&&b.contains(x.target)?f.dom.parentElement:null,r&&(a1=e)},p=()=>{a1&&(a1=null)};return window.addEventListener("dragstart",m),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",m),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(f,m)=>{if(s=r===f.dom.parentElement,l=m,!s){const p=a1;p?.isEditable&&setTimeout(()=>{const x=p.state.selection;x&&p.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(f,m)=>{var p;const x=(p=m.clipboardData)==null?void 0:p.getData("text/html");return o=m,i=!!x?.includes("data-pm-slice"),!1}}},appendTransaction:(f,m,p)=>{const x=f[0],b=x.getMeta("uiEvent")==="paste"&&!i,y=x.getMeta("uiEvent")==="drop"&&!s,v=x.getMeta("applyPasteRules"),S=!!v;if(!b&&!y&&!S)return;if(S){let{text:T}=v;typeof T=="string"?T=T:T=BL(Et.from(T),p.schema);const{from:k}=v,E=k+T.length,D=E7e(T);return c({rule:d,state:p,from:k,to:{b:E},pasteEvt:D})}const N=m.doc.content.findDiffStart(p.doc.content),C=m.doc.content.findDiffEnd(p.doc.content);if(!(!w7e(N)||!C||N===C.b))return c({rule:d,state:p,from:N,to:C,pasteEvt:o})}}))}var IM=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=fne(t),this.schema=zVe(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:Ej(e.name,this.schema)},r=Qt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return $L([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Ej(r.name,this.schema)},s=[],o=Qt(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&Qt(r,"exitable",i)&&(l.ArrowRight=()=>$h.handleExit({editor:t,mark:r})),o){const m=Object.fromEntries(Object.entries(o()).map(([p,x])=>[p,()=>x({editor:t})]));l={...l,...m}}const c=HHe(l);s.push(c);const u=Qt(r,"addInputRules",i);if(U9(r,t.options.enableInputRules)&&u){const m=u();if(m&&m.length){const p=v7e({editor:t,rules:m}),x=Array.isArray(p)?p:[p];s.push(...x)}}const d=Qt(r,"addPasteRules",i);if(U9(r,t.options.enablePasteRules)&&d){const m=d();if(m&&m.length){const p=C7e({editor:t,rules:m});s.push(...p)}}const f=Qt(r,"addProseMirrorPlugins",i);if(f){const m=f();s.push(...m)}return s})}get attributes(){return hne(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=dx(this.extensions);return Object.fromEntries(e.filter(n=>!!Qt(n,"addNodeView")).map(n=>{const r=this.attributes.filter(c=>c.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:zi(n.name,this.schema)},s=Qt(n,"addNodeView",i);if(!s)return[];const o=s();if(!o)return[];const l=(c,u,d,f,m)=>{const p=v2(c,r);return o({node:c,view:u,getPos:d,decorations:f,innerDecorations:m,editor:t,extension:n,HTMLAttributes:p})};return[n.name,l]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=dx(this.extensions);return Object.fromEntries(e.filter(n=>!!Qt(n,"addMarkView")).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:Xu(n.name,this.schema)},s=Qt(n,"addMarkView",i);if(!s)return[];const o=(l,c,u)=>{const d=v2(l,r);return s()({mark:l,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{$7e(l,t,f)}})};return[n.name,o]}))}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:Ej(e.name,this.schema)};e.type==="mark"&&((n=mr(Qt(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Qt(e,"onBeforeCreate",r),s=Qt(e,"onCreate",r),o=Qt(e,"onUpdate",r),l=Qt(e,"onSelectionUpdate",r),c=Qt(e,"onTransaction",r),u=Qt(e,"onFocus",r),d=Qt(e,"onBlur",r),f=Qt(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}};IM.resolve=fne;IM.sort=$L;IM.flatten=zL;var T7e={};LL(T7e,{ClipboardTextSerializer:()=>wne,Commands:()=>Sne,Delete:()=>Nne,Drop:()=>Mne,Editable:()=>Ene,FocusEvents:()=>Tne,Keymap:()=>Ane,Paste:()=>kne,Tabindex:()=>jne,TextDirection:()=>Pne,focusEventsPluginKey:()=>Cne});var kr=class _ne extends VL{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new _ne(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},wne=kr.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new ai({key:new ia("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(d=>d.$from.pos)),l=Math.max(...s.map(d=>d.$to.pos)),c=pne(n);return mne(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),Sne=kr.create({name:"commands",addCommands(){return{...rne}}}),Nne=kr.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const s=()=>{var o,l,c,u;if((u=(c=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:c.call(l,t))!=null?u:t.getMeta("y-sync$"))return;const d=une(t.before,[t,...e]);xne(d).forEach(p=>{d.mapping.mapResult(p.oldRange.from).deletedAfter&&d.mapping.mapResult(p.oldRange.to).deletedBefore&&d.before.nodesBetween(p.oldRange.from,p.oldRange.to,(x,b)=>{const y=b+x.nodeSize-2,v=p.oldRange.from<=b&&y<=p.oldRange.to;this.editor.emit("delete",{type:"node",node:x,from:b,to:y,newFrom:d.mapping.map(b),newTo:d.mapping.map(y),deletedRange:p.oldRange,newRange:p.newRange,partial:!v,editor:this.editor,transaction:t,combinedTransform:d})})});const m=d.mapping;d.steps.forEach((p,x)=>{var b,y;if(p instanceof Dl){const v=m.slice(x).map(p.from,-1),S=m.slice(x).map(p.to),N=m.invert().map(v,-1),C=m.invert().map(S),T=(b=d.doc.nodeAt(v-1))==null?void 0:b.marks.some(E=>E.eq(p.mark)),k=(y=d.doc.nodeAt(S))==null?void 0:y.marks.some(E=>E.eq(p.mark));this.editor.emit("delete",{type:"mark",mark:p.mark,from:p.from,to:p.to,deletedRange:{from:N,to:C},newRange:{from:v,to:S},partial:!!(k||T),editor:this.editor,transaction:t,combinedTransform:d})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(s,0):s()}}),Mne=kr.create({name:"drop",addProseMirrorPlugins(){return[new ai({key:new ia("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Ene=kr.create({name:"editable",addProseMirrorPlugins(){return[new ai({key:new ia("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Cne=new ia("focusEvents"),Tne=kr.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new ai({key:Cne,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}}}})]}}),Ane=kr.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:c,doc:u}=l,{empty:d,$anchor:f}=c,{pos:m,parent:p}=f,x=f.parent.isTextblock&&m>0?l.doc.resolve(m-1):f,b=x.parent.type.spec.isolating,y=f.pos-f.parentOffset,v=b&&x.parent.childCount===1?y===f.pos:kn.atStart(u).from===m;return!d||!p.type.isTextblock||p.textContent.length||!v||v&&f.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.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 UL()||lne()?s:i},addProseMirrorPlugins(){return[new ai({key:new ia("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(b=>b.getMeta("composition")))return;const r=t.some(b=>b.docChanged)&&!e.doc.eq(n.doc),i=t.some(b=>b.getMeta("preventClearDocument"));if(!r||i)return;const{empty:s,from:o,to:l}=e.selection,c=kn.atStart(e.doc).from,u=kn.atEnd(e.doc).to;if(s||!(o===c&&l===u)||!OM(n.doc))return;const m=n.tr,p=jM({state:n,transaction:m}),{commands:x}=new PM({editor:this.editor,state:p});if(x.clearNodes(),!!m.steps.length)return m}})]}}),kne=kr.create({name:"paste",addProseMirrorPlugins(){return[new ai({key:new ia("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),jne=kr.create({name:"tabindex",addProseMirrorPlugins(){return[new ai({key:new ia("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Pne=kr.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=dx(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 ai({key:new ia("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),A7e=class cg{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 cg(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 cg(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 cg(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,o=this.pos+r+(s?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(o);if(!i&&l.depth<=this.depth)return;const c=new cg(l,this.editor,i,i?n:null);i&&(c.actualDepth=this.depth+1),e.push(new cg(l,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,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const c=o[l];if(s[c]!==n[c])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(n);return this.children.forEach(o=>{r&&i.length>0||(o.node.type.name===e&&s.every(c=>n[c]===o.node.attrs[c])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.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)}},k7e=`.ProseMirror {
  8152. position: relative;
  8153. }
  8154. .ProseMirror {
  8155. word-wrap: break-word;
  8156. white-space: pre-wrap;
  8157. white-space: break-spaces;
  8158. -webkit-font-variant-ligatures: none;
  8159. font-variant-ligatures: none;
  8160. font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
  8161. }
  8162. .ProseMirror [contenteditable="false"] {
  8163. white-space: normal;
  8164. }
  8165. .ProseMirror [contenteditable="false"] [contenteditable="true"] {
  8166. white-space: pre-wrap;
  8167. }
  8168. .ProseMirror pre {
  8169. white-space: pre-wrap;
  8170. }
  8171. img.ProseMirror-separator {
  8172. display: inline !important;
  8173. border: none !important;
  8174. margin: 0 !important;
  8175. width: 0 !important;
  8176. height: 0 !important;
  8177. }
  8178. .ProseMirror-gapcursor {
  8179. display: none;
  8180. pointer-events: none;
  8181. position: absolute;
  8182. margin: 0;
  8183. }
  8184. .ProseMirror-gapcursor:after {
  8185. content: "";
  8186. display: block;
  8187. position: absolute;
  8188. top: -2px;
  8189. width: 20px;
  8190. border-top: 1px solid black;
  8191. animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
  8192. }
  8193. @keyframes ProseMirror-cursor-blink {
  8194. to {
  8195. visibility: hidden;
  8196. }
  8197. }
  8198. .ProseMirror-hideselection *::selection {
  8199. background: transparent;
  8200. }
  8201. .ProseMirror-hideselection *::-moz-selection {
  8202. background: transparent;
  8203. }
  8204. .ProseMirror-hideselection * {
  8205. caret-color: transparent;
  8206. }
  8207. .ProseMirror-focused .ProseMirror-gapcursor {
  8208. display: block;
  8209. }`;function j7e(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 P7e=class extends b7e{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=sne(e,this.options.autofocus);this.editorState=vg.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=j7e(k7e,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=dne(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(o=>!o.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?[Ene,wne.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Sne,Tne,Ane,jne,Mne,kne,Nne,Pne.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 IM(r,this)}createCommandManager(){this.commandManager=new PM({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=VR(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=VR(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new tne(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 o=n.findLast(u=>u.getMeta("focus")||u.getMeta("blur")),l=o?.getMeta("focus"),c=o?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:o}),c&&this.emit("blur",{editor:this,event:c.event,transaction:o}),!(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 gne(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return KVe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return BL(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
  8210. `,textSerializers:n={}}=t||{};return $Ve(this.state.doc,{blockSeparator:e,textSerializers:{...pne(this.schema),...n}})}get isEmpty(){return OM(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 A7e(e,this)}get $doc(){return this.$pos(0)}};function hx(t){return new LM({find:t.find,handler:({state:e,range:n,match:r})=>{const i=mr(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,o=r[r.length-1],l=r[0];if(o){const c=l.search(/\S/),u=n.from+l.indexOf(o),d=u+o.length;if(HL(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(b=>b===t.type&&b!==p.mark.type)).filter(p=>p.to>u).length)return null;d<n.to&&s.delete(d,n.to),u>n.from&&s.delete(n.from+c,u);const m=n.from+c+o.length;s.addMark(n.from+c,m,t.type.create(i||{})),s.removeStoredMark(t.type)}},undoable:t.undoable})}function Rne(t){return new LM({find:t.find,handler:({state:e,range:n,match:r})=>{const i=mr(t.getAttributes,void 0,r)||{},{tr:s}=e,o=n.from;let l=n.to;const c=t.type.create(i);if(r[1]){const u=r[0].lastIndexOf(r[1]);let d=o+u;d>l?d=l:l=d+r[1].length;const f=r[0][r[0].length-1];s.insertText(f,o+r[0].length-1),s.replaceWith(d,l,c)}else if(r[0]){const u=t.type.isInline?o:o-1;s.insert(u,t.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()},undoable:t.undoable})}function qR(t){return new LM({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),s=mr(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 fx(t){return new LM({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=mr(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),c=o.doc.resolve(n.from).blockRange(),u=c&&vL(c,t.type,s);if(!u)return null;if(o.wrap(c,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:m}=e,{splittableMarks:p}=t.editor.extensionManager,x=m||f.$to.parentOffset&&f.$from.marks();if(x){const b=x.filter(y=>p.includes(y.type.name));o.ensureMarks(b)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,s).run()}const d=o.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&zh(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&o.join(n.from-1)},undoable:t.undoable})}var R7e=t=>"touches"in t,D7e=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=o=>{if(!this.isResizing||!this.activeHandle)return;const l=o.clientX-this.startX,c=o.clientY-this.startY;this.handleResize(l,c)},this.handleTouchMove=o=>{if(!this.isResizing||!this.activeHandle)return;const l=o.touches[0];if(!l)return;const c=l.clientX-this.startX,u=l.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;const o=this.element.offsetWidth,l=this.element.offsetHeight;this.onCommit(o,l),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=o=>{o.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=o=>{o.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,R7e(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"),o=t.includes("left"),l=t.includes("bottom"),c=t.includes("top");return s?r=this.startWidth+e:o&&(r=this.startWidth-e),l?i=this.startHeight+n:c&&(i=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(s?e:-e)),(t==="top"||t==="bottom")&&(i=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,s,o;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 l=t,c=e;return l<this.minSize.width&&(l=this.minSize.width,c=l/this.aspectRatio),c<this.minSize.height&&(c=this.minSize.height,l=c*this.aspectRatio),(s=this.maxSize)!=null&&s.width&&l>this.maxSize.width&&(l=this.maxSize.width,c=l/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&c>this.maxSize.height&&(c=this.maxSize.height,l=c*this.aspectRatio),{width:l,height:c}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",i=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function O7e(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Jt){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 L7e={};LL(L7e,{createAtomBlockMarkdownSpec:()=>I7e,createBlockMarkdownSpec:()=>F7e,createInlineMarkdownSpec:()=>B7e,parseAttributes:()=>GL,parseIndentedBlocks:()=>WR,renderNestedMarkdownContent:()=>WL,serializeAttributes:()=>qL});function GL(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 o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,u,d])=>{var f;const m=parseInt(((f=d.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),p=n[m];p&&(e[u]=p.slice(1,-1))});const c=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return c&&c.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function qL(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 I7e(t){const{nodeName:e,name:n,parseAttributes:r=GL,serializeAttributes:i=qL,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:l}=t,c=n||e,u=d=>{if(!l)return d;const f={};return l.forEach(m=>{m in d&&(f[m]=d[m])}),f};return{parseMarkdown:(d,f)=>{const m={...s,...d.attributes};return f.createNode(e,m,[])},markdownTokenizer:{name:e,level:"block",start(d){var f;const m=new RegExp(`^:::${c}(?:\\s|$)`,"m"),p=(f=d.match(m))==null?void 0:f.index;return p!==void 0?p:-1},tokenize(d,f,m){const p=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),x=d.match(p);if(!x)return;const b=x[1]||"",y=r(b);if(!o.find(S=>!(S in y)))return{type:e,raw:x[0],attributes:y}}},renderMarkdown:d=>{const f=u(d.attrs||{}),m=i(f),p=m?` {${m}}`:"";return`:::${c}${p} :::`}}}function F7e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=GL,serializeAttributes:s=qL,defaultAttributes:o={},content:l="block",allowedAttributes:c}=t,u=n||e,d=f=>{if(!c)return f;const m={};return c.forEach(p=>{p in f&&(m[p]=f[p])}),m};return{parseMarkdown:(f,m)=>{let p;if(r){const b=r(f);p=typeof b=="string"?[{type:"text",text:b}]:b}else l==="block"?p=m.parseChildren(f.tokens||[]):p=m.parseInline(f.tokens||[]);const x={...o,...f.attributes};return m.createNode(e,x,p)},markdownTokenizer:{name:e,level:"block",start(f){var m;const p=new RegExp(`^:::${u}`,"m"),x=(m=f.match(p))==null?void 0:m.index;return x!==void 0?x:-1},tokenize(f,m,p){var x;const b=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),y=f.match(b);if(!y)return;const[v,S=""]=y,N=i(S);let C=1;const T=v.length;let k="";const E=/^:::([\w-]*)(\s.*)?/gm,D=f.slice(T);for(E.lastIndex=0;;){const A=E.exec(D);if(A===null)break;const R=A.index,F=A[1];if(!((x=A[2])!=null&&x.endsWith(":::"))){if(F)C+=1;else if(C-=1,C===0){const O=D.slice(0,R);k=O.trim();const H=f.slice(0,T+R+A[0].length);let j=[];if(k)if(l==="block")for(j=p.blockTokens(O),j.forEach(G=>{G.text&&(!G.tokens||G.tokens.length===0)&&(G.tokens=p.inlineTokens(G.text))});j.length>0;){const G=j[j.length-1];if(G.type==="paragraph"&&(!G.text||G.text.trim()===""))j.pop();else break}else j=p.inlineTokens(k);return{type:e,raw:H,attributes:N,content:k,tokens:j}}}}}},renderMarkdown:(f,m)=>{const p=d(f.attrs||{}),x=s(p),b=x?` {${x}}`:"",y=m.renderChildren(f.content||[],`
  8211. `);return`:::${u}${b}
  8212. ${y}
  8213. :::`}}}function U7e(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,s,o]=r;e[i]=s||o,r=n.exec(t)}return e}function z7e(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function B7e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=U7e,serializeAttributes:s=z7e,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:c}=t,u=n||e,d=m=>{if(!c)return m;const p={};return c.forEach(x=>{x in m&&(p[x]=m[x])}),p},f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(m,p)=>{const x={...o,...m.attributes};if(l)return p.createNode(e,x);const b=r?r(m):m.content||"";return b?p.createNode(e,x,[p.createTextNode(b)]):p.createNode(e,x,[])},markdownTokenizer:{name:e,level:"inline",start(m){const p=l?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),x=m.match(p),b=x?.index;return b!==void 0?b:-1},tokenize(m,p,x){const b=l?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),y=m.match(b);if(!y)return;let v="",S="";if(l){const[,C]=y;S=C}else{const[,C,T]=y;S=C,v=T||""}const N=i(S.trim());return{type:e,raw:y[0],content:v.trim(),attributes:N}}},renderMarkdown:m=>{let p="";r?p=r(m):m.content&&m.content.length>0&&(p=m.content.filter(v=>v.type==="text").map(v=>v.text).join(""));const x=d(m.attrs||{}),b=s(x),y=b?` ${b}`:"";return l?`[${u}${y}]`:`[${u}${y}]${p}[/${u}]`}}}function WR(t,e,n){var r,i,s,o;const l=t.split(`
  8214. `),c=[];let u="",d=0;const f=e.baseIndentSize||2;for(;d<l.length;){const m=l[d],p=m.match(e.itemPattern);if(!p){if(c.length>0)break;if(m.trim()===""){d+=1,u=`${u}${m}
  8215. `;continue}else return}const x=e.extractItemData(p),{indentLevel:b,mainContent:y}=x;u=`${u}${m}
  8216. `;const v=[y];for(d+=1;d<l.length;){const T=l[d];if(T.trim()===""){const E=l.slice(d+1).findIndex(R=>R.trim()!=="");if(E===-1)break;if((((i=(r=l[d+1+E].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>b){v.push(T),u=`${u}${T}
  8217. `,d+=1;continue}else break}if((((o=(s=T.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:o.length)||0)>b)v.push(T),u=`${u}${T}
  8218. `,d+=1;else break}let S;const N=v.slice(1);if(N.length>0){const T=N.map(k=>k.slice(b+f)).join(`
  8219. `);T.trim()&&(e.customNestedParser?S=e.customNestedParser(T):S=n.blockTokens(T))}const C=e.createToken(x,S);c.push(C)}if(c.length!==0)return{items:c,raw:u}}function WL(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[s,...o]=t.content,l=e.renderChildren([s]),c=[`${i}${l}`];return o&&o.length>0&&o.forEach(u=>{const d=e.renderChildren([u]);if(d){const f=d.split(`
  8220. `).map(m=>m?e.indent(m):"").join(`
  8221. `);c.push(f)}}),c.join(`
  8222. `)}function $7e(t,e,n={}){const{state:r}=e,{doc:i,tr:s}=r,o=t;i.descendants((l,c)=>{const u=s.mapping.map(c),d=s.mapping.map(c)+l.nodeSize;let f=null;if(l.marks.forEach(p=>{if(p!==o)return!1;f=p}),!f)return;let m=!1;if(Object.keys(n).forEach(p=>{n[p]!==f.attrs[p]&&(m=!0)}),m){const p=t.type.create({...t.attrs,...n});s.removeMark(u,d,t.type),s.addMark(u,d,p)}}),s.docChanged&&e.view.dispatch(s)}var Ws=class Dne extends VL{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Dne(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Nm(t){return new S7e({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=mr(t.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:o}=e,l=r[r.length-1],c=r[0];let u=n.to;if(l){const d=c.search(/\S/),f=n.from+c.indexOf(l),m=f+l.length;if(HL(n.from,n.to,e.doc).filter(x=>x.mark.type.excluded.find(y=>y===t.type&&y!==x.mark.type)).filter(x=>x.to>f).length)return null;m<n.to&&o.delete(m,n.to),f>n.from&&o.delete(n.from+d,f),u=n.from+d+l.length,o.addMark(n.from+d,u,t.type.create(s||{})),o.removeStoredMark(t.type)}}})}var Aj,$9;function H7e(){return $9||($9=1,Aj=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 o=s[i];if(!(o==="_owner"&&e.$$typeof)&&!t(e[o],n[o]))return!1}return!0}return e!==e&&n!==n}),Aj}var V7e=H7e();const G7e=ul(V7e);var q7e=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},W7e=({contentComponent:t})=>{const e=mD.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return a.jsx(a.Fragment,{children:Object.values(e)})};function K7e(){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]:Tle.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 X7e=class extends Kr.Component{constructor(t){var e;super(t),this.editorContentRef=Kr.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=K7e(),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 a.jsxs(a.Fragment,{children:[a.jsx("div",{ref:q7e(e,this.editorContentRef),...n}),t?.contentComponent&&a.jsx(W7e,{contentComponent:t.contentComponent})]})}},Y7e=w.forwardRef((t,e)=>{const n=Kr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Kr.createElement(X7e,{key:n,innerRef:e,...t})}),Q7e=Kr.memo(Y7e),Z7e=typeof window<"u"?w.useLayoutEffect:w.useEffect,J7e=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 eGe(t){var e;const[n]=w.useState(()=>new J7e(t.editor)),r=GX.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:G7e);return Z7e(()=>n.watch(t.editor),[t.editor,n]),w.useDebugValue(r),r}var tGe=!1,KR=typeof window>"u",nGe=KR||!!(typeof window<"u"&&window.next),rGe=class One{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?KR||nGe?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 P7e(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 o;return i===((o=n.extensions)==null?void 0:o[s])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?One.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 iGe(t={},e=[]){const n=w.useRef(t);n.current=t;const[r]=w.useState(()=>new rGe(n)),i=mD.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return w.useDebugValue(i),w.useEffect(r.onRender(e)),eGe({editor:i,selector:({transactionNumber:s})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&s===0?0:s+1}),i}var aGe=w.createContext({editor:null});aGe.Consumer;var sGe=w.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),oGe=()=>w.useContext(sGe);Kr.forwardRef((t,e)=>{const{onDragStart:n}=oGe(),r=t.as||"div";return a.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});Kr.createContext({markViewContentRef:()=>{}});var _2=(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]},lGe=/^\s*>\s$/,cGe=Ws.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return _2("blockquote",{...gi(this.options.HTMLAttributes,t),children:_2("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 l=e.renderChildren([i]).split(`
  8223. `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(l.join(`
  8224. `))}),r.join(`
  8225. ${n}
  8226. `)},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[fx({find:lGe,type:this.type})]}}),uGe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,dGe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,hGe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,fGe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,mGe=$h.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 _2("strong",{...gi(this.options.HTMLAttributes,t),children:_2("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[hx({find:uGe,type:this.type}),hx({find:hGe,type:this.type})]},addPasteRules(){return[Nm({find:dGe,type:this.type}),Nm({find:fGe,type:this.type})]}}),pGe=/(^|[^`])`([^`]+)`(?!`)$/,gGe=/(^|[^`])`([^`]+)`(?!`)/g,xGe=$h.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",gi(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[hx({find:pGe,type:this.type})]},addPasteRules(){return[Nm({find:gGe,type:this.type})]}}),kj=4,bGe=/^```([a-z]+)?[\s\n]$/,yGe=/^~~~([a-z]+)?[\s\n]$/,vGe=Ws.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:kj,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(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",gi(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(`
  8227. `):r=`\`\`\`${i}
  8228. \`\`\``,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:kj,{state:r}=t,{selection:i}=r,{$from:s,empty:o}=i;if(s.parent.type!==this.type)return!1;const l=" ".repeat(n);return o?t.commands.insertContent(l):t.commands.command(({tr:c})=>{const{from:u,to:d}=i,p=r.doc.textBetween(u,d,`
  8229. `,`
  8230. `).split(`
  8231. `).map(x=>l+x).join(`
  8232. `);return c.replaceWith(u,d,r.schema.text(p)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:kj,{state:r}=t,{selection:i}=r,{$from:s,empty:o}=i;return s.parent.type!==this.type?!1:o?t.commands.command(({tr:l})=>{var c;const{pos:u}=s,d=s.start(),f=s.end(),p=r.doc.textBetween(d,f,`
  8233. `,`
  8234. `).split(`
  8235. `);let x=0,b=0;const y=u-d;for(let k=0;k<p.length;k+=1){if(b+p[k].length>=y){x=k;break}b+=p[k].length+1}const S=((c=p[x].match(/^ */))==null?void 0:c[0])||"",N=Math.min(S.length,n);if(N===0)return!0;let C=d;for(let k=0;k<x;k+=1)C+=p[k].length+1;return l.delete(C,C+N),u-C<=N&&l.setSelection(pn.create(l.doc,C)),!0}):t.commands.command(({tr:l})=>{const{from:c,to:u}=i,m=r.doc.textBetween(c,u,`
  8236. `,`
  8237. `).split(`
  8238. `).map(p=>{var x;const b=((x=p.match(/^ */))==null?void 0:x[0])||"",y=Math.min(b.length,n);return p.slice(y)}).join(`
  8239. `);return l.replaceWith(c,u,r.schema.text(m)),!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,o=r.parent.textContent.endsWith(`
  8240. `);return!s||!o?!1:t.chain().command(({tr:l})=>(l.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 l=i.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:u})=>(u.setSelection(kn.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[qR({find:bGe,type:this.type,getAttributes:t=>({language:t[1]})}),qR({find:yGe,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new ai({key:new ia("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:o,schema:l}=t.state,c=l.text(n.replace(/\r\n?/g,`
  8241. `));return o.replaceSelectionWith(this.type.create({language:s},c)),o.selection.$from.parent.type!==this.type&&o.setSelection(pn.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),_Ge=Ws.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
  8242. `):""}),wGe=Ws.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",gi(this.options.HTMLAttributes,t)]},renderText(){return`
  8243. `},renderMarkdown:()=>`
  8244. `,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:o}=this.options,{splittableMarks:l}=r.extensionManager,c=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:d})=>{if(d&&c&&o){const f=c.filter(m=>l.includes(m.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),SGe=Ws.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]}`,gi(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=>qR({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),NGe=Ws.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",gi(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!O7e(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return bne(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:s,tr:o,dispatch:l})=>{if(l){const{$to:c}=o.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(pn.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(Jt.create(o.doc,c.pos)):o.setSelection(pn.create(o.doc,c.pos));else{const d=s.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,f=d?.create();f&&(o.insert(u,f),o.setSelection(pn.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Rne({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),MGe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,EGe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,CGe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,TGe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,AGe=$h.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",gi(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[hx({find:MGe,type:this.type}),hx({find:CGe,type:this.type})]},addPasteRules(){return[Nm({find:EGe,type:this.type}),Nm({find:TGe,type:this.type})]}});const kGe="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",jGe="ελ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",XR="numeric",YR="ascii",QR="alpha",j0="asciinumeric",m0="alphanumeric",ZR="domain",Lne="emoji",PGe="scheme",RGe="slashscheme",jj="whitespace";function DGe(t,e){return t in e||(e[t]=[]),e[t]}function Uf(t,e,n){e[XR]&&(e[j0]=!0,e[m0]=!0),e[YR]&&(e[j0]=!0,e[QR]=!0),e[j0]&&(e[m0]=!0),e[QR]&&(e[m0]=!0),e[m0]&&(e[ZR]=!0),e[Lne]&&(e[ZR]=!0);for(const r in e){const i=DGe(r,n);i.indexOf(t)<0&&i.push(t)}}function OGe(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Is(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Is.groups={};Is.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||Is.groups;let i;return e&&e.j?i=e:(i=new Is(e),n&&r&&Uf(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 o=0;o<s-1;o++)i=i.tt(t[o]);return i.tt(t[s-1],e,n,r)},tt(t,e,n,r){r=r||Is.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const s=e;let o,l=i.go(t);if(l?(o=new Is,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new Is,s){if(r)if(o.t&&typeof o.t=="string"){const c=Object.assign(OGe(o.t,r),n);Uf(s,c,r)}else n&&Uf(s,n,r);o.t=s}return i.j[t]=o,o}};const En=(t,e,n,r,i)=>t.ta(e,n,r,i),ci=(t,e,n,r,i)=>t.tr(e,n,r,i),H9=(t,e,n,r,i)=>t.ts(e,n,r,i),kt=(t,e,n,r,i)=>t.tt(e,n,r,i),cu="WORD",JR="UWORD",Ine="ASCIINUMERICAL",Fne="ALPHANUMERICAL",Ay="LOCALHOST",eD="TLD",tD="UTLD",I1="SCHEME",ug="SLASH_SCHEME",KL="NUM",nD="WS",XL="NL",P0="OPENBRACE",R0="CLOSEBRACE",w2="OPENBRACKET",S2="CLOSEBRACKET",N2="OPENPAREN",M2="CLOSEPAREN",E2="OPENANGLEBRACKET",C2="CLOSEANGLEBRACKET",T2="FULLWIDTHLEFTPAREN",A2="FULLWIDTHRIGHTPAREN",k2="LEFTCORNERBRACKET",j2="RIGHTCORNERBRACKET",P2="LEFTWHITECORNERBRACKET",R2="RIGHTWHITECORNERBRACKET",D2="FULLWIDTHLESSTHAN",O2="FULLWIDTHGREATERTHAN",L2="AMPERSAND",I2="APOSTROPHE",F2="ASTERISK",Hd="AT",U2="BACKSLASH",z2="BACKTICK",B2="CARET",Xd="COLON",YL="COMMA",$2="DOLLAR",Jl="DOT",H2="EQUALS",QL="EXCLAMATION",Bo="HYPHEN",D0="PERCENT",V2="PIPE",G2="PLUS",q2="POUND",O0="QUERY",ZL="QUOTE",Une="FULLWIDTHMIDDLEDOT",JL="SEMI",ec="SLASH",L0="TILDE",W2="UNDERSCORE",zne="EMOJI",K2="SYM";var Bne=Object.freeze({__proto__:null,ALPHANUMERICAL:Fne,AMPERSAND:L2,APOSTROPHE:I2,ASCIINUMERICAL:Ine,ASTERISK:F2,AT:Hd,BACKSLASH:U2,BACKTICK:z2,CARET:B2,CLOSEANGLEBRACKET:C2,CLOSEBRACE:R0,CLOSEBRACKET:S2,CLOSEPAREN:M2,COLON:Xd,COMMA:YL,DOLLAR:$2,DOT:Jl,EMOJI:zne,EQUALS:H2,EXCLAMATION:QL,FULLWIDTHGREATERTHAN:O2,FULLWIDTHLEFTPAREN:T2,FULLWIDTHLESSTHAN:D2,FULLWIDTHMIDDLEDOT:Une,FULLWIDTHRIGHTPAREN:A2,HYPHEN:Bo,LEFTCORNERBRACKET:k2,LEFTWHITECORNERBRACKET:P2,LOCALHOST:Ay,NL:XL,NUM:KL,OPENANGLEBRACKET:E2,OPENBRACE:P0,OPENBRACKET:w2,OPENPAREN:N2,PERCENT:D0,PIPE:V2,PLUS:G2,POUND:q2,QUERY:O0,QUOTE:ZL,RIGHTCORNERBRACKET:j2,RIGHTWHITECORNERBRACKET:R2,SCHEME:I1,SEMI:JL,SLASH:ec,SLASH_SCHEME:ug,SYM:K2,TILDE:L0,TLD:eD,UNDERSCORE:W2,UTLD:tD,UWORD:JR,WORD:cu,WS:nD});const iu=/[a-z]/,t0=new RegExp("\\p{L}","u"),Pj=new RegExp("\\p{Emoji}","u"),au=/\d/,Rj=/\s/,V9="\r",Dj=`
  8245. `,LGe="️",IGe="‍",Oj="";let s1=null,o1=null;function FGe(t=[]){const e={};Is.groups=e;const n=new Is;s1==null&&(s1=G9(kGe)),o1==null&&(o1=G9(jGe)),kt(n,"'",I2),kt(n,"{",P0),kt(n,"}",R0),kt(n,"[",w2),kt(n,"]",S2),kt(n,"(",N2),kt(n,")",M2),kt(n,"<",E2),kt(n,">",C2),kt(n,"(",T2),kt(n,")",A2),kt(n,"「",k2),kt(n,"」",j2),kt(n,"『",P2),kt(n,"』",R2),kt(n,"<",D2),kt(n,">",O2),kt(n,"&",L2),kt(n,"*",F2),kt(n,"@",Hd),kt(n,"`",z2),kt(n,"^",B2),kt(n,":",Xd),kt(n,",",YL),kt(n,"$",$2),kt(n,".",Jl),kt(n,"=",H2),kt(n,"!",QL),kt(n,"-",Bo),kt(n,"%",D0),kt(n,"|",V2),kt(n,"+",G2),kt(n,"#",q2),kt(n,"?",O0),kt(n,'"',ZL),kt(n,"/",ec),kt(n,";",JL),kt(n,"~",L0),kt(n,"_",W2),kt(n,"\\",U2),kt(n,"・",Une);const r=ci(n,au,KL,{[XR]:!0});ci(r,au,r);const i=ci(r,iu,Ine,{[j0]:!0}),s=ci(r,t0,Fne,{[m0]:!0}),o=ci(n,iu,cu,{[YR]:!0});ci(o,au,i),ci(o,iu,o),ci(i,au,i),ci(i,iu,i);const l=ci(n,t0,JR,{[QR]:!0});ci(l,iu),ci(l,au,s),ci(l,t0,l),ci(s,au,s),ci(s,iu),ci(s,t0,s);const c=kt(n,Dj,XL,{[jj]:!0}),u=kt(n,V9,nD,{[jj]:!0}),d=ci(n,Rj,nD,{[jj]:!0});kt(n,Oj,d),kt(u,Dj,c),kt(u,Oj,d),ci(u,Rj,d),kt(d,V9),kt(d,Dj),ci(d,Rj,d),kt(d,Oj,d);const f=ci(n,Pj,zne,{[Lne]:!0});kt(f,"#"),ci(f,Pj,f),kt(f,LGe,f);const m=kt(f,IGe);kt(m,"#"),ci(m,Pj,f);const p=[[iu,o],[au,i]],x=[[iu,null],[t0,l],[au,s]];for(let b=0;b<s1.length;b++)Od(n,s1[b],eD,cu,p);for(let b=0;b<o1.length;b++)Od(n,o1[b],tD,JR,x);Uf(eD,{tld:!0,ascii:!0},e),Uf(tD,{utld:!0,alpha:!0},e),Od(n,"file",I1,cu,p),Od(n,"mailto",I1,cu,p),Od(n,"http",ug,cu,p),Od(n,"https",ug,cu,p),Od(n,"ftp",ug,cu,p),Od(n,"ftps",ug,cu,p),Uf(I1,{scheme:!0,ascii:!0},e),Uf(ug,{slashscheme:!0,ascii:!0},e),t=t.sort((b,y)=>b[0]>y[0]?1:-1);for(let b=0;b<t.length;b++){const y=t[b][0],S=t[b][1]?{[PGe]:!0}:{[RGe]:!0};y.indexOf("-")>=0?S[ZR]=!0:iu.test(y)?au.test(y)?S[j0]=!0:S[YR]=!0:S[XR]=!0,H9(n,y,y,S)}return H9(n,"localhost",Ay,{ascii:!0}),n.jd=new Is(K2),{start:n,tokens:Object.assign({groups:e},Bne)}}function $ne(t,e){const n=UGe(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,i=[];let s=0,o=0;for(;o<r;){let l=t,c=null,u=0,d=null,f=-1,m=-1;for(;o<r&&(c=l.go(n[o]));)l=c,l.accepts()?(f=0,m=0,d=l):f>=0&&(f+=n[o].length,m++),u+=n[o].length,s+=n[o].length,o++;s-=f,o-=m,u-=f,i.push({t:d.t,v:e.slice(s-u,s),s:s-u,e:s})}return i}function UGe(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),s,o=i<55296||i>56319||r+1===n||(s=t.charCodeAt(r+1))<56320||s>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function Od(t,e,n,r,i){let s;const o=e.length;for(let l=0;l<o-1;l++){const c=e[l];t.j[c]?s=t.j[c]:(s=new Is(r),s.jr=i.slice(),t.j[c]=s),t=s}return s=new Is(n),s.jr=i.slice(),t.j[e[o-1]]=s,s}function G9(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 o=parseInt(t.substring(r,r+s),10);o>0;o--)n.pop();r+=s}else n.push(t[r]),r++}return e}const ky={defaultProtocol:"http",events:null,format:q9,formatHref:q9,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function e5(t,e=null){let n=Object.assign({},ky);t&&(n=Object.assign(n,t instanceof e5?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}e5.prototype={o:ky,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]:ky[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 q9(t){return t}function Hne(t,e){this.t="token",this.v=t,this.tk=e}Hne.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=ky.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),o={},l=t.get("className",n,e),c=t.get("target",n,e),u=t.get("rel",n,e),d=t.getObj("attributes",n,e),f=t.getObj("events",n,e);return o.href=r,l&&(o.class=l),c&&(o.target=c),u&&(o.rel=u),d&&Object.assign(o,d),{tagName:i,attributes:o,content:s,eventListeners:f}}};function FM(t,e){class n extends Hne{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 W9=FM("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),K9=FM("text"),zGe=FM("nl"),l1=FM("url",{isLink:!0,toHref(t=ky.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Ay&&t[1].t===Xd}}),Fo=t=>new Is(t);function BGe({groups:t}){const e=t.domain.concat([L2,F2,Hd,U2,z2,B2,$2,H2,Bo,KL,D0,V2,G2,q2,ec,K2,L0,W2]),n=[I2,Xd,YL,Jl,QL,D0,O0,ZL,JL,E2,C2,P0,R0,S2,w2,N2,M2,T2,A2,k2,j2,P2,R2,D2,O2],r=[L2,I2,F2,U2,z2,B2,$2,H2,Bo,P0,R0,D0,V2,G2,q2,O0,ec,K2,L0,W2],i=Fo(),s=kt(i,L0);En(s,r,s),En(s,t.domain,s);const o=Fo(),l=Fo(),c=Fo();En(i,t.domain,o),En(i,t.scheme,l),En(i,t.slashscheme,c),En(o,r,s),En(o,t.domain,o);const u=kt(o,Hd);kt(s,Hd,u),kt(l,Hd,u),kt(c,Hd,u);const d=kt(s,Jl);En(d,r,s),En(d,t.domain,s);const f=Fo();En(u,t.domain,f),En(f,t.domain,f);const m=kt(f,Jl);En(m,t.domain,f);const p=Fo(W9);En(m,t.tld,p),En(m,t.utld,p),kt(u,Ay,p);const x=kt(f,Bo);kt(x,Bo,x),En(x,t.domain,f),En(p,t.domain,f),kt(p,Jl,m),kt(p,Bo,x);const b=kt(p,Xd);En(b,t.numeric,W9);const y=kt(o,Bo),v=kt(o,Jl);kt(y,Bo,y),En(y,t.domain,o),En(v,r,s),En(v,t.domain,o);const S=Fo(l1);En(v,t.tld,S),En(v,t.utld,S),En(S,t.domain,o),En(S,r,s),kt(S,Jl,v),kt(S,Bo,y),kt(S,Hd,u);const N=kt(S,Xd),C=Fo(l1);En(N,t.numeric,C);const T=Fo(l1),k=Fo();En(T,e,T),En(T,n,k),En(k,e,T),En(k,n,k),kt(S,ec,T),kt(C,ec,T);const E=kt(l,Xd),D=kt(c,Xd),A=kt(D,ec),R=kt(A,ec);En(l,t.domain,o),kt(l,Jl,v),kt(l,Bo,y),En(c,t.domain,o),kt(c,Jl,v),kt(c,Bo,y),En(E,t.domain,T),kt(E,ec,T),kt(E,O0,T),En(R,t.domain,T),En(R,e,T),kt(R,ec,T);const F=[[P0,R0],[w2,S2],[N2,M2],[E2,C2],[T2,A2],[k2,j2],[P2,R2],[D2,O2]];for(let O=0;O<F.length;O++){const[H,j]=F[O],G=kt(T,H);kt(k,H,G),kt(G,j,T);const $=Fo(l1);En(G,e,$);const q=Fo();En(G,n),En($,e,$),En($,n,q),En(q,e,$),En(q,n,q),kt($,j,T),kt(q,j,T)}return kt(i,Ay,S),kt(i,XL,zGe),{start:i,tokens:Bne}}function $Ge(t,e,n){let r=n.length,i=0,s=[],o=[];for(;i<r;){let l=t,c=null,u=null,d=0,f=null,m=-1;for(;i<r&&!(c=l.go(n[i].t));)o.push(n[i++]);for(;i<r&&(u=c||l.go(n[i].t));)c=null,l=u,l.accepts()?(m=0,f=l):m>=0&&m++,i++,d++;if(m<0)i-=d,i<r&&(o.push(n[i]),i++);else{o.length>0&&(s.push(Lj(K9,e,o)),o=[]),i-=m,d-=m;const p=f.t,x=n.slice(i-d,i);s.push(Lj(p,e,x))}}return o.length>0&&s.push(Lj(K9,e,o)),s}function Lj(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 HGe=typeof console<"u"&&console&&console.warn||(()=>{}),VGe="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Hr={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function GGe(){return Is.groups={},Hr.scanner=null,Hr.parser=null,Hr.tokenQueue=[],Hr.pluginQueue=[],Hr.customSchemes=[],Hr.initialized=!1,Hr}function X9(t,e=!1){if(Hr.initialized&&HGe(`linkifyjs: already initialized - will not register custom scheme "${t}" ${VGe}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
  8246. 1. Must only contain digits, lowercase ASCII letters or "-"
  8247. 2. Cannot start or end with "-"
  8248. 3. "-" cannot repeat`);Hr.customSchemes.push([t,e])}function qGe(){Hr.scanner=FGe(Hr.customSchemes);for(let t=0;t<Hr.tokenQueue.length;t++)Hr.tokenQueue[t][1]({scanner:Hr.scanner});Hr.parser=BGe(Hr.scanner.tokens);for(let t=0;t<Hr.pluginQueue.length;t++)Hr.pluginQueue[t][1]({scanner:Hr.scanner,parser:Hr.parser});return Hr.initialized=!0,Hr}function t5(t){return Hr.initialized||qGe(),$Ge(Hr.parser.start,t,$ne(Hr.scanner.start,t))}t5.scan=$ne;function Vne(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 e5(n),i=t5(t),s=[];for(let o=0;o<i.length;o++){const l=i[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&s.push(l.toFormattedObject(r))}return s}var n5="[\0-   ᠎ -\u2029  ]",WGe=new RegExp(n5),KGe=new RegExp(`${n5}$`),XGe=new RegExp(n5,"g");function YGe(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function QGe(t){return new ai({key:new ia("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:o}=r,l=une(n.doc,[...e]);if(xne(l).forEach(({newRange:u})=>{const d=LVe(r.doc,u,p=>p.isTextblock);let f,m;if(d.length>1)f=d[0],m=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(d.length){const p=r.doc.textBetween(u.from,u.to," "," ");if(!KGe.test(p))return;f=d[0],m=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&m){const p=m.split(WGe).filter(Boolean);if(p.length<=0)return!1;const x=p[p.length-1],b=f.pos+m.lastIndexOf(x);if(!x)return!1;const y=t5(x).map(v=>v.toObject(t.defaultProtocol));if(!YGe(y))return!1;y.filter(v=>v.isLink).map(v=>({...v,from:b+v.start+1,to:b+v.end+1})).filter(v=>r.schema.marks.code?!r.doc.rangeHasMark(v.from,v.to,r.schema.marks.code):!0).filter(v=>t.validate(v.value)).filter(v=>t.shouldAutoLink(v.value)).forEach(v=>{HL(v.from,v.to,r.doc).some(S=>S.mark.type===t.type)||o.addMark(v.from,v.to,t.type.create({href:v.href}))})}}),!!o.steps.length)return o}})}function ZGe(t){return new ai({key:new ia("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,s;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let d=r.target;const f=[];for(;d.nodeName!=="DIV";)f.push(d),d=d.parentNode;o=f.find(m=>m.nodeName==="A")}if(!o)return!1;const l=gne(e.state,t.type.name),c=(i=o?.href)!=null?i:l.href,u=(s=o?.target)!=null?s:l.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),o&&c?(window.open(c,u),!0):!1}}})}function JGe(t){return new ai({key:new ia("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:s}=e,{selection:o}=s,{empty:l}=o;if(l)return!1;let c="";r.content.forEach(d=>{c+=d.textContent});const u=Vne(c,{defaultProtocol:t.defaultProtocol}).find(d=>d.isLink&&d.value===c);return!c||!u||i!==void 0&&!i(u.href)?!1:t.editor.commands.setMark(t.type,{href:u.href})}}})}function bf(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(XGe,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Gne=$h.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"){X9(t);return}X9(t.scheme,t.optionalSlashes)})},onDestroy(){GGe()},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)=>!!bf(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=>!!bf(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=>!!bf(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",gi(this.options.HTMLAttributes,t),0]:["a",gi(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=>!!bf(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=>!!bf(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[Nm({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=Vne(t).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:o=>!!bf(o,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(QGe({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!bf(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(ZGe({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(JGe({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),e9e=Gne,t9e=Object.defineProperty,n9e=(t,e)=>{for(var n in e)t9e(t,n,{get:e[n],enumerable:!0})},r9e="listItem",Y9="textStyle",Q9=/^\s*([-+*])\s$/,qne=Ws.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",gi(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,`
  8249. `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(r9e,this.editor.getAttributes(Y9)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=fx({find:Q9,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=fx({find:Q9,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Y9),editor:this.editor})),[t]}}),Wne=Ws.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",gi(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 o=t.tokens.slice(1),l=e.parseChildren(o);n.push(...l)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>WL(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)}}}),i9e={};n9e(i9e,{findListItemPos:()=>vv,getNextListDepth:()=>r5,handleBackspace:()=>rD,handleDelete:()=>iD,hasListBefore:()=>Kne,hasListItemAfter:()=>a9e,hasListItemBefore:()=>Xne,listItemHasSubList:()=>Yne,nextListIsDeeper:()=>Qne,nextListIsHigher:()=>Zne});var vv=(t,e)=>{const{$from:n}=e.selection,r=zi(t,e.schema);let i=null,s=n.depth,o=n.pos,l=null;for(;s>0&&l===null;)i=n.node(s),i.type===r?l=s:(s-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},r5=(t,e)=>{const n=vv(t,e);if(!n)return!1;const[,r]=qVe(e,t,n.$pos.pos+4);return r},Kne=(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))},Xne=(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)},Yne=(t,e,n)=>{if(!n)return!1;const r=zi(t,e.schema);let i=!1;return n.descendants(s=>{s.type===r&&(i=!0)}),i},rD=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Rh(t.state,e)&&Kne(t.state,e,n)){const{$anchor:l}=t.state.selection,c=t.state.doc.resolve(l.before()-1),u=[];c.node().descendants((m,p)=>{m.type.name===e&&u.push({node:m,pos:p})});const d=u.at(-1);if(!d)return!1;const f=t.state.doc.resolve(c.start()+d.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},f.end()).joinForward().run()}if(!Rh(t.state,e)||!YVe(t.state))return!1;const r=vv(e,t.state);if(!r)return!1;const s=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=Yne(e,t.state,s);return Xne(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Qne=(t,e)=>{const n=r5(t,e),r=vv(t,e);return!r||!n?!1:n>r.depth},Zne=(t,e)=>{const n=r5(t,e),r=vv(t,e);return!r||!n?!1:n<r.depth},iD=(t,e)=>{if(!Rh(t.state,e)||!XVe(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:Qne(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Zne(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},a9e=(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)},Jne=kr.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&&iD(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&&iD(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&&rD(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&&rD(t,n,r)&&(e=!0)}),e}}}}),Z9=/^(\s*)(\d+)\.\s+(.*)$/,s9e=/^\s/;function o9e(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],s=i.match(Z9);if(!s)break;const[,o,l,c]=s,u=o.length;let d=c,f=n+1;const m=[i];for(;f<t.length;){const p=t[f];if(p.match(Z9))break;if(p.trim()==="")m.push(p),d+=`
  8250. `,f+=1;else if(p.match(s9e))m.push(p),d+=`
  8251. ${p.slice(u+2)}`,f+=1;else break}e.push({indent:u,number:parseInt(l,10),content:d.trim(),raw:m.join(`
  8252. `)}),r=f,n=f}return[e,r]}function ere(t,e,n){var r;const i=[];let s=0;for(;s<t.length;){const o=t[s];if(o.indent===e){const l=o.content.split(`
  8253. `),c=((r=l[0])==null?void 0:r.trim())||"",u=[];c&&u.push({type:"paragraph",raw:c,tokens:n.inlineTokens(c)});const d=l.slice(1).join(`
  8254. `).trim();if(d){const p=n.blockTokens(d);u.push(...p)}let f=s+1;const m=[];for(;f<t.length&&t[f].indent>e;)m.push(t[f]),f+=1;if(m.length>0){const p=Math.min(...m.map(b=>b.indent)),x=ere(m,p,n);u.push({type:"list",ordered:!0,start:m[0].number,items:x,raw:m.map(b=>b.raw).join(`
  8255. `)})}i.push({type:"list_item",raw:o.raw,tokens:u}),s=f}else s+=1}return i}function l9e(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 c9e="listItem",J9="textStyle",eq=/^(\d+)\.\s$/,tre=Ws.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",gi(this.options.HTMLAttributes,n),0]:["ol",gi(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?l9e(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,`
  8256. `):"",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(`
  8257. `),[s,o]=o9e(i);if(s.length===0)return;const l=ere(s,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=s[0])==null?void 0:r.number)||1,items:l,raw:i.slice(0,o).join(`
  8258. `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(c9e,this.editor.getAttributes(J9)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=fx({find:eq,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=fx({find:eq,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(J9)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),u9e=/^\s*(\[([( |x])?\])\s$/,d9e=Ws.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",gi(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 WL(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"),o=document.createElement("span"),l=document.createElement("input"),c=document.createElement("div"),u=d=>{var f,m;l.ariaLabel=((m=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:m.call(f,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return u(t),s.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:m})=>{const p=n();if(typeof p!="number")return!1;const x=m.doc.nodeAt(p);return m.setNodeMarkup(p,void 0,{...x?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{i.setAttribute(d,f)}),i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,s.append(l,o),i.append(s,c),Object.entries(e).forEach(([d,f])=>{i.setAttribute(d,f)}),{dom:i,contentDOM:c,update:d=>d.type!==this.type?!1:(i.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,u(d),!0)}}},addInputRules(){return[fx({find:u9e,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),h9e=Ws.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",gi(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,`
  8259. `):"",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 o=WR(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,c)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:c}),customNestedParser:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(s)},i=WR(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,o)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:n.inlineTokens(s.mainContent),nestedTokens:o}),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()}}});kr.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(qne.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Wne.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Jne.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(tre.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(d9e.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(h9e.configure(this.options.taskList)),t}});var f9e=Ws.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",gi(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()}}}),m9e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,p9e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,g9e=$h.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",gi(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[hx({find:m9e,type:this.type})]},addPasteRules(){return[Nm({find:p9e,type:this.type})]}}),x9e=Ws.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),nre=$h.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",gi(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()}}}),b9e=nre;function y9e(t={}){return new ai({view(e){return new v9e(e,t)}})}class v9e{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=o=>{this[i](o)};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(),o=s.width/i.offsetWidth,l=s.height/i.offsetHeight;if(n){let f=e.nodeBefore,m=e.nodeAfter;if(f||m){let p=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(p){let x=p.getBoundingClientRect(),b=f?x.bottom:x.top;f&&m&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;r={left:x.left,right:x.right,top:b-y,bottom:b+y}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),m=this.width/2*o;r={left:f.left-m,right:f.left+m,top:f.top,bottom:f.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let u,d;if(!c||c==document.body&&getComputedStyle(c).position=="static")u=-pageXOffset,d=-pageYOffset;else{let f=c.getBoundingClientRect(),m=f.width/c.offsetWidth,p=f.height/c.offsetHeight;u=f.left-c.scrollLeft*m,d=f.top-c.scrollTop*p}this.element.style.left=(r.left-u)/o+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"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 o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=nte(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class hi extends kn{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return hi.valid(r)?new hi(r):kn.near(r)}content(){return zt.empty}eq(e){return e instanceof hi&&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 hi(e.resolve(n.pos))}getBookmark(){return new i5(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!_9e(e)||!w9e(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&&hi.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){s=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=n;let c=e.doc.resolve(i);if(hi.valid(c))return c}for(;;){let o=n>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!Jt.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*n),r=!1;continue e}break}s=o,i+=n;let l=e.doc.resolve(i);if(hi.valid(l))return l}return null}}}hi.prototype.visible=!1;hi.findFrom=hi.findGapCursorFrom;kn.jsonID("gapcursor",hi);class i5{constructor(e){this.pos=e}map(e){return new i5(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return hi.valid(n)?new hi(n):kn.near(n)}}function rre(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function _9e(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||rre(i.type))return!0;if(i.inlineContent)return!1}}return!0}function w9e(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||rre(i.type))return!0;if(i.inlineContent)return!1}}return!0}function S9e(){return new ai({props:{decorations:C9e,createSelectionBetween(t,e,n){return e.pos==n.pos&&hi.valid(n)?new hi(n):null},handleClick:M9e,handleKeyDown:N9e,handleDOMEvents:{beforeinput:E9e}}})}const N9e=nne({ArrowLeft:c1("horiz",-1),ArrowRight:c1("horiz",1),ArrowUp:c1("vert",-1),ArrowDown:c1("vert",1)});function c1(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,l=e>0?o.$to:o.$from,c=o.empty;if(o instanceof pn){if(!s.endOfTextblock(n)||l.depth==0)return!1;c=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=hi.findGapCursorFrom(l,e,c);return u?(i&&i(r.tr.setSelection(new hi(u))),!0):!1}}function M9e(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!hi.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Jt.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new hi(r))),!0)}function E9e(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof hi))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=Et.empty;for(let o=r.length-1;o>=0;o--)i=Et.from(r[o].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new zt(i,0,0));return s.setSelection(pn.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function C9e(t){if(!(t.selection instanceof hi))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ei.create(t.doc,[gs.widget(t.selection.head,e,{key:"gapcursor"})])}var X2=200,ya=function(){};ya.prototype.append=function(e){return e.length?(e=ya.from(e),!this.length&&e||e.length<X2&&this.leafAppend(e)||this.length<X2&&e.leafPrepend(this)||this.appendInner(e)):this};ya.prototype.prepend=function(e){return e.length?ya.from(e).append(this):this};ya.prototype.appendInner=function(e){return new T9e(this,e)};ya.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?ya.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};ya.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ya.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)};ya.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},n,r),i};ya.from=function(e){return e instanceof ya?e:e&&e.length?new ire(e):ya.empty};var ire=(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,o,l){for(var c=s;c<o;c++)if(i(this.values[c],l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,o,l){for(var c=s-1;c>=o;c--)if(i(this.values[c],l+c)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=X2)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=X2)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})(ya);ya.empty=new ire([]);var T9e=(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,o){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(r,Math.min(i,l),s,o)===!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})(ya);const A9e=500;class jl{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 o=e.tr,l,c,u=[],d=[];return this.items.forEach((f,m)=>{if(!f.step){i||(i=this.remapping(r,m+1),s=i.maps.length),s--,d.push(f);return}if(i){d.push(new tc(f.map));let p=f.step.map(i.slice(s)),x;p&&o.maybeStep(p).doc&&(x=o.mapping.maps[o.mapping.maps.length-1],u.push(new tc(x,void 0,void 0,u.length+d.length))),s--,x&&i.appendMap(x,s)}else o.maybeStep(f.step);if(f.selection)return l=i?f.selection.map(i.slice(s)):f.selection,c=new jl(this.items.slice(0,r).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:l}}addTransform(e,n,r,i){let s=[],o=this.eventCount,l=this.items,c=!i&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),m=new tc(e.mapping.maps[d],f,n),p;(p=c&&c.merge(m))&&(m=p,d?s.pop():l=l.slice(0,l.length-1)),s.push(m),n&&(o++,n=void 0),i||(c=m)}let u=o-r.depth;return u>j9e&&(l=k9e(l,u),o-=u),new jl(l.append(s),o)}remapping(e,n){let r=new Sy;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new jl(this.items.append(e.map(n=>new tc(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(m=>{m.selection&&l--},i);let c=n;this.items.forEach(m=>{let p=s.getMirror(--c);if(p==null)return;o=Math.min(o,p);let x=s.maps[p];if(m.step){let b=e.steps[p].invert(e.docs[p]),y=m.selection&&m.selection.map(s.slice(c+1,p));y&&l++,r.push(new tc(x,b,y))}else r.push(new tc(x))},i);let u=[];for(let m=n;m<o;m++)u.push(new tc(s.maps[m]));let d=this.items.slice(0,i).append(u).append(r),f=new jl(d,l);return f.emptyItemCount()>A9e&&(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((o,l)=>{if(l>=e)i.push(o),o.selection&&s++;else if(o.step){let c=o.step.map(n.slice(r)),u=c&&c.getMap();if(r--,u&&n.appendMap(u,r),c){let d=o.selection&&o.selection.map(n.slice(r));d&&s++;let f=new tc(u.invert(),c,d),m,p=i.length-1;(m=i.length&&i[p].merge(f))?i[p]=m:i.push(f)}}else o.map&&r--},this.items.length,0),new jl(ya.from(i.reverse()),s)}}jl.empty=new jl(ya.empty,0);function k9e(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class tc{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 tc(n.getMap().invert(),n,this.selection)}}}class Vd{constructor(e,n,r,i,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const j9e=20;function P9e(t,e,n,r){let i=n.getMeta(Jf),s;if(i)return i.historyState;n.getMeta(O9e)&&(t=new Vd(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Jf))return o.getMeta(Jf).redo?new Vd(t.done.addTransform(n,void 0,r,F1(e)),t.undone,tq(n.mapping.maps),t.prevTime,t.prevComposition):new Vd(t.done,t.undone.addTransform(n,void 0,r,F1(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),c=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!R9e(n,t.prevRanges)),u=o?Ij(t.prevRanges,n.mapping):tq(n.mapping.maps);return new Vd(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,F1(e)),jl.empty,u,n.time,l??t.prevComposition)}else return(s=n.getMeta("rebased"))?new Vd(t.done.rebased(n,s),t.undone.rebased(n,s),Ij(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Vd(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Ij(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function R9e(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 tq(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,s,o)=>e.push(s,o));return e}function Ij(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 D9e(t,e,n){let r=F1(e),i=Jf.get(e).spec.config,s=(n?t.undone:t.done).popEvent(e,r);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(n?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),c=new Vd(n?l:s.remaining,n?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(Jf,{redo:n,historyState:c})}let Fj=!1,nq=null;function F1(t){let e=t.plugins;if(nq!=e){Fj=!1,nq=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Fj=!0;break}}return Fj}const Jf=new ia("history"),O9e=new ia("closeHistory");function L9e(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new ai({key:Jf,state:{init(){return new Vd(jl.empty,jl.empty,null,0,-1)},apply(e,n,r){return P9e(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?sre:r=="historyRedo"?ore:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function are(t,e){return(n,r)=>{let i=Jf.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let s=D9e(i,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const sre=are(!1,!0),ore=are(!0,!0);kr.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 ai({key:new ia("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 o=s-i,l=0,c=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(l,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,c=s-r,u=l-c,d=l;return e.deleteRange(u,d),!(this.storage.characters({node:e.doc})>r)}})]}});var I9e=kr.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[y9e(this.options)]}});kr.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new ai({key:new ia("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!n||!r)return ei.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((c,u)=>{if(c.isText)return;if(!(i>=u&&i<=u+c.nodeSize-1))return!1;o+=1});let l=0;return t.descendants((c,u)=>{if(c.isText||!(i>=u&&i<=u+c.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";s.push(gs.node(u,u+c.nodeSize,{class:this.options.className}))}),ei.create(t,s)}}})]}});var F9e=kr.create({name:"gapCursor",addProseMirrorPlugins(){return[S9e()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=mr(Qt(t,"allowGapCursor",n)))!=null?e:null}}});kr.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new ai({key:new ia("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((o,l)=>{const c=r>=l&&r<=l+o.nodeSize,u=!o.isLeaf&&OM(o);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];s&&d.push(this.options.emptyEditorClass);const f=gs.node(l,l+o.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:l,hasAnchor:c}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),ei.create(t,i)}}})]}});kr.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new ai({key:new ia("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||bne(n.selection)||t.view.dragging?null:ei.create(n.doc,[gs.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function rq({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var U9e=kr.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new ia(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 ai({key:e,appendTransaction:(i,s,o)=>{const{doc:l,tr:c,schema:u}=o,d=e.getState(o),f=l.content.size,m=u.nodes[n];if(d)return c.insert(f,m.create())},state:{init:(i,s)=>{const o=s.tr.doc.lastChild;return!rq({node:o,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;const o=i.doc.lastChild;return!rq({node:o,types:r})}}})]}}),z9e=kr.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>sre(t,e),redo:()=>({state:t,dispatch:e})=>ore(t,e)}},addProseMirrorPlugins(){return[L9e(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()}}}),B9e=kr.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(mGe.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(cGe.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(qne.configure(this.options.bulletList)),this.options.code!==!1&&i.push(xGe.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(vGe.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(_Ge.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(I9e.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(F9e.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(wGe.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(SGe.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(z9e.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(NGe.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(AGe.configure(this.options.italic)),this.options.listItem!==!1&&i.push(Wne.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(Jne.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(Gne.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(tre.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(f9e.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(g9e.configure(this.options.strike)),this.options.text!==!1&&i.push(x9e.configure(this.options.text)),this.options.underline!==!1&&i.push(nre.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(U9e.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),$9e=B9e,H9e=kr.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")}}}),V9e=H9e,G9e=20,lre=(t,e=0)=>{const n=[];return!t.children.length||e>G9e||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...lre(r,e+1))}),n},q9e=t=>{if(!t.children.length)return;const e=lre(t);e&&e.forEach(n=>{var r,i;const s=n.getAttribute("style"),o=(i=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:i.getAttribute("style");n.setAttribute("style",`${o};${s}`)})},cre=$h.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&q9e(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",gi(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}}}}),W9e=kr.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 o=s[0].trim().toLowerCase(),l=s.slice(1).join(":").trim();if(o==="background-color")return l.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()}}}),ure=kr.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 o=s[0].trim().toLowerCase(),l=s.slice(1).join(":").trim();if(o==="color")return l.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()}}}),K9e=kr.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()}}}),X9e=kr.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()}}}),Y9e=kr.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()}}});kr.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(W9e.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(ure.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(K9e.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(X9e.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(Y9e.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(cre.configure(this.options.textStyle)),t}});var Q9e=ure,Z9e=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,J9e=Ws.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",gi(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,o;const l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",c=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",u=(o=(s=t.attrs)==null?void 0:s.title)!=null?o:"";return u?`![${c}](${l} "${u}")`:`![${c}](${l})`},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:o})=>{const l=document.createElement("img");Object.entries(o).forEach(([d,f])=>{if(f!=null)switch(d){case"width":case"height":break;default:l.setAttribute(d,f);break}}),l.src=o.src;const c=new D7e({element:l,node:i,getPos:s,onResize:(d,f)=>{l.style.width=`${d}px`,l.style.height=`${f}px`},onCommit:(d,f)=>{const m=s();m!==void 0&&this.editor.chain().setNodeSelection(m).updateAttributes(this.name,{width:d,height:f}).run()},onUpdate:(d,f,m)=>d.type===i.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),u=c.dom;return u.style.visibility="hidden",u.style.pointerEvents="none",l.onload=()=>{u.style.visibility="",u.style.pointerEvents=""},c}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[Rne({find:Z9e,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),eqe=J9e;function aD({content:t,onChange:e,placeholder:n}){const r=iGe({extensions:[$9e.configure({heading:!1,codeBlock:!1,code:!1}),b9e,e9e.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),V9e.configure({types:["paragraph"]}),cre,Q9e,eqe.configure({HTMLAttributes:{style:"max-width: 100%; height: auto;"}})],content:t,onUpdate:({editor:o})=>{e(o.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:o,isActive:l=!1,children:c,title:u})=>a.jsx("button",{type:"button",onClick:o,title:u,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary transition-colors ${l?"bg-bambu-dark-tertiary text-bambu-green":"text-bambu-gray"}`,children:c}),s=()=>{const o=window.prompt("Enter URL:");o&&r.chain().focus().setLink({href:o}).run()};return a.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[a.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[a.jsx(i,{onClick:()=>r.chain().focus().toggleBold().run(),isActive:r.isActive("bold"),title:"Bold",children:a.jsx(Sce,{className:"w-4 h-4"})}),a.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:a.jsx(gde,{className:"w-4 h-4"})}),a.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:a.jsx(sfe,{className:"w-4 h-4"})}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),a.jsx(i,{onClick:()=>r.chain().focus().toggleBulletList().run(),isActive:r.isActive("bulletList"),title:"Bullet List",children:a.jsx(gN,{className:"w-4 h-4"})}),a.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:a.jsx(NW,{className:"w-4 h-4"})}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),a.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("left").run(),isActive:r.isActive({textAlign:"left"}),title:"Align Left",children:a.jsx(Zhe,{className:"w-4 h-4"})}),a.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("center").run(),isActive:r.isActive({textAlign:"center"}),title:"Align Center",children:a.jsx(Khe,{className:"w-4 h-4"})}),a.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("right").run(),isActive:r.isActive({textAlign:"right"}),title:"Align Right",children:a.jsx(Yhe,{className:"w-4 h-4"})}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),a.jsx(i,{onClick:s,isActive:r.isActive("link"),title:"Add Link",children:a.jsx(Fy,{className:"w-4 h-4"})}),r.isActive("link")&&a.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:a.jsx(OD,{className:"w-4 h-4"})})]}),a.jsx(Q7e,{editor:r})]})}function dre({archiveId:t,archiveName:e,onClose:n}){const r=on(),[i,s]=w.useState(!1),[o,l]=w.useState(null),[c,u]=w.useState({}),{data:d,isLoading:f,error:m}=at({queryKey:["archive-project-page",t],queryFn:()=>ue.getArchiveProjectPage(t)}),p=mt({mutationFn:T=>ue.updateArchiveProjectPage(t,T),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),s(!1),u({})}});w.useEffect(()=>{const T=k=>{k.key==="Escape"&&(o!==null?l(null):i?v():n())};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[o,i,n]);const x=[...d?.model_pictures||[],...d?.profile_pictures||[]],b=()=>{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)},y=()=>{p.mutate(c)},v=()=>{s(!1),u({})},S=T=>{const k=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],E=new DOMParser().parseFromString(T,"text/html"),D=A=>{if(A.nodeType===Node.TEXT_NODE)return A.textContent||"";if(A.nodeType===Node.ELEMENT_NODE){const R=A,F=R.tagName.toLowerCase();if(!k.includes(F))return Array.from(R.childNodes).map(D).join("");let O="";if(F==="a"&&R.getAttribute("href")){const j=R.getAttribute("href");j?.toLowerCase().startsWith("http")&&(O=` href="${j}" target="_blank" rel="noopener noreferrer"`)}if(F==="img"){const j=R.getAttribute("src");if(!j?.toLowerCase().startsWith("http"))return"";O=` src="${j}" style="max-width: 100%; height: auto;"`}const H=Array.from(R.childNodes).map(D).join("");return["br","img"].includes(F)?`<${F}${O} />`:`<${F}${O}>${H}</${F}>`}return""};return Array.from(E.body.childNodes).map(D).join("")},N=d&&(d.title||d.description||d.designer||d.profile_title||x.length>0),C=T=>{T.target===T.currentTarget&&n()};return a.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:C,children:[a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(fs,{className:"w-5 h-5 text-bambu-green"}),a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&a.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[!i&&N&&a.jsxs(Ne,{variant:"ghost",size:"sm",onClick:b,children:[a.jsx(rm,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&a.jsxs(a.Fragment,{children:[a.jsx(Ne,{variant:"ghost",size:"sm",onClick:v,children:"Cancel"}),a.jsxs(Ne,{variant:"primary",size:"sm",onClick:y,disabled:p.isPending,children:[a.jsx(ms,{className:"w-4 h-4 mr-1"}),"Save"]})]}),a.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Dt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[f&&a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),m&&a.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!N&&a.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[a.jsx(fs,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),a.jsx("p",{children:"No project page data found in this 3MF file."}),a.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),d&&N&&a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-4",children:[i?a.jsx("input",{type:"text",value:c.title||"",onChange:T=>u({...c,title:T.target.value}),placeholder:"Title",className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-4 py-2 text-white text-xl font-semibold"}):d.title&&a.jsx("h3",{className:"text-xl font-semibold text-white",children:d.title}),a.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(am,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:c.designer||"",onChange:T=>u({...c,designer:T.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.designer&&a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[a.jsx(am,{className:"w-4 h-4"}),a.jsx("span",{children:d.designer}),d.designer_user_id&&a.jsx("a",{href:`https://makerworld.com/en/@${d.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:a.jsx(Yr,{className:"w-3 h-3"})})]}),d.creation_date&&a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[a.jsx(ti,{className:"w-4 h-4"}),a.jsx("span",{children:d.creation_date})]}),i?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(fs,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:c.license||"",onChange:T=>u({...c,license:T.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.license&&a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[a.jsx(fs,{className:"w-4 h-4"}),a.jsx("span",{children:d.license})]}),d.origin&&a.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:d.origin})]})]}),(d.description||i)&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?a.jsx(aD,{content:c.description||"",onChange:T=>u({...c,description:T}),placeholder:"Enter description..."}):a.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:S(d.description||"")}})]}),(d.profile_title||d.profile_description||i)&&a.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),i?a.jsxs("div",{className:"space-y-2",children:[a.jsx("input",{type:"text",value:c.profile_title||"",onChange:T=>u({...c,profile_title:T.target.value}),placeholder:"Profile Title",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-white"}),a.jsx(aD,{content:c.profile_description||"",onChange:T=>u({...c,profile_description:T}),placeholder:"Profile description..."})]}):a.jsxs(a.Fragment,{children:[d.profile_title&&a.jsx("p",{className:"text-white font-medium",children:d.profile_title}),d.profile_description&&a.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:S(d.profile_description)}}),d.profile_user_name&&a.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",d.profile_user_name]})]})]}),x.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[a.jsx(Du,{className:"w-4 h-4"}),"Images (",x.length,")"]}),a.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:x.map((T,k)=>a.jsx("button",{onClick:()=>l(k),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:a.jsx("img",{src:T.url,alt:T.name,className:"w-full h-full object-cover"})},T.path))})]}),d.design_model_id&&a.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:a.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:[a.jsx(Yr,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),o!==null&&x[o]&&a.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>l(null),children:[a.jsx("button",{onClick:T=>{T.stopPropagation(),l(Math.max(0,o-1))},disabled:o===0,className:"absolute left-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:a.jsx(gh,{className:"w-6 h-6 text-white"})}),a.jsx("img",{src:x[o].url,alt:x[o].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:T=>T.stopPropagation()}),a.jsx("button",{onClick:T=>{T.stopPropagation(),l(Math.min(x.length-1,o+1))},disabled:o===x.length-1,className:"absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:a.jsx(vs,{className:"w-6 h-6 text-white"})}),a.jsx("button",{onClick:()=>l(null),className:"absolute top-4 right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary",children:a.jsx(Dt,{className:"w-6 h-6 text-white"})}),a.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[o+1," / ",x.length]})]})]})}const tqe=[.25,.5,.75,1,1.5,2,3,4];function tg(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}function nqe({archiveId:t,timelapseSrc:e,onClose:n,onSave:r}){const{showToast:i}=Vn(),s=w.useRef(null),o=w.useRef(null),[l,c]=w.useState(!1),[u,d]=w.useState(0),[f,m]=w.useState(0),[p,x]=w.useState(0),[b,y]=w.useState(0),[v,S]=w.useState(1),[N,C]=w.useState(null),[T,k]=w.useState(null),[E,D]=w.useState(.8),[A,R]=w.useState(!1),{data:F,isLoading:O}=at({queryKey:["timelapse-info",t],queryFn:()=>ue.getTimelapseInfo(t)}),{data:H}=at({queryKey:["timelapse-thumbnails",t],queryFn:()=>ue.getTimelapseThumbnails(t,15)}),j=mt({mutationFn:()=>ue.processTimelapse(t,{trimStart:p,trimEnd:b,speed:v,saveMode:"replace"},N||void 0),onSuccess:B=>{i(B.message,"success"),r?.(),n()},onError:B=>{i(B.message||"Processing failed","error")}});w.useEffect(()=>{F?.duration&&b===0&&y(F.duration)},[F?.duration,b]),w.useEffect(()=>{const B=W=>{W.key==="Escape"&&n()};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[n]),w.useEffect(()=>{const B=s.current;if(!B)return;const W=()=>{const fe=B.currentTime;d(fe),fe>=b&&(B.currentTime=p)},se=()=>{m(B.duration),b===0&&y(B.duration)},ne=()=>c(!0),ce=()=>c(!1);return B.addEventListener("timeupdate",W),B.addEventListener("durationchange",se),B.addEventListener("play",ne),B.addEventListener("pause",ce),()=>{B.removeEventListener("timeupdate",W),B.removeEventListener("durationchange",se),B.removeEventListener("play",ne),B.removeEventListener("pause",ce)}},[p,b]),w.useEffect(()=>{const B=o.current,W=s.current;!B||!W||!T||(B.currentTime=W.currentTime,B.playbackRate=W.playbackRate,l&&!A?B.play().catch(()=>{}):B.pause())},[l,T,A]),w.useEffect(()=>{o.current&&(o.current.volume=A?0:E)},[E,A]),w.useEffect(()=>{s.current&&(s.current.playbackRate=v),o.current&&(o.current.playbackRate=v)},[v]);const G=w.useCallback(()=>{const B=s.current;B&&(l?B.pause():(B.currentTime<p&&(B.currentTime=p),B.play()))},[l,p]),$=B=>{const W=s.current;W&&(W.currentTime=Math.max(p,Math.min(b,B)))},q=B=>{const W=B.target.files?.[0];W&&(T&&URL.revokeObjectURL(T),C(W),k(URL.createObjectURL(W)))},Y=()=>{T&&URL.revokeObjectURL(T),C(null),k(null)};w.useEffect(()=>()=>{T&&URL.revokeObjectURL(T)},[T]);const Z=b-p,oe=Z/v;return O?a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:a.jsxs("div",{className:"flex items-center gap-3 text-white",children:[a.jsx(ct,{className:"w-6 h-6 animate-spin"}),"Loading video info..."]})}):a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:a.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-5xl w-full mx-4 max-h-[90vh] overflow-hidden flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(ih,{className:"w-5 h-5 text-bambu-green"}),"Edit Timelapse"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ne,{variant:"primary",size:"sm",onClick:()=>j.mutate(),disabled:j.isPending,children:j.isPending?a.jsxs(a.Fragment,{children:[a.jsx(ct,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(ms,{className:"w-4 h-4"}),"Save"]})}),a.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:a.jsx(Dt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[a.jsxs("div",{className:"relative",children:[a.jsx("video",{ref:s,src:e,className:"w-full rounded-lg bg-black",onClick:G,muted:!!T}),!l&&a.jsx("button",{onClick:G,className:"absolute inset-0 flex items-center justify-center bg-black/30 hover:bg-black/40 transition-colors",children:a.jsx("div",{className:"p-4 bg-bambu-green rounded-full",children:a.jsx(Us,{className:"w-8 h-8 text-white"})})}),T&&a.jsx("audio",{ref:o,src:T,loop:!0})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(whe,{className:"w-4 h-4"}),a.jsx("span",{children:"Trim"}),a.jsxs("span",{className:"ml-auto",children:[tg(p)," - ",tg(b)," (",tg(Z),")"]})]}),a.jsxs("div",{className:"relative h-16 bg-bambu-dark rounded-lg overflow-hidden",children:[a.jsx("div",{className:"absolute inset-0 flex",children:H?.thumbnails.map((B,W)=>a.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${B})`}},W))}),a.jsx("div",{className:"absolute inset-y-0 left-0 bg-black/60",style:{width:`${p/f*100}%`}}),a.jsx("div",{className:"absolute inset-y-0 right-0 bg-black/60",style:{width:`${(f-b)/f*100}%`}}),a.jsx("div",{className:"absolute inset-y-0 border-2 border-bambu-green",style:{left:`${p/f*100}%`,right:`${(f-b)/f*100}%`}}),a.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-white shadow-lg",style:{left:`${u/f*100}%`}}),a.jsx("input",{type:"range",min:0,max:f,step:.1,value:p,onChange:B=>{const W=parseFloat(B.target.value);W<b-1&&(x(W),s.current&&s.current.currentTime<W&&(s.current.currentTime=W))},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 50% 0 0)"}}),a.jsx("input",{type:"range",min:0,max:f,step:.1,value:b,onChange:B=>{const W=parseFloat(B.target.value);W>p+1&&y(W)},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 0 0 50%)"}})]}),a.jsx("input",{type:"range",min:0,max:f,step:.1,value:u,onChange:B=>$(parseFloat(B.target.value)),className:`w-full h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8260. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8261. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
  8262. [&::-webkit-slider-thumb]:cursor-pointer`}),a.jsx("div",{className:"flex items-center justify-center gap-2",children:a.jsx("button",{onClick:G,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?a.jsx(jD,{className:"w-5 h-5 text-white"}):a.jsx(Us,{className:"w-5 h-5 text-white"})})})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(hN,{className:"w-4 h-4"}),a.jsx("span",{children:"Speed"}),a.jsxs("span",{className:"ml-auto",children:[v,"x (output: ",tg(oe),")"]})]}),a.jsx("div",{className:"flex gap-1",children:tqe.map(B=>a.jsxs("button",{onClick:()=>S(B),className:`flex-1 px-2 py-2 text-sm rounded transition-colors ${v===B?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[B,"x"]},B))})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(y3,{className:"w-4 h-4"}),a.jsx("span",{children:"Music Overlay"})]}),N?a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[a.jsx(y3,{className:"w-5 h-5 text-bambu-green"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:N.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[(N.size/1024/1024).toFixed(1)," MB"]})]}),a.jsx("button",{onClick:()=>R(!A),className:"p-2 hover:bg-bambu-dark-tertiary rounded transition-colors",children:A?a.jsx(pfe,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(ffe,{className:"w-4 h-4 text-bambu-green"})}),a.jsx("input",{type:"range",min:0,max:1,step:.1,value:E,onChange:B=>D(parseFloat(B.target.value)),className:`w-20 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8263. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8264. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full`}),a.jsx("button",{onClick:Y,className:"p-2 hover:bg-red-500/20 rounded transition-colors",children:a.jsx(an,{className:"w-4 h-4 text-red-400"})})]}):a.jsxs("label",{className:"flex flex-col items-center justify-center gap-2 p-6 border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green/50 transition-colors",children:[a.jsx(Oa,{className:"w-8 h-8 text-bambu-gray"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:"Drop audio file or click to upload"}),a.jsx("span",{className:"text-xs text-bambu-gray/60",children:"MP3, WAV, M4A, AAC, OGG"}),a.jsx("input",{type:"file",accept:".mp3,.wav,.m4a,.aac,.ogg,audio/*",onChange:q,className:"hidden"})]})]}),a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg text-sm space-y-1",children:[a.jsxs("p",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white",children:"Original:"})," ",tg(f)," @ ",F?.width,"x",F?.height]}),a.jsxs("p",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white",children:"Output:"})," ",tg(oe)," @ ",v,"x speed",N&&" + music overlay"]})]})]}),j.isPending&&a.jsxs("div",{className:"absolute inset-0 bg-black/80 flex flex-col items-center justify-center gap-4",children:[a.jsx(ct,{className:"w-12 h-12 text-bambu-green animate-spin"}),a.jsx("p",{className:"text-white text-lg",children:"Processing timelapse..."}),a.jsx("p",{className:"text-bambu-gray text-sm",children:"This may take a few moments"})]})]})})}const rqe=[.25,.5,.75,1,1.5,2,3,4];function hre({src:t,title:e,downloadFilename:n,archiveId:r,onClose:i,onEdit:s}){const o=w.useRef(null),[l,c]=w.useState(!0),[u,d]=w.useState(1),[f,m]=w.useState(0),[p,x]=w.useState(0),[b,y]=w.useState(!1);w.useEffect(()=>{const E=o.current;E&&(E.playbackRate=u)},[u]),w.useEffect(()=>{const E=D=>{D.key==="Escape"&&i()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[i]),w.useEffect(()=>{const E=o.current;if(!E)return;const D=()=>m(E.currentTime),A=()=>x(E.duration),R=()=>c(!0),F=()=>c(!1);return E.addEventListener("timeupdate",D),E.addEventListener("durationchange",A),E.addEventListener("play",R),E.addEventListener("pause",F),()=>{E.removeEventListener("timeupdate",D),E.removeEventListener("durationchange",A),E.removeEventListener("play",R),E.removeEventListener("pause",F)}},[]);const v=()=>{const E=o.current;E&&(l?E.pause():E.play())},S=E=>{const D=o.current;D&&(D.currentTime=parseFloat(E.target.value))},N=()=>{const E=o.current;E&&(E.currentTime=Math.max(0,E.currentTime-5))},C=()=>{const E=o.current;E&&(E.currentTime=Math.min(p,E.currentTime+5))},T=E=>{const D=Math.floor(E/60),A=Math.floor(E%60);return`${D}:${A.toString().padStart(2,"0")}`},k=()=>{const E=document.createElement("a");E.href=t,E.download=n,E.click()};return a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:[a.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(ih,{className:"w-5 h-5 text-bambu-green"}),e]}),a.jsxs("div",{className:"flex items-center gap-2",children:[r&&a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>y(!0),children:[a.jsx(Ki,{className:"w-4 h-4"}),"Edit"]}),a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:k,children:[a.jsx(pi,{className:"w-4 h-4"}),"Download"]}),a.jsx("button",{onClick:i,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:a.jsx(Dt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),a.jsxs("div",{className:"p-4",children:[a.jsx("video",{ref:o,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:v}),a.jsxs("div",{className:"mt-4 space-y-3",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:T(f)}),a.jsx("input",{type:"range",min:0,max:p||100,value:f,onChange:S,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8265. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8266. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
  8267. [&::-webkit-slider-thumb]:cursor-pointer`}),a.jsx("span",{className:"text-xs text-bambu-gray w-12",children:T(p)})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:N,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:a.jsx(Rhe,{className:"w-5 h-5 text-bambu-gray"})}),a.jsx("button",{onClick:v,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?a.jsx(jD,{className:"w-5 h-5 text-white"}):a.jsx(Us,{className:"w-5 h-5 text-white"})}),a.jsx("button",{onClick:C,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:a.jsx(DD,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:"Speed:"}),a.jsx("div",{className:"flex gap-1",children:rqe.map(E=>a.jsxs("button",{onClick:()=>d(E),className:`px-2 py-1 text-xs rounded transition-colors ${u===E?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[E,"x"]},E))})]})]})]})]})]}),b&&r&&a.jsx(nqe,{archiveId:r,timelapseSrc:t,onClose:()=>y(!1),onSave:s})]})}function iqe({archiveIds:t,onClose:e}){w.useEffect(()=>{const s=o=>{o.key==="Escape"&&e()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e]);const{data:n,isLoading:r,error:i}=at({queryKey:["archive-comparison",t],queryFn:()=>ue.compareArchives(t)});return a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:e,children:a.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:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Compare Archives (",t.length,")"]}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white p-1",children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"flex-1 overflow-auto p-4 bg-bambu-dark-secondary",children:r?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(ct,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i?a.jsxs("div",{className:"text-center py-12 text-red-400",children:[a.jsx(jn,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),a.jsx("p",{children:"Failed to load comparison"}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:i instanceof Error?i.message:"Unknown error"})]}):n?a.jsx(aqe,{comparison:n}):null}),a.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:a.jsx(Ne,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function aqe({comparison:t}){return a.jsxs("div",{className:"space-y-6",children:[a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full",children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.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=>a.jsxs("th",{className:"text-left text-sm font-medium pb-2 px-2 min-w-[120px]",children:[a.jsx("div",{className:"text-white truncate max-w-[150px]",title:e.print_name,children:e.print_name}),a.jsx("div",{className:`text-xs ${e.status==="completed"?"text-status-ok":e.status==="failed"?"text-status-error":"text-bambu-gray"}`,children:e.status})]},e.id))]})}),a.jsx("tbody",{className:"divide-y divide-bambu-gray/20",children:t.comparison.map(e=>a.jsxs("tr",{className:e.has_difference?"bg-yellow-500/5":"",children:[a.jsx("td",{className:"py-2 pr-4 text-sm",children:a.jsxs("div",{className:"flex items-center gap-2",children:[e.has_difference&&a.jsx(jn,{className:"w-3 h-3 text-yellow-400 flex-shrink-0"}),a.jsx("span",{className:e.has_difference?"text-yellow-400":"text-bambu-gray",children:e.label})]})}),e.values.map((n,r)=>a.jsxs("td",{className:"py-2 px-2 text-sm text-white",children:[n??a.jsx("span",{className:"text-bambu-gray/50",children:"-"}),e.unit&&n!==null&&a.jsx("span",{className:"text-bambu-gray ml-1",children:e.unit})]},r))]},e.field))})]})}),t.differences.length>0&&a.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[a.jsxs("h4",{className:"text-sm font-medium text-yellow-400 mb-2 flex items-center gap-2",children:[a.jsx(jn,{className:"w-4 h-4"}),t.differences.length," Difference",t.differences.length>1?"s":""," Found"]}),a.jsxs("ul",{className:"text-sm text-white/80 space-y-1",children:[t.differences.slice(0,5).map(e=>a.jsxs("li",{children:[a.jsx("span",{className:"text-yellow-400",children:e.label}),": ",e.values.join(" vs ")," ",e.unit||""]},e.field)),t.differences.length>5&&a.jsxs("li",{className:"text-bambu-gray",children:["...and ",t.differences.length-5," more"]})]})]}),t.success_correlation.has_both_outcomes?a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg",children:[a.jsxs("h4",{className:"text-sm font-medium text-white mb-3 flex items-center gap-2",children:[a.jsx(Wi,{className:"w-4 h-4 text-bambu-green"}),"Success/Failure Analysis"]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm mb-3",children:[a.jsxs("span",{className:"text-bambu-green",children:[t.success_correlation.successful_count," successful"]}),a.jsxs("span",{className:"text-red-400",children:[t.success_correlation.failed_count," failed"]})]}),t.success_correlation.insights&&t.success_correlation.insights.length>0?a.jsx("div",{className:"space-y-2",children:t.success_correlation.insights.map(e=>a.jsxs("div",{className:"text-sm p-2 bg-bambu-dark-secondary rounded",children:[a.jsxs("span",{className:"text-white font-medium",children:[e.label,":"]})," ",a.jsx("span",{className:"text-white/80",children:e.insight})]},e.field))}):a.jsx("p",{className:"text-sm text-bambu-gray",children:"No clear correlations found between settings and outcomes."})]}):a.jsx("div",{className:"p-4 bg-bambu-dark rounded-lg text-sm text-bambu-gray",children:a.jsx("p",{children:t.success_correlation.message||"Need both successful and failed prints for correlation analysis."})})]})}function sqe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function oqe(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4);if(i<1)return"Just now";if(i<60)return`${i}m ago`;const s=Math.floor(i/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}function lqe({upload:t,projects:e,onArchive:n,onDiscard:r,isArchiving:i,isDiscarding:s}){const[o,l]=w.useState(!1),[c,u]=w.useState(t.tags||""),[d,f]=w.useState(t.notes||""),[m,p]=w.useState(t.project_id),[x,b]=w.useState(!1);return a.jsx(wt,{children:a.jsxs(St,{className:"py-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(zf,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium",children:t.filename}),a.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[a.jsx("span",{children:sqe(t.file_size)}),a.jsx("span",{children:"·"}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Qn,{className:"w-3 h-3"}),oqe(t.uploaded_at)]}),t.source_ip&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"·"}),a.jsxs("span",{children:["from ",t.source_ip]})]})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:()=>l(!o),className:"p-1 text-bambu-gray hover:text-white transition-colors",children:o?a.jsx(xh,{className:"w-5 h-5"}):a.jsx(Xr,{className:"w-5 h-5"})}),a.jsx(Ne,{variant:"primary",size:"sm",onClick:()=>n(t.id,{tags:c,notes:d,project_id:m||void 0}),disabled:i,children:i?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsxs(a.Fragment,{children:[a.jsx(fo,{className:"w-4 h-4"}),"Archive"]})}),a.jsx(Ne,{variant:"secondary",size:"sm",onClick:()=>b(!0),disabled:s,children:s?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(an,{className:"w-4 h-4 text-red-400"})})]})]}),x&&a.jsx(Yn,{title:"Discard Upload",message:`Are you sure you want to discard "${t.filename}"? This cannot be undone.`,confirmText:"Discard",variant:"danger",onConfirm:()=>{r(t.id),b(!1)},onCancel:()=>b(!1)}),o&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),a.jsx("input",{type:"text",value:c,onChange:y=>u(y.target.value),placeholder:"e.g., functional, prototype, gift",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),a.jsx("textarea",{value:d,onChange:y=>f(y.target.value),placeholder:"Add notes about this print...",rows:2,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm resize-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Project"}),a.jsxs("select",{value:m||"",onChange:y=>p(y.target.value?Number(y.target.value):null),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white text-sm",children:[a.jsx("option",{value:"",children:"No project"}),e.map(y=>a.jsx("option",{value:y.id,children:y.name},y.id))]})]})]})]})})}function cqe(){const t=on(),{showToast:e}=Vn(),[n,r]=w.useState(!1),[i,s]=w.useState(!1),[o,l]=w.useState(new Set),[c,u]=w.useState(new Set),{data:d,isLoading:f}=at({queryKey:["pending-uploads"],queryFn:ig.list,refetchInterval:1e4}),{data:m}=at({queryKey:["projects"],queryFn:()=>ue.getProjects()}),p=mt({mutationFn:({id:v,data:S})=>ig.archive(v,S),onMutate:({id:v})=>{l(S=>new Set(S).add(v))},onSettled:(v,S,{id:N})=>{l(C=>{const T=new Set(C);return T.delete(N),T})},onSuccess:v=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived: ${v.print_name}`)},onError:v=>{e(v.message||"Failed to archive","error")}}),x=mt({mutationFn:v=>ig.discard(v),onMutate:v=>{u(S=>new Set(S).add(v))},onSettled:(v,S,N)=>{u(C=>{const T=new Set(C);return T.delete(N),T})},onSuccess:()=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e("Upload discarded")},onError:v=>{e(v.message||"Failed to discard","error")}}),b=mt({mutationFn:ig.archiveAll,onSuccess:v=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived ${v.archived} files${v.failed>0?`, ${v.failed} failed`:""}`)},onError:v=>{e(v.message||"Failed to archive all","error")}}),y=mt({mutationFn:ig.discardAll,onSuccess:v=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e(`Discarded ${v.discarded} files`)},onError:v=>{e(v.message||"Failed to discard all","error")}});return f?a.jsx(wt,{children:a.jsx(St,{className:"py-8 flex justify-center",children:a.jsx(ct,{className:"w-6 h-6 animate-spin text-bambu-green"})})}):!d||d.length===0?null:a.jsxs("div",{className:"mb-6",children:[a.jsxs(wt,{className:"border-l-4 border-l-yellow-500",children:[a.jsx(Hn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Oa,{className:"w-5 h-5 text-yellow-500"}),a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Pending Uploads (",d.length,")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ne,{variant:"primary",size:"sm",onClick:()=>r(!0),disabled:b.isPending,children:b.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsxs(a.Fragment,{children:[a.jsx(fo,{className:"w-4 h-4"}),"Archive All"]})}),a.jsx(Ne,{variant:"secondary",size:"sm",onClick:()=>s(!0),disabled:y.isPending,children:y.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsxs(a.Fragment,{children:[a.jsx(an,{className:"w-4 h-4"}),"Discard All"]})})]})]})}),a.jsxs(St,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"These files were uploaded via the virtual printer. Review and archive them to add to your collection."}),a.jsx("div",{className:"space-y-3",children:d.map(v=>a.jsx(lqe,{upload:v,projects:m||[],onArchive:(S,N)=>p.mutate({id:S,data:N}),onDiscard:S=>x.mutate(S),isArchiving:o.has(v.id),isDiscarding:c.has(v.id)},v.id))})]})]}),n&&a.jsx(Yn,{title:"Archive All Uploads",message:`Are you sure you want to archive all ${d.length} pending uploads?`,confirmText:"Archive All",onConfirm:()=>{b.mutate(),r(!1)},onCancel:()=>r(!1)}),i&&a.jsx(Yn,{title:"Discard All Uploads",message:`Are you sure you want to discard all ${d.length} pending uploads? This cannot be undone.`,confirmText:"Discard All",variant:"danger",onConfirm:()=>{y.mutate(),s(!1)},onCancel:()=>s(!1)})]})}function uqe({onClose:t}){const e=on(),{showToast:n}=Vn(),[r,i]=w.useState(""),[s,o]=w.useState(null),[l,c]=w.useState(""),[u,d]=w.useState(null),[f,m]=w.useState("count");w.useEffect(()=>{const A=R=>{R.key==="Escape"&&(s?o(null):u?d(null):t())};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[t,s,u]);const{data:p,isLoading:x}=at({queryKey:["tags"],queryFn:ue.getTags}),b=mt({mutationFn:({oldName:A,newName:R})=>ue.renameTag(A,R),onSuccess:(A,{oldName:R,newName:F})=>{e.invalidateQueries({queryKey:["tags"]}),e.invalidateQueries({queryKey:["archives"]}),n(`Renamed "${R}" to "${F}" in ${A.affected} archive${A.affected!==1?"s":""}`),o(null)},onError:A=>{n(A.message||"Failed to rename tag","error")}}),y=mt({mutationFn:A=>ue.deleteTag(A),onSuccess:(A,R)=>{e.invalidateQueries({queryKey:["tags"]}),e.invalidateQueries({queryKey:["archives"]}),n(`Deleted "${R}" from ${A.affected} archive${A.affected!==1?"s":""}`),d(null)},onError:A=>{n(A.message||"Failed to delete tag","error")}}),v=A=>{o(A.name),c(A.name),d(null)},S=()=>{o(null),c("")},N=()=>{if(!s||!l.trim())return;const A=l.trim();if(A===s){S();return}b.mutate({oldName:s,newName:A})},C=A=>{A.key==="Enter"?(A.preventDefault(),N()):A.key==="Escape"&&(A.preventDefault(),S())},T=A=>{d(A),o(null)},k=()=>{u&&y.mutate(u)},E=p?.filter(A=>A.name.toLowerCase().includes(r.toLowerCase())).sort((A,R)=>f==="count"&&R.count-A.count||A.name.localeCompare(R.name)),D=p?.reduce((A,R)=>A+R.count,0)||0;return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(wt,{className:"w-full max-w-lg max-h-[80vh] flex flex-col",children:a.jsxs(St,{className:"p-0 flex flex-col min-h-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(yh,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-xl font-semibold text-white",children:"Manage Tags"})]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(pa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:"Search tags...",className:"w-full pl-9 pr-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:r,onChange:A=>i(A.target.value)})]}),a.jsxs("select",{className:"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:f,onChange:A=>m(A.target.value),children:[a.jsx("option",{value:"count",children:"Sort by Count"}),a.jsx("option",{value:"name",children:"Sort by Name"})]})]}),p&&a.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[p.length," tag",p.length!==1?"s":""," across ",D," usage",D!==1?"s":""]})]}),a.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 p-4",children:x?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(ct,{className:"w-6 h-6 animate-spin text-bambu-gray"})}):E?.length?a.jsx("div",{className:"space-y-2",children:E.map(A=>a.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary transition-colors group",children:s===A.name?a.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[a.jsx("input",{type:"text",className:"flex-1 px-2 py-1 bg-bambu-dark-tertiary border border-bambu-green rounded text-white text-sm focus:outline-none",value:l,onChange:R=>c(R.target.value),onKeyDown:C,autoFocus:!0}),a.jsx(Ne,{size:"sm",variant:"primary",onClick:N,disabled:!l.trim()||b.isPending,className:"p-1.5",children:b.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(Wi,{className:"w-4 h-4"})}),a.jsx(Ne,{size:"sm",variant:"ghost",onClick:S,className:"p-1.5",children:a.jsx(Dt,{className:"w-4 h-4"})})]}):u===A.name?a.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[a.jsx(jn,{className:"w-4 h-4 text-yellow-400 flex-shrink-0"}),a.jsxs("span",{className:"text-sm text-bambu-gray-light flex-1",children:['Delete "',A.name,'" from ',A.count," archive",A.count!==1?"s":"","?"]}),a.jsx(Ne,{size:"sm",variant:"danger",onClick:k,disabled:y.isPending,className:"p-1.5",children:y.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(an,{className:"w-4 h-4"})}),a.jsx(Ne,{size:"sm",variant:"ghost",onClick:()=>d(null),className:"p-1.5",children:a.jsx(Dt,{className:"w-4 h-4"})})]}):a.jsxs(a.Fragment,{children:[a.jsx(yh,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"text-white flex-1 truncate",children:A.name}),a.jsx("span",{className:"px-2 py-0.5 rounded-full bg-bambu-dark-tertiary text-bambu-gray text-xs",children:A.count}),a.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[a.jsx("button",{onClick:()=>v(A),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Rename tag",children:a.jsx(Ki,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>T(A.name),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",title:"Delete tag",children:a.jsx(an,{className:"w-4 h-4"})})]})]})},A.name))}):a.jsx("div",{className:"text-center py-8 text-bambu-gray",children:r?"No tags match your search":"No tags found"})}),a.jsx("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary flex-shrink-0",children:a.jsx(Ne,{variant:"secondary",onClick:t,className:"flex-1",children:"Close"})})]})})})}function Y2(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function n0(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function kf(t){if(!t)return!1;const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function dqe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:s,isHighlighted:o,timeFormat:l="system"}){o&&console.log("ArchiveCard isHighlighted=true for archive:",t.id);const c=on(),{showToast:u}=Vn(),{hasPermission:d,canModify:f}=Si(),m=UD(),[p,x]=w.useState(!1),[b,y]=w.useState(!1),[v,S]=w.useState(!1),[N,C]=w.useState(!1),[T,k]=w.useState(!1),[E,D]=w.useState(!1),[A,R]=w.useState([]),[F,O]=w.useState(!1),[H,j]=w.useState(!1),[G,$]=w.useState(!1),[q,Y]=w.useState(!1),[Z,oe]=w.useState(!1),[B,W]=w.useState(!1),[se,ne]=w.useState(null),[ce,fe]=w.useState(null),[ye,ge]=w.useState(!1),xe=w.useRef(null),Pe=w.useRef(null),{data:Ue}=at({queryKey:["archive-plates",t.id],queryFn:()=>ue.getArchivePlates(t.id),enabled:ye,staleTime:300*1e3}),be=Ue?.plates??[],it=Ue?.is_multi_plate??!1,U=ce??0,K=mt({mutationFn:ie=>ue.uploadSource3mf(t.id,ie),onSuccess:ie=>{c.invalidateQueries({queryKey:["archives"]}),u(`Source 3MF attached: ${ie.filename}`)},onError:ie=>{u(ie.message||"Failed to upload source 3MF","error")}}),J=mt({mutationFn:()=>ue.deleteSource3mf(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Source 3MF removed")},onError:ie=>{u(ie.message||"Failed to remove source 3MF","error")}}),Q=mt({mutationFn:ie=>ue.uploadF3d(t.id,ie),onSuccess:ie=>{c.invalidateQueries({queryKey:["archives"]}),u(`F3D attached: ${ie.filename}`)},onError:ie=>{u(ie.message||"Failed to upload F3D","error")}}),z=mt({mutationFn:()=>ue.deleteF3d(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("F3D removed")},onError:ie=>{u(ie.message||"Failed to remove F3D","error")}}),re=mt({mutationFn:()=>ue.scanArchiveTimelapse(t.id),onSuccess:ie=>{ie.status==="attached"?(c.invalidateQueries({queryKey:["archives"]}),u(`Timelapse attached: ${ie.filename}`)):ie.status==="exists"?u("Timelapse already attached"):ie.status==="not_found"&&ie.available_files&&ie.available_files.length>0?(R(ie.available_files),D(!0)):u(ie.message||"No matching timelapse found","warning")},onError:ie=>{u(ie.message||"Failed to scan for timelapse","error")}}),Ee=mt({mutationFn:ie=>ue.selectArchiveTimelapse(t.id,ie),onSuccess:ie=>{c.invalidateQueries({queryKey:["archives"]}),u(`Timelapse attached: ${ie.filename}`),D(!1),R([])},onError:ie=>{u(ie.message||"Failed to attach timelapse","error")}}),_e=mt({mutationFn:()=>ue.deleteArchive(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Archive deleted")},onError:()=>{u("Failed to delete archive","error")}}),Te=mt({mutationFn:()=>ue.toggleFavorite(t.id),onSuccess:ie=>{c.invalidateQueries({queryKey:["archives"]}),u(ie.is_favorite?"Added to favorites":"Removed from favorites")}}),{data:V}=at({queryKey:["archive-folders",t.id],queryFn:()=>ue.getLibraryFoldersByArchive(t.id)}),L=mt({mutationFn:ie=>ue.updateArchive(t.id,{project_id:ie}),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),c.invalidateQueries({queryKey:["projects"]}),u("Project updated")},onError:()=>{u("Failed to update project","error")}}),X=ie=>{ie.preventDefault(),ne({x:ie.clientX,y:ie.clientY})},Me=[...kf(t.filename)?[{label:"Print",icon:a.jsx(Ir,{className:"w-4 h-4"}),onClick:()=>y(!0),disabled:!f("archives","reprint",t.created_by_id),title:f("archives","reprint",t.created_by_id)?void 0:"You do not have permission to reprint this archive"},{label:"Schedule",icon:a.jsx(ti,{className:"w-4 h-4"}),onClick:()=>Y(!0),disabled:!d("queue:create"),title:d("queue:create")?void 0:"You do not have permission to add to queue"},{label:"Open in Bambu Studio",icon:a.jsx(Yr,{className:"w-4 h-4"}),onClick:()=>{const ie=t.print_name||t.filename||"model",De=`${window.location.origin}${ue.getArchiveForSlicer(t.id,ie)}`;sc(De)}}]:[{label:"Slice",icon:a.jsx(Yr,{className:"w-4 h-4"}),onClick:()=>{const ie=t.print_name||t.filename||"model",De=`${window.location.origin}${ue.getArchiveForSlicer(t.id,ie)}`;sc(De)}}],{label:t.external_url?"External Link":"View on MakerWorld",icon:a.jsx(ah,{className:"w-4 h-4"}),onClick:()=>{const ie=t.external_url||t.makerworld_url;ie&&window.open(ie,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:a.jsx(Pi,{className:"w-4 h-4"}),onClick:()=>x(!0)},{label:"View Timelapse",icon:a.jsx(ih,{className:"w-4 h-4"}),onClick:()=>k(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:a.jsx(X1,{className:"w-4 h-4"}),onClick:()=>re.mutate(),disabled:!t.printer_id||!!t.timelapse_path||re.isPending||!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:"You do not have permission to update archives"},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:a.jsx(q1,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const ie=document.createElement("a");ie.href=ue.getSource3mfDownloadUrl(t.id),ie.download=`${t.print_name||t.filename}_source.3mf`,ie.click()}else xe.current?.click()},disabled:!t.source_3mf_path&&!f("archives","update",t.created_by_id),title:!t.source_3mf_path&&!f("archives","update",t.created_by_id)?"You do not have permission to upload files":void 0},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:a.jsx(Oa,{className:"w-4 h-4"}),onClick:()=>xe.current?.click(),disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:"You do not have permission to update this archive"},{label:"Remove Source 3MF",icon:a.jsx(an,{className:"w-4 h-4"}),onClick:()=>oe(!0),danger:!0,disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:"You do not have permission to update this archive"}]:[],{label:t.f3d_path?"Replace F3D":"Upload F3D",icon:a.jsx(Pi,{className:"w-4 h-4"}),onClick:()=>Pe.current?.click(),disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:"You do not have permission to update this archive"},...t.f3d_path?[{label:"Download F3D",icon:a.jsx(pi,{className:"w-4 h-4"}),onClick:()=>{const ie=document.createElement("a");ie.href=ue.getF3dDownloadUrl(t.id),ie.download=`${t.print_name||t.filename}.f3d`,ie.click()}},{label:"Remove F3D",icon:a.jsx(an,{className:"w-4 h-4"}),onClick:()=>W(!0),danger:!0,disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:"You do not have permission to update this archive"}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:a.jsx(pi,{className:"w-4 h-4"}),onClick:()=>{const ie=document.createElement("a");ie.href=ue.getArchiveDownload(t.id),ie.download=`${t.print_name||t.filename}.3mf`,ie.click()},disabled:!d("archives:read"),title:d("archives:read")?void 0:"You do not have permission to download archives"},{label:"Copy Download Link",icon:a.jsx(Ll,{className:"w-4 h-4"}),onClick:()=>{const ie=`${window.location.origin}${ue.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(ie).then(()=>{u("Link copied to clipboard")}).catch(()=>{u("Failed to copy link","error")})},disabled:!d("archives:read"),title:d("archives:read")?void 0:"You do not have permission to copy download links"},{label:"QR Code",icon:a.jsx(AW,{className:"w-4 h-4"}),onClick:()=>O(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:a.jsx(Ug,{className:"w-4 h-4"}),onClick:()=>j(!0),disabled:!t.photos?.length},{label:"Project Page",icon:a.jsx(fs,{className:"w-4 h-4"}),onClick:()=>$(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:a.jsx(im,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>Te.mutate(),disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:"You do not have permission to update this archive"},{label:"Edit",icon:a.jsx(Ki,{className:"w-4 h-4"}),onClick:()=>C(!0),disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:"You do not have permission to update this archive"},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:a.jsx(Qa,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:a.jsx(Qa,{className:"w-4 h-4"}),onClick:()=>{},disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:"You do not have permission to update this archive",submenu:(()=>{const ie=[];if(t.project_id&&ie.push({label:"Remove from Project",icon:a.jsx(Dt,{className:"w-4 h-4"}),onClick:()=>L.mutate(null),disabled:!f("archives","update",t.created_by_id)}),!s)ie.push({label:"Loading...",icon:a.jsx(ct,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const De=s.filter(Le=>Le.status==="active");De.length===0?ie.push({label:"No projects available",icon:a.jsx(Qa,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):De.forEach(Le=>{ie.push({label:Le.name,icon:a.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:Le.color||"#888"}}),onClick:()=>L.mutate(Le.id),disabled:t.project_id===Le.id||!f("archives","update",t.created_by_id)})})}return ie})()},{label:n?"Deselect":"Select",icon:n?a.jsx(Vs,{className:"w-4 h-4"}):a.jsx(il,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:a.jsx(an,{className:"w-4 h-4"}),onClick:()=>S(!0),danger:!0,disabled:!f("archives","delete",t.created_by_id),title:f("archives","delete",t.created_by_id)?void 0:"You do not have permission to delete this archive"}];return a.jsxs(wt,{"data-archive-id":t.id,className:`relative flex flex-col group ${n?"ring-2 ring-bambu-green":""} ${i?"cursor-pointer":""}`,style:o?{outline:"4px solid #facc15",outlineOffset:"2px"}:void 0,onContextMenu:X,onClick:i?()=>r(t.id):void 0,children:[i&&a.jsx("button",{className:"absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:ie=>{ie.stopPropagation(),r(t.id)},children:n?a.jsx(Vs,{className:"w-5 h-5 text-bambu-green"}):a.jsx(il,{className:"w-5 h-5 text-white"})}),a.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",onMouseEnter:()=>ge(!0),onMouseLeave:()=>ge(!1),children:[t.thumbnail_path?a.jsx("img",{src:ce!==null&&be.length>0?ue.getArchivePlateThumbnail(t.id,be[U]?.index??0):ue.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center",children:a.jsx(Du,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),it&&be.length>1&&a.jsxs(a.Fragment,{children:[a.jsx("button",{className:`absolute left-1 top-1/2 -translate-y-1/2 p-1 rounded-full bg-black/60 hover:bg-black/80 transition-all ${m?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:ie=>{ie.stopPropagation(),fe(De=>{const Le=De??0;return Le>0?Le-1:be.length-1})},title:"Previous plate",children:a.jsx(gh,{className:"w-4 h-4 text-white"})}),a.jsx("button",{className:`absolute right-1 top-1/2 -translate-y-1/2 p-1 rounded-full bg-black/60 hover:bg-black/80 transition-all ${m?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:ie=>{ie.stopPropagation(),fe(De=>{const Le=De??0;return Le<be.length-1?Le+1:0})},title:"Next plate",children:a.jsx(vs,{className:"w-4 h-4 text-white"})}),a.jsx("div",{className:`absolute bottom-1 left-1/2 -translate-x-1/2 flex gap-1 px-2 py-1 rounded-full bg-black/50 transition-all ${m?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:be.map((ie,De)=>a.jsx("button",{className:`w-2 h-2 rounded-full transition-colors ${De===U?"bg-bambu-green":"bg-white/50 hover:bg-white/80"}`,onClick:Le=>{Le.stopPropagation(),fe(De)},title:ie.name||`Plate ${ie.index}`},ie.index))})]}),a.jsx("button",{className:`absolute top-2 left-2 p-1.5 rounded bg-black/50 hover:bg-black/70 transition-all ${m?"opacity-100":"opacity-0 group-hover:opacity-100"} ${i?"left-10":""}`,onClick:ie=>{ie.stopPropagation();const De=ie.currentTarget.getBoundingClientRect();ne({x:De.left,y:De.bottom+4})},title:"Right-click for more options",children:a.jsx(rh,{className:"w-5 h-5 text-white"})}),a.jsx("button",{className:`absolute top-2 right-2 p-1 rounded transition-colors ${f("archives","update",t.created_by_id)?"bg-black/50 hover:bg-black/70":"bg-black/30 cursor-not-allowed"}`,onClick:ie=>{ie.stopPropagation(),f("archives","update",t.created_by_id)&&Te.mutate()},disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?t.is_favorite?"Remove from favorites":"Add to favorites":"You do not have permission to update archives",children:a.jsx(im,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"} ${f("archives","update",t.created_by_id)?"":"opacity-50"}`})}),(t.status==="failed"||t.status==="aborted")&&a.jsx("div",{className:"absolute top-2 left-12 px-2 py-1 rounded text-xs bg-status-error/80 text-white",children:t.status==="aborted"?"cancelled":"failed"}),t.duplicate_count>0&&a.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:[a.jsx(Ll,{className:"w-3 h-3"}),"duplicate"]}),t.source_3mf_path&&a.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:ie=>{ie.stopPropagation();const De=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",Le=`${window.location.origin}${ue.getSource3mfForSlicer(t.id,De)}`;sc(Le)},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:a.jsx(q1,{className:"w-4 h-4 text-orange-400"})}),t.f3d_path&&a.jsx("button",{className:`absolute bottom-2 ${t.source_3mf_path?"left-12":"left-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:ie=>{ie.stopPropagation(),window.location.href=ue.getF3dDownloadUrl(t.id)},title:"Download Fusion 360 design file",children:a.jsx(Pi,{className:"w-4 h-4 text-cyan-400"})}),t.timelapse_path&&a.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:ie=>{ie.stopPropagation(),k(!0)},title:"View timelapse",children:a.jsx(ih,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&a.jsxs("button",{className:`absolute bottom-2 ${t.timelapse_path?"right-12":"right-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:ie=>{ie.stopPropagation(),j(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[a.jsx(Ug,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&a.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})]}),V&&V.length>0&&a.jsx(Os,{to:`/files?folder=${V[0].id}`,className:"absolute bottom-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:ie=>ie.stopPropagation(),title:`Open folder: ${V[0].name}`,style:{left:t.source_3mf_path?t.f3d_path?"5.5rem":"3rem":t.f3d_path?"3rem":"0.5rem"},children:a.jsx(Il,{className:"w-4 h-4 text-yellow-400"})})]}),a.jsxs(St,{className:"p-4 flex-1 flex flex-col",children:[a.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),a.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:e}),a.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${kf(t.filename)?"bg-bambu-green/20 text-bambu-green":"bg-orange-500/20 text-orange-400"}`,title:kf(t.filename)?"Sliced file - ready to print":"Source file only - no AMS mapping available",children:kf(t.filename)?"GCODE":"SOURCE"}),t.project_name&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full truncate max-w-[120px]",style:{backgroundColor:`${s?.find(ie=>ie.id===t.project_id)?.color||"#6b7280"}20`,color:s?.find(ie=>ie.id===t.project_id)?.color||"#6b7280"},title:`Project: ${t.project_name}`,children:t.project_name})]}),a.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)&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${n0(t.print_time_seconds||0)}
  8268. Actual: ${n0(t.actual_time_seconds||0)}
  8269. Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${n0(t.actual_time_seconds)}`:`Estimated: ${n0(t.print_time_seconds||0)}`,children:[a.jsx(Qn,{className:"w-3 h-3"}),n0(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&a.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&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[a.jsx(pc,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[a.jsx(xs,{className:"w-3 h-3"}),t.total_layers&&a.jsxs("span",{children:[t.total_layers," layers"]}),t.total_layers&&t.layer_height&&a.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&a.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.object_count!=null&&t.object_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:`${t.object_count} object${t.object_count>1?"s":""}`,children:[a.jsx(Pi,{className:"w-3 h-3"}),t.object_count," object",t.object_count>1?"s":""]}),t.sliced_for_model&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:`Sliced for ${t.sliced_for_model}`,children:[a.jsx(Ir,{className:"w-3 h-3"}),t.sliced_for_model]}),t.filament_type&&a.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[a.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&a.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((ie,De)=>a.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:ie},title:ie},De))})]})]}),(t.tags||t.notes)&&a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t.notes&&a.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:a.jsx(jW,{className:"w-3 h-3"})}),t.tags?.split(",").map((ie,De)=>a.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:ie.trim()},De))]}),a.jsx("div",{className:"flex-1"}),a.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[a.jsx("span",{children:$g(t.created_at,l)}),a.jsxs("div",{className:"flex items-center gap-2",children:[t.created_by_username&&a.jsxs("span",{className:"flex items-center gap-1",title:`Uploaded by ${t.created_by_username}`,children:[a.jsx(am,{className:"w-3 h-3"}),t.created_by_username]}),a.jsx("span",{children:Y2(t.file_size)})]})]}),a.jsxs("div",{className:"flex gap-1 mt-3",children:[kf(t.filename)?a.jsxs(a.Fragment,{children:[a.jsxs(Ne,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>y(!0),disabled:!f("archives","reprint",t.created_by_id),title:f("archives","reprint",t.created_by_id)?void 0:"You do not have permission to reprint",children:[a.jsx(Ir,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"hidden sm:inline",children:"Reprint"})]}),a.jsxs(Ne,{variant:"secondary",size:"sm",className:"flex-1 min-w-0",onClick:()=>Y(!0),disabled:!d("queue:create"),title:d("queue:create")?"Schedule Print":"You do not have permission to add to queue",children:[a.jsx(ti,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"hidden sm:inline",children:"Schedule"})]}),a.jsx(Ne,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const ie=t.print_name||t.filename||"model",De=`${window.location.origin}${ue.getArchiveForSlicer(t.id,ie)}`;sc(De)},title:"Open in Bambu Studio",children:a.jsx(Yr,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}):a.jsxs(Ne,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>{const ie=t.print_name||t.filename||"model",De=`${window.location.origin}${ue.getArchiveForSlicer(t.id,ie)}`;sc(De)},title:"Open in Bambu Studio to slice",children:[a.jsx(Yr,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"hidden sm:inline",children:"Slice"})]}),a.jsx(Ne,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const ie=t.external_url||t.makerworld_url;ie&&window.open(ie,"_blank")},disabled:!t.external_url&&!t.makerworld_url,title:t.external_url?"External Link":t.makerworld_url?`MakerWorld: ${t.designer||"View project"}`:"No external link",children:a.jsx(ah,{className:`w-3 h-3 sm:w-4 sm:h-4 ${!t.external_url&&!t.makerworld_url?"opacity-20":""}`})}),a.jsx(Ne,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>x(!0),title:"3D Preview",children:a.jsx(Pi,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),a.jsx(Ne,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const ie=document.createElement("a");ie.href=ue.getArchiveDownload(t.id),ie.download=`${t.print_name||t.filename}.3mf`,ie.click()},title:"Download",children:a.jsx(pi,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),a.jsx(Ne,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>C(!0),disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?"Edit":"You do not have permission to edit archives",children:a.jsx(Ki,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),a.jsx(Ne,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>S(!0),disabled:!f("archives","delete",t.created_by_id),title:f("archives","delete",t.created_by_id)?"Delete":"You do not have permission to delete archives",children:a.jsx(an,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),N&&a.jsx(Eee,{archive:t,onClose:()=>C(!1)}),p&&a.jsx(gL,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>x(!1)}),b&&a.jsx(jh,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>y(!1)}),v&&a.jsx(Yn,{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:()=>{_e.mutate(),S(!1)},onCancel:()=>S(!1)}),Z&&a.jsx(Yn,{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:()=>{J.mutate(),oe(!1)},onCancel:()=>oe(!1)}),B&&a.jsx(Yn,{title:"Remove F3D",message:`Are you sure you want to remove the Fusion 360 design file from "${t.print_name||t.filename}"?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{z.mutate(),W(!1)},onCancel:()=>W(!1)}),se&&a.jsx(Cee,{x:se.x,y:se.y,items:Me,onClose:()=>ne(null)}),T&&t.timelapse_path&&a.jsx(hre,{src:ue.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>k(!1),onEdit:()=>{c.invalidateQueries({queryKey:["archives"]}),k(!1)}}),E&&A.length>0&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),a.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),a.jsx("button",{onClick:()=>{D(!1),R([])},className:"text-gray-400 hover:text-white p-1",children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:A.map(ie=>a.jsxs("button",{onClick:()=>Ee.mutate(ie.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:[a.jsx(ih,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-white font-medium truncate",children:ie.name}),a.jsxs("p",{className:"text-sm text-gray-400",children:[Y2(ie.size),ie.mtime&&` • ${$g(ie.mtime,l)}`]})]})]},ie.name))}),a.jsx("div",{className:"p-4 border-t border-gray-700",children:a.jsx(Ne,{variant:"secondary",onClick:()=>{D(!1),R([])},className:"w-full",children:"Cancel"})})]})}),F&&a.jsx(Tee,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>O(!1)}),H&&t.photos&&t.photos.length>0&&a.jsx(Aee,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>j(!1),onDelete:async ie=>{try{await ue.deleteArchivePhoto(t.id,ie),c.invalidateQueries({queryKey:["archives"]}),u("Photo deleted")}catch{u("Failed to delete photo","error")}}}),G&&a.jsx(dre,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>$(!1)}),q&&a.jsx(jh,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>Y(!1)}),a.jsx("input",{ref:xe,type:"file",accept:".3mf",className:"hidden",onChange:ie=>{const De=ie.target.files?.[0];De&&K.mutate(De),ie.target.value=""}}),a.jsx("input",{ref:Pe,type:"file",accept:".f3d",className:"hidden",onChange:ie=>{const De=ie.target.files?.[0];De&&Q.mutate(De),ie.target.value=""}})]})}function hqe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:s,isHighlighted:o}){const l=on(),{showToast:c}=Vn(),{hasPermission:u,canModify:d}=Si(),[f,m]=w.useState(!1),[p,x]=w.useState(!1),[b,y]=w.useState(!1),[v,S]=w.useState(!1),[N,C]=w.useState(!1),[T,k]=w.useState(!1),[E,D]=w.useState(!1),[A,R]=w.useState([]),[F,O]=w.useState(!1),[H,j]=w.useState(!1),[G,$]=w.useState(!1),[q,Y]=w.useState(!1),[Z,oe]=w.useState(!1),[B,W]=w.useState(null),se=w.useRef(null),ne=w.useRef(null),ce=mt({mutationFn:z=>ue.uploadSource3mf(t.id,z),onSuccess:z=>{l.invalidateQueries({queryKey:["archives"]}),c(`Source 3MF attached: ${z.filename}`)},onError:z=>{c(z.message||"Failed to upload source 3MF","error")}}),fe=mt({mutationFn:()=>ue.deleteSource3mf(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Source 3MF removed")},onError:z=>{c(z.message||"Failed to remove source 3MF","error")}}),ye=mt({mutationFn:z=>ue.uploadF3d(t.id,z),onSuccess:z=>{l.invalidateQueries({queryKey:["archives"]}),c(`F3D attached: ${z.filename}`)},onError:z=>{c(z.message||"Failed to upload F3D","error")}}),ge=mt({mutationFn:()=>ue.deleteF3d(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("F3D removed")},onError:z=>{c(z.message||"Failed to remove F3D","error")}}),xe=mt({mutationFn:()=>ue.scanArchiveTimelapse(t.id),onSuccess:z=>{z.status==="attached"?(l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${z.filename}`)):z.status==="exists"?c("Timelapse already attached"):z.status==="not_found"&&z.available_files&&z.available_files.length>0?(R(z.available_files),D(!0)):c(z.message||"No matching timelapse found","warning")},onError:z=>{c(z.message||"Failed to scan for timelapse","error")}}),Pe=mt({mutationFn:z=>ue.selectArchiveTimelapse(t.id,z),onSuccess:z=>{l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${z.filename}`),D(!1),R([])},onError:z=>{c(z.message||"Failed to attach timelapse","error")}}),Ue=mt({mutationFn:()=>ue.deleteArchive(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Archive deleted")},onError:()=>{c("Failed to delete archive","error")}}),be=mt({mutationFn:()=>ue.toggleFavorite(t.id),onSuccess:z=>{l.invalidateQueries({queryKey:["archives"]}),c(z.is_favorite?"Added to favorites":"Removed from favorites")}}),{data:it}=at({queryKey:["archive-folders",t.id],queryFn:()=>ue.getLibraryFoldersByArchive(t.id)}),U=mt({mutationFn:z=>ue.updateArchive(t.id,{project_id:z}),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),l.invalidateQueries({queryKey:["projects"]}),c("Project updated")},onError:()=>{c("Failed to update project","error")}}),K=z=>{z.preventDefault(),W({x:z.clientX,y:z.clientY})},Q=[...kf(t.filename)?[{label:"Print",icon:a.jsx(Ir,{className:"w-4 h-4"}),onClick:()=>y(!0),disabled:!d("archives","reprint",t.created_by_id),title:d("archives","reprint",t.created_by_id)?void 0:"You do not have permission to reprint this archive"},{label:"Schedule",icon:a.jsx(ti,{className:"w-4 h-4"}),onClick:()=>S(!0),disabled:!u("queue:create"),title:u("queue:create")?void 0:"You do not have permission to add to queue"},{label:"Open in Bambu Studio",icon:a.jsx(Yr,{className:"w-4 h-4"}),onClick:()=>{const z=t.print_name||t.filename||"model",re=`${window.location.origin}${ue.getArchiveForSlicer(t.id,z)}`;sc(re)}}]:[{label:"Slice",icon:a.jsx(Yr,{className:"w-4 h-4"}),onClick:()=>{const z=t.print_name||t.filename||"model",re=`${window.location.origin}${ue.getArchiveForSlicer(t.id,z)}`;sc(re)}}],{label:t.external_url?"External Link":"View on MakerWorld",icon:a.jsx(ah,{className:"w-4 h-4"}),onClick:()=>{const z=t.external_url||t.makerworld_url;z&&window.open(z,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:a.jsx(Pi,{className:"w-4 h-4"}),onClick:()=>C(!0)},{label:"View Timelapse",icon:a.jsx(ih,{className:"w-4 h-4"}),onClick:()=>k(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:a.jsx(X1,{className:"w-4 h-4"}),onClick:()=>xe.mutate(),disabled:!t.printer_id||!!t.timelapse_path||xe.isPending||!d("archives","update",t.created_by_id),title:d("archives","update",t.created_by_id)?void 0:"You do not have permission to update archives"},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:a.jsx(q1,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const z=document.createElement("a");z.href=ue.getSource3mfDownloadUrl(t.id),z.download=`${t.print_name||t.filename}_source.3mf`,z.click()}else se.current?.click()},disabled:!t.source_3mf_path&&!d("archives","update",t.created_by_id),title:!t.source_3mf_path&&!d("archives","update",t.created_by_id)?"You do not have permission to upload files":void 0},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:a.jsx(Oa,{className:"w-4 h-4"}),onClick:()=>se.current?.click(),disabled:!d("archives","update",t.created_by_id),title:d("archives","update",t.created_by_id)?void 0:"You do not have permission to update this archive"},{label:"Remove Source 3MF",icon:a.jsx(an,{className:"w-4 h-4"}),onClick:()=>Y(!0),danger:!0,disabled:!d("archives","update",t.created_by_id),title:d("archives","update",t.created_by_id)?void 0:"You do not have permission to update this archive"}]:[],{label:t.f3d_path?"Replace F3D":"Upload F3D",icon:a.jsx(Pi,{className:"w-4 h-4"}),onClick:()=>ne.current?.click(),disabled:!d("archives","update",t.created_by_id),title:d("archives","update",t.created_by_id)?void 0:"You do not have permission to update this archive"},...t.f3d_path?[{label:"Download F3D",icon:a.jsx(pi,{className:"w-4 h-4"}),onClick:()=>{const z=document.createElement("a");z.href=ue.getF3dDownloadUrl(t.id),z.download=`${t.print_name||t.filename}.f3d`,z.click()}},{label:"Remove F3D",icon:a.jsx(an,{className:"w-4 h-4"}),onClick:()=>oe(!0),danger:!0,disabled:!d("archives","update",t.created_by_id),title:d("archives","update",t.created_by_id)?void 0:"You do not have permission to update this archive"}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:a.jsx(pi,{className:"w-4 h-4"}),onClick:()=>{const z=document.createElement("a");z.href=ue.getArchiveDownload(t.id),z.download=`${t.print_name||t.filename}.3mf`,z.click()},disabled:!u("archives:read"),title:u("archives:read")?void 0:"You do not have permission to download archives"},{label:"Copy Download Link",icon:a.jsx(Ll,{className:"w-4 h-4"}),onClick:()=>{const z=`${window.location.origin}${ue.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(z).then(()=>{c("Link copied to clipboard")}).catch(()=>{c("Failed to copy link","error")})},disabled:!u("archives:read"),title:u("archives:read")?void 0:"You do not have permission to copy download links"},{label:"QR Code",icon:a.jsx(AW,{className:"w-4 h-4"}),onClick:()=>O(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:a.jsx(Ug,{className:"w-4 h-4"}),onClick:()=>j(!0),disabled:!t.photos?.length},{label:"Project Page",icon:a.jsx(fs,{className:"w-4 h-4"}),onClick:()=>$(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:a.jsx(im,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>be.mutate(),disabled:!d("archives","update",t.created_by_id),title:d("archives","update",t.created_by_id)?void 0:"You do not have permission to update this archive"},{label:"Edit",icon:a.jsx(Ki,{className:"w-4 h-4"}),onClick:()=>m(!0),disabled:!d("archives","update",t.created_by_id),title:d("archives","update",t.created_by_id)?void 0:"You do not have permission to update this archive"},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:a.jsx(Qa,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:a.jsx(Qa,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const z=[];if(t.project_id&&z.push({label:"Remove from Project",icon:a.jsx(Dt,{className:"w-4 h-4"}),onClick:()=>U.mutate(null)}),!s)z.push({label:"Loading...",icon:a.jsx(ct,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const re=s.filter(Ee=>Ee.status==="active");re.length===0?z.push({label:"No projects available",icon:a.jsx(Qa,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):re.forEach(Ee=>{z.push({label:Ee.name,icon:a.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:Ee.color||"#888"}}),onClick:()=>U.mutate(Ee.id),disabled:t.project_id===Ee.id})})}return z})()},{label:n?"Deselect":"Select",icon:n?a.jsx(Vs,{className:"w-4 h-4"}):a.jsx(il,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:a.jsx(an,{className:"w-4 h-4"}),onClick:()=>x(!0),danger:!0,disabled:!d("archives","delete",t.created_by_id),title:d("archives","delete",t.created_by_id)?void 0:"You do not have permission to delete this archive"}];return a.jsxs(a.Fragment,{children:[a.jsxs("div",{"data-archive-id":t.id,className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${n?"bg-bambu-green/10":""}`,style:o?{outline:"4px solid #facc15",outlineOffset:"-4px"}:void 0,onContextMenu:K,children:[a.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[i&&a.jsx("button",{onClick:()=>r(t.id),children:n?a.jsx(Vs,{className:"w-4 h-4 text-bambu-green"}):a.jsx(il,{className:"w-4 h-4 text-bambu-gray"})}),t.thumbnail_path?a.jsx("img",{src:ue.getArchiveThumbnail(t.id),alt:"",className:"w-10 h-10 object-cover rounded"}):a.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:a.jsx(Du,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),a.jsxs("div",{className:"col-span-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("p",{className:"text-white text-sm truncate",children:t.print_name||t.filename}),t.timelapse_path&&a.jsx("span",{title:"Has timelapse",children:a.jsx(ih,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})}),it&&it.length>0&&a.jsx(Os,{to:`/files?folder=${it[0].id}`,className:"flex-shrink-0",title:`Open folder: ${it[0].name}`,onClick:z=>z.stopPropagation(),children:a.jsx(Il,{className:"w-3.5 h-3.5 text-yellow-400"})})]}),(t.filament_type||t.sliced_for_model)&&a.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.sliced_for_model&&a.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",title:`Sliced for ${t.sliced_for_model}`,children:[a.jsx(Ir,{className:"w-2.5 h-2.5"}),t.sliced_for_model]}),t.sliced_for_model&&t.filament_type&&a.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.filament_type&&a.jsx("span",{className:"text-xs text-bambu-gray",children:t.filament_type}),t.filament_color&&a.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((z,re)=>a.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:z},title:z},re))})]})]}),a.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:e}),a.jsxs("div",{className:"col-span-2 text-sm text-bambu-gray",children:[a.jsx("div",{children:Bg(t.created_at)}),t.created_by_username&&a.jsxs("div",{className:"flex items-center gap-1 text-xs opacity-75",title:`Uploaded by ${t.created_by_username}`,children:[a.jsx(am,{className:"w-3 h-3"}),t.created_by_username]})]}),a.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:Y2(t.file_size)}),a.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[a.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>{const z=t.print_name||t.filename||"model",re=`${window.location.origin}${ue.getArchiveForSlicer(t.id,z)}`;sc(re)},title:"Open in Bambu Studio",children:a.jsx(Yr,{className:"w-4 h-4"})}),(t.external_url||t.makerworld_url)&&a.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>window.open(t.external_url||t.makerworld_url,"_blank"),title:t.external_url?"External Link":"MakerWorld",children:a.jsx(ah,{className:"w-4 h-4"})}),a.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>{const z=document.createElement("a");z.href=ue.getArchiveDownload(t.id),z.download=`${t.print_name||t.filename}.3mf`,z.click()},title:"Download",children:a.jsx(pi,{className:"w-4 h-4"})}),a.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>m(!0),disabled:!d("archives","update",t.created_by_id),title:d("archives","update",t.created_by_id)?"Edit":"You do not have permission to edit archives",children:a.jsx(Ki,{className:"w-4 h-4"})}),a.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>x(!0),disabled:!d("archives","delete",t.created_by_id),title:d("archives","delete",t.created_by_id)?"Delete":"You do not have permission to delete archives",children:a.jsx(an,{className:"w-4 h-4 text-red-400"})}),a.jsx(Ne,{variant:"ghost",size:"sm",onClick:z=>{const re=z.currentTarget.getBoundingClientRect();W({x:re.left,y:re.bottom+4})},title:"More options",children:a.jsx(rh,{className:"w-4 h-4"})})]})]}),f&&a.jsx(Eee,{archive:t,onClose:()=>m(!1)}),N&&a.jsx(gL,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>C(!1)}),b&&a.jsx(jh,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>y(!1)}),p&&a.jsx(Yn,{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:()=>{Ue.mutate(),x(!1)},onCancel:()=>x(!1)}),q&&a.jsx(Yn,{title:"Remove Source 3MF",message:`Are you sure you want to remove the source 3MF file from "${t.print_name||t.filename}"?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{fe.mutate(),Y(!1)},onCancel:()=>Y(!1)}),Z&&a.jsx(Yn,{title:"Remove F3D",message:`Are you sure you want to remove the Fusion 360 design file from "${t.print_name||t.filename}"?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{ge.mutate(),oe(!1)},onCancel:()=>oe(!1)}),B&&a.jsx(Cee,{x:B.x,y:B.y,items:Q,onClose:()=>W(null)}),T&&t.timelapse_path&&a.jsx(hre,{src:ue.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>k(!1),onEdit:()=>{l.invalidateQueries({queryKey:["archives"]}),k(!1)}}),E&&A.length>0&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),a.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),a.jsx("button",{onClick:()=>{D(!1),R([])},className:"text-gray-400 hover:text-white p-1",children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:A.map(z=>a.jsxs("button",{onClick:()=>Pe.mutate(z.name),disabled:Pe.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors mb-1",children:[a.jsx("div",{className:"font-medium text-white",children:z.name}),a.jsxs("div",{className:"text-sm text-gray-400 flex gap-3",children:[a.jsx("span",{children:Y2(z.size)}),z.mtime&&a.jsx("span",{children:Bg(z.mtime)})]})]},z.name))})]})}),F&&a.jsx(Tee,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>O(!1)}),H&&t.photos&&a.jsx(Aee,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>j(!1),onDelete:async z=>{try{await ue.deleteArchivePhoto(t.id,z),l.invalidateQueries({queryKey:["archives"]}),c("Photo deleted")}catch{c("Failed to delete photo","error")}}}),G&&a.jsx(dre,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>$(!1)}),v&&a.jsx(jh,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>S(!1)}),a.jsx("input",{ref:se,type:"file",accept:".3mf",className:"hidden",onChange:z=>{const re=z.target.files?.[0];re&&ce.mutate(re),z.target.value=""}}),a.jsx("input",{ref:ne,type:"file",accept:".f3d",className:"hidden",onChange:z=>{const re=z.target.files?.[0];re&&ye.mutate(re),z.target.value=""}})]})}const fqe=[{id:"all",label:"All Archives",icon:a.jsx(Il,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:a.jsx(Qn,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:a.jsx(ti,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:a.jsx(ti,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:a.jsx(im,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:a.jsx(Ii,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:a.jsx(Ll,{className:"w-4 h-4"})}];function mqe(){const t=on(),{showToast:e}=Vn(),{hasPermission:n,hasAnyPermission:r}=Si(),i=w.useRef(null),[s,o]=w.useState(""),[l,c]=w.useState(()=>{const pe=localStorage.getItem("archiveFilterPrinter");return pe?Number(pe):null}),[u,d]=w.useState(()=>localStorage.getItem("archiveFilterMaterial")),[f,m]=w.useState(()=>{const pe=localStorage.getItem("archiveFilterColors");return pe?new Set(JSON.parse(pe)):new Set}),[p,x]=w.useState(()=>localStorage.getItem("archiveColorFilterMode")||"or"),[b,y]=w.useState(()=>localStorage.getItem("archiveFilterFavorites")==="true"),[v,S]=w.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[N,C]=w.useState(()=>localStorage.getItem("archiveFilterTag")),[T,k]=w.useState(()=>localStorage.getItem("archiveFilterFileType")||"all"),[E,D]=w.useState(!1),[A,R]=w.useState([]),[F,O]=w.useState(!1),[H,j]=w.useState(new Set),[G,$]=w.useState(!1),[q,Y]=w.useState(!1),[Z,oe]=w.useState(!1),[B,W]=w.useState(!1),[se,ne]=w.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[ce,fe]=w.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[ye,ge]=w.useState(()=>localStorage.getItem("archiveCollection")||"all"),[xe,Pe]=w.useState(!1),[Ue,be]=w.useState(!1),[it,U]=w.useState(!1),[K,J]=w.useState(!1),[Q,z]=w.useState(null);w.useEffect(()=>{if(Q){const pe=setTimeout(()=>{const de=document.querySelector(`[data-archive-id="${Q}"]`);de&&de.scrollIntoView({behavior:"smooth",block:"center"})},100),Ce=setTimeout(()=>z(null),5e3);return()=>{clearTimeout(pe),clearTimeout(Ce)}}},[Q]);const{data:re,isLoading:Ee}=at({queryKey:["archives",l],queryFn:()=>ue.getArchives(l||void 0)}),{data:_e}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:Te}=at({queryKey:["projects"],queryFn:()=>ue.getProjects()}),{data:V}=at({queryKey:["settings"],queryFn:ue.getSettings}),L=V?.time_format||"system",X=mt({mutationFn:async pe=>(await Promise.all(pe.map(Ce=>ue.deleteArchive(Ce))),pe.length),onSuccess:pe=>{t.invalidateQueries({queryKey:["archives"]}),j(new Set),e(`${pe} archive${pe!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}});w.useEffect(()=>{l!==null?localStorage.setItem("archiveFilterPrinter",l.toString()):localStorage.removeItem("archiveFilterPrinter")},[l]),w.useEffect(()=>{u?localStorage.setItem("archiveFilterMaterial",u):localStorage.removeItem("archiveFilterMaterial")},[u]),w.useEffect(()=>{localStorage.setItem("archiveFilterColors",JSON.stringify([...f]))},[f]),w.useEffect(()=>{localStorage.setItem("archiveColorFilterMode",p)},[p]),w.useEffect(()=>{localStorage.setItem("archiveFilterFavorites",b.toString())},[b]),w.useEffect(()=>{localStorage.setItem("archiveHideFailed",v.toString())},[v]),w.useEffect(()=>{N?localStorage.setItem("archiveFilterTag",N):localStorage.removeItem("archiveFilterTag")},[N]),w.useEffect(()=>{localStorage.setItem("archiveFilterFileType",T)},[T]),w.useEffect(()=>{localStorage.setItem("archiveViewMode",se)},[se]),w.useEffect(()=>{localStorage.setItem("archiveSortBy",ce)},[ce]),w.useEffect(()=>{localStorage.setItem("archiveCollection",ye)},[ye]);const te=new Map(_e?.map(pe=>[pe.id,pe.name])||[]),Me=[...new Set(re?.flatMap(pe=>pe.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),ie=[...new Set(re?.flatMap(pe=>pe.filament_color?.split(",")||[]).filter(Boolean)||[])],De=[...new Set(re?.flatMap(pe=>pe.tags?.split(",").map(Ce=>Ce.trim())||[]).filter(Boolean)||[])].sort(),Le=re?.filter(pe=>{const Ce=new Date,de=Ri(pe.created_at)||new Date(0);let Ve=!0;switch(ye){case"recent":Ve=Ce.getTime()-de.getTime()<1440*60*1e3;break;case"this-week":Ve=Ce.getTime()-de.getTime()<10080*60*1e3;break;case"this-month":Ve=de.getMonth()===Ce.getMonth()&&de.getFullYear()===Ce.getFullYear();break;case"favorites":Ve=pe.is_favorite===!0;break;case"failed":Ve=pe.status==="failed"||pe.status==="aborted";break;case"duplicates":Ve=pe.duplicate_count>0;break}const yt=(pe.print_name||pe.filename).toLowerCase().includes(s.toLowerCase()),ut=!u||pe.filament_type?.split(", ").includes(u),It=pe.filament_color?.split(",")||[],Ft=f.size===0||(p==="or"?It.some(Gn=>f.has(Gn)):[...f].every(Gn=>It.includes(Gn))),vn=ye==="favorites"||!b||pe.is_favorite,Kt=ye==="failed"||!v||pe.status!=="failed"&&pe.status!=="aborted",cr=pe.tags?.split(",").map(Gn=>Gn.trim())||[],dr=!N||cr.includes(N),Jn=kf(pe.filename);return Ve&&yt&&ut&&Ft&&vn&&Kt&&dr&&(T==="all"||T==="gcode"&&Jn||T==="source"&&!Jn)}).sort((pe,Ce)=>{switch(ce){case"date-desc":return(Ri(Ce.created_at)?.getTime()||0)-(Ri(pe.created_at)?.getTime()||0);case"date-asc":return(Ri(pe.created_at)?.getTime()||0)-(Ri(Ce.created_at)?.getTime()||0);case"name-asc":return(pe.print_name||pe.filename).localeCompare(Ce.print_name||Ce.filename);case"name-desc":return(Ce.print_name||Ce.filename).localeCompare(pe.print_name||pe.filename);case"size-desc":return Ce.file_size-pe.file_size;case"size-asc":return pe.file_size-Ce.file_size;default:return 0}}),$e=G||H.size>0,Ze=pe=>{j(Ce=>{const de=new Set(Ce);return de.has(pe)?de.delete(pe):de.add(pe),de})},Ie=()=>{Le&&j(new Set(Le.map(pe=>pe.id)))},ae=()=>{j(new Set),$(!1)},He=pe=>{m(Ce=>{const de=new Set(Ce);return de.has(pe)?de.delete(pe):de.add(pe),de})},Se=()=>{m(new Set)},Be=()=>{o(""),c(null),d(null),y(!1),S(!1),C(null),k("all")},ft=s||l||u||b||v||N||T!=="all",we=w.useCallback(pe=>{pe.preventDefault(),pe.dataTransfer.types.includes("Files")&&O(!0)},[]),tt=w.useCallback(pe=>{pe.preventDefault(),pe.currentTarget===pe.target&&O(!1)},[]),ke=w.useCallback(pe=>{pe.preventDefault(),O(!1);const Ce=Array.from(pe.dataTransfer.files).filter(de=>de.name.endsWith(".3mf"));Ce.length>0?(R(Ce),D(!0)):pe.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),We=w.useCallback(pe=>{const Ce=pe.target;if(Ce.tagName==="INPUT"||Ce.tagName==="TEXTAREA"||Ce.isContentEditable){pe.key==="Escape"&&Ce.blur();return}switch(pe.key){case"/":pe.preventDefault(),i.current?.focus();break;case"u":case"U":!pe.metaKey&&!pe.ctrlKey&&(pe.preventDefault(),D(!0));break;case"Escape":$e&&ae();break}},[$e]);return w.useEffect(()=>(document.addEventListener("keydown",We),()=>document.removeEventListener("keydown",We)),[We]),a.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:we,onDragLeave:tt,onDrop:ke,children:[F&&a.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:a.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[a.jsx(Oa,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),a.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),a.jsx("p",{className:"text-bambu-gray",children:"Release to upload"})]})}),$e&&a.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:[a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:ae,children:[a.jsx(Dt,{className:"w-4 h-4"}),"Close"]}),a.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),a.jsxs("span",{className:"text-white font-medium",children:[H.size," selected"]}),a.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),a.jsx(Ne,{variant:"secondary",size:"sm",onClick:Ie,children:"Select All"}),a.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>oe(!0),disabled:!r("archives:update_own","archives:update_all"),title:r("archives:update_own","archives:update_all")?void 0:"You do not have permission to update archives",children:[a.jsx(yh,{className:"w-4 h-4"}),"Tags"]}),a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>W(!0),disabled:!r("archives:update_own","archives:update_all"),title:r("archives:update_own","archives:update_all")?void 0:"You do not have permission to update archives",children:[a.jsx(Qa,{className:"w-4 h-4"}),"Project"]}),a.jsxs(Ne,{variant:"secondary",size:"sm",disabled:!r("archives:update_own","archives:update_all"),title:r("archives:update_own","archives:update_all")?void 0:"You do not have permission to update archives",onClick:()=>{const pe=Array.from(H);Promise.all(pe.map(Ce=>ue.toggleFavorite(Ce))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${pe.length} archive${pe.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[a.jsx(im,{className:"w-4 h-4"}),"Favorite"]}),a.jsxs(Ne,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>Y(!0),disabled:!r("archives:delete_own","archives:delete_all"),title:r("archives:delete_own","archives:delete_all")?void 0:"You do not have permission to delete archives",children:[a.jsx(an,{className:"w-4 h-4"}),"Delete"]})]}),a.jsxs("div",{className:"flex items-center justify-between mb-8",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),a.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:ye,onChange:pe=>ge(pe.target.value),children:fqe.map(pe=>a.jsx("option",{value:pe.id,children:pe.label},pe.id))})]}),a.jsxs("p",{className:"text-bambu-gray",children:[Le?.length||0," of ",re?.length||0," prints"]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"relative",children:[a.jsxs(Ne,{variant:"secondary",onClick:()=>Pe(!xe),disabled:Ue,children:[Ue?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(W1,{className:"w-4 h-4"}),"Export"]}),xe&&a.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:[a.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()=>{Pe(!1),be(!0);try{const{blob:pe,filename:Ce}=await ue.exportArchives({format:"csv",printerId:l||void 0,status:ye==="failed"?"failed":void 0,search:s||void 0}),de=URL.createObjectURL(pe),Ve=document.createElement("a");Ve.href=de,Ve.download=Ce,Ve.click(),URL.revokeObjectURL(de),e("Export downloaded")}catch{e("Export failed","error")}finally{be(!1)}},children:[a.jsx(fs,{className:"w-4 h-4"}),"Export as CSV"]}),a.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()=>{Pe(!1),be(!0);try{const{blob:pe,filename:Ce}=await ue.exportArchives({format:"xlsx",printerId:l||void 0,status:ye==="failed"?"failed":void 0,search:s||void 0}),de=URL.createObjectURL(pe),Ve=document.createElement("a");Ve.href=de,Ve.download=Ce,Ve.click(),URL.revokeObjectURL(de),e("Export downloaded")}catch{e("Export failed","error")}finally{be(!1)}},children:[a.jsx(W1,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),H.size>=2&&H.size<=5&&a.jsxs(Ne,{variant:"secondary",onClick:()=>U(!0),children:[a.jsx(wg,{className:"w-4 h-4"}),"Compare (",H.size,")"]}),!$e&&a.jsxs(Ne,{variant:"secondary",onClick:()=>$(!0),children:[a.jsx(Vs,{className:"w-4 h-4"}),"Select"]}),a.jsxs(Ne,{onClick:()=>D(!0),disabled:!n("archives:create"),title:n("archives:create")?void 0:"You do not have permission to create archives",children:[a.jsx(Oa,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),a.jsx(wt,{className:"mb-6",children:a.jsxs(St,{className:"py-4",children:[a.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:gap-4 md:items-center md:flex-wrap",children:[a.jsxs("div",{className:"w-full md:flex-1 relative md:min-w-[200px]",children:[a.jsx(pa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{ref:i,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:s,onChange:pe=>o(pe.target.value)})]}),a.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:[a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(dN,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),a.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:l||"",onChange:pe=>c(pe.target.value?Number(pe.target.value):null),children:[a.jsx("option",{value:"",children:"All Printers"}),_e?.map(pe=>a.jsx("option",{value:pe.id,children:pe.name},pe.id))]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(pc,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),a.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:u||"",onChange:pe=>d(pe.target.value||null),children:[a.jsx("option",{value:"",children:"All Materials"}),Me.map(pe=>a.jsx("option",{value:pe,children:pe},pe))]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(q1,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),a.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:T,onChange:pe=>k(pe.target.value),children:[a.jsx("option",{value:"all",children:"All Files"}),a.jsx("option",{value:"gcode",children:"Sliced (GCODE)"}),a.jsx("option",{value:"source",children:"Source Only"})]})]}),a.jsxs("button",{onClick:()=>y(!b),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${b?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:b?"Show all":"Show favorites only",children:[a.jsx(im,{className:`w-4 h-4 ${b?"fill-yellow-400":""}`}),a.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),a.jsxs("button",{onClick:()=>S(!v),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${v?"bg-red-500/20 border-red-500 text-red-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:v?"Show failed prints":"Hide failed prints",children:[a.jsx(Ii,{className:"w-4 h-4 "}),a.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),De.length>0&&a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(yh,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),a.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:N||"",onChange:pe=>C(pe.target.value||null),children:[a.jsx("option",{value:"",children:"All Tags"}),De.map(pe=>a.jsx("option",{value:pe,children:pe},pe))]}),a.jsx("button",{onClick:()=>J(!0),className:"p-2 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-green transition-colors",title:"Manage Tags",children:a.jsx(bN,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(bW,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),a.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:ce,onChange:pe=>fe(pe.target.value),children:[a.jsx("option",{value:"date-desc",children:"Newest first"}),a.jsx("option",{value:"date-asc",children:"Oldest first"}),a.jsx("option",{value:"name-asc",children:"Name A-Z"}),a.jsx("option",{value:"name-desc",children:"Name Z-A"}),a.jsx("option",{value:"size-desc",children:"Largest first"}),a.jsx("option",{value:"size-asc",children:"Smallest first"})]})]}),a.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden flex-shrink-0",children:[a.jsx("button",{className:`p-2 ${se==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>ne("grid"),title:"Grid view",children:a.jsx(pN,{className:"w-4 h-4"})}),a.jsx("button",{className:`p-2 ${se==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>ne("list"),title:"List view",children:a.jsx(gN,{className:"w-4 h-4"})}),a.jsx("button",{className:`p-2 ${se==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>ne("calendar"),title:"Calendar view",children:a.jsx(Lce,{className:"w-4 h-4"})})]})]}),ft&&a.jsxs(Ne,{variant:"ghost",size:"sm",onClick:Be,className:"text-bambu-gray hover:text-white",children:[a.jsx(Dt,{className:"w-4 h-4"}),"Reset"]})]}),ie.length>0&&a.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),f.size>1&&a.jsx("button",{onClick:()=>x(pe=>pe==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${p==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:p==="or"?"Match ANY selected color":"Match ALL selected colors",children:p.toUpperCase()}),a.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:ie.map(pe=>a.jsx("button",{onClick:()=>He(pe),className:`w-6 h-6 rounded-full border-2 transition-all ${f.has(pe)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:pe},title:pe},pe))}),f.size>0&&a.jsxs("button",{onClick:Se,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[a.jsx(Dt,{className:"w-3 h-3"}),"Clear"]})]})]})}),a.jsx(cqe,{}),Ee?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):Le?.length===0?a.jsx(wt,{children:a.jsxs(St,{className:"text-center py-12",children:[a.jsx("p",{className:"text-bambu-gray",children:s?"No archives match your search":"No archives yet"}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):se==="calendar"?a.jsx(wt,{className:"p-6",children:a.jsx(z8e,{archives:Le||[],onArchiveClick:pe=>{o(""),ne("grid"),z(pe.id)},highlightedArchiveId:Q})}):se==="grid"?a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:Le?.map(pe=>a.jsx(dqe,{archive:pe,printerName:pe.printer_id?te.get(pe.printer_id)||"Unknown":pe.sliced_for_model?`Sliced for ${pe.sliced_for_model}`:"No Printer",isSelected:H.has(pe.id),onSelect:Ze,selectionMode:$e,projects:Te,isHighlighted:pe.id===Q,timeFormat:L},pe.id))}):se==="list"?a.jsx(wt,{children:a.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[a.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[a.jsx("div",{className:"col-span-1"}),a.jsx("div",{className:"col-span-4",children:"Name"}),a.jsx("div",{className:"col-span-2",children:"Printer"}),a.jsx("div",{className:"col-span-2",children:"Date"}),a.jsx("div",{className:"col-span-1",children:"Size"}),a.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),Le?.map(pe=>a.jsx(hqe,{archive:pe,printerName:pe.printer_id?te.get(pe.printer_id)||"Unknown":pe.sliced_for_model?`Sliced for ${pe.sliced_for_model}`:"No Printer",isSelected:H.has(pe.id),onSelect:Ze,selectionMode:$e,projects:Te,isHighlighted:pe.id===Q},pe.id))]})}):null,E&&a.jsx(j8e,{onClose:()=>{D(!1),R([])},initialFiles:A}),q&&a.jsx(Yn,{title:"Delete Archives",message:`Are you sure you want to delete ${H.size} archive${H.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${H.size}`,variant:"danger",onConfirm:()=>{X.mutate(Array.from(H)),Y(!1)},onCancel:()=>Y(!1)}),Z&&a.jsx(D8e,{selectedIds:Array.from(H),existingTags:De,onClose:()=>oe(!1)}),B&&a.jsx(O8e,{selectedIds:Array.from(H),onClose:()=>W(!1)}),it&&H.size>=2&&H.size<=5&&a.jsx(iqe,{archiveIds:Array.from(H),onClose:()=>{U(!1),j(new Set),$(!1)}}),K&&a.jsx(uqe,{onClose:()=>J(!1)})]})}function pqe(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return w.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const UM=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Lx(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function a5(t){return"nodeType"in t}function Ks(t){var e,n;return t?Lx(t)?t:a5(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function s5(t){const{Document:e}=Ks(t);return t instanceof e}function _v(t){return Lx(t)?!1:t instanceof Ks(t).HTMLElement}function fre(t){return t instanceof Ks(t).SVGElement}function Ix(t){return t?Lx(t)?t.document:a5(t)?s5(t)?t:_v(t)||fre(t)?t.ownerDocument:document:document:document}const Sc=UM?w.useLayoutEffect:w.useEffect;function o5(t){const e=w.useRef(t);return Sc(()=>{e.current=t}),w.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 gqe(){const t=w.useRef(null),e=w.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=w.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function jy(t,e){e===void 0&&(e=[t]);const n=w.useRef(t);return Sc(()=>{n.current!==t&&(n.current=t)},e),n}function wv(t,e){const n=w.useRef();return w.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function Q2(t){const e=o5(t),n=w.useRef(null),r=w.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function sD(t){const e=w.useRef();return w.useEffect(()=>{e.current=t},[t]),e.current}let Uj={};function Sv(t,e){return w.useMemo(()=>{if(e)return e;const n=Uj[t]==null?0:Uj[t]+1;return Uj[t]=n,t+"-"+n},[t,e])}function mre(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,o)=>{const l=Object.entries(o);for(const[c,u]of l){const d=s[c];d!=null&&(s[c]=d+t*u)}return s},{...e})}}const Lg=mre(1),Py=mre(-1);function xqe(t){return"clientX"in t&&"clientY"in t}function l5(t){if(!t)return!1;const{KeyboardEvent:e}=Ks(t.target);return e&&t instanceof e}function bqe(t){if(!t)return!1;const{TouchEvent:e}=Ks(t.target);return e&&t instanceof e}function oD(t){if(bqe(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 xqe(t)?{x:t.clientX,y:t.clientY}:null}const mx=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[mx.Translate.toString(t),mx.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),iq="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function yqe(t){return t.matches(iq)?t:t.querySelector(iq)}const vqe={display:"none"};function _qe(t){let{id:e,value:n}=t;return Kr.createElement("div",{id:e,style:vqe},n)}function wqe(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 Kr.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function Sqe(){const[t,e]=w.useState("");return{announce:w.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const pre=w.createContext(null);function Nqe(t){const e=w.useContext(pre);w.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function Mqe(){const[t]=w.useState(()=>new Set),e=w.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[w.useCallback(r=>{let{type:i,event:s}=r;t.forEach(o=>{var l;return(l=o[i])==null?void 0:l.call(o,s)})},[t]),e]}const Eqe={draggable:`
  8270. To pick up a draggable item, press the space bar.
  8271. While dragging, use the arrow keys to move the item.
  8272. Press space again to drop the item in its new position, or press escape to cancel.
  8273. `},Cqe={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 Tqe(t){let{announcements:e=Cqe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Eqe}=t;const{announce:s,announcement:o}=Sqe(),l=Sv("DndLiveRegion"),[c,u]=w.useState(!1);if(w.useEffect(()=>{u(!0)},[]),Nqe(w.useMemo(()=>({onDragStart(f){let{active:m}=f;s(e.onDragStart({active:m}))},onDragMove(f){let{active:m,over:p}=f;e.onDragMove&&s(e.onDragMove({active:m,over:p}))},onDragOver(f){let{active:m,over:p}=f;s(e.onDragOver({active:m,over:p}))},onDragEnd(f){let{active:m,over:p}=f;s(e.onDragEnd({active:m,over:p}))},onDragCancel(f){let{active:m,over:p}=f;s(e.onDragCancel({active:m,over:p}))}}),[s,e])),!c)return null;const d=Kr.createElement(Kr.Fragment,null,Kr.createElement(_qe,{id:r,value:i.draggable}),Kr.createElement(wqe,{id:l,announcement:o}));return n?pu.createPortal(d,n):d}var Gi;(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"})(Gi||(Gi={}));function Z2(){}function J2(t,e){return w.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function gre(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return w.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const Ul=Object.freeze({x:0,y:0});function xre(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function bre(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function Aqe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function aq(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 yre(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function sq(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 vre=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=sq(e,e.left,e.top),s=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=xre(sq(c),i);s.push({id:l,data:{droppableContainer:o,value:u}})}}return s.sort(bre)},kqe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=aq(e),s=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=aq(c),d=i.reduce((m,p,x)=>m+xre(u[x],p),0),f=Number((d/4).toFixed(4));s.push({id:l,data:{droppableContainer:o,value:f}})}}return s.sort(bre)};function jqe(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),o=i-r,l=s-n;if(r<i&&n<s){const c=e.width*e.height,u=t.width*t.height,d=o*l,f=d/(c+u-d);return Number(f.toFixed(4))}return 0}const Pqe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=[];for(const s of r){const{id:o}=s,l=n.get(o);if(l){const c=jqe(l,e);c>0&&i.push({id:o,data:{droppableContainer:s,value:c}})}}return i.sort(Aqe)};function Rqe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function _re(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Ul}function Dqe(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((o,l)=>({...o,top:o.top+t*l.y,bottom:o.bottom+t*l.y,left:o.left+t*l.x,right:o.right+t*l.x}),{...n})}}const Oqe=Dqe(1);function Lqe(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 Iqe(t,e,n){const r=Lqe(e);if(!r)return t;const{scaleX:i,scaleY:s,x:o,y:l}=r,c=t.left-o-(1-i)*parseFloat(n),u=t.top-l-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),d=i?t.width/i:t.width,f=s?t.height/s:t.height;return{width:d,height:f,top:u,right:c+d,bottom:u+f,left:c}}const Fqe={ignoreTransform:!1};function Fx(t,e){e===void 0&&(e=Fqe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=Ks(t).getComputedStyle(t);u&&(n=Iqe(n,u,d))}const{top:r,left:i,width:s,height:o,bottom:l,right:c}=n;return{top:r,left:i,width:s,height:o,bottom:l,right:c}}function oq(t){return Fx(t,{ignoreTransform:!0})}function Uqe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function zqe(t,e){return e===void 0&&(e=Ks(t).getComputedStyle(t)),e.position==="fixed"}function Bqe(t,e){e===void 0&&(e=Ks(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 zM(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(s5(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!_v(i)||fre(i)||n.includes(i))return n;const s=Ks(t).getComputedStyle(i);return i!==t&&Bqe(i,s)&&n.push(i),zqe(i,s)?n:r(i.parentNode)}return t?r(t):n}function wre(t){const[e]=zM(t,1);return e??null}function zj(t){return!UM||!t?null:Lx(t)?t:a5(t)?s5(t)||t===Ix(t).scrollingElement?window:_v(t)?t:null:null}function Sre(t){return Lx(t)?t.scrollX:t.scrollLeft}function Nre(t){return Lx(t)?t.scrollY:t.scrollTop}function lD(t){return{x:Sre(t),y:Nre(t)}}var fa;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(fa||(fa={}));function Mre(t){return!UM||!t?!1:t===document.scrollingElement}function Ere(t){const e={x:0,y:0},n=Mre(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,o=t.scrollTop>=r.y,l=t.scrollLeft>=r.x;return{isTop:i,isLeft:s,isBottom:o,isRight:l,maxScroll:r,minScroll:e}}const $qe={x:.2,y:.2};function Hqe(t,e,n,r,i){let{top:s,left:o,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=$qe);const{isTop:u,isBottom:d,isLeft:f,isRight:m}=Ere(t),p={x:0,y:0},x={x:0,y:0},b={height:e.height*i.y,width:e.width*i.x};return!u&&s<=e.top+b.height?(p.y=fa.Backward,x.y=r*Math.abs((e.top+b.height-s)/b.height)):!d&&c>=e.bottom-b.height&&(p.y=fa.Forward,x.y=r*Math.abs((e.bottom-b.height-c)/b.height)),!m&&l>=e.right-b.width?(p.x=fa.Forward,x.x=r*Math.abs((e.right-b.width-l)/b.width)):!f&&o<=e.left+b.width&&(p.x=fa.Backward,x.x=r*Math.abs((e.left+b.width-o)/b.width)),{direction:p,speed:x}}function Vqe(t){if(t===document.scrollingElement){const{innerWidth:s,innerHeight:o}=window;return{top:0,left:0,right:s,bottom:o,width:s,height:o}}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 Cre(t){return t.reduce((e,n)=>Lg(e,lD(n)),Ul)}function Gqe(t){return t.reduce((e,n)=>e+Sre(n),0)}function qqe(t){return t.reduce((e,n)=>e+Nre(n),0)}function Wqe(t,e){if(e===void 0&&(e=Fx),!t)return;const{top:n,left:r,bottom:i,right:s}=e(t);wre(t)&&(i<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const Kqe=[["x",["left","right"],Gqe],["y",["top","bottom"],qqe]];class c5{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=zM(n),i=Cre(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[s,o,l]of Kqe)for(const c of o)Object.defineProperty(this,c,{get:()=>{const u=l(r),d=i[s]-u;return this.rect[c]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class I0{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 Xqe(t){const{EventTarget:e}=Ks(t);return t instanceof e?t:Ix(t)}function Bj(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 Go;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Go||(Go={}));function lq(t){t.preventDefault()}function Yqe(t){t.stopPropagation()}var Xn;(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"})(Xn||(Xn={}));const Tre={start:[Xn.Space,Xn.Enter],cancel:[Xn.Esc],end:[Xn.Space,Xn.Enter,Xn.Tab]},Qqe=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case Xn.Right:return{...n,x:n.x+25};case Xn.Left:return{...n,x:n.x-25};case Xn.Down:return{...n,y:n.y+25};case Xn.Up:return{...n,y:n.y-25}}};class BM{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 I0(Ix(n)),this.windowListeners=new I0(Ks(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Go.Resize,this.handleCancel),this.windowListeners.add(Go.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Go.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&Wqe(r),n(Ul)}handleKeyDown(e){if(l5(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:s=Tre,coordinateGetter:o=Qqe,scrollBehavior:l="smooth"}=i,{code:c}=e;if(s.end.includes(c)){this.handleEnd(e);return}if(s.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:u}=r.current,d=u?{x:u.left,y:u.top}:Ul;this.referenceCoordinates||(this.referenceCoordinates=d);const f=o(e,{active:n,context:r.current,currentCoordinates:d});if(f){const m=Py(f,d),p={x:0,y:0},{scrollableAncestors:x}=r.current;for(const b of x){const y=e.code,{isTop:v,isRight:S,isLeft:N,isBottom:C,maxScroll:T,minScroll:k}=Ere(b),E=Vqe(b),D={x:Math.min(y===Xn.Right?E.right-E.width/2:E.right,Math.max(y===Xn.Right?E.left:E.left+E.width/2,f.x)),y:Math.min(y===Xn.Down?E.bottom-E.height/2:E.bottom,Math.max(y===Xn.Down?E.top:E.top+E.height/2,f.y))},A=y===Xn.Right&&!S||y===Xn.Left&&!N,R=y===Xn.Down&&!C||y===Xn.Up&&!v;if(A&&D.x!==f.x){const F=b.scrollLeft+m.x,O=y===Xn.Right&&F<=T.x||y===Xn.Left&&F>=k.x;if(O&&!m.y){b.scrollTo({left:F,behavior:l});return}O?p.x=b.scrollLeft-F:p.x=y===Xn.Right?b.scrollLeft-T.x:b.scrollLeft-k.x,p.x&&b.scrollBy({left:-p.x,behavior:l});break}else if(R&&D.y!==f.y){const F=b.scrollTop+m.y,O=y===Xn.Down&&F<=T.y||y===Xn.Up&&F>=k.y;if(O&&!m.x){b.scrollTo({top:F,behavior:l});return}O?p.y=b.scrollTop-F:p.y=y===Xn.Down?b.scrollTop-T.y:b.scrollTop-k.y,p.y&&b.scrollBy({top:-p.y,behavior:l});break}}this.handleMove(e,Lg(Py(f,this.referenceCoordinates),p))}}}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()}}BM.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=Tre,onActivation:i}=e,{active:s}=n;const{code:o}=t.nativeEvent;if(r.start.includes(o)){const l=s.activatorNode.current;return l&&t.target!==l?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function cq(t){return!!(t&&"distance"in t)}function uq(t){return!!(t&&"delay"in t)}class u5{constructor(e,n,r){var i;r===void 0&&(r=Xqe(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:o}=s;this.props=e,this.events=n,this.document=Ix(o),this.documentListeners=new I0(this.document),this.listeners=new I0(r),this.windowListeners=new I0(Ks(o)),this.initialCoordinates=(i=oD(s))!=null?i:Ul,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(Go.Resize,this.handleCancel),this.windowListeners.add(Go.DragStart,lq),this.windowListeners.add(Go.VisibilityChange,this.handleCancel),this.windowListeners.add(Go.ContextMenu,lq),this.documentListeners.add(Go.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(uq(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(cq(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(Go.Click,Yqe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Go.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:s}=this,{onMove:o,options:{activationConstraint:l}}=s;if(!i)return;const c=(n=oD(e))!=null?n:Ul,u=Py(i,c);if(!r&&l){if(cq(l)){if(l.tolerance!=null&&Bj(u,l.tolerance))return this.handleCancel();if(Bj(u,l.distance))return this.handleStart()}if(uq(l)&&Bj(u,l.tolerance))return this.handleCancel();this.handlePending(l,u);return}e.cancelable&&e.preventDefault(),o(c)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===Xn.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const Zqe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class $M extends u5{constructor(e){const{event:n}=e,r=Ix(n.target);super(e,Zqe,r)}}$M.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 Jqe={move:{name:"mousemove"},end:{name:"mouseup"}};var cD;(function(t){t[t.RightClick=2]="RightClick"})(cD||(cD={}));class eWe extends u5{constructor(e){super(e,Jqe,Ix(e.event.target))}}eWe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===cD.RightClick?!1:(r?.({event:n}),!0)}}];const $j={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class tWe extends u5{constructor(e){super(e,$j)}static setup(){return window.addEventListener($j.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener($j.move.name,e)};function e(){}}}tWe.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 F0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(F0||(F0={}));var eN;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(eN||(eN={}));function nWe(t){let{acceleration:e,activator:n=F0.Pointer,canScroll:r,draggingRect:i,enabled:s,interval:o=5,order:l=eN.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:m}=t;const p=iWe({delta:f,disabled:!s}),[x,b]=gqe(),y=w.useRef({x:0,y:0}),v=w.useRef({x:0,y:0}),S=w.useMemo(()=>{switch(n){case F0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case F0.DraggableRect:return i}},[n,i,c]),N=w.useRef(null),C=w.useCallback(()=>{const k=N.current;if(!k)return;const E=y.current.x*v.current.x,D=y.current.y*v.current.y;k.scrollBy(E,D)},[]),T=w.useMemo(()=>l===eN.TreeOrder?[...u].reverse():u,[l,u]);w.useEffect(()=>{if(!s||!u.length||!S){b();return}for(const k of T){if(r?.(k)===!1)continue;const E=u.indexOf(k),D=d[E];if(!D)continue;const{direction:A,speed:R}=Hqe(k,D,S,e,m);for(const F of["x","y"])p[F][A[F]]||(R[F]=0,A[F]=0);if(R.x>0||R.y>0){b(),N.current=k,x(C,o),y.current=R,v.current=A;return}}y.current={x:0,y:0},v.current={x:0,y:0},b()},[e,C,r,b,s,o,JSON.stringify(S),JSON.stringify(p),x,u,T,d,JSON.stringify(m)])}const rWe={x:{[fa.Backward]:!1,[fa.Forward]:!1},y:{[fa.Backward]:!1,[fa.Forward]:!1}};function iWe(t){let{delta:e,disabled:n}=t;const r=sD(e);return wv(i=>{if(n||!r||!i)return rWe;const s={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[fa.Backward]:i.x[fa.Backward]||s.x===-1,[fa.Forward]:i.x[fa.Forward]||s.x===1},y:{[fa.Backward]:i.y[fa.Backward]||s.y===-1,[fa.Forward]:i.y[fa.Forward]||s.y===1}}},[n,e,r])}function aWe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return wv(i=>{var s;return e==null?null:(s=r??i)!=null?s:null},[r,e])}function sWe(t,e){return w.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,s=i.activators.map(o=>({eventName:o.eventName,handler:e(o.handler,r)}));return[...n,...s]},[]),[t,e])}var Ry;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(Ry||(Ry={}));var uD;(function(t){t.Optimized="optimized"})(uD||(uD={}));const dq=new Map;function oWe(t,e){let{dragging:n,dependencies:r,config:i}=e;const[s,o]=w.useState(null),{frequency:l,measure:c,strategy:u}=i,d=w.useRef(t),f=y(),m=jy(f),p=w.useCallback(function(v){v===void 0&&(v=[]),!m.current&&o(S=>S===null?v:S.concat(v.filter(N=>!S.includes(N))))},[m]),x=w.useRef(null),b=wv(v=>{if(f&&!n)return dq;if(!v||v===dq||d.current!==t||s!=null){const S=new Map;for(let N of t){if(!N)continue;if(s&&s.length>0&&!s.includes(N.id)&&N.rect.current){S.set(N.id,N.rect.current);continue}const C=N.node.current,T=C?new c5(c(C),C):null;N.rect.current=T,T&&S.set(N.id,T)}return S}return v},[t,s,n,f,c]);return w.useEffect(()=>{d.current=t},[t]),w.useEffect(()=>{f||p()},[n,f]),w.useEffect(()=>{s&&s.length>0&&o(null)},[JSON.stringify(s)]),w.useEffect(()=>{f||typeof l!="number"||x.current!==null||(x.current=setTimeout(()=>{p(),x.current=null},l))},[l,f,p,...r]),{droppableRects:b,measureDroppableContainers:p,measuringScheduled:s!=null};function y(){switch(u){case Ry.Always:return!1;case Ry.BeforeDragging:return n;default:return!n}}}function Are(t,e){return wv(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function lWe(t,e){return Are(t,e)}function cWe(t){let{callback:e,disabled:n}=t;const r=o5(e),i=w.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(r)},[r,n]);return w.useEffect(()=>()=>i?.disconnect(),[i]),i}function HM(t){let{callback:e,disabled:n}=t;const r=o5(e),i=w.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(r)},[n]);return w.useEffect(()=>()=>i?.disconnect(),[i]),i}function uWe(t){return new c5(Fx(t),t)}function hq(t,e,n){e===void 0&&(e=uWe);const[r,i]=w.useState(null);function s(){i(c=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=c??n)!=null?u:null}const d=e(t);return JSON.stringify(c)===JSON.stringify(d)?c:d})}const o=cWe({callback(c){if(t)for(const u of c){const{type:d,target:f}=u;if(d==="childList"&&f instanceof HTMLElement&&f.contains(t)){s();break}}}}),l=HM({callback:s});return Sc(()=>{s(),t?(l?.observe(t),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[t]),r}function dWe(t){const e=Are(t);return _re(t,e)}const fq=[];function hWe(t){const e=w.useRef(t),n=wv(r=>t?r&&r!==fq&&t&&e.current&&t.parentNode===e.current.parentNode?r:zM(t):fq,[t]);return w.useEffect(()=>{e.current=t},[t]),n}function fWe(t){const[e,n]=w.useState(null),r=w.useRef(t),i=w.useCallback(s=>{const o=zj(s.target);o&&n(l=>l?(l.set(o,lD(o)),new Map(l)):null)},[]);return w.useEffect(()=>{const s=r.current;if(t!==s){o(s);const l=t.map(c=>{const u=zj(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,lD(u)]):null}).filter(c=>c!=null);n(l.length?new Map(l):null),r.current=t}return()=>{o(t),o(s)};function o(l){l.forEach(c=>{const u=zj(c);u?.removeEventListener("scroll",i)})}},[i,t]),w.useMemo(()=>t.length?e?Array.from(e.values()).reduce((s,o)=>Lg(s,o),Ul):Cre(t):Ul,[t,e])}function mq(t,e){e===void 0&&(e=[]);const n=w.useRef(null);return w.useEffect(()=>{n.current=null},e),w.useEffect(()=>{const r=t!==Ul;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?Py(t,n.current):Ul}function mWe(t){w.useEffect(()=>{if(!UM)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 pWe(t,e){return w.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:s}=r;return n[i]=o=>{s(o,e)},n},{}),[t,e])}function kre(t){return w.useMemo(()=>t?Uqe(t):null,[t])}const pq=[];function gWe(t,e){e===void 0&&(e=Fx);const[n]=t,r=kre(n?Ks(n):null),[i,s]=w.useState(pq);function o(){s(()=>t.length?t.map(c=>Mre(c)?r:new c5(e(c),c)):pq)}const l=HM({callback:o});return Sc(()=>{l?.disconnect(),o(),t.forEach(c=>l?.observe(c))},[t]),i}function xWe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return _v(e)?e:t}function bWe(t){let{measure:e}=t;const[n,r]=w.useState(null),i=w.useCallback(u=>{for(const{target:d}of u)if(_v(d)){r(f=>{const m=e(d);return f?{...f,width:m.width,height:m.height}:m});break}},[e]),s=HM({callback:i}),o=w.useCallback(u=>{const d=xWe(u);s?.disconnect(),d&&s?.observe(d),r(d?e(d):null)},[e,s]),[l,c]=Q2(o);return w.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const yWe=[{sensor:$M,options:{}},{sensor:BM,options:{}}],vWe={current:{}},U1={draggable:{measure:oq},droppable:{measure:oq,strategy:Ry.WhileDragging,frequency:uD.Optimized},dragOverlay:{measure:Fx}};class U0 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 _We={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new U0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Z2},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:U1,measureDroppableContainers:Z2,windowRect:null,measuringScheduled:!1},wWe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Z2,draggableNodes:new Map,over:null,measureDroppableContainers:Z2},VM=w.createContext(wWe),jre=w.createContext(_We);function SWe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new U0}}}function NWe(t,e){switch(e.type){case Gi.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case Gi.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 Gi.DragEnd:case Gi.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Gi.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new U0(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case Gi.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,s=t.droppable.containers.get(n);if(!s||r!==s.key)return t;const o=new U0(t.droppable.containers);return o.set(n,{...s,disabled:i}),{...t,droppable:{...t.droppable,containers:o}}}case Gi.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const s=new U0(t.droppable.containers);return s.delete(n),{...t,droppable:{...t.droppable,containers:s}}}default:return t}}function MWe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=w.useContext(VM),s=sD(r),o=sD(n?.id);return w.useEffect(()=>{if(!e&&!r&&s&&o!=null){if(!l5(s)||document.activeElement===s.target)return;const l=i.get(o);if(!l)return;const{activatorNode:c,node:u}=l;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const d of[c.current,u.current]){if(!d)continue;const f=yqe(d);if(f){f.focus();break}}})}},[r,e,i,o,s]),null}function EWe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,s)=>s({transform:i,...r}),n):n}function CWe(t){return w.useMemo(()=>({draggable:{...U1.draggable,...t?.draggable},droppable:{...U1.droppable,...t?.droppable},dragOverlay:{...U1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function TWe(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const s=w.useRef(!1),{x:o,y:l}=typeof i=="boolean"?{x:i,y:i}:i;Sc(()=>{if(!o&&!l||!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=_re(d,r);if(o||(f.x=0),l||(f.y=0),s.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const m=wre(u);m&&m.scrollBy({top:f.y,left:f.x})}},[e,o,l,r,n])}const Pre=w.createContext({...Ul,scaleX:1,scaleY:1});var Gd;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Gd||(Gd={}));const Rre=w.memo(function(e){var n,r,i,s;let{id:o,accessibility:l,autoScroll:c=!0,children:u,sensors:d=yWe,collisionDetection:f=Pqe,measuring:m,modifiers:p,...x}=e;const b=w.useReducer(NWe,void 0,SWe),[y,v]=b,[S,N]=Mqe(),[C,T]=w.useState(Gd.Uninitialized),k=C===Gd.Initialized,{draggable:{active:E,nodes:D,translate:A},droppable:{containers:R}}=y,F=E!=null?D.get(E):null,O=w.useRef({initial:null,translated:null}),H=w.useMemo(()=>{var We;return E!=null?{id:E,data:(We=F?.data)!=null?We:vWe,rect:O}:null},[E,F]),j=w.useRef(null),[G,$]=w.useState(null),[q,Y]=w.useState(null),Z=jy(x,Object.values(x)),oe=Sv("DndDescribedBy",o),B=w.useMemo(()=>R.getEnabled(),[R]),W=CWe(m),{droppableRects:se,measureDroppableContainers:ne,measuringScheduled:ce}=oWe(B,{dragging:k,dependencies:[A.x,A.y],config:W.droppable}),fe=aWe(D,E),ye=w.useMemo(()=>q?oD(q):null,[q]),ge=ke(),xe=lWe(fe,W.draggable.measure);TWe({activeNode:E!=null?D.get(E):null,config:ge.layoutShiftCompensation,initialRect:xe,measure:W.draggable.measure});const Pe=hq(fe,W.draggable.measure,xe),Ue=hq(fe?fe.parentElement:null),be=w.useRef({activatorEvent:null,active:null,activeNode:fe,collisionRect:null,collisions:null,droppableRects:se,draggableNodes:D,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),it=R.getNodeFor((n=be.current.over)==null?void 0:n.id),U=bWe({measure:W.dragOverlay.measure}),K=(r=U.nodeRef.current)!=null?r:fe,J=k?(i=U.rect)!=null?i:Pe:null,Q=!!(U.nodeRef.current&&U.rect),z=dWe(Q?null:Pe),re=kre(K?Ks(K):null),Ee=hWe(k?it??fe:null),_e=gWe(Ee),Te=EWe(p,{transform:{x:A.x-z.x,y:A.y-z.y,scaleX:1,scaleY:1},activatorEvent:q,active:H,activeNodeRect:Pe,containerNodeRect:Ue,draggingNodeRect:J,over:be.current.over,overlayNodeRect:U.rect,scrollableAncestors:Ee,scrollableAncestorRects:_e,windowRect:re}),V=ye?Lg(ye,A):null,L=fWe(Ee),X=mq(L),te=mq(L,[Pe]),Me=Lg(Te,X),ie=J?Oqe(J,Te):null,De=H&&ie?f({active:H,collisionRect:ie,droppableRects:se,droppableContainers:B,pointerCoordinates:V}):null,Le=yre(De,"id"),[$e,Ze]=w.useState(null),Ie=Q?Te:Lg(Te,te),ae=Rqe(Ie,(s=$e?.rect)!=null?s:null,Pe),He=w.useRef(null),Se=w.useCallback((We,pe)=>{let{sensor:Ce,options:de}=pe;if(j.current==null)return;const Ve=D.get(j.current);if(!Ve)return;const yt=We.nativeEvent,ut=new Ce({active:j.current,activeNode:Ve,event:yt,options:de,context:be,onAbort(Ft){if(!D.get(Ft))return;const{onDragAbort:Kt}=Z.current,cr={id:Ft};Kt?.(cr),S({type:"onDragAbort",event:cr})},onPending(Ft,vn,Kt,cr){if(!D.get(Ft))return;const{onDragPending:Jn}=Z.current,ln={id:Ft,constraint:vn,initialCoordinates:Kt,offset:cr};Jn?.(ln),S({type:"onDragPending",event:ln})},onStart(Ft){const vn=j.current;if(vn==null)return;const Kt=D.get(vn);if(!Kt)return;const{onDragStart:cr}=Z.current,dr={activatorEvent:yt,active:{id:vn,data:Kt.data,rect:O}};pu.unstable_batchedUpdates(()=>{cr?.(dr),T(Gd.Initializing),v({type:Gi.DragStart,initialCoordinates:Ft,active:vn}),S({type:"onDragStart",event:dr}),$(He.current),Y(yt)})},onMove(Ft){v({type:Gi.DragMove,coordinates:Ft})},onEnd:It(Gi.DragEnd),onCancel:It(Gi.DragCancel)});He.current=ut;function It(Ft){return async function(){const{active:Kt,collisions:cr,over:dr,scrollAdjustedTranslate:Jn}=be.current;let ln=null;if(Kt&&Jn){const{cancelDrop:Gn}=Z.current;ln={activatorEvent:yt,active:Kt,collisions:cr,delta:Jn,over:dr},Ft===Gi.DragEnd&&typeof Gn=="function"&&await Promise.resolve(Gn(ln))&&(Ft=Gi.DragCancel)}j.current=null,pu.unstable_batchedUpdates(()=>{v({type:Ft}),T(Gd.Uninitialized),Ze(null),$(null),Y(null),He.current=null;const Gn=Ft===Gi.DragEnd?"onDragEnd":"onDragCancel";if(ln){const nr=Z.current[Gn];nr?.(ln),S({type:Gn,event:ln})}})}}},[D]),Be=w.useCallback((We,pe)=>(Ce,de)=>{const Ve=Ce.nativeEvent,yt=D.get(de);if(j.current!==null||!yt||Ve.dndKit||Ve.defaultPrevented)return;const ut={active:yt};We(Ce,pe.options,ut)===!0&&(Ve.dndKit={capturedBy:pe.sensor},j.current=de,Se(Ce,pe))},[D,Se]),ft=sWe(d,Be);mWe(d),Sc(()=>{Pe&&C===Gd.Initializing&&T(Gd.Initialized)},[Pe,C]),w.useEffect(()=>{const{onDragMove:We}=Z.current,{active:pe,activatorEvent:Ce,collisions:de,over:Ve}=be.current;if(!pe||!Ce)return;const yt={active:pe,activatorEvent:Ce,collisions:de,delta:{x:Me.x,y:Me.y},over:Ve};pu.unstable_batchedUpdates(()=>{We?.(yt),S({type:"onDragMove",event:yt})})},[Me.x,Me.y]),w.useEffect(()=>{const{active:We,activatorEvent:pe,collisions:Ce,droppableContainers:de,scrollAdjustedTranslate:Ve}=be.current;if(!We||j.current==null||!pe||!Ve)return;const{onDragOver:yt}=Z.current,ut=de.get(Le),It=ut&&ut.rect.current?{id:ut.id,rect:ut.rect.current,data:ut.data,disabled:ut.disabled}:null,Ft={active:We,activatorEvent:pe,collisions:Ce,delta:{x:Ve.x,y:Ve.y},over:It};pu.unstable_batchedUpdates(()=>{Ze(It),yt?.(Ft),S({type:"onDragOver",event:Ft})})},[Le]),Sc(()=>{be.current={activatorEvent:q,active:H,activeNode:fe,collisionRect:ie,collisions:De,droppableRects:se,draggableNodes:D,draggingNode:K,draggingNodeRect:J,droppableContainers:R,over:$e,scrollableAncestors:Ee,scrollAdjustedTranslate:Me},O.current={initial:J,translated:ie}},[H,fe,De,ie,D,K,J,se,R,$e,Ee,Me]),nWe({...ge,delta:A,draggingRect:ie,pointerCoordinates:V,scrollableAncestors:Ee,scrollableAncestorRects:_e});const we=w.useMemo(()=>({active:H,activeNode:fe,activeNodeRect:Pe,activatorEvent:q,collisions:De,containerNodeRect:Ue,dragOverlay:U,draggableNodes:D,droppableContainers:R,droppableRects:se,over:$e,measureDroppableContainers:ne,scrollableAncestors:Ee,scrollableAncestorRects:_e,measuringConfiguration:W,measuringScheduled:ce,windowRect:re}),[H,fe,Pe,q,De,Ue,U,D,R,se,$e,ne,Ee,_e,W,ce,re]),tt=w.useMemo(()=>({activatorEvent:q,activators:ft,active:H,activeNodeRect:Pe,ariaDescribedById:{draggable:oe},dispatch:v,draggableNodes:D,over:$e,measureDroppableContainers:ne}),[q,ft,H,Pe,v,oe,D,$e,ne]);return Kr.createElement(pre.Provider,{value:N},Kr.createElement(VM.Provider,{value:tt},Kr.createElement(jre.Provider,{value:we},Kr.createElement(Pre.Provider,{value:ae},u)),Kr.createElement(MWe,{disabled:l?.restoreFocus===!1})),Kr.createElement(Tqe,{...l,hiddenTextDescribedById:oe}));function ke(){const We=G?.autoScrollEnabled===!1,pe=typeof c=="object"?c.enabled===!1:c===!1,Ce=k&&!We&&!pe;return typeof c=="object"?{...c,enabled:Ce}:{enabled:Ce}}}),AWe=w.createContext(null),gq="button",kWe="Draggable";function jWe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const s=Sv(kWe),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:m}=w.useContext(VM),{role:p=gq,roleDescription:x="draggable",tabIndex:b=0}=i??{},y=c?.id===e,v=w.useContext(y?Pre:AWe),[S,N]=Q2(),[C,T]=Q2(),k=pWe(o,e),E=jy(n);Sc(()=>(f.set(e,{id:e,key:s,node:S,activatorNode:C,data:E}),()=>{const A=f.get(e);A&&A.key===s&&f.delete(e)}),[f,e]);const D=w.useMemo(()=>({role:p,tabIndex:b,"aria-disabled":r,"aria-pressed":y&&p===gq?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,p,b,y,x,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:D,isDragging:y,listeners:r?void 0:k,node:S,over:m,setNodeRef:N,setActivatorNodeRef:T,transform:v}}function PWe(){return w.useContext(jre)}const RWe="Droppable",DWe={timeout:25};function OWe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const s=Sv(RWe),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=w.useContext(VM),d=w.useRef({disabled:n}),f=w.useRef(!1),m=w.useRef(null),p=w.useRef(null),{disabled:x,updateMeasurementsFor:b,timeout:y}={...DWe,...i},v=jy(b??r),S=w.useCallback(()=>{if(!f.current){f.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{u(Array.isArray(v.current)?v.current:[v.current]),p.current=null},y)},[y]),N=HM({callback:S,disabled:x||!o}),C=w.useCallback((D,A)=>{N&&(A&&(N.unobserve(A),f.current=!1),D&&N.observe(D))},[N]),[T,k]=Q2(C),E=jy(e);return w.useEffect(()=>{!N||!T.current||(N.disconnect(),f.current=!1,N.observe(T.current))},[T,N]),w.useEffect(()=>(l({type:Gi.RegisterDroppable,element:{id:r,key:s,disabled:n,node:T,rect:m,data:E}}),()=>l({type:Gi.UnregisterDroppable,key:s,id:r})),[r]),w.useEffect(()=>{n!==d.current.disabled&&(l({type:Gi.SetDroppableDisabled,id:r,key:s,disabled:n}),d.current.disabled=n)},[r,s,n,l]),{active:o,rect:m,isOver:c?.id===r,node:T,over:c,setNodeRef:k}}function GM(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function LWe(t,e){return t.reduce((n,r,i)=>{const s=e.get(r);return s&&(n[i]=s),n},Array(t.length))}function u1(t){return t!==null&&t>=0}function IWe(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 FWe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const d5=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const s=GM(e,r,n),o=e[i],l=s[i];return!l||!o?null:{x:l.left-o.left,y:l.top-o.top,scaleX:l.width/o.width,scaleY:l.height/o.height}},d1={scaleX:1,scaleY:1},UWe=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:i,rects:s,overIndex:o}=t;const l=(e=s[n])!=null?e:r;if(!l)return null;if(i===n){const u=s[o];return u?{x:0,y:n<o?u.top+u.height-(l.top+l.height):u.top-l.top,...d1}:null}const c=zWe(s,i,n);return i>n&&i<=o?{x:0,y:-l.height-c,...d1}:i<n&&i>=o?{x:0,y:l.height+c,...d1}:{x:0,y:0,...d1}};function zWe(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 Dre="Sortable",Ore=Kr.createContext({activeIndex:-1,containerId:Dre,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:d5,disabled:{draggable:!1,droppable:!1}});function Lre(t){let{children:e,id:n,items:r,strategy:i=d5,disabled:s=!1}=t;const{active:o,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:d}=PWe(),f=Sv(Dre,n),m=l.rect!==null,p=w.useMemo(()=>r.map(k=>typeof k=="object"&&"id"in k?k.id:k),[r]),x=o!=null,b=o?p.indexOf(o.id):-1,y=u?p.indexOf(u.id):-1,v=w.useRef(p),S=!IWe(p,v.current),N=y!==-1&&b===-1||S,C=FWe(s);Sc(()=>{S&&x&&d(p)},[S,p,x,d]),w.useEffect(()=>{v.current=p},[p]);const T=w.useMemo(()=>({activeIndex:b,containerId:f,disabled:C,disableTransforms:N,items:p,overIndex:y,useDragOverlay:m,sortedRects:LWe(p,c),strategy:i}),[b,f,C.draggable,C.droppable,N,p,y,c,m,i]);return Kr.createElement(Ore.Provider,{value:T},e)}const BWe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return GM(n,r,i).indexOf(e)},$We=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:s,newIndex:o,previousItems:l,previousContainerId:c,transition:u}=t;return!u||!r||l!==s&&i===o?!1:n?!0:o!==i&&e===c},HWe={duration:200,easing:"ease"},Ire="transform",VWe=mx.Transition.toString({property:Ire,duration:0,easing:"linear"}),GWe={roleDescription:"sortable"};function qWe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[s,o]=w.useState(null),l=w.useRef(n);return Sc(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const u=Fx(r.current,{ignoreTransform:!0}),d={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(d.x||d.y)&&o(d)}}n!==l.current&&(l.current=n)},[e,n,r,i]),w.useEffect(()=>{s&&o(null)},[s]),s}function Fre(t){let{animateLayoutChanges:e=$We,attributes:n,disabled:r,data:i,getNewIndex:s=BWe,id:o,strategy:l,resizeObserverConfig:c,transition:u=HWe}=t;const{items:d,containerId:f,activeIndex:m,disabled:p,disableTransforms:x,sortedRects:b,overIndex:y,useDragOverlay:v,strategy:S}=w.useContext(Ore),N=WWe(r,p),C=d.indexOf(o),T=w.useMemo(()=>({sortable:{containerId:f,index:C,items:d},...i}),[f,i,C,d]),k=w.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:E,node:D,isOver:A,setNodeRef:R}=OWe({id:o,data:T,disabled:N.droppable,resizeObserverConfig:{updateMeasurementsFor:k,...c}}),{active:F,activatorEvent:O,activeNodeRect:H,attributes:j,setNodeRef:G,listeners:$,isDragging:q,over:Y,setActivatorNodeRef:Z,transform:oe}=jWe({id:o,data:T,attributes:{...GWe,...n},disabled:N.draggable}),B=pqe(R,G),W=!!F,se=W&&!x&&u1(m)&&u1(y),ne=!v&&q,ce=ne&&se?oe:null,ye=se?ce??(l??S)({rects:b,activeNodeRect:H,activeIndex:m,overIndex:y,index:C}):null,ge=u1(m)&&u1(y)?s({id:o,items:d,activeIndex:m,overIndex:y}):C,xe=F?.id,Pe=w.useRef({activeId:xe,items:d,newIndex:ge,containerId:f}),Ue=d!==Pe.current.items,be=e({active:F,containerId:f,isDragging:q,isSorting:W,id:o,index:C,items:d,newIndex:Pe.current.newIndex,previousItems:Pe.current.items,previousContainerId:Pe.current.containerId,transition:u,wasDragging:Pe.current.activeId!=null}),it=qWe({disabled:!be,index:C,node:D,rect:E});return w.useEffect(()=>{W&&Pe.current.newIndex!==ge&&(Pe.current.newIndex=ge),f!==Pe.current.containerId&&(Pe.current.containerId=f),d!==Pe.current.items&&(Pe.current.items=d)},[W,ge,f,d]),w.useEffect(()=>{if(xe===Pe.current.activeId)return;if(xe!=null&&Pe.current.activeId==null){Pe.current.activeId=xe;return}const K=setTimeout(()=>{Pe.current.activeId=xe},50);return()=>clearTimeout(K)},[xe]),{active:F,activeIndex:m,attributes:j,data:T,rect:E,index:C,newIndex:ge,items:d,isOver:A,isSorting:W,isDragging:q,listeners:$,node:D,overIndex:y,over:Y,setNodeRef:B,setActivatorNodeRef:Z,setDroppableNodeRef:R,setDraggableNodeRef:G,transform:it??ye,transition:U()};function U(){if(it||Ue&&Pe.current.newIndex===C)return VWe;if(!(ne&&!l5(O)||!u)&&(W||be))return mx.Transition.toString({...u,property:Ire})}}function WWe(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 tN(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 KWe=[Xn.Down,Xn.Right,Xn.Up,Xn.Left],Ure=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:s,over:o,scrollableAncestors:l}}=e;if(KWe.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];s.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const m=i.get(f.id);if(m)switch(t.code){case Xn.Down:r.top<m.top&&c.push(f);break;case Xn.Up:r.top>m.top&&c.push(f);break;case Xn.Left:r.left>m.left&&c.push(f);break;case Xn.Right:r.left<m.left&&c.push(f);break}});const u=kqe({collisionRect:r,droppableRects:i,droppableContainers:c});let d=yre(u,"id");if(d===o?.id&&u.length>1&&(d=u[1].id),d!=null){const f=s.get(n.id),m=s.get(d),p=m?i.get(m.id):null,x=m?.node.current;if(x&&p&&f&&m){const y=zM(x).some((k,E)=>l[E]!==k),v=zre(f,m),S=XWe(f,m),N=y||!v?{x:0,y:0}:{x:S?r.width-p.width:0,y:S?r.height-p.height:0},C={x:p.left,y:p.top};return N.x&&N.y?C:Py(C,N)}}}};function zre(t,e){return!tN(t)||!tN(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function XWe(t,e){return!tN(t)||!tN(e)||!zre(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function Bre(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 YWe(t,e="system"){if(!t)return"ASAP";const n=Ri(t);if(!n)return"ASAP";const r=new Date,i=n.getTime()-r.getTime();return i<-6e4?"Overdue":i<0?"Now":i<6e4?"In less than a minute":i<36e5?`In ${Math.round(i/6e4)} min`:i<864e5?`In ${Math.round(i/36e5)} hours`:$g(t,e)}function QWe({status:t,waitingReason:e}){if(t==="pending"&&e)return a.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border text-purple-400 bg-purple-400/10 border-purple-400/20",children:[a.jsx(Qn,{className:"w-3.5 h-3.5"}),"Waiting"]});const n={pending:{icon:Qn,color:"text-status-warning bg-status-warning/10 border-status-warning/20",label:"Pending"},printing:{icon:Us,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"Printing"},completed:{icon:Tr,color:"text-status-ok bg-status-ok/10 border-status-ok/20",label:"Completed"},failed:{icon:qi,color:"text-status-error bg-status-error/10 border-status-error/20",label:"Failed"},skipped:{icon:DD,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:Dt,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:"Cancelled"}},{icon:r,color:i,label:s}=n[t];return a.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${i}`,children:[a.jsx(r,{className:"w-3.5 h-3.5"}),s]})}function ZWe({selectedCount:t,printers:e,onSave:n,onClose:r,isSaving:i}){const[s,o]=w.useState("unchanged"),[l,c]=w.useState("unchanged"),[u,d]=w.useState("unchanged"),[f,m]=w.useState("unchanged"),[p,x]=w.useState("unchanged"),[b,y]=w.useState("unchanged"),[v,S]=w.useState("unchanged"),[N,C]=w.useState("unchanged"),[T,k]=w.useState("unchanged"),[E,D]=w.useState("unchanged"),A=()=>{const F={};s!=="unchanged"&&(F.printer_id=s),l!=="unchanged"&&(F.manual_start=l),u!=="unchanged"&&(F.auto_off_after=u),f!=="unchanged"&&(F.require_previous_success=f),p!=="unchanged"&&(F.bed_levelling=p),b!=="unchanged"&&(F.flow_cali=b),v!=="unchanged"&&(F.vibration_cali=v),N!=="unchanged"&&(F.layer_inspect=N),T!=="unchanged"&&(F.timelapse=T),E!=="unchanged"&&(F.use_ams=E),n(F)},R=s!=="unchanged"||l!=="unchanged"||u!=="unchanged"||f!=="unchanged"||p!=="unchanged"||b!=="unchanged"||v!=="unchanged"||N!=="unchanged"||T!=="unchanged"||E!=="unchanged";return a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit ",t," Item",t!==1?"s":""]}),a.jsx("button",{onClick:r,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Dt,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Only changed settings will be applied to selected items."}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Printer"}),a.jsxs("select",{value:s===null?"null":s==="unchanged"?"unchanged":String(s),onChange:F=>{const O=F.target.value;o(O==="unchanged"?"unchanged":O==="null"?null:Number(O))},className:"w-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:[a.jsx("option",{value:"unchanged",children:"— No change —"}),a.jsx("option",{value:"null",children:"Unassigned"}),e.map(F=>a.jsx("option",{value:F.id,children:F.name},F.id))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Queue Options"}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(su,{label:"Staged (manual start)",value:l,onChange:c}),a.jsx(su,{label:"Auto power off after print",value:u,onChange:d}),a.jsx(su,{label:"Require previous success",value:f,onChange:m})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Print Options"}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(su,{label:"Bed levelling",value:p,onChange:x}),a.jsx(su,{label:"Flow calibration",value:b,onChange:y}),a.jsx(su,{label:"Vibration calibration",value:v,onChange:S}),a.jsx(su,{label:"First layer inspection",value:N,onChange:C}),a.jsx(su,{label:"Timelapse",value:T,onChange:k}),a.jsx(su,{label:"Use AMS",value:E,onChange:D})]})]})]}),a.jsxs("div",{className:"flex justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Ne,{variant:"secondary",onClick:r,children:"Cancel"}),a.jsx(Ne,{onClick:A,disabled:!R||i,children:i?"Saving...":"Apply Changes"})]})]})})}function su({label:t,value:e,onChange:n}){return a.jsxs("div",{className:"flex items-center justify-between py-1",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:t}),a.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded-lg p-0.5",children:[a.jsx("button",{onClick:()=>n("unchanged"),className:`px-2 py-1 text-xs rounded ${e==="unchanged"?"bg-bambu-dark-tertiary text-white":"text-bambu-gray hover:text-white"}`,children:"—"}),a.jsx("button",{onClick:()=>n(!1),className:`px-2 py-1 text-xs rounded ${e===!1?"bg-red-500/20 text-red-400":"text-bambu-gray hover:text-white"}`,children:"Off"}),a.jsx("button",{onClick:()=>n(!0),className:`px-2 py-1 text-xs rounded ${e===!0?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white"}`,children:"On"})]})]})}function Hj({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:s,onRequeue:o,onStart:l,timeFormat:c="system",isSelected:u=!1,onToggleSelect:d,hasPermission:f,canModify:m}){const p=f("queue:reorder"),{attributes:x,listeners:b,setNodeRef:y,transform:v,transition:S,isDragging:N}=Fre({id:t.id,disabled:t.status!=="pending"||!p}),C={transform:mx.Transform.toString(v),transition:S},T=t.status==="printing",k=t.status==="pending",E=["completed","failed","skipped","cancelled"].includes(t.status);return a.jsx("div",{ref:y,style:C,className:`
  8274. group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
  8275. transition-all duration-200 hover:border-bambu-dark-tertiary/80
  8276. ${N?"opacity-50 scale-[1.02] shadow-xl z-50":""}
  8277. ${T?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
  8278. `,children:a.jsxs("div",{className:"flex items-center gap-4 p-4",children:[k&&d&&a.jsx("button",{onClick:D=>{D.stopPropagation(),d()},className:`flex items-center justify-center w-6 h-6 rounded border transition-colors ${u?"bg-bambu-green border-bambu-green text-white":"border-white/30 bg-black/30 hover:border-bambu-green/50"}`,children:u&&a.jsx(Wi,{className:"w-4 h-4"})}),k?a.jsx("div",{...x,...b,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:a.jsx(zg,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}):e!==void 0?a.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]}):a.jsx("div",{className:"w-8"}),a.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?a.jsx("img",{src:t.plate_id!=null?ue.getArchivePlateThumbnail(t.archive_id,t.plate_id):ue.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):t.library_file_thumbnail?a.jsx("img",{src:t.plate_id!=null?ue.getLibraryFilePlateThumbnail(t.library_file_id,t.plate_id):ue.getLibraryFileThumbnailUrl(t.library_file_id),alt:"",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:a.jsx(xs,{className:"w-6 h-6"})})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||t.library_file_name||`File #${t.archive_id||t.library_file_id}`}),t.archive_id?a.jsx(Os,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View archive",children:a.jsx(Yr,{className:"w-3.5 h-3.5"})}):t.library_file_id?a.jsx(Os,{to:`/library?highlight=${t.library_file_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View in File Manager",children:a.jsx(Yr,{className:"w-3.5 h-3.5"})}):null]}),a.jsxs("div",{className:"flex items-center gap-3 text-sm text-bambu-gray",children:[a.jsxs("span",{className:`flex items-center gap-1.5 ${t.printer_id===null&&!t.target_model?"text-orange-400":""} ${t.target_model?"text-blue-400":""}`,children:[a.jsx(Ir,{className:"w-3.5 h-3.5"}),t.target_model?`Any ${t.target_model}${t.required_filament_types?.length?` (${t.required_filament_types.join(", ")})`:""}`:t.printer_id===null?"Unassigned":t.printer_name||`Printer #${t.printer_id}`]}),t.print_time_seconds&&a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(gu,{className:"w-3.5 h-3.5"}),Bre(t.print_time_seconds)]}),t.created_by_username&&a.jsxs("span",{className:"flex items-center gap-1.5",title:`Added by ${t.created_by_username}`,children:[a.jsx(am,{className:"w-3.5 h-3.5"}),t.created_by_username]}),k&&!t.manual_start&&a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(Qn,{className:"w-3.5 h-3.5"}),YWe(t.scheduled_time,c)]})]}),a.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.manual_start&&a.jsxs("span",{className:"text-xs px-2 py-0.5 bg-purple-500/10 text-purple-400 rounded-full border border-purple-500/20 flex items-center gap-1",children:[a.jsx(SW,{className:"w-3 h-3"}),"Staged"]}),t.require_previous_success&&a.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&&a.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:[a.jsx(Vu,{className:"w-3 h-3"}),"Auto power off"]})]}),T&&a.jsxs("div",{className:"mt-3",children:[a.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Printing in progress..."})]}),t.waiting_reason&&t.status==="pending"&&a.jsxs("p",{className:"text-xs text-purple-400 mt-2 flex items-start gap-1",children:[a.jsx(Ii,{className:"w-3 h-3 mt-0.5 flex-shrink-0"}),a.jsx("span",{children:t.waiting_reason})]}),t.error_message&&a.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[a.jsx(Ii,{className:"w-3 h-3"}),t.error_message]})]}),a.jsx(QWe,{status:t.status,waitingReason:t.waiting_reason}),a.jsxs("div",{className:"flex items-center gap-1",children:[T&&a.jsx(Ne,{variant:"ghost",size:"sm",onClick:s,disabled:!f("printers:control"),title:f("printers:control")?"Stop Print":"You do not have permission to stop prints",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:a.jsx(tue,{className:"w-4 h-4"})}),k&&a.jsxs(a.Fragment,{children:[t.manual_start&&a.jsx(Ne,{variant:"ghost",size:"sm",onClick:l,disabled:!f("printers:control"),title:f("printers:control")?"Start Print":"You do not have permission to start prints",className:"text-bambu-green hover:text-bambu-green-light hover:bg-bambu-green/10",children:a.jsx(Us,{className:"w-4 h-4"})}),a.jsx(Ne,{variant:"ghost",size:"sm",onClick:n,disabled:!m("queue","update",t.created_by_id),title:m("queue","update",t.created_by_id)?"Edit":"You do not have permission to edit this queue item",children:a.jsx(Ki,{className:"w-4 h-4"})}),a.jsx(Ne,{variant:"ghost",size:"sm",onClick:r,disabled:!m("queue","delete",t.created_by_id),title:m("queue","delete",t.created_by_id)?"Cancel":"You do not have permission to cancel this queue item",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:a.jsx(Dt,{className:"w-4 h-4"})})]}),E&&a.jsxs(a.Fragment,{children:[a.jsx(Ne,{variant:"ghost",size:"sm",onClick:o,disabled:!f("queue:create"),title:f("queue:create")?"Re-queue":"You do not have permission to re-queue items",className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:a.jsx(Pr,{className:"w-4 h-4"})}),a.jsx(Ne,{variant:"ghost",size:"sm",onClick:i,disabled:!m("queue","delete",t.created_by_id),title:m("queue","delete",t.created_by_id)?"Remove":"You do not have permission to remove this queue item",children:a.jsx(an,{className:"w-4 h-4"})})]})]})]})})}function JWe(){const t=on(),{showToast:e}=Vn(),{hasPermission:n,hasAnyPermission:r,canModify:i}=Si(),[s,o]=w.useState(null),[l,c]=w.useState(""),[u,d]=w.useState(!1),[f,m]=w.useState(null),[p,x]=w.useState(null),[b,y]=w.useState(null),[v,S]=w.useState([]),[N,C]=w.useState(!1),[T,k]=w.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[E,D]=w.useState(()=>{const U=localStorage.getItem("queue.historySortAsc");return U!==null?U==="true":!1}),[A,R]=w.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[F,O]=w.useState(()=>{const U=localStorage.getItem("queue.pendingSortAsc");return U!==null?U==="true":!0});w.useEffect(()=>{localStorage.setItem("queue.historySortBy",T)},[T]),w.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(E))},[E]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",A)},[A]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(F))},[F]);const H=gre(J2($M,{activationConstraint:{distance:8}}),J2(BM,{coordinateGetter:Ure})),{data:j}=at({queryKey:["settings"],queryFn:ue.getSettings}),G=j?.time_format||"system",{data:$,isLoading:q}=at({queryKey:["queue",s,l],queryFn:()=>ue.getQueue(s||void 0,l||void 0),refetchInterval:5e3}),{data:Y}=at({queryKey:["printers"],queryFn:()=>ue.getPrinters()}),Z=mt({mutationFn:U=>ue.cancelQueueItem(U),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),oe=mt({mutationFn:U=>ue.removeFromQueue(U),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),B=mt({mutationFn:U=>ue.stopQueueItem(U),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),W=mt({mutationFn:U=>ue.startQueueItem(U),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print released to queue")},onError:()=>e("Failed to start print","error")}),se=mt({mutationFn:U=>ue.reorderQueue(U),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),ne=mt({mutationFn:async()=>{const U=$?.filter(K=>["completed","failed","skipped","cancelled"].includes(K.status))||[];for(const K of U)await ue.removeFromQueue(K.id);return U.length},onSuccess:U=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${U} history item${U!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),ce=mt({mutationFn:U=>ue.bulkUpdateQueue(U),onSuccess:U=>{t.invalidateQueries({queryKey:["queue"]}),S([]),C(!1),e(U.message)},onError:()=>e("Failed to update items","error")}),fe=mt({mutationFn:async U=>{for(const K of U)await ue.cancelQueueItem(K);return U.length},onSuccess:U=>{t.invalidateQueries({queryKey:["queue"]}),S([]),e(`Cancelled ${U} item${U!==1?"s":""}`)},onError:()=>e("Failed to cancel items","error")}),ye=U=>{S(K=>K.includes(U)?K.filter(J=>J!==U):[...K,U])},ge=w.useMemo(()=>{const U=$?.filter(J=>J.status==="pending")||[],K=J=>{if(!J.scheduled_time)return 0;const Q=new Date(J.scheduled_time).getTime(),z=Date.now()+4320*60*60*1e3;return Q>z?0:Q};return[...U].sort((J,Q)=>{let z;if(A==="name"){const re=J.archive_name||J.library_file_name||"",Ee=Q.archive_name||Q.library_file_name||"";z=re.localeCompare(Ee)}else A==="printer"?z=(J.printer_name||"").localeCompare(Q.printer_name||""):A==="time"?z=K(J)-K(Q):z=J.position-Q.position;return F?z:-z})},[$,A,F]),xe=()=>{const U=ge.map(K=>K.id);v.length===U.length?S([]):S(U)},Pe=$?.filter(U=>U.status==="printing")||[],Ue=w.useMemo(()=>[...$?.filter(K=>["completed","failed","skipped","cancelled"].includes(K.status))||[]].sort((K,J)=>{let Q;if(T==="name"){const z=K.archive_name||K.library_file_name||"",re=J.archive_name||J.library_file_name||"";Q=z.localeCompare(re)}else T==="printer"?Q=(K.printer_name||"").localeCompare(J.printer_name||""):Q=new Date(J.completed_at||J.created_at).getTime()-new Date(K.completed_at||K.created_at).getTime();return E?-Q:Q}),[$,T,E]),be=w.useMemo(()=>ge.reduce((U,K)=>U+(K.print_time_seconds||0),0),[ge]),it=U=>{const{active:K,over:J}=U;if(!J||K.id===J.id)return;const Q=ge.findIndex(re=>re.id===K.id),z=ge.findIndex(re=>re.id===J.id);if(Q!==-1&&z!==-1){const Ee=GM(ge,Q,z).map((_e,Te)=>({id:_e.id,position:Te+1}));se.mutate(Ee)}};return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsx("div",{className:"flex items-center justify-between mb-8",children:a.jsxs("div",{children:[a.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[a.jsx(NW,{className:"w-7 h-7 text-bambu-green"}),"Print Queue"]}),a.jsx("p",{className:"text-bambu-gray mt-1",children:"Schedule and manage your print jobs"})]})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[a.jsx(wt,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:a.jsx(St,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:a.jsx(Us,{className:"w-5 h-5 text-blue-400"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:Pe.length}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),a.jsx(wt,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:a.jsx(St,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center",children:a.jsx(Qn,{className:"w-5 h-5 text-yellow-400"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:ge.length}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),a.jsx(wt,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:a.jsx(St,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:a.jsx(gu,{className:"w-5 h-5 text-bambu-green"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:Bre(be)}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),a.jsx(wt,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:a.jsx(St,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-500/20 flex items-center justify-center",children:a.jsx(Tr,{className:"w-5 h-5 text-gray-400"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:Ue.length}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"History"})]})]})})})]}),a.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[a.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:s===-1?"unassigned":s||"",onChange:U=>{const K=U.target.value;o(K==="unassigned"?-1:K===""?null:Number(K))},children:[a.jsx("option",{value:"",children:"All Printers"}),a.jsx("option",{value:"unassigned",children:"Unassigned"}),Y?.map(U=>a.jsx("option",{value:U.id,children:U.name},U.id))]}),a.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:l,onChange:U=>c(U.target.value),children:[a.jsx("option",{value:"",children:"All Status"}),a.jsx("option",{value:"pending",children:"Pending"}),a.jsx("option",{value:"printing",children:"Printing"}),a.jsx("option",{value:"completed",children:"Completed"}),a.jsx("option",{value:"failed",children:"Failed"}),a.jsx("option",{value:"skipped",children:"Skipped"}),a.jsx("option",{value:"cancelled",children:"Cancelled"})]}),a.jsx("div",{className:"flex-1"}),Ue.length>0&&a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>d(!0),disabled:!n("queue:delete_all"),title:n("queue:delete_all")?void 0:"You do not have permission to clear all history",children:[a.jsx(an,{className:"w-4 h-4"}),"Clear History"]})]}),q?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):$?.length===0?a.jsxs(wt,{className:"p-12 text-center border-dashed",children:[a.jsx(ti,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),a.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:"No prints scheduled"}),a.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.'})]}):a.jsxs("div",{className:"space-y-8",children:[Pe.length>0&&a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),"Currently Printing"]}),a.jsx("div",{className:"space-y-3",children:Pe.map(U=>a.jsx(Hj,{item:U,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>y({type:"stop",item:U}),onRequeue:()=>{},onStart:()=>{},timeFormat:G,hasPermission:n,canModify:i},U.id))})]}),ge.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Qn,{className:"w-5 h-5 text-yellow-400"}),"Queued",a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",ge.length," item",ge.length!==1?"s":"",")"]}),a.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)"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.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:A,onChange:U=>R(U.target.value),children:[a.jsx("option",{value:"position",children:"Sort by Position"}),a.jsx("option",{value:"name",children:"Sort by Name"}),a.jsx("option",{value:"printer",children:"Sort by Printer"}),a.jsx("option",{value:"time",children:"Sort by Schedule"})]}),a.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>O(!F),title:F?"Ascending":"Descending",className:"px-2",children:F?a.jsx(Fg,{className:"w-4 h-4"}):a.jsx(G0,{className:"w-4 h-4"})})]})]}),a.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-bambu-dark rounded-lg",children:[a.jsxs(Ne,{variant:"ghost",size:"sm",onClick:xe,className:"flex items-center gap-2",children:[v.length===ge.length&&ge.length>0?a.jsx(Vs,{className:"w-4 h-4 text-bambu-green"}):a.jsx(il,{className:"w-4 h-4"}),v.length===ge.length&&ge.length>0?"Deselect All":"Select All"]}),v.length>0&&a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"text-sm text-bambu-gray",children:[v.length," selected"]}),a.jsx("div",{className:"h-4 w-px bg-bambu-dark-tertiary"}),a.jsxs(Ne,{variant:"ghost",size:"sm",onClick:()=>C(!0),className:"flex items-center gap-2 text-bambu-green hover:text-bambu-green-light",disabled:!r("queue:update_own","queue:update_all"),title:r("queue:update_own","queue:update_all")?void 0:"You do not have permission to edit queue items",children:[a.jsx(Ki,{className:"w-4 h-4"}),"Edit Selected"]}),a.jsxs(Ne,{variant:"ghost",size:"sm",onClick:()=>fe.mutate(v),className:"flex items-center gap-2 text-red-400 hover:text-red-300",disabled:fe.isPending||!r("queue:delete_own","queue:delete_all"),title:r("queue:delete_own","queue:delete_all")?void 0:"You do not have permission to cancel queue items",children:[a.jsx(Dt,{className:"w-4 h-4"}),"Cancel Selected"]})]})]}),a.jsx(Rre,{sensors:H,collisionDetection:vre,onDragEnd:it,children:a.jsx(Lre,{items:ge.map(U=>U.id),strategy:UWe,children:a.jsx("div",{className:"space-y-3",children:ge.map((U,K)=>a.jsx(Hj,{item:U,position:K+1,onEdit:()=>m(U),onCancel:()=>y({type:"cancel",item:U}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>W.mutate(U.id),timeFormat:G,isSelected:v.includes(U.id),onToggleSelect:()=>ye(U.id),hasPermission:n,canModify:i},U.id))})})})]}),Ue.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Tr,{className:"w-5 h-5 text-bambu-gray"}),"History",a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",Ue.length," item",Ue.length!==1?"s":"",")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.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:T,onChange:U=>k(U.target.value),children:[a.jsx("option",{value:"date",children:"Sort by Date"}),a.jsx("option",{value:"name",children:"Sort by Name"}),a.jsx("option",{value:"printer",children:"Sort by Printer"})]}),a.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>D(!E),title:E?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:E?a.jsx(Fg,{className:"w-4 h-4"}):a.jsx(G0,{className:"w-4 h-4"})})]})]}),a.jsx("div",{className:"space-y-3",children:Ue.slice(0,20).map((U,K)=>a.jsx(Hj,{item:U,position:K+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>y({type:"remove",item:U}),onStop:()=>{},onRequeue:()=>x(U),onStart:()=>{},timeFormat:G,hasPermission:n,canModify:i},U.id))})]})]}),f&&a.jsx(jh,{mode:"edit-queue-item",archiveId:f.archive_id??void 0,libraryFileId:f.library_file_id??void 0,archiveName:f.archive_name||f.library_file_name||`File #${f.archive_id||f.library_file_id}`,queueItem:f,onClose:()=>m(null)}),p&&a.jsx(jh,{mode:"add-to-queue",archiveId:p.archive_id??void 0,libraryFileId:p.library_file_id??void 0,archiveName:p.archive_name||p.library_file_name||`File #${p.archive_id||p.library_file_id}`,onClose:()=>x(null)}),b&&a.jsx(Yn,{title:b.type==="cancel"?"Cancel Scheduled Print":b.type==="stop"?"Stop Print":"Remove from History",message:b.type==="cancel"?`Are you sure you want to cancel "${b.item.archive_name||b.item.library_file_name||"this print"}"?`:b.type==="stop"?`Are you sure you want to stop the current print "${b.item.archive_name||b.item.library_file_name||"this print"}"? This will cancel the print job on the printer.`:`Are you sure you want to remove "${b.item.archive_name||b.item.library_file_name||"this item"}" from the queue history?`,confirmText:b.type==="cancel"?"Cancel Print":b.type==="stop"?"Stop Print":"Remove",variant:"danger",onConfirm:()=>{b.type==="cancel"?Z.mutate(b.item.id):b.type==="stop"?B.mutate(b.item.id):oe.mutate(b.item.id),y(null)},onCancel:()=>y(null)}),u&&a.jsx(Yn,{title:"Clear History",message:`Are you sure you want to remove all ${Ue.length} item${Ue.length!==1?"s":""} from the history?`,confirmText:"Clear History",variant:"danger",onConfirm:()=>{ne.mutate(),d(!1)},onCancel:()=>d(!1)}),N&&a.jsx(ZWe,{selectedCount:v.length,printers:Y?.map(U=>({id:U.id,name:U.name}))||[],onSave:U=>{Object.keys(U).length>0&&ce.mutate({item_ids:v,...U})},onClose:()=>C(!1),isSaving:ce.isPending})]})}function eKe({printDates:t,months:e=3}){const n=w.useRef(null),[r,i]=w.useState(0);w.useEffect(()=>{const S=n.current;if(!S)return;const N=new ResizeObserver(C=>{const T=C[0]?.contentRect.width||0;i(T)});return N.observe(S),()=>N.disconnect()},[]);const{weeks:s,monthLabels:o,printCounts:l}=w.useMemo(()=>{const S={};t.forEach(F=>{const O=F.split("T")[0];S[O]=(S[O]||0)+1});const N=new Date,C=new Date(N);C.setMonth(C.getMonth()-e),C.setDate(C.getDate()-C.getDay());const T=[],k=[];let E=[],D=-1;const A=new Date(C);let R=0;for(;A<=N;)A.getDay()===0&&E.length>0&&(T.push(E),E=[],R++),A.getMonth()!==D&&(k.push({month:A.toLocaleDateString("en-US",{month:"short"}),weekIndex:R}),D=A.getMonth()),E.push(new Date(A)),A.setDate(A.getDate()+1);return E.length>0&&T.push(E),{weeks:T,monthLabels:k,printCounts:S}},[t,e]),c=Math.max(1,...Object.values(l)),u=S=>{if(S===0)return"bg-bambu-dark";const N=S/c;return N<=.25?"bg-bambu-green/30":N<=.5?"bg-bambu-green/50":N<=.75?"bg-bambu-green/75":"bg-bambu-green"},d=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],f=s.length,m=32,p=2,x=r-m-16,b=f>0?Math.floor((x-(f-1)*p)/f):12,y=Math.max(8,Math.min(20,b)),v=y<=10?10:12;return a.jsx("div",{ref:n,className:"w-full flex justify-center",children:r>0&&a.jsxs("div",{children:[a.jsx("div",{className:"flex mb-1",style:{marginLeft:m+4},children:o.map(({month:S,weekIndex:N},C)=>a.jsx("div",{className:"text-bambu-gray",style:{fontSize:v,marginLeft:C===0?0:`${(N-(o[C-1]?.weekIndex||0))*(y+p)-24}px`},children:S},C))}),a.jsxs("div",{className:"flex",style:{gap:p},children:[a.jsx("div",{className:"flex flex-col",style:{gap:p,marginRight:4,width:m},children:d.map((S,N)=>a.jsx("div",{className:"text-bambu-gray flex items-center",style:{width:m,height:y,fontSize:v,visibility:N%2===1?"visible":"hidden"},children:S},S))}),s.map((S,N)=>a.jsx("div",{className:"flex flex-col",style:{gap:p},children:[0,1,2,3,4,5,6].map(C=>{const T=S.find(A=>A.getDay()===C);if(!T)return a.jsx("div",{style:{width:y,height:y}},C);const k=T.toISOString().split("T")[0],E=l[k]||0,D=k===new Date().toISOString().split("T")[0];return a.jsx("div",{className:`rounded-sm ${u(E)} ${D?"ring-1 ring-white":""}`,style:{width:y,height:y},title:`${T.toLocaleDateString()}: ${E} print${E!==1?"s":""}`},C)})},N))]}),a.jsxs("div",{className:"flex items-center gap-2 mt-3 text-bambu-gray",style:{fontSize:v},children:[a.jsx("span",{children:"Less"}),a.jsxs("div",{className:"flex",style:{gap:p},children:[a.jsx("div",{className:"rounded-sm bg-bambu-dark",style:{width:y,height:y}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/30",style:{width:y,height:y}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/50",style:{width:y,height:y}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/75",style:{width:y,height:y}}),a.jsx("div",{className:"rounded-sm bg-bambu-green",style:{width:y,height:y}})]}),a.jsx("span",{children:"More"})]})]})})}const h1=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function tKe(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 nKe({archives:t,currency:e="$"}){const[n,r]=w.useState("30d"),i=w.useMemo(()=>{const m=tKe(n);return t.filter(p=>(Ri(p.completed_at||p.created_at)||new Date(0))>=m)},[t,n]),s=w.useMemo(()=>{const m=new Map;return i.forEach(p=>{const x=Ri(p.completed_at||p.created_at)||new Date,b=`${x.getFullYear()}-${String(x.getMonth()+1).padStart(2,"0")}-${String(x.getDate()).padStart(2,"0")}`,y=m.get(b)||{date:b,filament:0,cost:0,prints:0};y.filament+=p.filament_used_grams||0,y.cost+=p.cost||0,y.prints+=1,m.set(b,y)}),Array.from(m.values()).sort((p,x)=>p.date.localeCompare(x.date)).map(p=>({...p,dateLabel:new Date(p.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),o=w.useMemo(()=>{if(n==="7d"||n==="30d")return s;const m=new Map;return i.forEach(p=>{const x=Ri(p.completed_at||p.created_at)||new Date,b=new Date(x);b.setDate(x.getDate()-x.getDay());const y=`${b.getFullYear()}-${String(b.getMonth()+1).padStart(2,"0")}-${String(b.getDate()).padStart(2,"0")}`,v=m.get(y)||{week:y,filament:0,cost:0,prints:0};v.filament+=p.filament_used_grams||0,v.cost+=p.cost||0,v.prints+=1,m.set(y,v)}),Array.from(m.values()).sort((p,x)=>p.week.localeCompare(x.week)).map(p=>({date:p.week,dateLabel:`Week of ${new Date(p.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...p}))},[i,s,n]),l=w.useMemo(()=>{const m=new Map;return i.forEach(p=>{const b=(p.filament_type||"Unknown").split(", ");b.forEach(y=>{const v=(p.filament_used_grams||0)/b.length;m.set(y,(m.get(y)||0)+v)})}),Array.from(m.entries()).map(([p,x])=>({name:p,value:Math.round(x)})).sort((p,x)=>x.value-p.value)},[i]),c=w.useMemo(()=>{const m=new Date,p=[];for(let x=5;x>=0;x--){const b=new Date(m.getFullYear(),m.getMonth()-x,1),y=new Date(m.getFullYear(),m.getMonth()-x+1,0),v=b.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),S=t.filter(N=>{const C=Ri(N.completed_at||N.created_at)||new Date(0);return C>=b&&C<=y});p.push({month:v,filament:Math.round(S.reduce((N,C)=>N+(C.filament_used_grams||0),0)),cost:S.reduce((N,C)=>N+(C.cost||0),0),prints:S.length})}return p},[t]),u=n==="7d"||n==="30d"?s:o,d=i.reduce((m,p)=>m+(p.filament_used_grams||0),0),f=i.reduce((m,p)=>m+(p.cost||0),0);return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),a.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(m=>a.jsx("button",{onClick:()=>r(m),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===m?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:m==="all"?"All":m.replace("d","D")},m))})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),a.jsxs("p",{className:"text-2xl font-bold text-white",children:[(d/1e3).toFixed(2),"kg"]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),a.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,f.toFixed(2)]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[i.length," prints"]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),a.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.length>0?(d/i.length).toFixed(0):0,"g"]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,i.length>0?(f/i.length).toFixed(2):"0.00"," avg"]})]})]}),u.length>0?a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),a.jsx(k1,{width:"100%",height:250,children:a.jsxs(UBe,{data:u,children:[a.jsx("defs",{children:a.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[a.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),a.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),a.jsx(t2,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),a.jsx(r2,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),a.jsx(i2,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),a.jsx(P1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:m=>[`${Number(m??0).toFixed(0)}g`,"Filament"]}),a.jsx(see,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):a.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),l.length>0?a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(k1,{width:160,height:160,children:a.jsxs(IBe,{children:[a.jsx(kJ,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((m,p)=>a.jsx(mv,{fill:h1[p%h1.length]},`cell-${p}`))}),a.jsx(P1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:m=>[`${m??0}g`,"Usage"]})]})}),a.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:l.map((m,p)=>{const x=l.reduce((y,v)=>y+v.value,0),b=x>0?(m.value/x*100).toFixed(0):0;return a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:h1[p%h1.length]}}),a.jsx("span",{className:"text-white truncate flex-1",children:m.name}),a.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[b,"%"]})]},m.name)})})]}):a.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),a.jsx(k1,{width:"100%",height:200,children:a.jsxs(MBe,{data:c,children:[a.jsx(t2,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),a.jsx(r2,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),a.jsx(i2,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),a.jsx(P1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(m,p)=>[p==="filament"?`${m??0}g`:p==="cost"?`${e}${Number(m??0).toFixed(2)}`:m??0,p==="filament"?"Filament":p==="cost"?"Cost":"Prints"]}),a.jsx(z4,{}),a.jsx(LJ,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function rKe({id:t,title:e,component:n,isHidden:r,size:i,onToggleVisibility:s,onToggleSize:o}){const{attributes:l,listeners:c,setNodeRef:u,transform:d,transition:f,isDragging:m}=Fre({id:t}),p={transform:mx.Transform.toString(d),transition:f,opacity:m?.5:1};return r?null:a.jsxs("div",{ref:u,style:{...p,gridColumn:`span ${i}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${m?"ring-2 ring-bambu-green shadow-lg":""}`,children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{...l,...c,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:a.jsx(zg,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}),a.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{onClick:o,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?a.jsx(EW,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):a.jsx(MW,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),a.jsx("button",{onClick:s,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:a.jsx(cN,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),a.jsx("div",{className:"p-4",children:typeof n=="function"?n(i):n})]})}function iKe({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i,renderControls:s}){const o=()=>{const C={};return t.forEach(T=>{C[T.id]=T.defaultSize||4}),C},[l,c]=w.useState(()=>{const C=localStorage.getItem(e);if(C)try{const T=JSON.parse(C);return T.sizes||(T.sizes=o()),T}catch{}return{order:t.map(T=>T.id),hidden:t.filter(T=>T.defaultVisible===!1).map(T=>T.id),sizes:o()}}),[u,d]=w.useState(!1);w.useEffect(()=>{const C=()=>d(T=>!T);return window.addEventListener("toggle-hidden-panel",C),()=>window.removeEventListener("toggle-hidden-panel",C)},[]),w.useEffect(()=>{localStorage.setItem(e,JSON.stringify(l))},[l,e]),w.useEffect(()=>{const T=t.map(k=>k.id).filter(k=>!l.order.includes(k));T.length>0&&c(k=>({...k,order:[...k.order,...T]}))},[t,l.order]);const f=gre(J2($M,{activationConstraint:{distance:8}}),J2(BM,{coordinateGetter:Ure})),m=C=>{const{active:T,over:k}=C;k&&T.id!==k.id&&c(E=>{const D=E.order.indexOf(T.id),A=E.order.indexOf(k.id);return{...E,order:GM(E.order,D,A)}})},p=C=>{c(T=>({...T,hidden:T.hidden.includes(C)?T.hidden.filter(k=>k!==C):[...T.hidden,C]}))},x=C=>{c(T=>{const k=T.sizes[C]||4,E=k===1?2:k===2?4:1;return{...T,sizes:{...T.sizes,[C]:E}}})},b=()=>{const C={order:t.map(T=>T.id),hidden:t.filter(T=>T.defaultVisible===!1).map(T=>T.id),sizes:o()};c(C),i?.()},y=l.order.map(C=>t.find(T=>T.id===C)).filter(Boolean),v=y.filter(C=>!l.hidden.includes(C.id)),S=y.filter(C=>l.hidden.includes(C.id)),N=s?.({hiddenCount:S.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:b});return a.jsxs("div",{className:"space-y-4",children:[N,!r&&!s&&a.jsxs("div",{className:"flex items-center justify-end gap-2",children:[a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:b,children:[a.jsx(Dh,{className:"w-4 h-4"}),"Reset Layout"]}),S.length>0&&a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[a.jsx(Ru,{className:"w-4 h-4"}),S.length," Hidden"]})]}),u&&S.length>0&&a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:S.map(C=>a.jsxs("button",{onClick:()=>p(C.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:[a.jsx(Ru,{className:"w-3 h-3"}),C.title]},C.id))})]}),a.jsx(Rre,{sensors:f,collisionDetection:vre,onDragEnd:m,children:a.jsx(Lre,{items:v.map(C=>C.id),strategy:d5,children:a.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:v.map(C=>a.jsx(rKe,{id:C.id,title:C.title,component:C.component,isHidden:l.hidden.includes(C.id),size:l.sizes[C.id]||2,onToggleVisibility:()=>p(C.id),onToggleSize:()=>x(C.id)},C.id))})})}),v.length===0&&a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx("p",{children:"All widgets are hidden."}),a.jsx(Ne,{className:"mt-4",onClick:b,children:"Reset Layout"})]})]})}function aKe({stats:t,currency:e}){return a.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:a.jsx(pc,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),a.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:a.jsx(Qn,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:a.jsx(pc,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:a.jsx(f3,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:a.jsx(vh,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:a.jsx(f3,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function sKe({stats:t,printerMap:e,size:n=1}){const r=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0,i=n===1?112:n===2?128:144,s=i/2-8,o=s*2*Math.PI;return a.jsxs("div",{className:"flex items-center gap-6",children:[a.jsxs("div",{className:"relative flex-shrink-0",style:{width:i,height:i},children:[a.jsxs("svg",{className:"w-full h-full -rotate-90",children:[a.jsx("circle",{cx:i/2,cy:i/2,r:s,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),a.jsx("circle",{cx:i/2,cy:i/2,r:s,fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${r/100*o} ${o}`})]}),a.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[r,"%"]})})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Tr,{className:"w-4 h-4 text-status-ok flex-shrink-0"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),a.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(qi,{className:"w-4 h-4 text-status-error flex-shrink-0"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:"Failed:"}),a.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]}),n>=2&&t?.prints_by_printer&&Object.keys(t.prints_by_printer).length>0&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:"Prints by Printer"}),a.jsx("div",{className:`grid gap-x-6 gap-y-1 ${n===4?"grid-cols-3":"grid-cols-2"}`,style:{width:"fit-content"},children:Object.entries(t.prints_by_printer).map(([l,c])=>a.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[a.jsx("span",{className:"text-bambu-gray truncate max-w-[120px]",children:e.get(l)||`Printer ${l}`}),a.jsx("span",{className:"text-white font-medium",children:c})]},l))})]})]})]})}function oKe({stats:t,printerMap:e,size:n=1}){const r=t?.average_time_accuracy;if(r==null)return a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No time accuracy data yet"})});const s=(Math.min(150,Math.max(50,r))-50)/100*100,l=(x=>x>=95&&x<=105?"#00ae42":x>105?"#3b82f6":"#f97316")(r),c=r-100,u=n===1?112:n===2?128:144,d=u/2-8,f=d*2*Math.PI,m=n===1?3:n===2?6:999,p=t?.time_accuracy_by_printer?Object.entries(t.time_accuracy_by_printer).slice(0,m):[];return a.jsxs("div",{className:"flex items-center gap-6",children:[a.jsxs("div",{className:"relative flex-shrink-0",style:{width:u,height:u},children:[a.jsxs("svg",{className:"w-full h-full -rotate-90",children:[a.jsx("circle",{cx:u/2,cy:u/2,r:d,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),a.jsx("circle",{cx:u/2,cy:u/2,r:d,fill:"none",stroke:l,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${s/100*f} ${f}`})]}),a.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[a.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[r.toFixed(0),"%"]}),a.jsxs("span",{className:`text-xs ${c>=0?"text-blue-400":"text-orange-400"}`,children:[c>=0?"+":"",c.toFixed(0),"%"]})]})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[a.jsx(PW,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{children:"100% = perfect estimate"})]}),p.length>0&&a.jsx("div",{className:`mt-2 ${n===4?"grid grid-cols-3 gap-x-6 gap-y-1":n===2?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,style:{width:"fit-content"},children:p.map(([x,b])=>a.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(x)||`Printer ${x}`}),a.jsxs("span",{className:`font-medium ${b>=95&&b<=105?"text-status-ok":b>105?"text-blue-400":"text-status-warning"}`,children:[b.toFixed(0),"%"]})]},x))})]})]})}function lKe({stats:t,size:e=1}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return a.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No filament data available"});const n=Object.entries(t.prints_by_filament_type).sort(([,o],[,l])=>l-o),r=e===1?5:e===2?8:999,i=n.slice(0,r),s=n.length>r;return e===4&&i.length>4?a.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4",children:i.map(([o,l])=>{const c=Math.round(l/(t.total_prints||1)*100);return a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-white truncate max-w-[120px]",children:o}),a.jsx("span",{className:"text-bambu-gray",children:l})]}),a.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:a.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${c}%`}})})]},o)})}):a.jsxs("div",{className:"space-y-3",children:[i.map(([o,l])=>{const c=Math.round(l/(t.total_prints||1)*100);return a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-white",children:o}),a.jsxs("span",{className:"text-bambu-gray",children:[l," prints"]})]}),a.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:a.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${c}%`}})})]},o)}),s&&a.jsxs("p",{className:"text-xs text-bambu-gray text-center pt-1",children:["+",n.length-r," more types"]})]})}function cKe({printDates:t,size:e=2}){const n=e===1?3:e===2?6:12;return a.jsx(eKe,{printDates:t,months:n})}function uKe({stats:t,printerMap:e}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?a.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No printer data available"}):a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,r])=>a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[a.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:a.jsx(Ir,{className:"w-4 h-4 text-bambu-green"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[r," prints"]})]})]},n))})}function dKe({archives:t,currency:e}){return!t||t.length===0?a.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data available"}):a.jsx(nKe,{archives:t,currency:e})}function hKe({size:t=1}){const{data:e,isLoading:n}=at({queryKey:["failureAnalysis"],queryFn:()=>ue.getFailureAnalysis({days:30})});if(n)return a.jsx("div",{className:"flex justify-center py-4",children:a.jsx(ct,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!e||e.total_prints===0)return a.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data in the last 30 days"});const r=t===1?5:t===2?8:999,i=Object.entries(e.failures_by_reason).sort(([,l],[,c])=>c-l),s=i.slice(0,r),o=i.length>r;return a.jsxs("div",{className:`${t>=2?"flex gap-8":"space-y-4"}`,children:[a.jsxs("div",{className:t>=2?"flex-shrink-0":"",children:[a.jsx("div",{className:"flex items-center gap-4",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(jn,{className:`w-5 h-5 ${e.failure_rate>20?"text-status-error":e.failure_rate>10?"text-status-warning":"text-status-ok"}`}),a.jsxs("span",{className:`font-bold text-white ${t>=2?"text-3xl":"text-2xl"}`,children:[e.failure_rate.toFixed(1),"%"]})]})}),a.jsxs("div",{className:"text-sm text-bambu-gray mt-1",children:[e.failed_prints," / ",e.total_prints," prints failed"]}),e.trend&&e.trend.length>=2&&a.jsx("div",{className:`${t>=2?"mt-4":"mt-2 pt-2 border-t border-bambu-dark-tertiary"}`,children:a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(DW,{className:`w-4 h-4 ${e.trend[e.trend.length-1].failure_rate<e.trend[e.trend.length-2].failure_rate?"text-status-ok":"text-status-error"}`}),a.jsxs("span",{className:"text-bambu-gray",children:["Last week: ",e.trend[e.trend.length-1].failure_rate.toFixed(1),"%"]})]})})]}),s.length>0&&a.jsxs("div",{className:`flex-1 ${t>=2?"border-l border-bambu-dark-tertiary pl-8":"pt-2"}`,children:[a.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:t>=2?"Failure Reasons":"Top Failure Reasons"}),a.jsx("div",{className:`${t===4?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,children:s.map(([l,c])=>a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:`text-white truncate ${t===4?"max-w-[200px]":"max-w-[160px]"}`,children:l||"Unknown"}),a.jsx("span",{className:"text-bambu-gray ml-2",children:c})]},l))}),o&&a.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["+",i.length-r," more reasons"]})]})]})}function fKe(){const{showToast:t}=Vn(),{hasPermission:e}=Si(),[n,r]=w.useState(!1),[i,s]=w.useState(!1),[o,l]=w.useState(0),[c,u]=w.useState(0),[d,f]=w.useState(!1);w.useEffect(()=>{const D=()=>{try{const R=localStorage.getItem("bambusy-dashboard-layout");if(R){const F=JSON.parse(R);u(F.hidden?.length||0)}}catch{u(0)}};D(),window.addEventListener("storage",D);const A=setInterval(D,500);return()=>{window.removeEventListener("storage",D),clearInterval(A)}},[o]);const{data:m,isLoading:p,refetch:x}=at({queryKey:["archiveStats"],queryFn:ue.getArchiveStats}),{data:b}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:y}=at({queryKey:["archives"],queryFn:()=>ue.getArchives(void 0,void 0,1e3,0)}),{data:v}=at({queryKey:["settings"],queryFn:ue.getSettings}),S=async D=>{s(!1),r(!0);try{const{blob:A,filename:R}=await ue.exportStats({format:D,days:90}),F=URL.createObjectURL(A),O=document.createElement("a");O.href=F,O.download=R,O.click(),URL.revokeObjectURL(F),t("Export downloaded")}catch{t("Export failed","error")}finally{r(!1)}},N=async()=>{f(!0);try{const D=await ue.recalculateCosts();await x(),t(`Recalculated costs for ${D.updated} archives`)}catch{t("Failed to recalculate costs","error")}finally{f(!1)}},C=v?.currency||"$",T=new Map(b?.map(D=>[String(D.id),D.name])||[]),k=y?.map(D=>D.created_at)||[];if(p)return a.jsx("div",{className:"p-4 md:p-8",children:a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const E=[{id:"quick-stats",title:"Quick Stats",component:a.jsx(aKe,{stats:m,currency:C}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:D=>a.jsx(sKe,{stats:m,printerMap:T,size:D}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:D=>a.jsx(oKe,{stats:m,printerMap:T,size:D}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:D=>a.jsx(lKe,{stats:m,size:D}),defaultSize:1},{id:"failure-analysis",title:"Failure Analysis (30 days)",component:D=>a.jsx(hKe,{size:D}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:D=>a.jsx(cKe,{printDates:k,size:D}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:a.jsx(uKe,{stats:m,printerMap:T}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:a.jsx(dKe,{archives:y||[],currency:C}),defaultSize:4}];return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),a.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[c>0&&a.jsxs(Ne,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[a.jsx(Ru,{className:"w-4 h-4"}),c," Hidden"]}),a.jsxs(Ne,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),l(D=>D+1),t("Layout reset")},disabled:!e("settings:update"),title:e("settings:update")?void 0:"You do not have permission to reset layout",children:[a.jsx(Dh,{className:"w-4 h-4"}),"Reset Layout"]}),a.jsxs(Ne,{variant:"secondary",onClick:N,disabled:d||!e("archives:update_all"),title:e("archives:update_all")?"Recalculate all archive costs using current filament prices":"You do not have permission to recalculate costs",children:[d?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(Dce,{className:"w-4 h-4"}),"Recalculate Costs"]}),a.jsxs("div",{className:"relative",children:[a.jsxs(Ne,{variant:"secondary",onClick:()=>s(!i),disabled:n,children:[n?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(W1,{className:"w-4 h-4"}),"Export Stats"]}),i&&a.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:[a.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:()=>S("csv"),children:[a.jsx(fs,{className:"w-4 h-4"}),"Export as CSV"]}),a.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:()=>S("xlsx"),children:[a.jsx(W1,{className:"w-4 h-4"}),"Export as Excel"]})]})]})]})]}),a.jsx(iKe,{widgets:E,storageKey:"bambusy-dashboard-layout",hideControls:!0},o)]})}function mKe({plug:t,onEdit:e}){const n=on(),{showToast:r}=Vn(),[i,s]=w.useState(!1),[o,l]=w.useState(!1),[c,u]=w.useState(!1),[d,f]=w.useState(!1),{data:m,isLoading:p}=at({queryKey:["smart-plug-status",t.id],queryFn:()=>ue.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:x}=at({queryKey:["printers"],queryFn:ue.getPrinters}),b=x?.find(A=>A.id===t.printer_id),y=mt({mutationFn:A=>ue.controlSmartPlug(t.id,A),onMutate:async A=>{await n.cancelQueries({queryKey:["smart-plug-status",t.id]});const R=n.getQueryData(["smart-plug-status",t.id]),F=A==="on"?"ON":A==="off"||m?.state==="ON"?"OFF":"ON";return n.setQueryData(["smart-plug-status",t.id],O=>({...O,state:F})),{previousStatus:R}},onError:(A,R,F)=>{F?.previousStatus&&n.setQueryData(["smart-plug-status",t.id],F.previousStatus),r(`Failed to turn ${R} "${t.name}"`,"error")},onSettled:()=>{setTimeout(()=>{n.invalidateQueries({queryKey:["smart-plug-status",t.id]}),n.invalidateQueries({queryKey:["smart-plugs"]})},1e3)}}),v=mt({mutationFn:A=>ue.updateSmartPlug(t.id,A),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),S=mt({mutationFn:()=>ue.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),N=m?.state==="ON",C=t.plug_type==="mqtt"&&m?.energy?.power!==null&&m?.energy?.power!==void 0,T=(m?.reachable??!1)||C,k=y.isPending,D=(()=>{if(t.plug_type!=="tasmota"||!t.ip_address)return null;const A=t.ip_address;return t.username&&t.password?`http://${encodeURIComponent(t.username)}:${encodeURIComponent(t.password)}@${A}/`:`http://${A}/`})();return a.jsxs(a.Fragment,{children:[a.jsx(wt,{className:"relative",children:a.jsxs(St,{className:"p-4",children:[a.jsxs("div",{className:"flex items-start justify-between gap-2 mb-3",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx("div",{className:`p-2 rounded-lg flex-shrink-0 ${t.plug_type==="mqtt"?T?"bg-teal-500/20":"bg-red-500/20":T?N?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:t.plug_type==="mqtt"?a.jsx(PD,{className:`w-5 h-5 ${T?"text-teal-400":"text-red-400"}`}):t.plug_type==="homeassistant"?a.jsx(mN,{className:`w-5 h-5 ${T?N?"text-bambu-green":"text-bambu-gray":"text-red-400"}`}):a.jsx(el,{className:`w-5 h-5 ${T?N?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("h3",{className:"font-medium text-white truncate",children:t.name}),a.jsx("p",{className:"text-sm text-bambu-gray truncate",title:t.plug_type==="mqtt"?t.mqtt_topic??void 0:t.plug_type==="homeassistant"?t.ha_entity_id??void 0:t.ip_address??void 0,children:t.plug_type==="mqtt"?t.mqtt_topic:t.plug_type==="homeassistant"?t.ha_entity_id:t.ip_address})]})]}),a.jsxs("div",{className:"flex flex-col items-end gap-1 flex-shrink-0",children:[p?a.jsx(ct,{className:"w-4 h-4 text-bambu-gray animate-spin"}):t.plug_type==="mqtt"?a.jsxs("div",{className:"flex items-center gap-1.5 text-sm whitespace-nowrap",children:[a.jsx("span",{className:"px-1.5 py-0.5 bg-teal-500/20 text-teal-400 text-[10px] font-medium rounded flex-shrink-0",children:"MQTT"}),T&&a.jsx("span",{className:"text-status-ok",children:"✓"})]}):t.plug_type==="homeassistant"?a.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[a.jsx("span",{className:"px-1 py-0.5 bg-blue-500/20 text-blue-400 text-[10px] font-medium rounded",children:"HA"}),a.jsx("span",{className:T?N?"text-status-ok":"text-bambu-gray":"text-status-error",children:T?m?.state||"?":"Offline"})]}):T?a.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[a.jsx(Sg,{className:"w-4 h-4 text-status-ok"}),a.jsx("span",{className:N?"text-status-ok":"text-bambu-gray",children:m?.state||"Unknown"})]}):a.jsxs("div",{className:"flex items-center gap-1 text-sm text-status-error",children:[a.jsx(sm,{className:"w-4 h-4"}),a.jsx("span",{children:"Offline"})]}),D&&a.jsxs("a",{href:D,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-2 py-0.5 bg-bambu-dark hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white text-xs rounded-full transition-colors",title:"Open plug admin page",children:[a.jsx(Yr,{className:"w-3 h-3"}),"Admin"]})]})]}),b&&a.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),a.jsx("span",{className:"text-sm text-white",children:b.name})]}),(t.power_alert_enabled||t.schedule_enabled||t.plug_type==="mqtt")&&a.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.plug_type==="mqtt"&&a.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-teal-500/20 text-teal-400 text-xs rounded-full",children:[a.jsx(Ru,{className:"w-3 h-3"}),"Monitor Only"]}),t.power_alert_enabled&&a.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:[a.jsx(_g,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&a.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:[a.jsx(ti,{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}`]})]}),t.plug_type!=="mqtt"&&a.jsxs("div",{className:"flex gap-2 mb-3",children:[a.jsxs(Ne,{size:"sm",variant:N?"primary":"secondary",disabled:!T||k,onClick:()=>l(!0),className:"flex-1",children:[k?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(Vu,{className:"w-4 h-4"}),"On"]}),a.jsxs(Ne,{size:"sm",variant:N?"secondary":"primary",disabled:!T||k,onClick:()=>u(!0),className:"flex-1",children:[k?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(xN,{className:"w-4 h-4"}),"Off"]})]}),t.plug_type==="mqtt"&&m?.energy&&a.jsxs("div",{className:"flex gap-2 mb-3 px-3 py-2 bg-bambu-dark rounded-lg",children:[m.energy.power!==null&&m.energy.power!==void 0&&a.jsxs("div",{className:"flex-1 text-center",children:[a.jsxs("p",{className:"text-lg font-semibold text-white",children:[Math.round(m.energy.power),"W"]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Power"})]}),m.energy.today!==null&&m.energy.today!==void 0&&a.jsxs("div",{className:"flex-1 text-center border-l border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-lg font-semibold text-white",children:m.energy.today.toFixed(2)}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"kWh Today"})]})]}),a.jsxs("button",{onClick:()=>f(!d),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx(bh,{className:"w-4 h-4"}),t.plug_type==="mqtt"?"Settings":"Automation Settings"]}),a.jsx("span",{children:d?"-":"+"})]}),d&&a.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(pN,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Show in Switchbar"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.show_in_switchbar,onChange:A=>v.mutate({show_in_switchbar:A.target.checked}),className:"sr-only peer"}),a.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.plug_type!=="mqtt"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Enabled"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.enabled,onChange:A=>v.mutate({enabled:A.target.checked}),className:"sr-only peer"}),a.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"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Auto On"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:A=>v.mutate({auto_on:A.target.checked}),className:"sr-only peer"}),a.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"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:A=>v.mutate({auto_off:A.target.checked}),className:"sr-only peer"}),a.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&&a.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:()=>v.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:[a.jsx(Qn,{className:"w-4 h-4"}),"Time"]}),a.jsxs("button",{onClick:()=>v.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:[a.jsx(yN,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),a.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:A=>v.mutate({off_delay_minutes:parseInt(A.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"})]}):a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),a.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:A=>v.mutate({off_temp_threshold:parseInt(A.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"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]})]}),a.jsxs("div",{className:"flex gap-2 pt-2",children:[a.jsxs(Ne,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[a.jsx(hg,{className:"w-4 h-4"}),"Edit"]}),a.jsx(Ne,{size:"sm",variant:"secondary",onClick:()=>s(!0),className:"text-red-400 hover:text-red-300",children:a.jsx(an,{className:"w-4 h-4"})})]})]})]})}),i&&a.jsx(Yn,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{S.mutate(),s(!1)},onCancel:()=>s(!1)}),o&&a.jsx(Yn,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{y.mutate("on"),l(!1)},onCancel:()=>l(!1)}),c&&a.jsx(Yn,{title:"Turn Off Smart Plug",message:`Are you sure you want to turn off "${t.name}"? This will cut power to the connected device.`,confirmText:"Turn Off",variant:"danger",onConfirm:()=>{y.mutate("off"),u(!1)},onCancel:()=>u(!1)})]})}function pKe({plug:t,onClose:e}){const n=on(),r=!!t,[i,s]=w.useState(t?.plug_type||"tasmota"),[o,l]=w.useState(t?.name||""),[c,u]=w.useState(t?.ip_address||""),[d,f]=w.useState(t?.username||""),[m,p]=w.useState(t?.password||""),[x,b]=w.useState(t?.ha_entity_id||""),[y,v]=w.useState(t?.mqtt_power_topic||t?.mqtt_topic||""),[S,N]=w.useState(t?.mqtt_power_path||""),[C,T]=w.useState((t?.mqtt_power_multiplier??t?.mqtt_multiplier??1).toString()),[k,E]=w.useState(t?.mqtt_energy_topic||""),[D,A]=w.useState(t?.mqtt_energy_path||""),[R,F]=w.useState((t?.mqtt_energy_multiplier??1).toString()),[O,H]=w.useState(t?.mqtt_state_topic||""),[j,G]=w.useState(t?.mqtt_state_path||""),[$,q]=w.useState(t?.mqtt_state_on_value||""),[Y,Z]=w.useState(t?.ha_power_entity||""),[oe,B]=w.useState(t?.ha_energy_today_entity||""),[W,se]=w.useState(t?.ha_energy_total_entity||""),[ne,ce]=w.useState(""),[fe,ye]=w.useState(""),[ge,xe]=w.useState(!1),Pe=w.useRef(null),[Ue,be]=w.useState(""),[it,U]=w.useState(!1),K=w.useRef(null),[J,Q]=w.useState(""),[z,re]=w.useState(!1),Ee=w.useRef(null),[_e,Te]=w.useState(""),[V,L]=w.useState(!1),X=w.useRef(null),[te,Me]=w.useState(t?.printer_id||null),[ie,De]=w.useState(null),[Le,$e]=w.useState(null),[Ze,Ie]=w.useState(t?.power_alert_enabled||!1),[ae,He]=w.useState(t?.power_alert_high?.toString()||""),[Se,Be]=w.useState(t?.power_alert_low?.toString()||""),[ft,we]=w.useState(t?.schedule_enabled||!1),[tt,ke]=w.useState(t?.schedule_on_time||""),[We,pe]=w.useState(t?.schedule_off_time||""),[Ce,de]=w.useState(t?.show_in_switchbar||!1),[Ve,yt]=w.useState(!1),[ut,It]=w.useState({scanned:0,total:0}),[Ft,vn]=w.useState([]),Kt=w.useRef(null),{data:cr}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:dr}=at({queryKey:["smart-plugs"],queryFn:ue.getSmartPlugs}),{data:Jn}=at({queryKey:["settings"],queryFn:ue.getSettings}),ln=!!(Jn?.ha_enabled&&Jn?.ha_url&&Jn?.ha_token);w.useEffect(()=>{const me=setTimeout(()=>{ye(ne)},300);return()=>clearTimeout(me)},[ne]),w.useEffect(()=>{const me=Fe=>{Pe.current&&!Pe.current.contains(Fe.target)&&xe(!1),K.current&&!K.current.contains(Fe.target)&&U(!1),Ee.current&&!Ee.current.contains(Fe.target)&&re(!1),X.current&&!X.current.contains(Fe.target)&&L(!1)};return document.addEventListener("mousedown",me),()=>document.removeEventListener("mousedown",me)},[]);const{data:Gn,isLoading:nr,error:er}=at({queryKey:["ha-entities",fe],queryFn:()=>ue.getHAEntities(fe||void 0),enabled:i==="homeassistant"&&ln,retry:!1,staleTime:0}),{data:bn}=at({queryKey:["ha-sensor-entities"],queryFn:ue.getHASensorEntities,enabled:i==="homeassistant"&&ln,retry:!1,staleTime:0});w.useEffect(()=>{const me=Fe=>{Fe.key==="Escape"&&e()};return window.addEventListener("keydown",me),()=>{window.removeEventListener("keydown",me),Kt.current&&clearInterval(Kt.current)}},[e]);const xi=async()=>{yt(!0),vn([]),It({scanned:0,total:0}),$e(null);try{await ue.startTasmotaScan();const me=async()=>{try{const Fe=await ue.getTasmotaScanStatus();It({scanned:Fe.scanned,total:Fe.total});const Oe=await ue.getDiscoveredTasmotaDevices();vn(Oe),Fe.running||(yt(!1),Kt.current&&(clearInterval(Kt.current),Kt.current=null))}catch(Fe){console.error("Polling error:",Fe)}};await me(),Kt.current=setInterval(me,500)}catch(me){yt(!1);const Fe=me instanceof Error?me.message:typeof me=="string"?me:JSON.stringify(me);$e(Fe||"Failed to start scan")}},Ia=async()=>{try{await ue.stopTasmotaScan()}catch{}yt(!1),Kt.current&&(clearInterval(Kt.current),Kt.current=null)},Ae=me=>{u(me.ip_address),l(me.name),De(null)},Xe=mt({mutationFn:()=>ue.testSmartPlugConnection(c,d||null,m||null),onSuccess:me=>{De(me),$e(null),!o&&me.device_name&&l(me.device_name)},onError:me=>{De(null),$e(me.message)}}),Je=mt({mutationFn:me=>ue.createSmartPlug(me),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:me=>{$e(me.message)}}),dt=mt({mutationFn:me=>ue.updateSmartPlug(t.id,me),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:me=>{$e(me.message)}}),st=cr?.filter(me=>!dr?.some(Oe=>Oe.printer_id===me.id&&Oe.id!==t?.id)),jt=me=>{if(me.preventDefault(),$e(null),!o.trim()){$e("Name is required");return}if(i==="tasmota"&&!c.trim()){$e("IP address is required for Tasmota plugs");return}if(i==="homeassistant"&&!x){$e("Entity is required for Home Assistant plugs");return}if(i==="mqtt"){const Oe=y.trim(),je=k.trim(),ht=O.trim();if(!Oe&&!je&&!ht){$e("At least one MQTT topic must be configured for power, energy, or state monitoring");return}}const Fe={name:o.trim(),plug_type:i,ip_address:i==="tasmota"?c.trim():null,ha_entity_id:i==="homeassistant"?x:null,ha_power_entity:i==="homeassistant"&&Y||null,ha_energy_today_entity:i==="homeassistant"&&oe||null,ha_energy_total_entity:i==="homeassistant"&&W||null,mqtt_power_topic:i==="mqtt"&&y.trim()||null,mqtt_power_path:i==="mqtt"&&S.trim()||null,mqtt_power_multiplier:i==="mqtt"&&parseFloat(C)||1,mqtt_energy_topic:i==="mqtt"&&k.trim()||null,mqtt_energy_path:i==="mqtt"&&D.trim()||null,mqtt_energy_multiplier:i==="mqtt"&&parseFloat(R)||1,mqtt_state_topic:i==="mqtt"&&O.trim()||null,mqtt_state_path:i==="mqtt"&&j.trim()||null,mqtt_state_on_value:i==="mqtt"&&$.trim()||null,username:i==="tasmota"&&d.trim()||null,password:i==="tasmota"&&m.trim()||null,printer_id:te,power_alert_enabled:Ze,power_alert_high:ae?parseFloat(ae):null,power_alert_low:Se?parseFloat(Se):null,schedule_enabled:ft,schedule_on_time:tt||null,schedule_off_time:We||null,show_in_switchbar:Ce};r?dt.mutate(Fe):Je.mutate(Fe)},he=Je.isPending||dt.isPending;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:a.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:me=>me.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Smart Plug":"Add Smart Plug"}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:jt,className:"p-6 space-y-4 overflow-y-auto",children:[Le&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:Le}),!r&&a.jsxs("div",{className:"flex gap-2 mb-2",children:[a.jsxs("button",{type:"button",onClick:()=>{s("tasmota"),De(null),$e(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${i==="tasmota"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[a.jsx(el,{className:"w-4 h-4"}),"Tasmota"]}),a.jsxs("button",{type:"button",onClick:()=>{s("homeassistant"),De(null),$e(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${i==="homeassistant"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[a.jsx(mN,{className:"w-4 h-4"}),"HA"]}),a.jsxs("button",{type:"button",onClick:()=>{s("mqtt"),De(null),$e(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${i==="mqtt"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[a.jsx(PD,{className:"w-4 h-4"}),"MQTT"]})]}),!r&&i==="tasmota"&&a.jsxs("div",{className:"space-y-3",children:[Ve?a.jsxs(Ne,{type:"button",variant:"secondary",onClick:Ia,className:"w-full",children:[a.jsx(Dt,{className:"w-4 h-4"}),"Stop Scanning"]}):a.jsxs(Ne,{type:"button",variant:"primary",onClick:xi,className:"w-full",children:[a.jsx(pa,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),Ve&&ut.total>0&&a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray",children:[a.jsx("span",{children:"Scanning network..."}),a.jsxs("span",{children:[ut.scanned," / ",ut.total]})]}),a.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:a.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${ut.scanned/ut.total*100}%`}})})]}),Ft.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",Ft.length," device(s) - click to select:"]}),a.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:Ft.map(me=>a.jsxs("button",{type:"button",onClick:()=>Ae(me),className:"w-full flex items-center justify-between p-2 bg-bambu-dark hover:bg-bambu-dark-tertiary rounded-lg transition-colors text-left border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(el,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:me.name}),a.jsx("p",{className:"text-xs text-bambu-gray",children:me.ip_address})]})]}),me.state&&a.jsxs("span",{className:`flex items-center gap-1 text-xs ${me.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[a.jsx(Vu,{className:"w-3 h-3"}),me.state]})]},me.ip_address))})]}),!Ve&&Ft.length===0&&ut.total>0&&a.jsx("p",{className:"text-xs text-bambu-gray text-center py-2",children:"No Tasmota devices found on your network"})]}),i==="homeassistant"&&a.jsxs("div",{className:"space-y-3",children:[!ln&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:["Home Assistant is not configured. Set it up in"," ",a.jsx("span",{className:"font-medium",children:"Settings → Network → Home Assistant"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1 opacity-50",children:"Select Entity *"}),a.jsx("select",{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 opacity-50",children:a.jsx("option",{children:"Choose an entity..."})})]})]}),ln&&a.jsxs(a.Fragment,{children:[nr&&a.jsxs("div",{className:"flex items-center justify-center py-4 text-bambu-gray",children:[a.jsx(ct,{className:"w-5 h-5 animate-spin mr-2"}),"Loading entities..."]}),er&&a.jsxs("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:["Failed to load entities: ",er.message]}),(()=>{const me=dr?.filter(je=>je.ha_entity_id&&je.id!==t?.id).map(je=>je.ha_entity_id)||[],Fe=(Gn||[]).filter(je=>!me.includes(je.entity_id)),Oe=Gn?.find(je=>je.entity_id===x);return a.jsxs("div",{ref:Pe,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Select Entity *"}),a.jsxs("div",{className:"relative",children:[a.jsx(pa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:ge?ne:Oe?`${Oe.friendly_name} (${Oe.entity_id})`:"",onChange:je=>{ce(je.target.value),ge||xe(!0)},onFocus:()=>{xe(!0),ce("")},placeholder:"Search entities...",className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),x&&!ge&&a.jsx("button",{type:"button",onClick:()=>{b(""),ce("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Dt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),nr&&a.jsx(ct,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray animate-spin"})]}),ge&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-60 overflow-y-auto",children:[nr&&a.jsxs("div",{className:"px-3 py-2 text-sm text-bambu-gray flex items-center gap-2",children:[a.jsx(ct,{className:"w-4 h-4 animate-spin"}),"Loading..."]}),!nr&&Fe.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:fe?`No entities found matching "${fe}"`:"No entities available"}),!nr&&Fe.map(je=>a.jsxs("button",{type:"button",onClick:()=>{b(je.entity_id),xe(!1),ce(""),o||l(je.friendly_name)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary transition-colors ${je.entity_id===x?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:je.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray flex items-center justify-between",children:[a.jsx("span",{children:je.entity_id}),a.jsx("span",{className:je.state==="on"?"text-bambu-green":"",children:je.state})]})]},je.entity_id))]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:fe?`Searching all entities (${Fe.length} found)`:`Showing switch, light, input_boolean (${Fe.length} available)`})]})})(),x&&bn&&bn.length>0&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4 space-y-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium mb-1",children:"Energy Monitoring (Optional)"}),a.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Search and select sensors that provide power/energy data."})]}),(()=>{const me=bn.filter(je=>je.unit_of_measurement==="W"||je.unit_of_measurement==="kW"||je.unit_of_measurement==="mW"),Fe=Ue?me.filter(je=>je.entity_id.toLowerCase().includes(Ue.toLowerCase())||je.friendly_name.toLowerCase().includes(Ue.toLowerCase())):me,Oe=bn.find(je=>je.entity_id===Y);return a.jsxs("div",{ref:K,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Power Sensor (W)"}),a.jsxs("div",{className:"relative",children:[a.jsx(pa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:it?Ue:Oe?`${Oe.friendly_name} (${Oe.state} ${Oe.unit_of_measurement})`:"",onChange:je=>{be(je.target.value),it||U(!0)},onFocus:()=>{U(!0),be("")},placeholder:"Search power sensors...",className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),Y&&!it&&a.jsx("button",{type:"button",onClick:()=>{Z(""),be("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Dt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),it&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[a.jsx("button",{type:"button",onClick:()=>{Z(""),U(!1),be("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Fe.map(je=>a.jsxs("button",{type:"button",onClick:()=>{Z(je.entity_id),U(!1),be("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${je.entity_id===Y?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:je.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[je.entity_id," • ",je.state," ",je.unit_of_measurement]})]},je.entity_id)),Fe.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const me=bn.filter(je=>je.unit_of_measurement==="kWh"||je.unit_of_measurement==="Wh"||je.unit_of_measurement==="MWh"),Fe=J?me.filter(je=>je.entity_id.toLowerCase().includes(J.toLowerCase())||je.friendly_name.toLowerCase().includes(J.toLowerCase())):me,Oe=bn.find(je=>je.entity_id===oe);return a.jsxs("div",{ref:Ee,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy Today (kWh)"}),a.jsxs("div",{className:"relative",children:[a.jsx(pa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:z?J:Oe?`${Oe.friendly_name} (${Oe.state} ${Oe.unit_of_measurement})`:"",onChange:je=>{Q(je.target.value),z||re(!0)},onFocus:()=>{re(!0),Q("")},placeholder:"Search energy sensors...",className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),oe&&!z&&a.jsx("button",{type:"button",onClick:()=>{B(""),Q("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Dt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),z&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[a.jsx("button",{type:"button",onClick:()=>{B(""),re(!1),Q("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Fe.map(je=>a.jsxs("button",{type:"button",onClick:()=>{B(je.entity_id),re(!1),Q("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${je.entity_id===oe?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:je.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[je.entity_id," • ",je.state," ",je.unit_of_measurement]})]},je.entity_id)),Fe.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const me=bn.filter(je=>je.unit_of_measurement==="kWh"||je.unit_of_measurement==="Wh"||je.unit_of_measurement==="MWh"),Fe=_e?me.filter(je=>je.entity_id.toLowerCase().includes(_e.toLowerCase())||je.friendly_name.toLowerCase().includes(_e.toLowerCase())):me,Oe=bn.find(je=>je.entity_id===W);return a.jsxs("div",{ref:X,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Total Energy (kWh)"}),a.jsxs("div",{className:"relative",children:[a.jsx(pa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:V?_e:Oe?`${Oe.friendly_name} (${Oe.state} ${Oe.unit_of_measurement})`:"",onChange:je=>{Te(je.target.value),V||L(!0)},onFocus:()=>{L(!0),Te("")},placeholder:"Search energy sensors...",className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),W&&!V&&a.jsx("button",{type:"button",onClick:()=>{se(""),Te("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Dt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),V&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[a.jsx("button",{type:"button",onClick:()=>{se(""),L(!1),Te("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Fe.map(je=>a.jsxs("button",{type:"button",onClick:()=>{se(je.entity_id),L(!1),Te("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${je.entity_id===W?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:je.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[je.entity_id," • ",je.state," ",je.unit_of_measurement]})]},je.entity_id)),Fe.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})()]})]})]}),i==="mqtt"&&a.jsxs("div",{className:"space-y-3",children:[!Jn?.mqtt_broker&&a.jsxs("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:["MQTT broker not configured. Set broker address in"," ",a.jsx("span",{className:"font-medium",children:"Settings → Network → MQTT Publishing"})," ","(you don't need to enable publishing, just fill in the broker details)."]}),Jn?.mqtt_broker&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg text-sm text-blue-300",children:[a.jsx("p",{className:"font-medium mb-1",children:"Monitor Only"}),a.jsx("p",{className:"text-xs opacity-80",children:"MQTT plugs receive power/energy data via MQTT subscription. On/off control is not available - use your MQTT broker or home automation system."})]}),a.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-white font-medium text-sm",children:"Power Monitoring"}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),a.jsx("input",{type:"text",value:y,onChange:me=>v(me.target.value),placeholder:"zigbee2mqtt/shelly-working-room",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),a.jsx("input",{type:"text",value:S,onChange:me=>N(me.target.value),placeholder:"power_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Multiplier"}),a.jsx("input",{type:"text",value:C,onChange:me=>T(me.target.value),placeholder:"1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:['JSON path extracts value from JSON payload (e.g., "power_l1"). Leave empty if topic publishes raw numeric values.',a.jsx("br",{}),"Use multiplier 0.001 for mW→W, 1000 for kW→W."]})]}),a.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("p",{className:"text-white font-medium text-sm",children:["Energy Monitoring ",a.jsx("span",{className:"text-bambu-gray font-normal",children:"(optional)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),a.jsx("input",{type:"text",value:k,onChange:me=>E(me.target.value),placeholder:"Same as power topic, or different",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),a.jsx("input",{type:"text",value:D,onChange:me=>A(me.target.value),placeholder:"energy_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Multiplier"}),a.jsx("input",{type:"text",value:R,onChange:me=>F(me.target.value),placeholder:"1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:["JSON path extracts value from JSON payload. Leave empty for raw values.",a.jsx("br",{}),"Use multiplier 0.001 for Wh→kWh, 1000 for MWh→kWh."]})]}),a.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("p",{className:"text-white font-medium text-sm",children:["State Monitoring ",a.jsx("span",{className:"text-bambu-gray font-normal",children:"(optional)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),a.jsx("input",{type:"text",value:O,onChange:me=>H(me.target.value),placeholder:"Same as power topic, or different",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),a.jsx("input",{type:"text",value:j,onChange:me=>G(me.target.value),placeholder:"state_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"ON Value"}),a.jsx("input",{type:"text",value:$,onChange:me=>q(me.target.value),placeholder:"ON, true, 1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:["JSON path extracts value from JSON payload. Leave empty for raw values.",a.jsx("br",{}),'ON value: the exact string that means "ON". Leave empty for auto-detect (ON, true, 1).']})]})]})]}),i==="tasmota"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",value:c,onChange:me=>{u(me.target.value),De(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"}),a.jsxs(Ne,{type:"button",variant:"secondary",onClick:()=>Xe.mutate(),disabled:!c.trim()||Xe.isPending,children:[Xe.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(Sg,{className:"w-4 h-4"}),"Test"]})]})]}),i==="tasmota"&&ie&&a.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${ie.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:ie.success?a.jsxs(a.Fragment,{children:[a.jsx(Tr,{className:"w-5 h-5"}),a.jsxs("div",{children:[a.jsx("p",{className:"font-medium",children:"Connected!"}),a.jsxs("p",{className:"text-sm opacity-80",children:[ie.device_name&&`Device: ${ie.device_name} - `,"State: ",ie.state]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx(sm,{className:"w-5 h-5"}),a.jsx("span",{children:"Connection failed"})]})}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),a.jsx("input",{type:"text",value:o,onChange:me=>l(me.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"})]}),i==="tasmota"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),a.jsx("input",{type:"text",value:d,onChange:me=>f(me.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),a.jsx("input",{type:"password",value:m,onChange:me=>p(me.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"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"})]}),i!=="mqtt"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),a.jsxs("select",{value:te??"",onChange:me=>Me(me.target.value?Number(me.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:[a.jsx("option",{value:"",children:"No printer (manual control only)"}),st?.map(me=>a.jsx("option",{value:me.id,children:me.name},me.id))]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(_g,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-white font-medium",children:"Power Alerts"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:Ze,onChange:me=>Ie(me.target.checked),className:"sr-only peer"}),a.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"})]})]}),Ze&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if above (W)"}),a.jsx("input",{type:"number",value:ae,onChange:me=>He(me.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if below (W)"}),a.jsx("input",{type:"number",value:Se,onChange:me=>Be(me.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"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Get notified when power consumption crosses these thresholds. Leave empty to disable that direction."})]})]}),i!=="mqtt"&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Qn,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-white font-medium",children:"Daily Schedule"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:ft,onChange:me=>we(me.target.checked),className:"sr-only peer"}),a.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"})]})]}),ft&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn On at"}),a.jsx("input",{type:"time",value:tt,onChange:me=>ke(me.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn Off at"}),a.jsx("input",{type:"time",value:We,onChange:me=>pe(me.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"})]})]}),a.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."})]})]}),a.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(pN,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white font-medium",children:"Show in Switchbar"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:Ce,onChange:me=>de(me.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Ne,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Ne,{type:"submit",disabled:he,className:"flex-1",children:[he?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(ms,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function On({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return a.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:a.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 gKe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function xKe({provider:t,onEdit:e}){const n=on(),[r,i]=w.useState(!1),[s,o]=w.useState(!1),[l,c]=w.useState(null),{data:u}=at({queryKey:["printers"],queryFn:ue.getPrinters}),d=u?.find(b=>b.id===t.printer_id),f=mt({mutationFn:b=>ue.updateNotificationProvider(t.id,b),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=mt({mutationFn:()=>ue.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=mt({mutationFn:()=>ue.testNotificationProvider(t.id),onSuccess:b=>{c(b),n.invalidateQueries({queryKey:["notification-providers"]})},onError:b=>{c({success:!1,message:b.message})}}),x=b=>b||"";return a.jsxs(a.Fragment,{children:[a.jsx(wt,{className:"relative",children:a.jsxs(St,{className:"p-4",children:[a.jsxs("div",{className:"flex items-start justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:a.jsx(_g,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium text-white",children:t.name}),a.jsx("p",{className:"text-sm text-bambu-gray",children:gKe[t.provider_type]||t.provider_type})]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[t.last_success&&a.jsxs("span",{className:"text-xs text-status-ok hidden sm:inline",children:["Last: ",Bg(t.last_success)]}),t.last_error&&t.last_error_at&&(!t.last_success||(Ri(t.last_error_at)?.getTime()||0)>(Ri(t.last_success)?.getTime()||0))&&a.jsx("span",{className:"text-xs text-status-error",title:t.last_error,children:"Error"}),a.jsx(On,{checked:t.enabled,onChange:b=>f.mutate({enabled:b})})]})]}),d&&a.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),a.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&a.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:a.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),a.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&a.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_plate_not_empty&&a.jsx("span",{className:"px-2 py-0.5 bg-rose-600/20 text-rose-300 text-xs rounded",children:"Plate Check"}),t.on_print_complete&&a.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&a.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&a.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&a.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&a.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&a.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&a.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&&a.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.on_ams_humidity_high&&a.jsx("span",{className:"px-2 py-0.5 bg-blue-600/20 text-blue-300 text-xs rounded",children:"AMS Humidity"}),t.on_ams_temperature_high&&a.jsx("span",{className:"px-2 py-0.5 bg-orange-600/20 text-orange-300 text-xs rounded",children:"AMS Temp"}),t.on_ams_ht_humidity_high&&a.jsx("span",{className:"px-2 py-0.5 bg-cyan-600/20 text-cyan-300 text-xs rounded",children:"AMS-HT Humidity"}),t.on_ams_ht_temperature_high&&a.jsx("span",{className:"px-2 py-0.5 bg-amber-600/20 text-amber-300 text-xs rounded",children:"AMS-HT Temp"}),t.quiet_hours_enabled&&a.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[a.jsx(K1,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&a.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[a.jsx(ti,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),a.jsx("div",{className:"mb-3",children:a.jsxs(Ne,{size:"sm",variant:"secondary",disabled:p.isPending,onClick:()=>{c(null),p.mutate()},className:"w-full",children:[p.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(RD,{className:"w-4 h-4"}),"Send Test Notification"]})}),l&&a.jsxs("div",{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${l.success?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[l.success?a.jsx(Tr,{className:"w-4 h-4"}):a.jsx(qi,{className:"w-4 h-4"}),a.jsx("span",{children:l.message})]}),a.jsxs("button",{onClick:()=>o(!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:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx(bh,{className:"w-4 h-4"}),"Event Settings"]}),s?a.jsx(xh,{className:"w-4 h-4"}):a.jsx(Xr,{className:"w-4 h-4"})]}),s&&a.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Enabled"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),a.jsx(On,{checked:t.enabled,onChange:b=>f.mutate({enabled:b})})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Started"}),a.jsx(On,{checked:t.on_print_start,onChange:b=>f.mutate({on_print_start:b})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Plate Not Empty"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Objects detected before print"})]}),a.jsx(On,{checked:t.on_plate_not_empty??!0,onChange:b=>f.mutate({on_plate_not_empty:b})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),a.jsx(On,{checked:t.on_print_complete,onChange:b=>f.mutate({on_print_complete:b})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),a.jsx(On,{checked:t.on_print_failed,onChange:b=>f.mutate({on_print_failed:b})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),a.jsx(On,{checked:t.on_print_stopped,onChange:b=>f.mutate({on_print_stopped:b})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),a.jsx(On,{checked:t.on_print_progress,onChange:b=>f.mutate({on_print_progress:b})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),a.jsx(On,{checked:t.on_printer_offline,onChange:b=>f.mutate({on_printer_offline:b})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),a.jsx(On,{checked:t.on_printer_error,onChange:b=>f.mutate({on_printer_error:b})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),a.jsx(On,{checked:t.on_filament_low,onChange:b=>f.mutate({on_filament_low:b})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),a.jsx(On,{checked:t.on_maintenance_due??!1,onChange:b=>f.mutate({on_maintenance_due:b})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS Alarms"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS Humidity High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS humidity exceeds threshold"})]}),a.jsx(On,{checked:t.on_ams_humidity_high??!1,onChange:b=>f.mutate({on_ams_humidity_high:b})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS Temperature High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS temperature exceeds threshold"})]}),a.jsx(On,{checked:t.on_ams_temperature_high??!1,onChange:b=>f.mutate({on_ams_temperature_high:b})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS-HT Alarms"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS-HT Humidity High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT humidity exceeds threshold"})]}),a.jsx(On,{checked:t.on_ams_ht_humidity_high??!1,onChange:b=>f.mutate({on_ams_ht_humidity_high:b})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS-HT Temperature High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT temperature exceeds threshold"})]}),a.jsx(On,{checked:t.on_ams_ht_temperature_high??!1,onChange:b=>f.mutate({on_ams_ht_temperature_high:b})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Queue"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Added"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job added to queue"})]}),a.jsx(On,{checked:t.on_queue_job_added??!1,onChange:b=>f.mutate({on_queue_job_added:b})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Assigned"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Model-based job assigned to printer"})]}),a.jsx(On,{checked:t.on_queue_job_assigned??!1,onChange:b=>f.mutate({on_queue_job_assigned:b})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Started"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Queue job started printing"})]}),a.jsx(On,{checked:t.on_queue_job_started??!1,onChange:b=>f.mutate({on_queue_job_started:b})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Waiting"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job waiting for filament"})]}),a.jsx(On,{checked:t.on_queue_job_waiting??!0,onChange:b=>f.mutate({on_queue_job_waiting:b})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Skipped"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job skipped (previous failed)"})]}),a.jsx(On,{checked:t.on_queue_job_skipped??!0,onChange:b=>f.mutate({on_queue_job_skipped:b})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Failed"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job failed to start"})]}),a.jsx(On,{checked:t.on_queue_job_failed??!0,onChange:b=>f.mutate({on_queue_job_failed:b})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Queue Complete"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"All queue jobs finished"})]}),a.jsx(On,{checked:t.on_queue_completed??!1,onChange:b=>f.mutate({on_queue_completed:b})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(K1,{className:"w-4 h-4 text-purple-400"}),a.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),a.jsx(On,{checked:t.quiet_hours_enabled,onChange:b=>f.mutate({quiet_hours_enabled:b})})]}),t.quiet_hours_enabled&&a.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Qn,{className:"w-4 h-4 text-bambu-gray"}),a.jsxs("span",{className:"text-sm text-white",children:[x(t.quiet_hours_start)||"22:00"," - ",x(t.quiet_hours_end)||"07:00"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ti,{className:"w-4 h-4 text-emerald-400"}),a.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),a.jsx(On,{checked:t.daily_digest_enabled,onChange:b=>f.mutate({daily_digest_enabled:b})})]}),t.daily_digest_enabled&&a.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Qn,{className:"w-4 h-4 text-bambu-gray"}),a.jsxs("span",{className:"text-sm text-white",children:["Send at ",x(t.daily_digest_time)||"08:00"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),a.jsxs("div",{className:"flex gap-2 pt-2",children:[a.jsxs(Ne,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[a.jsx(hg,{className:"w-4 h-4"}),"Edit"]}),a.jsx(Ne,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:a.jsx(an,{className:"w-4 h-4"})})]})]})]})}),r&&a.jsx(Yn,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{m.mutate(),i(!1)},onCancel:()=>i(!1)})]})}const xq=[{value:"email",label:"Email",description:"SMTP email notifications"},{value:"telegram",label:"Telegram",description:"Notifications via Telegram bot"},{value:"discord",label:"Discord",description:"Send to Discord channel via webhook"},{value:"ntfy",label:"ntfy",description:"Free, self-hostable push notifications"},{value:"pushover",label:"Pushover",description:"Simple, reliable push notifications"},{value:"callmebot",label:"CallMeBot/WhatsApp",description:"Free WhatsApp notifications via CallMeBot"},{value:"webhook",label:"Webhook",description:"Generic HTTP POST to any URL"}];function bKe({provider:t,onClose:e}){const n=on(),r=!!t,[i,s]=w.useState(t?.name||""),[o,l]=w.useState(t?.provider_type||"email"),[c,u]=w.useState(t?.printer_id||null),[d,f]=w.useState(t?.quiet_hours_enabled||!1),[m,p]=w.useState(t?.quiet_hours_start||"22:00"),[x,b]=w.useState(t?.quiet_hours_end||"07:00"),[y,v]=w.useState(t?.daily_digest_enabled||!1),[S,N]=w.useState(t?.daily_digest_time||"08:00"),[C,T]=w.useState(t?.on_print_start??!1),[k,E]=w.useState(t?.on_print_complete??!0),[D,A]=w.useState(t?.on_print_failed??!0),[R,F]=w.useState(t?.on_print_stopped??!0),[O,H]=w.useState(t?.on_print_progress??!1),[j,G]=w.useState(t?.on_printer_offline??!1),[$,q]=w.useState(t?.on_printer_error??!1),[Y,Z]=w.useState(t?.on_filament_low??!1),[oe,B]=w.useState(t?.on_maintenance_due??!1),[W,se]=w.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([Q,z])=>[Q,String(z)])):{}),[ne,ce]=w.useState(null),[fe,ye]=w.useState(null),{data:ge}=at({queryKey:["printers"],queryFn:ue.getPrinters});w.useEffect(()=>{const Q=z=>{z.key==="Escape"&&e()};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[e]);const xe=mt({mutationFn:()=>ue.testNotificationConfig({provider_type:o,config:W}),onSuccess:Q=>{ce(Q),ye(null)},onError:Q=>{ce({success:!1,message:Q.message})}}),Pe=mt({mutationFn:Q=>ue.createNotificationProvider(Q),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:Q=>{ye(Q.message)}}),Ue=mt({mutationFn:Q=>ue.updateNotificationProvider(t.id,Q),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:Q=>{ye(Q.message)}}),be=Q=>{if(Q.preventDefault(),ye(null),!i.trim()){ye("Name is required");return}const z=K(o);for(const Ee of z)if(!W[Ee.key]?.trim()){ye(`${Ee.label} is required`);return}const re={name:i.trim(),provider_type:o,config:W,printer_id:c,quiet_hours_enabled:d,quiet_hours_start:d?m:null,quiet_hours_end:d?x:null,daily_digest_enabled:y,daily_digest_time:y?S:null,on_print_start:C,on_print_complete:k,on_print_failed:D,on_print_stopped:R,on_print_progress:O,on_printer_offline:j,on_printer_error:$,on_filament_low:Y,on_maintenance_due:oe};r?Ue.mutate(re):Pe.mutate(re)},it=Pe.isPending||Ue.isPending,U=Q=>{switch(Q){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:"payload_format",label:"Payload Format",type:"select",required:!1,options:[{value:"generic",label:"Generic JSON"},{value:"slack",label:"Slack / Mattermost"}]},{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,showIf:z=>z.payload_format!=="slack"},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1,showIf:z=>z.payload_format!=="slack"}];default:return[]}},K=Q=>U(Q).filter(z=>z.required),J=U(o);return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8 max-h-[90vh] overflow-y-auto",onClick:Q=>Q.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:be,className:"p-6 space-y-4",children:[fe&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:fe}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),a.jsx("input",{type:"text",value:i,onChange:Q=>s(Q.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),a.jsx("select",{value:o,onChange:Q=>{l(Q.target.value),se({}),ce(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:xq.map(Q=>a.jsx("option",{value:Q.value,children:Q.label},Q.value))}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:xq.find(Q=>Q.value===o)?.description})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),J.filter(Q=>!("showIf"in Q)||Q.showIf?.(W)!==!1).map(Q=>a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[Q.label," ",Q.required&&"*"]}),Q.type==="select"&&"options"in Q&&Q.options?a.jsx("select",{value:W[Q.key]||Q.options[0]?.value||"",onChange:z=>{se({...W,[Q.key]:z.target.value}),ce(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:Q.options.map(z=>a.jsx("option",{value:z.value,children:z.label},z.value))}):a.jsx("input",{type:Q.type,value:W[Q.key]||"",onChange:z=>{se({...W,[Q.key]:z.target.value}),ce(null)},placeholder:Q.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"})]},Q.key))]}),a.jsx("div",{className:"flex gap-2",children:a.jsxs(Ne,{type:"button",variant:"secondary",onClick:()=>{ce(null),xe.mutate()},disabled:xe.isPending||!W[K(o)[0]?.key],className:"flex-1",children:[xe.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(RD,{className:"w-4 h-4"}),"Test Configuration"]})}),ne&&a.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${ne.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:ne.success?a.jsxs(a.Fragment,{children:[a.jsx(Tr,{className:"w-5 h-5"}),a.jsx("span",{children:ne.message})]}):a.jsxs(a.Fragment,{children:[a.jsx(qi,{className:"w-5 h-5"}),a.jsx("span",{children:ne.message})]})}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),a.jsxs("select",{value:c??"",onChange:Q=>u(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:[a.jsx("option",{value:"",children:"All printers"}),ge?.map(Q=>a.jsx("option",{value:Q.id,children:Q.name},Q.id))]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),a.jsx(On,{checked:d,onChange:f})]}),d&&a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),a.jsx("input",{type:"time",value:m,onChange:Q=>p(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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),a.jsx("input",{type:"time",value:x,onChange:Q=>b(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"})]})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),a.jsx(On,{checked:y,onChange:v})]}),y&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),a.jsx("input",{type:"time",value:S,onChange:Q=>N(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"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),a.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Start"}),a.jsx(On,{checked:C,onChange:T})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Complete"}),a.jsx(On,{checked:k,onChange:E})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Failed"}),a.jsx(On,{checked:D,onChange:A})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Stopped"}),a.jsx(On,{checked:R,onChange:F})]}),a.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-white",children:"Progress"}),a.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),a.jsx(On,{checked:O,onChange:H})]})]})]}),a.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Offline"}),a.jsx(On,{checked:j,onChange:G})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Error"}),a.jsx(On,{checked:$,onChange:q})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),a.jsx(On,{checked:Y,onChange:Z})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),a.jsx(On,{checked:oe,onChange:B})]})]})]})]}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Ne,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Ne,{type:"submit",disabled:it,className:"flex-1",children:[it?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(ms,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function yKe({template:t,onClose:e}){const n=on(),r=w.useRef(null),[i,s]=w.useState(t.title_template),[o,l]=w.useState(t.body_template),[c,u]=w.useState(null),[d,f]=w.useState(!0),{data:m}=at({queryKey:["template-variables"],queryFn:ue.getTemplateVariables}),p=m?.find(T=>T.event_type===t.event_type),{data:x,isLoading:b}=at({queryKey:["template-preview",t.event_type,i,o],queryFn:()=>ue.previewTemplate({event_type:t.event_type,title_template:i,body_template:o}),enabled:d&&i.length>0&&o.length>0});w.useEffect(()=>{const T=k=>{k.key==="Escape"&&e()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[e]);const y=mt({mutationFn:T=>ue.updateNotificationTemplate(t.id,T),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:T=>{u(T.message)}}),v=mt({mutationFn:()=>ue.resetNotificationTemplate(t.id),onSuccess:T=>{s(T.title_template),l(T.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:T=>{u(T.message)}}),S=T=>{if(T.preventDefault(),u(null),!i.trim()){u("Title is required");return}if(!o.trim()){u("Body is required");return}y.mutate({title_template:i,body_template:o})},N=T=>{const k=r.current;if(!k)return;const E=k.selectionStart,D=k.selectionEnd,A=o,R=A.substring(0,E),F=A.substring(D),O=R+`{${T}}`+F;l(O),setTimeout(()=>{k.focus();const H=E+T.length+2;k.setSelectionRange(H,H)},0)},C=i!==t.title_template||o!==t.body_template;return a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:a.jsx(Dt,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("form",{onSubmit:S,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[c&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:c}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),a.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..."})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),a.jsx("textarea",{ref:r,value:o,onChange:T=>l(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..."})]}),p&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:p.variables.map(T=>a.jsxs("button",{type:"button",onClick:()=>N(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:[a.jsx(lr,{className:"w-3 h-3"}),T]},T))}),a.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[a.jsx(Ru,{className:"w-4 h-4"}),"Live Preview"]}),a.jsx("button",{type:"button",onClick:()=>f(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&a.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:b?a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[a.jsx(ct,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):x?a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),a.jsx("div",{className:"text-white font-medium",children:x.title})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),a.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:x.body})]})]}):a.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),a.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[a.jsxs(Ne,{type:"button",variant:"ghost",onClick:()=>v.mutate(),disabled:v.isPending,className:"text-orange-400 hover:text-orange-300",children:[v.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(Dh,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ne,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),a.jsxs(Ne,{onClick:S,disabled:y.isPending||!C,children:[y.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(ms,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const vKe={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"},_Ke={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 wKe({onClose:t}){const e=on(),{showToast:n}=Vn(),[r,i]=w.useState(7),[s,o]=w.useState(null),[l,c]=w.useState(!1),{data:u}=at({queryKey:["settings"],queryFn:ue.getSettings}),d=u?.time_format||"system",{data:f,isLoading:m,refetch:p,isRefetching:x}=at({queryKey:["notification-logs",r,l],queryFn:()=>ue.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:b}=at({queryKey:["notification-log-stats",r],queryFn:()=>ue.getNotificationLogStats(r)}),y=mt({mutationFn:()=>ue.clearNotificationLogs(30),onSuccess:S=>{n(S.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:S=>{n(`Failed to clear logs: ${S.message}`,"error")}}),v=S=>{const N=Ri(S);if(!N)return"";const T=new Date().getTime()-N.getTime();return T<6e4?"Just now":T<36e5?`${Math.floor(T/6e4)}m ago`:T<864e5?`${Math.floor(T/36e5)}h ago`:N.toLocaleDateString()+" "+Ufe(N,d)};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.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:[a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(q0,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),b&&a.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:a.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[a.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",a.jsx("span",{className:"text-white font-medium",children:b.total})," notifications"]}),a.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[a.jsx(Tr,{className:"w-4 h-4"}),b.success_count," sent"]}),b.failure_count>0&&a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(qi,{className:"w-4 h-4"}),b.failure_count," failed"]})]})}),a.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[a.jsxs("select",{value:r,onChange:S=>i(Number(S.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:[a.jsx("option",{value:1,children:"Last 24 hours"}),a.jsx("option",{value:7,children:"Last 7 days"}),a.jsx("option",{value:30,children:"Last 30 days"}),a.jsx("option",{value:90,children:"Last 90 days"})]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:l,onChange:S=>c(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Show failed only"]}),a.jsx("div",{className:"flex-1"}),a.jsxs(Ne,{size:"sm",variant:"secondary",onClick:()=>p(),disabled:x,children:[x?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(Pr,{className:"w-4 h-4"}),"Refresh"]}),a.jsxs(Ne,{size:"sm",variant:"secondary",onClick:()=>y.mutate(),disabled:y.isPending,className:"text-red-400 hover:text-red-300",children:[y.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(an,{className:"w-4 h-4"}),"Clear Old"]})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:m?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(ct,{className:"w-6 h-6 text-bambu-green animate-spin"})}):f&&f.length>0?a.jsx("div",{className:"space-y-2",children:f.map(S=>a.jsx(SKe,{log:S,isExpanded:s===S.id,onToggle:()=>o(s===S.id?null:S.id),formatDate:v,formatFullDate:N=>$g(N,d)},S.id))}):a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(q0,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{className:"text-sm",children:l?"No failed notifications":"No notifications logged"})]})})]})})}function SKe({log:t,isExpanded:e,onToggle:n,formatDate:r,formatFullDate:i}){return a.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:[a.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?a.jsx(Tr,{className:"w-4 h-4 text-bambu-green shrink-0"}):a.jsx(qi,{className:"w-4 h-4 text-red-400 shrink-0"}),a.jsx("span",{className:`text-xs font-medium ${_Ke[t.event_type]||"text-bambu-gray"}`,children:vKe[t.event_type]||t.event_type}),a.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||"Unknown Provider"}),t.printer_name&&a.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),a.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?a.jsx(xh,{className:"w-4 h-4 text-bambu-gray shrink-0"}):a.jsx(Xr,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&a.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),a.jsx("p",{className:"text-sm text-white",children:t.title})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),a.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),a.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),a.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[a.jsxs("span",{children:["Provider: ",t.provider_type]}),a.jsxs("span",{children:["Time: ",i(t.created_at)]})]})]})]})}async function NKe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function MKe(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 EKe(){const t=on(),[e,n]=w.useState(!1),[r,i]=w.useState(""),[s,o]=w.useState("auto"),[l,c]=w.useState(!1),[u,d]=w.useState("all"),[f,m]=w.useState(!1),[p,x]=w.useState(!1),{data:b,isLoading:y}=at({queryKey:["spoolman-settings"],queryFn:NKe}),{data:v,isLoading:S,refetch:N}=at({queryKey:["spoolman-status"],queryFn:ue.getSpoolmanStatus,refetchInterval:3e4}),{data:C}=at({queryKey:["printers"],queryFn:ue.getPrinters});w.useEffect(()=>{b&&(n(b.spoolman_enabled==="true"),i(b.spoolman_url||""),o(b.spoolman_sync_mode||"auto"),m(!0))},[b]),w.useEffect(()=>{if(!f||!b)return;if(b.spoolman_enabled==="true"!==e||(b.spoolman_url||"")!==r||(b.spoolman_sync_mode||"auto")!==s){const G=setTimeout(()=>{T.mutate()},500);return()=>clearTimeout(G)}},[e,r,s,f]);const T=mt({mutationFn:()=>MKe({spoolman_enabled:e?"true":"false",spoolman_url:r,spoolman_sync_mode:s}),onSuccess:()=>{t.invalidateQueries({queryKey:["spoolman-settings"]}),t.invalidateQueries({queryKey:["spoolman-status"]}),c(!0),setTimeout(()=>c(!1),2e3)}}),k=mt({mutationFn:ue.connectSpoolman,onSuccess:()=>{N()}}),E=mt({mutationFn:ue.disconnectSpoolman,onSuccess:()=>{N()}}),D=mt({mutationFn:ue.syncAllPrintersAms,onSuccess:j=>{j.success}}),A=mt({mutationFn:j=>ue.syncPrinterAms(j),onSuccess:j=>{j.success}}),R=()=>{u==="all"?D.mutate():A.mutate(u)},F=D.isPending||A.isPending,O=u==="all"?D.data:A.data,H=u==="all"?D.isSuccess:A.isSuccess;return y?a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Nu,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),a.jsx(St,{children:a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(ct,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Nu,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),T.isPending&&a.jsx(ct,{className:"w-4 h-4 text-bambu-green animate-spin"}),l&&a.jsx(Wi,{className:"w-4 h-4 text-bambu-green"})]})}),a.jsxs(St,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),a.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Qo,{className:"w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"text-xs text-blue-300",children:[a.jsx("p",{className:"font-medium mb-1",children:"How Sync Works"}),a.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-blue-300/80",children:[a.jsx("li",{children:"Only official Bambu Lab spools with RFID are synced"}),a.jsx("li",{children:"New spools are auto-created in Spoolman on first sync"}),a.jsx("li",{children:"Non-Bambu Lab spools (third-party, refilled) are skipped"})]}),a.jsx("p",{className:"font-medium mt-2 mb-1",children:"Linking Existing Spools"}),a.jsx("p",{className:"text-blue-300/80",children:'To link existing Spoolman spools to your AMS, hover over an AMS slot and click "Link to Spoolman".'})]})]})}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Enable Spoolman"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:e,onChange:j=>n(j.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),a.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:r,onChange:j=>i(j.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none disabled:opacity-50"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),a.jsxs("select",{value:s,onChange:j=>o(j.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:[a.jsx("option",{value:"auto",children:"Automatic"}),a.jsx("option",{value:"manual",children:"Manual Only"})]}),a.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&&a.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),S?a.jsx(ct,{className:"w-4 h-4 text-bambu-gray animate-spin"}):v?.connected?a.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[a.jsx(Wi,{className:"w-4 h-4"}),"Connected"]}):a.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[a.jsx(Dt,{className:"w-4 h-4"}),"Disconnected"]})]}),a.jsx("div",{className:"flex gap-2",children:v?.connected?a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>E.mutate(),disabled:E.isPending,children:[E.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(wde,{className:"w-4 h-4"}),"Disconnect"]}):a.jsxs(Ne,{size:"sm",onClick:()=>k.mutate(),disabled:k.isPending||!r,children:[k.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(dc,{className:"w-4 h-4"}),"Connect"]})})]}),k.isError&&a.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:k.error.message}),v?.connected&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsxs("select",{value:u,onChange:j=>d(j.target.value==="all"?"all":Number(j.target.value)),className:"w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[a.jsx("option",{value:"all",children:"All Printers"}),C?.map(j=>a.jsx("option",{value:j.id,children:j.name},j.id))]}),a.jsx(Xr,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:R,disabled:F,children:[F?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(Pr,{className:"w-4 h-4"}),"Sync"]})]})]}),H&&O&&a.jsxs("div",{className:"mt-3 space-y-2",children:[a.jsx("div",{className:`p-2 rounded text-sm ${O.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:O.success?`Synced ${O.synced_count} spool${O.synced_count!==1?"s":""} successfully`:`Synced ${O.synced_count} spool${O.synced_count!==1?"s":""} with ${O.errors.length} error${O.errors.length!==1?"s":""}`}),O.skipped_count>0&&a.jsxs("div",{className:"p-2 bg-amber-500/10 border border-amber-500/30 rounded text-sm",children:[a.jsxs("div",{className:"flex items-center justify-between text-amber-400 mb-1",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(jn,{className:"w-3.5 h-3.5"}),a.jsxs("span",{className:"font-medium",children:[O.skipped_count," spool",O.skipped_count!==1?"s":""," skipped"]})]}),O.skipped_count>5&&a.jsx("button",{onClick:()=>x(!p),className:"text-xs text-amber-400 hover:text-amber-300 underline",children:p?"Show less":"Show all"})]}),a.jsxs("ul",{className:"text-xs text-amber-300/80 space-y-0.5",children:[(p?O.skipped:O.skipped.slice(0,5)).map((j,G)=>a.jsxs("li",{className:"flex items-center gap-2",children:[j.color&&a.jsx("span",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:`#${j.color}`}}),a.jsx("span",{children:j.location}),a.jsxs("span",{className:"text-amber-300/60",children:["- ",j.reason]})]},G)),!p&&O.skipped_count>5&&a.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",O.skipped_count-5," more"]})]})]}),O.errors.length>0&&a.jsxs("div",{className:"p-2 bg-red-500/10 border border-red-500/30 rounded text-sm",children:[a.jsx("div",{className:"text-red-400 font-medium mb-1",children:"Errors:"}),a.jsx("ul",{className:"text-xs text-red-300/80 space-y-0.5",children:O.errors.map((j,G)=>a.jsx("li",{children:j},G))})]})]})]})]})]})}function CKe({link:t,onClose:e}){const n=on(),{mode:r}=Oh(),i=!!t,s=w.useRef(null),[o,l]=w.useState(t?.name||""),[c,u]=w.useState(t?.url||""),[d,f]=w.useState(t?.icon||"link"),[m,p]=w.useState(!!t?.custom_icon),[x,b]=w.useState(t?.custom_icon?ue.getExternalLinkIconUrl(t.id):null),[y,v]=w.useState(null),[S,N]=w.useState(null);w.useEffect(()=>{const F=O=>{O.key==="Escape"&&e()};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[e]);const C=mt({mutationFn:async F=>{const O=await ue.createExternalLink(F);return y?await ue.uploadExternalLinkIcon(O.id,y):O},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:F=>{N(F.message)}}),T=mt({mutationFn:async F=>{let O=await ue.updateExternalLink(t.id,F);return y?O=await ue.uploadExternalLinkIcon(t.id,y):!m&&t?.custom_icon&&(O=await ue.deleteExternalLinkIcon(t.id)),O},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:F=>{N(F.message)}}),k=F=>{const O=F.target.files?.[0];if(O){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(O.type)){N("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(O.size>1024*1024){N("Image file must be less than 1MB");return}v(O),p(!0);const j=new FileReader;j.onload=G=>{b(G.target?.result)},j.readAsDataURL(O)}},E=()=>{v(null),b(null),p(!1),s.current&&(s.current.value="")},D=F=>{if(F.preventDefault(),N(null),!o.trim()){N("Name is required");return}if(!c.trim()){N("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){N("URL must start with http:// or https://");return}const O={name:o.trim(),url:c.trim(),icon:d};i?T.mutate(O):C.mutate(O)},A=C.isPending||T.isPending,R=vN(d);return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:F=>F.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:m&&x?a.jsx("img",{src:x,alt:"",className:`w-5 h-5 rounded ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):a.jsx(R,{className:"w-5 h-5"})}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Link":"Add External Link"})]}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:D,className:"p-6 space-y-4",children:[S&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:S}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),a.jsx("input",{type:"text",value:o,onChange:F=>l(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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"URL *"}),a.jsx("input",{type:"text",value:c,onChange:F=>u(F.target.value),placeholder:"https://example.com",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("label",{className:"block text-sm text-bambu-gray",children:"Icon"}),a.jsxs("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm text-white",children:"Custom Icon"}),a.jsx("input",{ref:s,type:"file",accept:"image/png,image/jpeg,image/gif,image/svg+xml,image/webp,image/x-icon",className:"hidden",onChange:k}),m&&x?a.jsxs("div",{className:"flex items-center gap-2",children:[a.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"}`}),a.jsx("button",{type:"button",onClick:E,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:a.jsx(an,{className:"w-4 h-4"})})]}):a.jsxs(Ne,{type:"button",variant:"secondary",size:"sm",onClick:()=>s.current?.click(),children:[a.jsx(Oa,{className:"w-4 h-4"}),"Upload"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"PNG, JPG, GIF, SVG, WebP, or ICO. Max 1MB."})]}),!m&&a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),a.jsx(kfe,{value:d,onChange:f})]})]}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Ne,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Ne,{type:"submit",disabled:A,className:"flex-1",children:[A?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(ms,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function TKe(){const t=on(),[e,n]=w.useState(!1),[r,i]=w.useState(null),[s,o]=w.useState(null),[l,c]=w.useState(null),{data:u,isLoading:d}=at({queryKey:["external-links"],queryFn:ue.getExternalLinks}),f=mt({mutationFn:S=>ue.deleteExternalLink(S),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),m=mt({mutationFn:S=>ue.reorderExternalLinks(S),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),p=(S,N)=>{c(N),S.dataTransfer.effectAllowed="move"},x=S=>{S.preventDefault(),S.dataTransfer.dropEffect="move"},b=(S,N)=>{if(S.preventDefault(),l===null||l===N||!u)return;const C=u.map(D=>D.id),T=C.indexOf(l),k=C.indexOf(N);if(T===-1||k===-1)return;const E=[...C];E.splice(T,1),E.splice(k,0,l),m.mutate(E),c(null)},y=S=>{o(S)},v=()=>{s&&(f.mutate(s.id),o(null))};return a.jsxs(a.Fragment,{children:[a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(dc,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),a.jsxs(Ne,{size:"sm",onClick:()=>n(!0),children:[a.jsx(lr,{className:"w-4 h-4"}),"Add Link"]})]})}),a.jsxs(St,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Add external links to the sidebar navigation. Drag to reorder."}),d?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(ct,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?a.jsx("div",{className:"space-y-2",children:u.map(S=>{const N=vN(S.icon);return a.jsxs("div",{draggable:!0,onDragStart:C=>p(C,S.id),onDragOver:x,onDrop:C=>b(C,S.id),className:`flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${l===S.id?"opacity-50":""}`,children:[a.jsx(zg,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0"}),a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray",children:a.jsx(N,{className:"w-4 h-4"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-white font-medium truncate",children:S.name}),a.jsx(Yr,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),a.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:S.url})]}),a.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[a.jsx("button",{onClick:()=>i(S),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:"Edit",children:a.jsx(Ki,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>y(S),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:a.jsx(an,{className:"w-4 h-4"})})]})]},S.id)})}):a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(dc,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:"No external links configured"}),a.jsx("p",{className:"text-sm",children:'Click "Add Link" to add one'})]})]})]}),(e||r)&&a.jsx(CKe,{link:r,onClose:()=>{n(!1),i(null)}}),s&&a.jsx(Yn,{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:v,onCancel:()=>o(null)})]})}function AKe(){const t=on(),{showToast:e}=Vn(),[n,r]=w.useState(!1),[i,s]=w.useState(""),[o,l]=w.useState("immediate"),[c,u]=w.useState("3DPrinter-X1-Carbon"),[d,f]=w.useState(!1),[m,p]=w.useState(null),{data:x,isLoading:b}=at({queryKey:["virtual-printer-settings"],queryFn:g1.getSettings,refetchInterval:1e4}),{data:y}=at({queryKey:["virtual-printer-models"],queryFn:g1.getModels});w.useEffect(()=>{if(x){r(x.enabled);let D=x.mode==="queue"?"review":x.mode;D!=="immediate"&&D!=="review"&&D!=="print_queue"&&(D="immediate"),l(D),u(x.model)}},[x]);const v=mt({mutationFn:D=>g1.updateSettings(D),onSuccess:()=>{t.invalidateQueries({queryKey:["virtual-printer-settings"]}),e("Virtual printer settings updated"),p(null)},onError:D=>{if(e(D.message||"Failed to update settings","error"),x){r(x.enabled);const A=x.mode==="queue"?"review":x.mode;l(A==="print_queue"||A==="review"?A:"immediate"),u(x.model)}p(null)}}),S=()=>{const D=!n;if(D&&!i&&!x?.access_code_set){e("Please set an access code first","error");return}r(D),p("toggle"),v.mutate({enabled:D,access_code:i||void 0,mode:o})},N=()=>{if(!i){e("Access code cannot be empty","error");return}if(i.length!==8){e("Access code must be exactly 8 characters","error");return}p("accessCode"),v.mutate({access_code:i}),s("")},C=D=>{l(D),p("mode"),v.mutate({mode:D})},T=D=>{u(D),p("model"),v.mutate({model:D})};if(b)return a.jsx(wt,{children:a.jsx(St,{className:"py-8 flex justify-center",children:a.jsx(ct,{className:"w-6 h-6 animate-spin text-bambu-green"})})});const k=x?.status,E=k?.running||!1;return a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[a.jsx("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ir,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Virtual Printer"})]}),k&&a.jsxs("div",{className:`flex items-center gap-2 text-sm ${E?"text-green-400":"text-bambu-gray"}`,children:[a.jsx("span",{className:`w-2 h-2 rounded-full ${E?"bg-green-400 animate-pulse":"bg-gray-500"}`}),E?"Running":"Stopped"]})]})}),a.jsxs(St,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable a virtual printer that appears in Bambu Studio and OrcaSlicer. Files sent to this printer will be archived directly without printing."}),a.jsxs("div",{className:"flex items-center justify-between py-3 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-white font-medium",children:"Enable Virtual Printer"}),a.jsx("div",{className:"text-sm text-bambu-gray",children:E?'Visible as "Bambuddy" in slicer discovery':"Not visible to slicers"})]}),a.jsx("button",{onClick:S,disabled:m==="toggle",className:`relative w-12 h-6 rounded-full transition-colors ${n?"bg-bambu-green":"bg-bambu-dark-tertiary"} ${m==="toggle"?"opacity-50":""}`,children:a.jsx("span",{className:`absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform ${n?"translate-x-6":""}`})})]}),a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:"Printer Model"}),a.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:"Select which printer model to emulate."}),a.jsxs("div",{className:"relative",children:[a.jsx("select",{value:c,onChange:D=>T(D.target.value),disabled:m==="model",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white appearance-none cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed pr-10",children:y?.models&&Object.entries(y.models).sort(([,D],[,A])=>D.localeCompare(A)).map(([D,A])=>a.jsx("option",{value:D,children:A},D))}),a.jsx(Xr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),n&&E&&a.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[a.jsx(Qo,{className:"w-3 h-3 inline mr-1"}),"Changing the model will restart the virtual printer"]})]}),a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:"Access Code"}),a.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:x?.access_code_set?a.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[a.jsx(Wi,{className:"w-4 h-4"}),"Access code is set"]}):a.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[a.jsx(jn,{className:"w-4 h-4"}),"No access code set - required to enable"]})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("input",{type:d?"text":"password",value:i,onChange:D=>s(D.target.value),placeholder:x?.access_code_set?"Enter new code to change":"Enter 8-char code",maxLength:8,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray pr-10 font-mono"}),a.jsx("button",{onClick:()=>f(!d),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:d?a.jsx(cN,{className:"w-4 h-4"}):a.jsx(Ru,{className:"w-4 h-4"})})]}),a.jsx(Ne,{onClick:N,disabled:!i||m==="accessCode",variant:"primary",children:m==="accessCode"?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):"Save"})]}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["Must be exactly 8 characters. Used by slicers to authenticate.",i&&a.jsxs("span",{className:i.length===8?"text-green-400":"text-yellow-400",children:[" ","(",i.length,"/8)"]})]})]}),a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:"Mode"}),a.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[a.jsxs("button",{onClick:()=>C("immediate"),disabled:m==="mode",className:`p-3 rounded-lg border text-left transition-colors ${o==="immediate"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsx("div",{className:"text-white font-medium",children:"Archive"}),a.jsx("div",{className:"text-xs text-bambu-gray",children:"Archive files immediately"})]}),a.jsxs("button",{onClick:()=>C("review"),disabled:m==="mode",className:`p-3 rounded-lg border text-left transition-colors ${o==="review"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsx("div",{className:"text-white font-medium",children:"Review"}),a.jsx("div",{className:"text-xs text-bambu-gray",children:"Review and tag before archiving"})]}),a.jsxs("button",{onClick:()=>C("print_queue"),disabled:m==="mode",className:`p-3 rounded-lg border text-left transition-colors ${o==="print_queue"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsx("div",{className:"text-white font-medium",children:"Queue"}),a.jsx("div",{className:"text-xs text-bambu-gray",children:"Archive and add to print queue"})]})]})]})]})]})}),a.jsxs("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:[a.jsx(wt,{className:"border-l-4 border-l-yellow-500",children:a.jsx(St,{className:"py-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(jn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"text-sm",children:[a.jsx("p",{className:"text-white font-medium mb-2",children:"Setup Required"}),a.jsx("p",{className:"text-bambu-gray mb-3",children:"The virtual printer feature requires additional system configuration before it will work. This includes port forwarding, firewall rules, and platform-specific settings."}),a.jsxs("a",{href:"https://wiki.bambuddy.cool/features/virtual-printer/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-yellow-500/20 border border-yellow-500/50 rounded-md text-yellow-400 hover:bg-yellow-500/30 transition-colors",children:[a.jsx(Yr,{className:"w-4 h-4"}),"Read the setup guide before enabling"]})]})]})})}),a.jsx(wt,{children:a.jsx(St,{className:"py-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Qo,{className:"w-5 h-5 text-blue-400 flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"text-sm text-bambu-gray",children:[a.jsx("p",{className:"mb-2",children:a.jsx("strong",{className:"text-white",children:"How it works:"})}),a.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[a.jsx("li",{children:"Complete the setup guide for your platform"}),a.jsx("li",{children:"Enable the virtual printer and set an access code"}),a.jsx("li",{children:'In Bambu Studio or OrcaSlicer, go to "Add Printer"'}),a.jsx("li",{children:'The "Bambuddy" printer should appear in the discovery list'}),a.jsx("li",{children:"Connect using the access code you set"}),a.jsx("li",{children:'When you "print" to Bambuddy, the 3MF file is archived instead'})]})]})]})})}),k&&E&&a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsx("h3",{className:"text-md font-semibold text-white",children:"Status Details"})}),a.jsx(St,{children:a.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:"Printer Name"}),a.jsx("div",{className:"text-white",children:k.name})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:"Model"}),a.jsx("div",{className:"text-white",children:k.model_name||k.model})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:"Serial Number"}),a.jsx("div",{className:"text-white font-mono",children:k.serial})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:"Mode"}),a.jsx("div",{className:"text-white capitalize",children:k.mode})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:"Pending Files"}),a.jsx("div",{className:"text-white",children:k.pending_files})]})]})})]})]})]})}function bq({status:t}){if(!t)return null;const e={success:"bg-green-500/20 text-green-400",failed:"bg-red-500/20 text-red-400",skipped:"bg-yellow-500/20 text-yellow-400",running:"bg-blue-500/20 text-blue-400"},n={success:a.jsx(Tr,{className:"w-3 h-3"}),failed:a.jsx(qi,{className:"w-3 h-3"}),skipped:a.jsx(DD,{className:"w-3 h-3"}),running:a.jsx(ct,{className:"w-3 h-3 animate-spin"})};return a.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium ${e[t]||"bg-gray-500/20 text-gray-400"}`,children:[n[t],t.charAt(0).toUpperCase()+t.slice(1)]})}function kKe(t){return t?new Date(t).toLocaleString():"-"}function yq(t){if(!t)return"-";const e=new Date(t),n=new Date,r=e.getTime()-n.getTime(),i=Math.round(r/6e4);if(i<0){const s=Math.abs(i);if(s<60)return`${s}m ago`;const o=Math.floor(s/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}else{if(i<60)return`in ${i}m`;const s=Math.floor(i/60);return s<24?`in ${s}h`:`in ${Math.floor(s/24)}d`}}function jKe(){const t=on(),{showToast:e}=Vn(),[n,r]=w.useState(""),[i,s]=w.useState(""),[o,l]=w.useState("main"),[c,u]=w.useState(!1),[d,f]=w.useState("daily"),[m,p]=w.useState(!0),[x,b]=w.useState(!0),[y,v]=w.useState(!1),[S,N]=w.useState(!0),[C,T]=w.useState(!1),[k,E]=w.useState(!1),[D,A]=w.useState(""),[R,F]=w.useState(!1),[O,H]=w.useState(null),[j,G]=w.useState(null),$=w.useRef(null);w.useEffect(()=>{if(C||k){const Te=V=>(V.preventDefault(),V.returnValue="A backup operation is in progress. Are you sure you want to leave?",V.returnValue);return window.addEventListener("beforeunload",Te),()=>window.removeEventListener("beforeunload",Te)}},[C,k]);const[q,Y]=w.useState(!1),[Z,oe]=w.useState(null),B=w.useRef(null),W=w.useRef(!1),{data:se,isLoading:ne}=at({queryKey:["github-backup-config"],queryFn:ue.getGitHubBackupConfig}),{data:ce}=at({queryKey:["github-backup-status"],queryFn:ue.getGitHubBackupStatus,refetchInterval:_e=>_e.state.data?.is_running?500:1e4}),{data:fe}=at({queryKey:["github-backup-logs"],queryFn:()=>ue.getGitHubBackupLogs(20)}),{data:ye}=at({queryKey:["cloud-status"],queryFn:ue.getCloudStatus}),{data:ge}=at({queryKey:["printers"],queryFn:ue.getPrinters}),xe=gW({queries:(ge??[]).map(_e=>({queryKey:["printerStatus",_e.id],queryFn:()=>ue.getPrinterStatus(_e.id),staleTime:1e4,refetchInterval:3e4}))}),Pe=(ge??[]).map((_e,Te)=>({printer:_e,connected:xe[Te]?.data?.connected??!1})),Ue=Pe.length,be=Pe.filter(_e=>_e.connected).length,it=Ue>0&&be===0,U=be>0&&be<Ue;w.useEffect(()=>{se&&(r(se.repository_url),l(se.branch),u(se.schedule_enabled),f(se.schedule_type),p(se.backup_kprofiles),b(se.backup_cloud_profiles),v(se.backup_settings),N(se.enabled),s(""),setTimeout(()=>{W.current=!0},100))},[se]);const K=w.useCallback(async(_e=!1)=>{if(se?.has_token)try{_e&&i?(await ue.saveGitHubBackupConfig({repository_url:n,access_token:i,branch:o,schedule_enabled:c,schedule_type:d,backup_kprofiles:m,backup_cloud_profiles:x,backup_settings:y,enabled:S}),s(""),e("Token updated")):(await ue.updateGitHubBackupConfig({repository_url:n,branch:o,schedule_enabled:c,schedule_type:d,backup_kprofiles:m,backup_cloud_profiles:x,backup_settings:y,enabled:S}),e("Settings saved")),t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]})}catch(Te){e(`Failed to save: ${Te.message}`,"error")}},[se?.has_token,n,i,o,c,d,m,x,y,S,t,e]);w.useEffect(()=>{if(!(!W.current||!se?.has_token))return B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{K(!1)},500),()=>{B.current&&clearTimeout(B.current)}},[n,o,c,d,m,x,y,S,K,se?.has_token]),w.useEffect(()=>{if(!(!W.current||!se?.has_token||!i))return B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{K(!0)},1e3),()=>{B.current&&clearTimeout(B.current)}},[i,K,se?.has_token]);const J=mt({mutationFn:_e=>ue.saveGitHubBackupConfig(_e),onSuccess:()=>{t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]}),e("GitHub backup enabled"),s(""),W.current=!0},onError:_e=>{e(`Failed to save: ${_e.message}`,"error")}}),Q=mt({mutationFn:ue.triggerGitHubBackup,onSuccess:_e=>{t.invalidateQueries({queryKey:["github-backup-status"]}),t.invalidateQueries({queryKey:["github-backup-logs"]}),_e.success?_e.files_changed>0?e(`Backup complete - ${_e.files_changed} files updated`):e("Backup skipped - no changes"):e(`Backup failed: ${_e.message}`,"error")},onError:_e=>{e(`Backup failed: ${_e.message}`,"error")}}),z=mt({mutationFn:()=>ue.clearGitHubBackupLogs(0),onSuccess:_e=>{t.invalidateQueries({queryKey:["github-backup-logs"]}),e(`Cleared ${_e.deleted} logs`)},onError:_e=>{e(`Failed to clear logs: ${_e.message}`,"error")}}),re=async()=>{Y(!0),oe(null);try{let _e;if(i){if(!n){e("Enter repository URL","error"),Y(!1);return}_e=await ue.testGitHubConnection(n,i)}else if(se?.has_token)_e=await ue.testGitHubStoredConnection();else{e("Enter repository URL and access token","error"),Y(!1);return}oe({success:_e.success,message:_e.message})}catch(_e){oe({success:!1,message:_e.message})}finally{Y(!1)}},Ee=()=>{if(!n){e("Repository URL is required","error");return}if(!i){e("Access token is required","error");return}J.mutate({repository_url:n,access_token:i,branch:o,schedule_enabled:c,schedule_type:d,backup_kprofiles:m,backup_cloud_profiles:x,backup_settings:y,enabled:S})};return ne?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(ct,{className:"w-8 h-8 animate-spin text-bambu-green"})}):a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[a.jsxs("div",{className:"space-y-6",children:[a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(m3,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"GitHub Backup"})]}),se&&ye?.is_authenticated&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:"Enabled"}),a.jsx(On,{checked:S,onChange:N})]})]})}),a.jsx(St,{className:"space-y-4",children:ye?.is_authenticated?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically sync your profiles to a private GitHub repository for backup and version history."}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Repository URL"}),a.jsx("input",{type:"text",value:n,onChange:_e=>{r(_e.target.value),oe(null)},placeholder:"https://github.com/username/bambuddy-backup",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:["Personal Access Token ",se?.has_token&&a.jsx("span",{className:"text-green-400",children:"(saved)"})]}),a.jsx("input",{type:"password",value:i,onChange:_e=>{s(_e.target.value),oe(null)},placeholder:se?.has_token?"Enter new token to update":"ghp_xxxxxxxxxxxx",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Fine-grained token with Contents read/write permission"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Branch"}),a.jsx("input",{type:"text",value:o,onChange:_e=>l(_e.target.value),placeholder:"main",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Auto-backup"}),a.jsxs("select",{value:c?d:"disabled",onChange:_e=>{_e.target.value==="disabled"?u(!1):(u(!0),f(_e.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:[a.jsx("option",{value:"disabled",children:"Manual only"}),a.jsx("option",{value:"hourly",children:"Hourly"}),a.jsx("option",{value:"daily",children:"Daily"}),a.jsx("option",{value:"weekly",children:"Weekly"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Include in backup"}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("label",{className:`flex items-start gap-2 ${it?"cursor-not-allowed opacity-60":"cursor-pointer"}`,children:[a.jsx("input",{type:"checkbox",checked:m,onChange:_e=>p(_e.target.checked),className:"w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green",disabled:it}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`text-sm ${it?"text-bambu-gray":"text-white"}`,children:"K-Profiles"}),it&&a.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:[a.jsx(jn,{className:"w-3 h-3"}),"No printers connected"]}),U&&a.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:[a.jsx(jn,{className:"w-3 h-3"}),be,"/",Ue," connected"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Pressure advance calibration from connected printers"})]})]}),a.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:x,onChange:_e=>b(_e.target.checked),className:"w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green",disabled:!ye?.is_authenticated}),a.jsxs("div",{children:[a.jsx("span",{className:`text-sm ${ye?.is_authenticated?"text-white":"text-bambu-gray"}`,children:"Cloud Profiles"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament, printer, and process presets from Bambu Cloud"})]})]}),a.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:y,onChange:_e=>v(_e.target.checked),className:"w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white text-sm",children:"App Settings"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Bambuddy configuration (excludes sensitive data)"})]})]})]})]}),a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 space-y-3",children:[ce?.configured&&a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("div",{className:"flex items-center gap-2 text-bambu-gray",children:ce.last_backup_at?a.jsxs(a.Fragment,{children:[a.jsxs("span",{children:["Last backup: ",yq(ce.last_backup_at)]}),a.jsx(bq,{status:ce.last_backup_status})]}):a.jsx("span",{children:"No backups yet"})}),ce.next_scheduled_run&&a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx(Qn,{className:"w-3 h-3 inline mr-1"}),"Next: ",yq(ce.next_scheduled_run)]})]}),Z&&a.jsxs("div",{className:`text-sm flex items-center gap-1 ${Z.success?"text-green-400":"text-red-400"}`,children:[Z.success?a.jsx(Tr,{className:"w-4 h-4"}):a.jsx(qi,{className:"w-4 h-4"}),Z.message]}),a.jsx("div",{className:"flex flex-wrap items-center gap-2",children:ce?.configured?a.jsx(a.Fragment,{children:Q.isPending||ce.is_running?a.jsxs("div",{className:"flex items-center gap-2 text-bambu-green",children:[a.jsx(ct,{className:"w-4 h-4 animate-spin"}),a.jsx("span",{className:"text-sm",children:ce.progress||"Starting backup..."})]}):a.jsxs(a.Fragment,{children:[a.jsxs(Ne,{variant:"primary",size:"sm",onClick:()=>Q.mutate(),disabled:!se?.enabled,children:[a.jsx(Us,{className:"w-4 h-4"}),"Backup Now"]}),a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:re,disabled:q,children:[q?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(Pr,{className:"w-4 h-4"}),"Test"]})]})}):a.jsxs(a.Fragment,{children:[a.jsxs(Ne,{variant:"primary",size:"sm",onClick:Ee,disabled:J.isPending||!n||!i,children:[J.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(Tr,{className:"w-4 h-4"}),"Enable Backup"]}),a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:re,disabled:q||!n||!i,children:[q?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(Pr,{className:"w-4 h-4"}),"Test Connection"]})]})})]})]}):a.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[a.jsx(jn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-sm text-yellow-400",children:"Bambu Cloud login required. Sign in under Profiles → Cloud Profiles to enable GitHub backup."})]})})]}),fe&&fe.length>0&&a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(q0,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"History"})]}),a.jsxs(Ne,{variant:"ghost",size:"sm",onClick:()=>z.mutate(),disabled:z.isPending,children:[a.jsx(an,{className:"w-4 h-4"}),"Clear"]})]})}),a.jsx(St,{children:a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"text-bambu-gray border-b border-bambu-dark-tertiary",children:[a.jsx("th",{className:"text-left py-2 px-2",children:"Date"}),a.jsx("th",{className:"text-left py-2 px-2",children:"Status"}),a.jsx("th",{className:"text-left py-2 px-2",children:"Commit"})]})}),a.jsx("tbody",{children:fe.slice(0,10).map(_e=>a.jsxs("tr",{className:"border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-secondary",children:[a.jsx("td",{className:"py-2 px-2 text-white",children:kKe(_e.started_at)}),a.jsx("td",{className:"py-2 px-2",children:a.jsx(bq,{status:_e.status})}),a.jsx("td",{className:"py-2 px-2",children:_e.commit_sha?a.jsxs("a",{href:`${se?.repository_url}/commit/${_e.commit_sha}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline inline-flex items-center gap-1",children:[_e.commit_sha.substring(0,7),a.jsx(Yr,{className:"w-3 h-3"})]}):a.jsx("span",{className:"text-bambu-gray",children:"-"})})]},_e.id))})]})})})]})]}),a.jsx("div",{className:"space-y-6",children:a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Nu,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Local Backup"})]})}),a.jsxs(St,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Create a complete backup of your Bambuddy data including the database, archives, uploads, and all files."}),a.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Download Backup"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Complete backup: database + all files (ZIP)"})]}),a.jsxs(Ne,{variant:"secondary",size:"sm",disabled:C||k,onClick:async()=>{T(!0),A("Preparing backup...");try{A("Creating backup archive... This may take a while for large archives.");const{blob:_e,filename:Te}=await ue.exportBackup();A("Downloading backup file...");const V=URL.createObjectURL(_e),L=document.createElement("a");L.href=V,L.download=Te,L.click(),URL.revokeObjectURL(V),e("Backup downloaded successfully")}catch(_e){e(`Failed to create backup: ${_e instanceof Error?_e.message:"Unknown error"}`,"error")}finally{T(!1),A("")}},children:[a.jsx(pi,{className:"w-4 h-4"}),"Download"]})]}),a.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Restore Backup"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Replace all data from a backup file"})]}),a.jsx("input",{ref:$,type:"file",accept:".zip",className:"hidden",onChange:_e=>{const Te=_e.target.files?.[0];Te&&(H(Te),F(!0)),_e.target.value=""}}),a.jsxs(Ne,{variant:"secondary",size:"sm",disabled:k||C,onClick:()=>$.current?.click(),children:[a.jsx(Oa,{className:"w-4 h-4"}),"Restore"]})]}),j&&a.jsx("div",{className:`p-3 rounded-lg ${j.success?"bg-green-500/10 border border-green-500/30":"bg-red-500/10 border border-red-500/30"}`,children:a.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[j.success?a.jsx(Tr,{className:"w-4 h-4 text-green-400 mt-0.5 flex-shrink-0"}):a.jsx(qi,{className:"w-4 h-4 text-red-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:j.success?"text-green-200":"text-red-200",children:[j.message,j.success&&a.jsx("div",{className:"mt-2",children:a.jsxs(Ne,{size:"sm",onClick:()=>window.location.reload(),children:[a.jsx(Dh,{className:"w-3 h-3"}),"Reload Now"]})})]})]})}),a.jsx("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:a.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[a.jsx(jn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"text-yellow-200",children:[a.jsx("span",{className:"font-medium",children:"Restore replaces all data."})," ",a.jsx("span",{className:"text-yellow-200/70",children:"Your current database and files will be completely replaced. A restart is required after restore."})]})]})})]})]})}),R&&O&&a.jsx(Yn,{title:"Restore Backup",message:`Are you sure you want to restore from "${O.name}"? This will completely replace your current database and all files. The application will need to be restarted after restore.`,confirmText:"Restore Backup",variant:"danger",onConfirm:async()=>{F(!1),E(!0),G(null);try{A("Uploading backup file...");const _e=await ue.importBackup(O);G(_e),_e.success?e("Backup restored. Please restart Bambuddy.","success"):e(_e.message,"error")}catch(_e){const Te=_e instanceof Error?_e.message:"Failed to restore backup";G({success:!1,message:Te}),e(Te,"error")}finally{E(!1),A(""),H(null)}},onCancel:()=>{F(!1),H(null)}}),(C||k)&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[100]",children:a.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl p-8 max-w-md w-full mx-4 text-center",children:[a.jsx("div",{className:"flex justify-center mb-4",children:a.jsxs("div",{className:"relative",children:[a.jsx("div",{className:"w-16 h-16 border-4 border-bambu-dark-tertiary rounded-full"}),a.jsx("div",{className:"w-16 h-16 border-4 border-bambu-green border-t-transparent rounded-full absolute inset-0 animate-spin"})]})}),a.jsx("h3",{className:"text-xl font-semibold text-white mb-2",children:C?"Creating Backup":"Restoring Backup"}),a.jsx("p",{className:"text-bambu-gray mb-4",children:D||(C?"Preparing...":"Processing...")}),a.jsx("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:a.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[a.jsx(jn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-yellow-200 text-left",children:"Please do not close this page or navigate away. This operation may take several minutes for large backups."})]})})]})})]})}const PKe={get:"bg-blue-500/20 text-blue-400 border-blue-500/30",post:"bg-green-500/20 text-green-400 border-green-500/30",put:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30",patch:"bg-orange-500/20 text-orange-400 border-orange-500/30",delete:"bg-red-500/20 text-red-400 border-red-500/30"};function RKe(t,e){const n=e.replace("#/","").split("/");let r=t;for(const i of n)r=r[i];return r}function p0(t,e,n=0){if(n>5)return"...";if(e.$ref)return p0(t,RKe(t,e.$ref),n+1);if(e.allOf){const r={};for(const i of e.allOf){const s=p0(t,i,n+1);typeof s=="object"&&s!==null&&Object.assign(r,s)}return r}if(e.example!==void 0)return e.example;if(e.default!==void 0)return e.default;switch(e.type){case"string":return e.enum?e.enum[0]:"string";case"integer":case"number":return 0;case"boolean":return!1;case"array":return e.items?[p0(t,e.items,n+1)]:[];case"object":if(e.properties){const r={};for(const[i,s]of Object.entries(e.properties))r[i]=p0(t,s,n+1);return r}return{};default:return null}}function DKe({path:t,method:e,spec:n,schema:r,apiKey:i}){const[s,o]=w.useState(!1),[l,c]=w.useState({}),[u,d]=w.useState(""),[f,m]=w.useState(null),[p,x]=w.useState(!1),[b,y]=w.useState(!1);w.useEffect(()=>{if(s&&n.parameters){const D={};for(const A of n.parameters)A.schema?.default!==void 0&&(D[A.name]=String(A.schema.default));c(A=>({...D,...A}))}},[s,n.parameters]),w.useEffect(()=>{if(s&&n.requestBody?.content?.["application/json"]?.schema&&!u){const D=n.requestBody.content["application/json"].schema,A=p0(r,D);d(JSON.stringify(A,null,2))}},[s,n.requestBody,r,u]);const S=(()=>{const D=[];for(const A of n.parameters||[])if(A.in==="path"||A.required){const R=l[A.name];(R===void 0||R==="")&&D.push(A.name)}return D})(),N=async()=>{if(S.length>0){m({status:0,statusText:"Validation Error",headers:{},body:`Missing required parameters: ${S.join(", ")}`,duration:0});return}x(!0),m(null);try{let D=t;const A=new URLSearchParams;for(const oe of n.parameters||[]){const B=l[oe.name];B!==void 0&&B!==""&&(oe.in==="path"?D=D.replace(`{${oe.name}}`,encodeURIComponent(B)):oe.in==="query"&&A.append(oe.name,B))}const R=A.toString(),F=`${D}${R?`?${R}`:""}`,O={"Content-Type":"application/json"};i&&(O["X-API-Key"]=i);const H={method:e.toUpperCase(),headers:O};["post","put","patch"].includes(e)&&u&&(H.body=u);const j=performance.now(),G=await fetch(F,H),$=Math.round(performance.now()-j),q={};G.headers.forEach((oe,B)=>{q[B]=oe});let Y;G.headers.get("content-type")?.includes("application/json")?Y=await G.json():Y=await G.text(),m({status:G.status,statusText:G.statusText,headers:q,body:Y,duration:$})}catch(D){m({status:0,statusText:"Network Error",headers:{},body:D instanceof Error?D.message:"Unknown error",duration:0})}finally{x(!1)}},C=async()=>{if(f){const D=typeof f.body=="string"?f.body:JSON.stringify(f.body,null,2);try{await navigator.clipboard.writeText(D),y(!0),setTimeout(()=>y(!1),2e3)}catch{const A=document.createElement("textarea");A.value=D,A.style.position="fixed",A.style.left="-999999px",document.body.appendChild(A),A.select(),document.execCommand("copy"),document.body.removeChild(A),y(!0),setTimeout(()=>y(!1),2e3)}}},T=(n.parameters||[]).filter(D=>D.in==="path"),k=(n.parameters||[]).filter(D=>D.in==="query"),E=["post","put","patch"].includes(e)&&n.requestBody;return a.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[a.jsxs("button",{onClick:()=>o(!s),className:"w-full flex items-center gap-3 p-3 hover:bg-bambu-dark-tertiary/50 transition-colors text-left",children:[s?a.jsx(Xr,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}):a.jsx(vs,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:`px-2 py-0.5 text-xs font-mono font-semibold uppercase rounded border ${PKe[e]||"bg-gray-500/20 text-gray-400"}`,children:e}),a.jsx("code",{className:"text-sm text-white font-mono flex-1 truncate",children:t}),n.summary&&a.jsx("span",{className:"text-sm text-bambu-gray truncate max-w-[40%]",children:n.summary})]}),s&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary p-4 space-y-4 bg-bambu-dark/50",children:[n.description&&a.jsx("p",{className:"text-sm text-bambu-gray",children:n.description}),T.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-sm font-medium text-white",children:"Path Parameters"}),a.jsx("div",{className:"space-y-2",children:T.map(D=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[D.name,D.required&&a.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),a.jsx("input",{type:"text",value:l[D.name]||"",onChange:A=>c(R=>({...R,[D.name]:A.target.value})),placeholder:D.description||D.schema?.type||"value",className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none"})]},D.name))})]}),k.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-sm font-medium text-white",children:"Query Parameters"}),a.jsx("div",{className:"space-y-2",children:k.map(D=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[D.name,D.required&&a.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),D.schema?.enum?a.jsxs("select",{value:l[D.name]||"",onChange:A=>c(R=>({...R,[D.name]:A.target.value})),className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:"-- Select --"}),D.schema.enum.map(A=>a.jsx("option",{value:A,children:A},A))]}):a.jsx("input",{type:"text",value:l[D.name]||"",onChange:A=>c(R=>({...R,[D.name]:A.target.value})),placeholder:D.description||D.schema?.type||"value",className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none"})]},D.name))})]}),E&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-sm font-medium text-white",children:"Request Body"}),a.jsx("textarea",{value:u,onChange:D=>d(D.target.value),rows:8,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono focus:border-bambu-green focus:outline-none resize-y",placeholder:"JSON request body..."})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Ne,{onClick:N,disabled:p,children:[p?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(Us,{className:"w-4 h-4"}),"Execute"]}),S.length>0&&a.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[a.jsx(Ii,{className:"w-3 h-3"}),"Fill in: ",S.join(", ")]})]}),f&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h4",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Response",a.jsxs("span",{className:`px-2 py-0.5 text-xs rounded ${f.status>=200&&f.status<300?"bg-green-500/20 text-green-400":f.status>=400?"bg-red-500/20 text-red-400":"bg-yellow-500/20 text-yellow-400"}`,children:[f.status," ",f.statusText]}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[f.duration,"ms"]})]}),a.jsx(Ne,{variant:"secondary",size:"sm",onClick:C,children:b?a.jsx(Tr,{className:"w-3 h-3 text-green-400"}):a.jsx(Ll,{className:"w-3 h-3"})})]}),a.jsx("pre",{className:"p-3 bg-bambu-dark rounded-lg text-sm font-mono text-white overflow-auto max-h-96 border border-bambu-dark-tertiary",children:typeof f.body=="string"?f.body:JSON.stringify(f.body,null,2)})]})]})]})}function OKe({apiKey:t=""}){const[e,n]=w.useState(null),[r,i]=w.useState(!0),[s,o]=w.useState(null),[l,c]=w.useState(new Set),[u,d]=w.useState("");if(w.useEffect(()=>{async function y(){try{const v=await fetch("/openapi.json");if(!v.ok)throw new Error("Failed to fetch OpenAPI schema");const S=await v.json();n(S)}catch(v){o(v instanceof Error?v.message:"Unknown error")}finally{i(!1)}}y()},[]),r)return a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(ct,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(s||!e)return a.jsx(wt,{children:a.jsx(St,{className:"py-8",children:a.jsxs("div",{className:"text-center text-red-400",children:[a.jsx(Ii,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),a.jsx("p",{children:"Failed to load API schema"}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:s})]})})});const f={};for(const[y,v]of Object.entries(e.paths))for(const[S,N]of Object.entries(v)){if(S==="parameters")continue;const C=N.tags||["Other"];for(const T of C)f[T]||(f[T]=[]),f[T].push({path:y,method:S,spec:N})}const m=Object.entries(f).map(([y,v])=>{if(!u)return{tag:y,endpoints:v};const S=v.filter(({path:N,method:C,spec:T})=>{const k=u.toLowerCase();return N.toLowerCase().includes(k)||C.toLowerCase().includes(k)||(T.summary?.toLowerCase()||"").includes(k)||(T.description?.toLowerCase()||"").includes(k)});return{tag:y,endpoints:S}}).filter(({endpoints:y})=>y.length>0).sort((y,v)=>y.tag.localeCompare(v.tag)),p=y=>{c(v=>{const S=new Set(v);return S.has(y)?S.delete(y):S.add(y),S})},x=()=>{c(new Set(m.map(y=>y.tag)))},b=()=>{c(new Set)};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsx("div",{className:"flex-1",children:a.jsx("input",{type:"text",value:u,onChange:y=>d(y.target.value),placeholder:"Search endpoints...",className:"w-full max-w-md px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ne,{variant:"secondary",size:"sm",onClick:x,children:"Expand All"}),a.jsx(Ne,{variant:"secondary",size:"sm",onClick:b,children:"Collapse All"}),a.jsxs("a",{href:"/docs",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-sm text-bambu-green hover:underline",children:[a.jsx(Yr,{className:"w-4 h-4"}),"Swagger UI"]})]})]}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[m.reduce((y,v)=>y+v.endpoints.length,0)," endpoints in ",m.length," categories"]}),a.jsx("div",{className:"space-y-3",children:m.map(({tag:y,endpoints:v})=>a.jsxs(wt,{children:[a.jsx("button",{onClick:()=>p(y),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/30 transition-colors text-left",children:a.jsxs("div",{className:"flex items-center gap-2",children:[l.has(y)?a.jsx(Xr,{className:"w-5 h-5 text-bambu-gray"}):a.jsx(vs,{className:"w-5 h-5 text-bambu-gray"}),a.jsx("h3",{className:"text-base font-semibold text-white capitalize",children:y.replace(/-/g," ")}),a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-2 py-0.5 rounded-full text-bambu-gray",children:v.length})]})}),l.has(y)&&a.jsx(St,{className:"pt-0 space-y-2",children:v.map(({path:S,method:N,spec:C})=>a.jsx(DKe,{path:S,method:N,spec:C,schema:e,apiKey:t},`${N}-${S}`))})]},y))})]})}const LKe=["general","network","plugs","notifications","filament","apikeys","virtual-printer","users","backup"];function IKe(){const t=on(),e=Mc(),[n,r]=wD(),{t:i,i18n:s}=Oy(),{showToast:o}=Vn(),{authEnabled:l,user:c,refreshAuth:u}=Si(),{mode:d,darkStyle:f,darkBackground:m,darkAccent:p,lightStyle:x,lightBackground:b,lightAccent:y,setDarkStyle:v,setDarkBackground:S,setDarkAccent:N,setLightStyle:C,setLightBackground:T,setLightAccent:k}=Oh(),[E,D]=w.useState(null),[A,R]=w.useState(!1),[F,O]=w.useState(null),[H,j]=w.useState(!1),[G,$]=w.useState(null),[q,Y]=w.useState(null),[Z,oe]=w.useState(!1),[B,W]=w.useState(zW()),se=n.get("tab"),ne=se&&LKe.includes(se)?se:"general",[ce,fe]=w.useState(ne),ye=le=>{fe(le),le==="general"?n.delete("tab"):n.set("tab",le),r(n,{replace:!0})},[ge,xe]=w.useState(!1),[Pe,Ue]=w.useState(""),[be,it]=w.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[U,K]=w.useState(null),[J,Q]=w.useState(null),[z,re]=w.useState(""),[Ee,_e]=w.useState(!1),[Te,V]=w.useState(!1),[L,X]=w.useState(null),[te,Me]=w.useState(!1),[ie,De]=w.useState(!1),[Le,$e]=w.useState(!1),[Ze,Ie]=w.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[ae,He]=w.useState(!1),[Se,Be]=w.useState(!1),[ft,we]=w.useState(!1),[tt,ke]=w.useState(null),[We,pe]=w.useState(null),[Ce,de]=w.useState(null),[Ve,yt]=w.useState(!1),[ut,It]=w.useState({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]}),[Ft,vn]=w.useState(!1),[Kt,cr]=w.useState(null),[dr,Jn]=w.useState(null),[ln,Gn]=w.useState({name:"",description:"",permissions:[]}),[nr,er]=w.useState(new Set),[bn,xi]=w.useState(null),[Ia,Ae]=w.useState(!1),[Xe,Je]=w.useState({}),[dt,st]=w.useState({}),jt=le=>{W(le),Ife(le)},he=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:me,isLoading:Fe}=at({queryKey:["settings"],queryFn:ue.getSettings}),{data:Oe,isLoading:je}=at({queryKey:["smart-plugs"],queryFn:ue.getSmartPlugs}),{data:ht,isLoading:Nt}=at({queryKey:["smart-plugs-energy",Oe?.map(le=>le.id)],queryFn:async()=>{if(!Oe||Oe.length===0)return null;const le=await Promise.all(Oe.filter(as=>as.enabled).map(async as=>{try{const ss=await ue.getSmartPlugStatus(as.id);return{plug:as,status:ss}}catch{return{plug:as,status:null}}}));let _t=0,Dn=0,Wn=0,Mo=0,Zu=0;for(const{plug:as,status:ss}of le){const Vx=as.plug_type==="mqtt"&&ss?.energy?.power!=null;(ss?.reachable||Vx)&&ss?.energy&&(Zu++,ss.energy?.power!=null&&(_t+=ss.energy.power),ss.energy?.today!=null&&(Dn+=ss.energy.today),ss.energy?.yesterday!=null&&(Wn+=ss.energy.yesterday),ss.energy?.total!=null&&(Mo+=ss.energy.total))}return{totalPower:_t,totalToday:Dn,totalYesterday:Wn,totalLifetime:Mo,reachableCount:Zu,totalPlugs:Oe.filter(as=>as.enabled).length}},enabled:ce==="plugs"&&!!Oe&&Oe.length>0,refetchInterval:ce==="plugs"?1e4:!1}),{data:Ct,isLoading:At}=at({queryKey:["notification-providers"],queryFn:ue.getNotificationProviders}),{data:Lt,isLoading:Rt}=at({queryKey:["api-keys"],queryFn:ue.getAPIKeys}),Mt=mt({mutationFn:le=>ue.createAPIKey(le),onSuccess:le=>{K(le.key||null),xe(!1),Ue(""),t.invalidateQueries({queryKey:["api-keys"]}),o("API key created")},onError:le=>{o(`Failed to create API key: ${le.message}`,"error")}}),Zt=mt({mutationFn:le=>ue.deleteAPIKey(le),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),o("API key deleted")},onError:le=>{o(`Failed to delete API key: ${le.message}`,"error")}}),{data:$t}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:un,isLoading:_n}=at({queryKey:["notification-templates"],queryFn:ue.getNotificationTemplates}),{data:Mn}=at({queryKey:["virtual-printer-settings"],queryFn:g1.getSettings,refetchInterval:1e4}),Ht=Mn?.status?.running??!1,{data:Xt}=at({queryKey:["ffmpeg-status"],queryFn:ue.checkFfmpeg}),{data:tn}=at({queryKey:["version"],queryFn:ue.getVersion}),{data:cn,refetch:Ur,isRefetching:qn}=at({queryKey:["updateCheck"],queryFn:ue.checkForUpdates,staleTime:300*1e3}),{data:Qe,refetch:Tt}=at({queryKey:["updateStatus"],queryFn:ue.getUpdateStatus,refetchInterval:le=>{const _t=le.state.data;return _t?.status==="downloading"||_t?.status==="installing"?1e3:!1}}),{data:qt}=at({queryKey:["mqtt-status"],queryFn:ue.getMQTTStatus,refetchInterval:ce==="network"?5e3:!1}),{data:xt}=at({queryKey:["github-backup-status"],queryFn:ue.getGitHubBackupStatus}),{data:nn}=at({queryKey:["cloud-status"],queryFn:ue.getCloudStatus}),{hasPermission:gn}=Si(),{data:tr=[],isLoading:br}=at({queryKey:["users"],queryFn:()=>ue.getUsers(),enabled:l&&gn("users:read")}),{data:Fa=[],isLoading:sn}=at({queryKey:["groups"],queryFn:()=>ue.getGroups(),enabled:l&&gn("groups:read")}),{data:Sn}=at({queryKey:["permissions"],queryFn:()=>ue.getPermissions(),enabled:l&&gn("groups:read")}),ns=mt({mutationFn:le=>ue.createUser(le),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),t.invalidateQueries({queryKey:["groups"]}),Be(!1),It({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]}),o("User created successfully")},onError:le=>{o(le.message,"error")}}),So=mt({mutationFn:({id:le,data:_t})=>ue.updateUser(le,_t),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),t.invalidateQueries({queryKey:["groups"]}),we(!1),ke(null),It({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]}),o("User updated successfully")},onError:le=>{o(le.message,"error")}}),aa=mt({mutationFn:({id:le,deleteItems:_t})=>ue.deleteUser(le,_t),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),o("User deleted successfully"),pe(null),de(null)},onError:le=>{o(le.message,"error")}}),rs=async le=>{pe(le),yt(!0);try{const _t=await ue.getUserItemsCount(le);de(_t)}catch{de({archives:0,queue_items:0,library_files:0})}finally{yt(!1)}},fl=mt({mutationFn:le=>ue.createGroup(le),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),vn(!1),No(),o("Group created successfully")},onError:le=>{o(le.message,"error")}}),is=mt({mutationFn:({id:le,data:_t})=>ue.updateGroup(le,_t),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),cr(null),No(),o("Group updated successfully")},onError:le=>{o(le.message,"error")}}),si=mt({mutationFn:le=>ue.deleteGroup(le),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),o("Group deleted successfully")},onError:le=>{o(le.message,"error")}}),Ua=()=>{if(!ut.username||!ut.password){o("Please fill in all required fields","error");return}if(ut.password!==ut.confirmPassword){o("Passwords do not match","error");return}if(ut.password.length<6){o("Password must be at least 6 characters","error");return}ns.mutate({username:ut.username,password:ut.password,role:ut.role,group_ids:ut.group_ids.length>0?ut.group_ids:void 0})},$l=le=>{if(ut.password){if(ut.password!==ut.confirmPassword){o("Passwords do not match","error");return}if(ut.password.length<6){o("Password must be at least 6 characters","error");return}}const _t={username:ut.username||void 0,password:ut.password||void 0,role:ut.role,group_ids:ut.group_ids};_t.password||delete _t.password,So.mutate({id:le,data:_t})},Bi=le=>{ke(le.id),It({username:le.username,password:"",confirmPassword:"",role:le.role,group_ids:le.groups?.map(_t=>_t.id)||[]}),we(!0)},Ux=le=>{It(_t=>({..._t,group_ids:_t.group_ids.includes(le)?_t.group_ids.filter(Dn=>Dn!==le):[..._t.group_ids,le]}))},No=()=>{Gn({name:"",description:"",permissions:[]}),er(new Set)},ml=()=>{if(!ln.name.trim()){o("Please enter a group name","error");return}fl.mutate({name:ln.name,description:ln.description||void 0,permissions:ln.permissions})},zx=()=>{if(Kt){if(!ln.name.trim()){o("Please enter a group name","error");return}is.mutate({id:Kt.id,data:{name:ln.name!==Kt.name?ln.name:void 0,description:ln.description,permissions:ln.permissions}})}},Hh=le=>{cr(le),Gn({name:le.name,description:le.description||"",permissions:le.permissions});const _t=new Set;Sn?.categories.forEach(Dn=>{Dn.permissions.some(Wn=>le.permissions.includes(Wn.value))&&_t.add(Dn.name)}),er(_t)},Hl=le=>{er(_t=>{const Dn=new Set(_t);return Dn.has(le)?Dn.delete(le):Dn.add(le),Dn})},Bx=le=>{Gn(_t=>{const Dn=_t.permissions.includes(le)?_t.permissions.filter(Wn=>Wn!==le):[..._t.permissions,le];return{..._t,permissions:Dn}})},Pm=(le,_t)=>{Gn(Dn=>{const Wn=le.permissions.map(as=>as.value),Mo=Dn.permissions.filter(as=>!Wn.includes(as)),Zu=_t?[...Mo,...Wn]:Mo;return{...Dn,permissions:Zu}})},Rm=le=>le.permissions.every(_t=>ln.permissions.includes(_t.value)),Vh=le=>{const _t=le.permissions.filter(Dn=>ln.permissions.includes(Dn.value));return _t.length>0&&_t.length<le.permissions.length},Yu=mt({mutationFn:ue.applyUpdate,onSuccess:le=>{le.is_docker?o(le.message,"error"):Tt()}}),[Ac,sa]=w.useState(null),pl=mt({mutationFn:ue.testAllNotificationProviders,onSuccess:le=>{sa(le),t.invalidateQueries({queryKey:["notification-providers"]}),le.failed===0?o(`All ${le.tested} providers tested successfully!`,"success"):o(`${le.success}/${le.tested} providers succeeded`,le.failed>0?"error":"success")},onError:le=>{o(`Failed to test providers: ${le.message}`,"error")}}),Vl=mt({mutationFn:async le=>{if(!Oe)return{success:0,failed:0};const _t=Oe.filter(Wn=>Wn.enabled),Dn=await Promise.all(_t.map(async Wn=>{try{return await ue.controlSmartPlug(Wn.id,le),{success:!0}}catch{return{success:!1}}}));return{success:Dn.filter(Wn=>Wn.success).length,failed:Dn.filter(Wn=>!Wn.success).length}},onSuccess:(le,_t)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),le.failed===0?o(`All ${le.success} plugs turned ${_t}`,"success"):o(`${le.success} plugs turned ${_t}, ${le.failed} failed`,"error")},onError:le=>{o(`Failed: ${le.message}`,"error")}}),gl=w.useRef(null),Dm=w.useRef(!1),Om=w.useRef(!0);w.useEffect(()=>{if(me&&!E){const le={...me,external_url:me.external_url||window.location.origin};D(le),setTimeout(()=>{Om.current=!1},100)}},[me,E]);const Lm=mt({mutationFn:ue.updateSettings,onSuccess:le=>{t.setQueryData(["settings"],le),D(le),t.invalidateQueries({queryKey:["archiveStats"]}),o("Settings saved","success")},onError:le=>{o(`Failed to save: ${le.message}`,"error")},onSettled:()=>{Dm.current=!1}}),Qu=mt({mutationFn:({id:le,data:_t})=>ue.updatePrinter(le,_t),onSuccess:()=>{t.invalidateQueries({queryKey:["printers"]}),o("Camera settings saved","success")},onError:le=>{o(`Failed to update printer: ${le.message}`,"error")}});w.useEffect(()=>{if(!(Om.current||!E||!me||!(me.auto_archive!==E.auto_archive||me.save_thumbnails!==E.save_thumbnails||me.capture_finish_photo!==E.capture_finish_photo||me.default_filament_cost!==E.default_filament_cost||me.currency!==E.currency||me.energy_cost_per_kwh!==E.energy_cost_per_kwh||me.energy_tracking_mode!==E.energy_tracking_mode||me.check_updates!==E.check_updates||(me.check_printer_firmware??!0)!==(E.check_printer_firmware??!0)||me.notification_language!==E.notification_language||me.ams_humidity_good!==E.ams_humidity_good||me.ams_humidity_fair!==E.ams_humidity_fair||me.ams_temp_good!==E.ams_temp_good||me.ams_temp_fair!==E.ams_temp_fair||me.ams_history_retention_days!==E.ams_history_retention_days||me.per_printer_mapping_expanded!==E.per_printer_mapping_expanded||me.date_format!==E.date_format||me.time_format!==E.time_format||me.default_printer_id!==E.default_printer_id||me.ftp_retry_enabled!==E.ftp_retry_enabled||me.ftp_retry_count!==E.ftp_retry_count||me.ftp_retry_delay!==E.ftp_retry_delay||me.ftp_timeout!==E.ftp_timeout||me.mqtt_enabled!==E.mqtt_enabled||me.mqtt_broker!==E.mqtt_broker||me.mqtt_port!==E.mqtt_port||me.mqtt_username!==E.mqtt_username||me.mqtt_password!==E.mqtt_password||me.mqtt_topic_prefix!==E.mqtt_topic_prefix||me.mqtt_use_tls!==E.mqtt_use_tls||me.external_url!==E.external_url||me.ha_enabled!==E.ha_enabled||me.ha_url!==E.ha_url||me.ha_token!==E.ha_token||(me.library_archive_mode??"ask")!==(E.library_archive_mode??"ask")||Number(me.library_disk_warning_gb??5)!==Number(E.library_disk_warning_gb??5)||(me.camera_view_mode??"window")!==(E.camera_view_mode??"window")||me.prometheus_enabled!==E.prometheus_enabled||me.prometheus_token!==E.prometheus_token))&&!Dm.current)return gl.current&&clearTimeout(gl.current),gl.current=setTimeout(()=>{if(Dm.current)return;Dm.current=!0;const _t={auto_archive:E.auto_archive,save_thumbnails:E.save_thumbnails,capture_finish_photo:E.capture_finish_photo,default_filament_cost:E.default_filament_cost,currency:E.currency,energy_cost_per_kwh:E.energy_cost_per_kwh,energy_tracking_mode:E.energy_tracking_mode,check_updates:E.check_updates,check_printer_firmware:E.check_printer_firmware,notification_language:E.notification_language,ams_humidity_good:E.ams_humidity_good,ams_humidity_fair:E.ams_humidity_fair,ams_temp_good:E.ams_temp_good,ams_temp_fair:E.ams_temp_fair,ams_history_retention_days:E.ams_history_retention_days,per_printer_mapping_expanded:E.per_printer_mapping_expanded,date_format:E.date_format,time_format:E.time_format,default_printer_id:E.default_printer_id,ftp_retry_enabled:E.ftp_retry_enabled,ftp_retry_count:E.ftp_retry_count,ftp_retry_delay:E.ftp_retry_delay,ftp_timeout:E.ftp_timeout,mqtt_enabled:E.mqtt_enabled,mqtt_broker:E.mqtt_broker,mqtt_port:E.mqtt_port,mqtt_username:E.mqtt_username,mqtt_password:E.mqtt_password,mqtt_topic_prefix:E.mqtt_topic_prefix,mqtt_use_tls:E.mqtt_use_tls,external_url:E.external_url,ha_enabled:E.ha_enabled,ha_url:E.ha_url,ha_token:E.ha_token,library_archive_mode:E.library_archive_mode,library_disk_warning_gb:E.library_disk_warning_gb,camera_view_mode:E.camera_view_mode,prometheus_enabled:E.prometheus_enabled,prometheus_token:E.prometheus_token};Lm.mutate(_t)},500),()=>{gl.current&&clearTimeout(gl.current)}},[E,me,Lm]);const hn=w.useCallback((le,_t)=>{D(Dn=>Dn?{...Dn,[le]:_t}:null)},[]),Nv=async(le,_t,Dn)=>{if(!_t){o("Please enter a camera URL","error");return}st(Wn=>({...Wn,[le]:!0})),Je(Wn=>({...Wn,[le]:null}));try{const Wn=await ue.testExternalCamera(le,_t,Dn);Je(Mo=>({...Mo,[le]:Wn})),Wn.success?o(`Camera connected${Wn.resolution?` (${Wn.resolution})`:""}`,"success"):o(Wn.error||"Connection failed","error")}catch(Wn){const Mo=Wn instanceof Error?Wn.message:"Test failed";Je(Zu=>({...Zu,[le]:{success:!1,error:Mo}})),o(Mo,"error")}finally{st(Wn=>({...Wn,[le]:!1}))}},[$x,Mv]=w.useState({}),Hx=w.useRef({}),Im=w.useRef(new Set);w.useEffect(()=>{if($t){const le={};$t.forEach(_t=>{_t.external_camera_url&&!Im.current.has(_t.id)&&(le[_t.id]=_t.external_camera_url,Im.current.add(_t.id))}),Object.keys(le).length>0&&Mv(_t=>({..._t,...le}))}},[$t]);const qM=(le,_t)=>{Mv(Dn=>({...Dn,[le]:_t})),Hx.current[le]&&clearTimeout(Hx.current[le]),Hx.current[le]=setTimeout(()=>{Qu.mutate({id:le,data:{external_camera_url:_t||null}})},800)},Ev=(le,_t)=>{const Dn={};_t.type!==void 0&&(Dn.external_camera_type=_t.type||null),_t.enabled!==void 0&&(Dn.external_camera_enabled=_t.enabled),Qu.mutate({id:le,data:Dn})};return Fe||!E?a.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:a.jsx(ct,{className:"w-8 h-8 text-bambu-green animate-spin"})}):a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"mb-8",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),a.jsx("p",{className:"text-bambu-gray",children:"Configure Bambuddy"})]}),a.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary overflow-x-auto",children:[a.jsx("button",{onClick:()=>ye("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${ce==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:"General"}),a.jsxs("button",{onClick:()=>ye("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ce==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(el,{className:"w-4 h-4"}),"Smart Plugs",Oe&&Oe.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Oe.length})]}),a.jsxs("button",{onClick:()=>ye("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ce==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(_g,{className:"w-4 h-4"}),"Notifications",Ct&&Ct.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Ct.length})]}),a.jsxs("button",{onClick:()=>ye("filament"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ce==="filament"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(bue,{className:"w-4 h-4"}),"Filament"]}),a.jsxs("button",{onClick:()=>ye("network"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ce==="network"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Sg,{className:"w-4 h-4"}),"Network",a.jsx("span",{className:`w-2 h-2 rounded-full ${qt?.enabled?"bg-green-400":"bg-gray-500"}`})]}),a.jsxs("button",{onClick:()=>ye("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ce==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Ho,{className:"w-4 h-4"}),"API Keys",Lt&&Lt.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Lt.length})]}),a.jsxs("button",{onClick:()=>ye("virtual-printer"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ce==="virtual-printer"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Ir,{className:"w-4 h-4"}),"Virtual Printer",a.jsx("span",{className:`w-2 h-2 rounded-full ${Ht?"bg-green-400":"bg-gray-500"}`})]}),a.jsxs("button",{onClick:()=>ye("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ce==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(fg,{className:"w-4 h-4"}),"Users",l&&a.jsx("span",{className:`w-2 h-2 rounded-full ${l?"bg-green-400":"bg-gray-500"}`})]}),a.jsxs("button",{onClick:()=>ye("backup"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ce==="backup"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Nu,{className:"w-4 h-4"}),"Backup",a.jsx("span",{className:`w-2 h-2 rounded-full ${nn?.is_authenticated&&xt?.configured&&xt?.enabled?"bg-green-400":"bg-gray-500"}`})]})]}),ce==="general"&&a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[a.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-xl",children:[a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.general")})}),a.jsxs(St,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(ah,{className:"w-4 h-4 inline mr-1"}),i("settings.language")]}),a.jsxs("div",{className:"relative",children:[a.jsx("select",{value:s.language,onChange:le=>s.changeLanguage(le.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:xz.map(le=>a.jsxs("option",{value:le.code,children:[le.nativeName," (",le.name,")"]},le.code))}),a.jsx(Xr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.languageDescription")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.defaultView")}),a.jsxs("div",{className:"relative",children:[a.jsx("select",{value:B,onChange:le=>jt(le.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:K0.map(le=>a.jsx("option",{value:le.to,children:i(le.labelKey)},le.id))}),a.jsx(Xr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.defaultViewDescription")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date Format"}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:E.date_format||"system",onChange:le=>hn("date_format",le.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[a.jsx("option",{value:"system",children:"System Default"}),a.jsx("option",{value:"us",children:"US (MM/DD/YYYY)"}),a.jsx("option",{value:"eu",children:"EU (DD/MM/YYYY)"}),a.jsx("option",{value:"iso",children:"ISO (YYYY-MM-DD)"})]}),a.jsx(Xr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:E.time_format||"system",onChange:le=>hn("time_format",le.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[a.jsx("option",{value:"system",children:"System Default"}),a.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),a.jsx("option",{value:"24h",children:"24-hour (15:30)"})]}),a.jsx(Xr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:E.default_printer_id??"",onChange:le=>hn("default_printer_id",le.target.value?Number(le.target.value):null),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[a.jsx("option",{value:"",children:"No default (ask each time)"}),$t?.map(le=>a.jsx("option",{value:le.id,children:le.name},le.id))]}),a.jsx(Xr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Pre-select this printer for uploads, reprints, and other operations."})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Sidebar order"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:he,children:[a.jsx(Dh,{className:"w-4 h-4"}),"Reset"]})]})]})]}),a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(TW,{className:"w-5 h-5"}),"Appearance"]})}),a.jsxs(St,{className:"space-y-6",children:[a.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${d==="dark"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[a.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Dark Mode",d==="dark"&&a.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),a.jsxs("select",{value:m,onChange:le=>{S(le.target.value),o("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"neutral",children:"Neutral"}),a.jsx("option",{value:"warm",children:"Warm"}),a.jsx("option",{value:"cool",children:"Cool"}),a.jsx("option",{value:"oled",children:"OLED Black"}),a.jsx("option",{value:"slate",children:"Slate Blue"}),a.jsx("option",{value:"forest",children:"Forest Green"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),a.jsxs("select",{value:p,onChange:le=>{N(le.target.value),o("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"green",children:"Green"}),a.jsx("option",{value:"teal",children:"Teal"}),a.jsx("option",{value:"blue",children:"Blue"}),a.jsx("option",{value:"orange",children:"Orange"}),a.jsx("option",{value:"purple",children:"Purple"}),a.jsx("option",{value:"red",children:"Red"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),a.jsxs("select",{value:f,onChange:le=>{v(le.target.value),o("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"classic",children:"Classic"}),a.jsx("option",{value:"glow",children:"Glow"}),a.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),a.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${d==="light"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[a.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Light Mode",d==="light"&&a.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),a.jsxs("select",{value:b,onChange:le=>{T(le.target.value),o("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"neutral",children:"Neutral"}),a.jsx("option",{value:"warm",children:"Warm"}),a.jsx("option",{value:"cool",children:"Cool"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),a.jsxs("select",{value:y,onChange:le=>{k(le.target.value),o("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"green",children:"Green"}),a.jsx("option",{value:"teal",children:"Teal"}),a.jsx("option",{value:"blue",children:"Blue"}),a.jsx("option",{value:"orange",children:"Orange"}),a.jsx("option",{value:"purple",children:"Purple"}),a.jsx("option",{value:"red",children:"Red"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),a.jsxs("select",{value:x,onChange:le=>{C(le.target.value),o("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"classic",children:"Classic"}),a.jsx("option",{value:"glow",children:"Glow"}),a.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Toggle between dark and light mode using the sun/moon icon in the sidebar."})]})]}),a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),a.jsxs(St,{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Auto-archive prints"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:E.auto_archive,onChange:le=>hn("auto_archive",le.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Save thumbnails"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:E.save_thumbnails,onChange:le=>hn("save_thumbnails",le.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Capture finish photo"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:E.capture_finish_photo,onChange:le=>hn("capture_finish_photo",le.target.checked),className:"sr-only peer"}),a.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.capture_finish_photo&&Xt&&!Xt.installed&&a.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[a.jsx(jn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"text-sm",children:[a.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),a.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",a.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",a.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]})]}),a.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-md",children:[a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(LD,{className:"w-5 h-5 text-bambu-green"}),"Camera"]})}),a.jsxs(St,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Camera View Mode"}),a.jsxs("select",{value:E.camera_view_mode??"window",onChange:le=>hn("camera_view_mode",le.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:[a.jsx("option",{value:"window",children:"New Window"}),a.jsx("option",{value:"embedded",children:"Embedded Overlay"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:E.camera_view_mode==="embedded"?"Camera opens in a resizable overlay on the main screen":"Camera opens in a separate browser window"})]}),a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4",children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-2",children:"External Cameras"}),a.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Configure external cameras to replace the built-in printer camera. Supports MJPEG streams, RTSP, HTTP snapshots, and USB cameras (V4L2). When enabled, the external camera is used for live view and finish photos."}),$t&&$t.length>0?a.jsx("div",{className:"space-y-3",children:$t.map(le=>a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-white font-medium text-sm",children:le.name}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:le.external_camera_enabled,onChange:_t=>Ev(le.id,{enabled:_t.target.checked}),className:"sr-only peer"}),a.jsx("div",{className:"w-9 h-5 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:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),le.external_camera_enabled&&a.jsxs("div",{className:"space-y-2 mt-2",children:[a.jsx("input",{type:"text",placeholder:le.external_camera_type==="usb"?"Device path (/dev/video0)":"Camera URL (rtsp://... or http://...)",value:$x[le.id]??le.external_camera_url??"",onChange:_t=>qM(le.id,_t.target.value),className:"w-full 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"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("select",{value:le.external_camera_type||"mjpeg",onChange:_t=>Ev(le.id,{type:_t.target.value}),className:"flex-1 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",children:[a.jsx("option",{value:"mjpeg",children:"MJPEG Stream"}),a.jsx("option",{value:"rtsp",children:"RTSP Stream"}),a.jsx("option",{value:"snapshot",children:"HTTP Snapshot"}),a.jsx("option",{value:"usb",children:"USB Camera (V4L2)"})]}),a.jsx(Ne,{size:"sm",variant:"secondary",onClick:()=>Nv(le.id,$x[le.id]??le.external_camera_url??"",le.external_camera_type||"mjpeg"),disabled:dt[le.id]||!($x[le.id]??le.external_camera_url),children:dt[le.id]?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):"Test"})]}),Xe[le.id]&&a.jsx("div",{className:`text-xs flex items-center gap-1 ${Xe[le.id]?.success?"text-green-500":"text-red-500"}`,children:Xe[le.id]?.success?a.jsxs(a.Fragment,{children:[a.jsx(Tr,{className:"w-3 h-3"}),"Connected",Xe[le.id]?.resolution&&` (${Xe[le.id]?.resolution})`]}):a.jsxs(a.Fragment,{children:[a.jsx(qi,{className:"w-3 h-3"}),Xe[le.id]?.error||"Connection failed"]})})]})]},le.id))}):a.jsx("p",{className:"text-xs text-bambu-gray italic",children:"No printers configured"})]})]})]}),a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),a.jsxs(St,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),a.jsx("input",{type:"number",step:"0.01",min:"0",value:E.default_filament_cost,onChange:le=>hn("default_filament_cost",parseFloat(le.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),a.jsxs("select",{value:E.currency,onChange:le=>hn("currency",le.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:[a.jsx("option",{value:"USD",children:"USD ($)"}),a.jsx("option",{value:"EUR",children:"EUR (€)"}),a.jsx("option",{value:"GBP",children:"GBP (£)"}),a.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),a.jsx("option",{value:"JPY",children:"JPY (¥)"}),a.jsx("option",{value:"CNY",children:"CNY (¥)"}),a.jsx("option",{value:"CAD",children:"CAD ($)"}),a.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),a.jsx("input",{type:"number",step:"0.01",min:"0",value:E.energy_cost_per_kwh,onChange:le=>hn("energy_cost_per_kwh",parseFloat(le.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),a.jsxs("select",{value:E.energy_tracking_mode||"total",onChange:le=>hn("energy_tracking_mode",le.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:[a.jsx("option",{value:"print",children:"Prints Only"}),a.jsx("option",{value:"total",children:"Total Consumption"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:E.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(fs,{className:"w-5 h-5 text-bambu-green"}),"File Manager"]})}),a.jsxs(St,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Create Archive Entry When Printing"}),a.jsxs("select",{value:E.library_archive_mode??"ask",onChange:le=>hn("library_archive_mode",le.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:[a.jsx("option",{value:"always",children:"Always create archive entry"}),a.jsx("option",{value:"never",children:"Never create archive entry"}),a.jsx("option",{value:"ask",children:"Ask each time"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"When printing from File Manager, optionally create an archive entry"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Low Disk Space Warning"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"0.5",max:"100",step:"0.5",value:E.library_disk_warning_gb??5,onChange:le=>hn("library_disk_warning_gb",parseFloat(le.target.value)||5),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"GB"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Show warning when free disk space falls below this threshold"})]})]})]})]}),a.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-sm",children:[a.jsx(TKe,{}),a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),a.jsxs(St,{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Check for updates"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:E.check_updates,onChange:le=>hn("check_updates",le.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Check printer firmware"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Check for printer firmware updates from Bambu Lab"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:E.check_printer_firmware??!0,onChange:le=>hn("check_printer_firmware",le.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Current version"}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",tn?.version||"..."]})]}),a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>Ur(),disabled:qn,children:[qn?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(Pr,{className:"w-4 h-4"}),"Check now"]})]}),cn?.update_available?a.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{children:[a.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",cn.latest_version]}),cn.release_name&&cn.release_name!==cn.latest_version&&a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:cn.release_name})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[cn.release_notes&&a.jsx("button",{onClick:()=>Me(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),cn.release_url&&a.jsx("a",{href:cn.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:a.jsx(Yr,{className:"w-4 h-4"})})]})]}),Qe?.status==="downloading"||Qe?.status==="installing"?a.jsxs("div",{className:"mt-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(ct,{className:"w-4 h-4 animate-spin"}),a.jsx("span",{children:Qe.message})]}),a.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:a.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${Qe.progress}%`}})})]}):Qe?.status==="complete"?a.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:Qe.message}):Qe?.status==="error"?a.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:Qe.error||Qe.message}):cn?.is_docker?a.jsxs("div",{className:"mt-3 p-3 bg-bambu-dark-tertiary rounded-lg",children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Update via Docker Compose:"}),a.jsx("code",{className:"block text-xs bg-bambu-dark p-2 rounded text-bambu-green font-mono",children:"docker compose pull && docker compose up -d"})]}):a.jsxs(Ne,{className:"mt-3",onClick:()=>Yu.mutate(),disabled:Yu.isPending,children:[Yu.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(pi,{className:"w-4 h-4"}),"Install Update"]})]}):cn?.error?a.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: ",cn.error]}):cn&&!cn.update_available?a.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Data Management"})}),a.jsxs(St,{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Clear Notification Logs"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Delete notification logs older than 30 days"})]}),a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>_e(!0),children:[a.jsx(an,{className:"w-4 h-4"}),"Clear"]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Reset UI Preferences"}),a.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."})]}),a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>V(!0),children:[a.jsx(an,{className:"w-4 h-4"}),"Reset"]})]}),a.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Backup & Restore"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Export/import settings and configure GitHub backup"})]}),a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>ye("backup"),children:[a.jsx(Nu,{className:"w-4 h-4"}),"Go to Backup"]})]})]})]})]})]}),ce==="network"&&E&&a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[a.jsxs("div",{className:"flex-1 lg:max-w-xl space-y-4",children:[a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(ah,{className:"w-5 h-5 text-blue-400"}),"External URL"]})}),a.jsxs(St,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"The external URL where Bambuddy is accessible. Used for notification images and external integrations."}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Bambuddy URL"}),a.jsx("input",{type:"text",value:E.external_url??"",onChange:le=>hn("external_url",le.target.value),placeholder:"http://192.168.1.100:8000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Include protocol and port (e.g., http://192.168.1.100:8000)"})]})]})]}),a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Pr,{className:"w-5 h-5 text-blue-400"}),"FTP Retry"]})}),a.jsxs(St,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Retry FTP operations when printer WiFi is unreliable. Applies to 3MF downloads, print uploads, timelapse downloads, and firmware updates."}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Enable retry"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically retry failed FTP operations"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:E.ftp_retry_enabled??!0,onChange:le=>hn("ftp_retry_enabled",le.target.checked),className:"sr-only peer"}),a.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.ftp_retry_enabled&&a.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry attempts"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"1",max:"10",value:E.ftp_retry_count??3,onChange:le=>hn("ftp_retry_count",Math.min(10,Math.max(1,parseInt(le.target.value)||3))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"times"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Number of retry attempts before giving up (1-10)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry delay"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"1",max:"30",value:E.ftp_retry_delay??2,onChange:le=>hn("ftp_retry_delay",Math.min(30,Math.max(1,parseInt(le.target.value)||2))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"seconds"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Wait time between retries (1-30)"})]})]}),a.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Connection timeout"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"10",max:"120",value:E.ftp_timeout??30,onChange:le=>hn("ftp_timeout",Math.min(120,Math.max(10,parseInt(le.target.value)||30))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"seconds"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Socket timeout for slow connections. Increase for A1/A1 Mini printers with weak WiFi (10-120)"})]})]})]})]}),a.jsxs("div",{className:"flex-1 lg:max-w-xl space-y-4",children:[a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(mN,{className:"w-5 h-5 text-bambu-green"}),"Home Assistant"]}),E.ha_enabled&&bn&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${bn.success?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:`text-sm ${bn.success?"text-green-400":"text-red-400"}`,children:bn.success?"Connected":"Disconnected"})]})]})}),a.jsxs(St,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Home Assistant to control smart plugs via HA's REST API. Supports switch, light, input_boolean, and script entities."}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Enable Home Assistant"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Control smart plugs via Home Assistant"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:E.ha_enabled??!1,onChange:le=>hn("ha_enabled",le.target.checked),className:"sr-only peer"}),a.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.ha_enabled&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Home Assistant URL"}),a.jsx("input",{type:"text",value:E.ha_url??"",onChange:le=>hn("ha_url",le.target.value),placeholder:"http://192.168.1.100:8123",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Long-Lived Access Token"}),a.jsx("input",{type:"password",value:E.ha_token??"",onChange:le=>hn("ha_token",le.target.value),placeholder:"eyJ0eXAiOiJKV1QiLC...",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Create a token in HA: Profile → Long-Lived Access Tokens → Create Token"})]}),E.ha_url&&E.ha_token&&a.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:a.jsxs(Ne,{variant:"secondary",size:"sm",disabled:Ia,onClick:async()=>{Ae(!0),xi(null);try{const le=await ue.testHAConnection(E.ha_url,E.ha_token);xi(le)}catch(le){xi({success:!1,message:null,error:le instanceof Error?le.message:"Unknown error"})}finally{Ae(!1)}},children:[Ia?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(Sg,{className:"w-4 h-4"}),"Test Connection"]})})]})]})]}),a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Sg,{className:"w-5 h-5 text-blue-400"}),"MQTT Publishing"]}),qt?.enabled&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${qt.connected?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:`text-sm ${qt.connected?"text-green-400":"text-red-400"}`,children:qt.connected?"Connected":"Disconnected"})]})]})}),a.jsxs(St,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Publish BamBuddy events to an external MQTT broker for integration with Node-RED, Home Assistant, and other automation systems."}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Enable MQTT"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Publish events to external MQTT broker"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:E.mqtt_enabled??!1,onChange:le=>hn("mqtt_enabled",le.target.checked),className:"sr-only peer"}),a.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.mqtt_enabled&&a.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Broker hostname"}),a.jsx("input",{type:"text",value:E.mqtt_broker??"",onChange:le=>hn("mqtt_broker",le.target.value),placeholder:"mqtt.example.com or 192.168.1.100",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex items-end gap-4",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Port"}),a.jsx("input",{type:"number",min:"1",max:"65535",value:E.mqtt_port??1883,onChange:le=>hn("mqtt_port",Math.min(65535,Math.max(1,parseInt(le.target.value)||1883))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex items-center gap-3 pb-2",children:[a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:E.mqtt_use_tls??!1,onChange:le=>{const _t=le.target.checked;hn("mqtt_use_tls",_t);const Dn=E.mqtt_port??1883;_t&&Dn===1883?hn("mqtt_port",8883):!_t&&Dn===8883&&hn("mqtt_port",1883)},className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]}),a.jsx("span",{className:"text-white text-sm",children:"Use TLS"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username (optional)"}),a.jsx("input",{type:"text",value:E.mqtt_username??"",onChange:le=>hn("mqtt_username",le.target.value),placeholder:"Leave empty for anonymous",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password (optional)"}),a.jsx("input",{type:"password",value:E.mqtt_password??"",onChange:le=>hn("mqtt_password",le.target.value),placeholder:"Leave empty for anonymous",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic prefix"}),a.jsx("input",{type:"text",value:E.mqtt_topic_prefix??"bambuddy",onChange:le=>hn("mqtt_topic_prefix",le.target.value),placeholder:"bambuddy",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["Topics will be: ",E.mqtt_topic_prefix||"bambuddy","/printers/<serial>/status, etc."]})]}),qt&&a.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:`w-2 h-2 rounded-full ${qt.connected?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:"text-bambu-gray",children:qt.connected?a.jsxs(a.Fragment,{children:["Connected to ",a.jsxs("span",{className:"text-white",children:[qt.broker,":",qt.port]})]}):"Not connected"})]})})]})]})]})]}),a.jsx("div",{className:"flex-1 lg:max-w-md space-y-4",children:a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(v3,{className:"w-5 h-5 text-orange-400"}),"Prometheus Metrics"]})}),a.jsxs(St,{className:"space-y-4",children:[a.jsxs("p",{className:"text-sm text-bambu-gray",children:["Expose printer metrics at ",a.jsx("code",{className:"bg-bambu-dark px-1 rounded",children:"/api/v1/metrics"})," for Prometheus/Grafana monitoring."]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Enable Metrics Endpoint"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Expose printer data in Prometheus format"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:E.prometheus_enabled??!1,onChange:le=>hn("prometheus_enabled",le.target.checked),className:"sr-only peer"}),a.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.prometheus_enabled&&a.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Bearer Token (optional)"}),a.jsx("input",{type:"password",value:E.prometheus_token??"",onChange:le=>hn("prometheus_token",le.target.value),placeholder:"Leave empty for no authentication",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["If set, requests must include ",a.jsx("code",{className:"bg-bambu-dark px-1 rounded",children:"Authorization: Bearer <token>"})]})]}),a.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-sm text-white mb-2",children:"Available Metrics"}),a.jsxs("div",{className:"text-xs text-bambu-gray space-y-1",children:[a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_printer_connected"})," - Connection status"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_printer_state"})," - Printer state (idle/printing/etc)"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_print_progress"})," - Print progress 0-100%"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_bed_temp_celsius"})," - Bed temperature"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_nozzle_temp_celsius"})," - Nozzle temperature"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_prints_total"})," - Total prints by result"]}),a.jsx("p",{className:"text-bambu-gray/70 italic",children:"...and more (layers, fans, queue, filament usage)"})]})]})]})]})]})})]}),bn&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-6 max-w-md w-full mx-4",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[bn.success?a.jsx(Tr,{className:"w-8 h-8 text-green-400"}):a.jsx(qi,{className:"w-8 h-8 text-red-400"}),a.jsx("h3",{className:"text-lg font-medium text-white",children:bn.success?"Connection Successful":"Connection Failed"})]}),a.jsx("p",{className:"text-bambu-gray mb-6",children:bn.success?bn.message||"Successfully connected to Home Assistant.":bn.error||"Failed to connect to Home Assistant."}),a.jsx("div",{className:"flex justify-end",children:a.jsx(Ne,{variant:"primary",onClick:()=>xi(null),children:"OK"})})]})}),ce==="plugs"&&a.jsxs("div",{className:"max-w-4xl",children:[a.jsxs("div",{className:"flex items-start justify-between mb-6",children:[a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(el,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Connect smart plugs (Tasmota or Home Assistant) to automate power control and track energy usage for your printers."})]}),a.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[Oe&&Oe.filter(le=>le.enabled).length>1&&a.jsxs(a.Fragment,{children:[a.jsxs(Ne,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>X("on"),disabled:Vl.isPending,title:"Turn all plugs on",children:[Vl.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(Vu,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),a.jsxs(Ne,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>X("off"),disabled:Vl.isPending,title:"Turn all plugs off",children:[Vl.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(xN,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),a.jsxs(Ne,{className:"whitespace-nowrap",onClick:()=>{O(null),R(!0)},children:[a.jsx(lr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),Oe&&Oe.length>0&&a.jsxs(wt,{className:"mb-6",children:[a.jsx(Hn,{children:a.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[a.jsx(vh,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",Nt&&a.jsx(ct,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),a.jsx(St,{children:ht?a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[a.jsx(vh,{className:"w-3 h-3"}),"Current Power"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[ht.totalPower.toFixed(1),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"W"})]}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[ht.reachableCount,"/",ht.totalPlugs," plugs online"]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[a.jsx(ti,{className:"w-3 h-3"}),"Today"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[ht.totalToday.toFixed(2),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),E&&E.energy_cost_per_kwh>0&&a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(ht.totalToday*E.energy_cost_per_kwh).toFixed(2)," ",E.currency]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[a.jsx(v3,{className:"w-3 h-3"}),"Yesterday"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[ht.totalYesterday.toFixed(2),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),E&&E.energy_cost_per_kwh>0&&a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(ht.totalYesterday*E.energy_cost_per_kwh).toFixed(2)," ",E.currency]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[a.jsx(f3,{className:"w-3 h-3"}),"Total"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[ht.totalLifetime.toFixed(1),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),E&&E.energy_cost_per_kwh>0&&a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(ht.totalLifetime*E.energy_cost_per_kwh).toFixed(2)," ",E.currency]})]})]}):Nt?null:a.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),je?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(ct,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Oe&&Oe.length>0?a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Oe.map(le=>a.jsx(mKe,{plug:le,onEdit:_t=>{O(_t),R(!0)}},le.id))}):a.jsx(wt,{children:a.jsx(St,{className:"py-12",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(el,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),a.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No smart plugs configured"}),a.jsx("p",{className:"text-sm mb-4",children:"Add a Tasmota-based smart plug to track energy usage and automate power control."}),a.jsxs(Ne,{onClick:()=>{O(null),R(!0)},children:[a.jsx(lr,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),ce==="notifications"&&a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(_g,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Ne,{size:"sm",variant:"secondary",onClick:()=>oe(!0),children:[a.jsx(q0,{className:"w-4 h-4"}),"Log"]}),Ct&&Ct.length>0&&a.jsxs(Ne,{size:"sm",variant:"secondary",onClick:()=>{sa(null),pl.mutate()},disabled:pl.isPending,children:[pl.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(RD,{className:"w-4 h-4"}),"Test All"]}),a.jsxs(Ne,{size:"sm",onClick:()=>{$(null),j(!0)},children:[a.jsx(lr,{className:"w-4 h-4"}),"Add"]})]})]}),a.jsx(wt,{className:"mb-4",children:a.jsx(St,{className:"py-3",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white text-sm font-medium",children:i("settings.notificationLanguage")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.notificationLanguageDescription")})]}),a.jsx("select",{value:E.notification_language||"en",onChange:le=>hn("notification_language",le.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:xz.map(le=>a.jsx("option",{value:le.code,children:le.nativeName},le.code))})]})})}),Ac&&a.jsx(wt,{className:"mb-4",children:a.jsxs(St,{className:"py-3",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm font-medium text-white",children:"Test Results"}),a.jsx("button",{onClick:()=>sa(null),className:"text-bambu-gray hover:text-white text-xs",children:"Dismiss"})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm mb-2",children:[a.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[a.jsx(Tr,{className:"w-4 h-4"}),Ac.success," passed"]}),Ac.failed>0&&a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(qi,{className:"w-4 h-4"}),Ac.failed," failed"]})]}),Ac.results.filter(le=>!le.success).length>0&&a.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:Ac.results.filter(le=>!le.success).map(le=>a.jsxs("div",{className:"text-xs text-red-400",children:[a.jsxs("span",{className:"font-medium",children:[le.provider_name,":"]})," ",le.message]},le.provider_id))})]})}),At?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(ct,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Ct&&Ct.length>0?a.jsx("div",{className:"space-y-3",children:Ct.map(le=>a.jsx(xKe,{provider:le,onEdit:_t=>{$(_t),j(!0)}},le.id))}):a.jsx(wt,{children:a.jsx(St,{className:"py-8",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(_g,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{className:"text-sm font-medium text-white mb-2",children:"No providers configured"}),a.jsx("p",{className:"text-xs mb-3",children:"Add a provider to receive alerts."}),a.jsxs(Ne,{size:"sm",onClick:()=>{$(null),j(!0)},children:[a.jsx(lr,{className:"w-4 h-4"}),"Add Provider"]})]})})})]}),a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[a.jsx(fs,{className:"w-5 h-5 text-bambu-green"}),"Message Templates"]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Customize notification messages for each event."}),_n?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(ct,{className:"w-6 h-6 text-bambu-green animate-spin"})}):un&&un.length>0?a.jsx("div",{className:"space-y-2",children:un.map(le=>a.jsx(wt,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>Y(le),children:a.jsx(St,{className:"py-2.5 px-3",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-white font-medium text-sm truncate",children:le.name}),a.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:le.title_template})]}),a.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:_t=>{_t.stopPropagation(),Y(le)},children:a.jsx(hg,{className:"w-4 h-4 text-bambu-gray"})})]})})},le.id))}):a.jsx(wt,{children:a.jsx(St,{className:"py-8",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(fs,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{className:"text-sm",children:"No templates available. Restart the backend to seed default templates."})]})})})]})]}),ce==="apikeys"&&a.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-8",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Ho,{className:"w-5 h-5 text-bambu-green"}),"API Keys"]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Create API keys for external integrations and webhooks."})]}),a.jsxs(Ne,{size:"sm",onClick:()=>xe(!0),className:"flex-shrink-0",children:[a.jsx(lr,{className:"w-4 h-4"}),"Create Key"]})]}),U&&a.jsx(wt,{className:"mb-6 border-bambu-green",children:a.jsx(St,{className:"py-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Tr,{className:"w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-white font-medium mb-1",children:"API Key Created Successfully"}),a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Copy this key now - it won't be shown again!"}),a.jsxs("div",{className:"flex items-center gap-2 bg-bambu-dark rounded-lg p-2",children:[a.jsx("code",{className:"flex-1 text-sm text-bambu-green font-mono break-all",children:U}),a.jsx(Ne,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(U);else{const le=document.createElement("textarea");le.value=U,le.style.position="fixed",le.style.left="-999999px",document.body.appendChild(le),le.select(),document.execCommand("copy"),document.body.removeChild(le)}o("Key copied to clipboard")}catch{o("Failed to copy key","error")}},children:a.jsx(Ll,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex gap-2 mt-3",children:[a.jsx(Ne,{variant:"secondary",size:"sm",onClick:()=>{re(U),o("Key added to API Browser")},children:"Use in API Browser"}),a.jsx(Ne,{variant:"secondary",size:"sm",onClick:()=>K(null),children:"Dismiss"})]})]})]})})}),ge&&a.jsxs(wt,{className:"mb-6",children:[a.jsx(Hn,{children:a.jsx("h3",{className:"text-base font-semibold text-white",children:"Create New API Key"})}),a.jsxs(St,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Key Name"}),a.jsx("input",{type:"text",value:Pe,onChange:le=>Ue(le.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Permissions"}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:be.can_read_status,onChange:le=>it(_t=>({..._t,can_read_status:le.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white",children:"Read Status"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"View printer status and queue"})]})]}),a.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:be.can_queue,onChange:le=>it(_t=>({..._t,can_queue:le.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white",children:"Manage Queue"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Add and remove items from print queue"})]})]}),a.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:be.can_control_printer,onChange:le=>it(_t=>({..._t,can_control_printer:le.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white",children:"Control Printer"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Pause, resume, and stop prints"})]})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[a.jsxs(Ne,{onClick:()=>Mt.mutate({name:Pe||"Unnamed Key",...be}),disabled:Mt.isPending,children:[Mt.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(lr,{className:"w-4 h-4"}),"Create Key"]}),a.jsx(Ne,{variant:"secondary",onClick:()=>xe(!1),children:"Cancel"})]})]})]}),Rt?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(ct,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Lt&&Lt.length>0?a.jsx("div",{className:"space-y-3",children:Lt.map(le=>a.jsx(wt,{children:a.jsx(St,{className:"py-3",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Ho,{className:`w-5 h-5 ${le.enabled?"text-bambu-green":"text-bambu-gray"}`}),a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium",children:le.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[le.key_prefix,"••••••••",le.last_used&&` · Last used: ${Bg(le.last_used)}`]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex gap-1 text-xs",children:[le.can_read_status&&a.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:"Read"}),le.can_queue&&a.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:"Queue"}),le.can_control_printer&&a.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:"Control"})]}),a.jsx(Ne,{variant:"secondary",size:"sm",onClick:()=>Q(le.id),children:a.jsx(an,{className:"w-4 h-4 text-red-400"})})]})]})})},le.id))}):a.jsx(wt,{children:a.jsx(St,{className:"py-12",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(Ho,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),a.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No API keys"}),a.jsx("p",{className:"text-sm mb-4",children:"Create an API key to integrate with external services."}),a.jsxs(Ne,{onClick:()=>xe(!0),children:[a.jsx(lr,{className:"w-4 h-4"}),"Create Your First Key"]})]})})}),a.jsxs(wt,{className:"mt-6",children:[a.jsx(Hn,{children:a.jsx("h3",{className:"text-base font-semibold text-white",children:"Webhook Endpoints"})}),a.jsxs(St,{className:"space-y-3 text-sm",children:[a.jsxs("p",{className:"text-bambu-gray",children:["Use your API key in the ",a.jsx("code",{className:"text-bambu-green",children:"X-API-Key"})," header."]}),a.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-blue-400",children:"GET"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/status"}),a.jsx("span",{className:"text-bambu-gray",children:" - Get all printer status"})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-blue-400",children:"GET"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/status/:id"}),a.jsx("span",{className:"text-bambu-gray",children:" - Get specific printer status"})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-green-400",children:"POST"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/queue"}),a.jsx("span",{className:"text-bambu-gray",children:" - Add to print queue"})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-orange-400",children:"POST"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/pause"}),a.jsx("span",{className:"text-bambu-gray",children:" - Pause print"})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-orange-400",children:"POST"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/resume"}),a.jsx("span",{className:"text-bambu-gray",children:" - Resume print"})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-red-400",children:"POST"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/stop"}),a.jsx("span",{className:"text-bambu-gray",children:" - Stop print"})]})]})]})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"mb-6",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(ah,{className:"w-5 h-5 text-bambu-green"}),"API Browser"]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Explore and test all available API endpoints."})]}),a.jsx(wt,{className:"mb-4",children:a.jsxs(St,{className:"py-3",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"API Key for Testing"}),a.jsx("input",{type:"text",value:z,onChange:le=>re(le.target.value),placeholder:"Paste your API key here to test authenticated endpoints...",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm focus:border-bambu-green focus:outline-none"}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["This key will be sent as ",a.jsx("code",{className:"text-bambu-green",children:"X-API-Key"})," header with requests."]})]})}),a.jsx(OKe,{apiKey:z})]})]}),ce==="virtual-printer"&&a.jsx(AKe,{}),ce==="filament"&&E&&a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[a.jsx("div",{className:"flex-1 lg:max-w-xl",children:a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),a.jsxs(St,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Configure color thresholds for AMS humidity and temperature indicators."}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-white",children:[a.jsx(kD,{className:"w-4 h-4 text-blue-400"}),a.jsx("span",{className:"font-medium",children:"Humidity"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (green) ≤"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"0",max:"100",value:E.ams_humidity_good??40,onChange:le=>hn("ams_humidity_good",parseInt(le.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"}),a.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"0",max:"100",value:E.ams_humidity_fair??60,onChange:le=>hn("ams_humidity_fair",parseInt(le.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"}),a.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (bad)"})]}),a.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 text-white",children:[a.jsx(yN,{className:"w-4 h-4 text-orange-400"}),a.jsx("span",{className:"font-medium",children:"Temperature"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (blue) ≤"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:E.ams_temp_good??28,onChange:le=>hn("ams_temp_good",parseFloat(le.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"}),a.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:E.ams_temp_fair??35,onChange:le=>hn("ams_temp_fair",parseFloat(le.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"}),a.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (hot)"})]}),a.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 text-white",children:[a.jsx(Nu,{className:"w-4 h-4 text-purple-400"}),a.jsx("span",{className:"font-medium",children:"History Retention"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Keep sensor history for"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"1",max:"365",value:E.ams_history_retention_days??30,onChange:le=>hn("ams_history_retention_days",parseInt(le.target.value)||30),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"days"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Older humidity and temperature data will be automatically deleted"})]}),a.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 text-white",children:[a.jsx(Ir,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"font-medium",children:"Print Modal"})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-white",children:"Expand custom mapping by default"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:"When printing to multiple printers, show per-printer AMS mapping expanded"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:E.per_printer_mapping_expanded??!1,onChange:le=>hn("per_printer_mapping_expanded",le.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})]})]})]})}),a.jsx("div",{className:"flex-1 lg:max-w-xl",children:a.jsx(EKe,{})})]}),J!==null&&a.jsx(Yn,{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:()=>{Zt.mutate(J),Q(null)},onCancel:()=>Q(null)}),A&&a.jsx(pKe,{plug:F,onClose:()=>{R(!1),O(null)}}),H&&a.jsx(bKe,{provider:G,onClose:()=>{j(!1),$(null)}}),q&&a.jsx(yKe,{template:q,onClose:()=>Y(null)}),Z&&a.jsx(wKe,{onClose:()=>oe(!1)}),Ee&&a.jsx(Yn,{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()=>{_e(!1);try{const le=await ue.clearNotificationLogs(30);o(le.message,"success")}catch{o("Failed to clear logs","error")}},onCancel:()=>_e(!1)}),Te&&a.jsx(Yn,{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:()=>{V(!1),localStorage.clear(),o("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>V(!1)}),L&&a.jsx(Yn,{title:`Turn All Plugs ${L==="on"?"On":"Off"}`,message:`This will turn ${L==="on"?"ON":"OFF"} all ${Oe?.filter(le=>le.enabled).length||0} enabled smart plugs. ${L==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${L==="on"?"On":"Off"}`,variant:L==="off"?"danger":"warning",onConfirm:()=>{const le=L;X(null),Vl.mutate(le)},onCancel:()=>X(null)}),te&&cn?.release_notes&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>Me(!1),children:a.jsxs(wt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:le=>le.stopPropagation(),children:[a.jsxs(Hn,{className:"flex flex-row items-center justify-between shrink-0",children:[a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Release Notes - v",cn.latest_version]}),cn.release_name&&cn.release_name!==cn.latest_version&&a.jsx("p",{className:"text-sm text-bambu-gray",children:cn.release_name})]}),a.jsx("button",{onClick:()=>Me(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsx(St,{className:"overflow-y-auto flex-1",children:a.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:cn.release_notes})}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[cn.release_url&&a.jsx("a",{href:cn.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:a.jsxs(Ne,{variant:"secondary",className:"w-full",children:[a.jsx(Yr,{className:"w-4 h-4"}),"View on GitHub"]})}),a.jsx(Ne,{onClick:()=>Me(!1),className:"flex-1",children:"Close"})]})]})}),ce==="users"&&a.jsxs("div",{className:"space-y-6",children:[a.jsx(wt,{children:a.jsx(St,{className:"py-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${l?"bg-green-500/20":"bg-gray-500/20"}`,children:l?a.jsx(rT,{className:"w-5 h-5 text-green-400"}):a.jsx(nT,{className:"w-5 h-5 text-gray-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-white font-medium",children:"Authentication"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:l?"Your instance is secured with user authentication":"Enable to require login and manage user access"})]})]}),l?c?.is_admin&&a.jsxs(Ne,{variant:"secondary",onClick:()=>De(!0),children:[a.jsx(nT,{className:"w-4 h-4"}),"Disable"]}):a.jsxs(Ne,{onClick:()=>e("/setup"),children:[a.jsx(rT,{className:"w-4 h-4"}),"Enable"]})]})})}),l&&a.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-6",children:[a.jsxs("div",{className:"space-y-6",children:[c&&a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(fg,{className:"w-5 h-5 text-bambu-green"}),"Current User"]}),a.jsxs(Ne,{size:"sm",variant:"ghost",onClick:()=>$e(!0),children:[a.jsx(Ho,{className:"w-4 h-4"}),"Change Password"]})]})}),a.jsx(St,{children:a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium text-lg",children:c.username}),a.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[c.is_admin&&a.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-purple-500/20 text-purple-300",children:"Admin"}),c.groups?.map(le=>a.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${le.name==="Administrators"?"bg-purple-500/20 text-purple-300":le.name==="Operators"?"bg-blue-500/20 text-blue-300":le.name==="Viewers"?"bg-green-500/20 text-green-300":"bg-gray-500/20 text-gray-300"}`,children:le.name},le.id))]})]})})})]}),a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(fg,{className:"w-5 h-5 text-bambu-green"}),"Users"]}),gn("users:create")&&a.jsxs(Ne,{size:"sm",onClick:()=>{Be(!0),It({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:[a.jsx(lr,{className:"w-4 h-4"}),"Add User"]})]})}),a.jsx(St,{children:br?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(ct,{className:"w-6 h-6 text-bambu-green animate-spin"})}):tr.length===0?a.jsx("p",{className:"text-center text-bambu-gray py-8",children:"No users found"}):a.jsx("div",{className:"divide-y divide-bambu-dark-tertiary",children:tr.map(le=>a.jsxs("div",{className:"py-3 flex items-center justify-between",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-white font-medium truncate",children:le.username}),a.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[le.is_admin&&a.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-purple-500/20 text-purple-300",children:"Admin"}),le.groups?.map(_t=>a.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${_t.name==="Administrators"?"bg-purple-500/20 text-purple-300":_t.name==="Operators"?"bg-blue-500/20 text-blue-300":_t.name==="Viewers"?"bg-green-500/20 text-green-300":"bg-gray-500/20 text-gray-300"}`,children:_t.name},_t.id))]})]}),a.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[gn("users:update")&&a.jsx(Ne,{size:"sm",variant:"ghost",onClick:()=>Bi(le),children:a.jsx(hg,{className:"w-4 h-4"})}),gn("users:delete")&&le.id!==c?.id&&a.jsx(Ne,{size:"sm",variant:"ghost",onClick:()=>rs(le.id),children:a.jsx(an,{className:"w-4 h-4"})})]})]},le.id))})})]})]}),a.jsx("div",{children:a.jsxs(wt,{children:[a.jsx(Hn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(iT,{className:"w-5 h-5 text-bambu-green"}),"Groups"]}),gn("groups:create")&&a.jsxs(Ne,{size:"sm",onClick:()=>{vn(!0),No()},children:[a.jsx(lr,{className:"w-4 h-4"}),"Add Group"]})]})}),a.jsx(St,{children:sn?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(ct,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Fa.length===0?a.jsx("p",{className:"text-center text-bambu-gray py-8",children:"No groups found"}):a.jsx("div",{className:"divide-y divide-bambu-dark-tertiary",children:Fa.map(le=>a.jsxs("div",{className:"py-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(iT,{className:`w-4 h-4 ${le.name==="Administrators"?"text-purple-400":le.name==="Operators"?"text-blue-400":le.name==="Viewers"?"text-green-400":"text-bambu-gray"}`}),a.jsx("span",{className:"text-white font-medium",children:le.name}),le.is_system&&a.jsx("span",{className:"px-2 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:"System"})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[gn("groups:update")&&a.jsx(Ne,{size:"sm",variant:"ghost",onClick:()=>Hh(le),children:a.jsx(hg,{className:"w-4 h-4"})}),gn("groups:delete")&&!le.is_system&&a.jsx(Ne,{size:"sm",variant:"ghost",onClick:()=>Jn(le.id),children:a.jsx(an,{className:"w-4 h-4"})})]})]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1 ml-6",children:le.description||"No description"}),a.jsxs("div",{className:"flex items-center gap-4 mt-2 ml-6 text-xs text-bambu-gray",children:[a.jsxs("span",{children:[le.user_count," users"]}),a.jsxs("span",{children:[le.permissions.length," permissions"]})]})]},le.id))})})]})})]}),!l&&a.jsx(wt,{children:a.jsx(St,{className:"py-6",children:a.jsxs("div",{className:"text-center",children:[a.jsx(nT,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"Authentication is Disabled"}),a.jsx("p",{className:"text-sm text-bambu-gray mb-4 max-w-md mx-auto",children:"Enable authentication to create user accounts, manage permissions, and secure your Bambuddy instance."}),a.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray mb-6 text-left max-w-xs mx-auto",children:[a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(Tr,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:"Require login to access the system"})]}),a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(Tr,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:"Create multiple users with group-based permissions"})]}),a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(Tr,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:"Control access with 50+ granular permissions"})]})]}),a.jsxs(Ne,{onClick:()=>e("/setup"),children:[a.jsx(rT,{className:"w-4 h-4"}),"Enable Authentication"]})]})})})]}),Se&&a.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{Be(!1),It({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsxs(wt,{className:"w-full max-w-md",onClick:le=>le.stopPropagation(),children:[a.jsx(Hn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(fg,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Create User"})]}),a.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>{Be(!1),It({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsx(Dt,{className:"w-5 h-5"})})]})}),a.jsxs(St,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Username"}),a.jsx("input",{type:"text",value:ut.username,onChange:le=>It({...ut,username:le.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter username",autoComplete:"username"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Password"}),a.jsx("input",{type:"password",value:ut.password,onChange:le=>It({...ut,password:le.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter password (min 6 characters)",autoComplete:"new-password",minLength:6})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Confirm Password"}),a.jsx("input",{type:"password",value:ut.confirmPassword,onChange:le=>It({...ut,confirmPassword:le.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${ut.confirmPassword&&ut.password!==ut.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:"Confirm password",autoComplete:"new-password",minLength:6}),ut.confirmPassword&&ut.password!==ut.confirmPassword&&a.jsx("p",{className:"text-red-400 text-xs mt-1",children:"Passwords do not match"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Groups"}),a.jsxs("div",{className:"space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg",children:[Fa.map(le=>a.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:ut.group_ids.includes(le.id),onChange:()=>Ux(le.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),a.jsx("span",{className:"text-sm text-white",children:le.name}),le.is_system&&a.jsx("span",{className:"text-xs text-yellow-400",children:"(System)"})]},le.id)),Fa.length===0&&a.jsx("p",{className:"text-sm text-bambu-gray",children:"No groups available"})]})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Ne,{variant:"secondary",onClick:()=>{Be(!1),It({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:"Cancel"}),a.jsx(Ne,{onClick:Ua,disabled:ns.isPending||!ut.username||!ut.password||ut.password!==ut.confirmPassword||ut.password.length<6,children:ns.isPending?a.jsxs(a.Fragment,{children:[a.jsx(ct,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):a.jsxs(a.Fragment,{children:[a.jsx(lr,{className:"w-4 h-4"}),"Create User"]})})]})]})]})}),ft&&tt!==null&&a.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{we(!1),ke(null),It({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsxs(wt,{className:"w-full max-w-md",onClick:le=>le.stopPropagation(),children:[a.jsx(Hn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(hg,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Edit User"})]}),a.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>{we(!1),ke(null),It({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsx(Dt,{className:"w-5 h-5"})})]})}),a.jsxs(St,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Username"}),a.jsx("input",{type:"text",value:ut.username,onChange:le=>It({...ut,username:le.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter username",autoComplete:"username"})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:["Password ",a.jsx("span",{className:"text-bambu-gray font-normal",children:"(leave blank to keep current)"})]}),a.jsx("input",{type:"password",value:ut.password,onChange:le=>It({...ut,password:le.target.value,confirmPassword:""}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter new password",autoComplete:"new-password",minLength:6})]}),ut.password&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Confirm Password"}),a.jsx("input",{type:"password",value:ut.confirmPassword,onChange:le=>It({...ut,confirmPassword:le.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${ut.confirmPassword&&ut.password!==ut.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:"Confirm new password",autoComplete:"new-password",minLength:6}),ut.confirmPassword&&ut.password!==ut.confirmPassword&&a.jsx("p",{className:"text-red-400 text-xs mt-1",children:"Passwords do not match"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Groups"}),a.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg",children:Fa.map(le=>a.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:ut.group_ids.includes(le.id),onChange:()=>Ux(le.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),a.jsx("span",{className:"text-sm text-white",children:le.name}),le.is_system&&a.jsx("span",{className:"text-xs text-yellow-400",children:"(System)"})]},le.id))})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Ne,{variant:"secondary",onClick:()=>{we(!1),ke(null),It({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:"Cancel"}),a.jsx(Ne,{onClick:()=>$l(tt),disabled:So.isPending||!ut.username||!!(ut.password&&(ut.password!==ut.confirmPassword||ut.password.length<6)),children:So.isPending?a.jsxs(a.Fragment,{children:[a.jsx(ct,{className:"w-4 h-4 animate-spin"}),"Saving..."]}):a.jsxs(a.Fragment,{children:[a.jsx(ms,{className:"w-4 h-4"}),"Save Changes"]})})]})]})]})}),We!==null&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:()=>{pe(null),de(null)},children:a.jsxs(wt,{className:"w-full max-w-md",onClick:le=>le.stopPropagation(),children:[a.jsx(Hn,{children:a.jsxs("div",{className:"flex items-center gap-2 text-red-400",children:[a.jsx(an,{className:"w-5 h-5"}),a.jsx("h3",{className:"text-lg font-semibold",children:"Delete User"})]})}),a.jsx(St,{className:"space-y-4",children:Ve?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-2 border-bambu-green border-t-transparent"})}):Ce&&Ce.archives+Ce.queue_items+Ce.library_files>0?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-white",children:"This user has created:"}),a.jsxs("ul",{className:"list-disc list-inside text-bambu-gray space-y-1",children:[Ce.archives>0&&a.jsxs("li",{children:[Ce.archives," archive",Ce.archives!==1?"s":""]}),Ce.queue_items>0&&a.jsxs("li",{children:[Ce.queue_items," queue item",Ce.queue_items!==1?"s":""]}),Ce.library_files>0&&a.jsxs("li",{children:[Ce.library_files," library file",Ce.library_files!==1?"s":""]})]}),a.jsx("p",{className:"text-bambu-gray text-sm",children:"What would you like to do with these items?"}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(Ne,{variant:"danger",onClick:()=>aa.mutate({id:We,deleteItems:!0}),disabled:aa.isPending,className:"justify-center",children:"Delete user AND their items"}),a.jsx(Ne,{variant:"secondary",onClick:()=>aa.mutate({id:We,deleteItems:!1}),disabled:aa.isPending,className:"justify-center",children:"Delete user, keep items (become ownerless)"}),a.jsx(Ne,{variant:"ghost",onClick:()=>{pe(null),de(null)},disabled:aa.isPending,className:"justify-center",children:"Cancel"})]})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-white",children:"Are you sure you want to delete this user?"}),a.jsx("p",{className:"text-bambu-gray text-sm",children:"This action cannot be undone."}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx(Ne,{variant:"ghost",onClick:()=>{pe(null),de(null)},disabled:aa.isPending,children:"Cancel"}),a.jsx(Ne,{variant:"danger",onClick:()=>aa.mutate({id:We,deleteItems:!1}),disabled:aa.isPending,children:"Delete User"})]})]})})]})}),(Ft||Kt)&&a.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{vn(!1),cr(null),No()},children:a.jsxs(wt,{className:"w-full max-w-2xl max-h-[90vh] overflow-y-auto",onClick:le=>le.stopPropagation(),children:[a.jsx(Hn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(iT,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:Kt?"Edit Group":"Create Group"})]}),a.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>{vn(!1),cr(null),No()},children:a.jsx(Dt,{className:"w-5 h-5"})})]})}),a.jsxs(St,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Group Name"}),a.jsx("input",{type:"text",value:ln.name,onChange:le=>Gn({...ln,name:le.target.value}),disabled:Kt?.is_system,className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors disabled:opacity-50",placeholder:"Enter group name"}),Kt?.is_system&&a.jsx("p",{className:"text-xs text-yellow-400 mt-1",children:"System group names cannot be changed"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Description"}),a.jsx("textarea",{value:ln.description,onChange:le=>Gn({...ln,description:le.target.value}),rows:2,className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors resize-none",placeholder:"Enter description (optional)"})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:["Permissions (",ln.permissions.length," selected)"]}),a.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:Sn?.categories.map(le=>a.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary cursor-pointer hover:bg-bambu-dark-tertiary transition-colors",onClick:()=>Hl(le.name),children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{type:"button",onClick:_t=>{_t.stopPropagation(),Pm(le,!Rm(le))},className:`w-5 h-5 rounded border flex items-center justify-center transition-colors ${Rm(le)?"bg-bambu-green border-bambu-green":Vh(le)?"bg-bambu-green/50 border-bambu-green":"border-bambu-gray hover:border-white"}`,children:(Rm(le)||Vh(le))&&a.jsx(Wi,{className:"w-3 h-3 text-white"})}),a.jsx("span",{className:"text-white font-medium",children:le.name}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:["(",le.permissions.filter(_t=>ln.permissions.includes(_t.value)).length,"/",le.permissions.length,")"]})]}),nr.has(le.name)?a.jsx(Xr,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(vs,{className:"w-4 h-4 text-bambu-gray"})]}),nr.has(le.name)&&a.jsx("div",{className:"p-3 bg-bambu-dark space-y-2",children:le.permissions.map(_t=>a.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-secondary cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:ln.permissions.includes(_t.value),onChange:()=>Bx(_t.value),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark-secondary"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:_t.label})]},_t.value))})]},le.name))})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Ne,{variant:"secondary",onClick:()=>{vn(!1),cr(null),No()},children:"Cancel"}),a.jsx(Ne,{onClick:Kt?zx:ml,disabled:fl.isPending||is.isPending||!ln.name.trim(),children:fl.isPending||is.isPending?a.jsxs(a.Fragment,{children:[a.jsx(ct,{className:"w-4 h-4 animate-spin"}),Kt?"Saving...":"Creating..."]}):a.jsxs(a.Fragment,{children:[a.jsx(ms,{className:"w-4 h-4"}),Kt?"Save Changes":"Create Group"]})})]})]})]})}),dr!==null&&a.jsx(Yn,{title:"Delete Group",message:"Are you sure you want to delete this group? Users in this group will lose these permissions.",confirmText:"Delete Group",variant:"danger",onConfirm:()=>{si.mutate(dr),Jn(null)},onCancel:()=>Jn(null)}),ce==="backup"&&a.jsx(jKe,{}),ie&&a.jsx(Yn,{title:"Disable Authentication",message:"Are you sure you want to disable authentication? This will make your Bambuddy instance accessible without login. All users will remain in the database but authentication will be disabled.",confirmText:"Disable Authentication",variant:"danger",onConfirm:async()=>{try{await ue.disableAuth(),o("Authentication disabled successfully","success"),await u(),De(!1),window.location.href="/"}catch(le){const _t=le instanceof Error?le.message:"Failed to disable authentication";o(_t,"error")}},onCancel:()=>De(!1)}),Le&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>{$e(!1),Ie({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsxs(wt,{className:"w-full max-w-md",onClick:le=>le.stopPropagation(),children:[a.jsx(Hn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ho,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Change Password"})]}),a.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>{$e(!1),Ie({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsx(Dt,{className:"w-5 h-5"})})]})}),a.jsxs(St,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Current Password"}),a.jsx("input",{type:"password",value:Ze.currentPassword,onChange:le=>Ie({...Ze,currentPassword:le.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter current password",autoComplete:"current-password"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"New Password"}),a.jsx("input",{type:"password",value:Ze.newPassword,onChange:le=>Ie({...Ze,newPassword:le.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter new password (min 6 characters)",autoComplete:"new-password",minLength:6})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Confirm New Password"}),a.jsx("input",{type:"password",value:Ze.confirmPassword,onChange:le=>Ie({...Ze,confirmPassword:le.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${Ze.confirmPassword&&Ze.newPassword!==Ze.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:"Confirm new password",autoComplete:"new-password",minLength:6}),Ze.confirmPassword&&Ze.newPassword!==Ze.confirmPassword&&a.jsx("p",{className:"text-red-400 text-xs mt-1",children:"Passwords do not match"})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Ne,{variant:"secondary",onClick:()=>{$e(!1),Ie({currentPassword:"",newPassword:"",confirmPassword:""})},children:"Cancel"}),a.jsx(Ne,{onClick:async()=>{if(Ze.newPassword!==Ze.confirmPassword){o("Passwords do not match","error");return}if(Ze.newPassword.length<6){o("Password must be at least 6 characters","error");return}He(!0);try{await ue.changePassword(Ze.currentPassword,Ze.newPassword),o("Password changed successfully","success"),$e(!1),Ie({currentPassword:"",newPassword:"",confirmPassword:""})}catch(le){const _t=le instanceof Error?le.message:"Failed to change password";o(_t,"error")}finally{He(!1)}},disabled:ae||!Ze.currentPassword||!Ze.newPassword||Ze.newPassword!==Ze.confirmPassword||Ze.newPassword.length<6,children:ae?a.jsxs(a.Fragment,{children:[a.jsx(ct,{className:"w-4 h-4 animate-spin"}),"Changing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Ho,{className:"w-4 h-4"}),"Change Password"]})})]})]})]})})]})}const $re=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},FKe=t=>t.startsWith("HH")?"HF":"S",UKe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},dD=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 Vj({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:s,note:o}){const l=FKe(t.nozzle_id),c=t.nozzle_diameter,u=()=>{r&&s?s():e()};return a.jsxs("div",{className:"flex items-center gap-2",children:[r&&a.jsx("button",{onClick:s,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?a.jsx(Vs,{className:"w-4 h-4 text-bambu-green"}):a.jsx(il,{className:"w-4 h-4"})}),a.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:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:$re(t.k_value)}),a.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),o&&a.jsx("span",{title:"Has note",children:a.jsx(jW,{className:"w-3 h-3 text-yellow-500"})}),a.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[l," ",c]})]}),o&&a.jsxs("div",{className:"text-xs mt-0.5 truncate text-yellow-500/70",title:o,children:["Note: ",o.length>50?o.substring(0,50)+"...":o]})]}),!r&&n&&a.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:a.jsx(Ll,{className:"w-4 h-4"})})]})}function Gj({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:s="",initialNoteKey:o=null,onClose:l,onSave:c,onSaveNote:u,hasPermission:d}){const{showToast:f}=Vn(),[m,p]=w.useState(t?.name||""),[x,b]=w.useState(t?.k_value?$re(t.k_value):"0.020"),[y,v]=w.useState(t?.filament_id||""),[S,N]=w.useState(t?.nozzle_id?UKe(t.nozzle_id):"HH00"),[C,T]=w.useState(t?.nozzle_diameter||n),[k,E]=w.useState(t?[t.extruder_id]:i?[0,1]:[0]),[D,A]=w.useState(!1),[R,F]=w.useState({current:0,total:0}),[O,H]=w.useState(s),j=Kr.useMemo(()=>{const B=new Map;for(const W of r)if(W.filament_id&&!B.has(W.filament_id)){const se=dD(W.name||"");B.set(W.filament_id,{id:W.filament_id,name:se||W.filament_id})}return Array.from(B.values()).sort((W,se)=>W.name.localeCompare(se.name))},[r]),G=mt({mutationFn:B=>(console.log("[KProfile] Calling API..."),ue.setKProfile(e,B)),onSuccess:B=>{if(console.log("[KProfile] Save success:",B),f("K-profile saved"),u&&O!==s){let W;O===""&&o?W=o:t&&t.slot_id>0?W=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:W=`name_${m}_${y}`,u(W,O)}A(!0),setTimeout(()=>{A(!1),c()},2500)},onError:B=>{console.error("[KProfile] Save error:",B),f(B.message,"error"),A(!1)}}),$=mt({mutationFn:B=>(console.log("[KProfile] Deleting profile..."),ue.deleteKProfile(e,B)),onSuccess:B=>{console.log("[KProfile] Delete success:",B),f("K-profile deleted"),A(!0),setTimeout(()=>{A(!1),l()},4e3)},onError:B=>{console.error("[KProfile] Delete error:",B),f(B.message,"error"),A(!1)}}),[q,Y]=w.useState(!1),Z=()=>{t&&$.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})},oe=async B=>{if(B.preventDefault(),i&&!t&&k.length===0){f("Please select at least one extruder","error");return}const W=parseFloat(x).toFixed(6),se=`${S}-${C}`;if(t||k.length===1){const ce={name:m,k_value:W,filament_id:y,nozzle_id:se,nozzle_diameter:C,extruder_id:t?t.extruder_id:k[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",ce),G.mutate(ce);return}A(!0),F({current:1,total:k.length});const ne=k.map(ce=>({name:m,k_value:W,filament_id:y,nozzle_id:se,nozzle_diameter:C,extruder_id:ce,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${ne.length} profiles in batch:`,ne);try{if(await ue.setKProfilesBatch(e,ne),f(`K-profile saved to ${k.length} extruders`),u&&O){const ce=`name_${m}_${y}`;u(ce,O)}}catch(ce){console.error("[KProfile] Failed to save batch:",ce),f("Failed to save K-profiles","error"),A(!1),F({current:0,total:0});return}F({current:k.length,total:k.length}),setTimeout(()=>{A(!1),F({current:0,total:0}),c()},3e3)};return a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[a.jsxs(wt,{className:"w-full max-w-md relative",children:[D&&a.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[a.jsx(ct,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),a.jsx("p",{className:"text-white font-medium",children:R.total>1?`Saving to extruder ${R.current}/${R.total}...`:"Syncing with printer..."}),a.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),a.jsxs(St,{className:"p-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:t?"Edit K-Profile":"Add K-Profile"}),a.jsx("button",{onClick:l,className:"text-bambu-gray hover:text-white transition-colors",disabled:D,children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:oe,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),a.jsx("input",{type:"text",value:m,onChange:B=>p(B.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})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),a.jsx("input",{type:"text",inputMode:"decimal",value:x,onChange:B=>{const W=B.target.value;(W===""||/^\d*\.?\d*$/.test(W))&&b(W)},onBlur:B=>{const W=parseFloat(B.target.value);isNaN(W)||b((Math.trunc(W*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}),a.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),a.jsxs("select",{value:y,onChange:B=>{const W=B.target.value;if(v(W),!t&&W&&!m){const se=j.find(ne=>ne.id===W);se&&p(`${S==="HH00"?"HF":"S"} ${se.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:[a.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&a.jsx("option",{value:t.filament_id,children:j.find(B=>B.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&j.map(B=>a.jsx("option",{value:B.id,children:B.name},B.id))]}),!t&&j.length===0&&a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),a.jsxs("select",{value:S,onChange:B=>{const W=B.target.value;if(N(W),!t&&y&&!m){const se=j.find(ne=>ne.id===y);se&&p(`${W==="HS00"?"HF":"S"} ${se.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:[a.jsx("option",{value:"HH00",children:"High Flow"}),a.jsx("option",{value:"HS00",children:"Standard"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),a.jsxs("select",{value:C,onChange:B=>T(B.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:[a.jsx("option",{value:"0.2",children:"0.2mm"}),a.jsx("option",{value:"0.4",children:"0.4mm"}),a.jsx("option",{value:"0.6",children:"0.6mm"}),a.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t?"Extruder":"Extruders"}),t?a.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"}):a.jsxs("div",{className:"flex gap-4",children:[a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.includes(1),onChange:B=>{B.target.checked?E([...k,1]):E(k.filter(W=>W!==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"}),a.jsx("span",{className:"text-white",children:"Left"})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.includes(0),onChange:B=>{B.target.checked?E([...k,0]):E(k.filter(W=>W!==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"}),a.jsx("span",{className:"text-white",children:"Right"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes (stored locally)"}),a.jsx("textarea",{value:O,onChange:B=>H(B.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"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Notes are saved in Bambuddy, not on the printer"})]}),a.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&a.jsx(Ne,{type:"button",variant:"secondary",onClick:()=>Y(!0),disabled:$.isPending||D||!d("kprofiles:delete"),title:d("kprofiles:delete")?void 0:"You do not have permission to delete K-profiles",className:"text-red-500 hover:bg-red-500/10",children:$.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(an,{className:"w-4 h-4"})}),a.jsx(Ne,{type:"button",variant:"secondary",onClick:l,disabled:D,className:"flex-1",children:"Cancel"}),a.jsxs(Ne,{type:"submit",disabled:G.isPending||D||!d(t?"kprofiles:update":"kprofiles:create"),title:d(t?"kprofiles:update":"kprofiles:create")?void 0:`You do not have permission to ${t?"update":"create"} K-profiles`,className:"flex-1",children:[G.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(hN,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),q&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:a.jsx(wt,{className:"w-full max-w-sm",children:a.jsxs(St,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:a.jsx(an,{className:"w-5 h-5 text-red-500"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),a.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",a.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(Ne,{variant:"secondary",onClick:()=>Y(!1),className:"flex-1",children:"Cancel"}),a.jsxs(Ne,{onClick:()=>{Y(!1),Z()},disabled:$.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[$.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(an,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const f1={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function zKe(){const{showToast:t}=Vn(),{hasPermission:e}=Si(),[n,r]=w.useState(null),[i,s]=w.useState(()=>localStorage.getItem(f1.NOZZLE_DIAMETER)||"0.4"),[o,l]=w.useState(null),[c,u]=w.useState(!1),[d,f]=w.useState(null),[m,p]=w.useState(""),[x,b]=w.useState("all"),[y,v]=w.useState("all"),[S,N]=w.useState(()=>localStorage.getItem(f1.SORT_OPTION)||"name"),[C,T]=w.useState(!1),[k,E]=w.useState(new Set),[D,A]=w.useState(!1),[R,F]=w.useState(!1),O=w.useCallback(z=>`${z.slot_id}_${z.extruder_id}`,[]);w.useEffect(()=>{localStorage.setItem(f1.NOZZLE_DIAMETER,i)},[i]),w.useEffect(()=>{localStorage.setItem(f1.SORT_OPTION,S)},[S]);const{data:H,isLoading:j}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:G,isLoading:$,isFetching:q,error:Y,refetch:Z}=at({queryKey:["kprofiles",n,i],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",n,"nozzle",i);const z=await ue.getKProfiles(n,i);return console.log("[KProfiles] Received profiles:",z?.profiles?.length||0,"profiles"),z},enabled:!!n,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:oe}=at({queryKey:["kprofiles",n,"0.4"],queryFn:()=>ue.getKProfiles(n,"0.4"),enabled:!!n,staleTime:6e4}),{data:B,refetch:W}=at({queryKey:["kprofile-notes",n],queryFn:()=>ue.getKProfileNotes(n),enabled:!!n,staleTime:3e4}),se=Y?.message?.includes("not connected");w.useEffect(()=>{if(!n&&H&&H.length>0){const z=H.find(re=>re.is_active);z&&r(z.id)}},[n,H]),w.useEffect(()=>{if(n){const z=setTimeout(()=>{Z()},150);return()=>clearTimeout(z)}},[n,i]);const ne=H?.filter(z=>z.is_active)||[],ce=Kr.useMemo(()=>G?.profiles?G.profiles.filter(re=>{const Ee=m.toLowerCase(),_e=!Ee||re.name.toLowerCase().includes(Ee)||re.filament_id.toLowerCase().includes(Ee),Te=x==="all"||x==="left"&&re.extruder_id===1||x==="right"&&re.extruder_id===0,V=y==="all"||y==="hf"&&re.nozzle_id.startsWith("HH")||y==="s"&&re.nozzle_id.startsWith("HS");return _e&&Te&&V}).sort((re,Ee)=>{switch(S){case"k_value":return parseFloat(re.k_value)-parseFloat(Ee.k_value);case"filament":return dD(re.name).localeCompare(dD(Ee.name));case"name":default:return re.name.localeCompare(Ee.name)}}):[],[G?.profiles,m,x,y,S]),fe=H?.find(z=>z.id===n),ye=fe?.nozzle_count===2;w.useEffect(()=>{const z=re=>{re.target instanceof HTMLInputElement||re.target instanceof HTMLTextAreaElement||re.target instanceof HTMLSelectElement||o||c||d||(re.key==="r"||re.key==="R"?(re.preventDefault(),Z()):re.key==="n"||re.key==="N"?(re.preventDefault(),u(!0)):re.key==="Escape"&&C&&(re.preventDefault(),T(!1),E(new Set)))};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[o,c,d,C,Z]);const ge=w.useCallback(()=>{if(!G?.profiles||G.profiles.length===0){t("No profiles to export","error");return}const z={version:1,exported_at:new Date().toISOString(),printer:fe?.name||"Unknown",nozzle_diameter:i,profiles:G.profiles.map(Te=>({name:Te.name,k_value:Te.k_value,filament_id:Te.filament_id,nozzle_id:Te.nozzle_id,nozzle_diameter:Te.nozzle_diameter,extruder_id:Te.extruder_id}))},re=new Blob([JSON.stringify(z,null,2)],{type:"application/json"}),Ee=URL.createObjectURL(re),_e=document.createElement("a");_e.href=Ee,_e.download=`kprofiles_${fe?.name||"printer"}_${i}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(_e),_e.click(),document.body.removeChild(_e),URL.revokeObjectURL(Ee),t(`Exported ${G.profiles.length} profiles`)},[G?.profiles,fe,i,t]),xe=w.useCallback(()=>{const z=document.createElement("input");z.type="file",z.accept=".json",z.onchange=async re=>{const Ee=re.target.files?.[0];if(Ee)try{const _e=await Ee.text(),Te=JSON.parse(_e);if(!Te.profiles||!Array.isArray(Te.profiles)){t("Invalid file format","error");return}let V=0;for(const L of Te.profiles)if(!(!L.name||!L.k_value||!L.filament_id))try{await ue.setKProfile(n,{name:L.name,k_value:parseFloat(L.k_value).toFixed(6),filament_id:L.filament_id,nozzle_id:L.nozzle_id||`HH00-${i}`,nozzle_diameter:L.nozzle_diameter||i,extruder_id:L.extruder_id??0,slot_id:0}),V++,await new Promise(X=>setTimeout(X,500))}catch(X){console.error("Failed to import profile:",L.name,X)}t(`Imported ${V} of ${Te.profiles.length} profiles`),Z()}catch(_e){console.error("Import error:",_e),t("Failed to parse import file","error")}},z.click()},[n,i,t,Z]),Pe=w.useCallback(z=>{E(re=>{const Ee=new Set(re);return Ee.has(z)?Ee.delete(z):Ee.add(z),Ee})},[]),Ue=w.useCallback(()=>{E(new Set(ce.map(z=>O(z))))},[ce,O]),be=w.useCallback(()=>{k.size!==0&&A(!0)},[k.size]),it=w.useCallback(async()=>{const z=ce.filter(Ee=>k.has(O(Ee)));F(!0);let re=0;for(const Ee of z)try{await ue.deleteKProfile(n,{slot_id:Ee.slot_id,extruder_id:Ee.extruder_id,nozzle_id:Ee.nozzle_id,nozzle_diameter:Ee.nozzle_diameter,filament_id:Ee.filament_id,setting_id:Ee.setting_id}),re++,await new Promise(_e=>setTimeout(_e,300))}catch(_e){console.error("Failed to delete profile:",Ee.name,_e)}t(`Deleted ${re} profiles`),F(!1),A(!1),T(!1),E(new Set),Z()},[n,k,ce,t,Z,O]),U=w.useCallback(z=>{const re=[];return z.setting_id&&re.push(z.setting_id),re.push(`slot_${z.slot_id}_${z.filament_id}_${z.extruder_id}`),re.push(`name_${z.name}_${z.filament_id}`),re},[]),K=w.useCallback(async(z,re)=>{if(n)try{await ue.setKProfileNote(n,z,re),W()}catch(Ee){console.error("Failed to save note:",Ee),t("Failed to save note","error")}},[n,W,t]),J=w.useCallback(z=>{if(!B?.notes)return{note:"",key:null};const re=U(z);for(const Ee of re)if(B.notes[Ee])return{note:B.notes[Ee],key:Ee};return{note:"",key:null}},[B,U]),Q=w.useCallback(z=>J(z).note,[J]);return j?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(ct,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!H||H.length===0?a.jsx(wt,{children:a.jsxs(St,{className:"py-12 text-center",children:[a.jsx(Ii,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),a.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):ne.length===0?a.jsx(wt,{children:a.jsxs(St,{className:"py-12 text-center",children:[a.jsx(Ir,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),a.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):a.jsxs(a.Fragment,{children:[q&&!$&&a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[a.jsx(ct,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),a.jsx("p",{className:"text-white font-medium",children:"Loading K-Profiles..."})]}),a.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[a.jsxs("div",{className:"flex-1 min-w-48",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),a.jsx("select",{value:n||"",onChange:z=>r(parseInt(z.target.value)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:ne.map(z=>a.jsx("option",{value:z.id,children:z.name},z.id))})]}),a.jsxs("div",{className:"w-32",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),a.jsxs("select",{value:i,onChange:z=>s(z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"0.2",children:"0.2mm"}),a.jsx("option",{value:"0.4",children:"0.4mm"}),a.jsx("option",{value:"0.6",children:"0.6mm"}),a.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),a.jsxs("div",{className:"flex items-end gap-2",children:[a.jsxs(Ne,{variant:"secondary",onClick:()=>Z(),disabled:q||!e("kprofiles:read"),title:e("kprofiles:read")?void 0:"You do not have permission to refresh profiles",children:[a.jsx(Pr,{className:`w-4 h-4 ${q?"animate-spin":""}`}),"Refresh"]}),a.jsxs(Ne,{onClick:()=>u(!0),disabled:!e("kprofiles:create"),title:e("kprofiles:create")?void 0:"You do not have permission to add profiles",children:[a.jsx(lr,{className:"w-4 h-4"}),"Add Profile"]})]})]}),a.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[a.jsxs("div",{className:"flex-1 min-w-48 relative",children:[a.jsx(pa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:m,onChange:z=>p(z.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"})]}),ye&&a.jsx("div",{className:"w-36",children:a.jsxs("select",{value:x,onChange:z=>b(z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"all",children:"All Extruders"}),a.jsx("option",{value:"left",children:"Left Only"}),a.jsx("option",{value:"right",children:"Right Only"})]})}),a.jsx("div",{className:"w-32",children:a.jsxs("select",{value:y,onChange:z=>v(z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"all",children:"All Flow"}),a.jsx("option",{value:"hf",children:"HF Only"}),a.jsx("option",{value:"s",children:"S Only"})]})}),a.jsx("div",{className:"w-32",children:a.jsxs("select",{value:S,onChange:z=>N(z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"name",children:"Sort: Name"}),a.jsx("option",{value:"k_value",children:"Sort: K-Value"}),a.jsx("option",{value:"filament",children:"Sort: Filament"})]})})]}),a.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[a.jsxs(Ne,{variant:"secondary",onClick:ge,disabled:!G?.profiles?.length||!e("kprofiles:read"),title:e("kprofiles:read")?"Export profiles to JSON":"You do not have permission to export profiles",children:[a.jsx(pi,{className:"w-4 h-4"}),"Export"]}),a.jsxs(Ne,{variant:"secondary",onClick:xe,disabled:!e("kprofiles:create"),title:e("kprofiles:create")?"Import profiles from JSON":"You do not have permission to import profiles",children:[a.jsx(Oa,{className:"w-4 h-4"}),"Import"]}),a.jsx("div",{className:"flex-1"}),C?a.jsxs(a.Fragment,{children:[a.jsxs(Ne,{variant:"secondary",onClick:Ue,title:"Select all visible profiles",children:[a.jsx(Vs,{className:"w-4 h-4"}),"Select All"]}),a.jsxs(Ne,{variant:"secondary",onClick:be,disabled:k.size===0||!e("kprofiles:delete"),className:"text-red-500 hover:bg-red-500/10",title:e("kprofiles:delete")?`Delete ${k.size} selected profiles`:"You do not have permission to delete profiles",children:[a.jsx(an,{className:"w-4 h-4"}),"Delete (",k.size,")"]}),a.jsxs(Ne,{variant:"secondary",onClick:()=>{T(!1),E(new Set)},children:[a.jsx(Dt,{className:"w-4 h-4"}),"Cancel"]})]}):a.jsxs(Ne,{variant:"secondary",onClick:()=>T(!0),disabled:!ce.length||!e("kprofiles:delete"),title:e("kprofiles:delete")?"Enter selection mode for bulk delete":"You do not have permission to delete profiles",children:[a.jsx(Vs,{className:"w-4 h-4"}),"Select"]})]}),$?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(ct,{className:"w-8 h-8 text-bambu-green animate-spin"})}):se?a.jsx(wt,{children:a.jsxs(St,{className:"py-12 text-center",children:[a.jsx(sm,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),a.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),a.jsxs(Ne,{variant:"secondary",onClick:()=>Z(),children:[a.jsx(Pr,{className:"w-4 h-4"}),"Retry"]})]})}):ce.length>0?ye?a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),a.jsx("div",{className:"space-y-1",children:ce.filter(z=>z.extruder_id===1).map(z=>a.jsx(Vj,{profile:z,onEdit:()=>l(z),onCopy:()=>f(z),selectionMode:C,isSelected:k.has(O(z)),onToggleSelect:()=>Pe(O(z)),note:Q(z)},O(z)))})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),a.jsx("div",{className:"space-y-1",children:ce.filter(z=>z.extruder_id===0).map(z=>a.jsx(Vj,{profile:z,onEdit:()=>l(z),onCopy:()=>f(z),selectionMode:C,isSelected:k.has(O(z)),onToggleSelect:()=>Pe(O(z)),note:Q(z)},O(z)))})]})]}):a.jsx("div",{className:"space-y-1",children:ce.map(z=>a.jsx(Vj,{profile:z,onEdit:()=>l(z),onCopy:()=>f(z),selectionMode:C,isSelected:k.has(O(z)),onToggleSelect:()=>Pe(O(z)),note:Q(z)},O(z)))}):m||x!=="all"||y!=="all"?a.jsx(wt,{children:a.jsxs(St,{className:"py-12 text-center",children:[a.jsx(pa,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),a.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):a.jsx(wt,{children:a.jsxs(St,{className:"py-12 text-center",children:[a.jsx(hN,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),a.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",i,"mm nozzle"]}),a.jsxs(Ne,{onClick:()=>u(!0),children:[a.jsx(lr,{className:"w-4 h-4"}),"Create First Profile"]})]})}),o&&n&&(()=>{const{note:z,key:re}=J(o);return a.jsx(Gj,{profile:o,printerId:n,nozzleDiameter:i,existingProfiles:oe?.profiles||G?.profiles,isDualNozzle:ye,initialNote:z,initialNoteKey:re,onSaveNote:K,hasPermission:e,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),l(null),Z()},onSave:()=>{l(null),Z()}})})(),c&&n&&a.jsx(Gj,{printerId:n,nozzleDiameter:i,existingProfiles:oe?.profiles||G?.profiles,isDualNozzle:ye,onSaveNote:K,hasPermission:e,onClose:()=>{u(!1),Z()},onSave:()=>{u(!1),Z()}}),d&&n&&a.jsx(Gj,{printerId:n,nozzleDiameter:i,existingProfiles:oe?.profiles||G?.profiles,isDualNozzle:ye,onSaveNote:K,hasPermission:e,profile:{...d,slot_id:0,name:`${d.name} (Copy)`},onClose:()=>{f(null),Z()},onSave:()=>{f(null),Z()}}),D&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(wt,{className:"w-full max-w-sm",children:a.jsxs(St,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:a.jsx(an,{className:"w-5 h-5 text-red-500"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profiles"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),a.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",a.jsx("span",{className:"text-white font-medium",children:k.size})," selected profiles from the printer?"]}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(Ne,{variant:"secondary",onClick:()=>A(!1),disabled:R,className:"flex-1",children:"Cancel"}),a.jsxs(Ne,{onClick:it,disabled:R,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[R?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(an,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function h5(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),o=s?(s[1]||s[2])+"mm":null,l=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),c=l?l[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:o,layerHeight:c,filamentType:d}}function Dy(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function BKe(t){const e=Ri(t);if(!e)return"";const r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4),s=Math.floor(r/36e5),o=Math.floor(r/864e5);return i<1?"Just now":i<60?`${i}m ago`:s<24?`${s}h ago`:o<7?`${o}d ago`:e.toLocaleDateString()}function $Ke({onSuccess:t}){const{showToast:e}=Vn(),[n,r]=w.useState("email"),[i,s]=w.useState(""),[o,l]=w.useState(""),[c,u]=w.useState(""),[d,f]=w.useState(""),[m,p]=w.useState("global"),x=mt({mutationFn:()=>ue.cloudLogin(i,o,m),onSuccess:N=>{N.success?(e("Logged in successfully"),t()):N.needs_verification?(e("Verification code sent to your email"),r("code")):e(N.message,"error")},onError:N=>e(N.message,"error")}),b=mt({mutationFn:()=>ue.cloudVerify(i,c),onSuccess:N=>{N.success?(e("Logged in successfully"),t()):e(N.message,"error")},onError:N=>e(N.message,"error")}),y=mt({mutationFn:()=>ue.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:N=>e(N.message,"error")}),v=N=>{N.preventDefault(),n==="email"?x.mutate():n==="code"?b.mutate():n==="token"&&y.mutate()},S=x.isPending||b.isPending||y.isPending;return a.jsx(wt,{className:"max-w-md mx-auto",children:a.jsxs(St,{children:[a.jsxs("div",{className:"text-center mb-6",children:[a.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:a.jsx(lN,{className:"w-6 h-6 text-bambu-green"})}),a.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Sync your slicer presets across devices"})]}),a.jsxs("form",{onSubmit:v,className:"space-y-4",children:[n==="email"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),a.jsx("input",{type:"email",value:i,onChange:N=>s(N.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})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),a.jsx("input",{type:"password",value:o,onChange:N=>l(N.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})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),a.jsxs("select",{value:m,onChange:N=>p(N.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:[a.jsx("option",{value:"global",children:"Global"}),a.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),a.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",i,") for a 6-digit code"]}),a.jsx("input",{type:"text",value:c,onChange:N=>u(N.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"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),a.jsx("textarea",{value:d,onChange:N=>f(N.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})]}),a.jsxs("div",{className:"flex gap-2",children:[n==="code"&&a.jsx(Ne,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),a.jsxs(Ne,{type:"submit",disabled:S,className:"flex-1",children:[S?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(Lz,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&a.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:a.jsxs("button",{type:"button",onClick:()=>r("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[a.jsx(Ho,{className:"w-4 h-4"}),"Use access token instead"]})}),n==="token"&&a.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:a.jsxs("button",{type:"button",onClick:()=>r("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[a.jsx(Lz,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function ng({label:t,value:e,options:n,onChange:r}){const[i,s]=w.useState(!1),o=n.find(l=>l.value===e);return a.jsxs("div",{className:"relative",children:[a.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:[a.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),a.jsx("span",{children:o?.label||"All"}),a.jsx(Xr,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"rotate-180":""}`})]}),i&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>s(!1)}),a.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(l=>a.jsxs("button",{onClick:()=>{r(l.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===l.value?"text-bambu-green":"text-white"}`,children:[a.jsx("span",{children:l.label}),l.count!==void 0&&a.jsx("span",{className:"text-bambu-gray text-xs",children:l.count})]},l.value))})]})]})}function HKe(){const[t,e]=w.useState(!1);w.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?a.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:a.jsx(Fg,{className:"w-5 h-5"})}):null}function qj({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:s,compareDisabled:o}){const l=h5(t.name),c=Dy(t.setting_id);return a.jsxs("div",{className:"flex items-center gap-2 group",children:[a.jsx("button",{onClick:e,disabled:o,className:`flex-1 text-left px-3 py-2 rounded transition-colors ${i?"bg-blue-500/20 border border-blue-500/50":o?"bg-bambu-dark/50 opacity-40 cursor-not-allowed":"bg-bambu-dark hover:bg-bambu-dark-tertiary"} ${r&&!o?"cursor-pointer":""}`,children:a.jsxs("div",{className:"flex items-center gap-2",children:[i&&s!==void 0&&a.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-blue-500 text-white text-xs flex items-center justify-center font-medium",children:s+1}),!i&&c&&a.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:"My preset (editable)"}),a.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),l.filamentType&&t.type==="filament"&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.filamentType}),l.layerHeight&&t.type==="process"&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.layerHeight}),l.printer&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.printer})]})}),a.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:a.jsx(Ll,{className:"w-4 h-4"})})]})}function hD(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(`
  8279. `)){const i=t.replace(/\\n/g,`
  8280. `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
  8281. `);if(i.length>1)return`"""
  8282. `+i.map(s=>n+" "+s).join(`
  8283. `)+`
  8284. `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
  8285. `+t.map(i=>n+" "+hD(i,e+1)).join(`,
  8286. `)+`
  8287. `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
  8288. `+r.map(([s,o])=>n+" "+JSON.stringify(s)+": "+hD(o,e+1)).join(`,
  8289. `)+`
  8290. `+n+"}"}return String(t)}function VKe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i,hasPermission:s}){const{showToast:o}=Vn(),l=on(),[c,u]=w.useState(!1),{data:d,isLoading:f}=at({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>ue.getCloudSettingDetail(t.setting_id)}),m=mt({mutationFn:()=>ue.deleteCloudSetting(t.setting_id),onSuccess:()=>{o("Preset deleted"),l.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:b=>o(b.message,"error")}),p=Dy(t.setting_id),x=h5(t.name,d?.setting?.inherits);return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(wt,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:a.jsxs(St,{className:"p-0 flex flex-col min-h-0 flex-1",children:[a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),p&&a.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:"Editable"})]}),a.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[a.jsxs("span",{className:"capitalize",children:[t.type," preset"]}),x.printer&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"•"}),a.jsx("span",{children:x.printer})]})]})]}),a.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:f?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(ct,{className:"w-8 h-8 text-bambu-green animate-spin"})}):d?a.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:hD(d)}):a.jsx("div",{className:"text-center py-16 text-bambu-gray",children:"Failed to load preset details"})}),c?a.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[a.jsx(jn,{className:"w-5 h-5"}),a.jsx("span",{className:"font-medium",children:"Delete this preset?"})]}),a.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:['This will permanently delete "',t.name,'" from Bambu Cloud. This cannot be undone.']}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ne,{variant:"secondary",onClick:()=>u(!1),disabled:m.isPending,className:"flex-1",children:"Cancel"}),a.jsxs(Ne,{variant:"danger",onClick:()=>m.mutate(),disabled:m.isPending,className:"flex-1",children:[m.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):a.jsx(an,{className:"w-4 h-4"}),"Delete"]})]})]}):a.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ne,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),a.jsxs(Ne,{variant:"secondary",onClick:r,disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:"You do not have permission to duplicate presets",children:[a.jsx(Ll,{className:"w-4 h-4"}),"Duplicate"]}),p&&a.jsxs(a.Fragment,{children:[a.jsxs(Ne,{variant:"secondary",onClick:i,disabled:f||!d||!s("cloud:auth"),title:s("cloud:auth")?void 0:"You do not have permission to edit presets",children:[a.jsx(Ki,{className:"w-4 h-4"}),"Edit"]}),a.jsx(Ne,{variant:"danger",onClick:()=>u(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:"You do not have permission to delete presets",children:a.jsx(an,{className:"w-4 h-4"})})]})]})})]})})})}function Hre(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function Vre(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function GKe({onClose:t,onApply:e}){const{showToast:n}=Vn(),[r,i]=w.useState(Hre),[s,o]=w.useState("all"),[l,c]=w.useState(null),[u,d]=w.useState(""),[f,m]=w.useState(""),[p,x]=w.useState("{}"),[b,y]=w.useState(null),[v,S]=w.useState(null),N=s==="all"?r:r.filter(O=>O.type===s),C=O=>{i(O),Vre(O)},T=O=>{const H=r.filter(j=>j.id!==O);C(H),S(null),n("Template deleted")},k=O=>{c(O.id),d(O.name),m(O.description),x(JSON.stringify(O.settings,null,2)),y(null)},E=()=>{if(!(!l||!u.trim()))try{const O=JSON.parse(p),H=r.map(j=>j.id===l?{...j,name:u.trim(),description:f.trim(),settings:O}:j);C(H),c(null),n("Template updated")}catch(O){y(O.message)}},D=()=>{c(null),d(""),m(""),x("{}"),y(null)},A=O=>{const H=r.map(j=>j.id===O?{...j,showInModal:!j.showInModal}:j);C(H)},R={filament:{label:"Filament",icon:AD,color:"text-amber-400"},print:{label:"Process",icon:bh,color:"text-blue-400"},printer:{label:"Printer",icon:Ir,color:"text-purple-400"}},F=v?r.find(O=>O.id===v):null;return w.useEffect(()=>{const O=H=>{H.key==="Escape"&&(v?S(null):l?D():t())};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[v,l,t]),a.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[F&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:a.jsx(wt,{className:"w-full max-w-md",children:a.jsxs(St,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:a.jsx(jn,{className:"w-6 h-6 text-red-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Template"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"This action cannot be undone"})]})]}),a.jsxs("p",{className:"text-white mb-6",children:['Are you sure you want to delete "',a.jsx("span",{className:"font-medium",children:F.name}),'"?']}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ne,{variant:"secondary",onClick:()=>S(null),className:"flex-1",children:"Cancel"}),a.jsxs(Ne,{onClick:()=>T(v),className:"flex-1 bg-red-500 hover:bg-red-600",children:[a.jsx(an,{className:"w-4 h-4"}),"Delete"]})]})]})})}),a.jsx(wt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:a.jsxs(St,{className:"p-0 flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(W0,{className:"w-5 h-5 text-amber-400"}),"Quick Templates"]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:"Type:"}),["all","filament","print","printer"].map(O=>a.jsx("button",{onClick:()=>o(O),className:`px-3 py-1 text-sm rounded-lg transition-colors ${s===O?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:O==="all"?"All":R[O].label},O))]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:N.length===0?a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(W0,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),a.jsx("p",{children:"No templates yet"}),a.jsx("p",{className:"text-sm mt-1",children:"Create templates from the preset editor"})]}):a.jsx("div",{className:"space-y-2",children:N.map(O=>{const H=R[O.type],j=H.icon;return l===O.id?a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[a.jsx("input",{type:"text",value:u,onChange:G=>d(G.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}),a.jsx("input",{type:"text",value:f,onChange:G=>m(G.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"})]}),a.jsxs("div",{className:"mb-3",children:[a.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:"Settings (JSON)"}),a.jsx("textarea",{value:p,onChange:G=>{x(G.target.value),y(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${b?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),b&&a.jsx("p",{className:"text-xs text-red-400 mt-1",children:b})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Ne,{size:"sm",onClick:E,disabled:!u.trim(),children:[a.jsx(ms,{className:"w-4 h-4"}),"Save"]}),a.jsx(Ne,{size:"sm",variant:"secondary",onClick:D,children:"Cancel"})]})]},O.id):a.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:[a.jsx(j,{className:`w-5 h-5 ${H.color} flex-shrink-0`}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:O.name}),a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:O.description})]}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:[Object.keys(O.settings).length," fields"]}),a.jsx("button",{onClick:()=>A(O.id),className:`p-1 transition-colors ${O.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:O.showInModal?"Shown in modals":"Hidden in modals",children:O.showInModal?a.jsx(Ru,{className:"w-4 h-4"}):a.jsx(cN,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>e(O),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:"Apply"}),a.jsx("button",{onClick:()=>k(O),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:a.jsx(Ki,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>S(O.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:a.jsx(an,{className:"w-4 h-4"})})]},O.id)})})})]})})]})}function Gre({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i}){const[s,o]=w.useState("changes"),[l,c]=w.useState(""),u=w.useMemo(()=>{const p=new Set([...Object.keys(e),...Object.keys(n)]),x=[];for(const b of p){if(b==="inherits"||b==="version")continue;const y=e[b],v=n[b],S=b in e,N=b in n;let C;!S&&N?C="added":S&&!N?C="removed":JSON.stringify(y)!==JSON.stringify(v)?C="changed":C="same",x.push({key:b,left:y,right:v,status:C})}return x.sort((b,y)=>{const v={changed:0,added:1,removed:2,same:3};return v[b.status]!==v[y.status]?v[b.status]-v[y.status]:b.key.localeCompare(y.key)})},[e,n]),d=w.useMemo(()=>{let p=[...u];if(s==="changes"&&(p=p.filter(x=>x.status!=="same")),l){const x=l.toLowerCase();p=p.filter(b=>b.key.toLowerCase().includes(x)||String(b.left).toLowerCase().includes(x)||String(b.right).toLowerCase().includes(x))}return p},[u,s,l]),f=w.useMemo(()=>({added:u.filter(p=>p.status==="added").length,removed:u.filter(p=>p.status==="removed").length,changed:u.filter(p=>p.status==="changed").length,same:u.filter(p=>p.status==="same").length}),[u]),m=p=>{if(p===void 0)return"—";if(p===null)return"null";if(Array.isArray(p))return p.length===0?"[]":p.length===1?String(p[0]):p.join(", ");if(typeof p=="object")return JSON.stringify(p);const x=String(p);if(x.includes("\\n")||x.length>100){const b=x.split("\\n").length;if(b>1)return`[${b} lines of G-code/script]`;if(x.length>100)return x.substring(0,100)+"…"}return x};return w.useEffect(()=>{const p=x=>{x.key==="Escape"&&t()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[t]),a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsx(wt,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:a.jsxs(St,{className:"p-0 flex flex-col min-h-0 flex-1",children:[a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(wg,{className:"w-5 h-5 text-blue-400"}),"Compare Presets"]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[a.jsxs("div",{className:"text-center",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:"Left:"}),a.jsx("p",{className:"text-white font-medium truncate",children:r})]}),a.jsxs("div",{className:"text-center",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:"Right:"}),a.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[a.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[a.jsx(lr,{className:"w-3.5 h-3.5"}),f.added," added"]}),a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(b3,{className:"w-3.5 h-3.5"}),f.removed," removed"]}),a.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[a.jsx(d3,{className:"w-3.5 h-3.5"}),f.changed," changed"]}),a.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[a.jsx(tT,{className:"w-3.5 h-3.5"}),f.same," same"]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"relative",children:[a.jsx(pa,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:l,onChange:p=>c(p.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&&a.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>o("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"}),a.jsx("button",{onClick:()=>o("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"})]})]})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:d.length===0?a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(tT,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),a.jsx("p",{children:s==="changes"?"No differences found":"No fields match the search"})]}):a.jsxs("table",{className:"w-full",children:[a.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:a.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[a.jsx("th",{className:"text-left p-3 w-1/3",children:"Field"}),a.jsx("th",{className:"text-left p-3 w-1/3",children:r}),a.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),a.jsx("tbody",{children:d.map(p=>{const x={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[p.status],b={added:a.jsx(lr,{className:"w-3.5 h-3.5 text-green-400"}),removed:a.jsx(b3,{className:"w-3.5 h-3.5 text-red-400"}),changed:a.jsx(d3,{className:"w-3.5 h-3.5 text-amber-400"}),same:a.jsx(tT,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[p.status];return a.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${x}`,children:[a.jsx("td",{className:"p-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[b,a.jsx("span",{className:"text-sm text-white font-mono",children:p.key})]})}),a.jsx("td",{className:"p-3",children:a.jsx("span",{className:`text-sm font-mono break-all ${p.status==="removed"?"text-red-300":p.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(p.left)})}),a.jsx("td",{className:"p-3",children:a.jsx("span",{className:`text-sm font-mono break-all ${p.status==="added"?"text-green-300":p.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(p.right)})})]},p.key)})})]})})]})})})}function qKe({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=Vn(),i=on(),s=!!e?.setting_id,[o,l]=w.useState("common"),[c,u]=w.useState(e?.type||"filament"),[d,f]=w.useState(e?.name?s?e.name:`${e.name} (Copy)`:""),[m,p]=w.useState(e?.base_id||""),[x,b]=w.useState(""),[y,v]=w.useState(e?.setting||{inherits:""}),[S,N]=w.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[C,T]=w.useState(null),[k,E]=w.useState(""),[D,A]=w.useState(!1),[R,F]=w.useState(""),[O,H]=w.useState(!1),[j,G]=w.useState(Hre),[$,q]=w.useState(!1),[Y,Z]=w.useState(""),[oe,B]=w.useState(""),[W,se]=w.useState(!0),[ne,ce]=w.useState(null),[fe,ye]=w.useState(!1),ge=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[c]||[],[n,c]),xe=w.useMemo(()=>ge.filter(ae=>Dy(ae.setting_id)),[ge]),{data:Pe}=at({queryKey:["cloudFields",c],queryFn:()=>ue.getCloudFields(c==="print"?"process":c),staleTime:1e3*60*60}),{data:Ue}=at({queryKey:["allPresetDetails",c,xe.map(ae=>ae.setting_id).join(",")],queryFn:async()=>{const ae={};for(let Se=0;Se<xe.length;Se+=5){const Be=xe.slice(Se,Se+5);(await Promise.all(Be.map(async we=>{try{const tt=await ue.getCloudSettingDetail(we.setting_id);return{id:we.setting_id,detail:tt}}catch{return null}}))).forEach(we=>{we&&(ae[we.id]=we.detail)})}return ae},enabled:xe.length>0,staleTime:1e3*60*10}),{data:be,isLoading:it}=at({queryKey:["cloudSettingDetail",m],queryFn:()=>ue.getCloudSettingDetail(m),enabled:!!m});w.useEffect(()=>{o!=="json"&&N(JSON.stringify(y,null,2))},[y,o]);const U=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[c]||[]).filter(He=>!Dy(He.setting_id)).sort((He,Se)=>He.name.localeCompare(Se.name)),[n,c]);w.useEffect(()=>{if(!m)return;const ae=U.find(He=>He.setting_id===m);ae&&(b(ae.name),s||(v({inherits:ae.name}),N(JSON.stringify({inherits:ae.name},null,2))))},[m,U,s]);const K=w.useMemo(()=>{const ae=Pe?.fields||[],He=new Set(ae.map(we=>we.key)),Se=new Set,Be=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);Ue&&Object.values(Ue).forEach(we=>{we?.setting&&Object.keys(we.setting).forEach(tt=>{!He.has(tt)&&!Be.has(tt)&&Se.add(tt)})}),Object.keys(y).forEach(we=>{!He.has(we)&&!Be.has(we)&&Se.add(we)});const ft=Array.from(Se).sort().map(we=>({key:we,label:we.replace(/_/g," ").replace(/\b\w/g,tt=>tt.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...ae,...ft]},[Pe,Ue,y]),J=K.filter(ae=>ae.label.toLowerCase().includes(k.toLowerCase())||ae.key.toLowerCase().includes(k.toLowerCase())),Q=()=>{if(R.trim()){const ae=R.trim().toLowerCase().replace(/\s+/g,"_");z(ae,""),F(""),H(!1),r(`Field "${ae}" added`)}},z=(ae,He)=>{v(Se=>{const Be={...Se};return He===""||He===void 0?delete Be[ae]:Be[ae]=He,Be})},re=ae=>{v(He=>({...He,...ae.settings})),ce(ae.name),r("Template applied")},Ee=()=>{if(!Y.trim())return;const ae={...y};if(delete ae.inherits,Object.keys(ae).length===0){r("No overrides to save","error");return}const He={id:Date.now().toString(),name:Y.trim(),description:oe.trim()||"Custom template",type:c,settings:ae,showInModal:W},Se=[...j,He];G(Se),Vre(Se),q(!1),Z(""),B(""),se(!0),r("Template saved")},_e=w.useMemo(()=>j.filter(ae=>ae.type===c&&ae.showInModal),[c,j]),Te=ae=>{N(ae);try{const He=JSON.parse(ae);v(He),T(null)}catch(He){T(He.message)}},V=ae=>{ae.preventDefault(),A(!1);const He=ae.dataTransfer.files[0];if(He&&He.name.endsWith(".json")){const Se=new FileReader;Se.onload=Be=>{try{const ft=Be.target?.result,we=JSON.parse(ft),tt=we.setting||we;v(ke=>({...ke,...tt})),N(JSON.stringify({...y,...tt},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},Se.readAsText(He)}},L=mt({mutationFn:()=>{const ae={...y},He=c==="filament"?"filament_settings_id":c==="print"?"print_settings_id":"printer_settings_id";ae[He]=`"${d}"`;const Se={type:c,name:d,base_id:m,setting:ae};return ue.createCloudSetting(Se)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ae=>r(ae.message,"error")}),X=mt({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return ue.updateCloudSetting(e.setting_id,{name:d,setting:y})},onSuccess:async()=>{r("Preset updated successfully"),i.removeQueries({queryKey:["cloudSettingDetail"]}),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ae=>r(ae.message,"error")}),te=s?X:L,Me=be?.setting?.inherits,ie=Me?U.find(ae=>ae.name===Me):void 0,{data:De}=at({queryKey:["cloudSettingDetail",ie?.setting_id],queryFn:()=>ue.getCloudSettingDetail(ie.setting_id),enabled:!!ie?.setting_id}),Le=w.useMemo(()=>{const ae=De?.setting||{},He=be?.setting||{},Se=m&&Ue?.[m]?.setting?Ue[m].setting:{};return{...ae,...He,...Se}},[m,be,De,Ue]),$e=ae=>{if(ae==null)return"";if(Array.isArray(ae)){const He=[...new Set(ae.map(Se=>String(Se)))];return He.length===1?He[0]:ae.join(", ")}return String(ae)},Ze=ae=>{const He=y[ae.key],Se=Le[ae.key],Be=$e(Se),ft=it?"Loading...":Be||"",we="w-full px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none";if(ae.type==="boolean"){const tt=He==="1"||He===void 0&&Se==="1";return a.jsx("button",{type:"button",onClick:()=>z(ae.key,He==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${tt?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:a.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${tt?"translate-x-3.5":"translate-x-0.5"}`})})}return ae.type==="select"?a.jsxs("select",{value:He||"",onChange:tt=>z(ae.key,tt.target.value),className:we,children:[a.jsx("option",{value:"",children:ft}),ae.options?.map(tt=>a.jsx("option",{value:tt.value,children:tt.label},tt.value))]}):a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:ae.type==="number"?"number":"text",value:He!==void 0?String(He):"",onChange:tt=>z(ae.key,tt.target.value),step:ae.step,min:ae.min,max:ae.max,placeholder:ft,className:we}),ae.unit&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:ae.unit})]})},Ie=w.useMemo(()=>be?.setting?be.setting:{},[be]);return a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:ae=>{ae.preventDefault(),A(!0)},onDragLeave:()=>A(!1),onDrop:V,children:[fe&&m&&a.jsx(Gre,{onClose:()=>ye(!1),leftPreset:Ie,rightPreset:y,leftLabel:`Base: ${x||m}`,rightLabel:`Current: ${d||"New Preset"}`}),a.jsx(wt,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:a.jsxs(St,{className:"p-0 flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:s?"Edit Preset":e?"Duplicate Preset":"Create New Preset"}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize settings for your new preset"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[m&&a.jsxs("button",{onClick:()=>ye(!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:[a.jsx(wg,{className:"w-4 h-4"}),"Compare"]}),a.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Dt,{className:"w-5 h-5"})})]})]}),D&&a.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:a.jsxs("div",{className:"text-center",children:[a.jsx(Oa,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),a.jsx("p",{className:"text-bambu-green font-medium",children:"Drop JSON file to import"})]})}),a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Type"}),a.jsxs("select",{value:c,onChange:ae=>{u(ae.target.value),p("")},className:"w-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:[a.jsx("option",{value:"filament",children:"Filament"}),a.jsx("option",{value:"print",children:"Process"}),a.jsx("option",{value:"printer",children:"Printer"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Base Preset"}),a.jsxs("select",{value:m,onChange:ae=>p(ae.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:"Select base preset..."}),U.map(ae=>a.jsx("option",{value:ae.setting_id,children:ae.name},ae.setting_id))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Preset Name"}),a.jsx("input",{type:"text",value:d,onChange:ae=>f(ae.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"My Custom Preset"})]})]}),x&&a.jsx("div",{className:"text-xs text-bambu-gray",children:a.jsxs("p",{className:"flex items-center gap-1",children:[a.jsx(Wi,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",a.jsx("span",{className:"text-white",children:x}),it&&a.jsx(ct,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[a.jsxs("button",{onClick:()=>l("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${o==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(Iz,{className:"w-4 h-4"}),"Common"]}),a.jsxs("button",{onClick:()=>l("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${o==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(gN,{className:"w-4 h-4"}),"All Fields"]}),a.jsxs("button",{onClick:()=>l("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${o==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(vW,{className:"w-4 h-4"}),"JSON",C&&a.jsx(Ii,{className:"w-3 h-3 text-red-400"})]}),a.jsx("div",{className:"flex-1"}),a.jsxs("button",{onClick:()=>{const ae={name:d,type:c,base_id:m,setting:y},He=new Blob([JSON.stringify(ae,null,2)],{type:"application/json"}),Se=URL.createObjectURL(He),Be=document.createElement("a");Be.href=Se,Be.download=`${d||"preset"}.json`,document.body.appendChild(Be),Be.click(),document.body.removeChild(Be),URL.revokeObjectURL(Se),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:[a.jsx(pi,{className:"w-4 h-4"}),"Export"]}),a.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:[a.jsx(Oa,{className:"w-4 h-4"}),"Import"]}),a.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:ae=>{const He=ae.target.files?.[0];if(He){const Se=new FileReader;Se.onload=Be=>{try{const ft=JSON.parse(Be.target?.result),we=ft.setting||ft;v(tt=>({...tt,...we})),r("File imported")}catch{r("Invalid JSON","error")}},Se.readAsText(He)}}})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[o==="common"&&a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[a.jsx(W0,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(y).filter(ae=>ae!=="inherits").length>0&&a.jsxs("button",{onClick:()=>q(!$),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[a.jsx(ms,{className:"w-3 h-3"}),"Save as template"]})]}),$&&a.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[a.jsx("input",{type:"text",value:Y,onChange:ae=>Z(ae.target.value),placeholder:"Template name",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),a.jsx("input",{type:"text",value:oe,onChange:ae=>B(ae.target.value),placeholder:"Description (optional)",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Ne,{size:"sm",onClick:Ee,disabled:!Y.trim(),children:[a.jsx(ms,{className:"w-3 h-3"}),"Save"]}),a.jsx(Ne,{size:"sm",variant:"secondary",onClick:()=>q(!1),children:"Cancel"})]}),a.jsxs("button",{onClick:()=>se(!W),className:`flex items-center gap-1.5 text-xs transition-colors ${W?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[W?a.jsx(Ru,{className:"w-3.5 h-3.5"}):a.jsx(cN,{className:"w-3.5 h-3.5"}),W?"Show in modals":"Hidden in modals"]})]})]}),ne&&a.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:[a.jsx(Wi,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("span",{className:"text-sm text-bambu-green",children:["Template applied: ",a.jsx("span",{className:"font-medium",children:ne})]}),a.jsx("button",{onClick:()=>ce(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:a.jsx(Dt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[_e.map(ae=>a.jsxs("button",{onClick:()=>re(ae),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:ae.name}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:ae.description})]},ae.id)),_e.length===0&&a.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."})]}),a.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:"Manage templates via the Templates button on the main page"})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Common Settings"}),a.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:K.slice(0,10).map(ae=>a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:ae.label}),a.jsx("div",{className:"w-48",children:Ze(ae)})]},ae.key))})]}),Object.keys(y).length>1&&a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Current Overrides"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(y).filter(([ae])=>ae!=="inherits").map(([ae,He])=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[ae,": ",String(He).slice(0,20),a.jsx("button",{onClick:()=>z(ae,void 0),className:"hover:text-white",children:a.jsx(Dt,{className:"w-3 h-3"})})]},ae))})]})]}),o==="fields"&&a.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[a.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[a.jsx("h3",{className:"text-sm font-medium text-white",children:"Available Fields"}),a.jsx("span",{className:"text-xs text-bambu-gray",children:Ue?`${K.length} fields`:"Loading..."})]}),a.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[a.jsx(pa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:k,onChange:ae=>E(ae.target.value),placeholder:"Search fields...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[J.filter(ae=>!(ae.key in y)).map(ae=>{const He=Le[ae.key],Se=$e(He);return a.jsxs("div",{onClick:()=>{v(Be=>({...Be,[ae.key]:Se||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm text-white truncate",children:ae.label}),a.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:ae.key})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Se&&a.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:Se,children:[Se.slice(0,20),Se.length>20?"...":""]}),a.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:a.jsx(lr,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},ae.key)}),J.filter(ae=>!(ae.key in y)).length===0&&a.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:k?"No matching fields":"All fields added"})]}),a.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:O?a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",value:R,onChange:ae=>F(ae.target.value),onKeyDown:ae=>ae.key==="Enter"&&Q(),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}),a.jsx(Ne,{size:"sm",onClick:Q,disabled:!R.trim(),children:a.jsx(lr,{className:"w-4 h-4"})}),a.jsx(Ne,{size:"sm",variant:"secondary",onClick:()=>{H(!1),F("")},children:a.jsx(Dt,{className:"w-4 h-4"})})]}):a.jsxs("button",{onClick:()=>H(!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:[a.jsx(lr,{className:"w-4 h-4"}),"Add custom field"]})})]}),a.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[a.jsx("h3",{className:"text-sm font-medium text-white",children:"Your Overrides"}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[Object.keys(y).filter(ae=>ae!=="inherits").length," fields"]})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(y).filter(([ae])=>ae!=="inherits").map(([ae,He])=>{const Se=K.find(Be=>Be.key===ae);return a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-white",children:Se?.label||ae}),a.jsx("p",{className:"text-xs text-bambu-gray-dark",children:ae})]}),a.jsx("button",{onClick:()=>z(ae,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:a.jsx(Dt,{className:"w-4 h-4"})})]}),Se?Ze(Se):a.jsx("input",{type:"text",value:String(He),onChange:Be=>z(ae,Be.target.value),className:"w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]},ae)}),Object.keys(y).filter(ae=>ae!=="inherits").length===0&&a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(Iz,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),a.jsx("p",{className:"text-sm",children:"No overrides yet"}),a.jsx("p",{className:"text-xs mt-1",children:"Click fields on the left to add them"})]})]}),Object.keys(y).filter(ae=>ae!=="inherits").length>0&&a.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:a.jsxs("button",{onClick:()=>{q(!0),l("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:[a.jsx(ms,{className:"w-4 h-4"}),"Save as template"]})})]})]}),o==="json"&&a.jsxs("div",{className:"space-y-2",children:[C&&a.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[a.jsx(Ii,{className:"w-4 h-4"}),C]}),a.jsx("textarea",{value:S,onChange:ae=>Te(ae.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${C?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Tip: Drag & drop a .json file anywhere on this modal to import settings"})]})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[a.jsx(Ne,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),a.jsxs(Ne,{onClick:()=>te.mutate(),disabled:te.isPending||!d.trim()||!s&&!m||!!C,className:"flex-1",children:[te.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):s?a.jsx(ms,{className:"w-4 h-4"}):a.jsx(lr,{className:"w-4 h-4"}),s?"Save":e?"Duplicate":"Create"]})]})]})})]})}function WKe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i,hasPermission:s}){const[o,l]=w.useState(""),[c,u]=w.useState("all"),[d,f]=w.useState("all"),[m,p]=w.useState("all"),[x,b]=w.useState("all"),[y,v]=w.useState("all"),[S,N]=w.useState("all"),[C,T]=w.useState(null),[k,E]=w.useState(!1),[D,A]=w.useState(!1),[R,F]=w.useState(null),[O,H]=w.useState(null),[j,G]=w.useState(null),[$,q]=w.useState(!1),[Y,Z]=w.useState([null,null]),[oe,B]=w.useState(!1),[W,se]=w.useState(null),ne=on(),ce=w.useMemo(()=>[...t.filament.map(Q=>({...Q,type:"filament"})),...t.printer.map(Q=>({...Q,type:"printer"})),...t.process.map(Q=>({...Q,type:"process"}))].map(Q=>({...Q,meta:h5(Q.name)})),[t]),fe=w.useMemo(()=>{const J=new Set,Q=new Set,z=new Set;return ce.forEach(re=>{re.meta.nozzle&&J.add(re.meta.nozzle),re.meta.filamentType&&Q.add(re.meta.filamentType),re.meta.layerHeight&&z.add(re.meta.layerHeight)}),{printers:i.map(re=>({id:re.id.toString(),name:re.name})),nozzles:Array.from(J).sort((re,Ee)=>parseFloat(re)-parseFloat(Ee)),filaments:Array.from(Q).sort(),layerHeights:Array.from(z).sort((re,Ee)=>parseFloat(re)-parseFloat(Ee))}},[ce,i]),ye=w.useMemo(()=>m==="all"?null:i.find(Q=>Q.id.toString()===m)?.model||null,[m,i]),ge=w.useMemo(()=>ce.filter(J=>c==="all"||J.type===c).filter(J=>{if(d==="all")return!0;const Q=Dy(J.setting_id);return d==="custom"?Q:!Q}).filter(J=>{if(m==="all"||!ye)return!0;const Q=J.meta.printer?.toLowerCase()||"",z=ye.toLowerCase();return Q.includes(z)||z.includes(Q)}).filter(J=>x==="all"||J.meta.nozzle===x).filter(J=>y==="all"||J.meta.filamentType===y).filter(J=>S==="all"||J.meta.layerHeight===S).filter(J=>o===""||J.name.toLowerCase().includes(o.toLowerCase())).sort((J,Q)=>J.name.localeCompare(Q.name)),[ce,c,d,m,ye,x,y,S,o]),xe=J=>{if($){const Q=Y[0]?.setting_id===J.setting_id,z=Y[1]?.setting_id===J.setting_id;if(Q)Z([Y[1],null]);else if(z)Z([Y[0],null]);else if(!Y[0])Z([J,null]);else if(Y[1]){if(Y[0].type!==J.type)return;Z([Y[0],J])}else{if(Y[0].type!==J.type)return;Z([Y[0],J])}}else T(J)},Pe=J=>{if(Y[0]?.setting_id===J.setting_id)return 0;if(Y[1]?.setting_id===J.setting_id)return 1},Ue=async J=>{try{const Q=await ue.getCloudSettingDetail(J.setting_id),z=J.type==="process"?"print":J.type;F({type:z,name:J.name,base_id:Q.base_id||"GFSA00",setting:Q.setting||{}}),T(null)}catch(Q){console.error("Failed to fetch preset details for duplication:",Q)}},be=async J=>{try{ne.removeQueries({queryKey:["cloudSettingDetail",J.setting_id]});const Q=await ue.getCloudSettingDetail(J.setting_id),z=J.type==="process"?"print":J.type;H({type:z,name:J.name,base_id:Q.base_id||"GFSA00",setting:Q.setting||{},setting_id:J.setting_id}),T(null)}catch(Q){console.error("Failed to fetch preset details for editing:",Q)}},it=()=>{u("all"),f("all"),p("all"),b("all"),v("all"),N("all"),l("")},U=c!=="all"||d!=="all"||m!=="all"||x!=="all"||y!=="all"||S!=="all"||o!=="",K=t.filament.length+t.printer.length+t.process.length;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"space-y-4 mb-6",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(pa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:o,onChange:J=>l(J.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"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Ne,{variant:$?"primary":"secondary",onClick:()=>{$?(q(!1),Z([null,null])):q(!0)},children:[a.jsx(wg,{className:"w-4 h-4"}),$?"Cancel":"Compare"]}),a.jsxs(Ne,{variant:"secondary",onClick:()=>A(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:"You do not have permission to manage templates",children:[a.jsx(W0,{className:"w-4 h-4"}),"Templates"]}),a.jsxs(Ne,{variant:"secondary",onClick:n,disabled:r||!s("cloud:auth"),title:s("cloud:auth")?void 0:"You do not have permission to refresh profiles",children:[a.jsx(Pr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),a.jsxs(Ne,{onClick:()=>E(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:"You do not have permission to create presets",children:[a.jsx(lr,{className:"w-4 h-4"}),"New Preset"]})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(dN,{className:"w-4 h-4 text-bambu-gray"}),a.jsx(ng,{label:"Type",value:c,options:[{value:"all",label:"All",count:K},{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:J=>u(J)}),a.jsx(ng,{label:"Owner",value:d,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:J=>f(J)}),fe.printers.length>0&&a.jsx(ng,{label:"Printer",value:m,options:[{value:"all",label:"All"},...fe.printers.map(J=>({value:J.id,label:J.name}))],onChange:p}),fe.nozzles.length>0&&a.jsx(ng,{label:"Nozzle",value:x,options:[{value:"all",label:"All"},...fe.nozzles.map(J=>({value:J,label:J}))],onChange:b}),fe.filaments.length>0&&(c==="all"||c==="filament")&&a.jsx(ng,{label:"Filament",value:y,options:[{value:"all",label:"All"},...fe.filaments.map(J=>({value:J,label:J}))],onChange:v}),fe.layerHeights.length>0&&(c==="all"||c==="process")&&a.jsx(ng,{label:"Layer",value:S,options:[{value:"all",label:"All"},...fe.layerHeights.map(J=>({value:J,label:J}))],onChange:N}),U&&a.jsx("button",{onClick:it,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:"Clear filters"})]})]}),$&&a.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(wg,{className:"w-5 h-5 text-blue-400"}),a.jsx("span",{className:"text-white font-medium",children:"Compare Mode"}),a.jsx("span",{className:"text-bambu-gray",children:Y[0]?`Select another ${Y[0].type} preset`:"Click two presets of the same type to compare"})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${Y[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Y[0]?Y[0].name:"1. Select first"}),a.jsx(d3,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${Y[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Y[1]?Y[1].name:"2. Select second"})]}),Y[0]&&Y[1]&&a.jsxs(Ne,{size:"sm",onClick:async()=>{try{const[J,Q]=await Promise.all([ue.getCloudSettingDetail(Y[0].setting_id),ue.getCloudSettingDetail(Y[1].setting_id)]);se([J.setting||{},Q.setting||{}]),B(!0)}catch{}},children:[a.jsx(wg,{className:"w-4 h-4"}),"Compare Now"]})]})]})}),a.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Qn,{className:"w-3 h-3"}),"Last synced: ",BKe(e.toISOString())]}),a.jsxs("span",{children:["Showing ",ge.length," of ",K," presets"]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),a.jsx("span",{children:"= My preset (editable)"})]})]}),ge.length===0?a.jsxs("div",{className:"text-center py-16",children:[a.jsx(xs,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),a.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),U&&a.jsx("button",{onClick:it,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:"Clear filters"})]}):a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(AD,{className:"w-4 h-4 text-amber-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Filament"}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ge.filter(J=>J.type==="filament").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ge.filter(J=>J.type==="filament").map(J=>a.jsx(qj,{setting:J,onClick:()=>xe(J),onDuplicate:()=>Ue(J),compareMode:$,isCompareSelected:Pe(J)!==void 0,compareIndex:Pe(J),compareDisabled:$&&!!Y[0]&&Y[0].type!==J.type},J.setting_id)),ge.filter(J=>J.type==="filament").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No filament presets"})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(bh,{className:"w-4 h-4 text-blue-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Process"}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ge.filter(J=>J.type==="process").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ge.filter(J=>J.type==="process").map(J=>a.jsx(qj,{setting:J,onClick:()=>xe(J),onDuplicate:()=>Ue(J),compareMode:$,isCompareSelected:Pe(J)!==void 0,compareIndex:Pe(J),compareDisabled:$&&!!Y[0]&&Y[0].type!==J.type},J.setting_id)),ge.filter(J=>J.type==="process").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No process presets"})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(Ir,{className:"w-4 h-4 text-purple-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Printer"}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ge.filter(J=>J.type==="printer").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ge.filter(J=>J.type==="printer").map(J=>a.jsx(qj,{setting:J,onClick:()=>xe(J),onDuplicate:()=>Ue(J),compareMode:$,isCompareSelected:Pe(J)!==void 0,compareIndex:Pe(J),compareDisabled:$&&!!Y[0]&&Y[0].type!==J.type},J.setting_id)),ge.filter(J=>J.type==="printer").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No printer presets"})]})]})]}),C&&a.jsx(VKe,{setting:C,onClose:()=>T(null),onDeleted:()=>T(null),onDuplicate:()=>Ue(C),onEdit:()=>be(C),hasPermission:s}),(k||R||O||j)&&a.jsx(qKe,{onClose:()=>{E(!1),F(null),H(null),G(null)},initialData:O||R||(j?{type:j.type,name:"",base_id:"",setting:j.setting}:void 0),allPresets:t}),D&&a.jsx(GKe,{onClose:()=>A(!1),onApply:J=>{G({type:J.type,setting:J.settings}),A(!1)}}),oe&&W&&Y[0]&&Y[1]&&a.jsx(Gre,{onClose:()=>{B(!1),se(null)},leftPreset:W[0],rightPreset:W[1],leftLabel:Y[0].name,rightLabel:Y[1].name})]})}function KKe(){const t=on(),{showToast:e}=Vn(),{hasPermission:n}=Si(),[r,i]=w.useState("cloud"),[s,o]=w.useState(),{data:l,isLoading:c}=at({queryKey:["cloudStatus"],queryFn:ue.getCloudStatus}),{data:u=[]}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:d,isLoading:f,refetch:m,dataUpdatedAt:p}=at({queryKey:["cloudSettings"],queryFn:()=>ue.getCloudSettings(),enabled:!!l?.is_authenticated,retry:!1,staleTime:1e3*60*5});w.useEffect(()=>{p&&o(new Date(p))},[p]);const x=mt({mutationFn:ue.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),b=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return c?a.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:a.jsx(ct,{className:"w-8 h-8 text-bambu-green animate-spin"})}):a.jsxs("div",{className:"p-6 lg:p-8",children:[a.jsxs("div",{className:"mb-6",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:"Profiles"}),a.jsx("p",{className:"text-bambu-gray",children:"Manage your slicer presets and pressure advance calibrations"})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[a.jsxs("button",{onClick:()=>i("cloud"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${r==="cloud"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(lN,{className:"w-4 h-4"}),"Cloud Profiles"]}),a.jsxs("button",{onClick:()=>i("kprofiles"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${r==="kprofiles"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(hN,{className:"w-4 h-4"}),"K-Profiles"]})]}),r==="cloud"&&a.jsxs(a.Fragment,{children:[l?.is_authenticated&&a.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:["Connected as ",a.jsx("span",{className:"text-white",children:l.email})]})]}),a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>x.mutate(),disabled:x.isPending||!n("cloud:auth"),title:n("cloud:auth")?void 0:"You do not have permission to logout",children:[a.jsx(x3,{className:"w-4 h-4"}),"Logout"]})]}),l?.is_authenticated?f?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(ct,{className:"w-8 h-8 text-bambu-green animate-spin"})}):d?a.jsx(WKe,{settings:d,lastSyncTime:s,onRefresh:()=>m(),isRefreshing:f,printers:u,hasPermission:n}):a.jsxs("div",{className:"text-center py-16",children:[a.jsx("p",{className:"text-bambu-gray mb-4",children:"Failed to load profiles"}),a.jsx(Ne,{onClick:()=>m(),children:"Retry"})]}):a.jsx($Ke,{onSuccess:b})]}),r==="kprofiles"&&a.jsx(zKe,{}),a.jsx(HKe,{})]})}const g0={Droplet:AD,Flame:Uue,Ruler:bhe,Sparkles:W0,Square:il,Cable:Pce,Wrench:om,Calendar:ti,Timer:gu,Cog:hue,Fan:_W,Zap:vh,Wind:OW,Thermometer:yN,Layers:xs,Box:Pi,Target:PW,RefreshCw:Pr,Settings:bN,Filter:dN,CircleDot:Qce};function z0(t){return t&&g0[t]||om}function rg(t,e){if(e==="days")return t<1?"Today":t===1?"1 day":t<7?`${Math.round(t)} days`:t<180?`${Math.round(t/7)} weeks`:`${Math.round(t/30)} months`;{if(t<1)return`${Math.round(t*60)}m`;if(t<24)return`${t<10?t.toFixed(1):Math.round(t)}h`;const n=t/24;if(n<7)return`${n<2?n.toFixed(1):Math.round(n)}d`;const r=n/7;return r<12?`${r<2?r.toFixed(1):Math.round(r)}w`:`${Math.round(r/4)}mo`}}function Wj(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 XKe(t,e){const n=(e||"").toUpperCase().replace(/[- ]/g,""),r=n.includes("X1"),i=n.includes("P1"),s=n.includes("A1MINI"),o=n.includes("A1")&&!s,l=n.includes("H2D"),c=n.includes("H2C"),u=n.includes("H2S"),d=l||c||u,f=n.includes("P2S");switch(t){case"Lubricate Linear Rails":return r?"https://wiki.bambulab.com/en/x1/maintenance/basic-maintenance":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":s?"https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis":o?"https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis":d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":f?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/general/lead-screws-lubrication";case"Clean Nozzle/Hotend":return r||i?"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog":s||o?"https://wiki.bambulab.com/en/a1-mini/troubleshooting/nozzle-clog":d?"https://wiki.bambulab.com/en/h2/maintenance/nozzl-cold-pull-maintenance-and-cleaning":f?"https://wiki.bambulab.com/en/p2s/maintenance/cold-pull-maintenance-hotend":"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog";case"Check Belt Tension":return r?"https://wiki.bambulab.com/en/x1/maintenance/belt-tension":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":s?"https://wiki.bambulab.com/en/a1-mini/maintenance/belt_tension":o?"https://wiki.bambulab.com/en/a1/maintenance/belt_tension":l?"https://wiki.bambulab.com/en/h2/maintenance/belt-tension":c?"https://wiki.bambulab.com/en/h2c/maintenance/belt-tension":u?"https://wiki.bambulab.com/en/h2s/maintenance/belt-tension":f?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/x1/maintenance/belt-tension";case"Clean Carbon Rods":return r||i?"https://wiki.bambulab.com/en/general/carbon-rods-clearance":s||o||d||f?null:"https://wiki.bambulab.com/en/general/carbon-rods-clearance";case"Clean Build Plate":return"https://wiki.bambulab.com/en/filament-acc/acc/pei-plate-clean-guide";case"Check PTFE Tube":return r||i?"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube":s||o?"https://wiki.bambulab.com/en/a1-mini/maintenance/ptfe-tube":l?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":u?"https://wiki.bambulab.com/en/h2s/maintenance/replace-ptfe-tube-on-h2s-printer":c?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube";case"Replace HEPA Filter":case"HEPA Filter":case"Replace Carbon Filter":case"Carbon Filter":return d?"https://wiki.bambulab.com/en/h2/maintenance/replace-smoke-purifier-air-filte":"https://wiki.bambulab.com/en/x1/maintenance/replace-carbon-filter";case"Lubricate Left Nozzle Rail":case"Left Nozzle Rail":return d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;default:return null}}function YKe({item:t,onPerform:e,onToggle:n,hasPermission:r}){const i=z0(t.maintenance_type_icon),s=t.interval_type||"hours",l=(()=>{if(s==="days"){const m=t.days_since_maintenance??0;return Math.max(0,Math.min(100,m/t.interval_hours*100))}return Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100))})(),c=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",u=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",d=()=>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",f=()=>{if(!t.enabled)return"Disabled";if(s==="days"){const m=t.days_until_due??0;return t.is_due?`Overdue by ${rg(Math.abs(m),"days")}`:t.is_warning?`Due in ${rg(m,"days")}`:`${rg(m,"days")} left`}else return t.is_due?`Overdue by ${rg(Math.abs(t.hours_until_due),"hours")}`:t.is_warning?`Due in ${rg(t.hours_until_due,"hours")}`:`${rg(t.hours_until_due,"hours")} left`};return a.jsx("div",{className:`rounded-xl border p-4 transition-all ${d()}`,children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.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:[a.jsx(i,{className:`w-5 h-5 ${c()}`}),t.enabled&&(t.is_due||t.is_warning)&&a.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`})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),s==="days"&&a.jsx("span",{title:"Time-based interval",children:a.jsx(ti,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const m=t.maintenance_type_wiki_url||XKe(t.maintenance_type_name,t.printer_model);return m?a.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-bambu-green transition-colors shrink-0",title:"View documentation",onClick:p=>p.stopPropagation(),children:a.jsx(Yr,{className:"w-3.5 h-3.5"})}):null})()]}),a.jsx("div",{className:"mt-2 mb-1.5",children:a.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${u()}`,style:{width:`${l}%`}})})}),a.jsxs("div",{className:`text-xs flex items-center gap-1 ${c()}`,children:[t.is_due&&a.jsx(jn,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&a.jsx(Qn,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&a.jsx(Wi,{className:"w-3 h-3"}),f()]})]}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[a.jsx("span",{title:r("maintenance:update")?void 0:"You do not have permission to update maintenance items",children:a.jsx(On,{checked:t.enabled,onChange:m=>n(t.id,m),disabled:!r("maintenance:update")})}),a.jsxs(Ne,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled||!r("maintenance:update"),title:r("maintenance:update")?void 0:"You do not have permission to perform maintenance",className:"!px-3",children:[a.jsx(Dh,{className:"w-3.5 h-3.5"}),"Reset"]})]})]})})}function QKe({overview:t,onPerform:e,onToggle:n,onSetHours:r,hasPermission:i}){const[s,o]=w.useState(!0),[l,c]=w.useState(!1),[u,d]=w.useState(t.total_print_hours.toFixed(1)),f=[...t.maintenance_items].sort((x,b)=>x.is_due&&!b.is_due?-1:!x.is_due&&b.is_due?1:x.is_warning&&!b.is_warning?-1:!x.is_warning&&b.is_warning?1:x.maintenance_type_id-b.maintenance_type_id),m=f.find(x=>x.enabled&&(x.is_due||x.is_warning)),p=()=>{const x=parseFloat(u);!isNaN(x)&&x>=0&&(r(t.printer_id,x),c(!1))};return a.jsxs(wt,{className:"overflow-hidden",children:[a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),a.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&a.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:[a.jsx(jn,{className:"w-3 h-3"}),t.due_count," overdue"]}),t.warning_count>0&&a.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:[a.jsx(Qn,{className:"w-3 h-3"}),t.warning_count," due soon"]}),t.due_count===0&&t.warning_count===0&&a.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:[a.jsx(Wi,{className:"w-3 h-3"}),"All good"]})]})]}),a.jsxs("button",{onClick:()=>o(!s),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:[s?a.jsx(xh,{className:"w-4 h-4"}):a.jsx(Xr,{className:"w-4 h-4"}),s?"Collapse":"Expand"]})]}),a.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:a.jsx(gu,{className:"w-4 h-4 text-bambu-gray"})}),l?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",value:u,onChange:x=>d(x.target.value),onKeyDown:x=>{x.key==="Enter"&&p(),x.key==="Escape"&&c(!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}),a.jsx("span",{className:"text-xs text-bambu-gray",children:"hours"}),a.jsx(Ne,{size:"sm",onClick:p,children:"Save"}),a.jsx(Ne,{size:"sm",variant:"secondary",onClick:()=>c(!1),children:"Cancel"})]}):a.jsxs("button",{onClick:()=>{i("maintenance:update")&&(d(Math.round(t.total_print_hours).toString()),c(!0))},className:`group ${i("maintenance:update")?"":"cursor-not-allowed opacity-60"}`,title:i("maintenance:update")?void 0:"You do not have permission to edit print hours",children:[a.jsxs("div",{className:`text-sm font-medium text-white ${i("maintenance:update")?"group-hover:text-bambu-green":""} transition-colors flex items-center gap-1`,children:[Math.round(t.total_print_hours)," hours",a.jsx(rm,{className:`w-3 h-3 text-bambu-gray ${i("maintenance:update")?"group-hover:text-bambu-green":""}`})]}),a.jsx("div",{className:"text-xs text-bambu-gray",children:"Total print time"})]})]}),a.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),m&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${m.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const x=z0(m.maintenance_type_icon);return a.jsx(x,{className:`w-4 h-4 ${m.is_due?"text-red-400":"text-amber-400"}`})})()}),a.jsxs("div",{children:[a.jsx("div",{className:`text-sm font-medium ${m.is_due?"text-red-400":"text-amber-400"}`,children:m.maintenance_type_name}),a.jsx("div",{className:`text-xs ${m.is_due?"text-red-400/70":"text-amber-400/70"}`,children:m.is_due?"Overdue":"Due soon"})]})]})]})]}),s&&a.jsx(St,{className:"pt-0 border-t border-bambu-dark-tertiary",children:a.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:f.map(x=>a.jsx(YKe,{item:x,onPerform:e,onToggle:n,hasPermission:i},x.id))})})]})}function ZKe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:s,onAssignType:o,onRemoveItem:l,hasPermission:c}){const[u,d]=w.useState(null),[f,m]=w.useState(""),[p,x]=w.useState("hours"),[b,y]=w.useState(!1),[v,S]=w.useState(""),[N,C]=w.useState("100"),[T,k]=w.useState("hours"),[E,D]=w.useState("Wrench"),[A,R]=w.useState(""),[F,O]=w.useState(new Set),[H,j]=w.useState(null),G=w.useMemo(()=>t?t.map(z=>({id:z.printer_id,name:z.printer_name})):[],[t]),$=z=>t?t.filter(re=>re.maintenance_items.some(Ee=>Ee.maintenance_type_id===z)).map(re=>({printerId:re.printer_id,printerName:re.printer_name,itemId:re.maintenance_items.find(Ee=>Ee.maintenance_type_id===z)?.id})):[],q=z=>{if(!t)return[];const re=new Set($(z).map(Ee=>Ee.printerId));return G.filter(Ee=>!re.has(Ee.id))},[Y,Z]=w.useState(null),[oe,B]=w.useState(""),[W,se]=w.useState(""),[ne,ce]=w.useState("hours"),[fe,ye]=w.useState("Wrench"),[ge,xe]=w.useState(""),Pe=z=>{Z(z),B(z.name),se(z.default_interval_hours.toString()),ce(z.interval_type||"hours"),ye(z.icon||"Wrench"),xe(z.wiki_url||"")},Ue=()=>{Y&&oe.trim()&&parseFloat(W)>0&&(i(Y.id,{name:oe.trim(),default_interval_hours:parseFloat(W),interval_type:ne,icon:fe,wiki_url:ge.trim()||null}),Z(null))},be=(z,re,Ee)=>{const _e=parseFloat(f);if(!isNaN(_e)&&_e>0){const Te=Math.abs(_e-re)<.01?null:_e;n(z,{custom_interval_hours:Te,custom_interval_type:p!==Ee?p:null})}d(null)},it=z=>{z.preventDefault(),v.trim()&&parseFloat(N)>0&&F.size>0&&(r({name:v.trim(),default_interval_hours:parseFloat(N),interval_type:T,icon:E,wiki_url:A.trim()||null},Array.from(F)),S(""),C("100"),k("hours"),R(""),O(new Set),y(!1))},U=z=>{O(re=>{const Ee=new Set(re);return Ee.has(z)?Ee.delete(z):Ee.add(z),Ee})},K=t?.map(z=>({printerId:z.printer_id,printerName:z.printer_name,items:z.maintenance_items.sort((re,Ee)=>re.maintenance_type_id-Ee.maintenance_type_id)})).sort((z,re)=>z.printerName.localeCompare(re.printerName))||[],J=e.filter(z=>z.is_system),Q=e.filter(z=>!z.is_system);return a.jsxs("div",{className:"space-y-8",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Maintenance Types"}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"System types and your custom maintenance tasks"})]}),a.jsxs(Ne,{onClick:()=>y(!b),disabled:!c("maintenance:create"),title:c("maintenance:create")?void 0:"You do not have permission to create maintenance types",children:[a.jsx(lr,{className:"w-4 h-4"}),"Add Custom Type"]})]}),b&&a.jsx(wt,{className:"mb-6",children:a.jsx(St,{className:"py-4",children:a.jsxs("form",{onSubmit:it,children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[a.jsxs("div",{className:"lg:col-span-2",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Name"}),a.jsx("input",{type:"text",value:v,onChange:z=>S(z.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})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Interval Type"}),a.jsxs("select",{value:T,onChange:z=>{k(z.target.value),z.target.value==="days"?C("30"):C("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:[a.jsx("option",{value:"hours",children:"Print Hours"}),a.jsx("option",{value:"days",children:"Calendar Days"})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-xs text-bambu-gray mb-1.5",children:["Interval (",T==="days"?"days":"hours",")"]}),a.jsx("input",{type:"number",value:N,onChange:z=>C(z.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"})]})]}),a.jsx("div",{className:"mt-4 flex items-end justify-between",children:a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Icon"}),a.jsx("div",{className:"flex gap-1",children:Object.keys(g0).map(z=>{const re=g0[z];return a.jsx("button",{type:"button",onClick:()=>D(z),className:`p-2 rounded-lg transition-colors ${E===z?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:a.jsx(re,{className:"w-4 h-4"})},z)})})]})}),a.jsxs("div",{className:"mt-4",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Documentation Link (optional)"}),a.jsx("input",{type:"url",value:A,onChange:z=>R(z.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:"https://wiki.bambulab.com/..."})]}),a.jsxs("div",{className:"mt-4",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Assign to Printers"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:G.map(z=>a.jsx("button",{type:"button",onClick:()=>U(z.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${F.has(z.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:z.name},z.id))}),F.size===0&&a.jsx("p",{className:"text-xs text-orange-400 mt-1",children:"Select at least one printer"})]}),a.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[a.jsx(Ne,{type:"button",variant:"secondary",onClick:()=>{y(!1),O(new Set)},children:"Cancel"}),a.jsx(Ne,{type:"submit",disabled:!v.trim()||F.size===0,children:"Add Type"})]})]})})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[J.map(z=>{const re=z0(z.icon),Ee=z.interval_type||"hours";return a.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:a.jsx(re,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"text-sm font-medium text-white truncate",children:z.name}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[Ee==="days"?a.jsx(ti,{className:"w-3 h-3"}):a.jsx(gu,{className:"w-3 h-3"}),Wj(z.default_interval_hours,Ee)]})]})]})},z.id)}),Q.map(z=>{const re=z0(z.icon),Ee=z.interval_type||"hours";if(Y?.id===z.id)return a.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:a.jsxs("div",{className:"space-y-3",children:[a.jsx("input",{type:"text",value:oe,onChange:X=>B(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"Name",autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("select",{value:ne,onChange:X=>ce(X.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:[a.jsx("option",{value:"hours",children:"Print Hours"}),a.jsx("option",{value:"days",children:"Calendar Days"})]}),a.jsx("input",{type:"number",value:W,onChange:X=>se(X.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"})]}),a.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(g0).map(X=>{const te=g0[X];return a.jsx("button",{type:"button",onClick:()=>ye(X),className:`p-1.5 rounded transition-colors ${fe===X?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:a.jsx(te,{className:"w-3.5 h-3.5"})},X)})}),a.jsx("input",{type:"url",value:ge,onChange:X=>xe(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"Documentation link (optional)"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ne,{size:"sm",onClick:Ue,disabled:!oe.trim(),children:"Save"}),a.jsx(Ne,{size:"sm",variant:"secondary",onClick:()=>Z(null),children:"Cancel"})]})]})},z.id);const Te=$(z.id),V=q(z.id),L=H===z.id;return a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:a.jsx(re,{className:"w-5 h-5 text-bambu-green"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm font-medium text-white truncate",children:z.name}),a.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:"Custom"})]}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[Ee==="days"?a.jsx(ti,{className:"w-3 h-3"}):a.jsx(gu,{className:"w-3 h-3"}),Wj(z.default_interval_hours,Ee)]})]}),a.jsxs("button",{onClick:()=>j(L?null:z.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${Te.length>0?"border-bambu-green/50 bg-bambu-green/10 text-bambu-green hover:bg-bambu-green/20":"border-orange-400/50 bg-orange-400/10 text-orange-400 hover:bg-orange-400/20"}`,title:`${Te.length} printer(s) assigned - click to manage`,children:[a.jsx(Ir,{className:"w-3 h-3"}),a.jsx("span",{className:"text-xs font-medium",children:Te.length}),a.jsx(Xr,{className:`w-3 h-3 transition-transform ${L?"rotate-180":""}`})]}),a.jsx("button",{onClick:()=>Pe(z),disabled:!c("maintenance:update"),title:c("maintenance:update")?void 0:"You do not have permission to edit maintenance types",className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors ${c("maintenance:update")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(rm,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>{confirm(`Delete "${z.name}"?`)&&s(z.id)},disabled:!c("maintenance:delete"),title:c("maintenance:delete")?void 0:"You do not have permission to delete maintenance types",className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors ${c("maintenance:delete")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(an,{className:"w-4 h-4"})})]}),L&&a.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Assigned to printers:"}),Te.length===0?a.jsx("p",{className:"text-xs text-orange-400",children:"No printers assigned"}):a.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:Te.map(X=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[X.printerName,a.jsx("button",{onClick:()=>X.itemId&&l(X.itemId),disabled:!c("maintenance:delete"),title:c("maintenance:delete")?"Remove from this printer":"You do not have permission to remove printer assignments",className:`ml-1 ${c("maintenance:delete")?"hover:text-red-400":"opacity-50 cursor-not-allowed"}`,children:"×"})]},X.printerId))}),V.length>0&&a.jsxs("div",{className:"flex flex-wrap gap-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:"Add:"}),V.map(X=>a.jsxs("button",{onClick:()=>o(X.id,z.id),disabled:!c("maintenance:create"),title:c("maintenance:create")?void 0:"You do not have permission to assign printers",className:`px-2 py-1 bg-bambu-dark rounded text-xs transition-colors ${c("maintenance:create")?"hover:bg-bambu-green/20 text-bambu-gray hover:text-bambu-green":"opacity-50 cursor-not-allowed text-bambu-gray"}`,children:["+ ",X.name]},X.id))]})]})]},z.id)})]})]}),K.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"mb-4",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Interval Overrides"}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize intervals for specific printers"})]}),a.jsx("div",{className:"space-y-4",children:K.map(z=>a.jsx(wt,{children:a.jsxs(St,{className:"py-4",children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:z.printerName}),a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:z.items.map(re=>{const Ee=z0(re.maintenance_type_icon),_e=e.find(te=>te.id===re.maintenance_type_id),Te=_e?.default_interval_hours||re.interval_hours,V=_e?.interval_type||"hours",L=re.interval_type||"hours",X=u===re.id;return a.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[a.jsx(Ee,{className:"w-4 h-4 text-bambu-gray shrink-0"}),a.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:re.maintenance_type_name}),X?a.jsxs("div",{className:"flex items-center gap-1",children:[p==="days"?a.jsx(ti,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):a.jsx(gu,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),a.jsxs("select",{value:p,onChange:te=>x(te.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[a.jsx("option",{value:"hours",children:"Print Hours"}),a.jsx("option",{value:"days",children:"Calendar Days"})]}),a.jsx("input",{type:"number",value:f,onChange:te=>m(te.target.value),onKeyDown:te=>{te.key==="Enter"&&be(re.id,Te,V),te.key==="Escape"&&d(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),a.jsx(Ne,{size:"sm",onClick:()=>be(re.id,Te,V),children:"OK"})]}):a.jsxs("button",{onClick:()=>{c("maintenance:update")&&(d(re.id),m(re.interval_hours.toString()),x(L))},disabled:!c("maintenance:update"),title:c("maintenance:update")?void 0:"You do not have permission to edit intervals",className:`px-2 py-1 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs font-medium text-white transition-colors flex items-center gap-1 ${c("maintenance:update")?"hover:bg-bambu-dark-secondary hover:border-bambu-green":"opacity-50 cursor-not-allowed"}`,children:[L==="days"?a.jsx(ti,{className:"w-3 h-3"}):a.jsx(gu,{className:"w-3 h-3"}),Wj(re.interval_hours,L),a.jsx(rm,{className:"w-3 h-3 text-bambu-gray"})]})]},re.id)})})]})},z.printerId))})]}),K.length===0&&a.jsx(wt,{children:a.jsxs(St,{className:"text-center py-12",children:[a.jsx(Qn,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),a.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),a.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to configure maintenance intervals"})]})})]})}function JKe(){const t=on(),{showToast:e}=Vn(),{hasPermission:n}=Si(),[r,i]=w.useState("status"),{data:s,isLoading:o}=at({queryKey:["maintenanceOverview"],queryFn:ue.getMaintenanceOverview}),{data:l}=at({queryKey:["maintenanceTypes"],queryFn:ue.getMaintenanceTypes}),c=mt({mutationFn:({id:C,notes:T})=>ue.performMaintenance(C,T),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as complete")},onError:C=>{e(C.message,"error")}}),u=mt({mutationFn:({id:C,data:T})=>ue.updateMaintenanceItem(C,T),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:C=>{e(C.message,"error")}}),d=mt({mutationFn:({id:C,data:T})=>ue.updateMaintenanceType(C,T),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type updated")},onError:C=>{e(C.message,"error")}}),f=mt({mutationFn:ue.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:C=>{e(C.message,"error")}}),m=mt({mutationFn:({printerId:C,hours:T})=>ue.setPrinterHours(C,T),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:C=>{e(C.message,"error")}}),p=mt({mutationFn:({printerId:C,typeId:T})=>ue.assignMaintenanceType(C,T),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer assigned")},onError:C=>{e(C.message,"error")}}),x=mt({mutationFn:ue.removeMaintenanceItem,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer removed")},onError:C=>{e(C.message,"error")}}),b=C=>{c.mutate({id:C})},y=(C,T)=>{u.mutate({id:C,data:{enabled:T}})},v=(C,T)=>{m.mutate({printerId:C,hours:T})};if(o)return a.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:a.jsx(ct,{className:"w-8 h-8 text-bambu-green animate-spin"})});const S=s?.reduce((C,T)=>C+T.due_count,0)||0,N=s?.reduce((C,T)=>C+T.warning_count,0)||0;return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"mb-6",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:"Maintenance"}),a.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:r==="status"?a.jsxs(a.Fragment,{children:[S>0&&a.jsxs("span",{className:"text-red-400",children:[S," task",S!==1?"s":""," overdue"]}),S>0&&N>0&&" · ",N>0&&a.jsxs("span",{className:"text-amber-400",children:[N," due soon"]}),S===0&&N===0&&a.jsx("span",{className:"text-bambu-green",children:"All maintenance up to date"})]}):"Configure maintenance types and intervals"})]}),a.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>i("status"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="status"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:"Status"}),a.jsx("button",{onClick:()=>i("settings"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="settings"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:"Settings"})]}),r==="status"?a.jsx("div",{className:"space-y-6",children:s&&s.length>0?[...s].sort((C,T)=>{const k=C.due_count*10+C.warning_count,E=T.due_count*10+T.warning_count;return k!==E?E-k:C.printer_name.localeCompare(T.printer_name)}).map(C=>a.jsx(QKe,{overview:C,onPerform:b,onToggle:y,onSetHours:v,hasPermission:n},C.printer_id)):a.jsx(wt,{children:a.jsxs(St,{className:"text-center py-16",children:[a.jsx(om,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),a.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No printers configured"}),a.jsx("p",{className:"text-bambu-gray",children:"Add printers to start tracking maintenance"})]})})}):a.jsx(ZKe,{overview:s,types:l||[],onUpdateInterval:(C,T)=>u.mutate({id:C,data:T}),onAddType:async(C,T)=>{const k=await ue.createMaintenanceType(C);for(const E of T)await ue.assignMaintenanceType(E,k.id);t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onUpdateType:(C,T)=>d.mutate({id:C,data:T}),onDeleteType:C=>f.mutate(C),onAssignType:(C,T)=>p.mutate({printerId:C,typeId:T}),onRemoveItem:C=>x.mutate(C),hasPermission:n})]})}const vq=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function qre({project:t,onClose:e,onSave:n,isLoading:r}){const[i,s]=w.useState(t?.name||""),[o,l]=w.useState(t?.description||""),[c,u]=w.useState(t?.color||vq[0]),[d,f]=w.useState(t?.target_count?.toString()||""),[m,p]=w.useState(t?.target_parts_count?.toString()||""),[x,b]=w.useState(t?.status||"active"),[y,v]=w.useState(t?.tags||""),[S,N]=w.useState(t?.due_date?.split("T")[0]||""),[C,T]=w.useState(t?.priority||"normal"),k=E=>{E.preventDefault(),n({name:i.trim(),description:o.trim()||void 0,color:c,target_count:d?parseInt(d,10):void 0,target_parts_count:m?parseInt(m,10):void 0,tags:y.trim()||void 0,due_date:S||void 0,priority:C,...t&&{status:x}})};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:t?"Edit Project":"New Project"})}),a.jsxs("form",{onSubmit:k,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Name"}),a.jsx("input",{type:"text",value:i,onChange:E=>s(E.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})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Description"}),a.jsx("textarea",{value:o,onChange:E=>l(E.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})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Color"}),a.jsx("div",{className:"flex gap-2 flex-wrap",children:vq.map(E=>a.jsx("button",{type:"button",onClick:()=>u(E),className:`w-8 h-8 rounded-full transition-transform ${c===E?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:E}},E))})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Target Plates"}),a.jsx("input",{type:"number",value:d,onChange:E=>f(E.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., 25",min:"1"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Number of print jobs"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Target Parts"}),a.jsx("input",{type:"number",value:m,onChange:E=>p(E.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., 150",min:"1"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Total objects needed"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Tags (comma-separated)"}),a.jsx("input",{type:"text",value:y,onChange:E=>v(E.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, functional, gift"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Due Date"}),a.jsx("input",{type:"date",value:S,onChange:E=>N(E.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Priority"}),a.jsxs("select",{value:C,onChange:E=>T(E.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:[a.jsx("option",{value:"low",children:"Low"}),a.jsx("option",{value:"normal",children:"Normal"}),a.jsx("option",{value:"high",children:"High"}),a.jsx("option",{value:"urgent",children:"Urgent"})]})]})]}),t&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Status"}),a.jsxs("select",{value:x,onChange:E=>b(E.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:[a.jsx("option",{value:"active",children:"Active"}),a.jsx("option",{value:"completed",children:"Completed"}),a.jsx("option",{value:"archived",children:"Archived"})]})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Ne,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),a.jsx(Ne,{type:"submit",disabled:!i.trim()||r,children:r?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):t?"Save":"Create"})]})]})]})})}function eXe({project:t,onClick:e,onEdit:n,onDelete:r,hasPermission:i}){const s=t.target_count?Math.round(t.archive_count/t.target_count*100):0,o=t.target_parts_count?Math.round(t.completed_count/t.target_parts_count*100):0,l=t.status==="completed",c=t.status==="archived",[u,d]=w.useState(!1),m=l?{icon:oN,color:"text-bambu-green",bg:"bg-bambu-green/10"}:c?{icon:fo,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:Qn,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:Qa,color:"text-bambu-gray",bg:"bg-bambu-gray/10"};return a.jsxs("div",{className:"group relative bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary hover:border-bambu-green/50 hover:shadow-lg hover:shadow-bambu-green/5 transition-all duration-300 cursor-pointer overflow-hidden",onClick:e,children:[a.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full",style:{backgroundColor:t.color||"#6b7280",boxShadow:`0 0 12px ${t.color||"#6b7280"}40`}}),a.jsxs("div",{className:"p-5 pl-6",children:[a.jsxs("div",{className:"flex items-start justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx("div",{className:`p-2 rounded-lg ${m.bg} flex-shrink-0`,children:a.jsx(m.icon,{className:`w-5 h-5 ${m.color}`})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx("h3",{className:"font-semibold text-white truncate",children:t.name}),t.target_parts_count?a.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${o>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.completed_count,"/",t.target_parts_count," parts"]}):t.target_count?a.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${s>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.archive_count,"/",t.target_count," plates"]}):t.completed_count>0?a.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium bg-bambu-dark text-bambu-gray",children:[t.completed_count," parts"]}):null,l&&a.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap",children:"Done"}),c&&a.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded-full whitespace-nowrap",children:"Archived"})]}),t.description&&a.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1 line-clamp-1",children:t.description}),t.archives&&t.archives.length>0&&(()=>{const p=t.archives.map(v=>v.filament_type).filter(Boolean).flatMap(v=>v.split(",").map(S=>S.trim())).filter(Boolean),x=[...new Set(p)],b=t.archives.map(v=>v.filament_color).filter(Boolean).flatMap(v=>v.split(",").map(S=>S.trim())).filter(v=>v.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(v)),y=[...new Set(b)];return x.length===0&&y.length===0?null:a.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[x.slice(0,3).map(v=>a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded",children:v},v)),y.length>0&&a.jsxs("div",{className:"flex items-center gap-0.5",children:[y.slice(0,5).map(v=>a.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:v.startsWith("#")?v:`#${v}`},title:v},v)),y.length>5&&a.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",y.length-5]})]})]})})()]})]}),a.jsxs("div",{className:"relative",onClick:p=>p.stopPropagation(),children:[a.jsx("button",{className:"p-1.5 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors opacity-0 group-hover:opacity-100",onClick:()=>d(!u),children:a.jsx(rh,{className:"w-4 h-4"})}),u&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>d(!1)}),a.jsxs("div",{className:"absolute right-0 top-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[a.jsxs("button",{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${i("projects:update")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{i("projects:update")&&(n(),d(!1))},disabled:!i("projects:update"),title:i("projects:update")?void 0:"You do not have permission to edit projects",children:[a.jsx(rm,{className:"w-4 h-4"}),"Edit"]}),a.jsxs("button",{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${i("projects:delete")?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{i("projects:delete")&&(r(),d(!1))},disabled:!i("projects:delete"),title:i("projects:delete")?void 0:"You do not have permission to delete projects",children:[a.jsx(an,{className:"w-4 h-4"}),"Delete"]})]})]})]})]}),a.jsx("div",{className:"mb-4",children:t.target_count||t.target_parts_count?a.jsxs("div",{className:"space-y-3",children:[t.target_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:"Plates"}),a.jsxs("span",{className:s>=100?"text-bambu-green font-medium":"text-white",children:[t.archive_count," / ",t.target_count]})]}),a.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:a.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(s,100)}%`,background:s>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${s>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.target_parts_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:"Parts"}),a.jsxs("span",{className:o>=100?"text-bambu-green font-medium":"text-white",children:[t.completed_count," / ",t.target_parts_count]})]}),a.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:a.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(o,100)}%`,background:o>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${o>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.failed_count>0&&a.jsxs("div",{className:"text-xs text-red-400",children:[t.failed_count," failed"]})]}):t.completed_count>0||t.failed_count>0?a.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[t.completed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[a.jsx(fo,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.completed_count," completed"]})]}),t.failed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",children:[a.jsx(jn,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.failed_count," failed"]})]}),t.queue_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",children:[a.jsx(Qn,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.queue_count," in queue"]})]})]}):a.jsx("div",{className:"text-xs text-bambu-gray/60 italic",children:"No prints yet"})}),t.archives&&t.archives.length>0&&a.jsxs("div",{className:"mb-4",children:[a.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:t.archives.slice(0,4).map(p=>a.jsxs("div",{className:"relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary",title:p.print_name||"Unknown",children:[p.thumbnail_path?a.jsx("img",{src:ue.getArchiveThumbnail(p.id),alt:p.print_name||"",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray/50",children:a.jsx(pc,{className:"w-6 h-6"})}),p.status==="failed"&&a.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:a.jsx(jn,{className:"w-4 h-4 text-white"})})]},p.id))}),t.archive_count>4&&a.jsxs("p",{className:"text-xs text-bambu-gray mt-1.5 text-center",children:["+",t.archive_count-4," more"]})]}),a.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-4 text-xs text-bambu-gray",children:[a.jsxs("div",{className:"flex items-center gap-1.5",title:"Print jobs (plates)",children:[a.jsx(xs,{className:"w-3.5 h-3.5 text-blue-400"}),a.jsxs("span",{children:[t.archive_count," plates"]})]}),a.jsxs("div",{className:"flex items-center gap-1.5",title:"Parts printed",children:[a.jsx(pc,{className:"w-3.5 h-3.5 text-bambu-green"}),a.jsxs("span",{children:[t.completed_count," parts"]})]}),t.failed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",title:"Failed parts",children:[a.jsx(jn,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:t.failed_count})]}),t.queue_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-yellow-400",title:"In queue",children:[a.jsx(g3,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:t.queue_count})]})]}),a.jsx(vs,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function tXe(){const t=Mc(),e=on(),{showToast:n}=Vn(),{hasPermission:r}=Si(),[i,s]=w.useState(!1),[o,l]=w.useState(),[c,u]=w.useState("active"),[d,f]=w.useState(null),{data:m,isLoading:p}=at({queryKey:["projects",c==="all"?void 0:c],queryFn:()=>ue.getProjects(c==="all"?void 0:c)}),x=mt({mutationFn:O=>ue.createProject(O),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),s(!1),n("Project created","success")},onError:O=>{n(O.message,"error")}}),b=mt({mutationFn:({id:O,data:H})=>ue.updateProject(O,H),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),s(!1),l(void 0),n("Project updated","success")},onError:O=>{n(O.message,"error")}}),y=mt({mutationFn:O=>ue.deleteProject(O),onSuccess:()=>{f(null),n("Project deleted","success"),setTimeout(()=>window.location.reload(),100)},onError:O=>{f(null),n(O.message,"error")}}),v=mt({mutationFn:O=>ue.importProject(O),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),n("Project imported","success")},onError:O=>{n(O.message,"error")}}),S=w.useRef(null),N=async()=>{try{const O=await ue.getProjects(),H=await Promise.all(O.map(async q=>await ue.exportProjectJson(q.id))),j=new Blob([JSON.stringify(H,null,2)],{type:"application/json"}),G=URL.createObjectURL(j),$=document.createElement("a");$.href=G,$.download=`bambuddy_projects_${new Date().toISOString().split("T")[0]}.json`,$.click(),URL.revokeObjectURL(G),n("Projects exported (metadata only)","success")}catch(O){n(O.message,"error")}},C=()=>{S.current?.click()},T=async O=>{const H=O.target.files?.[0];if(H){try{if(H.name.toLowerCase().endsWith(".zip")){const G=new FormData;G.append("file",H);const $=await fetch("/api/v1/projects/import/file",{method:"POST",body:G});if(!$.ok){const q=await $.json();throw new Error(q.detail||"Import failed")}e.invalidateQueries({queryKey:["projects"]}),n("Project imported","success")}else{const G=await H.text(),$=JSON.parse(G),q=Array.isArray($)?$:[$];for(const Y of q)await v.mutateAsync(Y);q.length>1&&n(`${q.length} projects imported`,"success")}}catch(j){n(`Import failed: ${j.message}`,"error")}O.target.value=""}},k=O=>{o?b.mutate({id:o.id,data:O}):x.mutate(O)},E=O=>{l(O),s(!0)},D=O=>{t(`/projects/${O.id}`)},A=O=>{f(O)},R=()=>{d!==null&&y.mutate(d)},F=m?.reduce((O,H)=>(O[H.status]=(O[H.status]||0)+1,O.all=(O.all||0)+1,O),{})||{};return a.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[a.jsx("input",{ref:S,type:"file",accept:".json,.zip",onChange:T,className:"hidden"}),a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:a.jsx(Qa,{className:"w-6 h-6 text-bambu-green"})}),"Projects"]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:"Organize and track your 3D printing projects"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Ne,{variant:"secondary",onClick:C,disabled:!r("projects:create"),title:r("projects:create")?"Import project":"You do not have permission to import projects",children:[a.jsx(Oa,{className:"w-4 h-4 mr-2"}),"Import"]}),a.jsxs(Ne,{variant:"secondary",onClick:N,disabled:!r("projects:read"),title:r("projects:read")?"Export all projects":"You do not have permission to export projects",children:[a.jsx(pi,{className:"w-4 h-4 mr-2"}),"Export"]}),a.jsxs(Ne,{onClick:()=>s(!0),className:"sm:w-auto w-full",disabled:!r("projects:create"),title:r("projects:create")?void 0:"You do not have permission to create projects",children:[a.jsx(lr,{className:"w-4 h-4 mr-2"}),"New Project"]})]})]}),a.jsx("div",{className:"flex gap-1 p-1 bg-bambu-dark rounded-xl w-fit",children:[{key:"active",label:"Active",icon:Qn},{key:"completed",label:"Completed",icon:oN},{key:"archived",label:"Archived",icon:fo},{key:"all",label:"All",icon:Qa}].map(({key:O,label:H,icon:j})=>a.jsxs("button",{onClick:()=>u(O),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${c===O?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[a.jsx(j,{className:"w-4 h-4"}),a.jsx("span",{children:H}),F[O]>0&&a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${c===O?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:F[O]})]},O))}),p?a.jsx("div",{className:"flex items-center justify-center py-20",children:a.jsxs("div",{className:"flex flex-col items-center gap-3",children:[a.jsx(ct,{className:"w-8 h-8 animate-spin text-bambu-green"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Loading projects..."})]})}):m?.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-4",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(Qa,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:c==="all"?"No projects yet":`No ${c} projects`}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:c==="all"?"Create your first project to start organizing related prints, tracking progress, and managing your builds.":`You don't have any ${c} projects. Projects will appear here when their status changes.`}),c==="all"&&a.jsxs(Ne,{onClick:()=>s(!0),disabled:!r("projects:create"),title:r("projects:create")?void 0:"You do not have permission to create projects",children:[a.jsx(lr,{className:"w-4 h-4 mr-2"}),"Create Your First Project"]})]}):a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8",children:m?.map(O=>a.jsx(eXe,{project:O,onClick:()=>D(O),onEdit:()=>E(O),onDelete:()=>A(O.id),hasPermission:r},O.id))}),d!==null&&a.jsx(Yn,{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:R,onCancel:()=>f(null)}),i&&a.jsx(qre,{project:o,onClose:()=>{s(!1),l(void 0)},onSave:k,isLoading:x.isPending||b.isPending})]})}function nXe(t){if(t<1)return`${Math.round(t*60)}m`;const e=Math.floor(t),n=Math.round((t-e)*60);return n>0?`${e}h ${n}m`:`${e}h`}function rXe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function iXe({status:t}){const e={active:"bg-bambu-green/20 text-bambu-green",completed:"bg-blue-500/20 text-blue-400",archived:"bg-bambu-gray/20 text-bambu-gray"},n=e[t]||e.active;return a.jsx("span",{className:`px-2 py-1 rounded text-sm font-medium ${n}`,children:t.charAt(0).toUpperCase()+t.slice(1)})}function _q({icon:t,label:e,value:n,subValue:r,hint:i,color:s="text-bambu-gray"}){return a.jsx(wt,{children:a.jsx(St,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",title:i,children:[a.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${s}`,children:a.jsx(t,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:e}),a.jsx("p",{className:"text-xl font-semibold text-white",children:n}),r&&a.jsx("p",{className:"text-xs text-bambu-gray/70",children:r})]})]})})})}function aXe({archives:t}){return t.length===0?a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(pc,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:"No prints in this project yet"})]}):a.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-3",children:t.map(e=>a.jsxs(Os,{to:`/archives?search=${encodeURIComponent(e.print_name||"")}`,className:"group relative aspect-square rounded-lg bg-bambu-dark border border-bambu-dark-tertiary overflow-hidden hover:border-bambu-green transition-colors",children:[e.thumbnail_path?a.jsx("img",{src:ue.getArchiveThumbnail(e.id),alt:e.print_name||"Print",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:a.jsx(pc,{className:"w-8 h-8"})}),e.status==="failed"&&a.jsx("div",{className:"absolute inset-0 bg-red-500/30 flex items-center justify-center",children:a.jsx(qi,{className:"w-8 h-8 text-white"})}),e.status==="completed"&&a.jsx("div",{className:"absolute top-1 right-1",children:a.jsx(Tr,{className:"w-4 h-4 text-bambu-green"})}),a.jsx("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 to-transparent p-2 opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx("p",{className:"text-xs text-white truncate",children:e.print_name||"Unknown"})})]},e.id))})}function sXe({priority:t}){const e={low:{color:"bg-gray-500/20 text-gray-400",label:"Low"},normal:{color:"bg-blue-500/20 text-blue-400",label:"Normal"},high:{color:"bg-orange-500/20 text-orange-400",label:"High"},urgent:{color:"bg-red-500/20 text-red-400",label:"Urgent"}},{color:n,label:r}=e[t]||e.normal;return a.jsxs("span",{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${n}`,children:[t==="urgent"&&a.jsx(jn,{className:"w-3 h-3"}),r]})}function oXe(t){return t?Bg(t,{year:"numeric",month:"short",day:"numeric"}):""}function Kj(t){if(!t)return null;const e=Ri(t);if(!e)return null;const n=new Date,r=Math.ceil((e.getTime()-n.getTime())/(1e3*60*60*24));return r<0?{color:"text-red-400",label:"Overdue"}:r===0?{color:"text-orange-400",label:"Due today"}:r<=3?{color:"text-yellow-400",label:`${r} days left`}:{color:"text-bambu-gray",label:`${r} days left`}}function lXe(){const{id:t}=iN(),e=Mc(),n=on(),{showToast:r}=Vn(),{hasPermission:i}=Si(),[s,o]=w.useState(!1),[l,c]=w.useState(!1),[u,d]=w.useState(""),f=parseInt(t||"0",10),{data:m,isLoading:p,error:x}=at({queryKey:["project",f],queryFn:()=>ue.getProject(f),enabled:f>0}),{data:b,isLoading:y}=at({queryKey:["project-archives",f],queryFn:()=>ue.getProjectArchives(f),enabled:f>0}),{data:v,isLoading:S}=at({queryKey:["project-bom",f],queryFn:()=>ue.getProjectBOM(f),enabled:f>0}),{data:N,isLoading:C}=at({queryKey:["project-timeline",f],queryFn:()=>ue.getProjectTimeline(f,20),enabled:f>0}),{data:T}=at({queryKey:["settings"],queryFn:ue.getSettings}),{data:k}=at({queryKey:["project-folders",f],queryFn:()=>ue.getLibraryFoldersByProject(f),enabled:f>0}),E=T?.currency||"$",D=T?.time_format||"system",A=mt({mutationFn:Se=>ue.updateProject(f,Se),onSuccess:()=>{n.invalidateQueries({queryKey:["project",f]}),n.invalidateQueries({queryKey:["projects"]}),o(!1),c(!1),r("Project updated","success")},onError:Se=>{r(Se.message,"error")}}),R=()=>{d(m?.notes||""),c(!0)},F=()=>{A.mutate({notes:u})},O=()=>{c(!1),d("")},[H,j]=w.useState(""),[G,$]=w.useState(1),[q,Y]=w.useState(""),[Z,oe]=w.useState(""),[B,W]=w.useState(""),[se,ne]=w.useState(!1),[ce,fe]=w.useState(!1),[ye,ge]=w.useState(null),[xe,Pe]=w.useState(""),[Ue,be]=w.useState(1),[it,U]=w.useState(""),[K,J]=w.useState(""),[Q,z]=w.useState(""),[re,Ee]=w.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),_e=mt({mutationFn:Se=>ue.createBOMItem(f,Se),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",f]}),n.invalidateQueries({queryKey:["project",f]}),j(""),$(1),Y(""),oe(""),W(""),ne(!1),r("Part added","success")},onError:Se=>r(Se.message,"error")}),Te=mt({mutationFn:({itemId:Se,data:Be})=>ue.updateBOMItem(f,Se,Be),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",f]}),n.invalidateQueries({queryKey:["project",f]}),ge(null)},onError:Se=>r(Se.message,"error")}),V=mt({mutationFn:Se=>ue.deleteBOMItem(f,Se),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",f]}),n.invalidateQueries({queryKey:["project",f]}),r("Part removed","success")},onError:Se=>r(Se.message,"error")}),L=Se=>{Se.preventDefault(),H.trim()&&_e.mutate({name:H.trim(),quantity_needed:G,unit_price:q?parseFloat(q):void 0,sourcing_url:Z.trim()||void 0,remarks:B.trim()||void 0})},X=Se=>{const Be=Se.is_complete?0:Se.quantity_needed;Te.mutate({itemId:Se.id,data:{quantity_acquired:Be}})},te=(Se,Be)=>{Ee({isOpen:!0,title:"Delete Part",message:`Are you sure you want to delete "${Be}"?`,onConfirm:()=>{Ee(ft=>({...ft,isOpen:!1})),V.mutate(Se)}})},Me=Se=>{ge(Se),Pe(Se.name),be(Se.quantity_needed),U(Se.unit_price?.toString()||""),J(Se.sourcing_url||""),z(Se.remarks||"")},ie=Se=>{Se.preventDefault(),!(!ye||!xe.trim())&&Te.mutate({itemId:ye.id,data:{name:xe.trim(),quantity_needed:Ue,unit_price:it?parseFloat(it):void 0,sourcing_url:K.trim()||void 0,remarks:Q.trim()||void 0}})},De=()=>{ge(null)},Le=async()=>{try{const Se=await fetch(`/api/v1/projects/${f}/export`);if(!Se.ok)throw new Error("Export failed");const Be=await Se.blob(),ft=URL.createObjectURL(Be),we=document.createElement("a");we.href=ft;const ke=Se.headers.get("Content-Disposition")?.match(/filename="(.+)"/);we.download=ke?.[1]||`${m?.name||"project"}_${new Date().toISOString().split("T")[0]}.zip`,we.click(),URL.revokeObjectURL(ft),r("Project exported","success")}catch(Se){r(Se.message,"error")}},$e=mt({mutationFn:()=>ue.createTemplateFromProject(f),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r("Template created","success")},onError:Se=>r(Se.message,"error")}),Ze=Se=>$g(Se,D,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(p)return a.jsx("div",{className:"flex items-center justify-center py-24",children:a.jsx(ct,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(x||!m)return a.jsxs("div",{className:"text-center py-24",children:[a.jsx("p",{className:"text-bambu-gray",children:x?`Error: ${x.message}`:"Project not found"}),a.jsx(Ne,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:"Back to Projects"})]});const Ie=m.stats,ae=Ie?.progress_percent??0,He=Ie?.parts_progress_percent??0;return a.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(Os,{to:"/projects",className:"hover:text-white transition-colors",children:"Projects"}),a.jsx(vs,{className:"w-4 h-4"}),a.jsx("span",{className:"text-white",children:m.name})]}),a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("button",{onClick:()=>e("/projects"),className:"p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors",children:a.jsx(pce,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:m.color||"#6b7280"}}),a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:m.name}),m.description&&a.jsx("p",{className:"text-bambu-gray mt-1",children:m.description})]})]}),a.jsx(iXe,{status:m.status})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Ne,{variant:"secondary",onClick:Le,disabled:!i("projects:read"),title:i("projects:read")?"Export project":"You do not have permission to export projects",children:[a.jsx(pi,{className:"w-4 h-4 mr-2"}),"Export"]}),a.jsxs(Ne,{onClick:()=>o(!0),disabled:!i("projects:update"),title:i("projects:update")?void 0:"You do not have permission to edit projects",children:[a.jsx(rm,{className:"w-4 h-4 mr-2"}),"Edit"]})]})]}),(m.target_count||m.target_parts_count)&&a.jsx(wt,{children:a.jsxs(St,{className:"p-4 space-y-4",children:[m.target_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:"Plates Progress"}),a.jsxs("span",{className:"text-sm font-medium text-white",children:[Ie?.total_archives||0," / ",m.target_count," print jobs"]})]}),a.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(ae,100)}%`,backgroundColor:ae>=100?"#22c55e":m.color||"#6b7280"}})}),a.jsxs("div",{className:"flex justify-between mt-1",children:[a.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[ae.toFixed(0),"% complete"]}),Ie?.remaining_prints!=null&&Ie.remaining_prints>0&&a.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[Ie.remaining_prints," remaining"]})]})]}),m.target_parts_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:"Parts Progress"}),a.jsxs("span",{className:"text-sm font-medium text-white",children:[Ie?.completed_prints||0," / ",m.target_parts_count," parts"]})]}),a.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(He,100)}%`,backgroundColor:He>=100?"#22c55e":m.color||"#6b7280"}})}),a.jsxs("div",{className:"flex justify-between mt-1",children:[a.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[He.toFixed(0),"% complete"]}),Ie?.remaining_parts!=null&&Ie.remaining_parts>0&&a.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[Ie.remaining_parts," remaining"]})]})]})]})}),Ie&&a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(wt,{children:a.jsx(St,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:a.jsx(pc,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Print Jobs"}),a.jsxs("p",{className:"text-xl font-semibold text-white",children:[Ie.total_archives," ",a.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:"total"})]}),Ie.failed_prints>0&&a.jsxs("p",{className:"text-sm text-status-error",children:[Ie.failed_prints," failed"]}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[Ie.completed_prints," parts printed"]})]})]})})}),a.jsx(_q,{icon:Qn,label:"Print Time",value:nXe(Ie.total_print_time_hours),color:"text-yellow-400"}),a.jsx(_q,{icon:Ir,label:"Filament Used",value:rXe(Ie.total_filament_grams),color:"text-purple-400"})]}),Ie&&(Ie.estimated_cost>0||m.budget)&&a.jsx(wt,{children:a.jsxs(St,{className:"p-4",children:[a.jsx("h2",{className:"text-lg font-semibold text-white mb-3",children:"Cost Tracking"}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Filament Cost"}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[E,Ie.estimated_cost.toFixed(2)]})]}),Ie.total_energy_kwh>0&&a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Energy"}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[Ie.total_energy_kwh.toFixed(2)," kWh",Ie.total_energy_cost>0&&a.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",E,Ie.total_energy_cost.toFixed(2),")"]})]})]}),m.budget&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Budget"}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[E,m.budget.toFixed(2)]})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Remaining"}),a.jsxs("p",{className:`text-lg font-semibold ${m.budget-Ie.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[E,(m.budget-Ie.estimated_cost).toFixed(2)]})]})]})]})]})}),m.children&&m.children.length>0&&a.jsx(wt,{children:a.jsxs(St,{className:"p-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[a.jsx(Gue,{className:"w-5 h-5"}),"Sub-projects (",m.children.length,")"]}),a.jsx("div",{className:"space-y-2",children:m.children.map(Se=>a.jsxs(Os,{to:`/projects/${Se.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Se.color||"#6b7280"}}),a.jsx("span",{className:"text-white",children:Se.name}),a.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${Se.status==="completed"?"bg-status-ok/20 text-status-ok":Se.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:Se.status})]}),Se.progress_percent!==null&&a.jsxs("span",{className:"text-sm text-bambu-gray",children:[Se.progress_percent.toFixed(0),"%"]})]},Se.id))})]})}),m.parent_id&&m.parent_name&&a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(xs,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-bambu-gray",children:"Part of:"}),a.jsx(Os,{to:`/projects/${m.parent_id}`,className:"text-bambu-green hover:underline",children:m.parent_name})]}),(m.tags||m.due_date||m.priority!=="normal")&&a.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[m.priority&&m.priority!=="normal"&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs text-bambu-gray uppercase",children:"Priority:"}),a.jsx(sXe,{priority:m.priority})]}),m.due_date&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ti,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-sm text-white",children:oXe(m.due_date)}),Kj(m.due_date)&&a.jsxs("span",{className:`text-xs ${Kj(m.due_date).color}`,children:["(",Kj(m.due_date).label,")"]})]}),m.tags&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(yh,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("div",{className:"flex flex-wrap gap-1",children:m.tags.split(",").map((Se,Be)=>a.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:Se.trim()},Be))})]})]}),a.jsx(wt,{children:a.jsxs(St,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(fs,{className:"w-5 h-5"}),"Notes"]}),l?a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:O,disabled:A.isPending,children:[a.jsx(Dt,{className:"w-4 h-4 mr-1"}),"Cancel"]}),a.jsxs(Ne,{size:"sm",onClick:F,disabled:A.isPending,children:[A.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin mr-1"}):a.jsx(ms,{className:"w-4 h-4 mr-1"}),"Save"]})]}):a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:R,disabled:!i("projects:update"),title:i("projects:update")?void 0:"You do not have permission to edit notes",children:[a.jsx(rm,{className:"w-4 h-4 mr-1"}),"Edit"]})]}),l?a.jsx(aD,{content:u,onChange:d,placeholder:"Add notes about this project..."}):m.notes?a.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:m.notes}}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No notes yet. Click Edit to add notes."})]})}),a.jsx(wt,{children:a.jsxs(St,{className:"p-4",children:[a.jsx("div",{className:"flex items-center justify-between mb-3",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Il,{className:"w-5 h-5"}),"Files"]})}),a.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[a.jsx(Os,{to:"/files",className:"text-bambu-green hover:underline",children:"Link folders from the File Manager"})," ","to this project for quick access."]}),k&&k.length>0?a.jsx("div",{className:"space-y-2",children:k.map(Se=>a.jsxs(Os,{to:`/files?folder=${Se.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a.jsx(Il,{className:"w-5 h-5 text-bambu-green flex-shrink-0"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:Se.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[Se.file_count," file",Se.file_count!==1?"s":""]})]})]}),a.jsx(vs,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},Se.id))}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No folders linked. Go to File Manager and link a folder to this project."})]})}),a.jsx(wt,{children:a.jsxs(St,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(kW,{className:"w-5 h-5"}),"Bill of Materials",Ie&&Ie.bom_total_items>0&&a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",Ie.bom_completed_items,"/",Ie.bom_total_items," acquired)"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[v&&v.some(Se=>Se.is_complete)&&a.jsx("button",{onClick:()=>fe(!ce),className:`text-xs px-2 py-1 rounded transition-colors ${ce?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:ce?"Show all":"Hide done"}),!se&&a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>ne(!0),disabled:!i("projects:update"),title:i("projects:update")?void 0:"You do not have permission to add parts",children:[a.jsx(lr,{className:"w-4 h-4 mr-1"}),"Add Part"]})]})]}),se&&a.jsxs("form",{onSubmit:L,className:"bg-bambu-dark rounded-lg p-4 mb-4 space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsx("input",{type:"text",value:H,onChange:Se=>j(Se.target.value),className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Part name (e.g., M3x8 screws)",autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"number",value:G,onChange:Se=>$(parseInt(Se.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:"Qty"}),a.jsx("input",{type:"number",step:"0.01",value:q,onChange:Se=>Y(Se.target.value),className:"flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:`Price (${E})`})]})]}),a.jsx("input",{type:"url",value:Z,onChange:Se=>oe(Se.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Sourcing URL (optional)"}),a.jsx("input",{type:"text",value:B,onChange:Se=>W(Se.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Remarks (optional)"}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Ne,{type:"button",variant:"secondary",size:"sm",onClick:()=>ne(!1),children:"Cancel"}),a.jsx(Ne,{type:"submit",size:"sm",disabled:!H.trim()||_e.isPending,children:_e.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):"Add Part"})]})]}),S?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx(ct,{className:"w-6 h-6 animate-spin text-bambu-green"})}):v&&v.length>0?a.jsxs("div",{className:"space-y-2",children:[v.filter(Se=>!ce||!Se.is_complete).map(Se=>a.jsx("div",{className:`p-3 rounded-lg transition-colors ${Se.is_complete?"bg-status-ok/10":"bg-bambu-dark"}`,children:ye?.id===Se.id?a.jsxs("form",{onSubmit:ie,className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsx("input",{type:"text",value:xe,onChange:Be=>Pe(Be.target.value),className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Part name",autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"number",value:Ue,onChange:Be=>be(parseInt(Be.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:"Qty"}),a.jsx("input",{type:"number",step:"0.01",value:it,onChange:Be=>U(Be.target.value),className:"flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:`Price (${E})`})]})]}),a.jsx("input",{type:"url",value:K,onChange:Be=>J(Be.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Sourcing URL (optional)"}),a.jsx("input",{type:"text",value:Q,onChange:Be=>z(Be.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Remarks (optional)"}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Ne,{type:"button",variant:"secondary",size:"sm",onClick:De,children:"Cancel"}),a.jsx(Ne,{type:"submit",size:"sm",disabled:!xe.trim()||Te.isPending,children:Te.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):"Save"})]})]}):a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("button",{onClick:()=>i("projects:update")&&X(Se),disabled:Te.isPending||!i("projects:update"),title:i("projects:update")?void 0:"You do not have permission to update parts",className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${Se.is_complete?"bg-status-ok border-status-ok text-white":i("projects:update")?"border-bambu-gray hover:border-bambu-green":"border-bambu-gray/50 cursor-not-allowed"}`,children:Se.is_complete&&a.jsx(Tr,{className:"w-3 h-3"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsxs("p",{className:`text-sm font-medium ${Se.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[Se.name,a.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",Se.quantity_needed]})]}),Se.unit_price!==null&&a.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[E,(Se.unit_price*Se.quantity_needed).toFixed(2)]})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{onClick:()=>i("projects:update")&&Me(Se),disabled:!i("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${i("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:i("projects:update")?"Edit":"You do not have permission to edit parts",children:a.jsx(Ki,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>i("projects:update")&&te(Se.id,Se.name),disabled:!i("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${i("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:i("projects:update")?"Delete":"You do not have permission to delete parts",children:a.jsx(an,{className:"w-4 h-4"})})]})]}),Se.sourcing_url&&a.jsxs("a",{href:Se.sourcing_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 mt-1 text-xs text-blue-400 hover:text-blue-300 transition-colors",onClick:Be=>Be.stopPropagation(),children:[a.jsx(Yr,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"truncate",children:(()=>{try{return new URL(Se.sourcing_url).hostname.replace("www.","")}catch{return Se.sourcing_url}})()})]}),Se.remarks&&a.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:Se.remarks})]})]})},Se.id)),v.some(Se=>Se.unit_price!==null)&&a.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary flex justify-between text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:"Total cost:"}),a.jsxs("span",{className:"text-white font-medium",children:[E,v.reduce((Se,Be)=>Se+(Be.unit_price||0)*Be.quantity_needed,0).toFixed(2)]})]})]}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No parts in the bill of materials. Add hardware, electronics, or other components to track what needs to be sourced."})]})}),a.jsx(wt,{children:a.jsxs(St,{className:"p-4",children:[a.jsx("div",{className:"flex items-center justify-between mb-3",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(q0,{className:"w-5 h-5"}),"Activity Timeline"]})}),C?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx(ct,{className:"w-6 h-6 animate-spin text-bambu-green"})}):N&&N.length>0?a.jsx("div",{className:"space-y-3",children:N.slice(0,10).map((Se,Be)=>a.jsxs("div",{className:"flex gap-3",children:[a.jsxs("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${Se.event_type==="print_completed"?"bg-status-ok/20 text-status-ok":Se.event_type==="print_failed"?"bg-status-error/20 text-status-error":Se.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[Se.event_type==="print_completed"&&a.jsx(Tr,{className:"w-4 h-4"}),Se.event_type==="print_failed"&&a.jsx(qi,{className:"w-4 h-4"}),Se.event_type==="print_started"&&a.jsx(Ir,{className:"w-4 h-4"}),Se.event_type==="queued"&&a.jsx(g3,{className:"w-4 h-4"}),Se.event_type==="project_created"&&a.jsx(lr,{className:"w-4 h-4"})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white",children:Se.title}),Se.description&&a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:Se.description}),a.jsx("p",{className:"text-xs text-bambu-gray/70",children:Ze(Se.timestamp)})]})]},Be))}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No activity yet."})]})}),!m.is_template&&a.jsx("div",{className:"flex justify-end",children:a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>$e.mutate(),disabled:$e.isPending||!i("projects:create"),title:i("projects:create")?void 0:"You do not have permission to create templates",children:[$e.isPending?a.jsx(ct,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(Ll,{className:"w-4 h-4 mr-2"}),"Save as Template"]})}),Ie&&(Ie.queued_prints>0||Ie.in_progress_prints>0)&&a.jsx(wt,{children:a.jsxs(St,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(g3,{className:"w-5 h-5"}),"Queue"]}),a.jsx(Os,{to:`/queue?project=${f}`,className:"text-sm text-bambu-green hover:underline",children:"View all"})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[Ie.in_progress_prints>0&&a.jsxs("span",{className:"text-yellow-400",children:[Ie.in_progress_prints," printing"]}),Ie.queued_prints>0&&a.jsxs("span",{className:"text-bambu-gray",children:[Ie.queued_prints," queued"]})]})]})}),a.jsxs("div",{children:[a.jsx("div",{className:"flex items-center justify-between mb-4",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(pc,{className:"w-5 h-5"}),"Prints (",b?.length||0,")"]})}),y?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(ct,{className:"w-6 h-6 animate-spin text-bambu-green"})}):a.jsx(aXe,{archives:b||[]})]}),s&&a.jsx(qre,{project:{...m,archive_count:Ie?.total_archives||0,total_items:Ie?.total_items||0,completed_count:Ie?.completed_prints||0,failed_count:Ie?.failed_prints||0,queue_count:Ie?.queued_prints||0,progress_percent:Ie?.progress_percent||null,archives:[]},onClose:()=>o(!1),onSave:Se=>A.mutate(Se),isLoading:A.isPending}),re.isOpen&&a.jsx(Yn,{title:re.title,message:re.message,confirmText:"Delete",variant:"danger",onConfirm:re.onConfirm,onCancel:()=>Ee(Se=>({...Se,isOpen:!1}))})]})}function dg(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function cXe(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 uXe({parentId:t,onClose:e,onSave:n,isLoading:r}){const[i,s]=w.useState(""),o=l=>{l.preventDefault(),n({name:i.trim(),parent_id:t})};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:"New Folder"})}),a.jsxs("form",{onSubmit:o,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Folder Name"}),a.jsx("input",{type:"text",value:i,onChange:l=>s(l.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., Functional Parts",autoFocus:!0,required:!0})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Ne,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),a.jsx(Ne,{type:"submit",disabled:!i.trim()||r,children:r?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):"Create"})]})]})]})})}function dXe({type:t,currentName:e,onClose:n,onSave:r,isLoading:i}){const[s,o]=w.useState(e),l=c=>{c.preventDefault(),s.trim()&&s.trim()!==e&&r(s.trim())};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Rename ",t==="file"?"File":"Folder"]})}),a.jsxs("form",{onSubmit:l,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Name"}),a.jsx("input",{type:"text",value:s,onChange:c=>o(c.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",autoFocus:!0,required:!0})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Ne,{type:"button",variant:"secondary",onClick:n,children:"Cancel"}),a.jsx(Ne,{type:"submit",disabled:!s.trim()||s.trim()===e||i,children:i?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):"Rename"})]})]})]})})}function hXe({folders:t,selectedFiles:e,currentFolderId:n,onClose:r,onMove:i,isLoading:s}){const[o,l]=w.useState(null),c=(d,f=0)=>{const m=[];for(const p of d)m.push({id:p.id,name:p.name,depth:f}),p.children.length>0&&m.push(...c(p.children,f+1));return m},u=[{id:null,name:"Root (No Folder)",depth:0},...c(t)];return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Move ",e.length," File(s)"]})}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1",children:u.map(d=>a.jsxs("button",{onClick:()=>l(d.id),disabled:d.id===n,className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===d.id?"bg-bambu-green/20 text-bambu-green":d.id===n?"opacity-50 cursor-not-allowed text-bambu-gray":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${12+d.depth*16}px`},children:[a.jsx(Il,{className:"w-4 h-4"}),d.name,d.id===n&&a.jsx("span",{className:"text-xs text-bambu-gray ml-auto",children:"(current)"})]},d.id??"root"))}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Ne,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),a.jsx(Ne,{onClick:()=>i(o),disabled:s,children:s?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):"Move"})]})]})]})})}function fXe({folder:t,onClose:e,onLink:n,isLoading:r}){const[i,s]=w.useState("project"),[o,l]=w.useState(t.project_id||t.archive_id||null);w.useState(()=>{t.archive_id&&s("archive")});const{data:c}=at({queryKey:["projects"],queryFn:()=>ue.getProjects()}),{data:u}=at({queryKey:["archives-for-link"],queryFn:()=>ue.getArchives(void 0,void 0,100)}),d=()=>{n(i==="project"?{project_id:o,archive_id:0}:{project_id:0,archive_id:o})},f=()=>{n({project_id:0,archive_id:0})},m=t.project_id||t.archive_id;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(dc,{className:"w-5 h-5 text-bambu-green"}),"Link Folder"]}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Dt,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsxs("p",{className:"text-sm text-bambu-gray",children:['Link "',a.jsx("span",{className:"text-white",children:t.name}),'" to a project or archive for quick access.']}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:()=>{s("project"),l(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${i==="project"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[a.jsx(yW,{className:"w-4 h-4"}),"Project"]}),a.jsxs("button",{onClick:()=>{s("archive"),l(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${i==="archive"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[a.jsx(fo,{className:"w-4 h-4"}),"Archive"]})]}),a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1 bg-bambu-dark rounded-lg p-2",children:i==="project"?c&&c.length>0?c.map(p=>a.jsxs("button",{onClick:()=>l(p.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===p.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[a.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:p.color||"#00ae42"}}),a.jsx("span",{className:"truncate",children:p.name})]},p.id)):a.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:"No projects found"}):u&&u.length>0?u.map(p=>a.jsxs("button",{onClick:()=>l(p.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===p.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[a.jsx(zf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"truncate",children:p.print_name||p.filename})]},p.id)):a.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:"No archives found"})})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-between",children:[m&&a.jsxs(Ne,{variant:"danger",onClick:f,disabled:r,children:[a.jsx(OD,{className:"w-4 h-4 mr-2"}),"Unlink"]}),a.jsxs("div",{className:`flex gap-2 ${m?"":"ml-auto"}`,children:[a.jsx(Ne,{variant:"secondary",onClick:e,children:"Cancel"}),a.jsx(Ne,{onClick:d,disabled:!o||r,children:r?a.jsx(ct,{className:"w-4 h-4 animate-spin"}):"Link"})]})]})]})})}function mXe({folderId:t,onClose:e,onUploadComplete:n}){const[r,i]=w.useState([]),[s,o]=w.useState(!1),[l,c]=w.useState(!1),[u,d]=w.useState(!0),[f,m]=w.useState(!1),[p,x]=w.useState(!0),b=w.useRef(null),y=H=>{H.preventDefault(),o(!0)},v=H=>{H.preventDefault(),o(!1)},S=H=>{H.preventDefault(),o(!1);const j=Array.from(H.dataTransfer.files);C(j)},N=H=>{H.target.files&&C(Array.from(H.target.files))},C=H=>{const j=H.map(G=>({file:G,status:"pending",isZip:G.name.toLowerCase().endsWith(".zip")}));i(G=>[...G,...j])},T=H=>{i(j=>j.filter((G,$)=>$!==H))},k=r.some(H=>H.isZip&&H.status==="pending"),E=r.some(H=>H.file.name.toLowerCase().endsWith(".stl")&&H.status==="pending"),D=async()=>{if(r.length!==0){c(!0);for(let H=0;H<r.length;H++)if(r[H].status==="pending"){i(j=>j.map((G,$)=>$===H?{...G,status:"uploading"}:G));try{if(r[H].isZip){const j=await ue.extractZipFile(r[H].file,t,u,f,p);i(G=>G.map(($,q)=>q===H?{...$,status:j.errors.length>0&&j.extracted===0?"error":"success",extractedCount:j.extracted,error:j.errors.length>0?`${j.errors.length} files failed`:void 0}:$))}else await ue.uploadLibraryFile(r[H].file,t,p),i(j=>j.map((G,$)=>$===H?{...G,status:"success"}:G))}catch(j){i(G=>G.map(($,q)=>q===H?{...$,status:"error",error:j instanceof Error?j.message:"Upload failed"}:$))}}c(!1),n(),e()}},A=r.filter(H=>H.status==="pending").length,R=r.filter(H=>H.status==="success").length,F=r.filter(H=>H.status==="error").length,O=r.length>0&&A===0&&!l;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Upload Files"}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Dt,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsxs("div",{onDragOver:y,onDragLeave:v,onDrop:S,onClick:()=>b.current?.click(),className:`border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${s?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,children:[a.jsx(Oa,{className:`w-10 h-10 mx-auto mb-3 ${s?"text-bambu-green":"text-bambu-gray"}`}),a.jsx("p",{className:"text-white font-medium",children:s?"Drop files here":"Drag & drop files here"}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"or click to browse"}),a.jsx("p",{className:"text-xs text-bambu-gray/70 mt-2",children:"All file types supported. ZIP files will be extracted."})]}),a.jsx("input",{ref:b,type:"file",multiple:!0,className:"hidden",onChange:N}),k&&a.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(fo,{className:"w-5 h-5 text-blue-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-blue-300 font-medium",children:"ZIP files detected"}),a.jsx("p",{className:"text-xs text-blue-300/70 mt-1",children:"ZIP files will be extracted. Choose how to handle folder structure:"}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:u,onChange:H=>d(H.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:"Preserve folder structure from ZIP"})]}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:f,onChange:H=>m(H.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:"Create folder from ZIP filename"})]})]})]})}),(E||k)&&a.jsx("div",{className:"p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Du,{className:"w-5 h-5 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-bambu-green font-medium",children:"STL thumbnail generation"}),a.jsx("p",{className:"text-xs text-bambu-green/70 mt-1",children:k&&!E?"ZIP files may contain STL files. Thumbnails can be generated during extraction.":"Thumbnails can be generated for STL files. Large models may take longer to process."}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:p,onChange:H=>x(H.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:"Generate thumbnails for STL files"})]})]})]})}),r.length>0&&a.jsx("div",{className:"max-h-48 overflow-y-auto space-y-2",children:r.map((H,j)=>a.jsxs("div",{className:"flex items-center gap-3 p-2 bg-bambu-dark rounded-lg",children:[H.isZip?a.jsx(fo,{className:"w-4 h-4 text-blue-400 flex-shrink-0"}):a.jsx(uN,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:H.file.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[(H.file.size/1024/1024).toFixed(2)," MB",H.isZip&&H.status==="pending"&&a.jsx("span",{className:"text-blue-400 ml-2",children:"• Will be extracted"}),H.extractedCount!==void 0&&a.jsxs("span",{className:"text-green-400 ml-2",children:["• ",H.extractedCount," files extracted"]})]})]}),H.status==="pending"&&a.jsx("button",{onClick:()=>T(j),className:"p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Dt,{className:"w-4 h-4 text-bambu-gray"})}),H.status==="uploading"&&a.jsx(ct,{className:"w-4 h-4 text-bambu-green animate-spin"}),H.status==="success"&&a.jsx(Tr,{className:"w-4 h-4 text-green-500"}),H.status==="error"&&a.jsx("span",{title:H.error,children:a.jsx(qi,{className:"w-4 h-4 text-red-500"})})]},j))}),O&&a.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:a.jsxs("p",{className:"text-sm text-white",children:["Upload complete: ",R," succeeded",F>0&&a.jsxs("span",{className:"text-red-400",children:[", ",F," failed"]})]})})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2",children:[a.jsx(Ne,{variant:"secondary",onClick:e,children:O?"Close":"Cancel"}),!O&&a.jsx(Ne,{onClick:D,disabled:A===0||l,children:l?a.jsxs(a.Fragment,{children:[a.jsx(ct,{className:"w-4 h-4 mr-2 animate-spin"}),"Uploading..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Oa,{className:"w-4 h-4 mr-2"}),"Upload ",A>0?`(${A})`:""]})})]})]})})}function Wre({folder:t,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:s,depth:o=0,wrapNames:l=!1,hasPermission:c}){const[u,d]=w.useState(!0),[f,m]=w.useState(!1),p=t.children.length>0,x=t.project_id||t.archive_id;return a.jsxs("div",{children:[a.jsxs("div",{className:`group flex items-center gap-1 px-2 py-1.5 rounded cursor-pointer transition-colors ${e===t.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${8+o*12}px`},onClick:()=>n(t.id),children:[p?a.jsx("button",{onClick:b=>{b.stopPropagation(),d(!u)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(vs,{className:`w-3.5 h-3.5 transition-transform ${u?"rotate-90":""}`})}):a.jsx("div",{className:"w-4.5"}),a.jsx(Il,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),a.jsx("span",{className:`text-sm flex-1 min-w-0 ${l?"break-all":"truncate"}`,title:t.name,children:t.name}),x&&a.jsxs("button",{onClick:b=>{b.stopPropagation(),i(t)},className:"flex-shrink-0 flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 transition-colors",title:`${t.project_name?`Project: ${t.project_name}`:`Archive: ${t.archive_name}`} (click to change)`,children:[a.jsx(dc,{className:"w-3 h-3"}),t.project_name?a.jsx(yW,{className:"w-3 h-3"}):a.jsx(fo,{className:"w-3 h-3"})]}),t.file_count>0&&a.jsx("span",{className:"flex-shrink-0 text-xs text-bambu-gray",children:t.file_count}),!x&&a.jsx("button",{onClick:b=>{b.stopPropagation(),i(t)},className:"flex-shrink-0 p-1 rounded hover:bg-bambu-dark-tertiary",title:"Link to project or archive",children:a.jsx(dc,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-bambu-green"})}),a.jsx("div",{className:`flex-shrink-0 flex items-center gap-0.5 transition-opacity ${l?"":"opacity-0 group-hover:opacity-100"}`,onClick:b=>b.stopPropagation(),children:a.jsxs("div",{className:"relative",children:[a.jsx("button",{onClick:()=>m(!f),className:"p-1 rounded hover:bg-bambu-dark-tertiary",children:a.jsx(rh,{className:"w-3.5 h-3.5 text-bambu-gray"})}),f&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>m(!1)}),a.jsxs("div",{className:"absolute right-0 top-full mt-1 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:update_all")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:update_all")&&(s(t),m(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:"You do not have permission to rename folders",children:[a.jsx(Ki,{className:"w-3.5 h-3.5"}),"Rename"]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:update_all")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:update_all")&&(i(t),m(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:"You do not have permission to link folders",children:[a.jsx(dc,{className:"w-3.5 h-3.5"}),x?"Change Link...":"Link to..."]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:delete_all")?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:delete_all")&&(r(t.id),m(!1))},disabled:!c("library:delete_all"),title:c("library:delete_all")?void 0:"You do not have permission to delete folders",children:[a.jsx(an,{className:"w-3.5 h-3.5"}),"Delete"]})]})]})]})})]}),p&&u&&a.jsx("div",{children:t.children.map(b=>a.jsx(Wre,{folder:b,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:s,depth:o+1,wrapNames:l,hasPermission:c},b.id))})]})}function fD(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function pXe({file:t,isSelected:e,isMobile:n,onSelect:r,onDelete:i,onDownload:s,onAddToQueue:o,onPrint:l,onPreview3d:c,onRename:u,onGenerateThumbnail:d,thumbnailVersion:f,hasPermission:m,canModify:p}){const[x,b]=w.useState(!1);return a.jsxs("div",{className:`group relative bg-bambu-card rounded-lg border transition-all cursor-pointer overflow-hidden ${e?"border-bambu-green ring-1 ring-bambu-green":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,onClick:()=>r(t.id),children:[a.jsxs("div",{className:"aspect-square bg-bambu-dark flex items-center justify-center overflow-hidden",children:[t.thumbnail_path?a.jsx("img",{src:`${ue.getLibraryFileThumbnailUrl(t.id)}${f?`?v=${f}`:""}`,alt:t.filename,className:"w-full h-full object-cover"}):a.jsx(zf,{className:"w-12 h-12 text-bambu-gray/30"}),a.jsx("div",{className:`absolute top-2 right-2 text-xs px-1.5 py-0.5 rounded font-medium ${t.file_type==="3mf"?"bg-bambu-green/90 text-white":t.file_type==="gcode"?"bg-blue-500/90 text-white":t.file_type==="stl"?"bg-purple-500/90 text-white":"bg-bambu-gray/90 text-white"}`,children:t.file_type.toUpperCase()})]}),a.jsxs("div",{className:"p-3",children:[a.jsx("h3",{className:"text-sm font-medium text-white truncate",title:t.print_name||t.filename,children:t.print_name||t.filename}),a.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-bambu-gray",children:[a.jsx("span",{children:dg(t.file_size)}),t.print_time_seconds&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Qn,{className:"w-3 h-3"}),cXe(t.print_time_seconds)]})]}),t.print_count>0&&a.jsxs("div",{className:"mt-1 text-xs text-bambu-green",children:["Printed ",t.print_count,"x"]}),t.created_by_username&&a.jsxs("div",{className:"mt-1 text-xs text-bambu-gray",children:["Uploaded by ",t.created_by_username]})]}),a.jsxs("div",{className:`absolute bottom-2 right-2 transition-opacity ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:y=>y.stopPropagation(),children:[a.jsx("button",{onClick:()=>b(!x),className:"p-1.5 rounded bg-bambu-dark-secondary/90 hover:bg-bambu-dark-tertiary",children:a.jsx(rh,{className:"w-4 h-4 text-bambu-gray"})}),x&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>b(!1)}),a.jsxs("div",{className:"absolute right-0 bottom-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[140px]",children:[l&&fD(t.filename)&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${m("printers:control")?"text-bambu-green hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{m("printers:control")&&(l(t),b(!1))},disabled:!m("printers:control"),title:m("printers:control")?void 0:"You do not have permission to print",children:[a.jsx(Ir,{className:"w-3.5 h-3.5"}),"Print"]}),o&&fD(t.filename)&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${m("queue:create")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{m("queue:create")&&(o(t.id),b(!1))},disabled:!m("queue:create"),title:m("queue:create")?void 0:"You do not have permission to add to queue",children:[a.jsx(Qn,{className:"w-3.5 h-3.5"}),"Add to Queue"]}),c&&(t.file_type==="3mf"||t.file_type==="gcode"||t.file_type==="stl")&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${m("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{m("library:read")&&(c(t),b(!1))},disabled:!m("library:read"),title:m("library:read")?void 0:"You do not have permission to preview files",children:[a.jsx(Pi,{className:"w-3.5 h-3.5"}),"3D Preview"]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${m("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{m("library:read")&&(s(t.id),b(!1))},disabled:!m("library:read"),title:m("library:read")?void 0:"You do not have permission to download files",children:[a.jsx(pi,{className:"w-3.5 h-3.5"}),"Download"]}),u&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","update",t.created_by_id)&&(u(t),b(!1))},disabled:!p("library","update",t.created_by_id),title:p("library","update",t.created_by_id)?void 0:"You do not have permission to rename this file",children:[a.jsx(Ki,{className:"w-3.5 h-3.5"}),"Rename"]}),d&&t.file_type==="stl"&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","update",t.created_by_id)&&(d(t),b(!1))},disabled:!p("library","update",t.created_by_id),title:p("library","update",t.created_by_id)?void 0:"You do not have permission to generate thumbnails",children:[a.jsx(Du,{className:"w-3.5 h-3.5"}),"Generate Thumbnail"]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library","delete",t.created_by_id)?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","delete",t.created_by_id)&&(i(t.id),b(!1))},disabled:!p("library","delete",t.created_by_id),title:p("library","delete",t.created_by_id)?void 0:"You do not have permission to delete this file",children:[a.jsx(an,{className:"w-3.5 h-3.5"}),"Delete"]})]})]})]}),a.jsx("div",{className:`absolute top-2 left-2 w-5 h-5 rounded border-2 flex items-center justify-center transition-all ${e?"bg-bambu-green border-bambu-green":`border-white/30 bg-black/30 ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`}`,children:e&&a.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})})]})}function gXe(){const t=on(),{showToast:e}=Vn(),{hasPermission:n,hasAnyPermission:r,canModify:i}=Si(),[s]=wD(),o=s.get("folder"),l=o?parseInt(o,10):null,[c,u]=w.useState(l),[d,f]=w.useState([]),[m,p]=w.useState(!1),[x,b]=w.useState(!1),[y,v]=w.useState(!1),[S,N]=w.useState(null),[C,T]=w.useState(null),[k,E]=w.useState(null),[D,A]=w.useState(null),[R,F]=w.useState(null),[O,H]=w.useState({}),[j,G]=w.useState(null),[$,q]=w.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[Y,Z]=w.useState(()=>localStorage.getItem("library-wrap-folders")==="true"),[oe,B]=w.useState(()=>{const de=localStorage.getItem("library-sidebar-width");return de?parseInt(de,10):256}),[W,se]=w.useState(!1),ne=w.useRef(null);w.useEffect(()=>{if(!W)return;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const de=yt=>{if(!ne.current)return;const ut=ne.current.parentElement?.getBoundingClientRect();if(!ut)return;const It=yt.clientX-ut.left,Ft=Math.min(500,Math.max(200,It));B(Ft)},Ve=()=>{se(!1),document.body.style.userSelect="",document.body.style.cursor="",localStorage.setItem("library-sidebar-width",String(oe))};return document.addEventListener("mousemove",de),document.addEventListener("mouseup",Ve),()=>{document.removeEventListener("mousemove",de),document.removeEventListener("mouseup",Ve),document.body.style.userSelect="",document.body.style.cursor=""}},[W,oe]);const[ce,fe]=w.useState(""),[ye,ge]=w.useState("all"),[xe,Pe]=w.useState(()=>localStorage.getItem("library-sort-field")||"name"),[Ue,be]=w.useState(()=>localStorage.getItem("library-sort-direction")||"asc"),it=UD();w.useEffect(()=>{const de=s.get("folder");if(de){const Ve=parseInt(de,10);u(Ve)}},[s]);const{data:U}=at({queryKey:["settings"],queryFn:()=>ue.getSettings()}),{data:K,isLoading:J}=at({queryKey:["library-folders"],queryFn:()=>ue.getLibraryFolders()}),{data:Q,isLoading:z}=at({queryKey:["library-files",c],queryFn:()=>ue.getLibraryFiles(c,c===null)}),{data:re}=at({queryKey:["library-stats"],queryFn:()=>ue.getLibraryStats()}),Ee=w.useMemo(()=>{if(!Q)return[];const de=new Set(Q.map(Ve=>Ve.file_type));return Array.from(de).sort()},[Q]),_e=w.useMemo(()=>{if(!Q)return[];let de=[...Q];if(ce.trim()){const Ve=ce.toLowerCase();de=de.filter(yt=>yt.filename.toLowerCase().includes(Ve)||yt.print_name&&yt.print_name.toLowerCase().includes(Ve))}return ye!=="all"&&(de=de.filter(Ve=>Ve.file_type===ye)),de.sort((Ve,yt)=>{let ut=0;switch(xe){case"name":ut=(Ve.print_name||Ve.filename).localeCompare(yt.print_name||yt.filename);break;case"date":ut=new Date(Ve.created_at).getTime()-new Date(yt.created_at).getTime();break;case"size":ut=Ve.file_size-yt.file_size;break;case"type":ut=Ve.file_type.localeCompare(yt.file_type);break;case"prints":ut=Ve.print_count-yt.print_count;break}return Ue==="asc"?ut:-ut}),de},[Q,ce,ye,xe,Ue]),Te=w.useMemo(()=>{if(!re||!U)return!1;const de=(U.library_disk_warning_gb||5)*1024*1024*1024;return re.disk_free_bytes<de},[re,U]),V=mt({mutationFn:de=>ue.createLibraryFolder(de),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),p(!1),e("Folder created","success")},onError:de=>e(de.message,"error")}),L=mt({mutationFn:de=>ue.deleteLibraryFolder(de),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-stats"]}),c===C?.id&&u(null),T(null),e("Folder deleted","success")},onError:de=>{T(null),e(de.message,"error")}}),X=mt({mutationFn:de=>ue.deleteLibraryFile(de),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]}),f(de=>de.filter(Ve=>Ve!==C?.id)),T(null),e("File deleted","success")},onError:de=>{T(null),e(de.message,"error")}}),te=mt({mutationFn:de=>ue.bulkDeleteLibrary(de,[]),onSuccess:(de,Ve)=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]}),e(`Deleted ${Ve.length} files`,"success"),f([]),T(null)},onError:de=>{T(null),e(de.message,"error")}}),Me=mt({mutationFn:({fileIds:de,folderId:Ve})=>ue.moveLibraryFiles(de,Ve),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),f([]),b(!1),e("Files moved","success")},onError:de=>e(de.message,"error")}),ie=mt({mutationFn:({id:de,data:Ve})=>ue.updateLibraryFolder(de,Ve),onSuccess:(de,Ve)=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["project-folders"]}),t.invalidateQueries({queryKey:["archive-folders"]}),N(null);const yt=Ve.data.project_id===0&&Ve.data.archive_id===0;e(yt?"Folder unlinked":"Folder linked","success")},onError:de=>e(de.message,"error")}),De=mt({mutationFn:de=>ue.addLibraryFilesToQueue(de),onSuccess:de=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["queue"]}),t.invalidateQueries({queryKey:["archives"]}),f([]),de.added.length>0&&de.errors.length===0?e(`Added ${de.added.length} file${de.added.length>1?"s":""} to queue`,"success"):de.added.length>0&&de.errors.length>0?e(`Added ${de.added.length} file${de.added.length>1?"s":""}, ${de.errors.length} failed`,"success"):e(`Failed to add files: ${de.errors[0]?.error||"Unknown error"}`,"error")},onError:de=>e(de.message,"error")}),Le=mt({mutationFn:({id:de,filename:Ve})=>ue.updateLibraryFile(de,{filename:Ve}),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),F(null),e("File renamed","success")},onError:de=>{F(null),e(de.message,"error")}}),$e=mt({mutationFn:({id:de,name:Ve})=>ue.updateLibraryFolder(de,{name:Ve}),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-files"]}),F(null),e("Folder renamed","success")},onError:de=>{F(null),e(de.message,"error")}}),Ze=mt({mutationFn:()=>ue.batchGenerateStlThumbnails({all_missing:!0}),onSuccess:de=>{if(t.invalidateQueries({queryKey:["library-files"]}),de.succeeded>0){const Ve=Date.now(),yt={};de.results.forEach(ut=>{ut.success&&(yt[ut.file_id]=Ve)}),H(ut=>({...ut,...yt}))}de.succeeded>0&&de.failed===0?e(`Generated ${de.succeeded} thumbnail${de.succeeded>1?"s":""}`,"success"):de.succeeded>0&&de.failed>0?e(`Generated ${de.succeeded} thumbnail${de.succeeded>1?"s":""}, ${de.failed} failed`,"success"):de.processed===0?e("No STL files missing thumbnails","info"):e(`Failed to generate thumbnails: ${de.results[0]?.error||"Unknown error"}`,"error")},onError:de=>e(de.message,"error")}),Ie=mt({mutationFn:de=>ue.batchGenerateStlThumbnails({file_ids:[de]}),onSuccess:de=>{if(t.invalidateQueries({queryKey:["library-files"]}),de.succeeded>0){const Ve=de.results[0]?.file_id;Ve&&H(yt=>({...yt,[Ve]:Date.now()})),e("Thumbnail generated","success")}else e(`Failed to generate thumbnail: ${de.results[0]?.error||"Unknown error"}`,"error")},onError:de=>e(de.message,"error")}),ae=w.useCallback(de=>{const Ve=de.toLowerCase();return Ve.endsWith(".gcode")||Ve.includes(".gcode.")},[]),He=w.useMemo(()=>Q?Q.filter(de=>d.includes(de.id)&&ae(de.filename)):[],[Q,d,ae]),Se=w.useCallback(de=>{f(Ve=>Ve.includes(de)?Ve.filter(yt=>yt!==de):[...Ve,de])},[]),Be=w.useCallback(()=>{_e.length>0&&f(_e.map(de=>de.id))},[_e]),ft=w.useCallback(()=>{f([])},[]),we=()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]})},tt=de=>{window.open(ue.getLibraryFileDownloadUrl(de),"_blank")},ke=()=>{C&&(C.type==="file"?X.mutate(C.id):C.type==="folder"?L.mutate(C.id):C.type==="bulk"&&te.mutate(d))},We=L.isPending||X.isPending||te.isPending,pe=de=>{q(de),localStorage.setItem("library-view-mode",de)},Ce=J||z;return a.jsxs("div",{className:"p-4 md:p-8 min-h-[calc(100vh-64px)] lg:h-[calc(100vh-64px)] flex flex-col",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:a.jsx(Il,{className:"w-6 h-6 text-bambu-green"})}),"File Manager"]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:"Organize and manage your print files"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex items-center bg-bambu-dark rounded-lg p-1",children:[a.jsx("button",{onClick:()=>pe("grid"),className:`p-1.5 rounded transition-colors ${$==="grid"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:"Grid view",children:a.jsx(pN,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>pe("list"),className:`p-1.5 rounded transition-colors ${$==="list"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:"List view",children:a.jsx(gN,{className:"w-4 h-4"})})]}),a.jsxs(Ne,{variant:"secondary",onClick:()=>Ze.mutate(),disabled:Ze.isPending||!r("library:update_own","library:update_all"),title:r("library:update_own","library:update_all")?"Generate thumbnails for STL files missing them":"You do not have permission to generate thumbnails",children:[Ze.isPending?a.jsx(ct,{className:"w-4 h-4 mr-2 animate-spin"}):a.jsx(Du,{className:"w-4 h-4 mr-2"}),"Generate Thumbnails"]}),a.jsxs(Ne,{variant:"secondary",onClick:()=>p(!0),disabled:!n("library:upload"),title:n("library:upload")?void 0:"You do not have permission to create folders",children:[a.jsx(Hue,{className:"w-4 h-4 mr-2"}),"New Folder"]}),a.jsxs(Ne,{onClick:()=>v(!0),disabled:!n("library:upload"),title:n("library:upload")?void 0:"You do not have permission to upload files",children:[a.jsx(Oa,{className:"w-4 h-4 mr-2"}),"Upload"]})]})]}),Te&&re&&U&&a.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:[a.jsx(jn,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-amber-500 font-medium",children:"Low disk space warning"}),a.jsxs("p",{className:"text-xs text-amber-500/80",children:["Only ",dg(re.disk_free_bytes)," free of ",dg(re.disk_total_bytes)," total. Threshold is set to ",U.library_disk_warning_gb," GB in settings."]})]})]}),re&&a.jsxs("div",{className:"flex flex-wrap items-center gap-3 sm:gap-6 mb-6 p-3 bg-bambu-card rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(uN,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-bambu-gray",children:"Files:"}),a.jsx("span",{className:"text-white font-medium",children:re.total_files})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(Il,{className:"w-4 h-4 text-blue-400"}),a.jsx("span",{className:"text-bambu-gray",children:"Folders:"}),a.jsx("span",{className:"text-white font-medium",children:re.total_folders})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(fN,{className:"w-4 h-4 text-amber-400"}),a.jsx("span",{className:"text-bambu-gray",children:"Size:"}),a.jsx("span",{className:"text-white font-medium",children:dg(re.total_size_bytes)})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm sm:ml-auto",children:[a.jsx("span",{className:"text-bambu-gray",children:"Free:"}),a.jsx("span",{className:`font-medium ${Te?"text-amber-500":"text-white"}`,children:dg(re.disk_free_bytes)})]})]}),a.jsxs("div",{className:"flex-1 flex flex-col lg:flex-row gap-4 lg:gap-6 min-h-0",children:[a.jsx("div",{className:"lg:hidden",children:a.jsxs("select",{value:c??"",onChange:de=>u(de.target.value?parseInt(de.target.value,10):null),className:"w-full bg-bambu-card border border-bambu-dark-tertiary rounded-lg px-3 py-2.5 text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"",children:"📁 All Files"}),K&&(()=>{const de=(Ve,yt=0)=>{const ut=[];for(const It of Ve)ut.push({id:It.id,name:It.name,fileCount:It.file_count,depth:yt}),It.children.length>0&&ut.push(...de(It.children,yt+1));return ut};return de(K).map(Ve=>a.jsxs("option",{value:Ve.id,children:["│ ".repeat(Ve.depth),"📂 ",Ve.name," ",Ve.fileCount>0?`(${Ve.fileCount})`:""]},Ve.id))})()]})}),a.jsxs("div",{ref:ne,className:"hidden lg:flex flex-shrink-0 bg-bambu-card rounded-lg border border-bambu-dark-tertiary overflow-hidden flex-col relative",style:{width:`${oe}px`},children:[a.jsx("div",{className:`absolute right-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 group/resize flex items-center justify-center transition-colors ${W?"bg-bambu-green":"hover:bg-bambu-green/50"}`,onMouseDown:de=>{de.preventDefault(),se(!0)},onDoubleClick:()=>{B(256),localStorage.setItem("library-sidebar-width","256")},title:"Drag to resize, double-click to reset",children:a.jsxs("div",{className:`flex flex-col gap-1 opacity-0 group-hover/resize:opacity-100 transition-opacity ${W?"opacity-100":""}`,children:[a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"})]})}),a.jsxs("div",{className:"p-3 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsx("h2",{className:"text-sm font-medium text-white",children:"Folders"}),a.jsx("button",{onClick:()=>{const de=!Y;Z(de),localStorage.setItem("library-wrap-folders",String(de))},className:`text-xs px-1.5 py-0.5 rounded transition-colors ${Y?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white hover:bg-bambu-dark"}`,title:Y?"Disable text wrapping":"Enable text wrapping",children:"Wrap"})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[a.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors ${c===null?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,onClick:()=>u(null),children:[a.jsx(zf,{className:"w-4 h-4"}),a.jsx("span",{className:"text-sm",children:"All Files"})]}),K?.map(de=>a.jsx(Wre,{folder:de,selectedFolderId:c,onSelect:u,onDelete:Ve=>T({type:"folder",id:Ve}),onLink:N,onRename:Ve=>F({type:"folder",id:Ve.id,name:Ve.name}),wrapNames:Y,hasPermission:n},de.id))]})]}),a.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[Q&&Q.length>0&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 mb-4 p-2 sm:p-3 bg-bambu-card rounded-lg border border-bambu-dark-tertiary sticky top-0 z-10 lg:static",children:[a.jsxs("div",{className:"relative w-full sm:w-auto sm:flex-1 sm:max-w-xs",children:[a.jsx(pa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:"Search files...",value:ce,onChange:de=>fe(de.target.value),className:"w-full pl-9 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(dN,{className:"w-4 h-4 text-bambu-gray hidden sm:block"}),a.jsxs("select",{value:ye,onChange:de=>ge(de.target.value),className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"all",children:"All types"}),Ee.map(de=>a.jsx("option",{value:de,children:de.toUpperCase()},de))]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("select",{value:xe,onChange:de=>{const Ve=de.target.value;Pe(Ve),localStorage.setItem("library-sort-field",Ve)},className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"name",children:"Name"}),a.jsx("option",{value:"date",children:"Date"}),a.jsx("option",{value:"size",children:"Size"}),a.jsx("option",{value:"type",children:"Type"}),a.jsx("option",{value:"prints",children:"Prints"})]}),a.jsx("button",{onClick:()=>be(de=>{const Ve=de==="asc"?"desc":"asc";return localStorage.setItem("library-sort-direction",Ve),Ve}),className:"p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:Ue==="asc"?"Ascending":"Descending",children:Ue==="asc"?a.jsx(yce,{className:"w-4 h-4 text-white"}):a.jsx(hce,{className:"w-4 h-4 text-white"})})]}),(ce||ye!=="all")&&a.jsxs("span",{className:"text-sm text-bambu-gray hidden sm:inline",children:[_e.length," of ",Q.length," files"]})]}),_e.length>0&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-4 p-2 bg-bambu-card rounded-lg border border-bambu-dark-tertiary sticky top-[52px] z-10 lg:static",children:[d.length===_e.length&&d.length>0?a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:ft,children:[a.jsx(il,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:"Deselect All"})]}):a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:Be,children:[a.jsx(Vs,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:"Select All"})]}),d.length>0&&a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"text-sm text-bambu-gray ml-2",children:[d.length," selected"]}),a.jsx("div",{className:"hidden sm:block flex-1"}),a.jsxs("div",{className:"w-full sm:w-auto flex flex-wrap items-center gap-2 mt-2 sm:mt-0",children:[He.length===1&&a.jsxs(Ne,{variant:"primary",size:"sm",onClick:()=>A(He[0]),disabled:!n("printers:control"),title:n("printers:control")?void 0:"You do not have permission to print",children:[a.jsx(Us,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:"Print"})]}),He.length>0&&a.jsxs(Ne,{variant:He.length===1?"secondary":"primary",size:"sm",onClick:()=>De.mutate(He.map(de=>de.id)),disabled:De.isPending||!n("queue:create"),title:n("queue:create")?void 0:"You do not have permission to add to queue",children:[a.jsx(Qn,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:De.isPending?"Adding...":`Add to Queue${He.length<d.length?` (${He.length})`:""}`})]}),a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>b(!0),disabled:!r("library:update_own","library:update_all"),title:r("library:update_own","library:update_all")?void 0:"You do not have permission to move files",children:[a.jsx(Qde,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:"Move"})]}),a.jsxs(Ne,{variant:"danger",size:"sm",onClick:()=>{d.length===1?T({type:"file",id:d[0]}):T({type:"bulk",id:0,count:d.length})},disabled:!r("library:delete_own","library:delete_all"),title:r("library:delete_own","library:delete_all")?void 0:"You do not have permission to delete files",children:[a.jsx(an,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:"Delete"})]}),a.jsxs(Ne,{variant:"secondary",size:"sm",onClick:ft,children:[a.jsx(Dt,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:"Clear"})]})]})]})]}),Ce?a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsxs("div",{className:"flex flex-col items-center gap-3",children:[a.jsx(ct,{className:"w-8 h-8 animate-spin text-bambu-green"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Loading files..."})]})}):Q?.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(zf,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:c!==null?"Folder is empty":"No files yet"}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:c!==null?"Upload files or move files into this folder to get started.":"Upload files to start organizing your print-related files."}),a.jsxs(Ne,{onClick:()=>v(!0),disabled:!n("library:upload"),title:n("library:upload")?void 0:"You do not have permission to upload files",children:[a.jsx(lr,{className:"w-4 h-4 mr-2"}),"Upload Files"]})]}):_e.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(pa,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No matching files"}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:"No files match your current search or filter criteria."}),a.jsx(Ne,{variant:"secondary",onClick:()=>{fe(""),ge("all")},children:"Clear filters"})]}):$==="grid"?a.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:a.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-4",children:_e.map(de=>a.jsx(pXe,{file:de,isSelected:d.includes(de.id),isMobile:it,onSelect:Se,onDelete:Ve=>T({type:"file",id:Ve}),onDownload:tt,onAddToQueue:Ve=>De.mutate([Ve]),onPrint:E,onPreview3d:G,onRename:Ve=>F({type:"file",id:Ve.id,name:Ve.filename}),onGenerateThumbnail:Ve=>Ie.mutate(Ve.id),thumbnailVersion:O[de.id],hasPermission:n,canModify:i},de.id))})}):a.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:a.jsxs("div",{className:"bg-bambu-card rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[a.jsxs("div",{className:"hidden sm:grid grid-cols-[auto_1fr_100px_100px_100px_80px] gap-4 px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary text-xs text-bambu-gray font-medium",children:[a.jsx("div",{className:"w-6"}),a.jsx("div",{children:"Name"}),a.jsx("div",{children:"Type"}),a.jsx("div",{children:"Size"}),a.jsx("div",{children:"Prints"}),a.jsx("div",{})]}),_e.map(de=>a.jsxs("div",{className:`grid grid-cols-[auto_1fr_100px_100px_100px_80px] gap-4 px-4 py-3 items-center border-b border-bambu-dark-tertiary last:border-b-0 cursor-pointer hover:bg-bambu-dark/50 transition-colors ${d.includes(de.id)?"bg-bambu-green/10":""}`,onClick:()=>Se(de.id),children:[a.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${d.includes(de.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:d.includes(de.id)&&a.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})}),a.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a.jsxs("div",{className:"relative group/thumb",children:[a.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark flex-shrink-0 overflow-hidden",children:de.thumbnail_path?a.jsx("img",{src:`${ue.getLibraryFileThumbnailUrl(de.id)}${O[de.id]?`?v=${O[de.id]}`:""}`,alt:"",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center",children:a.jsx(zf,{className:"w-5 h-5 text-bambu-gray/50"})})}),de.thumbnail_path&&a.jsx("div",{className:"absolute left-0 top-full mt-2 z-50 hidden group-hover/thumb:block",children:a.jsx("div",{className:"w-48 h-48 rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary shadow-xl overflow-hidden",children:a.jsx("img",{src:`${ue.getLibraryFileThumbnailUrl(de.id)}${O[de.id]?`?v=${O[de.id]}`:""}`,alt:de.filename,className:"w-full h-full object-contain"})})})]}),a.jsx("div",{className:"min-w-0",children:a.jsx("div",{className:"text-sm text-white truncate",children:de.print_name||de.filename})})]}),a.jsx("div",{children:a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${de.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":de.file_type==="gcode"?"bg-blue-500/20 text-blue-400":de.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:de.file_type.toUpperCase()})}),a.jsx("div",{className:"text-sm text-bambu-gray",children:dg(de.file_size)}),a.jsx("div",{className:"text-sm text-bambu-gray",children:de.print_count>0?`${de.print_count}x`:"-"}),a.jsxs("div",{className:"flex items-center gap-1",onClick:Ve=>Ve.stopPropagation(),children:[fD(de.filename)&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>n("printers:control")&&E(de),className:`p-1.5 rounded transition-colors ${n("printers:control")?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:n("printers:control")?"Print":"You do not have permission to print",disabled:!n("printers:control"),children:a.jsx(Ir,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>n("queue:create")&&De.mutate([de.id]),className:`p-1.5 rounded transition-colors ${n("queue:create")?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:n("queue:create")?"Add to Queue":"You do not have permission to add to queue",disabled:De.isPending||!n("queue:create"),children:a.jsx(Qn,{className:"w-4 h-4"})})]}),(de.file_type==="3mf"||de.file_type==="gcode"||de.file_type==="stl")&&a.jsx("button",{onClick:()=>n("library:read")&&G(de),className:`p-1.5 rounded transition-colors ${n("library:read")?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:n("library:read")?"3D Preview":"You do not have permission to preview files",disabled:!n("library:read"),children:a.jsx(Pi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>n("library:read")&&tt(de.id),className:`p-1.5 rounded transition-colors ${n("library:read")?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:n("library:read")?"Download":"You do not have permission to download files",disabled:!n("library:read"),children:a.jsx(pi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>i("library","update",de.created_by_id)&&F({type:"file",id:de.id,name:de.filename}),className:`p-1.5 rounded transition-colors ${i("library","update",de.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:i("library","update",de.created_by_id)?"Rename":"You do not have permission to rename this file",disabled:!i("library","update",de.created_by_id),children:a.jsx(Ki,{className:"w-4 h-4"})}),de.file_type==="stl"&&a.jsx("button",{onClick:()=>i("library","update",de.created_by_id)&&Ie.mutate(de.id),className:`p-1.5 rounded transition-colors ${i("library","update",de.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:i("library","update",de.created_by_id)?"Generate Thumbnail":"You do not have permission to generate thumbnails",disabled:Ie.isPending||!i("library","update",de.created_by_id),children:a.jsx(Du,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>i("library","delete",de.created_by_id)&&T({type:"file",id:de.id}),className:`p-1.5 rounded transition-colors ${i("library","delete",de.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:i("library","delete",de.created_by_id)?"Delete":"You do not have permission to delete this file",disabled:!i("library","delete",de.created_by_id),children:a.jsx(an,{className:"w-4 h-4"})})]})]},de.id))]})})]})]}),m&&a.jsx(uXe,{parentId:c,onClose:()=>p(!1),onSave:de=>V.mutate(de),isLoading:V.isPending}),x&&K&&a.jsx(hXe,{folders:K,selectedFiles:d,currentFolderId:c,onClose:()=>b(!1),onMove:de=>Me.mutate({fileIds:d,folderId:de}),isLoading:Me.isPending}),y&&a.jsx(mXe,{folderId:c,onClose:()=>v(!1),onUploadComplete:we}),S&&a.jsx(fXe,{folder:S,onClose:()=>N(null),onLink:de=>ie.mutate({id:S.id,data:de}),isLoading:ie.isPending}),C&&a.jsx(Yn,{title:C.type==="folder"?"Delete Folder":C.type==="bulk"?`Delete ${C.count} Files`:"Delete File",message:C.type==="folder"?"Are you sure you want to delete this folder? All files inside will also be deleted.":C.type==="bulk"?`Are you sure you want to delete ${C.count} selected files? This action cannot be undone.`:"Are you sure you want to delete this file?",confirmText:"Delete",variant:"danger",isLoading:We,loadingText:"Deleting...",onConfirm:ke,onCancel:()=>T(null)}),k&&a.jsx(jh,{mode:"reprint",libraryFileId:k.id,archiveName:k.print_name||k.filename,onClose:()=>E(null),onSuccess:()=>{E(null),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["archives"]})}}),D&&a.jsx(jh,{mode:"reprint",libraryFileId:D.id,archiveName:D.print_name||D.filename,onClose:()=>A(null),onSuccess:()=>{A(null),f([]),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["archives"]})}}),j&&a.jsx(gL,{libraryFileId:j.id,title:j.print_name||j.filename,fileType:j.file_type,onClose:()=>G(null)}),R&&a.jsx(dXe,{type:R.type,currentName:R.name,onClose:()=>F(null),onSave:de=>{R.type==="file"?Le.mutate({id:R.id,filename:de}):$e.mutate({id:R.id,name:de})},isLoading:Le.isPending||$e.isPending})]})}const Xj=5,xXe=2e3,bXe=3e4,yXe=5e3;function vXe(){const{printerId:t}=iN(),e=parseInt(t||"0",10),[n,r]=w.useState("stream"),[i,s]=w.useState(!1),[o,l]=w.useState(!0),[c,u]=w.useState(Date.now()),[d,f]=w.useState(!1),[m,p]=w.useState(!1),[x,b]=w.useState(0),[y,v]=w.useState(!1),[S,N]=w.useState(0),[C,T]=w.useState(1),[k,E]=w.useState({x:0,y:0}),[D,A]=w.useState(!1),[R,F]=w.useState({x:0,y:0}),[O,H]=w.useState(null),[j,G]=w.useState(null),$=w.useRef(null),q=w.useRef(null),Y=w.useRef(null),Z=w.useRef(null),oe=w.useRef(null),{data:B}=at({queryKey:["printer",e],queryFn:()=>ue.getPrinter(e),enabled:e>0});w.useEffect(()=>(B&&(document.title=`${B.name} - Camera`),()=>{document.title="Bambuddy"}),[B]);const W=w.useRef(!1);w.useEffect(()=>{const X=`/api/v1/printers/${e}/camera/stop`;W.current=!1;const te=()=>{e>0&&!W.current&&(W.current=!0,navigator.sendBeacon(X))},Me=()=>{te()};window.addEventListener("beforeunload",Me);const ie=$.current;return()=>{window.removeEventListener("beforeunload",Me),ie&&(ie.src=""),te()}},[e]),w.useEffect(()=>{if(o&&!d){const te=setTimeout(()=>{l(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(te)}},[n,o,c,d]),w.useEffect(()=>{const X=()=>{const te=!!document.fullscreenElement;p(te),T(1),E({x:0,y:0}),n==="stream"&&!d&&($.current&&($.current.src=""),setTimeout(()=>{l(!0),u(Date.now())},200))};return document.addEventListener("fullscreenchange",X),()=>document.removeEventListener("fullscreenchange",X)},[n,d]),w.useEffect(()=>{let X;const te=()=>{clearTimeout(X),X=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener("resize",te),()=>{clearTimeout(X),window.removeEventListener("resize",te)}},[]),w.useEffect(()=>()=>{Y.current&&clearTimeout(Y.current),Z.current&&clearInterval(Z.current),oe.current&&clearInterval(oe.current)},[]);const se=w.useCallback(()=>{if(x>=Xj){v(!1),s(!0);return}const X=Math.min(xXe*Math.pow(2,x),bXe);v(!0),N(Math.ceil(X/1e3)),Z.current=setInterval(()=>{N(te=>te<=1?(Z.current&&clearInterval(Z.current),0):te-1)},1e3),Y.current=setTimeout(()=>{b(te=>te+1),v(!1),l(!0),s(!1),$.current&&($.current.src=""),u(Date.now())},X)},[x]);w.useEffect(()=>{if(n!=="stream"||o||y||d){oe.current&&(clearInterval(oe.current),oe.current=null);return}return oe.current=setInterval(async()=>{try{const X=await fetch(`/api/v1/printers/${e}/camera/status`);if(X.ok){const te=await X.json();(te.stalled||!te.active&&!i)&&(console.log(`Stream issue detected: stalled=${te.stalled}, active=${te.active}, reconnecting...`),oe.current&&(clearInterval(oe.current),oe.current=null),l(!1),se())}}catch{}},yXe),()=>{oe.current&&(clearInterval(oe.current),oe.current=null)}},[n,o,i,y,d,e,se]);const ne=()=>{l(!1),n==="stream"&&x<Xj?se():s(!0)},ce=()=>{if(l(!1),s(!1),b(0),v(!1),Y.current&&clearTimeout(Y.current),Z.current&&clearInterval(Z.current),$.current&&!localStorage.getItem("cameraWindowState")){const X=$.current,te=X.naturalWidth,Me=X.naturalHeight;if(te>0&&Me>0){const Le=window.outerWidth-window.innerWidth,$e=window.outerHeight-window.innerHeight,Ze=te+16+Le,Ie=Me+45+16+$e;try{window.resizeTo(Ze,Ie)}catch{}}}},fe=()=>{e>0&&fetch(`/api/v1/printers/${e}/camera/stop`).catch(()=>{})},ye=X=>{n===X||d||(f(!0),l(!0),s(!1),b(0),v(!1),T(1),E({x:0,y:0}),Y.current&&clearTimeout(Y.current),Z.current&&clearInterval(Z.current),$.current&&($.current.src=""),n==="stream"&&fe(),setTimeout(()=>{r(X),u(Date.now()),f(!1)},100))},ge=()=>{d||(f(!0),l(!0),s(!1),b(0),v(!1),Y.current&&clearTimeout(Y.current),Z.current&&clearInterval(Z.current),$.current&&($.current.src=""),n==="stream"&&fe(),setTimeout(()=>{u(Date.now()),f(!1)},100))},xe=()=>{q.current&&(document.fullscreenElement?document.exitFullscreen():q.current.requestFullscreen())},Pe=()=>{T(X=>Math.min(X+.5,4))},Ue=()=>{T(X=>{const te=Math.max(X-.5,1);return te===1&&E({x:0,y:0}),te})},be=X=>{X.preventDefault(),X.deltaY<0?Pe():Ue()},it=X=>{C>1&&(X.preventDefault(),A(!0),F({x:X.clientX-k.x,y:X.clientY-k.y}))},U=w.useCallback(()=>{if(!q.current)return{x:300,y:200};const X=q.current.getBoundingClientRect(),te=X.width*(C-1)/2,Me=X.height*(C-1)/2;return{x:Math.max(50,te),y:Math.max(50,Me)}},[C]),K=X=>{if(D&&C>1){const te=X.clientX-R.x,Me=X.clientY-R.y,ie=U();E({x:Math.max(-ie.x,Math.min(ie.x,te)),y:Math.max(-ie.y,Math.min(ie.y,Me))})}},J=()=>{A(!1)},Q=X=>{if(X.length<2)return 0;const te=X[0].clientX-X[1].clientX,Me=X[0].clientY-X[1].clientY;return Math.sqrt(te*te+Me*Me)},z=X=>X.length<2?{x:X[0].clientX,y:X[0].clientY}:{x:(X[0].clientX+X[1].clientX)/2,y:(X[0].clientY+X[1].clientY)/2},re=X=>{X.touches.length===2?(X.preventDefault(),H(Q(X.touches)),G(z(X.touches))):X.touches.length===1&&C>1&&(X.preventDefault(),A(!0),F({x:X.touches[0].clientX-k.x,y:X.touches[0].clientY-k.y}))},Ee=X=>{if(X.touches.length===2&&O!==null){X.preventDefault();const te=Q(X.touches),Me=te/O;T(De=>{const Le=Math.max(1,Math.min(4,De*Me));return Le===1&&E({x:0,y:0}),Le}),H(te);const ie=z(X.touches);if(j){const De=U();E(Le=>({x:Math.max(-De.x,Math.min(De.x,Le.x+(ie.x-j.x))),y:Math.max(-De.y,Math.min(De.y,Le.y+(ie.y-j.y)))}))}G(ie)}else if(X.touches.length===1&&D&&C>1){X.preventDefault();const te=X.touches[0].clientX-R.x,Me=X.touches[0].clientY-R.y,ie=U();E({x:Math.max(-ie.x,Math.min(ie.x,te)),y:Math.max(-ie.y,Math.min(ie.y,Me))})}},_e=X=>{X.touches.length<2&&(H(null),G(null)),X.touches.length===0&&A(!1)},Te=()=>{T(1),E({x:0,y:0})},V=d?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=15&t=${c}`:`/api/v1/printers/${e}/camera/snapshot?t=${c}`,L=o||d||y;return e?a.jsxs("div",{ref:q,className:"min-h-screen bg-black flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[a.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[a.jsx(Ug,{className:"w-4 h-4"}),B?.name||`Printer ${e}`]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[a.jsx("button",{onClick:()=>ye("stream"),disabled:L,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"}),a.jsx("button",{onClick:()=>ye("snapshot"),disabled:L,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"})]}),a.jsx("button",{onClick:ge,disabled:L,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:a.jsx(Pr,{className:`w-4 h-4 text-bambu-gray ${L?"animate-spin":""}`})}),a.jsx("button",{onClick:xe,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:m?"Exit fullscreen":"Fullscreen",children:m?a.jsx(CW,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(Ude,{className:"w-4 h-4 text-bambu-gray"})})]})]}),a.jsx("div",{className:"flex-1 flex items-center justify-center p-2 overflow-hidden",onWheel:be,onMouseMove:K,onMouseUp:J,onMouseLeave:J,onTouchStart:re,onTouchMove:Ee,onTouchEnd:_e,style:{touchAction:"none"},children:a.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(o||d)&&!y&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:a.jsxs("div",{className:"text-center",children:[a.jsx(Pr,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:n==="stream"?"Connecting to camera...":"Capturing snapshot..."})]})}),y&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:a.jsxs("div",{className:"text-center p-4",children:[a.jsx(sm,{className:"w-10 h-10 text-orange-400 mx-auto mb-3"}),a.jsx("p",{className:"text-white mb-2",children:"Connection lost"}),a.jsxs("p",{className:"text-sm text-bambu-gray mb-3",children:["Reconnecting in ",S,"s... (attempt ",x+1,"/",Xj,")"]}),a.jsx("button",{onClick:ge,className:"px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors",children:"Reconnect now"})]})}),i&&!y&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:a.jsxs("div",{className:"text-center p-4",children:[a.jsx(jn,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),a.jsx("p",{className:"text-white mb-2",children:"Camera unavailable"}),a.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:"Make sure the printer is powered on and connected."}),a.jsx("button",{onClick:ge,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),a.jsx("img",{ref:$,src:V,alt:"Camera stream",className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${C}) translate(${k.x/C}px, ${k.y/C}px)`,cursor:C>1?D?"grabbing":"grab":"default"},onError:V?ne:void 0,onLoad:V?ce:void 0,onMouseDown:it,draggable:!1},c),a.jsxs("div",{className:"absolute bottom-4 left-4 flex items-center gap-1.5 bg-black/60 rounded-lg px-2 py-1.5",children:[a.jsx("button",{onClick:Ue,disabled:C<=1,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:a.jsx(FD,{className:"w-4 h-4 text-white"})}),a.jsxs("button",{onClick:Te,className:"px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]",title:"Reset zoom",children:[Math.round(C*100),"%"]}),a.jsx("button",{onClick:Pe,disabled:C>=4,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:a.jsx(ID,{className:"w-4 h-4 text-white"})})]})]})})]}):a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-white",children:"Invalid printer ID"})})}function _Xe(t){const e=t.get("show")?.split(",")||["progress","layers","eta","filename","status"],n=parseInt(t.get("fps")||"15",10),r=Math.min(Math.max(isNaN(n)?15:n,1),30),i=t.get("camera"),s=i!=="false"&&i!=="0";return{size:t.get("size")||"medium",fps:r,showCamera:s,showProgress:e.includes("progress"),showLayers:e.includes("layers"),showEta:e.includes("eta"),showFilename:e.includes("filename"),showStatus:e.includes("status"),showPrinter:e.includes("printer")}}function wXe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function SXe(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"});return i.getTime()===r.getTime()?s:i.getTime()===r.getTime()+864e5?`Tomorrow ${s}`:n.toLocaleDateString([],{weekday:"short"})+" "+s}function NXe(t){if(t.stg_cur_name)return t.stg_cur_name;switch(t.state){case"RUNNING":return"Printing";case"PAUSE":return"Paused";case"FINISH":return"Finished";case"FAILED":return"Failed";case"IDLE":return"Idle";default:return t.state||"Unknown"}}function MXe(t){switch(t){case"small":return{container:"p-3",text:"text-sm",textLarge:"text-lg",progressHeight:"h-2",icon:"w-3 h-3",gap:"gap-2",logoHeight:"h-12"};case"large":return{container:"p-6",text:"text-xl",textLarge:"text-3xl",progressHeight:"h-4",icon:"w-6 h-6",gap:"gap-4",logoHeight:"h-24"};case"medium":default:return{container:"p-4",text:"text-base",textLarge:"text-xl",progressHeight:"h-3",icon:"w-4 h-4",gap:"gap-3",logoHeight:"h-16"}}}function EXe(){const{printerId:t}=iN(),[e]=wD(),n=on(),r=parseInt(t||"0",10),[i,s]=w.useState(Date.now()),o=w.useMemo(()=>_Xe(e),[e]),l=MXe(o.size),{data:c}=at({queryKey:["printer",r],queryFn:()=>ue.getPrinter(r),enabled:r>0}),{data:u}=at({queryKey:["printerStatus",r],queryFn:()=>ue.getPrinterStatus(r),enabled:r>0,refetchInterval:2e3});w.useEffect(()=>{if(!r)return;const b=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,y=new WebSocket(b);return y.onmessage=v=>{try{const S=JSON.parse(v.data);S.type==="printer_status"&&S.printer_id===r&&n.setQueryData(["printerStatus",r],S.status)}catch{}},y.onerror=()=>{},()=>{y.close()}},[r,n]),w.useEffect(()=>(document.title=c?`${c.name} - Stream Overlay`:"Stream Overlay",()=>{document.title="Bambuddy"}),[c]);const d=()=>{setTimeout(()=>{s(Date.now())},3e3)};if(!r)return a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-white",children:"Invalid printer ID"})});if(!u)return a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-gray-400",children:"Loading..."})});const f=u.state==="RUNNING"||u.state==="PAUSE",m=u.progress||0,p=`/api/v1/printers/${r}/camera/stream?fps=${o.fps}&t=${i}`;return a.jsxs("div",{className:"min-h-screen bg-black relative overflow-hidden",children:[o.showCamera&&a.jsx("img",{src:p,alt:"Camera stream",className:"absolute inset-0 w-full h-full object-contain",onError:d},i),a.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"absolute top-4 right-4 z-10",children:a.jsx("img",{src:"/img/bambuddy_logo_dark_transparent.png",alt:"Bambuddy",className:`${l.logoHeight} object-contain drop-shadow-lg hover:scale-105 transition-transform`})}),a.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-10 bg-gradient-to-t from-black/80 via-black/60 to-transparent",children:a.jsxs("div",{className:`${l.container}`,children:[o.showPrinter&&c&&a.jsxs("div",{className:`flex items-center ${l.gap} mb-2`,children:[a.jsx(Ir,{className:`${l.icon} text-white/70`}),a.jsx("span",{className:`${l.text} text-white font-medium`,children:c.name})]}),o.showFilename&&u.current_print&&a.jsx("div",{className:`${l.textLarge} text-white font-semibold mb-2 truncate drop-shadow-md`,children:u.current_print.replace(/\.gcode\.3mf$|\.3mf$|\.gcode$/i,"")}),o.showStatus&&a.jsx("div",{className:`${l.text} text-white/70 mb-2`,children:NXe(u)}),o.showProgress&&f&&a.jsxs("div",{className:"mb-3",children:[a.jsxs("div",{className:`flex items-center justify-between mb-1 ${l.text}`,children:[a.jsx("span",{className:"text-white/70",children:"Progress"}),a.jsxs("span",{className:"text-white font-bold",children:[Math.round(m),"%"]})]}),a.jsx("div",{className:`w-full bg-white/20 rounded-full ${l.progressHeight}`,children:a.jsx("div",{className:`bg-bambu-green ${l.progressHeight} rounded-full transition-all duration-500`,style:{width:`${m}%`}})})]}),f&&(o.showLayers||o.showEta)&&a.jsxs("div",{className:`flex items-center ${l.gap} flex-wrap`,children:[o.showLayers&&u.layer_num!=null&&u.total_layers!=null&&u.total_layers>0&&a.jsxs("div",{className:`flex items-center ${l.gap} text-white/70`,children:[a.jsx(xs,{className:l.icon}),a.jsxs("span",{className:l.text,children:[a.jsx("span",{className:"text-white",children:u.layer_num}),a.jsx("span",{className:"mx-1",children:"/"}),a.jsx("span",{children:u.total_layers})]})]}),o.showEta&&u.remaining_time!=null&&u.remaining_time>0&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:`flex items-center ${l.gap} text-white/70`,children:[a.jsx(gu,{className:l.icon}),a.jsx("span",{className:`${l.text} text-white`,children:wXe(u.remaining_time*60)})]}),a.jsxs("div",{className:`flex items-center ${l.gap} text-white/70`,children:[a.jsx(Qn,{className:l.icon}),a.jsxs("span",{className:`${l.text} text-white`,children:["ETA ",SXe(u.remaining_time)]})]})]})]}),!f&&a.jsx("div",{className:`${l.text} text-white/70 py-2`,children:u.connected?"Printer is idle":"Printer offline"})]})})]})}function CXe(){const{id:t}=iN(),{mode:e}=Oh(),{data:n,isLoading:r,error:i}=at({queryKey:["external-link",t],queryFn:()=>ue.getExternalLink(Number(t)),enabled:!!t});return r?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx(ct,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i||!n?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[a.jsx(jn,{className:"w-12 h-12"}),a.jsx("p",{children:"Link not found"})]}):a.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"})}const wq=["DEBUG","INFO","WARNING","ERROR"],Yj={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},TXe={DEBUG:sN,INFO:Qo,WARNING:jn,ERROR:Ii};function AXe(){const t=on(),[e,n]=w.useState(!0),[r,i]=w.useState(new Set),[s,o]=w.useState(""),[l,c]=w.useState("ALL"),[u,d]=w.useState(!1),[f,m]=w.useState(!1),p=w.useRef(null),{data:x,isLoading:b,refetch:y}=at({queryKey:["application-logs",l,s],queryFn:()=>Ng.getLogs({limit:200,level:l==="ALL"?void 0:l,search:s||void 0}),refetchInterval:f?2e3:!1,enabled:u});w.useEffect(()=>{u||m(!1)},[u]);const v=mt({mutationFn:()=>Ng.clearLogs(),onSuccess:()=>{t.invalidateQueries({queryKey:["application-logs"]})}});w.useEffect(()=>{e&&p.current&&x?.entries&&(p.current.scrollTop=p.current.scrollHeight)},[x?.entries,e]);const S=E=>{i(D=>{const A=new Set(D);return A.has(E)?A.delete(E):A.add(E),A})},N=E=>{const D=E.split(" ");return D.length>=2?D[1]:E},C=w.useMemo(()=>x?.entries??[],[x?.entries]),T=w.useMemo(()=>[...C].reverse(),[C]),k=({level:E})=>{const D=TXe[E]||Qo;return a.jsx(D,{className:`w-3.5 h-3.5 ${Yj[E]||"text-gray-400"}`})};return a.jsxs("div",{className:"bg-bambu-dark rounded-lg overflow-hidden",children:[a.jsxs("button",{onClick:()=>d(!u),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/50 transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${f?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:a.jsx(sN,{className:"w-5 h-5"})}),a.jsxs("div",{className:"text-left",children:[a.jsx("p",{className:"font-medium text-white",children:"Application Logs"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:f?`Live streaming - ${x?.filtered_count??0} entries`:"View and filter application logs"})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[f&&a.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-1 bg-bambu-green/20 rounded text-bambu-green text-xs",children:[a.jsx("span",{className:"w-1.5 h-1.5 bg-bambu-green rounded-full animate-pulse"}),"Live"]}),u?a.jsx(xh,{className:"w-5 h-5 text-bambu-gray"}):a.jsx(Xr,{className:"w-5 h-5 text-bambu-gray"})]})]}),u&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[f?a.jsxs("button",{onClick:E=>{E.stopPropagation(),m(!1)},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-red-500/20 text-red-400 hover:bg-red-500/30 rounded transition-colors",children:[a.jsx(il,{className:"w-4 h-4"}),"Stop"]}):a.jsxs("button",{onClick:E=>{E.stopPropagation(),m(!0),y()},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 rounded transition-colors",children:[a.jsx(Us,{className:"w-4 h-4"}),"Start"]}),a.jsxs("button",{onClick:()=>v.mutate(),disabled:v.isPending||C.length===0,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:[a.jsx(an,{className:"w-4 h-4"}),"Clear"]}),a.jsx("button",{onClick:()=>y(),disabled:b,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:a.jsx(Pr,{className:`w-4 h-4 ${b?"animate-spin":""}`})}),a.jsx("div",{className:"flex-1"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:e,onChange:E=>n(E.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark-tertiary"}),"Auto-scroll"]}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:[x?.filtered_count??0,"/",x?.total_in_file??0]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(pa,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:"Search message or logger name...",value:s,onChange:E=>o(E.target.value),className:"w-full pl-8 pr-8 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),s&&a.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:a.jsx(Dt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark-secondary rounded border border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>c("ALL"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${l==="ALL"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),wq.map((E,D)=>a.jsx("button",{onClick:()=>c(E),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${D===wq.length-1?"rounded-r":""} ${l===E?`${Yj[E]} bg-bambu-dark-tertiary`:"text-bambu-gray hover:text-white"}`,children:E},E))]})]})]}),a.jsx("div",{ref:p,className:"overflow-auto font-mono text-xs bg-black min-h-[300px] max-h-[500px]",children:C.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-[300px] text-bambu-gray",children:[a.jsx("p",{className:"mb-2",children:"No log entries found"}),a.jsx("p",{className:"text-sm",children:"Log file may be empty or cleared"})]}):a.jsx("div",{className:"divide-y divide-bambu-dark-tertiary/30",children:T.map((E,D)=>{const A=r.has(D),R=E.message.includes(`
  8291. `);return a.jsx("div",{className:`p-2 cursor-pointer hover:bg-bambu-dark-secondary/50 transition-colors ${A?"bg-bambu-dark-secondary/30":""}`,onClick:()=>R&&S(D),children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("span",{className:"text-bambu-gray/70 shrink-0 w-20",children:N(E.timestamp)}),a.jsx("span",{className:"shrink-0",children:a.jsx(k,{level:E.level})}),a.jsxs("span",{className:"text-purple-400/80 shrink-0 max-w-[200px] truncate",title:E.logger_name,children:["[",E.logger_name,"]"]}),a.jsx("span",{className:`flex-1 ${Yj[E.level]||"text-white/80"} ${!A&&R?"truncate":""}`,children:A?a.jsx("pre",{className:"whitespace-pre-wrap break-all",children:E.message}):E.message.split(`
  8292. `)[0]}),R&&a.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:A?a.jsx(xh,{className:"w-3.5 h-3.5"}):a.jsx(Xr,{className:"w-3.5 h-3.5"})})]})},D)})})}),a.jsx("div",{className:"flex items-center justify-between p-3 border-t border-bambu-dark-tertiary text-sm text-bambu-gray",children:f?a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Auto-refreshing every 2 seconds"]}):a.jsx("span",{children:"Click Start to enable live log streaming"})})]})]})}function kXe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function ui({icon:t,label:e,value:n,subValue:r,color:i="text-bambu-green"}){return a.jsxs("div",{className:"flex items-start gap-3 p-4 bg-bambu-dark rounded-lg",children:[a.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark-tertiary ${i}`,children:a.jsx(t,{className:"w-5 h-5"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:e}),a.jsx("p",{className:"text-lg font-semibold text-white truncate",children:n}),r&&a.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:r})]})]})}function Sq({percent:t,color:e="bg-bambu-green"}){return a.jsx("div",{className:"w-full h-2 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full ${e} transition-all duration-300`,style:{width:`${Math.min(100,t)}%`}})})}function Ld({title:t,icon:e,children:n}){return a.jsxs(wt,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[a.jsx(e,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t})]}),n]})}function jXe(){const{t}=Oy(),e=on(),[n,r]=w.useState(null),[i,s]=w.useState(!1),[o,l]=w.useState(!1),{data:c,isLoading:u,refetch:d,isFetching:f}=at({queryKey:["systemInfo"],queryFn:ue.getSystemInfo,refetchInterval:3e4}),{data:m}=at({queryKey:["debugLogging"],queryFn:Ng.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:p}=at({queryKey:["settings"],queryFn:ue.getSettings}),{data:x}=at({queryKey:["library-stats"],queryFn:ue.getLibraryStats}),b=p?.time_format||"system",y=async()=>{l(!0);try{const C=await Ng.setDebugLogging(!m?.enabled);e.setQueryData(["debugLogging"],C)}catch(C){console.error("Failed to toggle debug logging:",C)}finally{l(!1)}},v=async()=>{r(null),s(!0);try{await Ng.downloadSupportBundle()}catch(C){r(C instanceof Error?C.message:"Failed to download support bundle")}finally{s(!1)}};if(u)return a.jsx("div",{className:"flex items-center justify-center h-64",children:a.jsx(ct,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(!c)return a.jsx("div",{className:"p-6 text-center text-bambu-gray",children:t("system.failedToLoad","Failed to load system information")});const S=c.storage.disk_percent_used>90?"bg-red-500":c.storage.disk_percent_used>75?"bg-yellow-500":"bg-bambu-green",N=c.memory.percent_used>90?"bg-red-500":c.memory.percent_used>75?"bg-yellow-500":"bg-bambu-green";return a.jsxs("div",{className:"p-6 space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("system.title","System Information")}),a.jsx("p",{className:"text-bambu-gray mt-1",children:t("system.subtitle","Monitor system resources and database statistics")})]}),a.jsxs("button",{onClick:()=>d(),disabled:f,className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary rounded-lg transition-colors disabled:opacity-50",children:[a.jsx(Pr,{className:`w-4 h-4 ${f?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),a.jsx(Ld,{title:t("system.application","Application"),icon:yf,children:a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[a.jsx(ui,{icon:yf,label:t("system.version","Version"),value:`v${c.app.version}`}),a.jsx(ui,{icon:Qn,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),a.jsx(ui,{icon:yf,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),a.jsx(Ld,{title:t("support.title","Support & Troubleshooting"),icon:lde,children:a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.description","Enable debug logging to capture detailed information, then download a support bundle to share when reporting issues.")}),a.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${m?.enabled?"bg-amber-500/20 text-amber-500":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:a.jsx(sN,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-white",children:t("support.debugLogging","Debug Logging")}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[m?.enabled?t("support.debugLoggingEnabled","Capturing detailed logs"):t("support.debugLoggingDisabled","Normal logging level"),m?.enabled&&m.duration_seconds!==null&&a.jsxs("span",{className:"text-amber-400 ml-2",children:["(",Math.floor(m.duration_seconds/60),"m ",m.duration_seconds%60,"s)"]})]})]})]}),a.jsxs("button",{onClick:y,disabled:o,className:`px-4 py-2 rounded-lg font-medium transition-colors flex items-center gap-2 ${m?.enabled?"bg-amber-500/20 text-amber-400 hover:bg-amber-500/30":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30"} disabled:opacity-50`,children:[o&&a.jsx(ct,{className:"w-4 h-4 animate-spin"}),m?.enabled?t("support.disableDebug","Disable"):t("support.enableDebug","Enable")]})]}),a.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-green",children:a.jsx(pi,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-white",children:t("support.supportBundle","Support Bundle")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.supportBundleDescription","Download system info and logs as a ZIP file")})]})]}),a.jsxs("button",{onClick:v,disabled:i||!m?.enabled,className:"px-4 py-2 rounded-lg font-medium bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",title:m?.enabled?void 0:t("support.enableDebugFirst","Enable debug logging first"),children:[i&&a.jsx(ct,{className:"w-4 h-4 animate-spin"}),t("common.download","Download")]})]}),n&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/30 rounded-lg text-red-400 text-sm",children:n}),!m?.enabled&&a.jsx("div",{className:"p-4 bg-bambu-dark-tertiary/50 rounded-lg",children:a.jsxs("p",{className:"text-sm text-bambu-gray",children:[a.jsx("span",{className:"text-amber-400 font-medium",children:t("support.instructions","To report an issue:")}),a.jsx("br",{}),"1. ",t("support.step1","Enable debug logging"),a.jsx("br",{}),"2. ",t("support.step2","Reproduce the issue"),a.jsx("br",{}),"3. ",t("support.step3","Download the support bundle"),a.jsx("br",{}),"4. ",t("support.step4","Attach the ZIP file to your issue report")]})}),a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg space-y-3",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:t("support.privacyTitle","What's in the support bundle?")}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-bambu-green font-medium mb-1",children:t("support.collected","Collected:")}),a.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[a.jsxs("li",{children:["• ",t("support.collectItem1","App version and debug mode")]}),a.jsxs("li",{children:["• ",t("support.collectItem2","OS, architecture, Python version")]}),a.jsxs("li",{children:["• ",t("support.collectItem3","Database statistics (counts only)")]}),a.jsxs("li",{children:["• ",t("support.collectItem4","Printer models and nozzle counts")]}),a.jsxs("li",{children:["• ",t("support.collectItem5","Non-sensitive settings (themes, formats)")]}),a.jsxs("li",{children:["• ",t("support.collectItem6","Debug logs (sanitized)")]})]})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-red-400 font-medium mb-1",children:t("support.notCollected","NOT collected:")}),a.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[a.jsxs("li",{children:["• ",t("support.notItem1","Printer names, IPs, serial numbers")]}),a.jsxs("li",{children:["• ",t("support.notItem2","Access codes and passwords")]}),a.jsxs("li",{children:["• ",t("support.notItem3","Email addresses")]}),a.jsxs("li",{children:["• ",t("support.notItem4","API keys and tokens")]}),a.jsxs("li",{children:["• ",t("support.notItem5","Webhook URLs")]}),a.jsxs("li",{children:["• ",t("support.notItem6","Your hostname or username")]})]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray/70",children:t("support.privacyNote","IP addresses in logs are replaced with [IP] and email addresses with [EMAIL].")})]}),a.jsx(AXe,{})]})}),a.jsxs(Ld,{title:t("system.database","Database"),icon:Nu,children:[a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[a.jsx(ui,{icon:fo,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),a.jsx(ui,{icon:oN,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),a.jsx(ui,{icon:qi,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),a.jsx(ui,{icon:ct,label:t("system.printing","Printing"),value:c.database.archives_printing,color:"text-yellow-500"})]}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(ui,{icon:Ir,label:t("system.printers","Printers"),value:c.database.printers}),a.jsx(ui,{icon:TW,label:t("system.filaments","Filaments"),value:c.database.filaments}),a.jsx(ui,{icon:Qa,label:t("system.projects","Projects"),value:c.database.projects}),a.jsx(ui,{icon:el,label:t("system.smartPlugs","Smart Plugs"),value:c.database.smart_plugs})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[a.jsx(ui,{icon:Qn,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),a.jsx(ui,{icon:fo,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),a.jsxs(Ld,{title:t("system.connectedPrinters","Connected Printers"),icon:Ir,children:[a.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[a.jsx("div",{className:"text-3xl font-bold text-bambu-green",children:c.printers.connected}),a.jsx("div",{className:"text-bambu-gray",children:t("system.ofTotal","of {{total}} printers connected",{total:c.printers.total})})]}),c.printers.connected_list.length>0?a.jsx("div",{className:"space-y-2",children:c.printers.connected_list.map(C=>a.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green"}),a.jsx("span",{className:"font-medium text-white",children:C.name})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[a.jsx("span",{children:C.model}),a.jsx("span",{className:`px-2 py-0.5 rounded ${C.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":C.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:C.state})]})]},C.id))}):a.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),a.jsx(Ld,{title:t("system.storage","Storage"),icon:fN,children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:t("system.diskUsage","Disk Usage")}),a.jsxs("span",{className:"text-white",children:[c.storage.disk_used_formatted," / ",c.storage.disk_total_formatted]})]}),a.jsx(Sq,{percent:c.storage.disk_percent_used,color:S}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.storage.disk_free_formatted," ",t("system.free","free")," (",(100-c.storage.disk_percent_used).toFixed(1),"%)"]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[a.jsx(ui,{icon:fo,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),a.jsx(ui,{icon:Nu,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),x&&a.jsx(ui,{icon:Il,label:t("system.fileManagerStorage","File Manager"),value:kXe(x.total_size_bytes),subValue:`${x.total_files} files, ${x.total_folders} folders`})]})]})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[a.jsx(Ld,{title:t("system.memory","Memory"),icon:Bde,children:a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:t("system.memoryUsage","Memory Usage")}),a.jsxs("span",{className:"text-white",children:[c.memory.used_formatted," / ",c.memory.total_formatted]})]}),a.jsx(Sq,{percent:c.memory.percent_used,color:N}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.memory.available_formatted," ",t("system.available","available")]})]})})}),a.jsx(Ld,{title:t("system.cpu","CPU"),icon:D_,children:a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(ui,{icon:D_,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),a.jsx(ui,{icon:D_,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),a.jsx(Ld,{title:t("system.systemDetails","System Details"),icon:yf,children:a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(ui,{icon:yf,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),a.jsx(ui,{icon:D_,label:t("system.architecture","Architecture"),value:c.system.architecture}),a.jsx(ui,{icon:yf,label:t("system.python","Python"),value:c.system.python_version}),a.jsx(ui,{icon:Qn,label:t("system.bootTime","Boot Time"),value:$g(c.system.boot_time,b)})]})})]})}function PXe(){const t=Mc(),{login:e}=Si(),{showToast:n}=Vn(),{mode:r}=Oh(),[i,s]=w.useState(""),[o,l]=w.useState(""),[c,u]=w.useState(!1),d=mt({mutationFn:()=>e(i,o),onSuccess:()=>{n("Logged in successfully"),t("/")},onError:m=>{n(m.message||"Login failed","error")}}),f=m=>{if(m.preventDefault(),!i||!o){n("Please enter username and password","error");return}d.mutate()};return a.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:[a.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"flex items-center justify-center mb-6",children:a.jsx("img",{src:r==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),a.jsx("h2",{className:"text-3xl font-bold text-white",children:"Bambuddy Login"}),a.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"Sign in to your account"})]}),a.jsxs("form",{className:"mt-8 space-y-6",onSubmit:f,children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-white mb-2",children:"Username"}),a.jsx("input",{id:"username",type:"text",required:!0,value:i,onChange:m=>s(m.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter your username",autoComplete:"username"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-white mb-2",children:"Password"}),a.jsx("input",{id:"password",type:"password",required:!0,value:o,onChange:m=>l(m.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter your password",autoComplete:"current-password"})]})]}),a.jsx("div",{children:a.jsx("button",{type:"submit",disabled:d.isPending,className:"w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green",children:d.isPending?"Logging in...":"Sign in"})}),a.jsx("div",{className:"text-center",children:a.jsx("button",{type:"button",onClick:()=>u(!0),className:"text-sm text-bambu-gray hover:text-bambu-green transition-colors",children:"Forgot your password?"})})]})]}),c&&a.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>u(!1),children:a.jsxs("div",{className:"w-full max-w-md bg-bambu-card rounded-xl border border-bambu-dark-tertiary shadow-lg p-6",onClick:m=>m.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Jce,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Forgot Password"})]}),a.jsx("button",{onClick:()=>u(!1),className:"p-1 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",children:a.jsx(Dt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-bambu-gray",children:"If you've forgotten your password, please contact your system administrator to reset it."}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4 space-y-2",children:[a.jsx("p",{className:"text-sm text-white font-medium",children:"How to reset your password:"}),a.jsxs("ol",{className:"text-sm text-bambu-gray space-y-1 list-decimal list-inside",children:[a.jsx("li",{children:"Contact your Bambuddy administrator"}),a.jsx("li",{children:"Ask them to reset your password in User Management"}),a.jsx("li",{children:"They can set a new temporary password for you"}),a.jsx("li",{children:"Log in with the new password and change it in Settings"})]})]}),a.jsx("button",{onClick:()=>u(!1),className:"w-full py-2 px-4 bg-bambu-dark-tertiary hover:bg-bambu-dark text-white rounded-lg transition-colors",children:"Got it"})]})]})})]})}function RXe(){const t=Mc(),{showToast:e}=Vn(),{mode:n}=Oh(),{refreshAuth:r}=Si(),[i,s]=w.useState(!1),[o,l]=w.useState(""),[c,u]=w.useState(""),[d,f]=w.useState(""),m=mt({mutationFn:()=>ue.setupAuth({auth_enabled:i,admin_username:i?o:void 0,admin_password:i?c:void 0}),onSuccess:async x=>{await r(),x.auth_enabled?x.admin_created?(e("Authentication enabled and admin user created"),t("/login")):(e("Authentication enabled using existing admin users"),t("/login")):(e("Setup completed"),t("/"))},onError:x=>{e(x.message,"error")}}),p=x=>{if(x.preventDefault(),i&&(o||c)){if(!o||!c){e("Please enter both admin username and password, or leave both empty to use existing admin users","error");return}if(c!==d){e("Passwords do not match","error");return}if(c.length<6){e("Password must be at least 6 characters","error");return}}m.mutate()};return a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:a.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"flex items-center justify-center mb-6",children:a.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),a.jsx("h2",{className:"text-3xl font-bold text-white",children:"Bambuddy Setup"}),a.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"Configure authentication for your Bambuddy instance"})]}),a.jsxs("form",{className:"mt-8 space-y-6",onSubmit:p,children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center p-4 bg-bambu-dark-secondary/50 rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("input",{id:"auth-enabled",type:"checkbox",checked:i,onChange:x=>s(x.target.checked),className:"h-4 w-4 text-bambu-green focus:ring-bambu-green border-bambu-dark-tertiary rounded bg-bambu-dark-secondary"}),a.jsx("label",{htmlFor:"auth-enabled",className:"ml-3 block text-sm font-medium text-white",children:"Enable Authentication"})]}),i&&a.jsxs("div",{className:"space-y-4 mt-4",children:[a.jsx("div",{className:"p-3 bg-bambu-dark-secondary/50 border border-bambu-dark-tertiary rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(Qo,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"text-sm text-bambu-gray",children:[a.jsx("p",{className:"text-white font-medium mb-1",children:"Admin Account"}),a.jsx("p",{children:"If admin users already exist, authentication will be enabled using the existing admin accounts. Leave the fields below empty to use existing admins, or enter new credentials to create a new admin user."})]})]})}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:"admin-username",className:"block text-sm font-medium text-white mb-2",children:["Admin Username ",a.jsx("span",{className:"text-bambu-gray text-xs",children:"(optional if admin users exist)"})]}),a.jsx("input",{id:"admin-username",type:"text",value:o,onChange:x=>l(x.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter admin username (optional)",autoComplete:"username"})]}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:"admin-password",className:"block text-sm font-medium text-white mb-2",children:["Admin Password ",a.jsx("span",{className:"text-bambu-gray text-xs",children:"(optional if admin users exist)"})]}),a.jsx("input",{id:"admin-password",type:"password",value:c,onChange:x=>u(x.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter admin password (optional)",minLength:6,autoComplete:"new-password"})]}),c&&a.jsxs("div",{children:[a.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium text-white mb-2",children:"Confirm Password"}),a.jsx("input",{id:"confirm-password",type:"password",value:d,onChange:x=>f(x.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Confirm admin password",minLength:6,autoComplete:"new-password"})]})]})]}),a.jsx("div",{children:a.jsx("button",{type:"submit",disabled:m.isPending,className:"w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green",children:m.isPending?"Setting up...":"Complete Setup"})})]})]})})}function DXe(){const t=w.useRef(null),e=w.useRef(null),n=on(),[r,i]=w.useState(!1),s=w.useRef(new Set),o=w.useRef(null),l=w.useRef(new Map),c=w.useRef(null),u=w.useRef([]),d=w.useRef(!1),f=w.useRef(()=>{}),m=w.useCallback(()=>{if(d.current||u.current.length===0)return;d.current=!0;const S=()=>{const N=u.current.shift();N?requestAnimationFrame(()=>{f.current(N),u.current.length>0?setTimeout(S,16):d.current=!1}):d.current=!1};S()},[]),p=w.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const N=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,C=new WebSocket(N);let T=null;C.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),T=window.setInterval(()=>{C.readyState===WebSocket.OPEN&&C.send(JSON.stringify({type:"ping"}))},3e4)},C.onmessage=k=>{try{const E=JSON.parse(k.data);E.type==="printer_status"&&E.printer_id!==void 0&&E.data?f.current(E):(u.current.push(E),m())}catch{}},C.onclose=k=>{console.log("[WebSocket] Closed",k.code,k.reason),T&&(clearInterval(T),T=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{p()},3e3)},C.onerror=k=>{console.error("[WebSocket] Error",k),C.close()},t.current=C},[m]),x=w.useCallback((S,N)=>{const C=l.current.get(S)||{};l.current.set(S,{...C,...N}),c.current||(c.current=window.setTimeout(()=>{const T=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{T.forEach((k,E)=>{n.setQueryData(["printerStatus",E],D=>{const A={...D,...k};return A.wifi_signal==null&&D?.wifi_signal!=null&&(A.wifi_signal=D.wifi_signal),A})})})},100))},[n]),b=w.useCallback(S=>{s.current.add(S),o.current&&clearTimeout(o.current),o.current=window.setTimeout(()=>{const N=Array.from(s.current);s.current.clear(),o.current=null;let C=0;N.forEach(T=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[T]})})},C),C+=500})},3e3)},[n]),y=w.useCallback(S=>{switch(S.type){case"printer_status":S.printer_id!==void 0&&S.data&&x(S.printer_id,S.data);break;case"print_start":S.printer_id!==void 0&&n.invalidateQueries({queryKey:["printerStatus",S.printer_id]});break;case"print_complete":b("archives"),b("archiveStats");break;case"archive_created":b("archives"),b("archiveStats");break;case"archive_updated":b("archives");break;case"pong":break;case"plate_not_empty":window.dispatchEvent(new CustomEvent("plate-not-empty",{detail:{printer_id:S.printer_id,printer_name:S.printer_name,message:S.message}}));break}},[n,b,x]);w.useEffect(()=>{f.current=y},[y]),w.useEffect(()=>(p(),()=>{e.current&&clearTimeout(e.current),o.current&&clearTimeout(o.current),c.current&&clearTimeout(c.current),t.current&&t.current.close()}),[p]);const v=w.useCallback(S=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(S))},[]);return{isConnected:r,sendMessage:v}}const OXe=new Zle({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function LXe({children:t}){return DXe(),a.jsx(a.Fragment,{children:t})}function IXe({children:t}){const{authEnabled:e,loading:n,user:r}=Si();return n?a.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e&&!r?a.jsx(Ig,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function FXe({children:t}){const{authEnabled:e,loading:n,user:r,isAdmin:i}=Si();return n?a.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?r?i?a.jsx(a.Fragment,{children:t}):a.jsx(Ig,{to:"/",replace:!0}):a.jsx(Ig,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function UXe({children:t}){const{authEnabled:e,loading:n}=Si();return n?a.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?a.jsx(Ig,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function zXe(){return a.jsx(Efe,{children:a.jsx(Dfe,{children:a.jsx(Jle,{client:OXe,children:a.jsx(jfe,{children:a.jsx(yle,{children:a.jsxs(Koe,{children:[a.jsx(ki,{path:"/setup",element:a.jsx(UXe,{children:a.jsx(RXe,{})})}),a.jsx(ki,{path:"/login",element:a.jsx(PXe,{})}),a.jsx(ki,{path:"/camera/:printerId",element:a.jsx(vXe,{})}),a.jsx(ki,{path:"/overlay/:printerId",element:a.jsx(EXe,{})}),a.jsxs(ki,{element:a.jsx(IXe,{children:a.jsx(LXe,{children:a.jsx(Ffe,{})})}),children:[a.jsx(ki,{index:!0,element:a.jsx(f8e,{})}),a.jsx(ki,{path:"archives",element:a.jsx(mqe,{})}),a.jsx(ki,{path:"queue",element:a.jsx(JWe,{})}),a.jsx(ki,{path:"stats",element:a.jsx(fKe,{})}),a.jsx(ki,{path:"profiles",element:a.jsx(KKe,{})}),a.jsx(ki,{path:"maintenance",element:a.jsx(JKe,{})}),a.jsx(ki,{path:"projects",element:a.jsx(tXe,{})}),a.jsx(ki,{path:"projects/:id",element:a.jsx(lXe,{})}),a.jsx(ki,{path:"files",element:a.jsx(gXe,{})}),a.jsx(ki,{path:"settings",element:a.jsx(FXe,{children:a.jsx(IKe,{})})}),a.jsx(ki,{path:"users",element:a.jsx(Ig,{to:"/settings?tab=users",replace:!0})}),a.jsx(ki,{path:"groups",element:a.jsx(Ig,{to:"/settings?tab=users",replace:!0})}),a.jsx(ki,{path:"system",element:a.jsx(jXe,{})}),a.jsx(ki,{path:"external/:id",element:a.jsx(CXe,{})})]})]})})})})})})}qae.createRoot(document.getElementById("root")).render(a.jsx(w.StrictMode,{children:a.jsx(zXe,{})}));