index-BQgTn9O8.js 3.5 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665
  1. function Aae(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const a=Object.getOwnPropertyDescriptor(r,i);a&&Object.defineProperty(t,i,a.get?a:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var Aw=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function hl(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var zk={exports:{}},kb={};var FU;function Cae(){if(FU)return kb;FU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,a){var o=null;if(a!==void 0&&(o=""+a),i.key!==void 0&&(o=""+i.key),"key"in i){a={};for(var l in i)l!=="key"&&(a[l]=i[l])}else a=i;return i=a.ref,{$$typeof:t,type:r,key:o,ref:i!==void 0?i:null,props:a}}return kb.Fragment=e,kb.jsx=n,kb.jsxs=n,kb}var IU;function jae(){return IU||(IU=1,zk.exports=Cae()),zk.exports}var s=jae(),Bk={exports:{}},yn={};var UU;function Pae(){if(UU)return yn;UU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),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"),p=Symbol.iterator;function m(B){return B===null||typeof B!="object"?null:(B=p&&B[p]||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,X,ne){this.props=B,this.context=X,this.refs=y,this.updater=ne||x}v.prototype.isReactComponent={},v.prototype.setState=function(B,X){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,X,"setState")},v.prototype.forceUpdate=function(B){this.updater.enqueueForceUpdate(this,B,"forceUpdate")};function S(){}S.prototype=v.prototype;function M(B,X,ne){this.props=B,this.context=X,this.refs=y,this.updater=ne||x}var T=M.prototype=new S;T.constructor=M,b(T,v.prototype),T.isPureReactComponent=!0;var E=Array.isArray;function C(){}var k={H:null,A:null,T:null,S:null},R=Object.prototype.hasOwnProperty;function A(B,X,ne){var se=ne.ref;return{$$typeof:t,type:B,key:X,ref:se!==void 0?se:null,props:ne}}function D(B,X){return A(B.type,X,B.props)}function U(B){return typeof B=="object"&&B!==null&&B.$$typeof===t}function F(B){var X={"=":"=0",":":"=2"};return"$"+B.replace(/[=:]/g,function(ne){return X[ne]})}var H=/\/+/g;function j(B,X){return typeof B=="object"&&B!==null&&B.key!=null?F(""+B.key):X.toString(36)}function $(B){switch(B.status){case"fulfilled":return B.value;case"rejected":throw B.reason;default:switch(typeof B.status=="string"?B.then(C,C):(B.status="pending",B.then(function(X){B.status==="pending"&&(B.status="fulfilled",B.value=X)},function(X){B.status==="pending"&&(B.status="rejected",B.reason=X)})),B.status){case"fulfilled":return B.value;case"rejected":throw B.reason}}throw B}function K(B,X,ne,se,be){var xe=typeof B;(xe==="undefined"||xe==="boolean")&&(B=null);var de=!1;if(B===null)de=!0;else switch(xe){case"bigint":case"string":case"number":de=!0;break;case"object":switch(B.$$typeof){case t:case e:de=!0;break;case d:return de=B._init,K(de(B._payload),X,ne,se,be)}}if(de)return be=be(B),de=se===""?"."+j(B,0):se,E(be)?(ne="",de!=null&&(ne=de.replace(H,"$&/")+"/"),K(be,X,ne,"",function(Me){return Me})):be!=null&&(U(be)&&(be=D(be,ne+(be.key==null||B&&B.key===be.key?"":(""+be.key).replace(H,"$&/")+"/")+de)),X.push(be)),1;de=0;var Pe=se===""?".":se+":";if(E(B))for(var ie=0;ie<B.length;ie++)se=B[ie],xe=Pe+j(se,ie),de+=K(se,X,ne,xe,be);else if(ie=m(B),typeof ie=="function")for(B=ie.call(B),ie=0;!(se=B.next()).done;)se=se.value,xe=Pe+j(se,ie++),de+=K(se,X,ne,xe,be);else if(xe==="object"){if(typeof B.then=="function")return K($(B),X,ne,se,be);throw X=String(B),Error("Objects are not valid as a React child (found: "+(X==="[object Object]"?"object with keys {"+Object.keys(B).join(", ")+"}":X)+"). If you meant to render a collection of children, use an array instead.")}return de}function V(B,X,ne){if(B==null)return B;var se=[],be=0;return K(B,se,"","",function(xe){return X.call(ne,xe,be++)}),se}function Q(B){if(B._status===-1){var X=B._result;X=X(),X.then(function(ne){(B._status===0||B._status===-1)&&(B._status=1,B._result=ne)},function(ne){(B._status===0||B._status===-1)&&(B._status=2,B._result=ne)}),B._status===-1&&(B._status=0,B._result=X)}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 X=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(X))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",B);return}console.error(B)},ae={map:V,forEach:function(B,X,ne){V(B,function(){X.apply(this,arguments)},ne)},count:function(B){var X=0;return V(B,function(){X++}),X},toArray:function(B){return V(B,function(X){return X})||[]},only:function(B){if(!U(B))throw Error("React.Children.only expected to receive a single React element child.");return B}};return yn.Activity=f,yn.Children=ae,yn.Component=v,yn.Fragment=n,yn.Profiler=i,yn.PureComponent=M,yn.StrictMode=r,yn.Suspense=c,yn.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=k,yn.__COMPILER_RUNTIME={__proto__:null,c:function(B){return k.H.useMemoCache(B)}},yn.cache=function(B){return function(){return B.apply(null,arguments)}},yn.cacheSignal=function(){return null},yn.cloneElement=function(B,X,ne){if(B==null)throw Error("The argument must be a React element, but you passed "+B+".");var se=b({},B.props),be=B.key;if(X!=null)for(xe in X.key!==void 0&&(be=""+X.key),X)!R.call(X,xe)||xe==="key"||xe==="__self"||xe==="__source"||xe==="ref"&&X.ref===void 0||(se[xe]=X[xe]);var xe=arguments.length-2;if(xe===1)se.children=ne;else if(1<xe){for(var de=Array(xe),Pe=0;Pe<xe;Pe++)de[Pe]=arguments[Pe+2];se.children=de}return A(B.type,be,se)},yn.createContext=function(B){return B={$$typeof:o,_currentValue:B,_currentValue2:B,_threadCount:0,Provider:null,Consumer:null},B.Provider=B,B.Consumer={$$typeof:a,_context:B},B},yn.createElement=function(B,X,ne){var se,be={},xe=null;if(X!=null)for(se in X.key!==void 0&&(xe=""+X.key),X)R.call(X,se)&&se!=="key"&&se!=="__self"&&se!=="__source"&&(be[se]=X[se]);var de=arguments.length-2;if(de===1)be.children=ne;else if(1<de){for(var Pe=Array(de),ie=0;ie<de;ie++)Pe[ie]=arguments[ie+2];be.children=Pe}if(B&&B.defaultProps)for(se in de=B.defaultProps,de)be[se]===void 0&&(be[se]=de[se]);return A(B,xe,be)},yn.createRef=function(){return{current:null}},yn.forwardRef=function(B){return{$$typeof:l,render:B}},yn.isValidElement=U,yn.lazy=function(B){return{$$typeof:d,_payload:{_status:-1,_result:B},_init:Q}},yn.memo=function(B,X){return{$$typeof:u,type:B,compare:X===void 0?null:X}},yn.startTransition=function(B){var X=k.T,ne={};k.T=ne;try{var se=B(),be=k.S;be!==null&&be(ne,se),typeof se=="object"&&se!==null&&typeof se.then=="function"&&se.then(C,Z)}catch(xe){Z(xe)}finally{X!==null&&ne.types!==null&&(X.types=ne.types),k.T=X}},yn.unstable_useCacheRefresh=function(){return k.H.useCacheRefresh()},yn.use=function(B){return k.H.use(B)},yn.useActionState=function(B,X,ne){return k.H.useActionState(B,X,ne)},yn.useCallback=function(B,X){return k.H.useCallback(B,X)},yn.useContext=function(B){return k.H.useContext(B)},yn.useDebugValue=function(){},yn.useDeferredValue=function(B,X){return k.H.useDeferredValue(B,X)},yn.useEffect=function(B,X){return k.H.useEffect(B,X)},yn.useEffectEvent=function(B){return k.H.useEffectEvent(B)},yn.useId=function(){return k.H.useId()},yn.useImperativeHandle=function(B,X,ne){return k.H.useImperativeHandle(B,X,ne)},yn.useInsertionEffect=function(B,X){return k.H.useInsertionEffect(B,X)},yn.useLayoutEffect=function(B,X){return k.H.useLayoutEffect(B,X)},yn.useMemo=function(B,X){return k.H.useMemo(B,X)},yn.useOptimistic=function(B,X){return k.H.useOptimistic(B,X)},yn.useReducer=function(B,X,ne){return k.H.useReducer(B,X,ne)},yn.useRef=function(B){return k.H.useRef(B)},yn.useState=function(B){return k.H.useState(B)},yn.useSyncExternalStore=function(B,X,ne){return k.H.useSyncExternalStore(B,X,ne)},yn.useTransition=function(){return k.H.useTransition()},yn.version="19.2.0",yn}var zU;function px(){return zU||(zU=1,Bk.exports=Pae()),Bk.exports}var _=px();const Jr=hl(_),Dae=Aae({__proto__:null,default:Jr},[_]);var $k={exports:{}},Tb={},Hk={exports:{}},Vk={};var BU;function Rae(){return BU||(BU=1,(function(t){function e(K,V){var Q=K.length;K.push(V);e:for(;0<Q;){var Z=Q-1>>>1,ae=K[Z];if(0<i(ae,V))K[Z]=V,K[Q]=ae,Q=Z;else break e}}function n(K){return K.length===0?null:K[0]}function r(K){if(K.length===0)return null;var V=K[0],Q=K.pop();if(Q!==V){K[0]=Q;e:for(var Z=0,ae=K.length,B=ae>>>1;Z<B;){var X=2*(Z+1)-1,ne=K[X],se=X+1,be=K[se];if(0>i(ne,Q))se<ae&&0>i(be,ne)?(K[Z]=be,K[se]=Q,Z=se):(K[Z]=ne,K[X]=Q,Z=X);else if(se<ae&&0>i(be,Q))K[Z]=be,K[se]=Q,Z=se;else break e}}return V}function i(K,V){var Q=K.sortIndex-V.sortIndex;return Q!==0?Q:K.id-V.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var c=[],u=[],d=1,f=null,p=3,m=!1,x=!1,b=!1,y=!1,v=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;function T(K){for(var V=n(u);V!==null;){if(V.callback===null)r(u);else if(V.startTime<=K)r(u),V.sortIndex=V.expirationTime,e(c,V);else break;V=n(u)}}function E(K){if(b=!1,T(K),!x)if(n(c)!==null)x=!0,C||(C=!0,F());else{var V=n(u);V!==null&&$(E,V.startTime-K)}}var C=!1,k=-1,R=5,A=-1;function D(){return y?!0:!(t.unstable_now()-A<R)}function U(){if(y=!1,C){var K=t.unstable_now();A=K;var V=!0;try{e:{x=!1,b&&(b=!1,S(k),k=-1),m=!0;var Q=p;try{t:{for(T(K),f=n(c);f!==null&&!(f.expirationTime>K&&D());){var Z=f.callback;if(typeof Z=="function"){f.callback=null,p=f.priorityLevel;var ae=Z(f.expirationTime<=K);if(K=t.unstable_now(),typeof ae=="function"){f.callback=ae,T(K),V=!0;break t}f===n(c)&&r(c),T(K)}else r(c);f=n(c)}if(f!==null)V=!0;else{var B=n(u);B!==null&&$(E,B.startTime-K),V=!1}}break e}finally{f=null,p=Q,m=!1}V=void 0}}finally{V?F():C=!1}}}var F;if(typeof M=="function")F=function(){M(U)};else if(typeof MessageChannel<"u"){var H=new MessageChannel,j=H.port2;H.port1.onmessage=U,F=function(){j.postMessage(null)}}else F=function(){v(U,0)};function $(K,V){k=v(function(){K(t.unstable_now())},V)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(K){K.callback=null},t.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):R=0<K?Math.floor(1e3/K):5},t.unstable_getCurrentPriorityLevel=function(){return p},t.unstable_next=function(K){switch(p){case 1:case 2:case 3:var V=3;break;default:V=p}var Q=p;p=V;try{return K()}finally{p=Q}},t.unstable_requestPaint=function(){y=!0},t.unstable_runWithPriority=function(K,V){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var Q=p;p=K;try{return V()}finally{p=Q}},t.unstable_scheduleCallback=function(K,V,Q){var Z=t.unstable_now();switch(typeof Q=="object"&&Q!==null?(Q=Q.delay,Q=typeof Q=="number"&&0<Q?Z+Q:Z):Q=Z,K){case 1:var ae=-1;break;case 2:ae=250;break;case 5:ae=1073741823;break;case 4:ae=1e4;break;default:ae=5e3}return ae=Q+ae,K={id:d++,callback:V,priorityLevel:K,startTime:Q,expirationTime:ae,sortIndex:-1},Q>Z?(K.sortIndex=Q,e(u,K),n(c)===null&&K===n(u)&&(b?(S(k),k=-1):b=!0,$(E,Q-Z))):(K.sortIndex=ae,e(c,K),x||m||(x=!0,C||(C=!0,F()))),K},t.unstable_shouldYield=D,t.unstable_wrapCallback=function(K){var V=p;return function(){var Q=p;p=V;try{return K.apply(this,arguments)}finally{p=Q}}}})(Vk)),Vk}var $U;function Oae(){return $U||($U=1,Hk.exports=Rae()),Hk.exports}var Gk={exports:{}},$a={};var HU;function Lae(){if(HU)return $a;HU=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 a(c,u,d){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:f==null?null:""+f,children:c,containerInfo:u,implementation:d}}var 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 $a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,$a.createPortal=function(c,u){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)throw Error(e(299));return a(c,u,null,d)},$a.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()}},$a.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))},$a.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},$a.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin),p=typeof u.integrity=="string"?u.integrity:void 0,m=typeof u.fetchPriority=="string"?u.fetchPriority:void 0;d==="style"?r.d.S(c,typeof u.precedence=="string"?u.precedence:void 0,{crossOrigin:f,integrity:p,fetchPriority:m}):d==="script"&&r.d.X(c,{crossOrigin:f,integrity:p,fetchPriority:m,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},$a.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)},$a.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})}},$a.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)},$a.requestFormReset=function(c){r.d.r(c)},$a.unstable_batchedUpdates=function(c,u){return c(u)},$a.useFormState=function(c,u,d){return o.H.useFormState(c,u,d)},$a.useFormStatus=function(){return o.H.useHostTransitionStatus()},$a.version="19.2.0",$a}var VU;function yq(){if(VU)return Gk.exports;VU=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(),Gk.exports=Lae(),Gk.exports}var GU;function Fae(){if(GU)return Tb;GU=1;var t=Oae(),e=px(),n=yq();function r(h){var g="https://react.dev/errors/"+h;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var w=2;w<arguments.length;w++)g+="&args[]="+encodeURIComponent(arguments[w])}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 a(h){var g=h,w=h;if(h.alternate)for(;g.return;)g=g.return;else{h=g;do g=h,(g.flags&4098)!==0&&(w=g.return),h=g.return;while(h)}return g.tag===3?w: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(a(h)!==h)throw Error(r(188))}function u(h){var g=h.alternate;if(!g){if(g=a(h),g===null)throw Error(r(188));return g!==h?null:h}for(var w=h,N=g;;){var P=w.return;if(P===null)break;var L=P.alternate;if(L===null){if(N=P.return,N!==null){w=N;continue}break}if(P.child===L.child){for(L=P.child;L;){if(L===w)return c(P),h;if(L===N)return c(P),g;L=L.sibling}throw Error(r(188))}if(w.return!==N.return)w=P,N=L;else{for(var J=!1,ve=P.child;ve;){if(ve===w){J=!0,w=P,N=L;break}if(ve===N){J=!0,N=P,w=L;break}ve=ve.sibling}if(!J){for(ve=L.child;ve;){if(ve===w){J=!0,w=L,N=P;break}if(ve===N){J=!0,N=L,w=P;break}ve=ve.sibling}if(!J)throw Error(r(189))}}if(w.alternate!==N)throw Error(r(190))}if(w.tag!==3)throw Error(r(188));return w.stateNode.current===w?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,p=Symbol.for("react.element"),m=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"),M=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),k=Symbol.for("react.memo"),R=Symbol.for("react.lazy"),A=Symbol.for("react.activity"),D=Symbol.for("react.memo_cache_sentinel"),U=Symbol.iterator;function F(h){return h===null||typeof h!="object"?null:(h=U&&h[U]||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 E:return"Suspense";case C:return"SuspenseList";case A:return"Activity"}if(typeof h=="object")switch(h.$$typeof){case x:return"Portal";case M:return h.displayName||"Context";case S:return(h._context.displayName||"Context")+".Consumer";case T:var g=h.render;return h=h.displayName,h||(h=g.displayName||g.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case k:return g=h.displayName||null,g!==null?g:j(h.type)||"Memo";case R:g=h._payload,h=h._init;try{return j(h(g))}catch{}}return null}var $=Array.isArray,K=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q={pending:!1,data:null,method:null,action:null},Z=[],ae=-1;function B(h){return{current:h}}function X(h){0>ae||(h.current=Z[ae],Z[ae]=null,ae--)}function ne(h,g){ae++,Z[ae]=h.current,h.current=g}var se=B(null),be=B(null),xe=B(null),de=B(null);function Pe(h,g){switch(ne(xe,g),ne(be,h),ne(se,null),g.nodeType){case 9:case 11:h=(h=g.documentElement)&&(h=h.namespaceURI)?sU(h):0;break;default:if(h=g.tagName,g=g.namespaceURI)g=sU(g),h=oU(g,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}X(se),ne(se,h)}function ie(){X(se),X(be),X(xe)}function Me(h){h.memoizedState!==null&&ne(de,h);var g=se.current,w=oU(g,h.type);g!==w&&(ne(be,h),ne(se,w))}function Oe(h){be.current===h&&(X(se),X(be)),de.current===h&&(X(de),Sb._currentValue=Q)}var ge,Ke;function G(h){if(ge===void 0)try{throw Error()}catch(w){var g=w.stack.trim().match(/\n( *(at )?)/);ge=g&&g[1]||"",Ke=-1<w.stack.indexOf(`
  2. at`)?" (<anonymous>)":-1<w.stack.indexOf("@")?"@unknown:0:0":""}return`
  3. `+ge+h+Ke}var Y=!1;function ce(h,g){if(!h||Y)return"";Y=!0;var w=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var N={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 ct=pt}Reflect.construct(h,[],vt)}else{try{vt.call()}catch(pt){ct=pt}h.call(vt.prototype)}}else{try{throw Error()}catch(pt){ct=pt}(vt=h())&&typeof vt.catch=="function"&&vt.catch(function(){})}}catch(pt){if(pt&&ct&&typeof pt.stack=="string")return[pt.stack,ct.stack]}return[null,null]}};N.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var P=Object.getOwnPropertyDescriptor(N.DetermineComponentFrameRoot,"name");P&&P.configurable&&Object.defineProperty(N.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var L=N.DetermineComponentFrameRoot(),J=L[0],ve=L[1];if(J&&ve){var Ue=J.split(`
  4. `),it=ve.split(`
  5. `);for(P=N=0;N<Ue.length&&!Ue[N].includes("DetermineComponentFrameRoot");)N++;for(;P<it.length&&!it[P].includes("DetermineComponentFrameRoot");)P++;if(N===Ue.length||P===it.length)for(N=Ue.length-1,P=it.length-1;1<=N&&0<=P&&Ue[N]!==it[P];)P--;for(;1<=N&&0<=P;N--,P--)if(Ue[N]!==it[P]){if(N!==1||P!==1)do if(N--,P--,0>P||Ue[N]!==it[P]){var gt=`
  6. `+Ue[N].replace(" at new "," at ");return h.displayName&&gt.includes("<anonymous>")&&(gt=gt.replace("<anonymous>",h.displayName)),gt}while(1<=N&&0<=P);break}}}finally{Y=!1,Error.prepareStackTrace=w}return(w=h?h.displayName||h.name:"")?G(w):""}function q(h,g){switch(h.tag){case 26:case 27:case 5:return G(h.type);case 16:return G("Lazy");case 13:return h.child!==g&&g!==null?G("Suspense Fallback"):G("Suspense");case 19:return G("SuspenseList");case 0:case 15:return ce(h.type,!1);case 11:return ce(h.type.render,!1);case 1:return ce(h.type,!0);case 31:return G("Activity");default:return""}}function te(h){try{var g="",w=null;do g+=q(h,w),w=h,h=h.return;while(h);return g}catch(N){return`
  7. Error generating stack: `+N.message+`
  8. `+N.stack}}var I=Object.prototype.hasOwnProperty,fe=t.unstable_scheduleCallback,me=t.unstable_cancelCallback,ke=t.unstable_shouldYield,z=t.unstable_requestPaint,O=t.unstable_now,ee=t.unstable_getCurrentPriorityLevel,le=t.unstable_ImmediatePriority,_e=t.unstable_UserBlockingPriority,we=t.unstable_NormalPriority,re=t.unstable_LowPriority,Fe=t.unstable_IdlePriority,$e=t.log,Ve=t.unstable_setDisableYieldValue,He=null,ye=null;function je(h){if(typeof $e=="function"&&Ve(h),ye&&typeof ye.setStrictMode=="function")try{ye.setStrictMode(He,h)}catch{}}var Be=Math.clz32?Math.clz32:Ne,Se=Math.log,Xe=Math.LN2;function Ne(h){return h>>>=0,h===0?32:31-(Se(h)/Xe|0)|0}var tt=256,Ee=262144,We=4194304;function ze(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 W(h,g,w){var N=h.pendingLanes;if(N===0)return 0;var P=0,L=h.suspendedLanes,J=h.pingedLanes;h=h.warmLanes;var ve=N&134217727;return ve!==0?(N=ve&~L,N!==0?P=ze(N):(J&=ve,J!==0?P=ze(J):w||(w=ve&~h,w!==0&&(P=ze(w))))):(ve=N&~L,ve!==0?P=ze(ve):J!==0?P=ze(J):w||(w=N&~h,w!==0&&(P=ze(w)))),P===0?0:g!==0&&g!==P&&(g&L)===0&&(L=P&-P,w=g&-g,L>=w||L===32&&(w&4194048)!==0)?g:P}function De(h,g){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&g)===0}function Ye(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 xt(){var h=We;return We<<=1,(We&62914560)===0&&(We=4194304),h}function ft(h){for(var g=[],w=0;31>w;w++)g.push(h);return g}function Bt(h,g){h.pendingLanes|=g,g!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function Lt(h,g,w,N,P,L){var J=h.pendingLanes;h.pendingLanes=w,h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0,h.expiredLanes&=w,h.entangledLanes&=w,h.errorRecoveryDisabledLanes&=w,h.shellSuspendCounter=0;var ve=h.entanglements,Ue=h.expirationTimes,it=h.hiddenUpdates;for(w=J&~w;0<w;){var gt=31-Be(w),vt=1<<gt;ve[gt]=0,Ue[gt]=-1;var ct=it[gt];if(ct!==null)for(it[gt]=null,gt=0;gt<ct.length;gt++){var pt=ct[gt];pt!==null&&(pt.lane&=-536870913)}w&=~vt}N!==0&&vn(h,N,0),L!==0&&P===0&&h.tag!==0&&(h.suspendedLanes|=L&~(J&~g))}function vn(h,g,w){h.pendingLanes|=g,h.suspendedLanes&=~g;var N=31-Be(g);h.entangledLanes|=g,h.entanglements[N]=h.entanglements[N]|1073741824|w&261930}function Jt(h,g){var w=h.entangledLanes|=g;for(h=h.entanglements;w;){var N=31-Be(w),P=1<<N;P&g|h[N]&g&&(h[N]|=g),w&=~P}}function rr(h,g){var w=g&-g;return w=(w&42)!==0?1:hr(w),(w&(h.suspendedLanes|g))!==0?0:w}function hr(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 Dn(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function ln(){var h=V.p;return h!==0?h:(h=window.event,h===void 0?32:CU(h.type))}function fr(h,g){var w=V.p;try{return V.p=h,g()}finally{V.p=w}}var Fn=Math.random().toString(36).slice(2),Kn="__reactFiber$"+Fn,bn="__reactProps$"+Fn,wi="__reactContainer$"+Fn,Ba="__reactEvents$"+Fn,Ae="__reactListeners$"+Fn,Ze="__reactHandles$"+Fn,st="__reactResources$"+Fn,lt="__reactMarker$"+Fn;function ot(h){delete h[Kn],delete h[bn],delete h[Ba],delete h[Ae],delete h[Ze]}function kt(h){var g=h[Kn];if(g)return g;for(var w=h.parentNode;w;){if(g=w[wi]||w[Kn]){if(w=g.alternate,g.child!==null||w!==null&&w.child!==null)for(h=mU(h);h!==null;){if(w=h[Kn])return w;h=mU(h)}return g}h=w,w=h.parentNode}return null}function he(h){if(h=h[Kn]||h[wi]){var g=h.tag;if(g===5||g===6||g===13||g===31||g===26||g===27||g===3)return h}return null}function pe(h){var g=h.tag;if(g===5||g===26||g===27||g===6)return h.stateNode;throw Error(r(33))}function Ie(h){var g=h[st];return g||(g=h[st]={hoistableStyles:new Map,hoistableScripts:new Map}),g}function Le(h){h[lt]=!0}var Ce=new Set,ut={};function St(h,g){At(h,g),At(h+"Capture",g)}function At(h,g){for(ut[h]=g,h=0;h<g.length;h++)Ce.add(g[h])}var Tt=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]*$"),Ft={},Pt={};function Mt(h){return I.call(Pt,h)?!0:I.call(Ft,h)?!1:Tt.test(h)?Pt[h]=!0:(Ft[h]=!0,!1)}function en(h,g,w){if(Mt(g))if(w===null)h.removeAttribute(g);else{switch(typeof w){case"undefined":case"function":case"symbol":h.removeAttribute(g);return;case"boolean":var N=g.toLowerCase().slice(0,5);if(N!=="data-"&&N!=="aria-"){h.removeAttribute(g);return}}h.setAttribute(g,""+w)}}function $t(h,g,w){if(w===null)h.removeAttribute(g);else{switch(typeof w){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(g);return}h.setAttribute(g,""+w)}}function dn(h,g,w,N){if(N===null)h.removeAttribute(w);else{switch(typeof N){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(w);return}h.setAttributeNS(g,w,""+N)}}function cn(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function Sn(h){var g=h.type;return(h=h.nodeName)&&h.toLowerCase()==="input"&&(g==="checkbox"||g==="radio")}function Gt(h,g,w){var N=Object.getOwnPropertyDescriptor(h.constructor.prototype,g);if(!h.hasOwnProperty(g)&&typeof N<"u"&&typeof N.get=="function"&&typeof N.set=="function"){var P=N.get,L=N.set;return Object.defineProperty(h,g,{configurable:!0,get:function(){return P.call(this)},set:function(J){w=""+J,L.call(this,J)}}),Object.defineProperty(h,g,{enumerable:N.enumerable}),{getValue:function(){return w},setValue:function(J){w=""+J},stopTracking:function(){h._valueTracker=null,delete h[g]}}}}function sn(h){if(!h._valueTracker){var g=Sn(h)?"checked":"value";h._valueTracker=Gt(h,g,""+h[g])}}function un(h){if(!h)return!1;var g=h._valueTracker;if(!g)return!0;var w=g.getValue(),N="";return h&&(N=Sn(h)?h.checked?"true":"false":h.value),h=N,h!==w?(g.setValue(h),!0):!1}function Yt(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 tr=/[\n"\\]/g;function jn(h){return h.replace(tr,function(g){return"\\"+g.charCodeAt(0).toString(16)+" "})}function ii(h,g,w,N,P,L,J,ve){h.name="",J!=null&&typeof J!="function"&&typeof J!="symbol"&&typeof J!="boolean"?h.type=J:h.removeAttribute("type"),g!=null?J==="number"?(g===0&&h.value===""||h.value!=g)&&(h.value=""+cn(g)):h.value!==""+cn(g)&&(h.value=""+cn(g)):J!=="submit"&&J!=="reset"||h.removeAttribute("value"),g!=null?lr(h,J,cn(g)):w!=null?lr(h,J,cn(w)):N!=null&&h.removeAttribute("value"),P==null&&L!=null&&(h.defaultChecked=!!L),P!=null&&(h.checked=P&&typeof P!="function"&&typeof P!="symbol"),ve!=null&&typeof ve!="function"&&typeof ve!="symbol"&&typeof ve!="boolean"?h.name=""+cn(ve):h.removeAttribute("name")}function nr(h,g,w,N,P,L,J,ve){if(L!=null&&typeof L!="function"&&typeof L!="symbol"&&typeof L!="boolean"&&(h.type=L),g!=null||w!=null){if(!(L!=="submit"&&L!=="reset"||g!=null)){sn(h);return}w=w!=null?""+cn(w):"",g=g!=null?""+cn(g):w,ve||g===h.value||(h.value=g),h.defaultValue=g}N=N??P,N=typeof N!="function"&&typeof N!="symbol"&&!!N,h.checked=ve?h.checked:!!N,h.defaultChecked=!!N,J!=null&&typeof J!="function"&&typeof J!="symbol"&&typeof J!="boolean"&&(h.name=J),sn(h)}function lr(h,g,w){g==="number"&&Yt(h.ownerDocument)===h||h.defaultValue===""+w||(h.defaultValue=""+w)}function et(h,g,w,N){if(h=h.options,g){g={};for(var P=0;P<w.length;P++)g["$"+w[P]]=!0;for(w=0;w<h.length;w++)P=g.hasOwnProperty("$"+h[w].value),h[w].selected!==P&&(h[w].selected=P),P&&N&&(h[w].defaultSelected=!0)}else{for(w=""+cn(w),g=null,P=0;P<h.length;P++){if(h[P].value===w){h[P].selected=!0,N&&(h[P].defaultSelected=!0);return}g!==null||h[P].disabled||(g=h[P])}g!==null&&(g.selected=!0)}}function jt(h,g,w){if(g!=null&&(g=""+cn(g),g!==h.value&&(h.value=g),w==null)){h.defaultValue!==g&&(h.defaultValue=g);return}h.defaultValue=w!=null?""+cn(w):""}function qt(h,g,w,N){if(g==null){if(N!=null){if(w!=null)throw Error(r(92));if($(N)){if(1<N.length)throw Error(r(93));N=N[0]}w=N}w==null&&(w=""),g=w}w=cn(g),h.defaultValue=w,N=h.textContent,N===w&&N!==""&&N!==null&&(h.value=N),sn(h)}function yt(h,g){if(g){var w=h.firstChild;if(w&&w===h.lastChild&&w.nodeType===3){w.nodeValue=g;return}}h.textContent=g}var wn=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 Fr(h,g,w){var N=g.indexOf("--")===0;w==null||typeof w=="boolean"||w===""?N?h.setProperty(g,""):g==="float"?h.cssFloat="":h[g]="":N?h.setProperty(g,w):typeof w!="number"||w===0||wn.has(g)?g==="float"?h.cssFloat=w:h[g]=(""+w).trim():h[g]=w+"px"}function Yr(h,g,w){if(g!=null&&typeof g!="object")throw Error(r(62));if(h=h.style,w!=null){for(var N in w)!w.hasOwnProperty(N)||g!=null&&g.hasOwnProperty(N)||(N.indexOf("--")===0?h.setProperty(N,""):N==="float"?h.cssFloat="":h[N]="");for(var P in g)N=g[P],g.hasOwnProperty(P)&&w[P]!==N&&Fr(h,P,N)}else for(var L in g)g.hasOwnProperty(L)&&Fr(h,L,g[L])}function Br(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 Ws=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"]]),tn=/^[\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 on(h){return tn.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function _i(){}var Ss=null;function _o(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var So=null,No=null;function Ns(h){var g=he(h);if(g&&(h=g.stateNode)){var w=h[bn]||null;e:switch(h=g.stateNode,g.type){case"input":if(ii(h,w.value,w.defaultValue,w.defaultValue,w.checked,w.defaultChecked,w.type,w.name),g=w.name,w.type==="radio"&&g!=null){for(w=h;w.parentNode;)w=w.parentNode;for(w=w.querySelectorAll('input[name="'+jn(""+g)+'"][type="radio"]'),g=0;g<w.length;g++){var N=w[g];if(N!==h&&N.form===h.form){var P=N[bn]||null;if(!P)throw Error(r(90));ii(N,P.value,P.defaultValue,P.defaultValue,P.checked,P.defaultChecked,P.type,P.name)}}for(g=0;g<w.length;g++)N=w[g],N.form===h.form&&un(N)}break e;case"textarea":jt(h,w.value,w.defaultValue);break e;case"select":g=w.value,g!=null&&et(h,!!w.multiple,g,!1)}}}var Si=!1;function Ks(h,g,w){if(Si)return h(g,w);Si=!0;try{var N=h(g);return N}finally{if(Si=!1,(So!==null||No!==null)&&(ow(),So&&(g=So,h=No,No=So=null,Ns(g),h)))for(g=0;g<h.length;g++)Ns(h[g])}}function la(h,g){var w=h.stateNode;if(w===null)return null;var N=w[bn]||null;if(N===null)return null;w=N[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":(N=!N.disabled)||(h=h.type,N=!(h==="button"||h==="input"||h==="select"||h==="textarea")),h=!N;break e;default:h=!1}if(h)return null;if(w&&typeof w!="function")throw Error(r(231,g,typeof w));return w}var $r=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ux=!1;if($r)try{var Hh={};Object.defineProperty(Hh,"passive",{get:function(){Ux=!0}}),window.addEventListener("test",Hh,Hh),window.removeEventListener("test",Hh,Hh)}catch{Ux=!1}var Hl=null,zx=null,Dm=null;function Rm(){if(Dm)return Dm;var h,g=zx,w=g.length,N,P="value"in Hl?Hl.value:Hl.textContent,L=P.length;for(h=0;h<w&&g[h]===P[h];h++);var J=w-h;for(N=1;N<=J&&g[w-N]===P[L-N];N++);return Dm=P.slice(h,1<N?1-N: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 Qu(){return!0}function Cc(){return!1}function ca(h){function g(w,N,P,L,J){this._reactName=w,this._targetInst=P,this.type=N,this.nativeEvent=L,this.target=J,this.currentTarget=null;for(var ve in h)h.hasOwnProperty(ve)&&(w=h[ve],this[ve]=w?w(L):L[ve]);return this.isDefaultPrevented=(L.defaultPrevented!=null?L.defaultPrevented:L.returnValue===!1)?Qu:Cc,this.isPropagationStopped=Cc,this}return f(g.prototype,{preventDefault:function(){this.defaultPrevented=!0;var w=this.nativeEvent;w&&(w.preventDefault?w.preventDefault():typeof w.returnValue!="unknown"&&(w.returnValue=!1),this.isDefaultPrevented=Qu)},stopPropagation:function(){var w=this.nativeEvent;w&&(w.stopPropagation?w.stopPropagation():typeof w.cancelBubble!="unknown"&&(w.cancelBubble=!0),this.isPropagationStopped=Qu)},persist:function(){},isPersistent:Qu}),g}var pl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Vl=ca(pl),gl=f({},pl,{view:0,detail:0}),Om=ca(gl),Lm,Fm,Zu,hn=f({},gl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Hx,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!==Zu&&(Zu&&h.type==="mousemove"?(Lm=h.screenX-Zu.screenX,Fm=h.screenY-Zu.screenY):Fm=Lm=0,Zu=h),Lm)},movementY:function(h){return"movementY"in h?h.movementY:Fm}}),Sv=ca(hn),Bx=f({},hn,{dataTransfer:0}),Nv=ca(Bx),$x=f({},gl,{relatedTarget:0}),Im=ca($x),GM=f({},pl,{animationName:0,elapsedTime:0,pseudoElement:0}),Mv=ca(GM),oe=f({},pl,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),wt=ca(oe),Rn=f({},pl,{data:0}),Zn=ca(Rn),Mo={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ju={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"},is={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function as(h){var g=this.nativeEvent;return g.getModifierState?g.getModifierState(h):(h=is[h])?!!g[h]:!1}function Hx(){return as}var uF=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"?Ju[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Hx,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}}),Bre=ca(uF),$re=f({},hn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),dF=ca($re),Hre=f({},gl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Hx}),Vre=ca(Hre),Gre=f({},pl,{propertyName:0,elapsedTime:0,pseudoElement:0}),qre=ca(Gre),Wre=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}),Kre=ca(Wre),Xre=f({},pl,{newState:0,oldState:0}),Yre=ca(Xre),Qre=[9,13,27,32],qM=$r&&"CompositionEvent"in window,Vx=null;$r&&"documentMode"in document&&(Vx=document.documentMode);var Zre=$r&&"TextEvent"in window&&!Vx,hF=$r&&(!qM||Vx&&8<Vx&&11>=Vx),fF=" ",mF=!1;function pF(h,g){switch(h){case"keyup":return Qre.indexOf(g.keyCode)!==-1;case"keydown":return g.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function gF(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var Um=!1;function Jre(h,g){switch(h){case"compositionend":return gF(g);case"keypress":return g.which!==32?null:(mF=!0,fF);case"textInput":return h=g.data,h===fF&&mF?null:h;default:return null}}function eie(h,g){if(Um)return h==="compositionend"||!qM&&pF(h,g)?(h=Rm(),Dm=zx=Hl=null,Um=!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 hF&&g.locale!=="ko"?null:g.data;default:return null}}var tie={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 xF(h){var g=h&&h.nodeName&&h.nodeName.toLowerCase();return g==="input"?!!tie[h.type]:g==="textarea"}function bF(h,g,w,N){So?No?No.push(N):No=[N]:So=N,g=mw(g,"onChange"),0<g.length&&(w=new Vl("onChange","change",null,w,N),h.push({event:w,listeners:g}))}var Gx=null,qx=null;function nie(h){eU(h,0)}function Ev(h){var g=pe(h);if(un(g))return h}function yF(h,g){if(h==="change")return g}var vF=!1;if($r){var WM;if($r){var KM="oninput"in document;if(!KM){var wF=document.createElement("div");wF.setAttribute("oninput","return;"),KM=typeof wF.oninput=="function"}WM=KM}else WM=!1;vF=WM&&(!document.documentMode||9<document.documentMode)}function _F(){Gx&&(Gx.detachEvent("onpropertychange",SF),qx=Gx=null)}function SF(h){if(h.propertyName==="value"&&Ev(qx)){var g=[];bF(g,qx,h,_o(h)),Ks(nie,g)}}function rie(h,g,w){h==="focusin"?(_F(),Gx=g,qx=w,Gx.attachEvent("onpropertychange",SF)):h==="focusout"&&_F()}function iie(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return Ev(qx)}function aie(h,g){if(h==="click")return Ev(g)}function sie(h,g){if(h==="input"||h==="change")return Ev(g)}function oie(h,g){return h===g&&(h!==0||1/h===1/g)||h!==h&&g!==g}var Xs=typeof Object.is=="function"?Object.is:oie;function Wx(h,g){if(Xs(h,g))return!0;if(typeof h!="object"||h===null||typeof g!="object"||g===null)return!1;var w=Object.keys(h),N=Object.keys(g);if(w.length!==N.length)return!1;for(N=0;N<w.length;N++){var P=w[N];if(!I.call(g,P)||!Xs(h[P],g[P]))return!1}return!0}function NF(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function MF(h,g){var w=NF(h);h=0;for(var N;w;){if(w.nodeType===3){if(N=h+w.textContent.length,h<=g&&N>=g)return{node:w,offset:g-h};h=N}e:{for(;w;){if(w.nextSibling){w=w.nextSibling;break e}w=w.parentNode}w=void 0}w=NF(w)}}function EF(h,g){return h&&g?h===g?!0:h&&h.nodeType===3?!1:g&&g.nodeType===3?EF(h,g.parentNode):"contains"in h?h.contains(g):h.compareDocumentPosition?!!(h.compareDocumentPosition(g)&16):!1:!1}function kF(h){h=h!=null&&h.ownerDocument!=null&&h.ownerDocument.defaultView!=null?h.ownerDocument.defaultView:window;for(var g=Yt(h.document);g instanceof h.HTMLIFrameElement;){try{var w=typeof g.contentWindow.location.href=="string"}catch{w=!1}if(w)h=g.contentWindow;else break;g=Yt(h.document)}return g}function XM(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 lie=$r&&"documentMode"in document&&11>=document.documentMode,zm=null,YM=null,Kx=null,QM=!1;function TF(h,g,w){var N=w.window===w?w.document:w.nodeType===9?w:w.ownerDocument;QM||zm==null||zm!==Yt(N)||(N=zm,"selectionStart"in N&&XM(N)?N={start:N.selectionStart,end:N.selectionEnd}:(N=(N.ownerDocument&&N.ownerDocument.defaultView||window).getSelection(),N={anchorNode:N.anchorNode,anchorOffset:N.anchorOffset,focusNode:N.focusNode,focusOffset:N.focusOffset}),Kx&&Wx(Kx,N)||(Kx=N,N=mw(YM,"onSelect"),0<N.length&&(g=new Vl("onSelect","select",null,g,w),h.push({event:g,listeners:N}),g.target=zm)))}function Gh(h,g){var w={};return w[h.toLowerCase()]=g.toLowerCase(),w["Webkit"+h]="webkit"+g,w["Moz"+h]="moz"+g,w}var Bm={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")},ZM={},AF={};$r&&(AF=document.createElement("div").style,"AnimationEvent"in window||(delete Bm.animationend.animation,delete Bm.animationiteration.animation,delete Bm.animationstart.animation),"TransitionEvent"in window||delete Bm.transitionend.transition);function qh(h){if(ZM[h])return ZM[h];if(!Bm[h])return h;var g=Bm[h],w;for(w in g)if(g.hasOwnProperty(w)&&w in AF)return ZM[h]=g[w];return h}var CF=qh("animationend"),jF=qh("animationiteration"),PF=qh("animationstart"),cie=qh("transitionrun"),uie=qh("transitionstart"),die=qh("transitioncancel"),DF=qh("transitionend"),RF=new Map,JM="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(" ");JM.push("scrollEnd");function xl(h,g){RF.set(h,g),St(g,[h])}var kv=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=[],$m=0,eE=0;function Tv(){for(var h=$m,g=eE=$m=0;g<h;){var w=Eo[g];Eo[g++]=null;var N=Eo[g];Eo[g++]=null;var P=Eo[g];Eo[g++]=null;var L=Eo[g];if(Eo[g++]=null,N!==null&&P!==null){var J=N.pending;J===null?P.next=P:(P.next=J.next,J.next=P),N.pending=P}L!==0&&OF(w,P,L)}}function Av(h,g,w,N){Eo[$m++]=h,Eo[$m++]=g,Eo[$m++]=w,Eo[$m++]=N,eE|=N,h.lanes|=N,h=h.alternate,h!==null&&(h.lanes|=N)}function tE(h,g,w,N){return Av(h,g,w,N),Cv(h)}function Wh(h,g){return Av(h,null,null,g),Cv(h)}function OF(h,g,w){h.lanes|=w;var N=h.alternate;N!==null&&(N.lanes|=w);for(var P=!1,L=h.return;L!==null;)L.childLanes|=w,N=L.alternate,N!==null&&(N.childLanes|=w),L.tag===22&&(h=L.stateNode,h===null||h._visibility&1||(P=!0)),h=L,L=L.return;return h.tag===3?(L=h.stateNode,P&&g!==null&&(P=31-Be(w),h=L.hiddenUpdates,N=h[P],N===null?h[P]=[g]:N.push(g),g.lane=w|536870912),L):null}function Cv(h){if(50<gb)throw gb=0,uk=null,Error(r(185));for(var g=h.return;g!==null;)h=g,g=h.return;return h.tag===3?h.stateNode:null}var Hm={};function hie(h,g,w,N){this.tag=h,this.key=w,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=N,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ys(h,g,w,N){return new hie(h,g,w,N)}function nE(h){return h=h.prototype,!(!h||!h.isReactComponent)}function jc(h,g){var w=h.alternate;return w===null?(w=Ys(h.tag,g,h.key,h.mode),w.elementType=h.elementType,w.type=h.type,w.stateNode=h.stateNode,w.alternate=h,h.alternate=w):(w.pendingProps=g,w.type=h.type,w.flags=0,w.subtreeFlags=0,w.deletions=null),w.flags=h.flags&65011712,w.childLanes=h.childLanes,w.lanes=h.lanes,w.child=h.child,w.memoizedProps=h.memoizedProps,w.memoizedState=h.memoizedState,w.updateQueue=h.updateQueue,g=h.dependencies,w.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext},w.sibling=h.sibling,w.index=h.index,w.ref=h.ref,w.refCleanup=h.refCleanup,w}function LF(h,g){h.flags&=65011714;var w=h.alternate;return w===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=w.childLanes,h.lanes=w.lanes,h.child=w.child,h.subtreeFlags=0,h.deletions=null,h.memoizedProps=w.memoizedProps,h.memoizedState=w.memoizedState,h.updateQueue=w.updateQueue,h.type=w.type,g=w.dependencies,h.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext}),h}function jv(h,g,w,N,P,L){var J=0;if(N=h,typeof h=="function")nE(h)&&(J=1);else if(typeof h=="string")J=xae(h,w,se.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case A:return h=Ys(31,w,g,P),h.elementType=A,h.lanes=L,h;case b:return Kh(w.children,P,L,g);case y:J=8,P|=24;break;case v:return h=Ys(12,w,g,P|2),h.elementType=v,h.lanes=L,h;case E:return h=Ys(13,w,g,P),h.elementType=E,h.lanes=L,h;case C:return h=Ys(19,w,g,P),h.elementType=C,h.lanes=L,h;default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case M:J=10;break e;case S:J=9;break e;case T:J=11;break e;case k:J=14;break e;case R:J=16,N=null;break e}J=29,w=Error(r(130,h===null?"null":typeof h,"")),N=null}return g=Ys(J,w,g,P),g.elementType=h,g.type=N,g.lanes=L,g}function Kh(h,g,w,N){return h=Ys(7,h,N,g),h.lanes=w,h}function rE(h,g,w){return h=Ys(6,h,null,g),h.lanes=w,h}function FF(h){var g=Ys(18,null,null,0);return g.stateNode=h,g}function iE(h,g,w){return g=Ys(4,h.children!==null?h.children:[],h.key,g),g.lanes=w,g.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},g}var IF=new WeakMap;function ko(h,g){if(typeof h=="object"&&h!==null){var w=IF.get(h);return w!==void 0?w:(g={value:h,source:g,stack:te(g)},IF.set(h,g),g)}return{value:h,source:g,stack:te(g)}}var Vm=[],Gm=0,Pv=null,Xx=0,To=[],Ao=0,ed=null,Gl=1,ql="";function Pc(h,g){Vm[Gm++]=Xx,Vm[Gm++]=Pv,Pv=h,Xx=g}function UF(h,g,w){To[Ao++]=Gl,To[Ao++]=ql,To[Ao++]=ed,ed=h;var N=Gl;h=ql;var P=32-Be(N)-1;N&=~(1<<P),w+=1;var L=32-Be(g)+P;if(30<L){var J=P-P%5;L=(N&(1<<J)-1).toString(32),N>>=J,P-=J,Gl=1<<32-Be(g)+P|w<<P|N,ql=L+h}else Gl=1<<L|w<<P|N,ql=h}function aE(h){h.return!==null&&(Pc(h,1),UF(h,1,0))}function sE(h){for(;h===Pv;)Pv=Vm[--Gm],Vm[Gm]=null,Xx=Vm[--Gm],Vm[Gm]=null;for(;h===ed;)ed=To[--Ao],To[Ao]=null,ql=To[--Ao],To[Ao]=null,Gl=To[--Ao],To[Ao]=null}function zF(h,g){To[Ao++]=Gl,To[Ao++]=ql,To[Ao++]=ed,Gl=g.id,ql=g.overflow,ed=h}var Na=null,Hr=null,Xn=!1,td=null,Co=!1,oE=Error(r(519));function nd(h){var g=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Yx(ko(g,h)),oE}function BF(h){var g=h.stateNode,w=h.type,N=h.memoizedProps;switch(g[Kn]=h,g[bn]=N,w){case"dialog":Un("cancel",g),Un("close",g);break;case"iframe":case"object":case"embed":Un("load",g);break;case"video":case"audio":for(w=0;w<bb.length;w++)Un(bb[w],g);break;case"source":Un("error",g);break;case"img":case"image":case"link":Un("error",g),Un("load",g);break;case"details":Un("toggle",g);break;case"input":Un("invalid",g),nr(g,N.value,N.defaultValue,N.checked,N.defaultChecked,N.type,N.name,!0);break;case"select":Un("invalid",g);break;case"textarea":Un("invalid",g),qt(g,N.value,N.defaultValue,N.children)}w=N.children,typeof w!="string"&&typeof w!="number"&&typeof w!="bigint"||g.textContent===""+w||N.suppressHydrationWarning===!0||iU(g.textContent,w)?(N.popover!=null&&(Un("beforetoggle",g),Un("toggle",g)),N.onScroll!=null&&Un("scroll",g),N.onScrollEnd!=null&&Un("scrollend",g),N.onClick!=null&&(g.onclick=_i),g=!0):g=!1,g||nd(h,!0)}function $F(h){for(Na=h.return;Na;)switch(Na.tag){case 5:case 31:case 13:Co=!1;return;case 27:case 3:Co=!0;return;default:Na=Na.return}}function qm(h){if(h!==Na)return!1;if(!Xn)return $F(h),Xn=!0,!1;var g=h.tag,w;if((w=g!==3&&g!==27)&&((w=g===5)&&(w=h.type,w=!(w!=="form"&&w!=="button")||Mk(h.type,h.memoizedProps)),w=!w),w&&Hr&&nd(h),$F(h),g===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));Hr=fU(h)}else if(g===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));Hr=fU(h)}else g===27?(g=Hr,gd(h.type)?(h=Ck,Ck=null,Hr=h):Hr=g):Hr=Na?Po(h.stateNode.nextSibling):null;return!0}function Xh(){Hr=Na=null,Xn=!1}function lE(){var h=td;return h!==null&&(Ts===null?Ts=h:Ts.push.apply(Ts,h),td=null),h}function Yx(h){td===null?td=[h]:td.push(h)}var cE=B(null),Yh=null,Dc=null;function rd(h,g,w){ne(cE,g._currentValue),g._currentValue=w}function Rc(h){h._currentValue=cE.current,X(cE)}function uE(h,g,w){for(;h!==null;){var N=h.alternate;if((h.childLanes&g)!==g?(h.childLanes|=g,N!==null&&(N.childLanes|=g)):N!==null&&(N.childLanes&g)!==g&&(N.childLanes|=g),h===w)break;h=h.return}}function dE(h,g,w,N){var P=h.child;for(P!==null&&(P.return=h);P!==null;){var L=P.dependencies;if(L!==null){var J=P.child;L=L.firstContext;e:for(;L!==null;){var ve=L;L=P;for(var Ue=0;Ue<g.length;Ue++)if(ve.context===g[Ue]){L.lanes|=w,ve=L.alternate,ve!==null&&(ve.lanes|=w),uE(L.return,w,h),N||(J=null);break e}L=ve.next}}else if(P.tag===18){if(J=P.return,J===null)throw Error(r(341));J.lanes|=w,L=J.alternate,L!==null&&(L.lanes|=w),uE(J,w,h),J=null}else J=P.child;if(J!==null)J.return=P;else for(J=P;J!==null;){if(J===h){J=null;break}if(P=J.sibling,P!==null){P.return=J.return,J=P;break}J=J.return}P=J}}function Wm(h,g,w,N){h=null;for(var P=g,L=!1;P!==null;){if(!L){if((P.flags&524288)!==0)L=!0;else if((P.flags&262144)!==0)break}if(P.tag===10){var J=P.alternate;if(J===null)throw Error(r(387));if(J=J.memoizedProps,J!==null){var ve=P.type;Xs(P.pendingProps.value,J.value)||(h!==null?h.push(ve):h=[ve])}}else if(P===de.current){if(J=P.alternate,J===null)throw Error(r(387));J.memoizedState.memoizedState!==P.memoizedState.memoizedState&&(h!==null?h.push(Sb):h=[Sb])}P=P.return}h!==null&&dE(g,h,w,N),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,Dc=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function Ma(h){return HF(Yh,h)}function Rv(h,g){return Yh===null&&Qh(h),HF(h,g)}function HF(h,g){var w=g._currentValue;if(g={context:g,memoizedValue:w,next:null},Dc===null){if(h===null)throw Error(r(308));Dc=g,h.dependencies={lanes:0,firstContext:g},h.flags|=524288}else Dc=Dc.next=g;return w}var fie=typeof AbortController<"u"?AbortController:function(){var h=[],g=this.signal={aborted:!1,addEventListener:function(w,N){h.push(N)}};this.abort=function(){g.aborted=!0,h.forEach(function(w){return w()})}},mie=t.unstable_scheduleCallback,pie=t.unstable_NormalPriority,Ci={$$typeof:M,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function hE(){return{controller:new fie,data:new Map,refCount:0}}function Qx(h){h.refCount--,h.refCount===0&&mie(pie,function(){h.controller.abort()})}var Zx=null,fE=0,Km=0,Xm=null;function gie(h,g){if(Zx===null){var w=Zx=[];fE=0,Km=gk(),Xm={status:"pending",value:void 0,then:function(N){w.push(N)}}}return fE++,g.then(VF,VF),g}function VF(){if(--fE===0&&Zx!==null){Xm!==null&&(Xm.status="fulfilled");var h=Zx;Zx=null,Km=0,Xm=null;for(var g=0;g<h.length;g++)(0,h[g])()}}function xie(h,g){var w=[],N={status:"pending",value:null,reason:null,then:function(P){w.push(P)}};return h.then(function(){N.status="fulfilled",N.value=g;for(var P=0;P<w.length;P++)(0,w[P])(g)},function(P){for(N.status="rejected",N.reason=P,P=0;P<w.length;P++)(0,w[P])(void 0)}),N}var GF=K.S;K.S=function(h,g){T5=O(),typeof g=="object"&&g!==null&&typeof g.then=="function"&&gie(h,g),GF!==null&&GF(h,g)};var Zh=B(null);function mE(){var h=Zh.current;return h!==null?h:Pr.pooledCache}function Ov(h,g){g===null?ne(Zh,Zh.current):ne(Zh,g.pool)}function qF(){var h=mE();return h===null?null:{parent:Ci._currentValue,pool:h}}var Ym=Error(r(460)),pE=Error(r(474)),Lv=Error(r(542)),Fv={then:function(){}};function WF(h){return h=h.status,h==="fulfilled"||h==="rejected"}function KF(h,g,w){switch(w=h[w],w===void 0?h.push(g):w!==g&&(g.then(_i,_i),g=w),g.status){case"fulfilled":return g.value;case"rejected":throw h=g.reason,YF(h),h;default:if(typeof g.status=="string")g.then(_i,_i);else{if(h=Pr,h!==null&&100<h.shellSuspendCounter)throw Error(r(482));h=g,h.status="pending",h.then(function(N){if(g.status==="pending"){var P=g;P.status="fulfilled",P.value=N}},function(N){if(g.status==="pending"){var P=g;P.status="rejected",P.reason=N}})}switch(g.status){case"fulfilled":return g.value;case"rejected":throw h=g.reason,YF(h),h}throw ef=g,Ym}}function Jh(h){try{var g=h._init;return g(h._payload)}catch(w){throw w!==null&&typeof w=="object"&&typeof w.then=="function"?(ef=w,Ym):w}}var ef=null;function XF(){if(ef===null)throw Error(r(459));var h=ef;return ef=null,h}function YF(h){if(h===Ym||h===Lv)throw Error(r(483))}var Qm=null,Jx=0;function Iv(h){var g=Jx;return Jx+=1,Qm===null&&(Qm=[]),KF(Qm,h,g)}function eb(h,g){g=g.props.ref,h.ref=g!==void 0?g:null}function Uv(h,g){throw g.$$typeof===p?Error(r(525)):(h=Object.prototype.toString.call(g),Error(r(31,h==="[object Object]"?"object with keys {"+Object.keys(g).join(", ")+"}":h)))}function QF(h){function g(Je,Ge){if(h){var rt=Je.deletions;rt===null?(Je.deletions=[Ge],Je.flags|=16):rt.push(Ge)}}function w(Je,Ge){if(!h)return null;for(;Ge!==null;)g(Je,Ge),Ge=Ge.sibling;return null}function N(Je){for(var Ge=new Map;Je!==null;)Je.key!==null?Ge.set(Je.key,Je):Ge.set(Je.index,Je),Je=Je.sibling;return Ge}function P(Je,Ge){return Je=jc(Je,Ge),Je.index=0,Je.sibling=null,Je}function L(Je,Ge,rt){return Je.index=rt,h?(rt=Je.alternate,rt!==null?(rt=rt.index,rt<Ge?(Je.flags|=67108866,Ge):rt):(Je.flags|=67108866,Ge)):(Je.flags|=1048576,Ge)}function J(Je){return h&&Je.alternate===null&&(Je.flags|=67108866),Je}function ve(Je,Ge,rt,bt){return Ge===null||Ge.tag!==6?(Ge=rE(rt,Je.mode,bt),Ge.return=Je,Ge):(Ge=P(Ge,rt),Ge.return=Je,Ge)}function Ue(Je,Ge,rt,bt){var Kt=rt.type;return Kt===b?gt(Je,Ge,rt.props.children,bt,rt.key):Ge!==null&&(Ge.elementType===Kt||typeof Kt=="object"&&Kt!==null&&Kt.$$typeof===R&&Jh(Kt)===Ge.type)?(Ge=P(Ge,rt.props),eb(Ge,rt),Ge.return=Je,Ge):(Ge=jv(rt.type,rt.key,rt.props,null,Je.mode,bt),eb(Ge,rt),Ge.return=Je,Ge)}function it(Je,Ge,rt,bt){return Ge===null||Ge.tag!==4||Ge.stateNode.containerInfo!==rt.containerInfo||Ge.stateNode.implementation!==rt.implementation?(Ge=iE(rt,Je.mode,bt),Ge.return=Je,Ge):(Ge=P(Ge,rt.children||[]),Ge.return=Je,Ge)}function gt(Je,Ge,rt,bt,Kt){return Ge===null||Ge.tag!==7?(Ge=Kh(rt,Je.mode,bt,Kt),Ge.return=Je,Ge):(Ge=P(Ge,rt),Ge.return=Je,Ge)}function vt(Je,Ge,rt){if(typeof Ge=="string"&&Ge!==""||typeof Ge=="number"||typeof Ge=="bigint")return Ge=rE(""+Ge,Je.mode,rt),Ge.return=Je,Ge;if(typeof Ge=="object"&&Ge!==null){switch(Ge.$$typeof){case m:return rt=jv(Ge.type,Ge.key,Ge.props,null,Je.mode,rt),eb(rt,Ge),rt.return=Je,rt;case x:return Ge=iE(Ge,Je.mode,rt),Ge.return=Je,Ge;case R:return Ge=Jh(Ge),vt(Je,Ge,rt)}if($(Ge)||F(Ge))return Ge=Kh(Ge,Je.mode,rt,null),Ge.return=Je,Ge;if(typeof Ge.then=="function")return vt(Je,Iv(Ge),rt);if(Ge.$$typeof===M)return vt(Je,Rv(Je,Ge),rt);Uv(Je,Ge)}return null}function ct(Je,Ge,rt,bt){var Kt=Ge!==null?Ge.key:null;if(typeof rt=="string"&&rt!==""||typeof rt=="number"||typeof rt=="bigint")return Kt!==null?null:ve(Je,Ge,""+rt,bt);if(typeof rt=="object"&&rt!==null){switch(rt.$$typeof){case m:return rt.key===Kt?Ue(Je,Ge,rt,bt):null;case x:return rt.key===Kt?it(Je,Ge,rt,bt):null;case R:return rt=Jh(rt),ct(Je,Ge,rt,bt)}if($(rt)||F(rt))return Kt!==null?null:gt(Je,Ge,rt,bt,null);if(typeof rt.then=="function")return ct(Je,Ge,Iv(rt),bt);if(rt.$$typeof===M)return ct(Je,Ge,Rv(Je,rt),bt);Uv(Je,rt)}return null}function pt(Je,Ge,rt,bt,Kt){if(typeof bt=="string"&&bt!==""||typeof bt=="number"||typeof bt=="bigint")return Je=Je.get(rt)||null,ve(Ge,Je,""+bt,Kt);if(typeof bt=="object"&&bt!==null){switch(bt.$$typeof){case m:return Je=Je.get(bt.key===null?rt:bt.key)||null,Ue(Ge,Je,bt,Kt);case x:return Je=Je.get(bt.key===null?rt:bt.key)||null,it(Ge,Je,bt,Kt);case R:return bt=Jh(bt),pt(Je,Ge,rt,bt,Kt)}if($(bt)||F(bt))return Je=Je.get(rt)||null,gt(Ge,Je,bt,Kt,null);if(typeof bt.then=="function")return pt(Je,Ge,rt,Iv(bt),Kt);if(bt.$$typeof===M)return pt(Je,Ge,rt,Rv(Ge,bt),Kt);Uv(Ge,bt)}return null}function Vt(Je,Ge,rt,bt){for(var Kt=null,ir=null,Wt=Ge,Nn=Ge=0,qn=null;Wt!==null&&Nn<rt.length;Nn++){Wt.index>Nn?(qn=Wt,Wt=null):qn=Wt.sibling;var ar=ct(Je,Wt,rt[Nn],bt);if(ar===null){Wt===null&&(Wt=qn);break}h&&Wt&&ar.alternate===null&&g(Je,Wt),Ge=L(ar,Ge,Nn),ir===null?Kt=ar:ir.sibling=ar,ir=ar,Wt=qn}if(Nn===rt.length)return w(Je,Wt),Xn&&Pc(Je,Nn),Kt;if(Wt===null){for(;Nn<rt.length;Nn++)Wt=vt(Je,rt[Nn],bt),Wt!==null&&(Ge=L(Wt,Ge,Nn),ir===null?Kt=Wt:ir.sibling=Wt,ir=Wt);return Xn&&Pc(Je,Nn),Kt}for(Wt=N(Wt);Nn<rt.length;Nn++)qn=pt(Wt,Je,Nn,rt[Nn],bt),qn!==null&&(h&&qn.alternate!==null&&Wt.delete(qn.key===null?Nn:qn.key),Ge=L(qn,Ge,Nn),ir===null?Kt=qn:ir.sibling=qn,ir=qn);return h&&Wt.forEach(function(wd){return g(Je,wd)}),Xn&&Pc(Je,Nn),Kt}function nn(Je,Ge,rt,bt){if(rt==null)throw Error(r(151));for(var Kt=null,ir=null,Wt=Ge,Nn=Ge=0,qn=null,ar=rt.next();Wt!==null&&!ar.done;Nn++,ar=rt.next()){Wt.index>Nn?(qn=Wt,Wt=null):qn=Wt.sibling;var wd=ct(Je,Wt,ar.value,bt);if(wd===null){Wt===null&&(Wt=qn);break}h&&Wt&&wd.alternate===null&&g(Je,Wt),Ge=L(wd,Ge,Nn),ir===null?Kt=wd:ir.sibling=wd,ir=wd,Wt=qn}if(ar.done)return w(Je,Wt),Xn&&Pc(Je,Nn),Kt;if(Wt===null){for(;!ar.done;Nn++,ar=rt.next())ar=vt(Je,ar.value,bt),ar!==null&&(Ge=L(ar,Ge,Nn),ir===null?Kt=ar:ir.sibling=ar,ir=ar);return Xn&&Pc(Je,Nn),Kt}for(Wt=N(Wt);!ar.done;Nn++,ar=rt.next())ar=pt(Wt,Je,Nn,ar.value,bt),ar!==null&&(h&&ar.alternate!==null&&Wt.delete(ar.key===null?Nn:ar.key),Ge=L(ar,Ge,Nn),ir===null?Kt=ar:ir.sibling=ar,ir=ar);return h&&Wt.forEach(function(Tae){return g(Je,Tae)}),Xn&&Pc(Je,Nn),Kt}function _r(Je,Ge,rt,bt){if(typeof rt=="object"&&rt!==null&&rt.type===b&&rt.key===null&&(rt=rt.props.children),typeof rt=="object"&&rt!==null){switch(rt.$$typeof){case m:e:{for(var Kt=rt.key;Ge!==null;){if(Ge.key===Kt){if(Kt=rt.type,Kt===b){if(Ge.tag===7){w(Je,Ge.sibling),bt=P(Ge,rt.props.children),bt.return=Je,Je=bt;break e}}else if(Ge.elementType===Kt||typeof Kt=="object"&&Kt!==null&&Kt.$$typeof===R&&Jh(Kt)===Ge.type){w(Je,Ge.sibling),bt=P(Ge,rt.props),eb(bt,rt),bt.return=Je,Je=bt;break e}w(Je,Ge);break}else g(Je,Ge);Ge=Ge.sibling}rt.type===b?(bt=Kh(rt.props.children,Je.mode,bt,rt.key),bt.return=Je,Je=bt):(bt=jv(rt.type,rt.key,rt.props,null,Je.mode,bt),eb(bt,rt),bt.return=Je,Je=bt)}return J(Je);case x:e:{for(Kt=rt.key;Ge!==null;){if(Ge.key===Kt)if(Ge.tag===4&&Ge.stateNode.containerInfo===rt.containerInfo&&Ge.stateNode.implementation===rt.implementation){w(Je,Ge.sibling),bt=P(Ge,rt.children||[]),bt.return=Je,Je=bt;break e}else{w(Je,Ge);break}else g(Je,Ge);Ge=Ge.sibling}bt=iE(rt,Je.mode,bt),bt.return=Je,Je=bt}return J(Je);case R:return rt=Jh(rt),_r(Je,Ge,rt,bt)}if($(rt))return Vt(Je,Ge,rt,bt);if(F(rt)){if(Kt=F(rt),typeof Kt!="function")throw Error(r(150));return rt=Kt.call(rt),nn(Je,Ge,rt,bt)}if(typeof rt.then=="function")return _r(Je,Ge,Iv(rt),bt);if(rt.$$typeof===M)return _r(Je,Ge,Rv(Je,rt),bt);Uv(Je,rt)}return typeof rt=="string"&&rt!==""||typeof rt=="number"||typeof rt=="bigint"?(rt=""+rt,Ge!==null&&Ge.tag===6?(w(Je,Ge.sibling),bt=P(Ge,rt),bt.return=Je,Je=bt):(w(Je,Ge),bt=rE(rt,Je.mode,bt),bt.return=Je,Je=bt),J(Je)):w(Je,Ge)}return function(Je,Ge,rt,bt){try{Jx=0;var Kt=_r(Je,Ge,rt,bt);return Qm=null,Kt}catch(Wt){if(Wt===Ym||Wt===Lv)throw Wt;var ir=Ys(29,Wt,null,Je.mode);return ir.lanes=bt,ir.return=Je,ir}finally{}}}var tf=QF(!0),ZF=QF(!1),id=!1;function gE(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function xE(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 ad(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function sd(h,g,w){var N=h.updateQueue;if(N===null)return null;if(N=N.shared,(cr&2)!==0){var P=N.pending;return P===null?g.next=g:(g.next=P.next,P.next=g),N.pending=g,g=Cv(h),OF(h,null,w),g}return Av(h,N,g,w),Cv(h)}function tb(h,g,w){if(g=g.updateQueue,g!==null&&(g=g.shared,(w&4194048)!==0)){var N=g.lanes;N&=h.pendingLanes,w|=N,g.lanes=w,Jt(h,w)}}function bE(h,g){var w=h.updateQueue,N=h.alternate;if(N!==null&&(N=N.updateQueue,w===N)){var P=null,L=null;if(w=w.firstBaseUpdate,w!==null){do{var J={lane:w.lane,tag:w.tag,payload:w.payload,callback:null,next:null};L===null?P=L=J:L=L.next=J,w=w.next}while(w!==null);L===null?P=L=g:L=L.next=g}else P=L=g;w={baseState:N.baseState,firstBaseUpdate:P,lastBaseUpdate:L,shared:N.shared,callbacks:N.callbacks},h.updateQueue=w;return}h=w.lastBaseUpdate,h===null?w.firstBaseUpdate=g:h.next=g,w.lastBaseUpdate=g}var yE=!1;function nb(){if(yE){var h=Xm;if(h!==null)throw h}}function rb(h,g,w,N){yE=!1;var P=h.updateQueue;id=!1;var L=P.firstBaseUpdate,J=P.lastBaseUpdate,ve=P.shared.pending;if(ve!==null){P.shared.pending=null;var Ue=ve,it=Ue.next;Ue.next=null,J===null?L=it:J.next=it,J=Ue;var gt=h.alternate;gt!==null&&(gt=gt.updateQueue,ve=gt.lastBaseUpdate,ve!==J&&(ve===null?gt.firstBaseUpdate=it:ve.next=it,gt.lastBaseUpdate=Ue))}if(L!==null){var vt=P.baseState;J=0,gt=it=Ue=null,ve=L;do{var ct=ve.lane&-536870913,pt=ct!==ve.lane;if(pt?(Gn&ct)===ct:(N&ct)===ct){ct!==0&&ct===Km&&(yE=!0),gt!==null&&(gt=gt.next={lane:0,tag:ve.tag,payload:ve.payload,callback:null,next:null});e:{var Vt=h,nn=ve;ct=g;var _r=w;switch(nn.tag){case 1:if(Vt=nn.payload,typeof Vt=="function"){vt=Vt.call(_r,vt,ct);break e}vt=Vt;break e;case 3:Vt.flags=Vt.flags&-65537|128;case 0:if(Vt=nn.payload,ct=typeof Vt=="function"?Vt.call(_r,vt,ct):Vt,ct==null)break e;vt=f({},vt,ct);break e;case 2:id=!0}}ct=ve.callback,ct!==null&&(h.flags|=64,pt&&(h.flags|=8192),pt=P.callbacks,pt===null?P.callbacks=[ct]:pt.push(ct))}else pt={lane:ct,tag:ve.tag,payload:ve.payload,callback:ve.callback,next:null},gt===null?(it=gt=pt,Ue=vt):gt=gt.next=pt,J|=ct;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&&(Ue=vt),P.baseState=Ue,P.firstBaseUpdate=it,P.lastBaseUpdate=gt,L===null&&(P.shared.lanes=0),dd|=J,h.lanes=J,h.memoizedState=vt}}function JF(h,g){if(typeof h!="function")throw Error(r(191,h));h.call(g)}function eI(h,g){var w=h.callbacks;if(w!==null)for(h.callbacks=null,h=0;h<w.length;h++)JF(w[h],g)}var Zm=B(null),zv=B(0);function tI(h,g){h=Hc,ne(zv,h),ne(Zm,g),Hc=h|g.baseLanes}function vE(){ne(zv,Hc),ne(Zm,Zm.current)}function wE(){Hc=zv.current,X(Zm),X(zv)}var Qs=B(null),jo=null;function od(h){var g=h.alternate;ne(Ni,Ni.current&1),ne(Qs,h),jo===null&&(g===null||Zm.current!==null||g.memoizedState!==null)&&(jo=h)}function _E(h){ne(Ni,Ni.current),ne(Qs,h),jo===null&&(jo=h)}function nI(h){h.tag===22?(ne(Ni,Ni.current),ne(Qs,h),jo===null&&(jo=h)):ld()}function ld(){ne(Ni,Ni.current),ne(Qs,Qs.current)}function Zs(h){X(Qs),jo===h&&(jo=null),X(Ni)}var Ni=B(0);function Bv(h){for(var g=h;g!==null;){if(g.tag===13){var w=g.memoizedState;if(w!==null&&(w=w.dehydrated,w===null||Tk(w)||Ak(w)))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 Oc=0,_n=null,vr=null,ji=null,$v=!1,Jm=!1,nf=!1,Hv=0,ib=0,ep=null,bie=0;function di(){throw Error(r(321))}function SE(h,g){if(g===null)return!1;for(var w=0;w<g.length&&w<h.length;w++)if(!Xs(h[w],g[w]))return!1;return!0}function NE(h,g,w,N,P,L){return Oc=L,_n=g,g.memoizedState=null,g.updateQueue=null,g.lanes=0,K.H=h===null||h.memoizedState===null?UI:UE,nf=!1,L=w(N,P),nf=!1,Jm&&(L=iI(g,w,N,P)),rI(h),L}function rI(h){K.H=ob;var g=vr!==null&&vr.next!==null;if(Oc=0,ji=vr=_n=null,$v=!1,ib=0,ep=null,g)throw Error(r(300));h===null||Pi||(h=h.dependencies,h!==null&&Dv(h)&&(Pi=!0))}function iI(h,g,w,N){_n=h;var P=0;do{if(Jm&&(ep=null),ib=0,Jm=!1,25<=P)throw Error(r(301));if(P+=1,ji=vr=null,h.updateQueue!=null){var L=h.updateQueue;L.lastEffect=null,L.events=null,L.stores=null,L.memoCache!=null&&(L.memoCache.index=0)}K.H=zI,L=g(w,N)}while(Jm);return L}function yie(){var h=K.H,g=h.useState()[0];return g=typeof g.then=="function"?ab(g):g,h=h.useState()[0],(vr!==null?vr.memoizedState:null)!==h&&(_n.flags|=1024),g}function ME(){var h=Hv!==0;return Hv=0,h}function EE(h,g,w){g.updateQueue=h.updateQueue,g.flags&=-2053,h.lanes&=~w}function kE(h){if($v){for(h=h.memoizedState;h!==null;){var g=h.queue;g!==null&&(g.pending=null),h=h.next}$v=!1}Oc=0,ji=vr=_n=null,Jm=!1,ib=Hv=0,ep=null}function ss(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ji===null?_n.memoizedState=ji=h:ji=ji.next=h,ji}function Mi(){if(vr===null){var h=_n.alternate;h=h!==null?h.memoizedState:null}else h=vr.next;var g=ji===null?_n.memoizedState:ji.next;if(g!==null)ji=g,vr=h;else{if(h===null)throw _n.alternate===null?Error(r(467)):Error(r(310));vr=h,h={memoizedState:vr.memoizedState,baseState:vr.baseState,baseQueue:vr.baseQueue,queue:vr.queue,next:null},ji===null?_n.memoizedState=ji=h:ji=ji.next=h}return ji}function Vv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ab(h){var g=ib;return ib+=1,ep===null&&(ep=[]),h=KF(ep,h,g),g=_n,(ji===null?g.memoizedState:ji.next)===null&&(g=g.alternate,K.H=g===null||g.memoizedState===null?UI:UE),h}function Gv(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return ab(h);if(h.$$typeof===M)return Ma(h)}throw Error(r(438,String(h)))}function TE(h){var g=null,w=_n.updateQueue;if(w!==null&&(g=w.memoCache),g==null){var N=_n.alternate;N!==null&&(N=N.updateQueue,N!==null&&(N=N.memoCache,N!=null&&(g={data:N.data.map(function(P){return P.slice()}),index:0})))}if(g==null&&(g={data:[],index:0}),w===null&&(w=Vv(),_n.updateQueue=w),w.memoCache=g,w=g.data[g.index],w===void 0)for(w=g.data[g.index]=Array(h),N=0;N<h;N++)w[N]=D;return g.index++,w}function Lc(h,g){return typeof g=="function"?g(h):g}function qv(h){var g=Mi();return AE(g,vr,h)}function AE(h,g,w){var N=h.queue;if(N===null)throw Error(r(311));N.lastRenderedReducer=w;var P=h.baseQueue,L=N.pending;if(L!==null){if(P!==null){var J=P.next;P.next=L.next,L.next=J}g.baseQueue=P=L,N.pending=null}if(L=h.baseState,P===null)h.memoizedState=L;else{g=P.next;var ve=J=null,Ue=null,it=g,gt=!1;do{var vt=it.lane&-536870913;if(vt!==it.lane?(Gn&vt)===vt:(Oc&vt)===vt){var ct=it.revertLane;if(ct===0)Ue!==null&&(Ue=Ue.next={lane:0,revertLane:0,gesture:null,action:it.action,hasEagerState:it.hasEagerState,eagerState:it.eagerState,next:null}),vt===Km&&(gt=!0);else if((Oc&ct)===ct){it=it.next,ct===Km&&(gt=!0);continue}else vt={lane:0,revertLane:it.revertLane,gesture:null,action:it.action,hasEagerState:it.hasEagerState,eagerState:it.eagerState,next:null},Ue===null?(ve=Ue=vt,J=L):Ue=Ue.next=vt,_n.lanes|=ct,dd|=ct;vt=it.action,nf&&w(L,vt),L=it.hasEagerState?it.eagerState:w(L,vt)}else ct={lane:vt,revertLane:it.revertLane,gesture:it.gesture,action:it.action,hasEagerState:it.hasEagerState,eagerState:it.eagerState,next:null},Ue===null?(ve=Ue=ct,J=L):Ue=Ue.next=ct,_n.lanes|=vt,dd|=vt;it=it.next}while(it!==null&&it!==g);if(Ue===null?J=L:Ue.next=ve,!Xs(L,h.memoizedState)&&(Pi=!0,gt&&(w=Xm,w!==null)))throw w;h.memoizedState=L,h.baseState=J,h.baseQueue=Ue,N.lastRenderedState=L}return P===null&&(N.lanes=0),[h.memoizedState,N.dispatch]}function CE(h){var g=Mi(),w=g.queue;if(w===null)throw Error(r(311));w.lastRenderedReducer=h;var N=w.dispatch,P=w.pending,L=g.memoizedState;if(P!==null){w.pending=null;var J=P=P.next;do L=h(L,J.action),J=J.next;while(J!==P);Xs(L,g.memoizedState)||(Pi=!0),g.memoizedState=L,g.baseQueue===null&&(g.baseState=L),w.lastRenderedState=L}return[L,N]}function aI(h,g,w){var N=_n,P=Mi(),L=Xn;if(L){if(w===void 0)throw Error(r(407));w=w()}else w=g();var J=!Xs((vr||P).memoizedState,w);if(J&&(P.memoizedState=w,Pi=!0),P=P.queue,DE(lI.bind(null,N,P,h),[h]),P.getSnapshot!==g||J||ji!==null&&ji.memoizedState.tag&1){if(N.flags|=2048,tp(9,{destroy:void 0},oI.bind(null,N,P,w,g),null),Pr===null)throw Error(r(349));L||(Oc&127)!==0||sI(N,g,w)}return w}function sI(h,g,w){h.flags|=16384,h={getSnapshot:g,value:w},g=_n.updateQueue,g===null?(g=Vv(),_n.updateQueue=g,g.stores=[h]):(w=g.stores,w===null?g.stores=[h]:w.push(h))}function oI(h,g,w,N){g.value=w,g.getSnapshot=N,cI(g)&&uI(h)}function lI(h,g,w){return w(function(){cI(g)&&uI(h)})}function cI(h){var g=h.getSnapshot;h=h.value;try{var w=g();return!Xs(h,w)}catch{return!0}}function uI(h){var g=Wh(h,2);g!==null&&As(g,h,2)}function jE(h){var g=ss();if(typeof h=="function"){var w=h;if(h=w(),nf){je(!0);try{w()}finally{je(!1)}}}return g.memoizedState=g.baseState=h,g.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lc,lastRenderedState:h},g}function dI(h,g,w,N){return h.baseState=w,AE(h,vr,typeof N=="function"?N:Lc)}function vie(h,g,w,N,P){if(Xv(h))throw Error(r(485));if(h=g.action,h!==null){var L={payload:P,action:h,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(J){L.listeners.push(J)}};K.T!==null?w(!0):L.isTransition=!1,N(L),w=g.pending,w===null?(L.next=g.pending=L,hI(g,L)):(L.next=w.next,g.pending=w.next=L)}}function hI(h,g){var w=g.action,N=g.payload,P=h.state;if(g.isTransition){var L=K.T,J={};K.T=J;try{var ve=w(P,N),Ue=K.S;Ue!==null&&Ue(J,ve),fI(h,g,ve)}catch(it){PE(h,g,it)}finally{L!==null&&J.types!==null&&(L.types=J.types),K.T=L}}else try{L=w(P,N),fI(h,g,L)}catch(it){PE(h,g,it)}}function fI(h,g,w){w!==null&&typeof w=="object"&&typeof w.then=="function"?w.then(function(N){mI(h,g,N)},function(N){return PE(h,g,N)}):mI(h,g,w)}function mI(h,g,w){g.status="fulfilled",g.value=w,pI(g),h.state=w,g=h.pending,g!==null&&(w=g.next,w===g?h.pending=null:(w=w.next,g.next=w,hI(h,w)))}function PE(h,g,w){var N=h.pending;if(h.pending=null,N!==null){N=N.next;do g.status="rejected",g.reason=w,pI(g),g=g.next;while(g!==N)}h.action=null}function pI(h){h=h.listeners;for(var g=0;g<h.length;g++)(0,h[g])()}function gI(h,g){return g}function xI(h,g){if(Xn){var w=Pr.formState;if(w!==null){e:{var N=_n;if(Xn){if(Hr){t:{for(var P=Hr,L=Co;P.nodeType!==8;){if(!L){P=null;break t}if(P=Po(P.nextSibling),P===null){P=null;break t}}L=P.data,P=L==="F!"||L==="F"?P:null}if(P){Hr=Po(P.nextSibling),N=P.data==="F!";break e}}nd(N)}N=!1}N&&(g=w[0])}}return w=ss(),w.memoizedState=w.baseState=g,N={pending:null,lanes:0,dispatch:null,lastRenderedReducer:gI,lastRenderedState:g},w.queue=N,w=LI.bind(null,_n,N),N.dispatch=w,N=jE(!1),L=IE.bind(null,_n,!1,N.queue),N=ss(),P={state:g,dispatch:null,action:h,pending:null},N.queue=P,w=vie.bind(null,_n,P,L,w),P.dispatch=w,N.memoizedState=h,[g,w,!1]}function bI(h){var g=Mi();return yI(g,vr,h)}function yI(h,g,w){if(g=AE(h,g,gI)[0],h=qv(Lc)[0],typeof g=="object"&&g!==null&&typeof g.then=="function")try{var N=ab(g)}catch(J){throw J===Ym?Lv:J}else N=g;g=Mi();var P=g.queue,L=P.dispatch;return w!==g.memoizedState&&(_n.flags|=2048,tp(9,{destroy:void 0},wie.bind(null,P,w),null)),[N,L,h]}function wie(h,g){h.action=g}function vI(h){var g=Mi(),w=vr;if(w!==null)return yI(g,w,h);Mi(),g=g.memoizedState,w=Mi();var N=w.queue.dispatch;return w.memoizedState=h,[g,N,!1]}function tp(h,g,w,N){return h={tag:h,create:w,deps:N,inst:g,next:null},g=_n.updateQueue,g===null&&(g=Vv(),_n.updateQueue=g),w=g.lastEffect,w===null?g.lastEffect=h.next=h:(N=w.next,w.next=h,h.next=N,g.lastEffect=h),h}function wI(){return Mi().memoizedState}function Wv(h,g,w,N){var P=ss();_n.flags|=h,P.memoizedState=tp(1|g,{destroy:void 0},w,N===void 0?null:N)}function Kv(h,g,w,N){var P=Mi();N=N===void 0?null:N;var L=P.memoizedState.inst;vr!==null&&N!==null&&SE(N,vr.memoizedState.deps)?P.memoizedState=tp(g,L,w,N):(_n.flags|=h,P.memoizedState=tp(1|g,L,w,N))}function _I(h,g){Wv(8390656,8,h,g)}function DE(h,g){Kv(2048,8,h,g)}function _ie(h){_n.flags|=4;var g=_n.updateQueue;if(g===null)g=Vv(),_n.updateQueue=g,g.events=[h];else{var w=g.events;w===null?g.events=[h]:w.push(h)}}function SI(h){var g=Mi().memoizedState;return _ie({ref:g,nextImpl:h}),function(){if((cr&2)!==0)throw Error(r(440));return g.impl.apply(void 0,arguments)}}function NI(h,g){return Kv(4,2,h,g)}function MI(h,g){return Kv(4,4,h,g)}function EI(h,g){if(typeof g=="function"){h=h();var w=g(h);return function(){typeof w=="function"?w():g(null)}}if(g!=null)return h=h(),g.current=h,function(){g.current=null}}function kI(h,g,w){w=w!=null?w.concat([h]):null,Kv(4,4,EI.bind(null,g,h),w)}function RE(){}function TI(h,g){var w=Mi();g=g===void 0?null:g;var N=w.memoizedState;return g!==null&&SE(g,N[1])?N[0]:(w.memoizedState=[h,g],h)}function AI(h,g){var w=Mi();g=g===void 0?null:g;var N=w.memoizedState;if(g!==null&&SE(g,N[1]))return N[0];if(N=h(),nf){je(!0);try{h()}finally{je(!1)}}return w.memoizedState=[N,g],N}function OE(h,g,w){return w===void 0||(Oc&1073741824)!==0&&(Gn&261930)===0?h.memoizedState=g:(h.memoizedState=w,h=C5(),_n.lanes|=h,dd|=h,w)}function CI(h,g,w,N){return Xs(w,g)?w:Zm.current!==null?(h=OE(h,w,N),Xs(h,g)||(Pi=!0),h):(Oc&42)===0||(Oc&1073741824)!==0&&(Gn&261930)===0?(Pi=!0,h.memoizedState=w):(h=C5(),_n.lanes|=h,dd|=h,g)}function jI(h,g,w,N,P){var L=V.p;V.p=L!==0&&8>L?L:8;var J=K.T,ve={};K.T=ve,IE(h,!1,g,w);try{var Ue=P(),it=K.S;if(it!==null&&it(ve,Ue),Ue!==null&&typeof Ue=="object"&&typeof Ue.then=="function"){var gt=xie(Ue,N);sb(h,g,gt,to(h))}else sb(h,g,N,to(h))}catch(vt){sb(h,g,{then:function(){},status:"rejected",reason:vt},to())}finally{V.p=L,J!==null&&ve.types!==null&&(J.types=ve.types),K.T=J}}function Sie(){}function LE(h,g,w,N){if(h.tag!==5)throw Error(r(476));var P=PI(h).queue;jI(h,P,g,Q,w===null?Sie:function(){return DI(h),w(N)})}function PI(h){var g=h.memoizedState;if(g!==null)return g;g={memoizedState:Q,baseState:Q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lc,lastRenderedState:Q},next:null};var w={};return g.next={memoizedState:w,baseState:w,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lc,lastRenderedState:w},next:null},h.memoizedState=g,h=h.alternate,h!==null&&(h.memoizedState=g),g}function DI(h){var g=PI(h);g.next===null&&(g=h.alternate.memoizedState),sb(h,g.next.queue,{},to())}function FE(){return Ma(Sb)}function RI(){return Mi().memoizedState}function OI(){return Mi().memoizedState}function Nie(h){for(var g=h.return;g!==null;){switch(g.tag){case 24:case 3:var w=to();h=ad(w);var N=sd(g,h,w);N!==null&&(As(N,g,w),tb(N,g,w)),g={cache:hE()},h.payload=g;return}g=g.return}}function Mie(h,g,w){var N=to();w={lane:N,revertLane:0,gesture:null,action:w,hasEagerState:!1,eagerState:null,next:null},Xv(h)?FI(g,w):(w=tE(h,g,w,N),w!==null&&(As(w,h,N),II(w,g,N)))}function LI(h,g,w){var N=to();sb(h,g,w,N)}function sb(h,g,w,N){var P={lane:N,revertLane:0,gesture:null,action:w,hasEagerState:!1,eagerState:null,next:null};if(Xv(h))FI(g,P);else{var L=h.alternate;if(h.lanes===0&&(L===null||L.lanes===0)&&(L=g.lastRenderedReducer,L!==null))try{var J=g.lastRenderedState,ve=L(J,w);if(P.hasEagerState=!0,P.eagerState=ve,Xs(ve,J))return Av(h,g,P,0),Pr===null&&Tv(),!1}catch{}finally{}if(w=tE(h,g,P,N),w!==null)return As(w,h,N),II(w,g,N),!0}return!1}function IE(h,g,w,N){if(N={lane:2,revertLane:gk(),gesture:null,action:N,hasEagerState:!1,eagerState:null,next:null},Xv(h)){if(g)throw Error(r(479))}else g=tE(h,w,N,2),g!==null&&As(g,h,2)}function Xv(h){var g=h.alternate;return h===_n||g!==null&&g===_n}function FI(h,g){Jm=$v=!0;var w=h.pending;w===null?g.next=g:(g.next=w.next,w.next=g),h.pending=g}function II(h,g,w){if((w&4194048)!==0){var N=g.lanes;N&=h.pendingLanes,w|=N,g.lanes=w,Jt(h,w)}}var ob={readContext:Ma,use:Gv,useCallback:di,useContext:di,useEffect:di,useImperativeHandle:di,useLayoutEffect:di,useInsertionEffect:di,useMemo:di,useReducer:di,useRef:di,useState:di,useDebugValue:di,useDeferredValue:di,useTransition:di,useSyncExternalStore:di,useId:di,useHostTransitionStatus:di,useFormState:di,useActionState:di,useOptimistic:di,useMemoCache:di,useCacheRefresh:di};ob.useEffectEvent=di;var UI={readContext:Ma,use:Gv,useCallback:function(h,g){return ss().memoizedState=[h,g===void 0?null:g],h},useContext:Ma,useEffect:_I,useImperativeHandle:function(h,g,w){w=w!=null?w.concat([h]):null,Wv(4194308,4,EI.bind(null,g,h),w)},useLayoutEffect:function(h,g){return Wv(4194308,4,h,g)},useInsertionEffect:function(h,g){Wv(4,2,h,g)},useMemo:function(h,g){var w=ss();g=g===void 0?null:g;var N=h();if(nf){je(!0);try{h()}finally{je(!1)}}return w.memoizedState=[N,g],N},useReducer:function(h,g,w){var N=ss();if(w!==void 0){var P=w(g);if(nf){je(!0);try{w(g)}finally{je(!1)}}}else P=g;return N.memoizedState=N.baseState=P,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:h,lastRenderedState:P},N.queue=h,h=h.dispatch=Mie.bind(null,_n,h),[N.memoizedState,h]},useRef:function(h){var g=ss();return h={current:h},g.memoizedState=h},useState:function(h){h=jE(h);var g=h.queue,w=LI.bind(null,_n,g);return g.dispatch=w,[h.memoizedState,w]},useDebugValue:RE,useDeferredValue:function(h,g){var w=ss();return OE(w,h,g)},useTransition:function(){var h=jE(!1);return h=jI.bind(null,_n,h.queue,!0,!1),ss().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,g,w){var N=_n,P=ss();if(Xn){if(w===void 0)throw Error(r(407));w=w()}else{if(w=g(),Pr===null)throw Error(r(349));(Gn&127)!==0||sI(N,g,w)}P.memoizedState=w;var L={value:w,getSnapshot:g};return P.queue=L,_I(lI.bind(null,N,L,h),[h]),N.flags|=2048,tp(9,{destroy:void 0},oI.bind(null,N,L,w,g),null),w},useId:function(){var h=ss(),g=Pr.identifierPrefix;if(Xn){var w=ql,N=Gl;w=(N&~(1<<32-Be(N)-1)).toString(32)+w,g="_"+g+"R_"+w,w=Hv++,0<w&&(g+="H"+w.toString(32)),g+="_"}else w=bie++,g="_"+g+"r_"+w.toString(32)+"_";return h.memoizedState=g},useHostTransitionStatus:FE,useFormState:xI,useActionState:xI,useOptimistic:function(h){var g=ss();g.memoizedState=g.baseState=h;var w={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return g.queue=w,g=IE.bind(null,_n,!0,w),w.dispatch=g,[h,g]},useMemoCache:TE,useCacheRefresh:function(){return ss().memoizedState=Nie.bind(null,_n)},useEffectEvent:function(h){var g=ss(),w={impl:h};return g.memoizedState=w,function(){if((cr&2)!==0)throw Error(r(440));return w.impl.apply(void 0,arguments)}}},UE={readContext:Ma,use:Gv,useCallback:TI,useContext:Ma,useEffect:DE,useImperativeHandle:kI,useInsertionEffect:NI,useLayoutEffect:MI,useMemo:AI,useReducer:qv,useRef:wI,useState:function(){return qv(Lc)},useDebugValue:RE,useDeferredValue:function(h,g){var w=Mi();return CI(w,vr.memoizedState,h,g)},useTransition:function(){var h=qv(Lc)[0],g=Mi().memoizedState;return[typeof h=="boolean"?h:ab(h),g]},useSyncExternalStore:aI,useId:RI,useHostTransitionStatus:FE,useFormState:bI,useActionState:bI,useOptimistic:function(h,g){var w=Mi();return dI(w,vr,h,g)},useMemoCache:TE,useCacheRefresh:OI};UE.useEffectEvent=SI;var zI={readContext:Ma,use:Gv,useCallback:TI,useContext:Ma,useEffect:DE,useImperativeHandle:kI,useInsertionEffect:NI,useLayoutEffect:MI,useMemo:AI,useReducer:CE,useRef:wI,useState:function(){return CE(Lc)},useDebugValue:RE,useDeferredValue:function(h,g){var w=Mi();return vr===null?OE(w,h,g):CI(w,vr.memoizedState,h,g)},useTransition:function(){var h=CE(Lc)[0],g=Mi().memoizedState;return[typeof h=="boolean"?h:ab(h),g]},useSyncExternalStore:aI,useId:RI,useHostTransitionStatus:FE,useFormState:vI,useActionState:vI,useOptimistic:function(h,g){var w=Mi();return vr!==null?dI(w,vr,h,g):(w.baseState=h,[h,w.queue.dispatch])},useMemoCache:TE,useCacheRefresh:OI};zI.useEffectEvent=SI;function zE(h,g,w,N){g=h.memoizedState,w=w(N,g),w=w==null?g:f({},g,w),h.memoizedState=w,h.lanes===0&&(h.updateQueue.baseState=w)}var BE={enqueueSetState:function(h,g,w){h=h._reactInternals;var N=to(),P=ad(N);P.payload=g,w!=null&&(P.callback=w),g=sd(h,P,N),g!==null&&(As(g,h,N),tb(g,h,N))},enqueueReplaceState:function(h,g,w){h=h._reactInternals;var N=to(),P=ad(N);P.tag=1,P.payload=g,w!=null&&(P.callback=w),g=sd(h,P,N),g!==null&&(As(g,h,N),tb(g,h,N))},enqueueForceUpdate:function(h,g){h=h._reactInternals;var w=to(),N=ad(w);N.tag=2,g!=null&&(N.callback=g),g=sd(h,N,w),g!==null&&(As(g,h,w),tb(g,h,w))}};function BI(h,g,w,N,P,L,J){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(N,L,J):g.prototype&&g.prototype.isPureReactComponent?!Wx(w,N)||!Wx(P,L):!0}function $I(h,g,w,N){h=g.state,typeof g.componentWillReceiveProps=="function"&&g.componentWillReceiveProps(w,N),typeof g.UNSAFE_componentWillReceiveProps=="function"&&g.UNSAFE_componentWillReceiveProps(w,N),g.state!==h&&BE.enqueueReplaceState(g,g.state,null)}function rf(h,g){var w=g;if("ref"in g){w={};for(var N in g)N!=="ref"&&(w[N]=g[N])}if(h=h.defaultProps){w===g&&(w=f({},w));for(var P in h)w[P]===void 0&&(w[P]=h[P])}return w}function HI(h){kv(h)}function VI(h){console.error(h)}function GI(h){kv(h)}function Yv(h,g){try{var w=h.onUncaughtError;w(g.value,{componentStack:g.stack})}catch(N){setTimeout(function(){throw N})}}function qI(h,g,w){try{var N=h.onCaughtError;N(w.value,{componentStack:w.stack,errorBoundary:g.tag===1?g.stateNode:null})}catch(P){setTimeout(function(){throw P})}}function $E(h,g,w){return w=ad(w),w.tag=3,w.payload={element:null},w.callback=function(){Yv(h,g)},w}function WI(h){return h=ad(h),h.tag=3,h}function KI(h,g,w,N){var P=w.type.getDerivedStateFromError;if(typeof P=="function"){var L=N.value;h.payload=function(){return P(L)},h.callback=function(){qI(g,w,N)}}var J=w.stateNode;J!==null&&typeof J.componentDidCatch=="function"&&(h.callback=function(){qI(g,w,N),typeof P!="function"&&(hd===null?hd=new Set([this]):hd.add(this));var ve=N.stack;this.componentDidCatch(N.value,{componentStack:ve!==null?ve:""})})}function Eie(h,g,w,N,P){if(w.flags|=32768,N!==null&&typeof N=="object"&&typeof N.then=="function"){if(g=w.alternate,g!==null&&Wm(g,w,P,!0),w=Qs.current,w!==null){switch(w.tag){case 31:case 13:return jo===null?lw():w.alternate===null&&hi===0&&(hi=3),w.flags&=-257,w.flags|=65536,w.lanes=P,N===Fv?w.flags|=16384:(g=w.updateQueue,g===null?w.updateQueue=new Set([N]):g.add(N),fk(h,N,P)),!1;case 22:return w.flags|=65536,N===Fv?w.flags|=16384:(g=w.updateQueue,g===null?(g={transitions:null,markerInstances:null,retryQueue:new Set([N])},w.updateQueue=g):(w=g.retryQueue,w===null?g.retryQueue=new Set([N]):w.add(N)),fk(h,N,P)),!1}throw Error(r(435,w.tag))}return fk(h,N,P),lw(),!1}if(Xn)return g=Qs.current,g!==null?((g.flags&65536)===0&&(g.flags|=256),g.flags|=65536,g.lanes=P,N!==oE&&(h=Error(r(422),{cause:N}),Yx(ko(h,w)))):(N!==oE&&(g=Error(r(423),{cause:N}),Yx(ko(g,w))),h=h.current.alternate,h.flags|=65536,P&=-P,h.lanes|=P,N=ko(N,w),P=$E(h.stateNode,N,P),bE(h,P),hi!==4&&(hi=2)),!1;var L=Error(r(520),{cause:N});if(L=ko(L,w),pb===null?pb=[L]:pb.push(L),hi!==4&&(hi=2),g===null)return!0;N=ko(N,w),w=g;do{switch(w.tag){case 3:return w.flags|=65536,h=P&-P,w.lanes|=h,h=$E(w.stateNode,N,h),bE(w,h),!1;case 1:if(g=w.type,L=w.stateNode,(w.flags&128)===0&&(typeof g.getDerivedStateFromError=="function"||L!==null&&typeof L.componentDidCatch=="function"&&(hd===null||!hd.has(L))))return w.flags|=65536,P&=-P,w.lanes|=P,P=WI(P),KI(P,h,w,N),bE(w,P),!1}w=w.return}while(w!==null);return!1}var HE=Error(r(461)),Pi=!1;function Ea(h,g,w,N){g.child=h===null?ZF(g,null,w,N):tf(g,h.child,w,N)}function XI(h,g,w,N,P){w=w.render;var L=g.ref;if("ref"in N){var J={};for(var ve in N)ve!=="ref"&&(J[ve]=N[ve])}else J=N;return Qh(g),N=NE(h,g,w,J,L,P),ve=ME(),h!==null&&!Pi?(EE(h,g,P),Fc(h,g,P)):(Xn&&ve&&aE(g),g.flags|=1,Ea(h,g,N,P),g.child)}function YI(h,g,w,N,P){if(h===null){var L=w.type;return typeof L=="function"&&!nE(L)&&L.defaultProps===void 0&&w.compare===null?(g.tag=15,g.type=L,QI(h,g,L,N,P)):(h=jv(w.type,null,N,g,g.mode,P),h.ref=g.ref,h.return=g,g.child=h)}if(L=h.child,!QE(h,P)){var J=L.memoizedProps;if(w=w.compare,w=w!==null?w:Wx,w(J,N)&&h.ref===g.ref)return Fc(h,g,P)}return g.flags|=1,h=jc(L,N),h.ref=g.ref,h.return=g,g.child=h}function QI(h,g,w,N,P){if(h!==null){var L=h.memoizedProps;if(Wx(L,N)&&h.ref===g.ref)if(Pi=!1,g.pendingProps=N=L,QE(h,P))(h.flags&131072)!==0&&(Pi=!0);else return g.lanes=h.lanes,Fc(h,g,P)}return VE(h,g,w,N,P)}function ZI(h,g,w,N){var P=N.children,L=h!==null?h.memoizedState:null;if(h===null&&g.stateNode===null&&(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),N.mode==="hidden"){if((g.flags&128)!==0){if(L=L!==null?L.baseLanes|w:w,h!==null){for(N=g.child=h.child,P=0;N!==null;)P=P|N.lanes|N.childLanes,N=N.sibling;N=P&~L}else N=0,g.child=null;return JI(h,g,L,w,N)}if((w&536870912)!==0)g.memoizedState={baseLanes:0,cachePool:null},h!==null&&Ov(g,L!==null?L.cachePool:null),L!==null?tI(g,L):vE(),nI(g);else return N=g.lanes=536870912,JI(h,g,L!==null?L.baseLanes|w:w,w,N)}else L!==null?(Ov(g,L.cachePool),tI(g,L),ld(),g.memoizedState=null):(h!==null&&Ov(g,null),vE(),ld());return Ea(h,g,P,w),g.child}function lb(h,g){return h!==null&&h.tag===22||g.stateNode!==null||(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.sibling}function JI(h,g,w,N,P){var L=mE();return L=L===null?null:{parent:Ci._currentValue,pool:L},g.memoizedState={baseLanes:w,cachePool:L},h!==null&&Ov(g,null),vE(),nI(g),h!==null&&Wm(h,g,N,!0),g.childLanes=P,null}function Qv(h,g){return g=Jv({mode:g.mode,children:g.children},h.mode),g.ref=h.ref,h.child=g,g.return=h,g}function e5(h,g,w){return tf(g,h.child,null,w),h=Qv(g,g.pendingProps),h.flags|=2,Zs(g),g.memoizedState=null,h}function kie(h,g,w){var N=g.pendingProps,P=(g.flags&128)!==0;if(g.flags&=-129,h===null){if(Xn){if(N.mode==="hidden")return h=Qv(g,N),g.lanes=536870912,lb(null,h);if(_E(g),(h=Hr)?(h=hU(h,Co),h=h!==null&&h.data==="&"?h:null,h!==null&&(g.memoizedState={dehydrated:h,treeContext:ed!==null?{id:Gl,overflow:ql}:null,retryLane:536870912,hydrationErrors:null},w=FF(h),w.return=g,g.child=w,Na=g,Hr=null)):h=null,h===null)throw nd(g);return g.lanes=536870912,null}return Qv(g,N)}var L=h.memoizedState;if(L!==null){var J=L.dehydrated;if(_E(g),P)if(g.flags&256)g.flags&=-257,g=e5(h,g,w);else if(g.memoizedState!==null)g.child=h.child,g.flags|=128,g=null;else throw Error(r(558));else if(Pi||Wm(h,g,w,!1),P=(w&h.childLanes)!==0,Pi||P){if(N=Pr,N!==null&&(J=rr(N,w),J!==0&&J!==L.retryLane))throw L.retryLane=J,Wh(h,J),As(N,h,J),HE;lw(),g=e5(h,g,w)}else h=L.treeContext,Hr=Po(J.nextSibling),Na=g,Xn=!0,td=null,Co=!1,h!==null&&zF(g,h),g=Qv(g,N),g.flags|=4096;return g}return h=jc(h.child,{mode:N.mode,children:N.children}),h.ref=g.ref,g.child=h,h.return=g,h}function Zv(h,g){var w=g.ref;if(w===null)h!==null&&h.ref!==null&&(g.flags|=4194816);else{if(typeof w!="function"&&typeof w!="object")throw Error(r(284));(h===null||h.ref!==w)&&(g.flags|=4194816)}}function VE(h,g,w,N,P){return Qh(g),w=NE(h,g,w,N,void 0,P),N=ME(),h!==null&&!Pi?(EE(h,g,P),Fc(h,g,P)):(Xn&&N&&aE(g),g.flags|=1,Ea(h,g,w,P),g.child)}function t5(h,g,w,N,P,L){return Qh(g),g.updateQueue=null,w=iI(g,N,w,P),rI(h),N=ME(),h!==null&&!Pi?(EE(h,g,L),Fc(h,g,L)):(Xn&&N&&aE(g),g.flags|=1,Ea(h,g,w,L),g.child)}function n5(h,g,w,N,P){if(Qh(g),g.stateNode===null){var L=Hm,J=w.contextType;typeof J=="object"&&J!==null&&(L=Ma(J)),L=new w(N,L),g.memoizedState=L.state!==null&&L.state!==void 0?L.state:null,L.updater=BE,g.stateNode=L,L._reactInternals=g,L=g.stateNode,L.props=N,L.state=g.memoizedState,L.refs={},gE(g),J=w.contextType,L.context=typeof J=="object"&&J!==null?Ma(J):Hm,L.state=g.memoizedState,J=w.getDerivedStateFromProps,typeof J=="function"&&(zE(g,w,J,N),L.state=g.memoizedState),typeof w.getDerivedStateFromProps=="function"||typeof L.getSnapshotBeforeUpdate=="function"||typeof L.UNSAFE_componentWillMount!="function"&&typeof L.componentWillMount!="function"||(J=L.state,typeof L.componentWillMount=="function"&&L.componentWillMount(),typeof L.UNSAFE_componentWillMount=="function"&&L.UNSAFE_componentWillMount(),J!==L.state&&BE.enqueueReplaceState(L,L.state,null),rb(g,N,L,P),nb(),L.state=g.memoizedState),typeof L.componentDidMount=="function"&&(g.flags|=4194308),N=!0}else if(h===null){L=g.stateNode;var ve=g.memoizedProps,Ue=rf(w,ve);L.props=Ue;var it=L.context,gt=w.contextType;J=Hm,typeof gt=="object"&&gt!==null&&(J=Ma(gt));var vt=w.getDerivedStateFromProps;gt=typeof vt=="function"||typeof L.getSnapshotBeforeUpdate=="function",ve=g.pendingProps!==ve,gt||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(ve||it!==J)&&$I(g,L,N,J),id=!1;var ct=g.memoizedState;L.state=ct,rb(g,N,L,P),nb(),it=g.memoizedState,ve||ct!==it||id?(typeof vt=="function"&&(zE(g,w,vt,N),it=g.memoizedState),(Ue=id||BI(g,w,Ue,N,ct,it,J))?(gt||typeof L.UNSAFE_componentWillMount!="function"&&typeof L.componentWillMount!="function"||(typeof L.componentWillMount=="function"&&L.componentWillMount(),typeof L.UNSAFE_componentWillMount=="function"&&L.UNSAFE_componentWillMount()),typeof L.componentDidMount=="function"&&(g.flags|=4194308)):(typeof L.componentDidMount=="function"&&(g.flags|=4194308),g.memoizedProps=N,g.memoizedState=it),L.props=N,L.state=it,L.context=J,N=Ue):(typeof L.componentDidMount=="function"&&(g.flags|=4194308),N=!1)}else{L=g.stateNode,xE(h,g),J=g.memoizedProps,gt=rf(w,J),L.props=gt,vt=g.pendingProps,ct=L.context,it=w.contextType,Ue=Hm,typeof it=="object"&&it!==null&&(Ue=Ma(it)),ve=w.getDerivedStateFromProps,(it=typeof ve=="function"||typeof L.getSnapshotBeforeUpdate=="function")||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(J!==vt||ct!==Ue)&&$I(g,L,N,Ue),id=!1,ct=g.memoizedState,L.state=ct,rb(g,N,L,P),nb();var pt=g.memoizedState;J!==vt||ct!==pt||id||h!==null&&h.dependencies!==null&&Dv(h.dependencies)?(typeof ve=="function"&&(zE(g,w,ve,N),pt=g.memoizedState),(gt=id||BI(g,w,gt,N,ct,pt,Ue)||h!==null&&h.dependencies!==null&&Dv(h.dependencies))?(it||typeof L.UNSAFE_componentWillUpdate!="function"&&typeof L.componentWillUpdate!="function"||(typeof L.componentWillUpdate=="function"&&L.componentWillUpdate(N,pt,Ue),typeof L.UNSAFE_componentWillUpdate=="function"&&L.UNSAFE_componentWillUpdate(N,pt,Ue)),typeof L.componentDidUpdate=="function"&&(g.flags|=4),typeof L.getSnapshotBeforeUpdate=="function"&&(g.flags|=1024)):(typeof L.componentDidUpdate!="function"||J===h.memoizedProps&&ct===h.memoizedState||(g.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||J===h.memoizedProps&&ct===h.memoizedState||(g.flags|=1024),g.memoizedProps=N,g.memoizedState=pt),L.props=N,L.state=pt,L.context=Ue,N=gt):(typeof L.componentDidUpdate!="function"||J===h.memoizedProps&&ct===h.memoizedState||(g.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||J===h.memoizedProps&&ct===h.memoizedState||(g.flags|=1024),N=!1)}return L=N,Zv(h,g),N=(g.flags&128)!==0,L||N?(L=g.stateNode,w=N&&typeof w.getDerivedStateFromError!="function"?null:L.render(),g.flags|=1,h!==null&&N?(g.child=tf(g,h.child,null,P),g.child=tf(g,null,w,P)):Ea(h,g,w,P),g.memoizedState=L.state,h=g.child):h=Fc(h,g,P),h}function r5(h,g,w,N){return Xh(),g.flags|=256,Ea(h,g,w,N),g.child}var GE={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function qE(h){return{baseLanes:h,cachePool:qF()}}function WE(h,g,w){return h=h!==null?h.childLanes&~w:0,g&&(h|=eo),h}function i5(h,g,w){var N=g.pendingProps,P=!1,L=(g.flags&128)!==0,J;if((J=L)||(J=h!==null&&h.memoizedState===null?!1:(Ni.current&2)!==0),J&&(P=!0,g.flags&=-129),J=(g.flags&32)!==0,g.flags&=-33,h===null){if(Xn){if(P?od(g):ld(),(h=Hr)?(h=hU(h,Co),h=h!==null&&h.data!=="&"?h:null,h!==null&&(g.memoizedState={dehydrated:h,treeContext:ed!==null?{id:Gl,overflow:ql}:null,retryLane:536870912,hydrationErrors:null},w=FF(h),w.return=g,g.child=w,Na=g,Hr=null)):h=null,h===null)throw nd(g);return Ak(h)?g.lanes=32:g.lanes=536870912,null}var ve=N.children;return N=N.fallback,P?(ld(),P=g.mode,ve=Jv({mode:"hidden",children:ve},P),N=Kh(N,P,w,null),ve.return=g,N.return=g,ve.sibling=N,g.child=ve,N=g.child,N.memoizedState=qE(w),N.childLanes=WE(h,J,w),g.memoizedState=GE,lb(null,N)):(od(g),KE(g,ve))}var Ue=h.memoizedState;if(Ue!==null&&(ve=Ue.dehydrated,ve!==null)){if(L)g.flags&256?(od(g),g.flags&=-257,g=XE(h,g,w)):g.memoizedState!==null?(ld(),g.child=h.child,g.flags|=128,g=null):(ld(),ve=N.fallback,P=g.mode,N=Jv({mode:"visible",children:N.children},P),ve=Kh(ve,P,w,null),ve.flags|=2,N.return=g,ve.return=g,N.sibling=ve,g.child=N,tf(g,h.child,null,w),N=g.child,N.memoizedState=qE(w),N.childLanes=WE(h,J,w),g.memoizedState=GE,g=lb(null,N));else if(od(g),Ak(ve)){if(J=ve.nextSibling&&ve.nextSibling.dataset,J)var it=J.dgst;J=it,N=Error(r(419)),N.stack="",N.digest=J,Yx({value:N,source:null,stack:null}),g=XE(h,g,w)}else if(Pi||Wm(h,g,w,!1),J=(w&h.childLanes)!==0,Pi||J){if(J=Pr,J!==null&&(N=rr(J,w),N!==0&&N!==Ue.retryLane))throw Ue.retryLane=N,Wh(h,N),As(J,h,N),HE;Tk(ve)||lw(),g=XE(h,g,w)}else Tk(ve)?(g.flags|=192,g.child=h.child,g=null):(h=Ue.treeContext,Hr=Po(ve.nextSibling),Na=g,Xn=!0,td=null,Co=!1,h!==null&&zF(g,h),g=KE(g,N.children),g.flags|=4096);return g}return P?(ld(),ve=N.fallback,P=g.mode,Ue=h.child,it=Ue.sibling,N=jc(Ue,{mode:"hidden",children:N.children}),N.subtreeFlags=Ue.subtreeFlags&65011712,it!==null?ve=jc(it,ve):(ve=Kh(ve,P,w,null),ve.flags|=2),ve.return=g,N.return=g,N.sibling=ve,g.child=N,lb(null,N),N=g.child,ve=h.child.memoizedState,ve===null?ve=qE(w):(P=ve.cachePool,P!==null?(Ue=Ci._currentValue,P=P.parent!==Ue?{parent:Ue,pool:Ue}:P):P=qF(),ve={baseLanes:ve.baseLanes|w,cachePool:P}),N.memoizedState=ve,N.childLanes=WE(h,J,w),g.memoizedState=GE,lb(h.child,N)):(od(g),w=h.child,h=w.sibling,w=jc(w,{mode:"visible",children:N.children}),w.return=g,w.sibling=null,h!==null&&(J=g.deletions,J===null?(g.deletions=[h],g.flags|=16):J.push(h)),g.child=w,g.memoizedState=null,w)}function KE(h,g){return g=Jv({mode:"visible",children:g},h.mode),g.return=h,h.child=g}function Jv(h,g){return h=Ys(22,h,null,g),h.lanes=0,h}function XE(h,g,w){return tf(g,h.child,null,w),h=KE(g,g.pendingProps.children),h.flags|=2,g.memoizedState=null,h}function a5(h,g,w){h.lanes|=g;var N=h.alternate;N!==null&&(N.lanes|=g),uE(h.return,g,w)}function YE(h,g,w,N,P,L){var J=h.memoizedState;J===null?h.memoizedState={isBackwards:g,rendering:null,renderingStartTime:0,last:N,tail:w,tailMode:P,treeForkCount:L}:(J.isBackwards=g,J.rendering=null,J.renderingStartTime=0,J.last=N,J.tail=w,J.tailMode=P,J.treeForkCount=L)}function s5(h,g,w){var N=g.pendingProps,P=N.revealOrder,L=N.tail;N=N.children;var J=Ni.current,ve=(J&2)!==0;if(ve?(J=J&1|2,g.flags|=128):J&=1,ne(Ni,J),Ea(h,g,N,w),N=Xn?Xx:0,!ve&&h!==null&&(h.flags&128)!==0)e:for(h=g.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&a5(h,w,g);else if(h.tag===19)a5(h,w,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(w=g.child,P=null;w!==null;)h=w.alternate,h!==null&&Bv(h)===null&&(P=w),w=w.sibling;w=P,w===null?(P=g.child,g.child=null):(P=w.sibling,w.sibling=null),YE(g,!1,P,w,L,N);break;case"backwards":case"unstable_legacy-backwards":for(w=null,P=g.child,g.child=null;P!==null;){if(h=P.alternate,h!==null&&Bv(h)===null){g.child=P;break}h=P.sibling,P.sibling=w,w=P,P=h}YE(g,!0,w,null,L,N);break;case"together":YE(g,!1,null,null,void 0,N);break;default:g.memoizedState=null}return g.child}function Fc(h,g,w){if(h!==null&&(g.dependencies=h.dependencies),dd|=g.lanes,(w&g.childLanes)===0)if(h!==null){if(Wm(h,g,w,!1),(w&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,w=jc(h,h.pendingProps),g.child=w,w.return=g;h.sibling!==null;)h=h.sibling,w=w.sibling=jc(h,h.pendingProps),w.return=g;w.sibling=null}return g.child}function QE(h,g){return(h.lanes&g)!==0?!0:(h=h.dependencies,!!(h!==null&&Dv(h)))}function Tie(h,g,w){switch(g.tag){case 3:Pe(g,g.stateNode.containerInfo),rd(g,Ci,h.memoizedState.cache),Xh();break;case 27:case 5:Me(g);break;case 4:Pe(g,g.stateNode.containerInfo);break;case 10:rd(g,g.type,g.memoizedProps.value);break;case 31:if(g.memoizedState!==null)return g.flags|=128,_E(g),null;break;case 13:var N=g.memoizedState;if(N!==null)return N.dehydrated!==null?(od(g),g.flags|=128,null):(w&g.child.childLanes)!==0?i5(h,g,w):(od(g),h=Fc(h,g,w),h!==null?h.sibling:null);od(g);break;case 19:var P=(h.flags&128)!==0;if(N=(w&g.childLanes)!==0,N||(Wm(h,g,w,!1),N=(w&g.childLanes)!==0),P){if(N)return s5(h,g,w);g.flags|=128}if(P=g.memoizedState,P!==null&&(P.rendering=null,P.tail=null,P.lastEffect=null),ne(Ni,Ni.current),N)break;return null;case 22:return g.lanes=0,ZI(h,g,w,g.pendingProps);case 24:rd(g,Ci,h.memoizedState.cache)}return Fc(h,g,w)}function o5(h,g,w){if(h!==null)if(h.memoizedProps!==g.pendingProps)Pi=!0;else{if(!QE(h,w)&&(g.flags&128)===0)return Pi=!1,Tie(h,g,w);Pi=(h.flags&131072)!==0}else Pi=!1,Xn&&(g.flags&1048576)!==0&&UF(g,Xx,g.index);switch(g.lanes=0,g.tag){case 16:e:{var N=g.pendingProps;if(h=Jh(g.elementType),g.type=h,typeof h=="function")nE(h)?(N=rf(h,N),g.tag=1,g=n5(null,g,h,N,w)):(g.tag=0,g=VE(null,g,h,N,w));else{if(h!=null){var P=h.$$typeof;if(P===T){g.tag=11,g=XI(null,g,h,N,w);break e}else if(P===k){g.tag=14,g=YI(null,g,h,N,w);break e}}throw g=j(h)||h,Error(r(306,g,""))}}return g;case 0:return VE(h,g,g.type,g.pendingProps,w);case 1:return N=g.type,P=rf(N,g.pendingProps),n5(h,g,N,P,w);case 3:e:{if(Pe(g,g.stateNode.containerInfo),h===null)throw Error(r(387));N=g.pendingProps;var L=g.memoizedState;P=L.element,xE(h,g),rb(g,N,null,w);var J=g.memoizedState;if(N=J.cache,rd(g,Ci,N),N!==L.cache&&dE(g,[Ci],w,!0),nb(),N=J.element,L.isDehydrated)if(L={element:N,isDehydrated:!1,cache:J.cache},g.updateQueue.baseState=L,g.memoizedState=L,g.flags&256){g=r5(h,g,N,w);break e}else if(N!==P){P=ko(Error(r(424)),g),Yx(P),g=r5(h,g,N,w);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(Hr=Po(h.firstChild),Na=g,Xn=!0,td=null,Co=!0,w=ZF(g,null,N,w),g.child=w;w;)w.flags=w.flags&-3|4096,w=w.sibling}else{if(Xh(),N===P){g=Fc(h,g,w);break e}Ea(h,g,N,w)}g=g.child}return g;case 26:return Zv(h,g),h===null?(w=bU(g.type,null,g.pendingProps,null))?g.memoizedState=w:Xn||(w=g.type,h=g.pendingProps,N=pw(xe.current).createElement(w),N[Kn]=g,N[bn]=h,ka(N,w,h),Le(N),g.stateNode=N):g.memoizedState=bU(g.type,h.memoizedProps,g.pendingProps,h.memoizedState),null;case 27:return Me(g),h===null&&Xn&&(N=g.stateNode=pU(g.type,g.pendingProps,xe.current),Na=g,Co=!0,P=Hr,gd(g.type)?(Ck=P,Hr=Po(N.firstChild)):Hr=P),Ea(h,g,g.pendingProps.children,w),Zv(h,g),h===null&&(g.flags|=4194304),g.child;case 5:return h===null&&Xn&&((P=N=Hr)&&(N=iae(N,g.type,g.pendingProps,Co),N!==null?(g.stateNode=N,Na=g,Hr=Po(N.firstChild),Co=!1,P=!0):P=!1),P||nd(g)),Me(g),P=g.type,L=g.pendingProps,J=h!==null?h.memoizedProps:null,N=L.children,Mk(P,L)?N=null:J!==null&&Mk(P,J)&&(g.flags|=32),g.memoizedState!==null&&(P=NE(h,g,yie,null,null,w),Sb._currentValue=P),Zv(h,g),Ea(h,g,N,w),g.child;case 6:return h===null&&Xn&&((h=w=Hr)&&(w=aae(w,g.pendingProps,Co),w!==null?(g.stateNode=w,Na=g,Hr=null,h=!0):h=!1),h||nd(g)),null;case 13:return i5(h,g,w);case 4:return Pe(g,g.stateNode.containerInfo),N=g.pendingProps,h===null?g.child=tf(g,null,N,w):Ea(h,g,N,w),g.child;case 11:return XI(h,g,g.type,g.pendingProps,w);case 7:return Ea(h,g,g.pendingProps,w),g.child;case 8:return Ea(h,g,g.pendingProps.children,w),g.child;case 12:return Ea(h,g,g.pendingProps.children,w),g.child;case 10:return N=g.pendingProps,rd(g,g.type,N.value),Ea(h,g,N.children,w),g.child;case 9:return P=g.type._context,N=g.pendingProps.children,Qh(g),P=Ma(P),N=N(P),g.flags|=1,Ea(h,g,N,w),g.child;case 14:return YI(h,g,g.type,g.pendingProps,w);case 15:return QI(h,g,g.type,g.pendingProps,w);case 19:return s5(h,g,w);case 31:return kie(h,g,w);case 22:return ZI(h,g,w,g.pendingProps);case 24:return Qh(g),N=Ma(Ci),h===null?(P=mE(),P===null&&(P=Pr,L=hE(),P.pooledCache=L,L.refCount++,L!==null&&(P.pooledCacheLanes|=w),P=L),g.memoizedState={parent:N,cache:P},gE(g),rd(g,Ci,P)):((h.lanes&w)!==0&&(xE(h,g),rb(g,null,null,w),nb()),P=h.memoizedState,L=g.memoizedState,P.parent!==N?(P={parent:N,cache:N},g.memoizedState=P,g.lanes===0&&(g.memoizedState=g.updateQueue.baseState=P),rd(g,Ci,N)):(N=L.cache,rd(g,Ci,N),N!==P.cache&&dE(g,[Ci],w,!0))),Ea(h,g,g.pendingProps.children,w),g.child;case 29:throw g.pendingProps}throw Error(r(156,g.tag))}function Ic(h){h.flags|=4}function ZE(h,g,w,N,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(R5())h.flags|=8192;else throw ef=Fv,pE}else h.flags&=-16777217}function l5(h,g){if(g.type!=="stylesheet"||(g.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!SU(g))if(R5())h.flags|=8192;else throw ef=Fv,pE}function ew(h,g){g!==null&&(h.flags|=4),h.flags&16384&&(g=h.tag!==22?xt():536870912,h.lanes|=g,ap|=g)}function cb(h,g){if(!Xn)switch(h.tailMode){case"hidden":g=h.tail;for(var w=null;g!==null;)g.alternate!==null&&(w=g),g=g.sibling;w===null?h.tail=null:w.sibling=null;break;case"collapsed":w=h.tail;for(var N=null;w!==null;)w.alternate!==null&&(N=w),w=w.sibling;N===null?g||h.tail===null?h.tail=null:h.tail.sibling=null:N.sibling=null}}function Vr(h){var g=h.alternate!==null&&h.alternate.child===h.child,w=0,N=0;if(g)for(var P=h.child;P!==null;)w|=P.lanes|P.childLanes,N|=P.subtreeFlags&65011712,N|=P.flags&65011712,P.return=h,P=P.sibling;else for(P=h.child;P!==null;)w|=P.lanes|P.childLanes,N|=P.subtreeFlags,N|=P.flags,P.return=h,P=P.sibling;return h.subtreeFlags|=N,h.childLanes=w,g}function Aie(h,g,w){var N=g.pendingProps;switch(sE(g),g.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Vr(g),null;case 1:return Vr(g),null;case 3:return w=g.stateNode,N=null,h!==null&&(N=h.memoizedState.cache),g.memoizedState.cache!==N&&(g.flags|=2048),Rc(Ci),ie(),w.pendingContext&&(w.context=w.pendingContext,w.pendingContext=null),(h===null||h.child===null)&&(qm(g)?Ic(g):h===null||h.memoizedState.isDehydrated&&(g.flags&256)===0||(g.flags|=1024,lE())),Vr(g),null;case 26:var P=g.type,L=g.memoizedState;return h===null?(Ic(g),L!==null?(Vr(g),l5(g,L)):(Vr(g),ZE(g,P,null,N,w))):L?L!==h.memoizedState?(Ic(g),Vr(g),l5(g,L)):(Vr(g),g.flags&=-16777217):(h=h.memoizedProps,h!==N&&Ic(g),Vr(g),ZE(g,P,h,N,w)),null;case 27:if(Oe(g),w=xe.current,P=g.type,h!==null&&g.stateNode!=null)h.memoizedProps!==N&&Ic(g);else{if(!N){if(g.stateNode===null)throw Error(r(166));return Vr(g),null}h=se.current,qm(g)?BF(g):(h=pU(P,N,w),g.stateNode=h,Ic(g))}return Vr(g),null;case 5:if(Oe(g),P=g.type,h!==null&&g.stateNode!=null)h.memoizedProps!==N&&Ic(g);else{if(!N){if(g.stateNode===null)throw Error(r(166));return Vr(g),null}if(L=se.current,qm(g))BF(g);else{var J=pw(xe.current);switch(L){case 1:L=J.createElementNS("http://www.w3.org/2000/svg",P);break;case 2:L=J.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;default:switch(P){case"svg":L=J.createElementNS("http://www.w3.org/2000/svg",P);break;case"math":L=J.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;case"script":L=J.createElement("div"),L.innerHTML="<script><\/script>",L=L.removeChild(L.firstChild);break;case"select":L=typeof N.is=="string"?J.createElement("select",{is:N.is}):J.createElement("select"),N.multiple?L.multiple=!0:N.size&&(L.size=N.size);break;default:L=typeof N.is=="string"?J.createElement(P,{is:N.is}):J.createElement(P)}}L[Kn]=g,L[bn]=N;e:for(J=g.child;J!==null;){if(J.tag===5||J.tag===6)L.appendChild(J.stateNode);else if(J.tag!==4&&J.tag!==27&&J.child!==null){J.child.return=J,J=J.child;continue}if(J===g)break e;for(;J.sibling===null;){if(J.return===null||J.return===g)break e;J=J.return}J.sibling.return=J.return,J=J.sibling}g.stateNode=L;e:switch(ka(L,P,N),P){case"button":case"input":case"select":case"textarea":N=!!N.autoFocus;break e;case"img":N=!0;break e;default:N=!1}N&&Ic(g)}}return Vr(g),ZE(g,g.type,h===null?null:h.memoizedProps,g.pendingProps,w),null;case 6:if(h&&g.stateNode!=null)h.memoizedProps!==N&&Ic(g);else{if(typeof N!="string"&&g.stateNode===null)throw Error(r(166));if(h=xe.current,qm(g)){if(h=g.stateNode,w=g.memoizedProps,N=null,P=Na,P!==null)switch(P.tag){case 27:case 5:N=P.memoizedProps}h[Kn]=g,h=!!(h.nodeValue===w||N!==null&&N.suppressHydrationWarning===!0||iU(h.nodeValue,w)),h||nd(g,!0)}else h=pw(h).createTextNode(N),h[Kn]=g,g.stateNode=h}return Vr(g),null;case 31:if(w=g.memoizedState,h===null||h.memoizedState!==null){if(N=qm(g),w!==null){if(h===null){if(!N)throw Error(r(318));if(h=g.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(557));h[Kn]=g}else Xh(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Vr(g),h=!1}else w=lE(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=w),h=!0;if(!h)return g.flags&256?(Zs(g),g):(Zs(g),null);if((g.flags&128)!==0)throw Error(r(558))}return Vr(g),null;case 13:if(N=g.memoizedState,h===null||h.memoizedState!==null&&h.memoizedState.dehydrated!==null){if(P=qm(g),N!==null&&N.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[Kn]=g}else Xh(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Vr(g),P=!1}else P=lE(),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=w,g):(w=N!==null,h=h!==null&&h.memoizedState!==null,w&&(N=g.child,P=null,N.alternate!==null&&N.alternate.memoizedState!==null&&N.alternate.memoizedState.cachePool!==null&&(P=N.alternate.memoizedState.cachePool.pool),L=null,N.memoizedState!==null&&N.memoizedState.cachePool!==null&&(L=N.memoizedState.cachePool.pool),L!==P&&(N.flags|=2048)),w!==h&&w&&(g.child.flags|=8192),ew(g,g.updateQueue),Vr(g),null);case 4:return ie(),h===null&&vk(g.stateNode.containerInfo),Vr(g),null;case 10:return Rc(g.type),Vr(g),null;case 19:if(X(Ni),N=g.memoizedState,N===null)return Vr(g),null;if(P=(g.flags&128)!==0,L=N.rendering,L===null)if(P)cb(N,!1);else{if(hi!==0||h!==null&&(h.flags&128)!==0)for(h=g.child;h!==null;){if(L=Bv(h),L!==null){for(g.flags|=128,cb(N,!1),h=L.updateQueue,g.updateQueue=h,ew(g,h),g.subtreeFlags=0,h=w,w=g.child;w!==null;)LF(w,h),w=w.sibling;return ne(Ni,Ni.current&1|2),Xn&&Pc(g,N.treeForkCount),g.child}h=h.sibling}N.tail!==null&&O()>aw&&(g.flags|=128,P=!0,cb(N,!1),g.lanes=4194304)}else{if(!P)if(h=Bv(L),h!==null){if(g.flags|=128,P=!0,h=h.updateQueue,g.updateQueue=h,ew(g,h),cb(N,!0),N.tail===null&&N.tailMode==="hidden"&&!L.alternate&&!Xn)return Vr(g),null}else 2*O()-N.renderingStartTime>aw&&w!==536870912&&(g.flags|=128,P=!0,cb(N,!1),g.lanes=4194304);N.isBackwards?(L.sibling=g.child,g.child=L):(h=N.last,h!==null?h.sibling=L:g.child=L,N.last=L)}return N.tail!==null?(h=N.tail,N.rendering=h,N.tail=h.sibling,N.renderingStartTime=O(),h.sibling=null,w=Ni.current,ne(Ni,P?w&1|2:w&1),Xn&&Pc(g,N.treeForkCount),h):(Vr(g),null);case 22:case 23:return Zs(g),wE(),N=g.memoizedState!==null,h!==null?h.memoizedState!==null!==N&&(g.flags|=8192):N&&(g.flags|=8192),N?(w&536870912)!==0&&(g.flags&128)===0&&(Vr(g),g.subtreeFlags&6&&(g.flags|=8192)):Vr(g),w=g.updateQueue,w!==null&&ew(g,w.retryQueue),w=null,h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(w=h.memoizedState.cachePool.pool),N=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(N=g.memoizedState.cachePool.pool),N!==w&&(g.flags|=2048),h!==null&&X(Zh),null;case 24:return w=null,h!==null&&(w=h.memoizedState.cache),g.memoizedState.cache!==w&&(g.flags|=2048),Rc(Ci),Vr(g),null;case 25:return null;case 30:return null}throw Error(r(156,g.tag))}function Cie(h,g){switch(sE(g),g.tag){case 1:return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 3:return Rc(Ci),ie(),h=g.flags,(h&65536)!==0&&(h&128)===0?(g.flags=h&-65537|128,g):null;case 26:case 27:case 5:return Oe(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 X(Ni),null;case 4:return ie(),null;case 10:return Rc(g.type),null;case 22:case 23:return Zs(g),wE(),h!==null&&X(Zh),h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 24:return Rc(Ci),null;case 25:return null;default:return null}}function c5(h,g){switch(sE(g),g.tag){case 3:Rc(Ci),ie();break;case 26:case 27:case 5:Oe(g);break;case 4:ie();break;case 31:g.memoizedState!==null&&Zs(g);break;case 13:Zs(g);break;case 19:X(Ni);break;case 10:Rc(g.type);break;case 22:case 23:Zs(g),wE(),h!==null&&X(Zh);break;case 24:Rc(Ci)}}function ub(h,g){try{var w=g.updateQueue,N=w!==null?w.lastEffect:null;if(N!==null){var P=N.next;w=P;do{if((w.tag&h)===h){N=void 0;var L=w.create,J=w.inst;N=L(),J.destroy=N}w=w.next}while(w!==P)}}catch(ve){pr(g,g.return,ve)}}function cd(h,g,w){try{var N=g.updateQueue,P=N!==null?N.lastEffect:null;if(P!==null){var L=P.next;N=L;do{if((N.tag&h)===h){var J=N.inst,ve=J.destroy;if(ve!==void 0){J.destroy=void 0,P=g;var Ue=w,it=ve;try{it()}catch(gt){pr(P,Ue,gt)}}}N=N.next}while(N!==L)}}catch(gt){pr(g,g.return,gt)}}function u5(h){var g=h.updateQueue;if(g!==null){var w=h.stateNode;try{eI(g,w)}catch(N){pr(h,h.return,N)}}}function d5(h,g,w){w.props=rf(h.type,h.memoizedProps),w.state=h.memoizedState;try{w.componentWillUnmount()}catch(N){pr(h,g,N)}}function db(h,g){try{var w=h.ref;if(w!==null){switch(h.tag){case 26:case 27:case 5:var N=h.stateNode;break;case 30:N=h.stateNode;break;default:N=h.stateNode}typeof w=="function"?h.refCleanup=w(N):w.current=N}}catch(P){pr(h,g,P)}}function Wl(h,g){var w=h.ref,N=h.refCleanup;if(w!==null)if(typeof N=="function")try{N()}catch(P){pr(h,g,P)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof w=="function")try{w(null)}catch(P){pr(h,g,P)}else w.current=null}function h5(h){var g=h.type,w=h.memoizedProps,N=h.stateNode;try{e:switch(g){case"button":case"input":case"select":case"textarea":w.autoFocus&&N.focus();break e;case"img":w.src?N.src=w.src:w.srcSet&&(N.srcset=w.srcSet)}}catch(P){pr(h,h.return,P)}}function JE(h,g,w){try{var N=h.stateNode;Zie(N,h.type,w,g),N[bn]=g}catch(P){pr(h,h.return,P)}}function f5(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&gd(h.type)||h.tag===4}function ek(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||f5(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&&gd(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 tk(h,g,w){var N=h.tag;if(N===5||N===6)h=h.stateNode,g?(w.nodeType===9?w.body:w.nodeName==="HTML"?w.ownerDocument.body:w).insertBefore(h,g):(g=w.nodeType===9?w.body:w.nodeName==="HTML"?w.ownerDocument.body:w,g.appendChild(h),w=w._reactRootContainer,w!=null||g.onclick!==null||(g.onclick=_i));else if(N!==4&&(N===27&&gd(h.type)&&(w=h.stateNode,g=null),h=h.child,h!==null))for(tk(h,g,w),h=h.sibling;h!==null;)tk(h,g,w),h=h.sibling}function tw(h,g,w){var N=h.tag;if(N===5||N===6)h=h.stateNode,g?w.insertBefore(h,g):w.appendChild(h);else if(N!==4&&(N===27&&gd(h.type)&&(w=h.stateNode),h=h.child,h!==null))for(tw(h,g,w),h=h.sibling;h!==null;)tw(h,g,w),h=h.sibling}function m5(h){var g=h.stateNode,w=h.memoizedProps;try{for(var N=h.type,P=g.attributes;P.length;)g.removeAttributeNode(P[0]);ka(g,N,w),g[Kn]=h,g[bn]=w}catch(L){pr(h,h.return,L)}}var Uc=!1,Di=!1,nk=!1,p5=typeof WeakSet=="function"?WeakSet:Set,ua=null;function jie(h,g){if(h=h.containerInfo,Sk=_w,h=kF(h),XM(h)){if("selectionStart"in h)var w={start:h.selectionStart,end:h.selectionEnd};else e:{w=(w=h.ownerDocument)&&w.defaultView||window;var N=w.getSelection&&w.getSelection();if(N&&N.rangeCount!==0){w=N.anchorNode;var P=N.anchorOffset,L=N.focusNode;N=N.focusOffset;try{w.nodeType,L.nodeType}catch{w=null;break e}var J=0,ve=-1,Ue=-1,it=0,gt=0,vt=h,ct=null;t:for(;;){for(var pt;vt!==w||P!==0&&vt.nodeType!==3||(ve=J+P),vt!==L||N!==0&&vt.nodeType!==3||(Ue=J+N),vt.nodeType===3&&(J+=vt.nodeValue.length),(pt=vt.firstChild)!==null;)ct=vt,vt=pt;for(;;){if(vt===h)break t;if(ct===w&&++it===P&&(ve=J),ct===L&&++gt===N&&(Ue=J),(pt=vt.nextSibling)!==null)break;vt=ct,ct=vt.parentNode}vt=pt}w=ve===-1||Ue===-1?null:{start:ve,end:Ue}}else w=null}w=w||{start:0,end:0}}else w=null;for(Nk={focusedElem:h,selectionRange:w},_w=!1,ua=g;ua!==null;)if(g=ua,h=g.child,(g.subtreeFlags&1028)!==0&&h!==null)h.return=g,ua=h;else for(;ua!==null;){switch(g=ua,L=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(w=0;w<h.length;w++)P=h[w],P.ref.impl=P.nextImpl;break;case 11:case 15:break;case 1:if((h&1024)!==0&&L!==null){h=void 0,w=g,P=L.memoizedProps,L=L.memoizedState,N=w.stateNode;try{var Vt=rf(w.type,P);h=N.getSnapshotBeforeUpdate(Vt,L),N.__reactInternalSnapshotBeforeUpdate=h}catch(nn){pr(w,w.return,nn)}}break;case 3:if((h&1024)!==0){if(h=g.stateNode.containerInfo,w=h.nodeType,w===9)kk(h);else if(w===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":kk(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,ua=h;break}ua=g.return}}function g5(h,g,w){var N=w.flags;switch(w.tag){case 0:case 11:case 15:Bc(h,w),N&4&&ub(5,w);break;case 1:if(Bc(h,w),N&4)if(h=w.stateNode,g===null)try{h.componentDidMount()}catch(J){pr(w,w.return,J)}else{var P=rf(w.type,g.memoizedProps);g=g.memoizedState;try{h.componentDidUpdate(P,g,h.__reactInternalSnapshotBeforeUpdate)}catch(J){pr(w,w.return,J)}}N&64&&u5(w),N&512&&db(w,w.return);break;case 3:if(Bc(h,w),N&64&&(h=w.updateQueue,h!==null)){if(g=null,w.child!==null)switch(w.child.tag){case 27:case 5:g=w.child.stateNode;break;case 1:g=w.child.stateNode}try{eI(h,g)}catch(J){pr(w,w.return,J)}}break;case 27:g===null&&N&4&&m5(w);case 26:case 5:Bc(h,w),g===null&&N&4&&h5(w),N&512&&db(w,w.return);break;case 12:Bc(h,w);break;case 31:Bc(h,w),N&4&&y5(h,w);break;case 13:Bc(h,w),N&4&&v5(h,w),N&64&&(h=w.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(w=zie.bind(null,w),sae(h,w))));break;case 22:if(N=w.memoizedState!==null||Uc,!N){g=g!==null&&g.memoizedState!==null||Di,P=Uc;var L=Di;Uc=N,(Di=g)&&!L?$c(h,w,(w.subtreeFlags&8772)!==0):Bc(h,w),Uc=P,Di=L}break;case 30:break;default:Bc(h,w)}}function x5(h){var g=h.alternate;g!==null&&(h.alternate=null,x5(g)),h.child=null,h.deletions=null,h.sibling=null,h.tag===5&&(g=h.stateNode,g!==null&&ot(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,Ms=!1;function zc(h,g,w){for(w=w.child;w!==null;)b5(h,g,w),w=w.sibling}function b5(h,g,w){if(ye&&typeof ye.onCommitFiberUnmount=="function")try{ye.onCommitFiberUnmount(He,w)}catch{}switch(w.tag){case 26:Di||Wl(w,g),zc(h,g,w),w.memoizedState?w.memoizedState.count--:w.stateNode&&(w=w.stateNode,w.parentNode.removeChild(w));break;case 27:Di||Wl(w,g);var N=Qr,P=Ms;gd(w.type)&&(Qr=w.stateNode,Ms=!1),zc(h,g,w),vb(w.stateNode),Qr=N,Ms=P;break;case 5:Di||Wl(w,g);case 6:if(N=Qr,P=Ms,Qr=null,zc(h,g,w),Qr=N,Ms=P,Qr!==null)if(Ms)try{(Qr.nodeType===9?Qr.body:Qr.nodeName==="HTML"?Qr.ownerDocument.body:Qr).removeChild(w.stateNode)}catch(L){pr(w,g,L)}else try{Qr.removeChild(w.stateNode)}catch(L){pr(w,g,L)}break;case 18:Qr!==null&&(Ms?(h=Qr,uU(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,w.stateNode),fp(h)):uU(Qr,w.stateNode));break;case 4:N=Qr,P=Ms,Qr=w.stateNode.containerInfo,Ms=!0,zc(h,g,w),Qr=N,Ms=P;break;case 0:case 11:case 14:case 15:cd(2,w,g),Di||cd(4,w,g),zc(h,g,w);break;case 1:Di||(Wl(w,g),N=w.stateNode,typeof N.componentWillUnmount=="function"&&d5(w,g,N)),zc(h,g,w);break;case 21:zc(h,g,w);break;case 22:Di=(N=Di)||w.memoizedState!==null,zc(h,g,w),Di=N;break;default:zc(h,g,w)}}function y5(h,g){if(g.memoizedState===null&&(h=g.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{fp(h)}catch(w){pr(g,g.return,w)}}}function v5(h,g){if(g.memoizedState===null&&(h=g.alternate,h!==null&&(h=h.memoizedState,h!==null&&(h=h.dehydrated,h!==null))))try{fp(h)}catch(w){pr(g,g.return,w)}}function Pie(h){switch(h.tag){case 31:case 13:case 19:var g=h.stateNode;return g===null&&(g=h.stateNode=new p5),g;case 22:return h=h.stateNode,g=h._retryCache,g===null&&(g=h._retryCache=new p5),g;default:throw Error(r(435,h.tag))}}function nw(h,g){var w=Pie(h);g.forEach(function(N){if(!w.has(N)){w.add(N);var P=Bie.bind(null,h,N);N.then(P,P)}})}function Es(h,g){var w=g.deletions;if(w!==null)for(var N=0;N<w.length;N++){var P=w[N],L=h,J=g,ve=J;e:for(;ve!==null;){switch(ve.tag){case 27:if(gd(ve.type)){Qr=ve.stateNode,Ms=!1;break e}break;case 5:Qr=ve.stateNode,Ms=!1;break e;case 3:case 4:Qr=ve.stateNode.containerInfo,Ms=!0;break e}ve=ve.return}if(Qr===null)throw Error(r(160));b5(L,J,P),Qr=null,Ms=!1,L=P.alternate,L!==null&&(L.return=null),P.return=null}if(g.subtreeFlags&13886)for(g=g.child;g!==null;)w5(g,h),g=g.sibling}var bl=null;function w5(h,g){var w=h.alternate,N=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:Es(g,h),ks(h),N&4&&(cd(3,h,h.return),ub(3,h),cd(5,h,h.return));break;case 1:Es(g,h),ks(h),N&512&&(Di||w===null||Wl(w,w.return)),N&64&&Uc&&(h=h.updateQueue,h!==null&&(N=h.callbacks,N!==null&&(w=h.shared.hiddenCallbacks,h.shared.hiddenCallbacks=w===null?N:w.concat(N))));break;case 26:var P=bl;if(Es(g,h),ks(h),N&512&&(Di||w===null||Wl(w,w.return)),N&4){var L=w!==null?w.memoizedState:null;if(N=h.memoizedState,w===null)if(N===null)if(h.stateNode===null){e:{N=h.type,w=h.memoizedProps,P=P.ownerDocument||P;t:switch(N){case"title":L=P.getElementsByTagName("title")[0],(!L||L[lt]||L[Kn]||L.namespaceURI==="http://www.w3.org/2000/svg"||L.hasAttribute("itemprop"))&&(L=P.createElement(N),P.head.insertBefore(L,P.querySelector("head > title"))),ka(L,N,w),L[Kn]=h,Le(L),N=L;break e;case"link":var J=wU("link","href",P).get(N+(w.href||""));if(J){for(var ve=0;ve<J.length;ve++)if(L=J[ve],L.getAttribute("href")===(w.href==null||w.href===""?null:w.href)&&L.getAttribute("rel")===(w.rel==null?null:w.rel)&&L.getAttribute("title")===(w.title==null?null:w.title)&&L.getAttribute("crossorigin")===(w.crossOrigin==null?null:w.crossOrigin)){J.splice(ve,1);break t}}L=P.createElement(N),ka(L,N,w),P.head.appendChild(L);break;case"meta":if(J=wU("meta","content",P).get(N+(w.content||""))){for(ve=0;ve<J.length;ve++)if(L=J[ve],L.getAttribute("content")===(w.content==null?null:""+w.content)&&L.getAttribute("name")===(w.name==null?null:w.name)&&L.getAttribute("property")===(w.property==null?null:w.property)&&L.getAttribute("http-equiv")===(w.httpEquiv==null?null:w.httpEquiv)&&L.getAttribute("charset")===(w.charSet==null?null:w.charSet)){J.splice(ve,1);break t}}L=P.createElement(N),ka(L,N,w),P.head.appendChild(L);break;default:throw Error(r(468,N))}L[Kn]=h,Le(L),N=L}h.stateNode=N}else _U(P,h.type,h.stateNode);else h.stateNode=vU(P,N,h.memoizedProps);else L!==N?(L===null?w.stateNode!==null&&(w=w.stateNode,w.parentNode.removeChild(w)):L.count--,N===null?_U(P,h.type,h.stateNode):vU(P,N,h.memoizedProps)):N===null&&h.stateNode!==null&&JE(h,h.memoizedProps,w.memoizedProps)}break;case 27:Es(g,h),ks(h),N&512&&(Di||w===null||Wl(w,w.return)),w!==null&&N&4&&JE(h,h.memoizedProps,w.memoizedProps);break;case 5:if(Es(g,h),ks(h),N&512&&(Di||w===null||Wl(w,w.return)),h.flags&32){P=h.stateNode;try{yt(P,"")}catch(Vt){pr(h,h.return,Vt)}}N&4&&h.stateNode!=null&&(P=h.memoizedProps,JE(h,P,w!==null?w.memoizedProps:P)),N&1024&&(nk=!0);break;case 6:if(Es(g,h),ks(h),N&4){if(h.stateNode===null)throw Error(r(162));N=h.memoizedProps,w=h.stateNode;try{w.nodeValue=N}catch(Vt){pr(h,h.return,Vt)}}break;case 3:if(bw=null,P=bl,bl=gw(g.containerInfo),Es(g,h),bl=P,ks(h),N&4&&w!==null&&w.memoizedState.isDehydrated)try{fp(g.containerInfo)}catch(Vt){pr(h,h.return,Vt)}nk&&(nk=!1,_5(h));break;case 4:N=bl,bl=gw(h.stateNode.containerInfo),Es(g,h),ks(h),bl=N;break;case 12:Es(g,h),ks(h);break;case 31:Es(g,h),ks(h),N&4&&(N=h.updateQueue,N!==null&&(h.updateQueue=null,nw(h,N)));break;case 13:Es(g,h),ks(h),h.child.flags&8192&&h.memoizedState!==null!=(w!==null&&w.memoizedState!==null)&&(iw=O()),N&4&&(N=h.updateQueue,N!==null&&(h.updateQueue=null,nw(h,N)));break;case 22:P=h.memoizedState!==null;var Ue=w!==null&&w.memoizedState!==null,it=Uc,gt=Di;if(Uc=it||P,Di=gt||Ue,Es(g,h),Di=gt,Uc=it,ks(h),N&8192)e:for(g=h.stateNode,g._visibility=P?g._visibility&-2:g._visibility|1,P&&(w===null||Ue||Uc||Di||af(h)),w=null,g=h;;){if(g.tag===5||g.tag===26){if(w===null){Ue=w=g;try{if(L=Ue.stateNode,P)J=L.style,typeof J.setProperty=="function"?J.setProperty("display","none","important"):J.display="none";else{ve=Ue.stateNode;var vt=Ue.memoizedProps.style,ct=vt!=null&&vt.hasOwnProperty("display")?vt.display:null;ve.style.display=ct==null||typeof ct=="boolean"?"":(""+ct).trim()}}catch(Vt){pr(Ue,Ue.return,Vt)}}}else if(g.tag===6){if(w===null){Ue=g;try{Ue.stateNode.nodeValue=P?"":Ue.memoizedProps}catch(Vt){pr(Ue,Ue.return,Vt)}}}else if(g.tag===18){if(w===null){Ue=g;try{var pt=Ue.stateNode;P?dU(pt,!0):dU(Ue.stateNode,!1)}catch(Vt){pr(Ue,Ue.return,Vt)}}}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;w===g&&(w=null),g=g.return}w===g&&(w=null),g.sibling.return=g.return,g=g.sibling}N&4&&(N=h.updateQueue,N!==null&&(w=N.retryQueue,w!==null&&(N.retryQueue=null,nw(h,w))));break;case 19:Es(g,h),ks(h),N&4&&(N=h.updateQueue,N!==null&&(h.updateQueue=null,nw(h,N)));break;case 30:break;case 21:break;default:Es(g,h),ks(h)}}function ks(h){var g=h.flags;if(g&2){try{for(var w,N=h.return;N!==null;){if(f5(N)){w=N;break}N=N.return}if(w==null)throw Error(r(160));switch(w.tag){case 27:var P=w.stateNode,L=ek(h);tw(h,L,P);break;case 5:var J=w.stateNode;w.flags&32&&(yt(J,""),w.flags&=-33);var ve=ek(h);tw(h,ve,J);break;case 3:case 4:var Ue=w.stateNode.containerInfo,it=ek(h);tk(h,it,Ue);break;default:throw Error(r(161))}}catch(gt){pr(h,h.return,gt)}h.flags&=-3}g&4096&&(h.flags&=-4097)}function _5(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var g=h;_5(g),g.tag===5&&g.flags&1024&&g.stateNode.reset(),h=h.sibling}}function Bc(h,g){if(g.subtreeFlags&8772)for(g=g.child;g!==null;)g5(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:cd(4,g,g.return),af(g);break;case 1:Wl(g,g.return);var w=g.stateNode;typeof w.componentWillUnmount=="function"&&d5(g,g.return,w),af(g);break;case 27:vb(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 $c(h,g,w){for(w=w&&(g.subtreeFlags&8772)!==0,g=g.child;g!==null;){var N=g.alternate,P=h,L=g,J=L.flags;switch(L.tag){case 0:case 11:case 15:$c(P,L,w),ub(4,L);break;case 1:if($c(P,L,w),N=L,P=N.stateNode,typeof P.componentDidMount=="function")try{P.componentDidMount()}catch(it){pr(N,N.return,it)}if(N=L,P=N.updateQueue,P!==null){var ve=N.stateNode;try{var Ue=P.shared.hiddenCallbacks;if(Ue!==null)for(P.shared.hiddenCallbacks=null,P=0;P<Ue.length;P++)JF(Ue[P],ve)}catch(it){pr(N,N.return,it)}}w&&J&64&&u5(L),db(L,L.return);break;case 27:m5(L);case 26:case 5:$c(P,L,w),w&&N===null&&J&4&&h5(L),db(L,L.return);break;case 12:$c(P,L,w);break;case 31:$c(P,L,w),w&&J&4&&y5(P,L);break;case 13:$c(P,L,w),w&&J&4&&v5(P,L);break;case 22:L.memoizedState===null&&$c(P,L,w),db(L,L.return);break;case 30:break;default:$c(P,L,w)}g=g.sibling}}function rk(h,g){var w=null;h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(w=h.memoizedState.cachePool.pool),h=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(h=g.memoizedState.cachePool.pool),h!==w&&(h!=null&&h.refCount++,w!=null&&Qx(w))}function ik(h,g){h=null,g.alternate!==null&&(h=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==h&&(g.refCount++,h!=null&&Qx(h))}function yl(h,g,w,N){if(g.subtreeFlags&10256)for(g=g.child;g!==null;)S5(h,g,w,N),g=g.sibling}function S5(h,g,w,N){var P=g.flags;switch(g.tag){case 0:case 11:case 15:yl(h,g,w,N),P&2048&&ub(9,g);break;case 1:yl(h,g,w,N);break;case 3:yl(h,g,w,N),P&2048&&(h=null,g.alternate!==null&&(h=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==h&&(g.refCount++,h!=null&&Qx(h)));break;case 12:if(P&2048){yl(h,g,w,N),h=g.stateNode;try{var L=g.memoizedProps,J=L.id,ve=L.onPostCommit;typeof ve=="function"&&ve(J,g.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(Ue){pr(g,g.return,Ue)}}else yl(h,g,w,N);break;case 31:yl(h,g,w,N);break;case 13:yl(h,g,w,N);break;case 23:break;case 22:L=g.stateNode,J=g.alternate,g.memoizedState!==null?L._visibility&2?yl(h,g,w,N):hb(h,g):L._visibility&2?yl(h,g,w,N):(L._visibility|=2,np(h,g,w,N,(g.subtreeFlags&10256)!==0||!1)),P&2048&&rk(J,g);break;case 24:yl(h,g,w,N),P&2048&&ik(g.alternate,g);break;default:yl(h,g,w,N)}}function np(h,g,w,N,P){for(P=P&&((g.subtreeFlags&10256)!==0||!1),g=g.child;g!==null;){var L=h,J=g,ve=w,Ue=N,it=J.flags;switch(J.tag){case 0:case 11:case 15:np(L,J,ve,Ue,P),ub(8,J);break;case 23:break;case 22:var gt=J.stateNode;J.memoizedState!==null?gt._visibility&2?np(L,J,ve,Ue,P):hb(L,J):(gt._visibility|=2,np(L,J,ve,Ue,P)),P&&it&2048&&rk(J.alternate,J);break;case 24:np(L,J,ve,Ue,P),P&&it&2048&&ik(J.alternate,J);break;default:np(L,J,ve,Ue,P)}g=g.sibling}}function hb(h,g){if(g.subtreeFlags&10256)for(g=g.child;g!==null;){var w=h,N=g,P=N.flags;switch(N.tag){case 22:hb(w,N),P&2048&&rk(N.alternate,N);break;case 24:hb(w,N),P&2048&&ik(N.alternate,N);break;default:hb(w,N)}g=g.sibling}}var fb=8192;function rp(h,g,w){if(h.subtreeFlags&fb)for(h=h.child;h!==null;)N5(h,g,w),h=h.sibling}function N5(h,g,w){switch(h.tag){case 26:rp(h,g,w),h.flags&fb&&h.memoizedState!==null&&bae(w,bl,h.memoizedState,h.memoizedProps);break;case 5:rp(h,g,w);break;case 3:case 4:var N=bl;bl=gw(h.stateNode.containerInfo),rp(h,g,w),bl=N;break;case 22:h.memoizedState===null&&(N=h.alternate,N!==null&&N.memoizedState!==null?(N=fb,fb=16777216,rp(h,g,w),fb=N):rp(h,g,w));break;default:rp(h,g,w)}}function M5(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 mb(h){var g=h.deletions;if((h.flags&16)!==0){if(g!==null)for(var w=0;w<g.length;w++){var N=g[w];ua=N,k5(N,h)}M5(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)E5(h),h=h.sibling}function E5(h){switch(h.tag){case 0:case 11:case 15:mb(h),h.flags&2048&&cd(9,h,h.return);break;case 3:mb(h);break;case 12:mb(h);break;case 22:var g=h.stateNode;h.memoizedState!==null&&g._visibility&2&&(h.return===null||h.return.tag!==13)?(g._visibility&=-3,rw(h)):mb(h);break;default:mb(h)}}function rw(h){var g=h.deletions;if((h.flags&16)!==0){if(g!==null)for(var w=0;w<g.length;w++){var N=g[w];ua=N,k5(N,h)}M5(h)}for(h=h.child;h!==null;){switch(g=h,g.tag){case 0:case 11:case 15:cd(8,g,g.return),rw(g);break;case 22:w=g.stateNode,w._visibility&2&&(w._visibility&=-3,rw(g));break;default:rw(g)}h=h.sibling}}function k5(h,g){for(;ua!==null;){var w=ua;switch(w.tag){case 0:case 11:case 15:cd(8,w,g);break;case 23:case 22:if(w.memoizedState!==null&&w.memoizedState.cachePool!==null){var N=w.memoizedState.cachePool.pool;N!=null&&N.refCount++}break;case 24:Qx(w.memoizedState.cache)}if(N=w.child,N!==null)N.return=w,ua=N;else e:for(w=h;ua!==null;){N=ua;var P=N.sibling,L=N.return;if(x5(N),N===w){ua=null;break e}if(P!==null){P.return=L,ua=P;break e}ua=L}}}var Die={getCacheForType:function(h){var g=Ma(Ci),w=g.data.get(h);return w===void 0&&(w=h(),g.data.set(h,w)),w},cacheSignal:function(){return Ma(Ci).controller.signal}},Rie=typeof WeakMap=="function"?WeakMap:Map,cr=0,Pr=null,In=null,Gn=0,mr=0,Js=null,ud=!1,ip=!1,ak=!1,Hc=0,hi=0,dd=0,sf=0,sk=0,eo=0,ap=0,pb=null,Ts=null,ok=!1,iw=0,T5=0,aw=1/0,sw=null,hd=null,qi=0,fd=null,sp=null,Vc=0,lk=0,ck=null,A5=null,gb=0,uk=null;function to(){return(cr&2)!==0&&Gn!==0?Gn&-Gn:K.T!==null?gk():ln()}function C5(){if(eo===0)if((Gn&536870912)===0||Xn){var h=Ee;Ee<<=1,(Ee&3932160)===0&&(Ee=262144),eo=h}else eo=536870912;return h=Qs.current,h!==null&&(h.flags|=32),eo}function As(h,g,w){(h===Pr&&(mr===2||mr===9)||h.cancelPendingCommit!==null)&&(op(h,0),md(h,Gn,eo,!1)),Bt(h,w),((cr&2)===0||h!==Pr)&&(h===Pr&&((cr&2)===0&&(sf|=w),hi===4&&md(h,Gn,eo,!1)),Kl(h))}function j5(h,g,w){if((cr&6)!==0)throw Error(r(327));var N=!w&&(g&127)===0&&(g&h.expiredLanes)===0||De(h,g),P=N?Fie(h,g):hk(h,g,!0),L=N;do{if(P===0){ip&&!N&&md(h,g,0,!1);break}else{if(w=h.current.alternate,L&&!Oie(w)){P=hk(h,g,!1),L=!1;continue}if(P===2){if(L=g,h.errorRecoveryDisabledLanes&L)var J=0;else J=h.pendingLanes&-536870913,J=J!==0?J:J&536870912?536870912:0;if(J!==0){g=J;e:{var ve=h;P=pb;var Ue=ve.current.memoizedState.isDehydrated;if(Ue&&(op(ve,J).flags|=256),J=hk(ve,J,!1),J!==2){if(ak&&!Ue){ve.errorRecoveryDisabledLanes|=L,sf|=L,P=4;break e}L=Ts,Ts=P,L!==null&&(Ts===null?Ts=L:Ts.push.apply(Ts,L))}P=J}if(L=!1,P!==2)continue}}if(P===1){op(h,0),md(h,g,0,!0);break}e:{switch(N=h,L=P,L){case 0:case 1:throw Error(r(345));case 4:if((g&4194048)!==g)break;case 6:md(N,g,eo,!ud);break e;case 2:Ts=null;break;case 3:case 5:break;default:throw Error(r(329))}if((g&62914560)===g&&(P=iw+300-O(),10<P)){if(md(N,g,eo,!ud),W(N,0,!0)!==0)break e;Vc=g,N.timeoutHandle=lU(P5.bind(null,N,w,Ts,sw,ok,g,eo,sf,ap,ud,L,"Throttled",-0,0),P);break e}P5(N,w,Ts,sw,ok,g,eo,sf,ap,ud,L,null,-0,0)}}break}while(!0);Kl(h)}function P5(h,g,w,N,P,L,J,ve,Ue,it,gt,vt,ct,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:_i},N5(g,L,vt);var Vt=(L&62914560)===L?iw-O():(L&4194048)===L?T5-O():0;if(Vt=yae(vt,Vt),Vt!==null){Vc=L,h.cancelPendingCommit=Vt(z5.bind(null,h,g,L,w,N,P,J,ve,Ue,gt,vt,null,ct,pt)),md(h,L,J,!it);return}}z5(h,g,L,w,N,P,J,ve,Ue)}function Oie(h){for(var g=h;;){var w=g.tag;if((w===0||w===11||w===15)&&g.flags&16384&&(w=g.updateQueue,w!==null&&(w=w.stores,w!==null)))for(var N=0;N<w.length;N++){var P=w[N],L=P.getSnapshot;P=P.value;try{if(!Xs(L(),P))return!1}catch{return!1}}if(w=g.child,g.subtreeFlags&16384&&w!==null)w.return=g,g=w;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 md(h,g,w,N){g&=~sk,g&=~sf,h.suspendedLanes|=g,h.pingedLanes&=~g,N&&(h.warmLanes|=g),N=h.expirationTimes;for(var P=g;0<P;){var L=31-Be(P),J=1<<L;N[L]=-1,P&=~J}w!==0&&vn(h,w,g)}function ow(){return(cr&6)===0?(xb(0),!1):!0}function dk(){if(In!==null){if(mr===0)var h=In.return;else h=In,Dc=Yh=null,kE(h),Qm=null,Jx=0,h=In;for(;h!==null;)c5(h.alternate,h),h=h.return;In=null}}function op(h,g){var w=h.timeoutHandle;w!==-1&&(h.timeoutHandle=-1,tae(w)),w=h.cancelPendingCommit,w!==null&&(h.cancelPendingCommit=null,w()),Vc=0,dk(),Pr=h,In=w=jc(h.current,null),Gn=g,mr=0,Js=null,ud=!1,ip=De(h,g),ak=!1,ap=eo=sk=sf=dd=hi=0,Ts=pb=null,ok=!1,(g&8)!==0&&(g|=g&32);var N=h.entangledLanes;if(N!==0)for(h=h.entanglements,N&=g;0<N;){var P=31-Be(N),L=1<<P;g|=h[P],N&=~L}return Hc=g,Tv(),w}function D5(h,g){_n=null,K.H=ob,g===Ym||g===Lv?(g=XF(),mr=3):g===pE?(g=XF(),mr=4):mr=g===HE?8:g!==null&&typeof g=="object"&&typeof g.then=="function"?6:1,Js=g,In===null&&(hi=1,Yv(h,ko(g,h.current)))}function R5(){var h=Qs.current;return h===null?!0:(Gn&4194048)===Gn?jo===null:(Gn&62914560)===Gn||(Gn&536870912)!==0?h===jo:!1}function O5(){var h=K.H;return K.H=ob,h===null?ob:h}function L5(){var h=K.A;return K.A=Die,h}function lw(){hi=4,ud||(Gn&4194048)!==Gn&&Qs.current!==null||(ip=!0),(dd&134217727)===0&&(sf&134217727)===0||Pr===null||md(Pr,Gn,eo,!1)}function hk(h,g,w){var N=cr;cr|=2;var P=O5(),L=L5();(Pr!==h||Gn!==g)&&(sw=null,op(h,g)),g=!1;var J=hi;e:do try{if(mr!==0&&In!==null){var ve=In,Ue=Js;switch(mr){case 8:dk(),J=6;break e;case 3:case 2:case 9:case 6:Qs.current===null&&(g=!0);var it=mr;if(mr=0,Js=null,lp(h,ve,Ue,it),w&&ip){J=0;break e}break;default:it=mr,mr=0,Js=null,lp(h,ve,Ue,it)}}Lie(),J=hi;break}catch(gt){D5(h,gt)}while(!0);return g&&h.shellSuspendCounter++,Dc=Yh=null,cr=N,K.H=P,K.A=L,In===null&&(Pr=null,Gn=0,Tv()),J}function Lie(){for(;In!==null;)F5(In)}function Fie(h,g){var w=cr;cr|=2;var N=O5(),P=L5();Pr!==h||Gn!==g?(sw=null,aw=O()+500,op(h,g)):ip=De(h,g);e:do try{if(mr!==0&&In!==null){g=In;var L=Js;t:switch(mr){case 1:mr=0,Js=null,lp(h,g,L,1);break;case 2:case 9:if(WF(L)){mr=0,Js=null,I5(g);break}g=function(){mr!==2&&mr!==9||Pr!==h||(mr=7),Kl(h)},L.then(g,g);break e;case 3:mr=7;break e;case 4:mr=5;break e;case 7:WF(L)?(mr=0,Js=null,I5(g)):(mr=0,Js=null,lp(h,g,L,7));break;case 5:var J=null;switch(In.tag){case 26:J=In.memoizedState;case 5:case 27:var ve=In;if(J?SU(J):ve.stateNode.complete){mr=0,Js=null;var Ue=ve.sibling;if(Ue!==null)In=Ue;else{var it=ve.return;it!==null?(In=it,cw(it)):In=null}break t}}mr=0,Js=null,lp(h,g,L,5);break;case 6:mr=0,Js=null,lp(h,g,L,6);break;case 8:dk(),hi=6;break e;default:throw Error(r(462))}}Iie();break}catch(gt){D5(h,gt)}while(!0);return Dc=Yh=null,K.H=N,K.A=P,cr=w,In!==null?0:(Pr=null,Gn=0,Tv(),hi)}function Iie(){for(;In!==null&&!ke();)F5(In)}function F5(h){var g=o5(h.alternate,h,Hc);h.memoizedProps=h.pendingProps,g===null?cw(h):In=g}function I5(h){var g=h,w=g.alternate;switch(g.tag){case 15:case 0:g=t5(w,g,g.pendingProps,g.type,void 0,Gn);break;case 11:g=t5(w,g,g.pendingProps,g.type.render,g.ref,Gn);break;case 5:kE(g);default:c5(w,g),g=In=LF(g,Hc),g=o5(w,g,Hc)}h.memoizedProps=h.pendingProps,g===null?cw(h):In=g}function lp(h,g,w,N){Dc=Yh=null,kE(g),Qm=null,Jx=0;var P=g.return;try{if(Eie(h,P,g,w,Gn)){hi=1,Yv(h,ko(w,h.current)),In=null;return}}catch(L){if(P!==null)throw In=P,L;hi=1,Yv(h,ko(w,h.current)),In=null;return}g.flags&32768?(Xn||N===1?h=!0:ip||(Gn&536870912)!==0?h=!1:(ud=h=!0,(N===2||N===9||N===3||N===6)&&(N=Qs.current,N!==null&&N.tag===13&&(N.flags|=16384))),U5(g,h)):cw(g)}function cw(h){var g=h;do{if((g.flags&32768)!==0){U5(g,ud);return}h=g.return;var w=Aie(g.alternate,g,Hc);if(w!==null){In=w;return}if(g=g.sibling,g!==null){In=g;return}In=g=h}while(g!==null);hi===0&&(hi=5)}function U5(h,g){do{var w=Cie(h.alternate,h);if(w!==null){w.flags&=32767,In=w;return}if(w=h.return,w!==null&&(w.flags|=32768,w.subtreeFlags=0,w.deletions=null),!g&&(h=h.sibling,h!==null)){In=h;return}In=h=w}while(h!==null);hi=6,In=null}function z5(h,g,w,N,P,L,J,ve,Ue){h.cancelPendingCommit=null;do uw();while(qi!==0);if((cr&6)!==0)throw Error(r(327));if(g!==null){if(g===h.current)throw Error(r(177));if(L=g.lanes|g.childLanes,L|=eE,Lt(h,w,L,J,ve,Ue),h===Pr&&(In=Pr=null,Gn=0),sp=g,fd=h,Vc=w,lk=L,ck=P,A5=N,(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,$ie(we,function(){return G5(),null})):(h.callbackNode=null,h.callbackPriority=0),N=(g.flags&13878)!==0,(g.subtreeFlags&13878)!==0||N){N=K.T,K.T=null,P=V.p,V.p=2,J=cr,cr|=4;try{jie(h,g,w)}finally{cr=J,V.p=P,K.T=N}}qi=1,B5(),$5(),H5()}}function B5(){if(qi===1){qi=0;var h=fd,g=sp,w=(g.flags&13878)!==0;if((g.subtreeFlags&13878)!==0||w){w=K.T,K.T=null;var N=V.p;V.p=2;var P=cr;cr|=4;try{w5(g,h);var L=Nk,J=kF(h.containerInfo),ve=L.focusedElem,Ue=L.selectionRange;if(J!==ve&&ve&&ve.ownerDocument&&EF(ve.ownerDocument.documentElement,ve)){if(Ue!==null&&XM(ve)){var it=Ue.start,gt=Ue.end;if(gt===void 0&&(gt=it),"selectionStart"in ve)ve.selectionStart=it,ve.selectionEnd=Math.min(gt,ve.value.length);else{var vt=ve.ownerDocument||document,ct=vt&&vt.defaultView||window;if(ct.getSelection){var pt=ct.getSelection(),Vt=ve.textContent.length,nn=Math.min(Ue.start,Vt),_r=Ue.end===void 0?nn:Math.min(Ue.end,Vt);!pt.extend&&nn>_r&&(J=_r,_r=nn,nn=J);var Je=MF(ve,nn),Ge=MF(ve,_r);if(Je&&Ge&&(pt.rangeCount!==1||pt.anchorNode!==Je.node||pt.anchorOffset!==Je.offset||pt.focusNode!==Ge.node||pt.focusOffset!==Ge.offset)){var rt=vt.createRange();rt.setStart(Je.node,Je.offset),pt.removeAllRanges(),nn>_r?(pt.addRange(rt),pt.extend(Ge.node,Ge.offset)):(rt.setEnd(Ge.node,Ge.offset),pt.addRange(rt))}}}}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}}_w=!!Sk,Nk=Sk=null}finally{cr=P,V.p=N,K.T=w}}h.current=g,qi=2}}function $5(){if(qi===2){qi=0;var h=fd,g=sp,w=(g.flags&8772)!==0;if((g.subtreeFlags&8772)!==0||w){w=K.T,K.T=null;var N=V.p;V.p=2;var P=cr;cr|=4;try{g5(h,g.alternate,g)}finally{cr=P,V.p=N,K.T=w}}qi=3}}function H5(){if(qi===4||qi===3){qi=0,z();var h=fd,g=sp,w=Vc,N=A5;(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?qi=5:(qi=0,sp=fd=null,V5(h,h.pendingLanes));var P=h.pendingLanes;if(P===0&&(hd=null),Dn(w),g=g.stateNode,ye&&typeof ye.onCommitFiberRoot=="function")try{ye.onCommitFiberRoot(He,g,void 0,(g.current.flags&128)===128)}catch{}if(N!==null){g=K.T,P=V.p,V.p=2,K.T=null;try{for(var L=h.onRecoverableError,J=0;J<N.length;J++){var ve=N[J];L(ve.value,{componentStack:ve.stack})}}finally{K.T=g,V.p=P}}(Vc&3)!==0&&uw(),Kl(h),P=h.pendingLanes,(w&261930)!==0&&(P&42)!==0?h===uk?gb++:(gb=0,uk=h):gb=0,xb(0)}}function V5(h,g){(h.pooledCacheLanes&=g)===0&&(g=h.pooledCache,g!=null&&(h.pooledCache=null,Qx(g)))}function uw(){return B5(),$5(),H5(),G5()}function G5(){if(qi!==5)return!1;var h=fd,g=lk;lk=0;var w=Dn(Vc),N=K.T,P=V.p;try{V.p=32>w?32:w,K.T=null,w=ck,ck=null;var L=fd,J=Vc;if(qi=0,sp=fd=null,Vc=0,(cr&6)!==0)throw Error(r(331));var ve=cr;if(cr|=4,E5(L.current),S5(L,L.current,J,w),cr=ve,xb(0,!1),ye&&typeof ye.onPostCommitFiberRoot=="function")try{ye.onPostCommitFiberRoot(He,L)}catch{}return!0}finally{V.p=P,K.T=N,V5(h,g)}}function q5(h,g,w){g=ko(w,g),g=$E(h.stateNode,g,2),h=sd(h,g,2),h!==null&&(Bt(h,2),Kl(h))}function pr(h,g,w){if(h.tag===3)q5(h,h,w);else for(;g!==null;){if(g.tag===3){q5(g,h,w);break}else if(g.tag===1){var N=g.stateNode;if(typeof g.type.getDerivedStateFromError=="function"||typeof N.componentDidCatch=="function"&&(hd===null||!hd.has(N))){h=ko(w,h),w=WI(2),N=sd(g,w,2),N!==null&&(KI(w,N,g,h),Bt(N,2),Kl(N));break}}g=g.return}}function fk(h,g,w){var N=h.pingCache;if(N===null){N=h.pingCache=new Rie;var P=new Set;N.set(g,P)}else P=N.get(g),P===void 0&&(P=new Set,N.set(g,P));P.has(w)||(ak=!0,P.add(w),h=Uie.bind(null,h,g,w),g.then(h,h))}function Uie(h,g,w){var N=h.pingCache;N!==null&&N.delete(g),h.pingedLanes|=h.suspendedLanes&w,h.warmLanes&=~w,Pr===h&&(Gn&w)===w&&(hi===4||hi===3&&(Gn&62914560)===Gn&&300>O()-iw?(cr&2)===0&&op(h,0):sk|=w,ap===Gn&&(ap=0)),Kl(h)}function W5(h,g){g===0&&(g=xt()),h=Wh(h,g),h!==null&&(Bt(h,g),Kl(h))}function zie(h){var g=h.memoizedState,w=0;g!==null&&(w=g.retryLane),W5(h,w)}function Bie(h,g){var w=0;switch(h.tag){case 31:case 13:var N=h.stateNode,P=h.memoizedState;P!==null&&(w=P.retryLane);break;case 19:N=h.stateNode;break;case 22:N=h.stateNode._retryCache;break;default:throw Error(r(314))}N!==null&&N.delete(g),W5(h,w)}function $ie(h,g){return fe(h,g)}var dw=null,cp=null,mk=!1,hw=!1,pk=!1,pd=0;function Kl(h){h!==cp&&h.next===null&&(cp===null?dw=cp=h:cp=cp.next=h),hw=!0,mk||(mk=!0,Vie())}function xb(h,g){if(!pk&&hw){pk=!0;do for(var w=!1,N=dw;N!==null;){if(h!==0){var P=N.pendingLanes;if(P===0)var L=0;else{var J=N.suspendedLanes,ve=N.pingedLanes;L=(1<<31-Be(42|h)+1)-1,L&=P&~(J&~ve),L=L&201326741?L&201326741|1:L?L|2:0}L!==0&&(w=!0,Q5(N,L))}else L=Gn,L=W(N,N===Pr?L:0,N.cancelPendingCommit!==null||N.timeoutHandle!==-1),(L&3)===0||De(N,L)||(w=!0,Q5(N,L));N=N.next}while(w);pk=!1}}function Hie(){K5()}function K5(){hw=mk=!1;var h=0;pd!==0&&eae()&&(h=pd);for(var g=O(),w=null,N=dw;N!==null;){var P=N.next,L=X5(N,g);L===0?(N.next=null,w===null?dw=P:w.next=P,P===null&&(cp=w)):(w=N,(h!==0||(L&3)!==0)&&(hw=!0)),N=P}qi!==0&&qi!==5||xb(h),pd!==0&&(pd=0)}function X5(h,g){for(var w=h.suspendedLanes,N=h.pingedLanes,P=h.expirationTimes,L=h.pendingLanes&-62914561;0<L;){var J=31-Be(L),ve=1<<J,Ue=P[J];Ue===-1?((ve&w)===0||(ve&N)!==0)&&(P[J]=Ye(ve,g)):Ue<=g&&(h.expiredLanes|=ve),L&=~ve}if(g=Pr,w=Gn,w=W(h,h===g?w:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),N=h.callbackNode,w===0||h===g&&(mr===2||mr===9)||h.cancelPendingCommit!==null)return N!==null&&N!==null&&me(N),h.callbackNode=null,h.callbackPriority=0;if((w&3)===0||De(h,w)){if(g=w&-w,g===h.callbackPriority)return g;switch(N!==null&&me(N),Dn(w)){case 2:case 8:w=_e;break;case 32:w=we;break;case 268435456:w=Fe;break;default:w=we}return N=Y5.bind(null,h),w=fe(w,N),h.callbackPriority=g,h.callbackNode=w,g}return N!==null&&N!==null&&me(N),h.callbackPriority=2,h.callbackNode=null,2}function Y5(h,g){if(qi!==0&&qi!==5)return h.callbackNode=null,h.callbackPriority=0,null;var w=h.callbackNode;if(uw()&&h.callbackNode!==w)return null;var N=Gn;return N=W(h,h===Pr?N:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),N===0?null:(j5(h,N,g),X5(h,O()),h.callbackNode!=null&&h.callbackNode===w?Y5.bind(null,h):null)}function Q5(h,g){if(uw())return null;j5(h,g,!0)}function Vie(){nae(function(){(cr&6)!==0?fe(le,Hie):K5()})}function gk(){if(pd===0){var h=Km;h===0&&(h=tt,tt<<=1,(tt&261888)===0&&(tt=256)),pd=h}return pd}function Z5(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:on(""+h)}function J5(h,g){var w=g.ownerDocument.createElement("input");return w.name=g.name,w.value=g.value,h.id&&w.setAttribute("form",h.id),g.parentNode.insertBefore(w,g),h=new FormData(h),w.parentNode.removeChild(w),h}function Gie(h,g,w,N,P){if(g==="submit"&&w&&w.stateNode===P){var L=Z5((P[bn]||null).action),J=N.submitter;J&&(g=(g=J[bn]||null)?Z5(g.formAction):J.getAttribute("formAction"),g!==null&&(L=g,J=null));var ve=new Vl("action","action",null,N,P);h.push({event:ve,listeners:[{instance:null,listener:function(){if(N.defaultPrevented){if(pd!==0){var Ue=J?J5(P,J):new FormData(P);LE(w,{pending:!0,data:Ue,method:P.method,action:L},null,Ue)}}else typeof L=="function"&&(ve.preventDefault(),Ue=J?J5(P,J):new FormData(P),LE(w,{pending:!0,data:Ue,method:P.method,action:L},L,Ue))},currentTarget:P}]})}}for(var xk=0;xk<JM.length;xk++){var bk=JM[xk],qie=bk.toLowerCase(),Wie=bk[0].toUpperCase()+bk.slice(1);xl(qie,"on"+Wie)}xl(CF,"onAnimationEnd"),xl(jF,"onAnimationIteration"),xl(PF,"onAnimationStart"),xl("dblclick","onDoubleClick"),xl("focusin","onFocus"),xl("focusout","onBlur"),xl(cie,"onTransitionRun"),xl(uie,"onTransitionStart"),xl(die,"onTransitionCancel"),xl(DF,"onTransitionEnd"),At("onMouseEnter",["mouseout","mouseover"]),At("onMouseLeave",["mouseout","mouseover"]),At("onPointerEnter",["pointerout","pointerover"]),At("onPointerLeave",["pointerout","pointerover"]),St("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),St("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),St("onBeforeInput",["compositionend","keypress","textInput","paste"]),St("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),St("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),St("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var bb="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(" "),Kie=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(bb));function eU(h,g){g=(g&4)!==0;for(var w=0;w<h.length;w++){var N=h[w],P=N.event;N=N.listeners;e:{var L=void 0;if(g)for(var J=N.length-1;0<=J;J--){var ve=N[J],Ue=ve.instance,it=ve.currentTarget;if(ve=ve.listener,Ue!==L&&P.isPropagationStopped())break e;L=ve,P.currentTarget=it;try{L(P)}catch(gt){kv(gt)}P.currentTarget=null,L=Ue}else for(J=0;J<N.length;J++){if(ve=N[J],Ue=ve.instance,it=ve.currentTarget,ve=ve.listener,Ue!==L&&P.isPropagationStopped())break e;L=ve,P.currentTarget=it;try{L(P)}catch(gt){kv(gt)}P.currentTarget=null,L=Ue}}}}function Un(h,g){var w=g[Ba];w===void 0&&(w=g[Ba]=new Set);var N=h+"__bubble";w.has(N)||(tU(g,h,2,!1),w.add(N))}function yk(h,g,w){var N=0;g&&(N|=4),tU(w,h,N,g)}var fw="_reactListening"+Math.random().toString(36).slice(2);function vk(h){if(!h[fw]){h[fw]=!0,Ce.forEach(function(w){w!=="selectionchange"&&(Kie.has(w)||yk(w,!1,h),yk(w,!0,h))});var g=h.nodeType===9?h:h.ownerDocument;g===null||g[fw]||(g[fw]=!0,yk("selectionchange",!1,g))}}function tU(h,g,w,N){switch(CU(g)){case 2:var P=_ae;break;case 8:P=Sae;break;default:P=Ok}w=P.bind(null,g,w,h),P=void 0,!Ux||g!=="touchstart"&&g!=="touchmove"&&g!=="wheel"||(P=!0),N?P!==void 0?h.addEventListener(g,w,{capture:!0,passive:P}):h.addEventListener(g,w,!0):P!==void 0?h.addEventListener(g,w,{passive:P}):h.addEventListener(g,w,!1)}function wk(h,g,w,N,P){var L=N;if((g&1)===0&&(g&2)===0&&N!==null)e:for(;;){if(N===null)return;var J=N.tag;if(J===3||J===4){var ve=N.stateNode.containerInfo;if(ve===P)break;if(J===4)for(J=N.return;J!==null;){var Ue=J.tag;if((Ue===3||Ue===4)&&J.stateNode.containerInfo===P)return;J=J.return}for(;ve!==null;){if(J=kt(ve),J===null)return;if(Ue=J.tag,Ue===5||Ue===6||Ue===26||Ue===27){N=L=J;continue e}ve=ve.parentNode}}N=N.return}Ks(function(){var it=L,gt=_o(w),vt=[];e:{var ct=RF.get(h);if(ct!==void 0){var pt=Vl,Vt=h;switch(h){case"keypress":if(Vh(w)===0)break e;case"keydown":case"keyup":pt=Bre;break;case"focusin":Vt="focus",pt=Im;break;case"focusout":Vt="blur",pt=Im;break;case"beforeblur":case"afterblur":pt=Im;break;case"click":if(w.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":pt=Sv;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":pt=Nv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":pt=Vre;break;case CF:case jF:case PF:pt=Mv;break;case DF:pt=qre;break;case"scroll":case"scrollend":pt=Om;break;case"wheel":pt=Kre;break;case"copy":case"cut":case"paste":pt=wt;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":pt=dF;break;case"toggle":case"beforetoggle":pt=Yre}var nn=(g&4)!==0,_r=!nn&&(h==="scroll"||h==="scrollend"),Je=nn?ct!==null?ct+"Capture":null:ct;nn=[];for(var Ge=it,rt;Ge!==null;){var bt=Ge;if(rt=bt.stateNode,bt=bt.tag,bt!==5&&bt!==26&&bt!==27||rt===null||Je===null||(bt=la(Ge,Je),bt!=null&&nn.push(yb(Ge,bt,rt))),_r)break;Ge=Ge.return}0<nn.length&&(ct=new pt(ct,Vt,null,w,gt),vt.push({event:ct,listeners:nn}))}}if((g&7)===0){e:{if(ct=h==="mouseover"||h==="pointerover",pt=h==="mouseout"||h==="pointerout",ct&&w!==Ss&&(Vt=w.relatedTarget||w.fromElement)&&(kt(Vt)||Vt[wi]))break e;if((pt||ct)&&(ct=gt.window===gt?gt:(ct=gt.ownerDocument)?ct.defaultView||ct.parentWindow:window,pt?(Vt=w.relatedTarget||w.toElement,pt=it,Vt=Vt?kt(Vt):null,Vt!==null&&(_r=a(Vt),nn=Vt.tag,Vt!==_r||nn!==5&&nn!==27&&nn!==6)&&(Vt=null)):(pt=null,Vt=it),pt!==Vt)){if(nn=Sv,bt="onMouseLeave",Je="onMouseEnter",Ge="mouse",(h==="pointerout"||h==="pointerover")&&(nn=dF,bt="onPointerLeave",Je="onPointerEnter",Ge="pointer"),_r=pt==null?ct:pe(pt),rt=Vt==null?ct:pe(Vt),ct=new nn(bt,Ge+"leave",pt,w,gt),ct.target=_r,ct.relatedTarget=rt,bt=null,kt(gt)===it&&(nn=new nn(Je,Ge+"enter",Vt,w,gt),nn.target=rt,nn.relatedTarget=_r,bt=nn),_r=bt,pt&&Vt)t:{for(nn=Xie,Je=pt,Ge=Vt,rt=0,bt=Je;bt;bt=nn(bt))rt++;bt=0;for(var Kt=Ge;Kt;Kt=nn(Kt))bt++;for(;0<rt-bt;)Je=nn(Je),rt--;for(;0<bt-rt;)Ge=nn(Ge),bt--;for(;rt--;){if(Je===Ge||Ge!==null&&Je===Ge.alternate){nn=Je;break t}Je=nn(Je),Ge=nn(Ge)}nn=null}else nn=null;pt!==null&&nU(vt,ct,pt,nn,!1),Vt!==null&&_r!==null&&nU(vt,_r,Vt,nn,!0)}}e:{if(ct=it?pe(it):window,pt=ct.nodeName&&ct.nodeName.toLowerCase(),pt==="select"||pt==="input"&&ct.type==="file")var ir=yF;else if(xF(ct))if(vF)ir=sie;else{ir=iie;var Wt=rie}else pt=ct.nodeName,!pt||pt.toLowerCase()!=="input"||ct.type!=="checkbox"&&ct.type!=="radio"?it&&Br(it.elementType)&&(ir=yF):ir=aie;if(ir&&(ir=ir(h,it))){bF(vt,ir,w,gt);break e}Wt&&Wt(h,ct,it),h==="focusout"&&it&&ct.type==="number"&&it.memoizedProps.value!=null&&lr(ct,"number",ct.value)}switch(Wt=it?pe(it):window,h){case"focusin":(xF(Wt)||Wt.contentEditable==="true")&&(zm=Wt,YM=it,Kx=null);break;case"focusout":Kx=YM=zm=null;break;case"mousedown":QM=!0;break;case"contextmenu":case"mouseup":case"dragend":QM=!1,TF(vt,w,gt);break;case"selectionchange":if(lie)break;case"keydown":case"keyup":TF(vt,w,gt)}var Nn;if(qM)e:{switch(h){case"compositionstart":var qn="onCompositionStart";break e;case"compositionend":qn="onCompositionEnd";break e;case"compositionupdate":qn="onCompositionUpdate";break e}qn=void 0}else Um?pF(h,w)&&(qn="onCompositionEnd"):h==="keydown"&&w.keyCode===229&&(qn="onCompositionStart");qn&&(hF&&w.locale!=="ko"&&(Um||qn!=="onCompositionStart"?qn==="onCompositionEnd"&&Um&&(Nn=Rm()):(Hl=gt,zx="value"in Hl?Hl.value:Hl.textContent,Um=!0)),Wt=mw(it,qn),0<Wt.length&&(qn=new Zn(qn,h,null,w,gt),vt.push({event:qn,listeners:Wt}),Nn?qn.data=Nn:(Nn=gF(w),Nn!==null&&(qn.data=Nn)))),(Nn=Zre?Jre(h,w):eie(h,w))&&(qn=mw(it,"onBeforeInput"),0<qn.length&&(Wt=new Zn("onBeforeInput","beforeinput",null,w,gt),vt.push({event:Wt,listeners:qn}),Wt.data=Nn)),Gie(vt,h,it,w,gt)}eU(vt,g)})}function yb(h,g,w){return{instance:h,listener:g,currentTarget:w}}function mw(h,g){for(var w=g+"Capture",N=[];h!==null;){var P=h,L=P.stateNode;if(P=P.tag,P!==5&&P!==26&&P!==27||L===null||(P=la(h,w),P!=null&&N.unshift(yb(h,P,L)),P=la(h,g),P!=null&&N.push(yb(h,P,L))),h.tag===3)return N;h=h.return}return[]}function Xie(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function nU(h,g,w,N,P){for(var L=g._reactName,J=[];w!==null&&w!==N;){var ve=w,Ue=ve.alternate,it=ve.stateNode;if(ve=ve.tag,Ue!==null&&Ue===N)break;ve!==5&&ve!==26&&ve!==27||it===null||(Ue=it,P?(it=la(w,L),it!=null&&J.unshift(yb(w,it,Ue))):P||(it=la(w,L),it!=null&&J.push(yb(w,it,Ue)))),w=w.return}J.length!==0&&h.push({event:g,listeners:J})}var Yie=/\r\n?/g,Qie=/\u0000|\uFFFD/g;function rU(h){return(typeof h=="string"?h:""+h).replace(Yie,`
  9. `).replace(Qie,"")}function iU(h,g){return g=rU(g),rU(h)===g}function wr(h,g,w,N,P,L){switch(w){case"children":typeof N=="string"?g==="body"||g==="textarea"&&N===""||yt(h,N):(typeof N=="number"||typeof N=="bigint")&&g!=="body"&&yt(h,""+N);break;case"className":$t(h,"class",N);break;case"tabIndex":$t(h,"tabindex",N);break;case"dir":case"role":case"viewBox":case"width":case"height":$t(h,w,N);break;case"style":Yr(h,N,L);break;case"data":if(g!=="object"){$t(h,"data",N);break}case"src":case"href":if(N===""&&(g!=="a"||w!=="href")){h.removeAttribute(w);break}if(N==null||typeof N=="function"||typeof N=="symbol"||typeof N=="boolean"){h.removeAttribute(w);break}N=on(""+N),h.setAttribute(w,N);break;case"action":case"formAction":if(typeof N=="function"){h.setAttribute(w,"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 L=="function"&&(w==="formAction"?(g!=="input"&&wr(h,g,"name",P.name,P,null),wr(h,g,"formEncType",P.formEncType,P,null),wr(h,g,"formMethod",P.formMethod,P,null),wr(h,g,"formTarget",P.formTarget,P,null)):(wr(h,g,"encType",P.encType,P,null),wr(h,g,"method",P.method,P,null),wr(h,g,"target",P.target,P,null)));if(N==null||typeof N=="symbol"||typeof N=="boolean"){h.removeAttribute(w);break}N=on(""+N),h.setAttribute(w,N);break;case"onClick":N!=null&&(h.onclick=_i);break;case"onScroll":N!=null&&Un("scroll",h);break;case"onScrollEnd":N!=null&&Un("scrollend",h);break;case"dangerouslySetInnerHTML":if(N!=null){if(typeof N!="object"||!("__html"in N))throw Error(r(61));if(w=N.__html,w!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=w}}break;case"multiple":h.multiple=N&&typeof N!="function"&&typeof N!="symbol";break;case"muted":h.muted=N&&typeof N!="function"&&typeof N!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(N==null||typeof N=="function"||typeof N=="boolean"||typeof N=="symbol"){h.removeAttribute("xlink:href");break}w=on(""+N),h.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",w);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":N!=null&&typeof N!="function"&&typeof N!="symbol"?h.setAttribute(w,""+N):h.removeAttribute(w);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":N&&typeof N!="function"&&typeof N!="symbol"?h.setAttribute(w,""):h.removeAttribute(w);break;case"capture":case"download":N===!0?h.setAttribute(w,""):N!==!1&&N!=null&&typeof N!="function"&&typeof N!="symbol"?h.setAttribute(w,N):h.removeAttribute(w);break;case"cols":case"rows":case"size":case"span":N!=null&&typeof N!="function"&&typeof N!="symbol"&&!isNaN(N)&&1<=N?h.setAttribute(w,N):h.removeAttribute(w);break;case"rowSpan":case"start":N==null||typeof N=="function"||typeof N=="symbol"||isNaN(N)?h.removeAttribute(w):h.setAttribute(w,N);break;case"popover":Un("beforetoggle",h),Un("toggle",h),en(h,"popover",N);break;case"xlinkActuate":dn(h,"http://www.w3.org/1999/xlink","xlink:actuate",N);break;case"xlinkArcrole":dn(h,"http://www.w3.org/1999/xlink","xlink:arcrole",N);break;case"xlinkRole":dn(h,"http://www.w3.org/1999/xlink","xlink:role",N);break;case"xlinkShow":dn(h,"http://www.w3.org/1999/xlink","xlink:show",N);break;case"xlinkTitle":dn(h,"http://www.w3.org/1999/xlink","xlink:title",N);break;case"xlinkType":dn(h,"http://www.w3.org/1999/xlink","xlink:type",N);break;case"xmlBase":dn(h,"http://www.w3.org/XML/1998/namespace","xml:base",N);break;case"xmlLang":dn(h,"http://www.w3.org/XML/1998/namespace","xml:lang",N);break;case"xmlSpace":dn(h,"http://www.w3.org/XML/1998/namespace","xml:space",N);break;case"is":en(h,"is",N);break;case"innerText":case"textContent":break;default:(!(2<w.length)||w[0]!=="o"&&w[0]!=="O"||w[1]!=="n"&&w[1]!=="N")&&(w=Ws.get(w)||w,en(h,w,N))}}function _k(h,g,w,N,P,L){switch(w){case"style":Yr(h,N,L);break;case"dangerouslySetInnerHTML":if(N!=null){if(typeof N!="object"||!("__html"in N))throw Error(r(61));if(w=N.__html,w!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=w}}break;case"children":typeof N=="string"?yt(h,N):(typeof N=="number"||typeof N=="bigint")&&yt(h,""+N);break;case"onScroll":N!=null&&Un("scroll",h);break;case"onScrollEnd":N!=null&&Un("scrollend",h);break;case"onClick":N!=null&&(h.onclick=_i);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ut.hasOwnProperty(w))e:{if(w[0]==="o"&&w[1]==="n"&&(P=w.endsWith("Capture"),g=w.slice(2,P?w.length-7:void 0),L=h[bn]||null,L=L!=null?L[w]:null,typeof L=="function"&&h.removeEventListener(g,L,P),typeof N=="function")){typeof L!="function"&&L!==null&&(w in h?h[w]=null:h.hasAttribute(w)&&h.removeAttribute(w)),h.addEventListener(g,N,P);break e}w in h?h[w]=N:N===!0?h.setAttribute(w,""):en(h,w,N)}}}function ka(h,g,w){switch(g){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Un("error",h),Un("load",h);var N=!1,P=!1,L;for(L in w)if(w.hasOwnProperty(L)){var J=w[L];if(J!=null)switch(L){case"src":N=!0;break;case"srcSet":P=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:wr(h,g,L,J,w,null)}}P&&wr(h,g,"srcSet",w.srcSet,w,null),N&&wr(h,g,"src",w.src,w,null);return;case"input":Un("invalid",h);var ve=L=J=P=null,Ue=null,it=null;for(N in w)if(w.hasOwnProperty(N)){var gt=w[N];if(gt!=null)switch(N){case"name":P=gt;break;case"type":J=gt;break;case"checked":Ue=gt;break;case"defaultChecked":it=gt;break;case"value":L=gt;break;case"defaultValue":ve=gt;break;case"children":case"dangerouslySetInnerHTML":if(gt!=null)throw Error(r(137,g));break;default:wr(h,g,N,gt,w,null)}}nr(h,L,ve,Ue,it,J,P,!1);return;case"select":Un("invalid",h),N=J=L=null;for(P in w)if(w.hasOwnProperty(P)&&(ve=w[P],ve!=null))switch(P){case"value":L=ve;break;case"defaultValue":J=ve;break;case"multiple":N=ve;default:wr(h,g,P,ve,w,null)}g=L,w=J,h.multiple=!!N,g!=null?et(h,!!N,g,!1):w!=null&&et(h,!!N,w,!0);return;case"textarea":Un("invalid",h),L=P=N=null;for(J in w)if(w.hasOwnProperty(J)&&(ve=w[J],ve!=null))switch(J){case"value":N=ve;break;case"defaultValue":P=ve;break;case"children":L=ve;break;case"dangerouslySetInnerHTML":if(ve!=null)throw Error(r(91));break;default:wr(h,g,J,ve,w,null)}qt(h,N,P,L);return;case"option":for(Ue in w)if(w.hasOwnProperty(Ue)&&(N=w[Ue],N!=null))switch(Ue){case"selected":h.selected=N&&typeof N!="function"&&typeof N!="symbol";break;default:wr(h,g,Ue,N,w,null)}return;case"dialog":Un("beforetoggle",h),Un("toggle",h),Un("cancel",h),Un("close",h);break;case"iframe":case"object":Un("load",h);break;case"video":case"audio":for(N=0;N<bb.length;N++)Un(bb[N],h);break;case"image":Un("error",h),Un("load",h);break;case"details":Un("toggle",h);break;case"embed":case"source":case"link":Un("error",h),Un("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(it in w)if(w.hasOwnProperty(it)&&(N=w[it],N!=null))switch(it){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:wr(h,g,it,N,w,null)}return;default:if(Br(g)){for(gt in w)w.hasOwnProperty(gt)&&(N=w[gt],N!==void 0&&_k(h,g,gt,N,w,void 0));return}}for(ve in w)w.hasOwnProperty(ve)&&(N=w[ve],N!=null&&wr(h,g,ve,N,w,null))}function Zie(h,g,w,N){switch(g){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var P=null,L=null,J=null,ve=null,Ue=null,it=null,gt=null;for(pt in w){var vt=w[pt];if(w.hasOwnProperty(pt)&&vt!=null)switch(pt){case"checked":break;case"value":break;case"defaultValue":Ue=vt;default:N.hasOwnProperty(pt)||wr(h,g,pt,null,N,vt)}}for(var ct in N){var pt=N[ct];if(vt=w[ct],N.hasOwnProperty(ct)&&(pt!=null||vt!=null))switch(ct){case"type":L=pt;break;case"name":P=pt;break;case"checked":it=pt;break;case"defaultChecked":gt=pt;break;case"value":J=pt;break;case"defaultValue":ve=pt;break;case"children":case"dangerouslySetInnerHTML":if(pt!=null)throw Error(r(137,g));break;default:pt!==vt&&wr(h,g,ct,pt,N,vt)}}ii(h,J,ve,Ue,it,gt,L,P);return;case"select":pt=J=ve=ct=null;for(L in w)if(Ue=w[L],w.hasOwnProperty(L)&&Ue!=null)switch(L){case"value":break;case"multiple":pt=Ue;default:N.hasOwnProperty(L)||wr(h,g,L,null,N,Ue)}for(P in N)if(L=N[P],Ue=w[P],N.hasOwnProperty(P)&&(L!=null||Ue!=null))switch(P){case"value":ct=L;break;case"defaultValue":ve=L;break;case"multiple":J=L;default:L!==Ue&&wr(h,g,P,L,N,Ue)}g=ve,w=J,N=pt,ct!=null?et(h,!!w,ct,!1):!!N!=!!w&&(g!=null?et(h,!!w,g,!0):et(h,!!w,w?[]:"",!1));return;case"textarea":pt=ct=null;for(ve in w)if(P=w[ve],w.hasOwnProperty(ve)&&P!=null&&!N.hasOwnProperty(ve))switch(ve){case"value":break;case"children":break;default:wr(h,g,ve,null,N,P)}for(J in N)if(P=N[J],L=w[J],N.hasOwnProperty(J)&&(P!=null||L!=null))switch(J){case"value":ct=P;break;case"defaultValue":pt=P;break;case"children":break;case"dangerouslySetInnerHTML":if(P!=null)throw Error(r(91));break;default:P!==L&&wr(h,g,J,P,N,L)}jt(h,ct,pt);return;case"option":for(var Vt in w)if(ct=w[Vt],w.hasOwnProperty(Vt)&&ct!=null&&!N.hasOwnProperty(Vt))switch(Vt){case"selected":h.selected=!1;break;default:wr(h,g,Vt,null,N,ct)}for(Ue in N)if(ct=N[Ue],pt=w[Ue],N.hasOwnProperty(Ue)&&ct!==pt&&(ct!=null||pt!=null))switch(Ue){case"selected":h.selected=ct&&typeof ct!="function"&&typeof ct!="symbol";break;default:wr(h,g,Ue,ct,N,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 nn in w)ct=w[nn],w.hasOwnProperty(nn)&&ct!=null&&!N.hasOwnProperty(nn)&&wr(h,g,nn,null,N,ct);for(it in N)if(ct=N[it],pt=w[it],N.hasOwnProperty(it)&&ct!==pt&&(ct!=null||pt!=null))switch(it){case"children":case"dangerouslySetInnerHTML":if(ct!=null)throw Error(r(137,g));break;default:wr(h,g,it,ct,N,pt)}return;default:if(Br(g)){for(var _r in w)ct=w[_r],w.hasOwnProperty(_r)&&ct!==void 0&&!N.hasOwnProperty(_r)&&_k(h,g,_r,void 0,N,ct);for(gt in N)ct=N[gt],pt=w[gt],!N.hasOwnProperty(gt)||ct===pt||ct===void 0&&pt===void 0||_k(h,g,gt,ct,N,pt);return}}for(var Je in w)ct=w[Je],w.hasOwnProperty(Je)&&ct!=null&&!N.hasOwnProperty(Je)&&wr(h,g,Je,null,N,ct);for(vt in N)ct=N[vt],pt=w[vt],!N.hasOwnProperty(vt)||ct===pt||ct==null&&pt==null||wr(h,g,vt,ct,N,pt)}function aU(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Jie(){if(typeof performance.getEntriesByType=="function"){for(var h=0,g=0,w=performance.getEntriesByType("resource"),N=0;N<w.length;N++){var P=w[N],L=P.transferSize,J=P.initiatorType,ve=P.duration;if(L&&ve&&aU(J)){for(J=0,ve=P.responseEnd,N+=1;N<w.length;N++){var Ue=w[N],it=Ue.startTime;if(it>ve)break;var gt=Ue.transferSize,vt=Ue.initiatorType;gt&&aU(vt)&&(Ue=Ue.responseEnd,J+=gt*(Ue<ve?1:(ve-it)/(Ue-it)))}if(--N,g+=8*(L+J)/(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 Sk=null,Nk=null;function pw(h){return h.nodeType===9?h:h.ownerDocument}function sU(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 oU(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 Mk(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 Ek=null;function eae(){var h=window.event;return h&&h.type==="popstate"?h===Ek?!1:(Ek=h,!0):(Ek=null,!1)}var lU=typeof setTimeout=="function"?setTimeout:void 0,tae=typeof clearTimeout=="function"?clearTimeout:void 0,cU=typeof Promise=="function"?Promise:void 0,nae=typeof queueMicrotask=="function"?queueMicrotask:typeof cU<"u"?function(h){return cU.resolve(null).then(h).catch(rae)}:lU;function rae(h){setTimeout(function(){throw h})}function gd(h){return h==="head"}function uU(h,g){var w=g,N=0;do{var P=w.nextSibling;if(h.removeChild(w),P&&P.nodeType===8)if(w=P.data,w==="/$"||w==="/&"){if(N===0){h.removeChild(P),fp(g);return}N--}else if(w==="$"||w==="$?"||w==="$~"||w==="$!"||w==="&")N++;else if(w==="html")vb(h.ownerDocument.documentElement);else if(w==="head"){w=h.ownerDocument.head,vb(w);for(var L=w.firstChild;L;){var J=L.nextSibling,ve=L.nodeName;L[lt]||ve==="SCRIPT"||ve==="STYLE"||ve==="LINK"&&L.rel.toLowerCase()==="stylesheet"||w.removeChild(L),L=J}}else w==="body"&&vb(h.ownerDocument.body);w=P}while(w);fp(g)}function dU(h,g){var w=h;h=0;do{var N=w.nextSibling;if(w.nodeType===1?g?(w._stashedDisplay=w.style.display,w.style.display="none"):(w.style.display=w._stashedDisplay||"",w.getAttribute("style")===""&&w.removeAttribute("style")):w.nodeType===3&&(g?(w._stashedText=w.nodeValue,w.nodeValue=""):w.nodeValue=w._stashedText||""),N&&N.nodeType===8)if(w=N.data,w==="/$"){if(h===0)break;h--}else w!=="$"&&w!=="$?"&&w!=="$~"&&w!=="$!"||h++;w=N}while(w)}function kk(h){var g=h.firstChild;for(g&&g.nodeType===10&&(g=g.nextSibling);g;){var w=g;switch(g=g.nextSibling,w.nodeName){case"HTML":case"HEAD":case"BODY":kk(w),ot(w);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(w.rel.toLowerCase()==="stylesheet")continue}h.removeChild(w)}}function iae(h,g,w,N){for(;h.nodeType===1;){var P=w;if(h.nodeName.toLowerCase()!==g.toLowerCase()){if(!N&&(h.nodeName!=="INPUT"||h.type!=="hidden"))break}else if(N){if(!h[lt])switch(g){case"meta":if(!h.hasAttribute("itemprop"))break;return h;case"link":if(L=h.getAttribute("rel"),L==="stylesheet"&&h.hasAttribute("data-precedence"))break;if(L!==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(L=h.getAttribute("src"),(L!==(P.src==null?null:P.src)||h.getAttribute("type")!==(P.type==null?null:P.type)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin))&&L&&h.hasAttribute("async")&&!h.hasAttribute("itemprop"))break;return h;default:return h}}else if(g==="input"&&h.type==="hidden"){var L=P.name==null?null:""+P.name;if(P.type==="hidden"&&h.getAttribute("name")===L)return h}else return h;if(h=Po(h.nextSibling),h===null)break}return null}function aae(h,g,w){if(g==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!w||(h=Po(h.nextSibling),h===null))return null;return h}function hU(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 Tk(h){return h.data==="$?"||h.data==="$~"}function Ak(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function sae(h,g){var w=h.ownerDocument;if(h.data==="$~")h._reactRetry=g;else if(h.data!=="$?"||w.readyState!=="loading")g();else{var N=function(){g(),w.removeEventListener("DOMContentLoaded",N)};w.addEventListener("DOMContentLoaded",N),h._reactRetry=N}}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 Ck=null;function fU(h){h=h.nextSibling;for(var g=0;h;){if(h.nodeType===8){var w=h.data;if(w==="/$"||w==="/&"){if(g===0)return Po(h.nextSibling);g--}else w!=="$"&&w!=="$!"&&w!=="$?"&&w!=="$~"&&w!=="&"||g++}h=h.nextSibling}return null}function mU(h){h=h.previousSibling;for(var g=0;h;){if(h.nodeType===8){var w=h.data;if(w==="$"||w==="$!"||w==="$?"||w==="$~"||w==="&"){if(g===0)return h;g--}else w!=="/$"&&w!=="/&"||g++}h=h.previousSibling}return null}function pU(h,g,w){switch(g=pw(w),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 vb(h){for(var g=h.attributes;g.length;)h.removeAttributeNode(g[0]);ot(h)}var Do=new Map,gU=new Set;function gw(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var Gc=V.d;V.d={f:oae,r:lae,D:cae,C:uae,L:dae,m:hae,X:mae,S:fae,M:pae};function oae(){var h=Gc.f(),g=ow();return h||g}function lae(h){var g=he(h);g!==null&&g.tag===5&&g.type==="form"?DI(g):Gc.r(h)}var up=typeof document>"u"?null:document;function xU(h,g,w){var N=up;if(N&&typeof g=="string"&&g){var P=jn(g);P='link[rel="'+h+'"][href="'+P+'"]',typeof w=="string"&&(P+='[crossorigin="'+w+'"]'),gU.has(P)||(gU.add(P),h={rel:h,crossOrigin:w,href:g},N.querySelector(P)===null&&(g=N.createElement("link"),ka(g,"link",h),Le(g),N.head.appendChild(g)))}}function cae(h){Gc.D(h),xU("dns-prefetch",h,null)}function uae(h,g){Gc.C(h,g),xU("preconnect",h,g)}function dae(h,g,w){Gc.L(h,g,w);var N=up;if(N&&h&&g){var P='link[rel="preload"][as="'+jn(g)+'"]';g==="image"&&w&&w.imageSrcSet?(P+='[imagesrcset="'+jn(w.imageSrcSet)+'"]',typeof w.imageSizes=="string"&&(P+='[imagesizes="'+jn(w.imageSizes)+'"]')):P+='[href="'+jn(h)+'"]';var L=P;switch(g){case"style":L=dp(h);break;case"script":L=hp(h)}Do.has(L)||(h=f({rel:"preload",href:g==="image"&&w&&w.imageSrcSet?void 0:h,as:g},w),Do.set(L,h),N.querySelector(P)!==null||g==="style"&&N.querySelector(wb(L))||g==="script"&&N.querySelector(_b(L))||(g=N.createElement("link"),ka(g,"link",h),Le(g),N.head.appendChild(g)))}}function hae(h,g){Gc.m(h,g);var w=up;if(w&&h){var N=g&&typeof g.as=="string"?g.as:"script",P='link[rel="modulepreload"][as="'+jn(N)+'"][href="'+jn(h)+'"]',L=P;switch(N){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":L=hp(h)}if(!Do.has(L)&&(h=f({rel:"modulepreload",href:h},g),Do.set(L,h),w.querySelector(P)===null)){switch(N){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(w.querySelector(_b(L)))return}N=w.createElement("link"),ka(N,"link",h),Le(N),w.head.appendChild(N)}}}function fae(h,g,w){Gc.S(h,g,w);var N=up;if(N&&h){var P=Ie(N).hoistableStyles,L=dp(h);g=g||"default";var J=P.get(L);if(!J){var ve={loading:0,preload:null};if(J=N.querySelector(wb(L)))ve.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":g},w),(w=Do.get(L))&&jk(h,w);var Ue=J=N.createElement("link");Le(Ue),ka(Ue,"link",h),Ue._p=new Promise(function(it,gt){Ue.onload=it,Ue.onerror=gt}),Ue.addEventListener("load",function(){ve.loading|=1}),Ue.addEventListener("error",function(){ve.loading|=2}),ve.loading|=4,xw(J,g,N)}J={type:"stylesheet",instance:J,count:1,state:ve},P.set(L,J)}}}function mae(h,g){Gc.X(h,g);var w=up;if(w&&h){var N=Ie(w).hoistableScripts,P=hp(h),L=N.get(P);L||(L=w.querySelector(_b(P)),L||(h=f({src:h,async:!0},g),(g=Do.get(P))&&Pk(h,g),L=w.createElement("script"),Le(L),ka(L,"link",h),w.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},N.set(P,L))}}function pae(h,g){Gc.M(h,g);var w=up;if(w&&h){var N=Ie(w).hoistableScripts,P=hp(h),L=N.get(P);L||(L=w.querySelector(_b(P)),L||(h=f({src:h,async:!0,type:"module"},g),(g=Do.get(P))&&Pk(h,g),L=w.createElement("script"),Le(L),ka(L,"link",h),w.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},N.set(P,L))}}function bU(h,g,w,N){var P=(P=xe.current)?gw(P):null;if(!P)throw Error(r(446));switch(h){case"meta":case"title":return null;case"style":return typeof w.precedence=="string"&&typeof w.href=="string"?(g=dp(w.href),w=Ie(P).hoistableStyles,N=w.get(g),N||(N={type:"style",instance:null,count:0,state:null},w.set(g,N)),N):{type:"void",instance:null,count:0,state:null};case"link":if(w.rel==="stylesheet"&&typeof w.href=="string"&&typeof w.precedence=="string"){h=dp(w.href);var L=Ie(P).hoistableStyles,J=L.get(h);if(J||(P=P.ownerDocument||P,J={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},L.set(h,J),(L=P.querySelector(wb(h)))&&!L._p&&(J.instance=L,J.state.loading=5),Do.has(h)||(w={rel:"preload",as:"style",href:w.href,crossOrigin:w.crossOrigin,integrity:w.integrity,media:w.media,hrefLang:w.hrefLang,referrerPolicy:w.referrerPolicy},Do.set(h,w),L||gae(P,h,w,J.state))),g&&N===null)throw Error(r(528,""));return J}if(g&&N!==null)throw Error(r(529,""));return null;case"script":return g=w.async,w=w.src,typeof w=="string"&&g&&typeof g!="function"&&typeof g!="symbol"?(g=hp(w),w=Ie(P).hoistableScripts,N=w.get(g),N||(N={type:"script",instance:null,count:0,state:null},w.set(g,N)),N):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,h))}}function dp(h){return'href="'+jn(h)+'"'}function wb(h){return'link[rel="stylesheet"]['+h+"]"}function yU(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function gae(h,g,w,N){h.querySelector('link[rel="preload"][as="style"]['+g+"]")?N.loading=1:(g=h.createElement("link"),N.preload=g,g.addEventListener("load",function(){return N.loading|=1}),g.addEventListener("error",function(){return N.loading|=2}),ka(g,"link",w),Le(g),h.head.appendChild(g))}function hp(h){return'[src="'+jn(h)+'"]'}function _b(h){return"script[async]"+h}function vU(h,g,w){if(g.count++,g.instance===null)switch(g.type){case"style":var N=h.querySelector('style[data-href~="'+jn(w.href)+'"]');if(N)return g.instance=N,Le(N),N;var P=f({},w,{"data-href":w.href,"data-precedence":w.precedence,href:null,precedence:null});return N=(h.ownerDocument||h).createElement("style"),Le(N),ka(N,"style",P),xw(N,w.precedence,h),g.instance=N;case"stylesheet":P=dp(w.href);var L=h.querySelector(wb(P));if(L)return g.state.loading|=4,g.instance=L,Le(L),L;N=yU(w),(P=Do.get(P))&&jk(N,P),L=(h.ownerDocument||h).createElement("link"),Le(L);var J=L;return J._p=new Promise(function(ve,Ue){J.onload=ve,J.onerror=Ue}),ka(L,"link",N),g.state.loading|=4,xw(L,w.precedence,h),g.instance=L;case"script":return L=hp(w.src),(P=h.querySelector(_b(L)))?(g.instance=P,Le(P),P):(N=w,(P=Do.get(L))&&(N=f({},w),Pk(N,P)),h=h.ownerDocument||h,P=h.createElement("script"),Le(P),ka(P,"link",N),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&&(N=g.instance,g.state.loading|=4,xw(N,w.precedence,h));return g.instance}function xw(h,g,w){for(var N=w.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),P=N.length?N[N.length-1]:null,L=P,J=0;J<N.length;J++){var ve=N[J];if(ve.dataset.precedence===g)L=ve;else if(L!==P)break}L?L.parentNode.insertBefore(h,L.nextSibling):(g=w.nodeType===9?w.head:w,g.insertBefore(h,g.firstChild))}function jk(h,g){h.crossOrigin==null&&(h.crossOrigin=g.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=g.referrerPolicy),h.title==null&&(h.title=g.title)}function Pk(h,g){h.crossOrigin==null&&(h.crossOrigin=g.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=g.referrerPolicy),h.integrity==null&&(h.integrity=g.integrity)}var bw=null;function wU(h,g,w){if(bw===null){var N=new Map,P=bw=new Map;P.set(w,N)}else P=bw,N=P.get(w),N||(N=new Map,P.set(w,N));if(N.has(h))return N;for(N.set(h,null),w=w.getElementsByTagName(h),P=0;P<w.length;P++){var L=w[P];if(!(L[lt]||L[Kn]||h==="link"&&L.getAttribute("rel")==="stylesheet")&&L.namespaceURI!=="http://www.w3.org/2000/svg"){var J=L.getAttribute(g)||"";J=h+J;var ve=N.get(J);ve?ve.push(L):N.set(J,[L])}}return N}function _U(h,g,w){h=h.ownerDocument||h,h.head.insertBefore(w,g==="title"?h.querySelector("head > title"):null)}function xae(h,g,w){if(w===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 SU(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function bae(h,g,w,N){if(w.type==="stylesheet"&&(typeof N.media!="string"||matchMedia(N.media).matches!==!1)&&(w.state.loading&4)===0){if(w.instance===null){var P=dp(N.href),L=g.querySelector(wb(P));if(L){g=L._p,g!==null&&typeof g=="object"&&typeof g.then=="function"&&(h.count++,h=yw.bind(h),g.then(h,h)),w.state.loading|=4,w.instance=L,Le(L);return}L=g.ownerDocument||g,N=yU(N),(P=Do.get(P))&&jk(N,P),L=L.createElement("link"),Le(L);var J=L;J._p=new Promise(function(ve,Ue){J.onload=ve,J.onerror=Ue}),ka(L,"link",N),w.instance=L}h.stylesheets===null&&(h.stylesheets=new Map),h.stylesheets.set(w,g),(g=w.state.preload)&&(w.state.loading&3)===0&&(h.count++,w=yw.bind(h),g.addEventListener("load",w),g.addEventListener("error",w))}}var Dk=0;function yae(h,g){return h.stylesheets&&h.count===0&&ww(h,h.stylesheets),0<h.count||0<h.imgCount?function(w){var N=setTimeout(function(){if(h.stylesheets&&ww(h,h.stylesheets),h.unsuspend){var L=h.unsuspend;h.unsuspend=null,L()}},6e4+g);0<h.imgBytes&&Dk===0&&(Dk=62500*Jie());var P=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&ww(h,h.stylesheets),h.unsuspend)){var L=h.unsuspend;h.unsuspend=null,L()}},(h.imgBytes>Dk?50:800)+g);return h.unsuspend=w,function(){h.unsuspend=null,clearTimeout(N),clearTimeout(P)}}:null}function yw(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ww(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var vw=null;function ww(h,g){h.stylesheets=null,h.unsuspend!==null&&(h.count++,vw=new Map,g.forEach(vae,h),vw=null,yw.call(h))}function vae(h,g){if(!(g.state.loading&4)){var w=vw.get(h);if(w)var N=w.get(null);else{w=new Map,vw.set(h,w);for(var P=h.querySelectorAll("link[data-precedence],style[data-precedence]"),L=0;L<P.length;L++){var J=P[L];(J.nodeName==="LINK"||J.getAttribute("media")!=="not all")&&(w.set(J.dataset.precedence,J),N=J)}N&&w.set(null,N)}P=g.instance,J=P.getAttribute("data-precedence"),L=w.get(J)||N,L===N&&w.set(null,P),w.set(J,P),this.count++,N=yw.bind(this),P.addEventListener("load",N),P.addEventListener("error",N),L?L.parentNode.insertBefore(P,L.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(P,h.firstChild)),g.state.loading|=4}}var Sb={$$typeof:M,Provider:null,Consumer:null,_currentValue:Q,_currentValue2:Q,_threadCount:0};function wae(h,g,w,N,P,L,J,ve,Ue){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=ft(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ft(0),this.hiddenUpdates=ft(null),this.identifierPrefix=N,this.onUncaughtError=P,this.onCaughtError=L,this.onRecoverableError=J,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Ue,this.incompleteTransitions=new Map}function NU(h,g,w,N,P,L,J,ve,Ue,it,gt,vt){return h=new wae(h,g,w,J,Ue,it,gt,vt,ve),g=1,L===!0&&(g|=24),L=Ys(3,null,null,g),h.current=L,L.stateNode=h,g=hE(),g.refCount++,h.pooledCache=g,g.refCount++,L.memoizedState={element:N,isDehydrated:w,cache:g},gE(L),h}function MU(h){return h?(h=Hm,h):Hm}function EU(h,g,w,N,P,L){P=MU(P),N.context===null?N.context=P:N.pendingContext=P,N=ad(g),N.payload={element:w},L=L===void 0?null:L,L!==null&&(N.callback=L),w=sd(h,N,g),w!==null&&(As(w,h,g),tb(w,h,g))}function kU(h,g){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var w=h.retryLane;h.retryLane=w!==0&&w<g?w:g}}function Rk(h,g){kU(h,g),(h=h.alternate)&&kU(h,g)}function TU(h){if(h.tag===13||h.tag===31){var g=Wh(h,67108864);g!==null&&As(g,h,67108864),Rk(h,67108864)}}function AU(h){if(h.tag===13||h.tag===31){var g=to();g=hr(g);var w=Wh(h,g);w!==null&&As(w,h,g),Rk(h,g)}}var _w=!0;function _ae(h,g,w,N){var P=K.T;K.T=null;var L=V.p;try{V.p=2,Ok(h,g,w,N)}finally{V.p=L,K.T=P}}function Sae(h,g,w,N){var P=K.T;K.T=null;var L=V.p;try{V.p=8,Ok(h,g,w,N)}finally{V.p=L,K.T=P}}function Ok(h,g,w,N){if(_w){var P=Lk(N);if(P===null)wk(h,g,N,Sw,w),jU(h,N);else if(Mae(P,h,g,w,N))N.stopPropagation();else if(jU(h,N),g&4&&-1<Nae.indexOf(h)){for(;P!==null;){var L=he(P);if(L!==null)switch(L.tag){case 3:if(L=L.stateNode,L.current.memoizedState.isDehydrated){var J=ze(L.pendingLanes);if(J!==0){var ve=L;for(ve.pendingLanes|=2,ve.entangledLanes|=2;J;){var Ue=1<<31-Be(J);ve.entanglements[1]|=Ue,J&=~Ue}Kl(L),(cr&6)===0&&(aw=O()+500,xb(0))}}break;case 31:case 13:ve=Wh(L,2),ve!==null&&As(ve,L,2),ow(),Rk(L,2)}if(L=Lk(N),L===null&&wk(h,g,N,Sw,w),L===P)break;P=L}P!==null&&N.stopPropagation()}else wk(h,g,N,null,w)}}function Lk(h){return h=_o(h),Fk(h)}var Sw=null;function Fk(h){if(Sw=null,h=kt(h),h!==null){var g=a(h);if(g===null)h=null;else{var w=g.tag;if(w===13){if(h=o(g),h!==null)return h;h=null}else if(w===31){if(h=l(g),h!==null)return h;h=null}else if(w===3){if(g.stateNode.current.memoizedState.isDehydrated)return g.tag===3?g.stateNode.containerInfo:null;h=null}else g!==h&&(h=null)}}return Sw=h,null}function CU(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(ee()){case le:return 2;case _e:return 8;case we:case re:return 32;case Fe:return 268435456;default:return 32}default:return 32}}var Ik=!1,xd=null,bd=null,yd=null,Nb=new Map,Mb=new Map,vd=[],Nae="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 jU(h,g){switch(h){case"focusin":case"focusout":xd=null;break;case"dragenter":case"dragleave":bd=null;break;case"mouseover":case"mouseout":yd=null;break;case"pointerover":case"pointerout":Nb.delete(g.pointerId);break;case"gotpointercapture":case"lostpointercapture":Mb.delete(g.pointerId)}}function Eb(h,g,w,N,P,L){return h===null||h.nativeEvent!==L?(h={blockedOn:g,domEventName:w,eventSystemFlags:N,nativeEvent:L,targetContainers:[P]},g!==null&&(g=he(g),g!==null&&TU(g)),h):(h.eventSystemFlags|=N,g=h.targetContainers,P!==null&&g.indexOf(P)===-1&&g.push(P),h)}function Mae(h,g,w,N,P){switch(g){case"focusin":return xd=Eb(xd,h,g,w,N,P),!0;case"dragenter":return bd=Eb(bd,h,g,w,N,P),!0;case"mouseover":return yd=Eb(yd,h,g,w,N,P),!0;case"pointerover":var L=P.pointerId;return Nb.set(L,Eb(Nb.get(L)||null,h,g,w,N,P)),!0;case"gotpointercapture":return L=P.pointerId,Mb.set(L,Eb(Mb.get(L)||null,h,g,w,N,P)),!0}return!1}function PU(h){var g=kt(h.target);if(g!==null){var w=a(g);if(w!==null){if(g=w.tag,g===13){if(g=o(w),g!==null){h.blockedOn=g,fr(h.priority,function(){AU(w)});return}}else if(g===31){if(g=l(w),g!==null){h.blockedOn=g,fr(h.priority,function(){AU(w)});return}}else if(g===3&&w.stateNode.current.memoizedState.isDehydrated){h.blockedOn=w.tag===3?w.stateNode.containerInfo:null;return}}}h.blockedOn=null}function Nw(h){if(h.blockedOn!==null)return!1;for(var g=h.targetContainers;0<g.length;){var w=Lk(h.nativeEvent);if(w===null){w=h.nativeEvent;var N=new w.constructor(w.type,w);Ss=N,w.target.dispatchEvent(N),Ss=null}else return g=he(w),g!==null&&TU(g),h.blockedOn=w,!1;g.shift()}return!0}function DU(h,g,w){Nw(h)&&w.delete(g)}function Eae(){Ik=!1,xd!==null&&Nw(xd)&&(xd=null),bd!==null&&Nw(bd)&&(bd=null),yd!==null&&Nw(yd)&&(yd=null),Nb.forEach(DU),Mb.forEach(DU)}function Mw(h,g){h.blockedOn===g&&(h.blockedOn=null,Ik||(Ik=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Eae)))}var Ew=null;function RU(h){Ew!==h&&(Ew=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Ew===h&&(Ew=null);for(var g=0;g<h.length;g+=3){var w=h[g],N=h[g+1],P=h[g+2];if(typeof N!="function"){if(Fk(N||w)===null)continue;break}var L=he(w);L!==null&&(h.splice(g,3),g-=3,LE(L,{pending:!0,data:P,method:w.method,action:N},N,P))}}))}function fp(h){function g(Ue){return Mw(Ue,h)}xd!==null&&Mw(xd,h),bd!==null&&Mw(bd,h),yd!==null&&Mw(yd,h),Nb.forEach(g),Mb.forEach(g);for(var w=0;w<vd.length;w++){var N=vd[w];N.blockedOn===h&&(N.blockedOn=null)}for(;0<vd.length&&(w=vd[0],w.blockedOn===null);)PU(w),w.blockedOn===null&&vd.shift();if(w=(h.ownerDocument||h).$$reactFormReplay,w!=null)for(N=0;N<w.length;N+=3){var P=w[N],L=w[N+1],J=P[bn]||null;if(typeof L=="function")J||RU(w);else if(J){var ve=null;if(L&&L.hasAttribute("formAction")){if(P=L,J=L[bn]||null)ve=J.formAction;else if(Fk(P)!==null)continue}else ve=J.action;typeof ve=="function"?w[N+1]=ve:(w.splice(N,3),N-=3),RU(w)}}}function OU(){function h(L){L.canIntercept&&L.info==="react-transition"&&L.intercept({handler:function(){return new Promise(function(J){return P=J})},focusReset:"manual",scroll:"manual"})}function g(){P!==null&&(P(),P=null),N||setTimeout(w,20)}function w(){if(!N&&!navigation.transition){var L=navigation.currentEntry;L&&L.url!=null&&navigation.navigate(L.url,{state:L.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var N=!1,P=null;return navigation.addEventListener("navigate",h),navigation.addEventListener("navigatesuccess",g),navigation.addEventListener("navigateerror",g),setTimeout(w,100),function(){N=!0,navigation.removeEventListener("navigate",h),navigation.removeEventListener("navigatesuccess",g),navigation.removeEventListener("navigateerror",g),P!==null&&(P(),P=null)}}}function Uk(h){this._internalRoot=h}kw.prototype.render=Uk.prototype.render=function(h){var g=this._internalRoot;if(g===null)throw Error(r(409));var w=g.current,N=to();EU(w,N,h,g,null,null)},kw.prototype.unmount=Uk.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var g=h.containerInfo;EU(h.current,2,null,h,null,null),ow(),g[wi]=null}};function kw(h){this._internalRoot=h}kw.prototype.unstable_scheduleHydration=function(h){if(h){var g=ln();h={blockedOn:null,target:h,priority:g};for(var w=0;w<vd.length&&g!==0&&g<vd[w].priority;w++);vd.splice(w,0,h),w===0&&PU(h)}};var LU=e.version;if(LU!=="19.2.0")throw Error(r(527,LU,"19.2.0"));V.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 kae={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:K,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Tw=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Tw.isDisabled&&Tw.supportsFiber)try{He=Tw.inject(kae),ye=Tw}catch{}}return Tb.createRoot=function(h,g){if(!i(h))throw Error(r(299));var w=!1,N="",P=HI,L=VI,J=GI;return g!=null&&(g.unstable_strictMode===!0&&(w=!0),g.identifierPrefix!==void 0&&(N=g.identifierPrefix),g.onUncaughtError!==void 0&&(P=g.onUncaughtError),g.onCaughtError!==void 0&&(L=g.onCaughtError),g.onRecoverableError!==void 0&&(J=g.onRecoverableError)),g=NU(h,1,!1,null,null,w,N,null,P,L,J,OU),h[wi]=g.current,vk(h),new Uk(g)},Tb.hydrateRoot=function(h,g,w){if(!i(h))throw Error(r(299));var N=!1,P="",L=HI,J=VI,ve=GI,Ue=null;return w!=null&&(w.unstable_strictMode===!0&&(N=!0),w.identifierPrefix!==void 0&&(P=w.identifierPrefix),w.onUncaughtError!==void 0&&(L=w.onUncaughtError),w.onCaughtError!==void 0&&(J=w.onCaughtError),w.onRecoverableError!==void 0&&(ve=w.onRecoverableError),w.formState!==void 0&&(Ue=w.formState)),g=NU(h,1,!0,g,w??null,N,P,Ue,L,J,ve,OU),g.context=MU(null),w=g.current,N=to(),N=hr(N),P=ad(N),P.callback=null,sd(w,P,N),w=N,g.current.lanes=w,Bt(g,w),Kl(g),h[wi]=g.current,vk(h),new kw(g)},Tb.version="19.2.0",Tb}var qU;function Iae(){if(qU)return $k.exports;qU=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(),$k.exports=Fae(),$k.exports}var Uae=Iae();const fn=t=>typeof t=="string",Ab=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},WU=t=>t==null?"":""+t,zae=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Bae=/###/g,KU=t=>t&&t.indexOf("###")>-1?t.replace(Bae,"."):t,XU=t=>!t||fn(t),x0=(t,e,n)=>{const r=fn(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(XU(t))return{};const a=KU(r[i]);!t[a]&&n&&(t[a]=new n),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++i}return XU(t)?{}:{obj:t,k:KU(r[i])}},YU=(t,e,n)=>{const{obj:r,k:i}=x0(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let a=e[e.length-1],o=e.slice(0,e.length-1),l=x0(t,o,Object);for(;l.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),l=x0(t,o,Object),l?.obj&&typeof l.obj[`${l.k}.${a}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${a}`]=n},$ae=(t,e,n,r)=>{const{obj:i,k:a}=x0(t,e,Object);i[a]=i[a]||[],i[a].push(n)},U1=(t,e)=>{const{obj:n,k:r}=x0(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Hae=(t,e,n)=>{const r=U1(t,n);return r!==void 0?r:U1(e,n)},vq=(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]):vq(t[r],e[r],n):t[r]=e[r]);return t},mp=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Vae={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const Gae=t=>fn(t)?t.replace(/[&<>"'\/]/g,e=>Vae[e]):t;class qae{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 Wae=[" ",",","?","!",";"],Kae=new qae(20),Xae=(t,e,n)=>{e=e||"",n=n||"";const r=Wae.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=Kae.getRegExp(`(${r.map(o=>o==="?"?"\\?":o).join("|")})`);let a=!i.test(t);if(!a){const o=t.indexOf(n);o>0&&!i.test(t.substring(0,o))&&(a=!0)}return a},Yj=(t,e,n=".")=>{if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const r=e.split(n);let i=t;for(let a=0;a<r.length;){if(!i||typeof i!="object")return;let o,l="";for(let c=a;c<r.length;++c)if(c!==a&&(l+=n),l+=r[c],o=i[l],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&c<r.length-1)continue;a+=c-a+1;break}i=o}return i},B0=t=>t?.replace("_","-"),Yae={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 z1{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||Yae,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 z1(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new z1(this.logger,e)}}var sc=new z1;let t2=class{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([i,a])=>{for(let o=0;o<a;o++)i(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,a])=>{for(let o=0;o<a;o++)i.apply(i,[e,...n])})}};class QU extends t2{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r,i={}){const a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,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)&&a?l.push(...r.split(a)):l.push(r)));const c=U1(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:Yj(this.data?.[e]?.[n],r,a)}addResource(e,n,r,i,a={silent:!1}){const o=a.keySeparator!==void 0?a.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),YU(this.data,l,i),a.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const a in r)(fn(r[a])||Array.isArray(r[a]))&&this.addResource(e,n,a,r[a],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,a,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=U1(this.data,l)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?vq(c,r,a):c={...c,...r},YU(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 wq={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(a=>{e=this.processors[a]?.process(e,n,r,i)??e}),e}};const _q=Symbol("i18next/PATH_KEY");function Qae(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===_q?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function Qj(t,e){const{[_q]:n}=t(Qae());return n.join(e?.keySeparator??".")}const ZU={},qk=t=>!fn(t)&&typeof t!="boolean"&&typeof t!="number";class B1 extends t2{constructor(e,n={}){super(),zae(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=sc.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){const r={...n};if(e==null)return!1;const i=this.resolve(e,r);if(i?.res===void 0)return!1;const a=qk(i.res);return!(r.returnObjects===!1&&a)}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=n.ns||this.options.defaultNS||[];const o=r&&e.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!Xae(e,r,i);if(o&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:fn(a)?[a]:a};const u=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(a=u.shift()),e=u.join(i)}return{key:e,namespaces:fn(a)?[a]:a}}translate(e,n,r){let i=typeof n=="object"?{...n}:n;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i={...i}),i||(i={}),e==null)return"";typeof e=="function"&&(e=Qj(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const a=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,p=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return p?a?{res:`${u}${d}${l}`,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${d}${l}`:a?{res:l,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:l;const m=this.resolve(e,i);let x=m?.res;const b=m?.usedKey||l,y=m?.exactUsedKey||l,v=["[object Number]","[object Function]","[object RegExp]"],S=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,M=!this.i18nFormat||this.i18nFormat.handleAsObject,T=i.count!==void 0&&!fn(i.count),E=B1.hasDefaultValue(i),C=T?this.pluralResolver.getSuffix(f,i.count,i):"",k=i.ordinal&&T?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",R=T&&!i.ordinal&&i.count===0,A=R&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${C}`]||i[`defaultValue${k}`]||i.defaultValue;let D=x;M&&!x&&E&&(D=A);const U=qk(D),F=Object.prototype.toString.apply(D);if(M&&D&&U&&v.indexOf(F)<0&&!(fn(S)&&Array.isArray(D))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const H=this.options.returnedObjectHandler?this.options.returnedObjectHandler(b,D,{...i,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return a?(m.res=H,m.usedParams=this.getUsedParamsDetails(i),m):H}if(o){const H=Array.isArray(D),j=H?[]:{},$=H?y:b;for(const K in D)if(Object.prototype.hasOwnProperty.call(D,K)){const V=`${$}${o}${K}`;E&&!x?j[K]=this.translate(V,{...i,defaultValue:qk(A)?A[K]:void 0,joinArrays:!1,ns:c}):j[K]=this.translate(V,{...i,joinArrays:!1,ns:c}),j[K]===V&&(j[K]=D[K])}x=j}}else if(M&&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)&&E&&(H=!0,x=A),this.isValidLookup(x)||(j=!0,x=l);const K=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&j?void 0:x,V=E&&A!==x&&this.options.updateMissing;if(j||H||V){if(this.logger.log(V?"updateKey":"missingKey",f,u,l,V?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 Q=[];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++)Q.push(Z[B]);else this.options.saveMissingTo==="all"?Q=this.languageUtils.toResolveHierarchy(i.lng||this.language):Q.push(i.lng||this.language);const ae=(B,X,ne)=>{const se=E&&ne!==x?ne:K;this.options.missingKeyHandler?this.options.missingKeyHandler(B,u,X,se,V,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(B,u,X,se,V,i),this.emit("missingKey",B,u,X,x)};this.options.saveMissing&&(this.options.saveMissingPlurals&&T?Q.forEach(B=>{const X=this.pluralResolver.getSuffixes(B,i);R&&i[`defaultValue${this.options.pluralSeparator}zero`]&&X.indexOf(`${this.options.pluralSeparator}zero`)<0&&X.push(`${this.options.pluralSeparator}zero`),X.forEach(ne=>{ae([B],l+ne,i[`defaultValue${ne}`]||A)})}):ae(Q,l,A))}x=this.extendTranslation(x,e,i,m,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 a?(m.res=x,m.usedParams=this.getUsedParamsDetails(i),m):x}extendTranslation(e,n,r,i,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=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),p=f&&f.length;u<p&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...f)=>a?.[0]===f[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${f[0]} in key: ${n[0]}`),null):this.translate(...f,n),r)),r.interpolation&&this.interpolator.reset()}const o=r.postProcess||this.options.postProcess,l=fn(o)?[o]:o;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=wq.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,a,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 p=n.count!==void 0&&!fn(n.count),m=p&&!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,!ZU[`${b[0]}-${y}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(ZU[`${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 T;p&&(T=this.pluralResolver.getSuffix(v,n.count,n));const E=`${this.options.pluralSeparator}zero`,C=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(n.ordinal&&T.indexOf(C)===0&&S.push(d+T.replace(C,this.options.pluralSeparator)),S.push(d+T),m&&S.push(d+E)),x){const k=`${d}${this.options.contextSeparator||"_"}${n.context}`;S.push(k),p&&(n.ordinal&&T.indexOf(C)===0&&S.push(k+T.replace(C,this.options.pluralSeparator)),S.push(k+T),m&&S.push(k+E))}}let M;for(;M=S.pop();)this.isValidLookup(r)||(a=M,r=this.getResource(v,y,M,n))}))})}),{res:r,usedKey:i,exactUsedKey:a,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 a of n)delete i[a]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}class JU{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=sc.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 a=this.getLanguagePartFromCode(r);if(this.isSupportedCode(a))return n=a;n=this.options.supportedLngs.find(o=>{if(o===a)return o;if(!(o.indexOf("-")<0&&a.indexOf("-")<0)&&(o.indexOf("-")>0&&a.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===a||o.indexOf(a)===0&&a.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=[],a=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"&&a(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(e))):fn(e)&&a(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&a(this.formatLanguageCode(o))}),i}}const ez={zero:0,one:1,two:2,few:3,many:4,other:5},tz={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Zae{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=sc.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",a=JSON.stringify({cleanedCode:r,type:i});if(a in this.pluralRulesCache)return this.pluralRulesCache[a];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!"),tz;if(!e.match(/-|_/))return tz;const c=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(c,n)}return this.pluralRulesCache[a]=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,a)=>ez[i]-ez[a]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n,r={}){const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const nz=(t,e,n,r=".",i=!0)=>{let a=Hae(t,e,n);return!a&&i&&fn(n)&&(a=Yj(t,n,r),a===void 0&&(a=Yj(e,n,r))),a},Wk=t=>t.replace(/\$/g,"$$$$");class Jae{constructor(e={}){this.logger=sc.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:i,prefix:a,prefixEscaped:o,suffix:l,suffixEscaped:c,formatSeparator:u,unescapeSuffix:d,unescapePrefix:f,nestingPrefix:p,nestingPrefixEscaped:m,nestingSuffix:x,nestingSuffixEscaped:b,nestingOptionsSeparator:y,maxReplaces:v,alwaysFormat:S}=e.interpolation;this.escape=n!==void 0?n:Gae,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=a?mp(a):o||"{{",this.suffix=l?mp(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=p?mp(p):m||mp("$t("),this.nestingSuffix=x?mp(x):b||mp(")"),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 a,o,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=m=>{if(m.indexOf(this.formatSeparator)<0){const v=nz(n,c,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(v,void 0,r,{...i,...n,interpolationkey:m}):v}const x=m.split(this.formatSeparator),b=x.shift().trim(),y=x.join(this.formatSeparator).trim();return this.format(nz(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:m=>Wk(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?Wk(this.escape(m)):Wk(m)}].forEach(m=>{for(l=0;a=m.regex.exec(e);){const x=a[1].trim();if(o=u(x),o===void 0)if(typeof d=="function"){const y=d(e,a,i);o=fn(y)?y:""}else if(i&&Object.prototype.hasOwnProperty.call(i,x))o="";else if(f){o=a[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),o="";else!fn(o)&&!this.useRawValueToEscape&&(o=WU(o));const b=m.safeValue(o);if(e=e.replace(a[0],b),f?(m.regex.lastIndex+=o.length,m.regex.lastIndex-=a[0].length):m.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,a,o;const l=(c,u)=>{const d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const f=c.split(new RegExp(`${d}[ ]*{`));let p=`{${f[1]}`;c=f[0],p=this.interpolate(p,o);const m=p.match(/'/g),x=p.match(/"/g);((m?.length??0)%2===0&&!x||x.length%2!==0)&&(p=p.replace(/'/g,'"'));try{o=JSON.parse(p),u&&(o={...u,...o})}catch(b){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,b),`${c}${d}${p}`}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)),a=n(l.call(this,i[1].trim(),o),o),a&&i[0]===e&&!fn(a))return a;fn(a)||(a=WU(a)),a||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),a=""),c.length&&(a=c.reduce((d,f)=>this.format(d,f,r.lng,{...r,interpolationkey:i[1].trim()}),a.trim())),e=e.replace(i[0],a),this.regexp.lastIndex=0}return e}}const ese=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}},rz=t=>{const e={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});const o=r+JSON.stringify(a);let l=e[o];return l||(l=t(B0(r),i),e[o]=l),l(n)}},tse=t=>(e,n,r)=>t(B0(n),r)(e);class nse{constructor(e={}){this.logger=sc.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?rz:tse;this.formats={number:r((i,a)=>{const o=new Intl.NumberFormat(i,{...a});return l=>o.format(l)}),currency:r((i,a)=>{const o=new Intl.NumberFormat(i,{...a,style:"currency"});return l=>o.format(l)}),datetime:r((i,a)=>{const o=new Intl.DateTimeFormat(i,{...a});return l=>o.format(l)}),relativetime:r((i,a)=>{const o=new Intl.RelativeTimeFormat(i,{...a});return l=>o.format(l,a.range||"day")}),list:r((i,a)=>{const o=new Intl.ListFormat(i,{...a});return l=>o.format(l)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=rz(n)}format(e,n,r,i={}){const a=n.split(this.formatSeparator);if(a.length>1&&a[0].indexOf("(")>1&&a[0].indexOf(")")<0&&a.find(l=>l.indexOf(")")>-1)){const l=a.findIndex(c=>c.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,l)].join(this.formatSeparator)}return a.reduce((l,c)=>{const{formatName:u,formatOptions:d}=ese(c);if(this.formats[u]){let f=l;try{const p=i?.formatParams?.[i.interpolationkey]||{},m=p.locale||p.lng||i.locale||i.lng||r;f=this.formats[u](l,m,{...d,...i,...p})}catch(p){this.logger.warn(p)}return f}else this.logger.warn(`there was no format function for ${u}`);return l},e)}}const rse=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class ise extends t2{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=sc.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,i.backend,i)}queueLoad(e,n,r,i){const a={},o={},l={},c={};return e.forEach(u=>{let d=!0;n.forEach(f=>{const p=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?o[p]===void 0&&(o[p]=!0):(this.state[p]=1,d=!1,o[p]===void 0&&(o[p]=!0),a[p]===void 0&&(a[p]=!0),c[f]===void 0&&(c[f]=!0)))}),d||(l[u]=!0)}),(Object.keys(a).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(a),pending:Object.keys(o),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(e,n,r){const i=e.split("|"),a=i[0],o=i[1];n&&this.emit("failedLoading",a,o,n),!n&&r&&this.store.addResourceBundle(a,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=>{$ae(c.loaded,[a],o),rse(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,a=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:a,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,a*2,o)},a);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 a=this.queueLoad(e,n,r,i);if(!a.toLoad.length)return a.pending.length||i(),null;a.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],a=r[1];this.read(i,a,"read",void 0,void 0,(o,l)=>{o&&this.logger.warn(`${n}loading namespace ${a} for language ${i} failed`,o),!o&&l&&this.logger.log(`${n}loaded namespace ${a} for language ${i}`,l),this.loaded(e,o,l)})}saveMissing(e,n,r,i,a,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:a},u=this.backend.create.bind(this.backend);if(u.length<6)try{let d;u.length===5?d=u(e,n,r,i,c):d=u(e,n,r,i),d&&typeof d.then=="function"?d.then(f=>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 iz=()=>({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}),az=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),Cw=()=>{},ase=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class b0 extends t2{constructor(e={},n){if(super(),this.options=az(e),this.services={},this.logger=sc,this.modules={external:[]},ase(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=iz();this.options={...r,...this.options,...az(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?sc.init(i(this.modules.logger),this.options):sc.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=nse;const d=new JU(this.options);this.store=new QU(this.options.resources,this.options);const f=this.services;f.logger=sc,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new Zae(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 Jae(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new ise(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(m,...x)=>{this.emit(m,...x)}),this.modules.languageDetector&&(f.languageDetector=i(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=i(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new B1(this.services,this.options),this.translator.on("*",(m,...x)=>{this.emit(m,...x)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,n||(n=Cw),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=Ab(),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=Cw){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 a=[],o=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(u=>{u!=="cimode"&&a.indexOf(u)<0&&a.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(a,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(e,n,r){const i=Ab();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=Cw),this.services.backendConnector.reload(e,n,a=>{i.resolve(),r(a)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&wq.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=Ab();this.emit("languageChanging",e);const i=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},a=(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=>{a(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=(a,o,...l)=>{let c;typeof o!="object"?c=this.options.overloadTranslationOptionHandler([a,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(a)?d=a.map(f=>(typeof f=="function"&&(f=Qj(f,{...this.options,...o})),`${c.keyPrefix}${u}${f}`)):(typeof a=="function"&&(a=Qj(a,{...this.options,...o})),d=c.keyPrefix?`${c.keyPrefix}${u}${a}`:a),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,a=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(a,e)))}loadNamespaces(e,n){const r=Ab();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=Ab();fn(e)&&(e=[e]);const i=this.options.preload||[],a=e.filter(o=>i.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return a.length?(this.options.preload=i.concat(a),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 a=i.getTextInfo();if(a&&a.direction)return a.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services?.languageUtils||new JU(iz());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=Cw){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},a=new b0(i);if((e.debug!==void 0||e.prefix!==void 0)&&(a.logger=a.logger.clone(e)),["store","services","language"].forEach(l=>{a[l]=this[l]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},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),{});a.store=new QU(l,i),a.services.resourceStore=a.store}return a.translator=new B1(a.services,i),a.translator.on("*",(l,...c)=>{a.emit(l,...c)}),a.init(i,n),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const _s=b0.createInstance();_s.createInstance;_s.dir;_s.init;_s.loadResources;_s.reloadResources;_s.use;_s.changeLanguage;_s.getFixedT;_s.t;_s.exists;_s.setDefaultNamespace;_s.hasLoadedNamespace;_s.loadNamespaces;_s.loadLanguages;const sse=(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)},sz={},Sq=(t,e,n,r)=>{em(n)&&sz[n]||(em(n)&&(sz[n]=new Date),sse(t,e,n,r))},Nq=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},Zj=(t,e,n)=>{t.loadNamespaces(e,Nq(t,n))},oz=(t,e,n,r)=>{if(em(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return Zj(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,Nq(t,r))},ose=(t,e,n={})=>!e.languages||!e.languages.length?(Sq(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",lse=t=>typeof t=="object"&&t!==null,cse=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,use={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},dse=t=>use[t],hse=t=>t.replace(cse,dse);let Jj={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:hse};const fse=(t={})=>{Jj={...Jj,...t}},mse=()=>Jj;let Mq;const pse=t=>{Mq=t},gse=()=>Mq,xse={type:"3rdParty",init(t){fse(t.options.react),pse(t)}},bse=_.createContext();class yse{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var Kk={exports:{}},Xk={};var lz;function vse(){if(lz)return Xk;lz=1;var t=px();function e(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,a=t.useLayoutEffect,o=t.useDebugValue;function l(f,p){var m=p(),x=r({inst:{value:m,getSnapshot:p}}),b=x[0].inst,y=x[1];return a(function(){b.value=m,b.getSnapshot=p,c(b)&&y({inst:b})},[f,m,p]),i(function(){return c(b)&&y({inst:b}),f(function(){c(b)&&y({inst:b})})},[f]),o(m),m}function c(f){var p=f.getSnapshot;f=f.value;try{var m=p();return!n(f,m)}catch{return!0}}function u(f,p){return p()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:l;return Xk.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,Xk}var cz;function Eq(){return cz||(cz=1,Kk.exports=vse()),Kk.exports}var fR=Eq();const wse=(t,e)=>em(e)?e:lse(e)&&em(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,_se={t:wse,ready:!1},Sse=()=>()=>{},$n=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=_.useContext(bse)||{},a=n||r||gse();a&&!a.reportNamespaces&&(a.reportNamespaces=new yse),a||Sq(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=_.useMemo(()=>({...mse(),...a?.options?.react,...e}),[a,e]),{useSuspense:l,keyPrefix:c}=o,u=i||a?.options?.defaultNS,d=em(u)?[u]:u||["translation"],f=_.useMemo(()=>d,d);a?.reportNamespaces?.addUsedNamespaces?.(f);const p=_.useRef(0),m=_.useCallback(A=>{if(!a)return Sse;const{bindI18n:D,bindI18nStore:U}=o,F=()=>{p.current+=1,A()};return D&&a.on(D,F),U&&a.store.on(U,F),()=>{D&&D.split(" ").forEach(H=>a.off(H,F)),U&&U.split(" ").forEach(H=>a.store.off(H,F))}},[a,o]),x=_.useRef(),b=_.useCallback(()=>{if(!a)return _se;const A=!!(a.isInitialized||a.initializedStoreOnce)&&f.every($=>ose($,a,o)),D=e.lng||a.language,U=p.current,F=x.current;if(F&&F.ready===A&&F.lng===D&&F.keyPrefix===c&&F.revision===U)return F;const j={t:a.getFixedT(D,o.nsMode==="fallback"?f:f[0],c),ready:A,lng:D,keyPrefix:c,revision:U};return x.current=j,j},[a,f,c,o,e.lng]),[y,v]=_.useState(0),{t:S,ready:M}=fR.useSyncExternalStore(m,b,b);_.useEffect(()=>{if(a&&!M&&!l){const A=()=>v(D=>D+1);e.lng?oz(a,e.lng,f,A):Zj(a,f,A)}},[a,e.lng,f,M,l,y]);const T=a||{},E=_.useRef(null),C=_.useRef(),k=A=>{const D=Object.getOwnPropertyDescriptors(A);D.__original&&delete D.__original;const U=Object.create(Object.getPrototypeOf(A),D);if(!Object.prototype.hasOwnProperty.call(U,"__original"))try{Object.defineProperty(U,"__original",{value:A,writable:!1,enumerable:!1,configurable:!1})}catch{}return U},R=_.useMemo(()=>{const A=T,D=A?.language;let U=A;A&&(E.current&&E.current.__original===A?C.current!==D?(U=k(A),E.current=U,C.current=D):U=E.current:(U=k(A),E.current=U,C.current=D));const F=[S,U,M];return F.t=S,F.i18n=U,F.ready=M,F},[S,T,M,T.resolvedLanguage,T.language,T.languages]);if(a&&l&&!M)throw new Promise(A=>{const D=()=>A();e.lng?oz(a,e.lng,f,D):Zj(a,f,D)});return R},{slice:Nse,forEach:Mse}=[];function Ese(t){return Mse.call(Nse.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function kse(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 uz=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Tse=function(t,e){const r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},i=encodeURIComponent(e);let a=`${t}=${i}`;if(r.maxAge>0){const o=r.maxAge-0;if(Number.isNaN(o))throw new Error("maxAge should be a Number");a+=`; Max-Age=${Math.floor(o)}`}if(r.domain){if(!uz.test(r.domain))throw new TypeError("option domain is invalid");a+=`; Domain=${r.domain}`}if(r.path){if(!uz.test(r.path))throw new TypeError("option path is invalid");a+=`; Path=${r.path}`}if(r.expires){if(typeof r.expires.toUTCString!="function")throw new TypeError("option expires is invalid");a+=`; Expires=${r.expires.toUTCString()}`}if(r.httpOnly&&(a+="; HttpOnly"),r.secure&&(a+="; Secure"),r.sameSite)switch(typeof r.sameSite=="string"?r.sameSite.toLowerCase():r.sameSite){case!0:a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;case"none":a+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return r.partitioned&&(a+="; Partitioned"),a},dz={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=Tse(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 Ase={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return dz.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=e;n&&typeof document<"u"&&dz.create(n,t,r,i,a)}},Cse={name:"querystring",lookup(t){let{lookupQuerystring:e}=t,n;if(typeof window<"u"){let{search:r}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));const a=r.substring(1).split("&");for(let o=0;o<a.length;o++){const l=a[o].indexOf("=");l>0&&a[o].substring(0,l)===e&&(n=a[o].substring(l+1))}}return n}},jse={name:"hash",lookup(t){let{lookupHash:e,lookupFromHashIndex:n}=t,r;if(typeof window<"u"){const{hash:i}=window.location;if(i&&i.length>2){const a=i.substring(1);if(e){const o=a.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 pp=null;const hz=()=>{if(pp!==null)return pp;try{if(pp=typeof window<"u"&&window.localStorage!==null,!pp)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{pp=!1}return pp};var Pse={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&hz())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&hz()&&window.localStorage.setItem(n,t)}};let gp=null;const fz=()=>{if(gp!==null)return gp;try{if(gp=typeof window<"u"&&window.sessionStorage!==null,!gp)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{gp=!1}return gp};var Dse={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&fz())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&fz()&&window.sessionStorage.setItem(n,t)}},Rse={name:"navigator",lookup(t){const e=[];if(typeof navigator<"u"){const{languages:n,userLanguage:r,language:i}=navigator;if(n)for(let a=0;a<n.length;a++)e.push(n[a]);r&&e.push(r),i&&e.push(i)}return e.length>0?e:void 0}},Ose={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}},Lse={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}},Fse={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 kq=!1;try{document.cookie,kq=!0}catch{}const Tq=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];kq||Tq.splice(1,1);const Ise=()=>({order:Tq,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class Aq{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=Ese(n,this.options||{},Ise()),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(Ase),this.addDetector(Cse),this.addDetector(Pse),this.addDetector(Dse),this.addDetector(Rse),this.addDetector(Ose),this.addDetector(Lse),this.addDetector(Fse),this.addDetector(jse)}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&&!kse(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)}))}}Aq.type="languageDetector";const Use={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}}",updateAvailableBanner:"Version {{version}} is available!",viewUpdate:"View update",viewOnGithub:"View on GitHub",keyboardShortcuts:"Keyboard shortcuts (?)",switchToLight:"Switch to light mode",switchToDark:"Switch to dark mode",smartSwitches:"Smart Switches",logout:"Logout"},common:{save:"Save",saving:"Saving...",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",days:"days",enable:"Enable",disable:"Disable",permissions:"Permissions",noPrinters:"No printers configured",noData:"No data available",linkNotFound:"Link not found",required:"Required",optional:"Optional",dismiss:"Dismiss",apply:"Apply",reset:"Reset",clear:"Clear",selectAll:"Select All",deselectAll:"Deselect All",noChange:"— No change —",unchanged:"Unchanged",unassigned:"Unassigned",unknown:"Unknown",unknownError:"Unknown error",today:"Today",asap:"ASAP",overdue:"Overdue",now:"Now",collapse:"Collapse",expand:"Expand",viewArchive:"View archive",viewInFileManager:"View in File Manager",addedBy:"Added by {{username}}",prints:"prints",more:"+{{count}} more",ascending:"Ascending",descending:"Descending",printer:"Printer",remove:"Remove",type:"Type",print:"Print",rename:"Rename",move:"Move",create:"Create",duplicate:"Duplicate",left:"Left",right:"Right"},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",sort:{name:"Name",status:"Status",model:"Model",location:"Location",ascending:"Sort ascending",descending:"Sort descending"},cardSize:{small:"Small cards",medium:"Medium cards",large:"Large cards",extraLarge:"Extra large cards"},hideOffline:"Hide offline",powerOn:"Power On",offlinePrintersWithPlugs:"Offline printers with smart plugs",noPrintersConfigured:"No printers configured yet",readyToPrint:"Ready to print",external:"External",deleteArchives:"Delete print archives",noLabel:"No label",printPreview:"Print preview",width:"Width",height:"Height",noObjectsFound:"No objects found",objectsLoadedOnPrintStart:"Objects are loaded when a print starts",willBeSkipped:"Will be skipped",name:"Name",serialCannotBeChanged:"Serial number cannot be changed",locationHelp:"Used to group printers and filter queue jobs",wifiSignal:{veryWeak:"Very weak",weak:"Weak",fair:"Fair",good:"Good",excellent:"Excellent"},maintenanceUpToDate:"All maintenance up to date - Click to view",chamberLightOn:"Turn on chamber light",chamberLightOff:"Turn off chamber light",browseFiles:"Browse printer files",autoOffAfterPrint:"Auto power-off after print",autoOffExecuted:"Auto-off was executed - turn printer on to reset",hmsErrors:"HMS Errors",viewHmsErrors:"View {{count}} HMS error(s)",resume:"Resume",pause:"Pause",stop:"Stop",camera:"Camera",skipObject:"Skip Object",reconnect:"Reconnect",mqttDebug:"MQTT Debug",activeNozzle:"Active: {{nozzle}} nozzle",firmwareUpdate:"Firmware Update",firmwareInstructions:"On the printer's touchscreen, go to",firmwareNav:"Navigate to",settings:"Settings",firmware:"Firmware",discoverPrinters:"Discover Printers",searching:"Searching...",manualEntry:"Manual Entry",addFromCloud:"Add from Cloud",toast:{printerDeleted:"Printer deleted",printerAdded:"Printer added",printerUpdated:"Printer updated",failedToDelete:"Failed to delete printer",failedToAdd:"Failed to add printer",failedToUpdate:"Failed to update printer",commandSent:"Command sent",failedToSendCommand:"Failed to send command",turnedOn:"{{name}} turned on",failedToPowerOn:"Failed to power on {{name}}",scriptTriggered:"Script triggered",printStopped:"Print stopped",printPaused:"Print paused",printResumed:"Print resumed",referenceDeleted:"Reference deleted",detectionAreaSaved:"Detection area saved",failedToRunScript:"Failed to run script",failedToStopPrint:"Failed to stop print",failedToPausePrint:"Failed to pause print",failedToResumePrint:"Failed to resume print",failedToControlChamberLight:"Failed to control chamber light",failedToUpdateSetting:"Failed to update setting",failedToSkipObjects:"Failed to skip objects",failedToRereadRfid:"Failed to re-read RFID",failedToCheckPlate:"Failed to check plate",failedToUpdateLabel:"Failed to update label",failedToDeleteReference:"Failed to delete reference",failedToSaveDetectionArea:"Failed to save detection area",plateCheckEnabled:"Plate check enabled",plateCheckDisabled:"Plate check disabled",calibrationSaved:"Calibration saved!",calibrationFailed:"Calibration failed",rfidRereadInitiated:"RFID re-read initiated"},connection:{connected:"Connected",offline:"Offline"},queue:{inQueue:"{{count}} print in queue",inQueue_plural:"{{count}} prints in queue"},controls:"Controls",rfid:{reread:"Re-read RFID"},permission:{noAdd:"You do not have permission to add printers",noEdit:"You do not have permission to edit printers",noDelete:"You do not have permission to delete printers",noControl:"You do not have permission to control printers",noFiles:"You do not have permission to access printer files",noAmsRfid:"You do not have permission to re-read AMS RFID",noSmartPlugControl:"You do not have permission to control smart plugs"},modal:{addTitle:"Add Printer",editTitle:"Edit Printer",myPrinter:"My Printer",selectModel:"Select model...",locationGroup:"Location / Group (optional)",locationPlaceholder:"e.g., Workshop, Office, Basement",autoArchiveLabel:"Auto-archive completed prints",fromPrinterSettings:"From printer settings",modelOptional:"Model (optional)",saveChanges:"Save Changes"},skipObjects:{tooltip:"Skip objects",onlyWhilePrinting:"Skip objects (only while printing)",requiresMultiple:"Skip objects (requires 2+ objects)",title:"Skip Objects",matchIdsInfo:"Match IDs with your printer display",printerShowsIds:"The printer screen shows object IDs on the build plate",skipSelected:"Skip Selected",skipping:"Skipping...",noObjectsSelected:"No objects selected",selectObjectsToSkip:"Select objects you want to skip from the current print",skipped:"skipped",objectsSkipped:"Objects skipped",activeCount:"{{count}} active",waitForLayer:"Wait for layer 2+ to skip objects (currently layer {{layer}})",skip:"Skip"},confirm:{deleteTitle:"Delete Printer",deleteMessage:'Are you sure you want to delete "{{name}}"? This will remove all connection settings.',deleteArchivesNote:"All print history for this printer will be permanently deleted.",keepArchivesNote:"Print history will be kept but no longer associated with this printer.",stopTitle:"Stop Print",stopMessage:'Are you sure you want to stop the current print on "{{name}}"? This will cancel the print job.',stopButton:"Stop Print",pauseTitle:"Pause Print",pauseMessage:'Are you sure you want to pause the current print on "{{name}}"?',pauseButton:"Pause Print",resumeTitle:"Resume Print",resumeMessage:'Are you sure you want to resume the print on "{{name}}"?',resumeButton:"Resume Print",powerOnTitle:"Power On Printer",powerOnMessage:'Are you sure you want to turn ON the power for "{{name}}"?',powerOnButton:"Power On",powerOffTitle:"Power Off Printer",powerOffMessage:'Are you sure you want to turn OFF the power for "{{name}}"?',powerOffWarning:'WARNING: "{{name}}" is currently printing! Are you sure you want to turn OFF the power? This will interrupt the print and may damage the printer.',powerOffButton:"Power Off"},discovery:{title:"Discover Printers",searching:"Searching...",scanning:"Scanning...",scanProgress:"Scanning... {{scanned}}/{{total}}",foundPrinters:"Found {{count}} printer(s)",noPrintersFound:"No printers found",noPrintersFoundSubnet:"No printers found in the specified subnet.",noPrintersFoundNetwork:"No printers found on the network.",allConfigured:"All discovered printers are already configured.",alreadyAdded:"Already added",select:"Select",manualEntry:"Manual Entry",addFromCloud:"Add from Cloud",subnetToScan:"Subnet to scan",dockerNote:"Docker detected. Enter your printer's subnet in CIDR notation. Requires network_mode: host in docker-compose.yml.",scanSubnet:"Scan Subnet for Printers",discoverNetwork:"Discover Printers on Network",scanningSubnet:"Scanning subnet for Bambu printers...",scanningNetwork:"Scanning network...",serialRequired:"Serial required",unknown:"Unknown",failedToStart:"Failed to start discovery"},filaments:"Filaments",openCameraOverlay:"Open camera overlay",openCameraWindow:"Open camera in new window",firmwareUpdateAvailable:"Firmware update available: {{current}} → {{latest}}",firmwareUpdateButton:"Update",plateDetection:{noPermission:"You do not have permission to update printers",enabledClick:"Plate check enabled - Click to disable",disabledClick:"Plate check disabled - Click to enable",manageCalibration:"Manage plate detection calibration",calibrationRequired:"Calibration Required",calibrationInstructions:"Please ensure the build plate is <strong>completely empty</strong>, then click Calibrate.",calibrationDescription:"Calibration captures a reference image of the empty plate. Future checks will compare against this reference to detect objects.",calibrationTip:"<strong>Tip:</strong> You can store up to 5 calibrations for different plates. The system automatically uses the best match when checking.",plateEmpty:"Plate appears empty",objectsDetected:"Objects detected on plate",confidence:"Confidence",difference:"Difference",analysisPreview:"Analysis preview:",analysisLegend:"Green box = detection area, Red overlay = differences from calibration",savedReferences:"Saved References ({{count}}/{{max}})",deleteReference:"Delete reference",labelPlaceholder:"Label...",clickToEdit:"{{label}} - Click to edit",clickToAddLabel:"Click to add label"},fans:{partCooling:"Part Cooling Fan",auxiliary:"Auxiliary Fan",chamber:"Chamber Fan"},clickToViewHmsErrors:"Click to view HMS errors",estimatedCompletion:"Estimated completion time",slotOptions:"Slot options",firmwareModal:{title:"Firmware Update",currentVersion:"Current:",latestVersion:"Latest:",releaseNotes:"Release Notes",checkingPrereqs:"Checking prerequisites...",sdCardReady:"SD card ready. Click below to upload firmware.",uploadedSuccess:"Firmware uploaded to SD card!",applyInstructions:"To apply the update on your printer:",step1:"On the printer's touchscreen, go to <strong>Settings</strong>",step2:"Navigate to <strong>Firmware</strong>",step3:"Select <strong>Update from SD card</strong>",step4:"The update will take 10-20 minutes",done:"Done",starting:"Starting...",uploadFirmware:"Upload Firmware",uploadedToast:"Firmware uploaded! Trigger update from printer screen."},accessCodePlaceholder:"Leave empty to keep current",roi:{title:"Detection Area (ROI)",xStart:"X Start",yStart:"Y Start",width:"Width",height:"Height",instruction:"Adjust the detection area to focus on the build plate. The green box in the preview shows the current area."}},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",sortLargest:"Largest first",sortSmallest:"Smallest first",sortSize:"Size",noArchives:"No archives found",noArchivesSearch:"No archives match your search",noArchivesYet:"No archives yet",loadingArchives:"Loading archives...",releaseToUpload:"Release to upload",showAll:"Show all",showFavoritesOnly:"Show favorites only",gridView:"Grid view",listView:"List view",calendarView:"Calendar view",manageTags:"Manage Tags",showFailedPrints:"Show failed prints",hideFailedPrints:"Hide failed prints",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"},toast:{source3mfAttached:"Source 3MF attached: {{filename}}",failedUploadSource3mf:"Failed to upload source 3MF",source3mfRemoved:"Source 3MF removed",failedRemoveSource3mf:"Failed to remove source 3MF",f3dAttached:"F3D attached: {{filename}}",failedUploadF3d:"Failed to upload F3D",f3dRemoved:"F3D removed",failedRemoveF3d:"Failed to remove F3D",timelapseAttached:"Timelapse attached: {{filename}}",timelapseAlreadyAttached:"Timelapse already attached",noMatchingTimelapse:"No matching timelapse found",failedScanTimelapse:"Failed to scan for timelapse",failedAttachTimelapse:"Failed to attach timelapse",archiveDeleted:"Archive deleted",failedDeleteArchive:"Failed to delete archive",addedToFavorites:"Added to favorites",removedFromFavorites:"Removed from favorites",projectUpdated:"Project updated",failedUpdateProject:"Failed to update project",linkCopied:"Link copied to clipboard",failedCopyLink:"Failed to copy link",photoDeleted:"Photo deleted",failedDeletePhoto:"Failed to delete photo",failedDeleteArchives:"Failed to delete archives",failedUpdateFavorites:"Failed to update favorites",exportDownloaded:"Export downloaded",exportFailed:"Export failed"},menu:{print:"Print",schedule:"Schedule",openInBambuStudio:"Open in Bambu Studio",slice:"Slice",externalLink:"External Link",viewOnMakerWorld:"View on MakerWorld",preview3d:"3D Preview",viewTimelapse:"View Timelapse",scanForTimelapse:"Scan for Timelapse",downloadSource3mf:"Download Source 3MF",uploadSource3mf:"Upload Source 3MF",replaceSource3mf:"Replace Source 3MF",removeSource3mf:"Remove Source 3MF",uploadF3d:"Upload F3D",replaceF3d:"Replace F3D",downloadF3d:"Download F3D",removeF3d:"Remove F3D",download:"Download",copyDownloadLink:"Copy Download Link",qrCode:"QR Code",viewPhotos:"View Photos",viewPhotosCount:"View Photos ({{count}})",projectPage:"Project Page",addToFavorites:"Add to Favorites",removeFromFavorites:"Remove from Favorites",edit:"Edit",goToProject:"Go to Project: {{name}}",addToProject:"Add to Project",removeFromProject:"Remove from Project",loading:"Loading...",noProjectsAvailable:"No projects available",select:"Select",deselect:"Deselect",delete:"Delete"},permission:{noReprint:"You do not have permission to reprint this archive",noAddToQueue:"You do not have permission to add to queue",noUpdateArchives:"You do not have permission to update archives",noUploadFiles:"You do not have permission to upload files",noDownload:"You do not have permission to download archives",noCopyLink:"You do not have permission to copy download links",noDelete:"You do not have permission to delete this archive",noCreate:"You do not have permission to create archives"},card:{previousPlate:"Previous plate",nextPlate:"Next plate",plateNumber:"Plate {{index}}",moreOptions:"Right-click for more options",addToFavorites:"Add to favorites",removeFromFavorites:"Remove from favorites",cancelled:"cancelled",failed:"failed",duplicate:"duplicate",duplicateTitle:"This model has been printed before",openSource3mf:"Open source 3MF in Bambu Studio (right-click for more options)",downloadF3d:"Download Fusion 360 design file",viewTimelapse:"View timelapse",viewPhoto:"View 1 photo",viewPhotos:"View {{count}} photos",openFolder:"Open folder: {{name}}",slicedFile:"Sliced file - ready to print",sourceFile:"Source file only - no AMS mapping available",gcode:"GCODE",source:"SOURCE",project:"Project: {{name}}",estimated:"Estimated: {{time}}",actual:"Actual: {{time}}",accuracy:"Accuracy: {{percent}}%",filament:"{{weight}}g",layer:"{{count}} layer",layers:"{{count}} layers",object:"{{count}} object",objects:"{{count}} objects",slicedFor:"Sliced for {{model}}",uploadedBy:"Uploaded by {{name}}",noPermissionReprint:"You do not have permission to reprint",noPermissionEdit:"You do not have permission to edit archives",noPermissionDelete:"You do not have permission to delete archives",reprint:"Reprint",schedulePrint:"Schedule Print",schedule:"Schedule",openInBambuStudio:"Open in Bambu Studio",openInBambuStudioToSlice:"Open in Bambu Studio to slice",slice:"Slice",externalLink:"External Link",makerWorld:"MakerWorld: {{designer}}",viewProject:"View project",noExternalLink:"No external link",preview3d:"3D Preview",download:"Download",edit:"Edit",delete:"Delete"},modal:{deleteArchive:"Delete Archive",deleteConfirm:'Are you sure you want to delete "{{name}}"? This action cannot be undone.',deleteButton:"Delete",removeSource3mf:"Remove Source 3MF",removeSource3mfConfirm:'Are you sure you want to remove the source 3MF file from "{{name}}"? This will delete the original slicer project file.',removeButton:"Remove",removeF3d:"Remove F3D",removeF3dConfirm:'Are you sure you want to remove the Fusion 360 design file from "{{name}}"?',timelapse:"{{name}} - Timelapse",selectTimelapse:"Select Timelapse",selectTimelapseDesc:"No auto-match found. Select the timelapse for this print:",deleteArchives:"Delete Archives",deleteArchivesConfirm:"Are you sure you want to delete {{count}} archive(s)? This action cannot be undone.",deleteCount:"Delete {{count}}"},page:{title:"Archives",printsCount:"{{filtered}} of {{total}} prints",dropFilesHere:"Drop .3mf files here",releaseToUpload:"Release to upload",only3mfSupported:"Only .3mf files are supported",close:"Close",selected:"{{count}} selected",selectAll:"Select All",tags:"Tags",project:"Project",favorite:"Favorite",delete:"Delete",toggledFavorites:"Toggled favorites for {{count}} archive(s)",failedUpdateFavorites:"Failed to update favorites",archivesDeleted:"{{count}} archive(s) deleted",failedDeleteArchives:"Failed to delete archives",photoDeleted:"Photo deleted",failedDeletePhoto:"Failed to delete photo"},list:{name:"Name",printer:"Printer",date:"Date",size:"Size",actions:"Actions",hasTimelapse:"Has timelapse"}},queue:{title:"Print Queue",subtitle:"Schedule and manage your print jobs",addToQueue:"Add to Queue",print:"Print",reprint:"Re-print",schedulePrint:"Schedule Print",editQueueItem:"Edit Queue Item",printToPrinters:"Print to {{count}} Printers",queueToPrinters:"Queue to {{count}} Printers",sending:"Sending...",sendingProgress:"Sending {{current}}/{{total}}...",adding:"Adding...",addingProgress:"Adding {{current}}/{{total}}...",savingProgress:"Saving {{current}}/{{total}}...",clearQueue:"Clear Queue",clearHistory:"Clear History",emptyQueue:"Queue is empty",position:"Position",scheduledTime:"Scheduled Time",moveUp:"Move Up",moveDown:"Move Down",startNow:"Start Now",printingInProgress:"Printing in progress...",viewArchive:"View archive",viewInFileManager:"View in File Manager",itemCount:"{{count}} item",itemCount_plural:"{{count}} items",dragToReorder:"Drag to reorder (ASAP only)",reorderHint:"Position only affects ASAP items. Scheduled items run at their set time.",addedBy:"Added by {{name}}",sections:{currentlyPrinting:"Currently Printing",queued:"Queued",history:"History"},status:{pending:"Pending",waiting:"Waiting",printing:"Printing",completed:"Completed",failed:"Failed",skipped:"Skipped",cancelled:"Cancelled"},summary:{printing:"Printing",queued:"Queued",totalTime:"Total Queue Time",history:"History"},filter:{allPrinters:"All Printers",unassigned:"Unassigned",allStatus:"All Status",allLocations:"All Locations",any:"Any"},sort:{byPosition:"Sort by Position",byName:"Sort by Name",byPrinter:"Sort by Printer",bySchedule:"Sort by Schedule",byDate:"Sort by Date",ascendingOldest:"Ascending (oldest first)",descendingNewest:"Descending (newest first)"},badges:{staged:"Staged",requiresPrevious:"Requires previous success",autoPowerOff:"Auto power off"},empty:{title:"No prints scheduled",description:'Schedule a print from the Archives page using the "Schedule" option in the context menu, or drag and drop files to get started.'},time:{asap:"ASAP",overdue:"Overdue",now:"Now",lessThanMinute:"In less than a minute",inMinutes:"In {{count}} min",inHours:"In {{count}} hours"},actions:{stopPrint:"Stop Print",startPrint:"Start Print",requeue:"Re-queue"},bulkEdit:{title:"Edit {{count}} Item",title_plural:"Edit {{count}} Items",description:"Only changed settings will be applied to selected items.",printer:"Printer",noChange:"— No change —",queueOptions:"Queue Options",staged:"Staged (manual start)",autoPowerOff:"Auto power off after print",requirePrevious:"Require previous success",printOptions:"Print Options",bedLevelling:"Bed levelling",flowCalibration:"Flow calibration",vibrationCalibration:"Vibration calibration",layerInspection:"First layer inspection",timelapse:"Timelapse",useAms:"Use AMS",applyChanges:"Apply Changes",selectAll:"Select All",deselectAll:"Deselect All",selected:"{{count}} selected",editSelected:"Edit Selected",cancelSelected:"Cancel Selected"},confirm:{cancelTitle:"Cancel Scheduled Print",cancelMessage:'Are you sure you want to cancel "{{name}}"?',stopTitle:"Stop Print",stopMessage:'Are you sure you want to stop the current print "{{name}}"? This will cancel the print job on the printer.',removeTitle:"Remove from History",removeMessage:'Are you sure you want to remove "{{name}}" from the queue history?',clearHistoryTitle:"Clear History",clearHistoryMessage:"Are you sure you want to remove all {{count}} item(s) from the history?",cancelButton:"Cancel Print",stopButton:"Stop Print",thisPrint:"this print",thisItem:"this item"},toast:{cancelled:"Queue item cancelled",cancelFailed:"Failed to cancel item",removed:"Queue item removed",removeFailed:"Failed to remove item",stopped:"Print stopped",stopFailed:"Failed to stop print",released:"Print released to queue",startFailed:"Failed to start print",reorderFailed:"Failed to reorder queue",historyCleared:"Cleared {{count}} history item(s)",clearHistoryFailed:"Failed to clear history",updateFailed:"Failed to update items",bulkCancelled:"Cancelled {{count}} item(s)",bulkCancelFailed:"Failed to cancel items"},permissions:{noStopPrint:"You do not have permission to stop prints",noStartPrint:"You do not have permission to start prints",noEdit:"You do not have permission to edit this queue item",noCancel:"You do not have permission to cancel this queue item",noRequeue:"You do not have permission to re-queue items",noRemove:"You do not have permission to remove this queue item",noClearHistory:"You do not have permission to clear all history",noEditItems:"You do not have permission to edit queue items",noCancelItems:"You do not have permission to cancel queue items"}},stats:{title:"Dashboard",subtitle:"Drag widgets to rearrange. Click the eye icon to hide.",overview:"Overview",totalPrints:"Total Prints",successRate:"Success Rate",totalPrintTime:"Total Print Time",printTime:"Print Time",totalFilament:"Total Filament Used",filamentUsed:"Filament Used",filamentCost:"Filament Cost",totalCost:"Total Cost",energyUsed:"Energy Used",energyCost:"Energy Cost",averagePrintTime:"Average Print Time",printsPerDay:"Prints per Day",byPrinter:"By Printer",printsByPrinter:"Prints by Printer",byMaterial:"By Material",byMonth:"By Month",last7Days:"Last 7 Days",last30Days:"Last 30 Days",last90Days:"Last 90 Days",allTime:"All Time",quickStats:"Quick Stats",printActivity:"Print Activity",filamentTypes:"Filament Types",filamentTrends:"Filament Trends",failureAnalysis:"Failure Analysis",timeAccuracy:"Time Accuracy",successful:"Successful:",failed:"Failed:",perfectEstimate:"100% = perfect estimate",noTimeAccuracyData:"No time accuracy data yet",noFilamentData:"No filament data available",noPrinterData:"No printer data available",noPrintData:"No print data available",noPrintDataLast30Days:"No print data in the last 30 days",failureReasons:"Failure Reasons",topFailureReasons:"Top Failure Reasons",failedPrintsCount:"{{failed}} / {{total}} prints failed",lastWeekRate:"Last week: {{rate}}%",resetLayout:"Reset Layout",recalculateCosts:"Recalculate Costs",recalculateCostsHint:"Recalculate all archive costs using current filament prices",exportStats:"Export Stats",exportAsCsv:"Export as CSV",exportAsExcel:"Export as Excel",hiddenCount:"{{count}} Hidden",exportDownloaded:"Export downloaded",exportFailed:"Export failed",layoutReset:"Layout reset",recalculatedCosts:"Recalculated costs for {{count}} archives",recalculateFailed:"Failed to recalculate costs",loadingStats:"Loading statistics...",noPermissionResetLayout:"You do not have permission to reset layout",noPermissionRecalculate:"You do not have permission to recalculate costs"},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",statusTab:"Status",settingsTab:"Settings",overdueCount:"{{count}} overdue",dueSoonCount:"{{count}} due soon",dueSoon:"Due soon",allGood:"All good",overdueBy:"Overdue by {{duration}}",dueIn:"Due in {{duration}}",timeLeft:"{{duration}} left",day:"1 day",days:"{{count}} days",week:"1 week",weeks:"{{count}} weeks",month:"1 month",months:"{{count}} months",year:"1 year",maintenanceTypes:"Maintenance Types",maintenanceTypesDescription:"System types and your custom maintenance tasks",addCustomType:"Add Custom Type",intervalType:"Interval Type",intervalValue:"Interval ({{type}})",icon:"Icon",documentationLink:"Documentation Link (optional)",assignToPrinters:"Assign to Printers",selectAtLeastOnePrinter:"Select at least one printer",addType:"Add Type",custom:"Custom",printHours:"Print Hours",calendarDays:"Calendar Days",exampleName:"e.g., Replace HEPA Filter",viewDocumentation:"View documentation",timeBasedInterval:"Time-based interval",intervalOverrides:"Interval Overrides",intervalOverridesDescription:"Customize intervals for specific printers",assignedToPrinters:"Assigned to printers:",noPrintersAssigned:"No printers assigned",addPrinterShort:"Add:",printersAssignedClick:"{{count}} printer(s) assigned - click to manage",removeFromPrinter:"Remove from this printer",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",cleanCarbonRods:"Clean Carbon Rods",checkPtfeTube:"Check PTFE Tube",replaceHepaFilter:"Replace HEPA Filter",replaceCarbonFilter:"Replace Carbon Filter",lubricateLeftNozzleRail:"Lubricate Left Nozzle Rail"},maintenanceComplete:"Maintenance marked as complete",typeUpdated:"Maintenance type updated",typeDeleted:"Maintenance type deleted",printHoursUpdated:"Print hours updated",printerAssigned:"Printer assigned",printerRemoved:"Printer removed",deleteTypeConfirm:'Delete "{{name}}"?',noPermissionUpdate:"You do not have permission to update maintenance items",noPermissionPerform:"You do not have permission to perform maintenance",noPermissionEditTypes:"You do not have permission to edit maintenance types",noPermissionDeleteTypes:"You do not have permission to delete maintenance types",noPermissionEditHours:"You do not have permission to edit print hours",noPermissionRemovePrinter:"You do not have permission to remove printer assignments",noPermissionAssignPrinter:"You do not have permission to assign printers",noPermissionEditIntervals:"You do not have permission to edit intervals",configureSettings:"Configure maintenance types and intervals"},settings:{title:"Settings",general:"General",tabs:{general:"General",smartPlugs:"Smart Plugs",notifications:"Notifications",filament:"Filament",network:"Network",apiKeys:"API Keys",virtualPrinter:"Virtual Printer",users:"Users",backup:"Backup"},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",noDefaultPrinter:"No default (ask each time)",sidebarOrder:"Sidebar order",saveThumbnails:"Save thumbnails",captureFinishPhoto:"Capture finish photo",noPrintersConfigured:"No printers configured",archiveMode:{always:"Always create archive entry",never:"Never create archive entry",ask:"Ask each time"},checkForUpdatesLabel:"Check for updates",checkPrinterFirmware:"Check printer firmware",enableRetry:"Enable retry",homeAssistantDescription:"Control smart plugs via Home Assistant",mqttConnectedTo:"Connected to",prometheusDescription:"Expose printer data in Prometheus format",noSmartPlugsTitle:"No smart plugs configured",noSmartPlugsDescription:"Add a Tasmota-based smart plug to track energy usage and automate power control.",noProvidersTitle:"No providers configured",noProvidersDescription:"Add a provider to receive alerts.",noTemplatesAvailable:"No templates available. Restart the backend to seed default templates.",apiPermissionView:"View printer status and queue",apiPermissionEdit:"Add and remove items from print queue",apiKeysEmptyTitle:"No API keys",apiKeysEmptyDescription:"Create an API key to integrate with external services.",noUsersFound:"No users found",noGroupsFound:"No groups found",noGroupsAvailable:"No groups available",passwordsDoNotMatch:"Passwords do not match",systemGroupWarning:"System group names cannot be changed",authDisabledTitle:"Authentication is Disabled",authDisabledFeature1:"Require login to access the system",authDisabledFeature2:"Create multiple users with group-based permissions",authDisabledFeature3:"Control access with 50+ granular permissions",userHasCreated:"This user has created:",userItemsQuestion:"What would you like to do with these items?",deleteUserConfirm:"Are you sure you want to delete this user?",actionCannotBeUndone:"This action cannot be undone.",addFirstSmartPlug:"Add Your First Smart Plug",providers:"Providers",log:"Log",testAll:"Test All",testResults:"Test Results",testPassedCount:"{{count}} passed",testFailedCount:"{{count}} failed",messageTemplates:"Message Templates",messageTemplatesDescription:"Customize notification messages for each event.",apiKeys:"API Keys",apiKeysDescription:"Create API keys for external integrations and webhooks.",createKey:"Create Key",apiKeyCreated:"API Key Created Successfully",apiKeyCopyWarning:"Copy this key now - it won't be shown again!",useInApiBrowser:"Use in API Browser",createNewApiKey:"Create New API Key",keyName:"Key Name",keyNamePlaceholder:"e.g., Home Assistant, OctoPrint",readStatus:"Read Status",readStatusDescription:"View printer status and queue",manageQueue:"Manage Queue",manageQueueDescription:"Add and remove items from print queue",controlPrinter:"Control Printer",controlPrinterDescription:"Pause, resume, and stop prints",unnamedKey:"Unnamed Key",lastUsed:"Last used",read:"Read",control:"Control",createFirstKey:"Create Your First Key",webhookEndpoints:"Webhook Endpoints",webhookApiKeyHint:"Use your API key in the X-API-Key header.",webhook:{getAllStatus:"Get all printer status",getSpecificStatus:"Get specific printer status",addToQueue:"Add to print queue",pausePrint:"Pause print",resumePrint:"Resume print",stopPrint:"Stop print"},apiBrowser:"API Browser",apiBrowserDescription:"Explore and test all available API endpoints.",apiKeyForTesting:"API Key for Testing",apiKeyPlaceholder:"Paste your API key here to test authenticated endpoints...",apiKeyHint:"This key will be sent as X-API-Key header with requests.",deleteApiKeyTitle:"Delete API Key",deleteApiKeyMessage:"Are you sure you want to delete this API key? Any integrations using this key will stop working.",deleteKey:"Delete Key",amsDisplayThresholds:"AMS Display Thresholds",amsThresholdsDescription:"Configure color thresholds for AMS humidity and temperature indicators.",humidity:"Humidity",goodGreen:"Good (green)",fairOrange:"Fair (orange)",aboveFairBad:"Above fair threshold shows as red (bad)",temperature:"Temperature",goodBlue:"Good (blue)",aboveFairHot:"Above fair threshold shows as red (hot)",historyRetention:"History Retention",keepSensorHistory:"Keep sensor history for",historyRetentionDescription:"Older humidity and temperature data will be automatically deleted",printModal:"Print Modal",expandCustomMapping:"Expand custom mapping by default",expandCustomMappingDescription:"When printing to multiple printers, show per-printer AMS mapping expanded",authentication:"Authentication",authEnabledDescription:"Your instance is secured with user authentication",authDisabledDescription:"Enable to require login and manage user access",authDisabledMessage:"Enable authentication to create user accounts, manage permissions, and secure your Bambuddy instance.",enableAuthentication:"Enable Authentication",currentUser:"Current User",changePassword:"Change Password",admin:"Admin",users:"Users",addUser:"Add User",groups:"Groups",addGroup:"Add Group",system:"System",noDescription:"No description",userCount:"{{count}} users",permissionCount:"{{count}} permissions",createUser:"Create User",username:"Username",enterUsername:"Enter username",password:"Password",enterPassword:"Enter password (min 6 characters)",confirmPassword:"Confirm Password",confirmPasswordPlaceholder:"Confirm password",viewReleaseOnGitHub:"View release on GitHub",turnAllPlugsOn:"Turn all plugs on",turnAllPlugsOff:"Turn all plugs off",clearNotificationLogs:"Clear Notification Logs",clearLogsMessage:"This will permanently delete all notification logs older than 30 days. This action cannot be undone.",clearLogs:"Clear Logs",resetUiPreferences:"Reset UI Preferences",resetUiPreferencesMessage:"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.",resetPreferences:"Reset Preferences",deleteGroupTitle:"Delete Group",deleteGroupMessage:"Are you sure you want to delete this group? Users in this group will lose these permissions.",deleteGroup:"Delete Group",disableAuthenticationTitle:"Disable Authentication",disableAuthenticationMessage:"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.",disableAuthentication:"Disable Authentication",configureBambuddy:"Configure Bambuddy",systemDefault:"System Default",archiveSettings:"Archive Settings",newWindow:"New Window",embeddedOverlay:"Embedded Overlay",externalCameras:"External Cameras",costTracking:"Cost Tracking",printsOnly:"Prints Only",totalConsumption:"Total Consumption",dataManagement:"Data Management",clearNotificationLogsDescription:"Delete notification logs older than 30 days",resetUiPreferencesDescription:"Reset sidebar order, theme, view modes, and layout preferences. Printers, archives, and settings are not affected.",enableHomeAssistant:"Enable Home Assistant",enableMqtt:"Enable MQTT",useTls:"Use TLS",enableMetricsEndpoint:"Enable Metrics Endpoint",availableMetrics:"Available Metrics",editUser:"Edit User",deleteUserTitle:"Delete User",groupName:"Group Name",leaveEmptyForAnonymous:"Leave empty for anonymous",leaveEmptyForNoAuth:"Leave empty for no authentication",enterNewPassword:"Enter new password",confirmNewPassword:"Confirm new password",enterGroupName:"Enter group name",enterDescriptionOptional:"Enter description (optional)",enterCurrentPassword:"Enter current password",enterNewPasswordMin6:"Enter new password (min 6 characters)",toast:{keyCopied:"Key copied to clipboard",copyFailed:"Failed to copy key",keyAddedToBrowser:"Key added to API Browser",clearLogsFailed:"Failed to clear logs",uiPreferencesReset:"UI preferences reset. Refreshing...",authDisabled:"Authentication disabled successfully",authDisableFailed:"Failed to disable authentication",apiKeyCreated:"API key created",apiKeyDeleted:"API key deleted",userCreated:"User created successfully",userUpdated:"User updated successfully",userDeleted:"User deleted successfully",groupCreated:"Group created successfully",groupUpdated:"Group updated successfully",groupDeleted:"Group deleted successfully",fillRequiredFields:"Please fill in all required fields",passwordsDoNotMatch:"Passwords do not match",passwordTooShort:"Password must be at least 6 characters",enterGroupName:"Please enter a group name",settingsSaved:"Settings saved",cameraSettingsSaved:"Camera settings saved",enterCameraUrl:"Please enter a camera URL",passwordChanged:"Password changed successfully",connectionFailed:"Connection failed",testFailed:"Test failed",cameraConnected:"Camera connected{{resolution}}"},testConnection:"Test Connection"},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"},hmsErrors:{title:"Errors - {{name}}",noErrors:"No errors",viewOnWiki:"View on Bambu Lab Wiki",clearInstructions:"Clear errors on the printer to dismiss them here."},mqttDebug:{title:"MQTT Debug Log",searchPlaceholder:"Search topic or payload...",noMessages:"No messages logged yet",startLoggingHint:'Click "Start Logging" to begin capturing MQTT messages',noMessagesMatch:"No messages match your filter",adjustFilterHint:"Try adjusting your search or filter criteria",incoming:"Incoming",outgoing:"Outgoing",loggingStopped:"Logging stopped",loggingActive:"Logging active - messages will auto-refresh",startLogging:"Start Logging",stopLogging:"Stop Logging",clearLog:"Clear Log",topic:"Topic",timestamp:"Timestamp",direction:"Direction",all:"All"},printerFiles:{title:"File Manager",storageUsed:"Used:",storageFree:"Free:",filterPlaceholder:"Filter files...",deleteButton:"Delete",deleteFiles:"Delete {{count}} Files",deleteFileConfirm:'Delete "{{name}}"? This cannot be undone.',deleteFilesConfirm:"Delete {{count}} selected files? This cannot be undone.",noFiles:"No files on printer",loadingFiles:"Loading files...",failedToLoad:"Failed to load files",toast:{filesDeleted:"Deleted {{count}} file(s)",deleteFailed:"Delete failed: {{error}}"}},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?"},login:{title:"Bambuddy Login",subtitle:"Sign in to your account",username:"Username",usernamePlaceholder:"Enter your username",password:"Password",passwordPlaceholder:"Enter your password",signIn:"Sign in",signingIn:"Logging in...",forgotPassword:"Forgot your password?",loginSuccess:"Logged in successfully",loginFailed:"Login failed",enterCredentials:"Please enter username and password",forgotPasswordTitle:"Forgot Password",forgotPasswordMessage:"If you've forgotten your password, please contact your system administrator to reset it.",howToReset:"How to reset your password:",resetStep1:"Contact your Bambuddy administrator",resetStep2:"Ask them to reset your password in User Management",resetStep3:"They can set a new temporary password for you",resetStep4:"Log in with the new password and change it in Settings",gotIt:"Got it"},setup:{title:"Bambuddy Setup",subtitle:"Configure authentication for your Bambuddy instance",enableAuth:"Enable Authentication",adminAccount:"Admin Account",adminAccountDesc:"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.",adminUsername:"Admin Username",adminPassword:"Admin Password",optionalIfAdminExists:"(optional if admin users exist)",adminUsernamePlaceholder:"Enter admin username (optional)",adminPasswordPlaceholder:"Enter admin password (optional)",confirmPassword:"Confirm Password",confirmPasswordPlaceholder:"Confirm admin password",settingUp:"Setting up...",completeSetup:"Complete Setup",toast:{authEnabledAdminCreated:"Authentication enabled and admin user created",authEnabledExistingAdmins:"Authentication enabled using existing admin users",setupCompleted:"Setup completed",enterBothCredentials:"Please enter both admin username and password, or leave both empty to use existing admin users",passwordsDoNotMatch:"Passwords do not match",passwordTooShort:"Password must be at least 6 characters"}},changePassword:{title:"Change Password",currentPassword:"Current Password",currentPasswordPlaceholder:"Enter current password",newPassword:"New Password",newPasswordPlaceholder:"Enter new password (min 6 characters)",confirmPassword:"Confirm New Password",confirmPasswordPlaceholder:"Confirm new password",passwordsDoNotMatch:"Passwords do not match",passwordTooShort:"Password must be at least 6 characters",changing:"Changing...",success:"Password changed successfully",failed:"Failed to change password"},plateAlert:{title:"Print Paused!",message:"Objects detected on build plate. The print has been automatically paused. Please clear the plate and resume the print.",understand:"I Understand"},camera:{title:"Camera View",invalidPrinterId:"Invalid printer ID",live:"Live",snapshot:"Snapshot",restartStream:"Restart stream",refreshSnapshot:"Refresh snapshot",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",connectingToCamera:"Connecting to camera...",capturingSnapshot:"Capturing snapshot...",connectionLost:"Connection lost",connectionFailed:"Camera connection failed",reconnecting:"Reconnecting in {{countdown}}s... (attempt {{attempt}}/{{max}})",reconnectNow:"Reconnect now",cameraUnavailable:"Camera unavailable",cameraUnavailableDesc:"Make sure the printer is powered on and connected.",noCamera:"No camera available",retry:"Retry",cameraStream:"Camera stream",zoomOut:"Zoom out",zoomIn:"Zoom in",resetZoom:"Reset zoom",recording:"Recording",startRecording:"Start Recording",stopRecording:"Stop Recording"},groups:{title:"Group Management",subtitle:"Manage permission groups for access control",backToSettings:"Back to Settings",createGroup:"Create Group",noPermission:"You do not have permission to access this page.",system:"System",noDescription:"No description",usersCount:"{{count}} users",permissionsCount:"{{count}} permissions",edit:"Edit",delete:"Delete",toast:{created:"Group created successfully",updated:"Group updated successfully",deleted:"Group deleted successfully",enterGroupName:"Please enter a group name"},modal:{editGroup:"Edit Group",createGroup:"Create Group",cancel:"Cancel",saving:"Saving...",creating:"Creating...",saveChanges:"Save Changes"},form:{groupName:"Group Name",groupNamePlaceholder:"Enter group name",systemGroupWarning:"System group names cannot be changed",description:"Description",descriptionPlaceholder:"Enter description (optional)",permissions:"Permissions ({{count}} selected)"},deleteModal:{title:"Delete Group",message:"Are you sure you want to delete this group? Users in this group will lose these permissions.",confirm:"Delete Group"}},users:{title:"User Management",subtitle:"Manage users and their access to your Bambuddy instance",backToSettings:"Back to Settings",createUser:"Create User",noPermission:"You do not have permission to access this page.",admin:"Admin",noGroups:"No groups",active:"Active",inactive:"Inactive",edit:"Edit",delete:"Delete",system:"System",noGroupsAvailable:"No groups available",table:{username:"Username",groups:"Groups",status:"Status",actions:"Actions"},toast:{created:"User created successfully",updated:"User updated successfully",deleted:"User deleted successfully",fillRequired:"Please fill in all required fields",passwordsDoNotMatch:"Passwords do not match",passwordTooShort:"Password must be at least 6 characters"},modal:{createUser:"Create User",editUser:"Edit User",cancel:"Cancel",creating:"Creating...",saving:"Saving...",saveChanges:"Save Changes"},form:{username:"Username",usernamePlaceholder:"Enter username",password:"Password",passwordPlaceholder:"Enter password",confirmPassword:"Confirm Password",confirmPasswordPlaceholder:"Confirm password",newPasswordPlaceholder:"Enter new password",confirmNewPasswordPlaceholder:"Confirm new password",leaveBlankToKeep:"leave blank to keep current",groups:"Groups"},deleteModal:{title:"Delete User",message:"Are you sure you want to delete this user? This action cannot be undone.",confirm:"Delete User"}},streamOverlay:{title:"Stream Overlay",invalidPrinterId:"Invalid printer ID",cameraStream:"Camera stream",progress:"Progress",eta:"ETA",tomorrow:"Tomorrow",printerIdle:"Printer is idle",printerOffline:"Printer offline",status:{printing:"Printing",paused:"Paused",finished:"Finished",failed:"Failed",idle:"Idle",unknown:"Unknown"}},profiles:{title:"Profiles",subtitle:"Manage your slicer presets and pressure advance calibrations",tabs:{cloud:"Cloud Profiles",kprofiles:"K-Profiles"},connectedAs:"Connected as",logout:"Logout",noLogoutPermission:"You do not have permission to logout",failedToLoad:"Failed to load profiles",retry:"Retry",time:{justNow:"Just now",minsAgo:"{{count}}m ago",hoursAgo:"{{count}}h ago",daysAgo:"{{count}}d ago"},toast:{loggedOut:"Logged out"},login:{title:"Connect to Bambu Cloud",subtitle:"Sync your slicer presets across devices",email:"Email",password:"Password",region:"Region",regionGlobal:"Global",regionChina:"China",verificationCode:"Verification Code",checkEmail:"Check your email ({{email}}) for a 6-digit code",accessToken:"Access Token",accessTokenHint:"Paste your Bambu Lab access token (from Bambu Studio)",back:"Back",loginButton:"Login",verifyButton:"Verify",setTokenButton:"Set Token",useToken:"Use access token instead",useEmail:"Login with email instead",toast:{loggedIn:"Logged in successfully",codeSent:"Verification code sent to your email",tokenSet:"Token set successfully"}},presets:{myPreset:"My preset (editable)",duplicate:"Duplicate",editable:"Editable",failedToLoadDetails:"Failed to load preset details",deleteConfirm:"Delete this preset?",deleteWarning:'This will permanently delete "{{name}}" from Bambu Cloud. This cannot be undone.',noDuplicatePermission:"You do not have permission to duplicate presets",noEditPermission:"You do not have permission to edit presets",noDeletePermission:"You do not have permission to delete presets",types:{filament:"Filament preset",printer:"Printer preset",process:"Process preset"},toast:{deleted:"Preset deleted",created:"Preset created",updated:"Preset updated",duplicated:"Preset duplicated",fieldAdded:'Field "{{key}}" added',exported:"Preset exported"},baseLabel:"Base: {{name}}",currentLabel:"Current: {{name}}",newPreset:"New Preset",editPreset:"Edit Preset",duplicatePreset:"Duplicate Preset",createNewPreset:"Create New Preset",customizeSettings:"Customize settings for your new preset",compareWithBase:"Compare with base preset",compare:"Compare",basePreset:"Base Preset",selectBasePreset:"Select base preset...",presetName:"Preset Name",myCustomPreset:"My custom preset",inheritsFrom:"Inherits from",dropJsonToImport:"Drop JSON to import",tabs:{common:"Common",allFields:"All Fields"},availableFields:"Available Fields",searchFieldsPlaceholder:"Search fields...",noMatchingFields:"No matching fields",allFieldsAdded:"All fields added",addCustomField:"Add custom field",yourOverrides:"Your Overrides",noOverridesYet:"No overrides yet",clickFieldsToAdd:"Click fields on the left to add them",saveAsTemplate:"Save as template",jsonTip:"Tip: Drag & drop a .json file anywhere on this modal to import settings"},cloudView:{searchPlaceholder:"Search presets...",templates:"Templates",refresh:"Refresh",newPreset:"New Preset",clearFilters:"Clear filters",compareMode:"Compare Mode",selectAnotherPreset:"Select another {{type}} preset",clickTwoPresets:"Click two presets of the same type to compare",selectFirst:"1. Select first",selectSecond:"2. Select second",compareNow:"Compare Now",lastSynced:"Last synced:",showingCount:"Showing {{showing}} of {{total}} presets",noPresetsFound:"No presets found",columns:{filament:"Filament",process:"Process",printer:"Printer"},noFilamentPresets:"No filament presets",noProcessPresets:"No process presets",noPrinterPresets:"No printer presets",filters:{type:"Type",owner:"Owner",printer:"Printer",nozzle:"Nozzle",filament:"Filament",layer:"Layer",all:"All",myPresets:"My Presets",builtIn:"Built-in",process:"Process"},noTemplatesPermission:"You do not have permission to manage templates",noRefreshPermission:"You do not have permission to refresh profiles",noCreatePermission:"You do not have permission to create presets"},templates:{title:"Quick Templates",noTemplates:"No templates yet",createFirst:"Create templates from the preset editor",typeFilter:"Type:",deleteTitle:"Delete Template",deleteWarning:"This action cannot be undone",deleteConfirm:'Are you sure you want to delete "{{name}}"?',namePlaceholder:"Template name",descriptionPlaceholder:"Description",settingsJson:"Settings (JSON)",fieldsCount:"{{count}} fields",shownInModals:"Shown in modals",hiddenInModals:"Hidden in modals",apply:"Apply",toast:{deleted:"Template deleted",updated:"Template updated",created:"Template created",applied:"Template applied"}}},support:{debugLoggingActive:"Debug logging is active",manageLogs:"Manage"},fileManager:{title:"File Manager",subtitle:"Organize and manage your print files",uploadFiles:"Upload Files",newFolder:"New Folder",folderName:"Folder Name",folderNamePlaceholder:"e.g., Functional Parts",renameFile:"Rename File",renameFolder:"Rename Folder",moveFiles:"Move {{count}} File(s)",rootNoFolder:"Root (No Folder)",current:"current",linkFolder:"Link Folder",linkFolderDescription:'Link "{{name}}" to a project or archive for quick access.',project:"Project",archive:"Archive",noProjectsFound:"No projects found",noArchivesFound:"No archives found",unlink:"Unlink",link:"Link",dragDropFiles:"Drag & drop files here",dropFilesHere:"Drop files here",orClickToBrowse:"or click to browse",allFileTypesSupported:"All file types supported. ZIP files will be extracted.",zipFilesDetected:"ZIP files detected",zipExtractOptions:"ZIP files will be extracted. Choose how to handle folder structure:",preserveZipStructure:"Preserve folder structure from ZIP",createFolderFromZip:"Create folder from ZIP filename",stlThumbnailGeneration:"STL thumbnail generation",zipMayContainStl:"ZIP files may contain STL files. Thumbnails can be generated during extraction.",thumbnailsCanBeGenerated:"Thumbnails can be generated for STL files. Large models may take longer to process.",generateThumbnailsForStl:"Generate thumbnails for STL files",willBeExtracted:"Will be extracted",filesExtracted:"{{count}} files extracted",uploadComplete:"Upload complete: {{succeeded}} succeeded",uploadFailed:"{{count}} failed",uploading:"Uploading...",changeLink:"Change Link...",linkTo:"Link to...",linkToProjectOrArchive:"Link to project or archive",addToQueue:"Add to Queue",generateThumbnail:"Generate Thumbnail",generateThumbnails:"Generate Thumbnails",generateThumbnailsForMissing:"Generate thumbnails for STL files missing them",gridView:"Grid view",listView:"List view",lowDiskSpaceWarning:"Low disk space warning",lowDiskSpaceDetails:"Only {{free}} free of {{total}} total. Threshold is set to {{threshold}} GB in settings.",files:"Files",folders:"Folders",size:"Size",free:"Free",allFiles:"All Files",wrap:"Wrap",enableTextWrapping:"Enable text wrapping",disableTextWrapping:"Disable text wrapping",dragToResizeTooltip:"Drag to resize, double-click to reset",searchFiles:"Search files...",allTypes:"All types",prints:"Prints",ascending:"Ascending",descending:"Descending",resultsCount:"{{showing}} of {{total}} files",selectAll:"Select All",deselectAll:"Deselect All",selected:"{{count}} selected",adding:"Adding...",loadingFiles:"Loading files...",folderIsEmpty:"Folder is empty",noFilesYet:"No files yet",folderEmptyDescription:"Upload files or move files into this folder to get started.",noFilesDescription:"Upload files to start organizing your print-related files.",noMatchingFiles:"No matching files",noMatchingFilesDescription:"No files match your current search or filter criteria.",clearFilters:"Clear filters",printedCount:"Printed {{count}}x",uploadedBy:"Uploaded by {{name}}",deleteFolder:"Delete Folder",deleteFile:"Delete File",deleteFilesCount:"Delete {{count}} Files",deleteFolderConfirm:"Are you sure you want to delete this folder? All files inside will also be deleted.",deleteFileConfirm:"Are you sure you want to delete this file?",deleteFilesConfirm:"Are you sure you want to delete {{count}} selected files? This action cannot be undone.",deleting:"Deleting...",noPermissionRenameFolder:"You do not have permission to rename folders",noPermissionLinkFolder:"You do not have permission to link folders",noPermissionDeleteFolder:"You do not have permission to delete folders",noPermissionPrint:"You do not have permission to print",noPermissionAddToQueue:"You do not have permission to add to queue",noPermissionDownload:"You do not have permission to download files",noPermissionRenameFile:"You do not have permission to rename this file",noPermissionGenerateThumbnail:"You do not have permission to generate thumbnails",noPermissionDeleteFile:"You do not have permission to delete this file",noPermissionCreateFolder:"You do not have permission to create folders",noPermissionUpload:"You do not have permission to upload files",noPermissionMoveFiles:"You do not have permission to move files",noPermissionDeleteFiles:"You do not have permission to delete files",toast:{folderCreated:"Folder created",folderDeleted:"Folder deleted",fileDeleted:"File deleted",filesDeleted:"Deleted {{count}} files",filesMoved:"Files moved",folderLinked:"Folder linked",folderUnlinked:"Folder unlinked",addedToQueue:"Added {{count}} file(s) to queue",addedToQueuePartial:"Added {{added}} file(s), {{failed}} failed",failedToAddToQueue:"Failed to add files: {{error}}",fileRenamed:"File renamed",folderRenamed:"Folder renamed",thumbnailsGenerated:"Generated {{count}} thumbnail(s)",thumbnailsGeneratedPartial:"Generated {{succeeded}} thumbnail(s), {{failed}} failed",noStlMissingThumbnails:"No STL files missing thumbnails",failedToGenerateThumbnails:"Failed to generate thumbnails: {{error}}",thumbnailGenerated:"Thumbnail generated",failedToGenerateThumbnail:"Failed to generate thumbnail: {{error}}"}},projects:{title:"Projects",subtitle:"Organize and track your 3D printing projects",newProject:"New Project",editProject:"Edit Project",deleteProject:"Delete Project",projectName:"Project Name",description:"Description",noProjects:"No projects yet",noProjectsFiltered:"No {{status}} projects",noProjectsFilteredHelp:"You don't have any {{status}} projects. Projects will appear here when their status changes.",createFirst:"Create your first project to start organizing related prints, tracking progress, and managing your builds.",createFirstButton:"Create Your First Project",create:"Create",files:"Files",prints:"Prints",plates:"plates",parts:"parts",lastModified:"Last Modified",deleteConfirm:"Are you sure you want to delete this project? Archives and queue items will be unlinked but not deleted.",addFiles:"Add Files",removeFile:"Remove File",viewDetails:"View Details",namePlaceholder:"e.g., Voron 2.4 Build",descriptionPlaceholder:"Optional description...",color:"Color",targetPlates:"Target Plates",targetPlatesPlaceholder:"e.g., 25",targetPlatesHelp:"Number of print jobs",targetParts:"Target Parts",targetPartsPlaceholder:"e.g., 150",targetPartsHelp:"Total objects needed",tagsLabel:"Tags (comma-separated)",tagsPlaceholder:"e.g., voron, functional, gift",dueDate:"Due Date",priority:"Priority",priorityLow:"Low",priorityNormal:"Normal",priorityHigh:"High",priorityUrgent:"Urgent",statusActive:"Active",statusCompleted:"Completed",statusArchived:"Archived",done:"Done",completed:"completed",failed:"failed",inQueue:"in queue",noPrintsYet:"No prints yet",printJobs:"Print jobs (plates)",partsPrinted:"Parts printed",failedParts:"Failed parts",import:"Import",export:"Export",importProject:"Import project",exportAll:"Export all projects",loading:"Loading projects...",noEditPermission:"You do not have permission to edit projects",noDeletePermission:"You do not have permission to delete projects",noCreatePermission:"You do not have permission to create projects",noImportPermission:"You do not have permission to import projects",noExportPermission:"You do not have permission to export projects",toast:{created:"Project created",updated:"Project updated",deleted:"Project deleted",imported:"Project imported",multipleImported:"{{count}} projects imported",importFailed:"Import failed",exported:"Projects exported (metadata only)"}},projectDetail:{notFound:"Project not found",backToProjects:"Back to Projects",export:"Export",exportProject:"Export project",noExportPermission:"You do not have permission to export projects",noEditPermission:"You do not have permission to edit projects",partOf:"Part of:",priorityLabel:"Priority:",noPrints:"No prints in this project yet",status:{active:"Active",completed:"Completed",archived:"Archived"},priority:{low:"Low",normal:"Normal",high:"High",urgent:"Urgent"},dueDate:{overdue:"Overdue",today:"Due today",daysLeft:"{{count}} days left"},progress:{platesProgress:"Plates Progress",partsProgress:"Parts Progress",printJobs:"print jobs",parts:"parts",percentComplete:"{{percent}}% complete",remaining:"{{count}} remaining"},stats:{printJobs:"Print Jobs",total:"total",failed:"{{count}} failed",partsPrinted:"{{count}} parts printed",printTime:"Print Time",filamentUsed:"Filament Used"},cost:{title:"Cost Tracking",filamentCost:"Filament Cost",energy:"Energy",budget:"Budget",remaining:"Remaining"},subProjects:{title:"Sub-projects ({{count}})"},notes:{title:"Notes",noEditPermission:"You do not have permission to edit notes",placeholder:"Add notes about this project...",empty:"No notes yet. Click Edit to add notes."},files:{title:"Files",linkFolders:"Link folders from the File Manager",forQuickAccess:"to this project for quick access.",fileCount:"{{count}} file(s)",empty:"No folders linked. Go to File Manager and link a folder to this project."},bom:{title:"Bill of Materials",acquired:"{{completed}}/{{total}} acquired",showAll:"Show all",hideDone:"Hide done",addPart:"Add Part",noAddPermission:"You do not have permission to add parts",partNamePlaceholder:"Part name (e.g., M3x8 screws)",partName:"Part name",qty:"Qty",price:"Price ({{currency}})",sourcingUrlPlaceholder:"Sourcing URL (optional)",remarksPlaceholder:"Remarks (optional)",deletePart:"Delete Part",deleteConfirm:'Are you sure you want to delete "{{name}}"?',noUpdatePermission:"You do not have permission to update parts",noEditPermission:"You do not have permission to edit parts",noDeletePermission:"You do not have permission to delete parts",totalCost:"Total cost:",empty:"No parts in the bill of materials. Add hardware, electronics, or other components to track what needs to be sourced."},timeline:{title:"Activity Timeline",empty:"No activity yet."},template:{saveAsTemplate:"Save as Template",noCreatePermission:"You do not have permission to create templates"},queue:{title:"Queue",viewAll:"View all",printing:"{{count}} printing",queued:"{{count}} queued"},prints:{title:"Prints ({{count}})"},toast:{projectUpdated:"Project updated",partAdded:"Part added",partRemoved:"Part removed",exportFailed:"Export failed",projectExported:"Project exported",templateCreated:"Template created"}},system:{title:"System Information",version:"Version",uptime:"Uptime",cpuUsage:"CPU Usage",memoryUsage:"Memory Usage",diskUsage:"Disk Usage",networkInfo:"Network Info",logs:"Logs",debugMode:"Debug Mode",enableDebug:"Enable Debug Logging",disableDebug:"Disable Debug Logging",downloadLogs:"Download Logs",clearLogs:"Clear Logs",dockerInfo:"Docker Info",containerName:"Container Name",imageName:"Image Name",platform:"Platform",architecture:"Architecture"},library:{title:"Filament Library",addFilament:"Add Filament",editFilament:"Edit Filament",deleteFilament:"Delete Filament",vendor:"Vendor",material:"Material",color:"Color",kFactor:"K Factor",temperature:"Temperature",noFilaments:"No filaments in library",deleteConfirm:"Are you sure you want to delete this filament?",importFromPrinter:"Import from Printer",exportToFile:"Export to File"},spoolman:{title:"Spoolman Integration",enabled:"Spoolman Enabled",url:"Spoolman URL",connected:"Connected",disconnected:"Not Connected",testConnection:"Test Connection",sync:"Sync",syncing:"Syncing...",lastSync:"Last Sync",linkToSpoolman:"Link to Spoolman",openInSpoolman:"Open in Spoolman",unlinkSpool:"Unlink Spool",selectSpool:"Select Spool",noUnlinkedSpools:"No unlinked spools available",linkSuccess:"Spool linked to Spoolman successfully",linkFailed:"Failed to link spool",spoolId:"Spool ID",weight:"Weight",remaining:"Remaining"},timelapse:{title:"Timelapse",create:"Create Timelapse",download:"Download",delete:"Delete",preview:"Preview",frameRate:"Frame Rate",quality:"Quality",processing:"Processing...",noTimelapses:"No timelapses available"},ams:{title:"AMS",slot:"Slot",empty:"Empty",emptySlot:"Empty slot",unknown:"Unknown",humidity:"Humidity",temperature:"Temperature",filamentType:"Filament Type",filamentColor:"Color",remaining:"Remaining",history:"AMS History",noHistory:"No history available",configureSlot:"Configure Slot",externalSpool:"External Spool",profile:"Profile",kFactor:"K Factor",fill:"Fill",configure:"Configure"},printModal:{title:"Start Print",selectPrinter:"Select Printer",selectPlate:"Select Plate",filamentMapping:"Filament Mapping",printSettings:"Print Settings",bedLeveling:"Bed Leveling",flowCalibration:"Flow Calibration",vibrationCalibration:"Vibration Calibration",layerInspection:"First Layer Inspection",timelapse:"Timelapse",startPrint:"Start Print",addToQueue:"Add to Queue",cancel:"Cancel",noPrintersAvailable:"No printers available",printerBusy:"Printer is busy",printerOffline:"Printer is offline"},backup:{title:"Backup & Restore",createBackup:"Create Backup",restoreBackup:"Restore Backup",downloadBackup:"Download Backup",uploadBackup:"Upload Backup",lastBackup:"Last Backup",autoBackup:"Auto Backup",backupNow:"Backup Now",restoreWarning:"Warning: Restoring a backup will overwrite all current data.",includeArchives:"Include Archives",includeSettings:"Include Settings",includeProfiles:"Include Profiles",backupSuccess:"Backup created successfully",restoreSuccess:"Backup restored successfully",backupFailed:"Backup failed",restoreFailed:"Restore failed"},tags:{title:"Tags",addTag:"Add Tag",editTag:"Edit Tag",deleteTag:"Delete Tag",tagName:"Tag Name",tagColor:"Tag Color",noTags:"No tags",deleteConfirm:"Are you sure you want to delete this tag?",manageTags:"Manage Tags"},uploadModal:{title:"Upload 3MF Files",dragDrop:"Drag & drop .3mf files here",or:"or",browseFiles:"Browse Files",extractionInfo:"The printer model will be automatically extracted from the 3MF file metadata.",uploaded:"uploaded",failed:"failed",uploading:"Uploading...",upload:"Upload",uploadFailed:"Upload failed"},editArchive:{title:"Edit Archive",name:"Name",namePlaceholder:"Print name",printer:"Printer",noPrinter:"No printer",project:"Project",noProject:"No project",itemsPrinted:"Items Printed",itemsPrintedHelp:"Number of items produced in this print job",notes:"Notes",notesPlaceholder:"Add notes about this print...",externalLink:"External Link",externalLinkPlaceholder:"https://printables.com/model/...",externalLinkHelp:"Link to Printables, Thingiverse, or other source",tags:"Tags",tagsPlaceholder:"Add tags...",addMoreTags:"Add more tags...",matchingTags:'Matching "{{query}}"',existingTags:"Existing tags",clickToAdd:"(click to add)",status:"Status",failureReason:"Failure Reason",selectReason:"Select reason...",photos:"Photos of Printed Result",photosHelp:"Click + to add photos of your printed result",printResult:"Print result",saving:"Saving...",failureReasons:{adhesionFailure:"Adhesion failure",spaghettiDetached:"Spaghetti / Detached",layerShift:"Layer shift",cloggedNozzle:"Clogged nozzle",filamentRunout:"Filament runout",warping:"Warping",stringing:"Stringing",underExtrusion:"Under-extrusion",powerFailure:"Power failure",userCancelled:"User cancelled",other:"Other"},statuses:{completed:"Completed",failed:"Failed",aborted:"Cancelled",printing:"Printing"}},kProfiles:{title:"K-Profiles",noPrintersConfigured:"No Printers Configured",addPrinterInSettings:"Add a printer in Settings to manage K-profiles",noActivePrinters:"No Active Printers",enablePrinterConnection:"Enable a printer connection to view its K-profiles",loadingProfiles:"Loading K-Profiles...",printerOffline:"Printer Offline",printerOfflineDesc:"The selected printer is not connected. Power it on to view K-profiles.",noMatchingProfiles:"No Matching Profiles",noMatchingProfilesDesc:"No profiles match your search criteria",noKProfiles:"No K-Profiles",noKProfilesDesc:"No pressure advance profiles found for {{diameter}}mm nozzle",createFirstProfile:"Create First Profile",printer:"Printer",nozzle:"Nozzle",refresh:"Refresh",addProfile:"Add Profile",export:"Export",import:"Import",select:"Select",selectAll:"Select All",delete:"Delete",searchPlaceholder:"Search by name or filament...",allExtruders:"All Extruders",leftOnly:"Left Only",rightOnly:"Right Only",allFlow:"All Flow",hfOnly:"HF Only",sOnly:"S Only",sortName:"Sort: Name",sortKValue:"Sort: K-Value",sortFilament:"Sort: Filament",leftExtruder:"Left Extruder",rightExtruder:"Right Extruder",modal:{addTitle:"Add K-Profile",editTitle:"Edit K-Profile",profileName:"Profile Name",profileNamePlaceholder:"My PLA Profile",kValue:"K-Value",kValuePlaceholder:"0.020",kValueHelp:"Typical range: 0.01 - 0.06 for PLA, 0.02 - 0.10 for PETG",filament:"Filament",selectFilament:"Select filament...",noFilamentsHelp:"No filaments found. Create a K-profile in Bambu Studio first.",flowType:"Flow Type",highFlow:"High Flow",standard:"Standard",nozzleSize:"Nozzle Size",extruder:"Extruder",extruders:"Extruders",left:"Left",right:"Right",notes:"Notes (stored locally)",notesPlaceholder:"Add notes about this profile...",notesHelp:"Notes are saved in Bambuddy, not on the printer",syncing:"Syncing with printer...",savingExtruder:"Saving to extruder {{current}}/{{total}}...",pleaseWait:"Please wait"},deleteConfirm:{title:"Delete Profile",cannotUndo:"This cannot be undone",message:'Are you sure you want to delete "{{name}}" from the printer?'},bulkDelete:{title:"Delete Profiles",cannotUndo:"This cannot be undone",message:"Are you sure you want to delete {{count}} selected profiles from the printer?"},toast:{profileSaved:"K-profile saved",profilesSaved:"K-profile saved to {{count}} extruders",selectAtLeastOneExtruder:"Please select at least one extruder",profileDeleted:"K-profile deleted",profilesDeleted:"Deleted {{count}} profiles",exportedProfiles:"Exported {{count}} profiles",importedProfiles:"Imported {{count}} of {{total}} profiles",noProfilesToExport:"No profiles to export",invalidFileFormat:"Invalid file format",failedToParseImport:"Failed to parse import file",failedToSaveBatch:"Failed to save K-profiles",noteSaved:"Note saved",failedToSaveNote:"Failed to save note"},permission:{noRead:"You do not have permission to refresh profiles",noCreate:"You do not have permission to add profiles",noUpdate:"You do not have permission to update K-profiles",noDelete:"You do not have permission to delete K-profiles",noExport:"You do not have permission to export profiles",noImport:"You do not have permission to import profiles"}},maintenanceDescriptions:{lubricateRails:"Apply lubricant to linear rails for smooth motion",cleanNozzle:"Clean hotend and nozzle to prevent clogs",checkBelts:"Verify belt tension for accurate prints",cleanBuildPlate:"Clean build plate for better adhesion",checkExtruder:"Inspect extruder gears for wear",checkCooling:"Ensure cooling fans are working properly",generalInspection:"General printer inspection",cleanCarbonRods:"Clean carbon rods to reduce friction",checkPtfeTube:"Inspect PTFE tube for wear or damage",replaceHepaFilter:"Replace HEPA filter for air quality",replaceCarbonFilter:"Replace activated carbon filter",lubricateLeftNozzleRail:"Lubricate left nozzle rail (H2 series)"}},zse={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}}",updateAvailableBanner:"Version {{version}} ist verfügbar!",viewUpdate:"Update anzeigen",viewOnGithub:"Auf GitHub ansehen",keyboardShortcuts:"Tastaturkürzel (?)",switchToLight:"Zum hellen Modus wechseln",switchToDark:"Zum dunklen Modus wechseln",smartSwitches:"Smart Switches",logout:"Abmelden"},common:{save:"Speichern",saving:"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",days:"Tage",enable:"Aktivieren",disable:"Deaktivieren",permissions:"Berechtigungen",noPrinters:"Keine Drucker konfiguriert",noData:"Keine Daten verfügbar",linkNotFound:"Link nicht gefunden",required:"Erforderlich",optional:"Optional",dismiss:"Schließen",apply:"Anwenden",reset:"Zurücksetzen",clear:"Leeren",selectAll:"Alle auswählen",deselectAll:"Auswahl aufheben",noChange:"— Keine Änderung —",unchanged:"Unverändert",unassigned:"Nicht zugewiesen",unknown:"Unbekannt",unknownError:"Unbekannter Fehler",today:"Heute",asap:"Sofort",overdue:"Überfällig",now:"Jetzt",collapse:"Einklappen",expand:"Ausklappen",viewArchive:"Archiv anzeigen",viewInFileManager:"Im Dateimanager anzeigen",addedBy:"Hinzugefügt von {{username}}",prints:"Drucke",more:"+{{count}} weitere",ascending:"Aufsteigend",descending:"Absteigend",printer:"Drucker",remove:"Entfernen",type:"Typ",print:"Drucken",rename:"Umbenennen",move:"Verschieben",create:"Erstellen",duplicate:"Duplizieren",left:"Links",right:"Rechts"},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",sort:{name:"Name",status:"Status",model:"Modell",location:"Standort",ascending:"Aufsteigend sortieren",descending:"Absteigend sortieren"},cardSize:{small:"Kleine Karten",medium:"Mittlere Karten",large:"Große Karten",extraLarge:"Extra große Karten"},hideOffline:"Offline ausblenden",powerOn:"Einschalten",offlinePrintersWithPlugs:"Offline-Drucker mit Smart-Plugs",noPrintersConfigured:"Noch keine Drucker konfiguriert",readyToPrint:"Druckbereit",external:"Extern",deleteArchives:"Druckarchive löschen",noLabel:"Keine Bezeichnung",printPreview:"Druckvorschau",width:"Breite",height:"Höhe",noObjectsFound:"Keine Objekte gefunden",objectsLoadedOnPrintStart:"Objekte werden beim Druckstart geladen",willBeSkipped:"Wird übersprungen",name:"Name",serialCannotBeChanged:"Seriennummer kann nicht geändert werden",locationHelp:"Dient zur Gruppierung von Druckern und zum Filtern von Warteschlangenaufträgen",wifiSignal:{veryWeak:"Sehr schwach",weak:"Schwach",fair:"Ausreichend",good:"Gut",excellent:"Ausgezeichnet"},maintenanceUpToDate:"Alle Wartungen aktuell - Klicken zum Anzeigen",chamberLightOn:"Kammerbeleuchtung einschalten",chamberLightOff:"Kammerbeleuchtung ausschalten",browseFiles:"Druckerdateien durchsuchen",autoOffAfterPrint:"Automatisches Ausschalten nach Druck",autoOffExecuted:"Auto-off wurde ausgeführt - Drucker einschalten zum Zurücksetzen",hmsErrors:"HMS-Fehler",viewHmsErrors:"{{count}} HMS-Fehler anzeigen",resume:"Fortsetzen",pause:"Pausieren",stop:"Stoppen",camera:"Kamera",skipObject:"Objekt überspringen",reconnect:"Neu verbinden",mqttDebug:"MQTT-Debug",activeNozzle:"Aktiv: {{nozzle}} Düse",firmwareUpdate:"Firmware-Update",firmwareInstructions:"Gehen Sie auf dem Touchscreen des Druckers zu",firmwareNav:"Navigieren Sie zu",settings:"Einstellungen",firmware:"Firmware",discoverPrinters:"Drucker entdecken",searching:"Suche...",manualEntry:"Manuelle Eingabe",addFromCloud:"Aus Cloud hinzufügen",toast:{printerDeleted:"Drucker gelöscht",printerAdded:"Drucker hinzugefügt",printerUpdated:"Drucker aktualisiert",failedToDelete:"Drucker konnte nicht gelöscht werden",failedToAdd:"Drucker konnte nicht hinzugefügt werden",failedToUpdate:"Drucker konnte nicht aktualisiert werden",commandSent:"Befehl gesendet",failedToSendCommand:"Befehl konnte nicht gesendet werden",turnedOn:"{{name}} eingeschaltet",failedToPowerOn:"{{name}} konnte nicht eingeschaltet werden",scriptTriggered:"Skript ausgelöst",printStopped:"Druck gestoppt",printPaused:"Druck pausiert",printResumed:"Druck fortgesetzt",referenceDeleted:"Referenz gelöscht",detectionAreaSaved:"Erkennungsbereich gespeichert",failedToRunScript:"Skript konnte nicht ausgeführt werden",failedToStopPrint:"Druck konnte nicht gestoppt werden",failedToPausePrint:"Druck konnte nicht pausiert werden",failedToResumePrint:"Druck konnte nicht fortgesetzt werden",failedToControlChamberLight:"Kammerbeleuchtung konnte nicht gesteuert werden",failedToUpdateSetting:"Einstellung konnte nicht aktualisiert werden",failedToSkipObjects:"Objekte konnten nicht übersprungen werden",failedToRereadRfid:"RFID konnte nicht erneut gelesen werden",failedToCheckPlate:"Platte konnte nicht überprüft werden",failedToUpdateLabel:"Bezeichnung konnte nicht aktualisiert werden",failedToDeleteReference:"Referenz konnte nicht gelöscht werden",failedToSaveDetectionArea:"Erkennungsbereich konnte nicht gespeichert werden",plateCheckEnabled:"Plattenprüfung aktiviert",plateCheckDisabled:"Plattenprüfung deaktiviert",calibrationSaved:"Kalibrierung gespeichert!",calibrationFailed:"Kalibrierung fehlgeschlagen",rfidRereadInitiated:"RFID-Neueinlesen gestartet"},connection:{connected:"Verbunden",offline:"Offline"},queue:{inQueue:"{{count}} Druck in Warteschlange",inQueue_plural:"{{count}} Drucke in Warteschlange"},controls:"Steuerung",rfid:{reread:"RFID neu lesen"},permission:{noAdd:"Sie haben keine Berechtigung, Drucker hinzuzufügen",noEdit:"Sie haben keine Berechtigung, Drucker zu bearbeiten",noDelete:"Sie haben keine Berechtigung, Drucker zu löschen",noControl:"Sie haben keine Berechtigung, Drucker zu steuern",noFiles:"Sie haben keine Berechtigung, auf Druckerdateien zuzugreifen",noAmsRfid:"Sie haben keine Berechtigung, AMS-RFID erneut zu lesen",noSmartPlugControl:"Sie haben keine Berechtigung, Smart Plugs zu steuern"},modal:{addTitle:"Drucker hinzufügen",editTitle:"Drucker bearbeiten",myPrinter:"Mein Drucker",selectModel:"Modell auswählen...",locationGroup:"Standort / Gruppe (optional)",locationPlaceholder:"z.B. Werkstatt, Büro, Keller",autoArchiveLabel:"Abgeschlossene Drucke automatisch archivieren",fromPrinterSettings:"Aus Druckereinstellungen",modelOptional:"Modell (optional)",saveChanges:"Änderungen speichern"},skipObjects:{tooltip:"Objekte überspringen",onlyWhilePrinting:"Objekte überspringen (nur während des Drucks)",requiresMultiple:"Objekte überspringen (erfordert 2+ Objekte)",title:"Objekte überspringen",matchIdsInfo:"IDs mit Drucker-Display abgleichen",printerShowsIds:"Der Druckerbildschirm zeigt Objekt-IDs auf der Bauplatte",skipSelected:"Ausgewählte überspringen",skipping:"Überspringe...",noObjectsSelected:"Keine Objekte ausgewählt",selectObjectsToSkip:"Wählen Sie Objekte aus, die Sie vom aktuellen Druck überspringen möchten",skipped:"übersprungen",objectsSkipped:"Objekte übersprungen",activeCount:"{{count}} aktiv",waitForLayer:"Warten Sie auf Schicht 2+ zum Überspringen von Objekten (aktuell Schicht {{layer}})",skip:"Überspringen"},confirm:{deleteTitle:"Drucker löschen",deleteMessage:'Möchten Sie "{{name}}" wirklich löschen? Alle Verbindungseinstellungen werden entfernt.',deleteArchivesNote:"Der gesamte Druckverlauf für diesen Drucker wird dauerhaft gelöscht.",keepArchivesNote:"Der Druckverlauf wird beibehalten, aber nicht mehr mit diesem Drucker verknüpft.",stopTitle:"Druck stoppen",stopMessage:'Möchten Sie den aktuellen Druck auf "{{name}}" wirklich stoppen? Der Druckauftrag wird abgebrochen.',stopButton:"Druck stoppen",pauseTitle:"Druck pausieren",pauseMessage:'Möchten Sie den aktuellen Druck auf "{{name}}" wirklich pausieren?',pauseButton:"Druck pausieren",resumeTitle:"Druck fortsetzen",resumeMessage:'Möchten Sie den Druck auf "{{name}}" fortsetzen?',resumeButton:"Druck fortsetzen",powerOnTitle:"Drucker einschalten",powerOnMessage:'Möchten Sie die Stromversorgung für "{{name}}" wirklich EINSCHALTEN?',powerOnButton:"Einschalten",powerOffTitle:"Drucker ausschalten",powerOffMessage:'Möchten Sie die Stromversorgung für "{{name}}" wirklich AUSSCHALTEN?',powerOffWarning:'WARNUNG: "{{name}}" druckt gerade! Möchten Sie die Stromversorgung wirklich AUSSCHALTEN? Dies unterbricht den Druck und kann den Drucker beschädigen.',powerOffButton:"Ausschalten"},discovery:{title:"Drucker entdecken",searching:"Suche...",scanning:"Scanne...",scanProgress:"Scanne... {{scanned}}/{{total}}",foundPrinters:"{{count}} Drucker gefunden",noPrintersFound:"Keine Drucker gefunden",noPrintersFoundSubnet:"Keine Drucker im angegebenen Subnetz gefunden.",noPrintersFoundNetwork:"Keine Drucker im Netzwerk gefunden.",allConfigured:"Alle erkannten Drucker sind bereits konfiguriert.",alreadyAdded:"Bereits hinzugefügt",select:"Auswählen",manualEntry:"Manuelle Eingabe",addFromCloud:"Aus Cloud hinzufügen",subnetToScan:"Zu scannendes Subnetz",dockerNote:"Docker erkannt. Geben Sie das Subnetz Ihres Druckers in CIDR-Notation ein. Erfordert network_mode: host in docker-compose.yml.",scanSubnet:"Subnetz nach Druckern scannen",discoverNetwork:"Drucker im Netzwerk suchen",scanningSubnet:"Subnetz wird nach Bambu-Druckern gescannt...",scanningNetwork:"Netzwerk wird gescannt...",serialRequired:"Seriennummer erforderlich",unknown:"Unbekannt",failedToStart:"Erkennung konnte nicht gestartet werden"},filaments:"Filamente",openCameraOverlay:"Kamera-Overlay öffnen",openCameraWindow:"Kamera in neuem Fenster öffnen",firmwareUpdateAvailable:"Firmware-Update verfügbar: {{current}} → {{latest}}",firmwareUpdateButton:"Update",plateDetection:{noPermission:"Sie haben keine Berechtigung, Drucker zu aktualisieren",enabledClick:"Plattenprüfung aktiviert - Klicken zum Deaktivieren",disabledClick:"Plattenprüfung deaktiviert - Klicken zum Aktivieren",manageCalibration:"Platten-Erkennungskalibrierung verwalten",calibrationRequired:"Kalibrierung erforderlich",calibrationInstructions:"Bitte stellen Sie sicher, dass die Druckplatte <strong>vollständig leer</strong> ist, und klicken Sie dann auf Kalibrieren.",calibrationDescription:"Die Kalibrierung erfasst ein Referenzbild der leeren Platte. Zukünftige Prüfungen vergleichen mit dieser Referenz, um Objekte zu erkennen.",calibrationTip:"<strong>Tipp:</strong> Sie können bis zu 5 Kalibrierungen für verschiedene Platten speichern. Das System verwendet automatisch die beste Übereinstimmung bei der Prüfung.",plateEmpty:"Platte erscheint leer",objectsDetected:"Objekte auf Platte erkannt",confidence:"Konfidenz",difference:"Differenz",analysisPreview:"Analysevorschau:",analysisLegend:"Grüner Rahmen = Erkennungsbereich, Rote Überlagerung = Unterschiede zur Kalibrierung",savedReferences:"Gespeicherte Referenzen ({{count}}/{{max}})",deleteReference:"Referenz löschen",labelPlaceholder:"Bezeichnung...",clickToEdit:"{{label}} - Zum Bearbeiten klicken",clickToAddLabel:"Zum Hinzufügen einer Bezeichnung klicken"},fans:{partCooling:"Bauteilkühlung",auxiliary:"Hilfsventilator",chamber:"Kammerventilator"},clickToViewHmsErrors:"Klicken, um HMS-Fehler anzuzeigen",estimatedCompletion:"Geschätzte Fertigstellungszeit",slotOptions:"Slot-Optionen",firmwareModal:{title:"Firmware-Update",currentVersion:"Aktuell:",latestVersion:"Neueste:",releaseNotes:"Versionshinweise",checkingPrereqs:"Prüfe Voraussetzungen...",sdCardReady:"SD-Karte bereit. Klicken Sie unten, um die Firmware hochzuladen.",uploadedSuccess:"Firmware auf SD-Karte hochgeladen!",applyInstructions:"So wenden Sie das Update auf Ihrem Drucker an:",step1:"Gehen Sie auf dem Touchscreen des Druckers zu <strong>Einstellungen</strong>",step2:"Navigieren Sie zu <strong>Firmware</strong>",step3:"Wählen Sie <strong>Update von SD-Karte</strong>",step4:"Das Update dauert 10-20 Minuten",done:"Fertig",starting:"Starte...",uploadFirmware:"Firmware hochladen",uploadedToast:"Firmware hochgeladen! Starten Sie das Update vom Druckerbildschirm."},accessCodePlaceholder:"Leer lassen, um den aktuellen zu behalten",roi:{title:"Erkennungsbereich (ROI)",xStart:"X-Start",yStart:"Y-Start",width:"Breite",height:"Höhe",instruction:"Passen Sie den Erkennungsbereich an, um sich auf die Druckplatte zu konzentrieren. Der grüne Rahmen in der Vorschau zeigt den aktuellen Bereich."}},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",sortLargest:"Größte zuerst",sortSmallest:"Kleinste zuerst",sortSize:"Größe",noArchives:"Keine Archive gefunden",noArchivesSearch:"Keine Archive entsprechen Ihrer Suche",noArchivesYet:"Noch keine Archive",loadingArchives:"Lade Archive...",releaseToUpload:"Loslassen zum Hochladen",showAll:"Alle anzeigen",showFavoritesOnly:"Nur Favoriten anzeigen",gridView:"Rasteransicht",listView:"Listenansicht",calendarView:"Kalenderansicht",manageTags:"Tags verwalten",showFailedPrints:"Fehlgeschlagene Drucke anzeigen",hideFailedPrints:"Fehlgeschlagene Drucke ausblenden",printTime:"Druckzeit",filamentUsed:"Verbrauchtes Filament",cost:"Kosten",reprint:"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"},toast:{source3mfAttached:"Quell-3MF angehängt: {{filename}}",failedUploadSource3mf:"Fehler beim Hochladen der Quell-3MF",source3mfRemoved:"Quell-3MF entfernt",failedRemoveSource3mf:"Fehler beim Entfernen der Quell-3MF",f3dAttached:"F3D angehängt: {{filename}}",failedUploadF3d:"Fehler beim Hochladen der F3D",f3dRemoved:"F3D entfernt",failedRemoveF3d:"Fehler beim Entfernen der F3D",timelapseAttached:"Zeitraffer angehängt: {{filename}}",timelapseAlreadyAttached:"Zeitraffer bereits angehängt",noMatchingTimelapse:"Kein passender Zeitraffer gefunden",failedScanTimelapse:"Fehler beim Suchen nach Zeitraffer",failedAttachTimelapse:"Fehler beim Anhängen des Zeitraffers",archiveDeleted:"Archiv gelöscht",failedDeleteArchive:"Fehler beim Löschen des Archivs",addedToFavorites:"Zu Favoriten hinzugefügt",removedFromFavorites:"Aus Favoriten entfernt",projectUpdated:"Projekt aktualisiert",failedUpdateProject:"Fehler beim Aktualisieren des Projekts",linkCopied:"Link in die Zwischenablage kopiert",failedCopyLink:"Fehler beim Kopieren des Links",photoDeleted:"Foto gelöscht",failedDeletePhoto:"Fehler beim Löschen des Fotos",failedDeleteArchives:"Fehler beim Löschen der Archive",failedUpdateFavorites:"Fehler beim Aktualisieren der Favoriten",exportDownloaded:"Export heruntergeladen",exportFailed:"Export fehlgeschlagen"},menu:{print:"Drucken",schedule:"Planen",openInBambuStudio:"In Bambu Studio öffnen",slice:"Slicen",externalLink:"Externer Link",viewOnMakerWorld:"Auf MakerWorld ansehen",preview3d:"3D-Vorschau",viewTimelapse:"Zeitraffer ansehen",scanForTimelapse:"Nach Zeitraffer suchen",downloadSource3mf:"Quell-3MF herunterladen",uploadSource3mf:"Quell-3MF hochladen",replaceSource3mf:"Quell-3MF ersetzen",removeSource3mf:"Quell-3MF entfernen",uploadF3d:"F3D hochladen",replaceF3d:"F3D ersetzen",downloadF3d:"F3D herunterladen",removeF3d:"F3D entfernen",download:"Herunterladen",copyDownloadLink:"Download-Link kopieren",qrCode:"QR-Code",viewPhotos:"Fotos ansehen",viewPhotosCount:"Fotos ansehen ({{count}})",projectPage:"Projektseite",addToFavorites:"Zu Favoriten hinzufügen",removeFromFavorites:"Aus Favoriten entfernen",edit:"Bearbeiten",goToProject:"Zum Projekt: {{name}}",addToProject:"Zu Projekt hinzufügen",removeFromProject:"Aus Projekt entfernen",loading:"Laden...",noProjectsAvailable:"Keine Projekte verfügbar",select:"Auswählen",deselect:"Abwählen",delete:"Löschen"},permission:{noReprint:"Sie haben keine Berechtigung, dieses Archiv erneut zu drucken",noAddToQueue:"Sie haben keine Berechtigung, zur Warteschlange hinzuzufügen",noUpdateArchives:"Sie haben keine Berechtigung, Archive zu aktualisieren",noUploadFiles:"Sie haben keine Berechtigung, Dateien hochzuladen",noDownload:"Sie haben keine Berechtigung, Archive herunterzuladen",noCopyLink:"Sie haben keine Berechtigung, Download-Links zu kopieren",noDelete:"Sie haben keine Berechtigung, dieses Archiv zu löschen",noCreate:"Sie haben keine Berechtigung, Archive zu erstellen"},card:{previousPlate:"Vorherige Platte",nextPlate:"Nächste Platte",plateNumber:"Platte {{index}}",moreOptions:"Rechtsklick für mehr Optionen",addToFavorites:"Zu Favoriten hinzufügen",removeFromFavorites:"Aus Favoriten entfernen",cancelled:"abgebrochen",failed:"fehlgeschlagen",duplicate:"Duplikat",duplicateTitle:"Dieses Modell wurde bereits zuvor gedruckt",openSource3mf:"Quell-3MF in Bambu Studio öffnen (Rechtsklick für mehr Optionen)",downloadF3d:"Fusion 360 Designdatei herunterladen",viewTimelapse:"Zeitraffer ansehen",viewPhoto:"1 Foto ansehen",viewPhotos:"{{count}} Fotos ansehen",openFolder:"Ordner öffnen: {{name}}",slicedFile:"Geslicte Datei - druckbereit",sourceFile:"Nur Quelldatei - keine AMS-Zuordnung verfügbar",gcode:"GCODE",source:"QUELLE",project:"Projekt: {{name}}",estimated:"Geschätzt: {{time}}",actual:"Tatsächlich: {{time}}",accuracy:"Genauigkeit: {{percent}}%",filament:"{{weight}}g",layer:"{{count}} Schicht",layers:"{{count}} Schichten",object:"{{count}} Objekt",objects:"{{count}} Objekte",slicedFor:"Geslict für {{model}}",uploadedBy:"Hochgeladen von {{name}}",noPermissionReprint:"Sie haben keine Berechtigung, erneut zu drucken",noPermissionEdit:"Sie haben keine Berechtigung, Archive zu bearbeiten",noPermissionDelete:"Sie haben keine Berechtigung, Archive zu löschen",reprint:"Drucken",schedulePrint:"Druck planen",schedule:"Planen",openInBambuStudio:"In Bambu Studio öffnen",openInBambuStudioToSlice:"In Bambu Studio öffnen zum Slicen",slice:"Slicen",externalLink:"Externer Link",makerWorld:"MakerWorld: {{designer}}",viewProject:"Projekt ansehen",noExternalLink:"Kein externer Link",preview3d:"3D-Vorschau",download:"Herunterladen",edit:"Bearbeiten",delete:"Löschen"},modal:{deleteArchive:"Archiv löschen",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen? Diese Aktion kann nicht rückgängig gemacht werden.',deleteButton:"Löschen",removeSource3mf:"Quell-3MF entfernen",removeSource3mfConfirm:'Möchten Sie die Quell-3MF-Datei wirklich von "{{name}}" entfernen? Die ursprüngliche Slicer-Projektdatei wird gelöscht.',removeButton:"Entfernen",removeF3d:"F3D entfernen",removeF3dConfirm:'Möchten Sie die Fusion 360 Designdatei wirklich von "{{name}}" entfernen?',timelapse:"{{name}} - Zeitraffer",selectTimelapse:"Zeitraffer auswählen",selectTimelapseDesc:"Keine automatische Übereinstimmung gefunden. Wählen Sie den Zeitraffer für diesen Druck:",deleteArchives:"Archive löschen",deleteArchivesConfirm:"Möchten Sie wirklich {{count}} Archiv(e) löschen? Diese Aktion kann nicht rückgängig gemacht werden.",deleteCount:"{{count}} löschen"},page:{title:"Archive",printsCount:"{{filtered}} von {{total}} Drucken",dropFilesHere:".3mf-Dateien hier ablegen",releaseToUpload:"Loslassen zum Hochladen",only3mfSupported:"Nur .3mf-Dateien werden unterstützt",close:"Schließen",selected:"{{count}} ausgewählt",selectAll:"Alle auswählen",tags:"Tags",project:"Projekt",favorite:"Favorit",delete:"Löschen",toggledFavorites:"Favoriten für {{count}} Archiv(e) umgeschaltet",failedUpdateFavorites:"Fehler beim Aktualisieren der Favoriten",archivesDeleted:"{{count}} Archiv(e) gelöscht",failedDeleteArchives:"Fehler beim Löschen der Archive",photoDeleted:"Foto gelöscht",failedDeletePhoto:"Fehler beim Löschen des Fotos"},list:{name:"Name",printer:"Drucker",date:"Datum",size:"Größe",actions:"Aktionen",hasTimelapse:"Hat Zeitraffer"}},queue:{title:"Druckwarteschlange",subtitle:"Planen und verwalten Sie Ihre Druckaufträge",addToQueue:"Zur Warteschlange hinzufügen",print:"Drucken",reprint:"Erneut drucken",schedulePrint:"Druck planen",editQueueItem:"Warteschlangeneintrag bearbeiten",printToPrinters:"Auf {{count}} Druckern drucken",queueToPrinters:"Zu {{count}} Druckern hinzufügen",sending:"Wird gesendet...",sendingProgress:"Sende {{current}}/{{total}}...",adding:"Wird hinzugefügt...",addingProgress:"Füge hinzu {{current}}/{{total}}...",savingProgress:"Speichere {{current}}/{{total}}...",clearQueue:"Warteschlange leeren",clearHistory:"Verlauf löschen",emptyQueue:"Warteschlange ist leer",position:"Position",scheduledTime:"Geplante Zeit",moveUp:"Nach oben",moveDown:"Nach unten",startNow:"Jetzt starten",printingInProgress:"Druck läuft...",viewArchive:"Archiv anzeigen",viewInFileManager:"Im Dateimanager anzeigen",itemCount:"{{count}} Element",itemCount_plural:"{{count}} Elemente",dragToReorder:"Ziehen zum Neuordnen (nur Sofort)",reorderHint:"Position betrifft nur Sofort-Elemente. Geplante Elemente werden zur festgelegten Zeit ausgeführt.",addedBy:"Hinzugefügt von {{name}}",sections:{currentlyPrinting:"Aktuell druckend",queued:"In Warteschlange",history:"Verlauf"},status:{pending:"Ausstehend",waiting:"Wartend",printing:"Druckt",completed:"Abgeschlossen",failed:"Fehlgeschlagen",skipped:"Übersprungen",cancelled:"Abgebrochen"},summary:{printing:"Druckt",queued:"In Warteschlange",totalTime:"Gesamte Wartezeit",history:"Verlauf"},filter:{allPrinters:"Alle Drucker",unassigned:"Nicht zugewiesen",allStatus:"Alle Status",allLocations:"Alle Standorte",any:"Beliebig"},sort:{byPosition:"Nach Position sortieren",byName:"Nach Name sortieren",byPrinter:"Nach Drucker sortieren",bySchedule:"Nach Zeitplan sortieren",byDate:"Nach Datum sortieren",ascendingOldest:"Aufsteigend (älteste zuerst)",descendingNewest:"Absteigend (neueste zuerst)"},badges:{staged:"Bereitgestellt",requiresPrevious:"Erfordert vorherigen Erfolg",autoPowerOff:"Automatisch ausschalten"},empty:{title:"Keine Drucke geplant",description:'Planen Sie einen Druck von der Archivseite über die Option "Planen" im Kontextmenü oder ziehen Sie Dateien hierher.'},time:{asap:"Sofort",overdue:"Überfällig",now:"Jetzt",lessThanMinute:"In weniger als einer Minute",inMinutes:"In {{count}} Min",inHours:"In {{count}} Stunden"},actions:{stopPrint:"Druck stoppen",startPrint:"Druck starten",requeue:"Erneut einreihen"},bulkEdit:{title:"{{count}} Element bearbeiten",title_plural:"{{count}} Elemente bearbeiten",description:"Nur geänderte Einstellungen werden auf ausgewählte Elemente angewendet.",printer:"Drucker",noChange:"— Keine Änderung —",queueOptions:"Warteschlangenoptionen",staged:"Bereitgestellt (manueller Start)",autoPowerOff:"Nach Druck automatisch ausschalten",requirePrevious:"Vorherigen Erfolg erfordern",printOptions:"Druckoptionen",bedLevelling:"Bett-Nivellierung",flowCalibration:"Fluss-Kalibrierung",vibrationCalibration:"Vibrations-Kalibrierung",layerInspection:"Erste-Schicht-Prüfung",timelapse:"Zeitraffer",useAms:"AMS verwenden",applyChanges:"Änderungen übernehmen",selectAll:"Alle auswählen",deselectAll:"Auswahl aufheben",selected:"{{count}} ausgewählt",editSelected:"Ausgewählte bearbeiten",cancelSelected:"Ausgewählte abbrechen"},confirm:{cancelTitle:"Geplanten Druck abbrechen",cancelMessage:'Möchten Sie "{{name}}" wirklich abbrechen?',stopTitle:"Druck stoppen",stopMessage:'Möchten Sie den aktuellen Druck "{{name}}" wirklich stoppen? Der Druckauftrag wird am Drucker abgebrochen.',removeTitle:"Aus Verlauf entfernen",removeMessage:'Möchten Sie "{{name}}" wirklich aus dem Warteschlangenverlauf entfernen?',clearHistoryTitle:"Verlauf löschen",clearHistoryMessage:"Möchten Sie alle {{count}} Element(e) aus dem Verlauf entfernen?",cancelButton:"Druck abbrechen",stopButton:"Druck stoppen",thisPrint:"diesen Druck",thisItem:"dieses Element"},toast:{cancelled:"Warteschlangenelement abgebrochen",cancelFailed:"Element konnte nicht abgebrochen werden",removed:"Warteschlangenelement entfernt",removeFailed:"Element konnte nicht entfernt werden",stopped:"Druck gestoppt",stopFailed:"Druck konnte nicht gestoppt werden",released:"Druck in Warteschlange freigegeben",startFailed:"Druck konnte nicht gestartet werden",reorderFailed:"Warteschlange konnte nicht neu geordnet werden",historyCleared:"{{count}} Verlaufselement(e) gelöscht",clearHistoryFailed:"Verlauf konnte nicht gelöscht werden",updateFailed:"Elemente konnten nicht aktualisiert werden",bulkCancelled:"{{count}} Element(e) abgebrochen",bulkCancelFailed:"Elemente konnten nicht abgebrochen werden"},permissions:{noStopPrint:"Sie haben keine Berechtigung, Drucke zu stoppen",noStartPrint:"Sie haben keine Berechtigung, Drucke zu starten",noEdit:"Sie haben keine Berechtigung, dieses Warteschlangenelement zu bearbeiten",noCancel:"Sie haben keine Berechtigung, dieses Warteschlangenelement abzubrechen",noRequeue:"Sie haben keine Berechtigung, Elemente erneut einzureihen",noRemove:"Sie haben keine Berechtigung, dieses Warteschlangenelement zu entfernen",noClearHistory:"Sie haben keine Berechtigung, den gesamten Verlauf zu löschen",noEditItems:"Sie haben keine Berechtigung, Warteschlangenelemente zu bearbeiten",noCancelItems:"Sie haben keine Berechtigung, Warteschlangenelemente abzubrechen"}},stats:{title:"Dashboard",subtitle:"Widgets zum Neuanordnen ziehen. Auf das Augensymbol klicken zum Ausblenden.",overview:"Übersicht",totalPrints:"Gesamtdrucke",successRate:"Erfolgsrate",totalPrintTime:"Gesamtdruckzeit",printTime:"Druckzeit",totalFilament:"Gesamtverbrauch Filament",filamentUsed:"Filamentverbrauch",filamentCost:"Filamentkosten",totalCost:"Gesamtkosten",energyUsed:"Energieverbrauch",energyCost:"Energiekosten",averagePrintTime:"Durchschnittliche Druckzeit",printsPerDay:"Drucke pro Tag",byPrinter:"Nach Drucker",printsByPrinter:"Drucke nach Drucker",byMaterial:"Nach Material",byMonth:"Nach Monat",last7Days:"Letzte 7 Tage",last30Days:"Letzte 30 Tage",last90Days:"Letzte 90 Tage",allTime:"Gesamt",quickStats:"Schnellstatistiken",printActivity:"Druckaktivität",filamentTypes:"Filamenttypen",filamentTrends:"Filamenttrends",failureAnalysis:"Fehleranalyse",timeAccuracy:"Zeitgenauigkeit",successful:"Erfolgreich:",failed:"Fehlgeschlagen:",perfectEstimate:"100% = perfekte Schätzung",noTimeAccuracyData:"Noch keine Zeitgenauigkeitsdaten",noFilamentData:"Keine Filamentdaten verfügbar",noPrinterData:"Keine Druckerdaten verfügbar",noPrintData:"Keine Druckdaten verfügbar",noPrintDataLast30Days:"Keine Druckdaten in den letzten 30 Tagen",failureReasons:"Fehlerursachen",topFailureReasons:"Häufigste Fehlerursachen",failedPrintsCount:"{{failed}} / {{total}} Drucke fehlgeschlagen",lastWeekRate:"Letzte Woche: {{rate}}%",resetLayout:"Layout zurücksetzen",recalculateCosts:"Kosten neu berechnen",recalculateCostsHint:"Alle Archivkosten mit aktuellen Filamentpreisen neu berechnen",exportStats:"Statistiken exportieren",exportAsCsv:"Als CSV exportieren",exportAsExcel:"Als Excel exportieren",hiddenCount:"{{count}} ausgeblendet",exportDownloaded:"Export heruntergeladen",exportFailed:"Export fehlgeschlagen",layoutReset:"Layout zurückgesetzt",recalculatedCosts:"Kosten für {{count}} Archive neu berechnet",recalculateFailed:"Kosten konnten nicht neu berechnet werden",loadingStats:"Statistiken werden geladen...",noPermissionResetLayout:"Sie haben keine Berechtigung, das Layout zurückzusetzen",noPermissionRecalculate:"Sie haben keine Berechtigung, Kosten neu zu berechnen"},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",statusTab:"Status",settingsTab:"Einstellungen",overdueCount:"{{count}} überfällig",dueSoonCount:"{{count}} bald fällig",dueSoon:"Bald fällig",allGood:"Alles in Ordnung",overdueBy:"Überfällig um {{duration}}",dueIn:"Fällig in {{duration}}",timeLeft:"{{duration}} verbleibend",day:"1 Tag",days:"{{count}} Tage",week:"1 Woche",weeks:"{{count}} Wochen",month:"1 Monat",months:"{{count}} Monate",year:"1 Jahr",maintenanceTypes:"Wartungstypen",maintenanceTypesDescription:"Systemtypen und Ihre benutzerdefinierten Wartungsaufgaben",addCustomType:"Benutzerdefinierten Typ hinzufügen",intervalType:"Intervalltyp",intervalValue:"Intervall ({{type}})",icon:"Symbol",documentationLink:"Dokumentationslink (optional)",assignToPrinters:"Druckern zuweisen",selectAtLeastOnePrinter:"Wählen Sie mindestens einen Drucker",addType:"Typ hinzufügen",custom:"Benutzerdefiniert",printHours:"Druckstunden",calendarDays:"Kalendertage",exampleName:"z.B. HEPA-Filter ersetzen",viewDocumentation:"Dokumentation anzeigen",timeBasedInterval:"Zeitbasiertes Intervall",intervalOverrides:"Intervall-Überschreibungen",intervalOverridesDescription:"Intervalle für bestimmte Drucker anpassen",assignedToPrinters:"Druckern zugewiesen:",noPrintersAssigned:"Keine Drucker zugewiesen",addPrinterShort:"Hinzufügen:",printersAssignedClick:"{{count}} Drucker zugewiesen - klicken zum Verwalten",removeFromPrinter:"Von diesem Drucker entfernen",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",cleanCarbonRods:"Kohlenstoffstangen reinigen",checkPtfeTube:"PTFE-Schlauch prüfen",replaceHepaFilter:"HEPA-Filter ersetzen",replaceCarbonFilter:"Aktivkohlefilter ersetzen",lubricateLeftNozzleRail:"Linke Düsenschiene schmieren"},maintenanceComplete:"Wartung als abgeschlossen markiert",typeUpdated:"Wartungstyp aktualisiert",typeDeleted:"Wartungstyp gelöscht",printHoursUpdated:"Druckstunden aktualisiert",printerAssigned:"Drucker zugewiesen",printerRemoved:"Drucker entfernt",deleteTypeConfirm:'"{{name}}" löschen?',noPermissionUpdate:"Sie haben keine Berechtigung, Wartungselemente zu aktualisieren",noPermissionPerform:"Sie haben keine Berechtigung, Wartungen durchzuführen",noPermissionEditTypes:"Sie haben keine Berechtigung, Wartungstypen zu bearbeiten",noPermissionDeleteTypes:"Sie haben keine Berechtigung, Wartungstypen zu löschen",noPermissionEditHours:"Sie haben keine Berechtigung, Druckstunden zu bearbeiten",noPermissionRemovePrinter:"Sie haben keine Berechtigung, Druckerzuweisungen zu entfernen",noPermissionAssignPrinter:"Sie haben keine Berechtigung, Drucker zuzuweisen",noPermissionEditIntervals:"Sie haben keine Berechtigung, Intervalle zu bearbeiten",configureSettings:"Wartungstypen und Intervalle konfigurieren"},settings:{title:"Einstellungen",general:"Allgemein",tabs:{general:"Allgemein",smartPlugs:"Smart Plugs",notifications:"Benachrichtigungen",filament:"Filament",network:"Netzwerk",apiKeys:"API-Schlüssel",virtualPrinter:"Virtueller Drucker",users:"Benutzer",backup:"Sicherung"},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",noDefaultPrinter:"Kein Standard (jedes Mal fragen)",sidebarOrder:"Seitenleisten-Reihenfolge",saveThumbnails:"Vorschaubilder speichern",captureFinishPhoto:"Abschlussfoto aufnehmen",noPrintersConfigured:"Keine Drucker konfiguriert",archiveMode:{always:"Immer Archiveintrag erstellen",never:"Nie Archiveintrag erstellen",ask:"Jedes Mal fragen"},checkForUpdatesLabel:"Nach Updates suchen",checkPrinterFirmware:"Drucker-Firmware prüfen",enableRetry:"Wiederholung aktivieren",homeAssistantDescription:"Smart Plugs über Home Assistant steuern",mqttConnectedTo:"Verbunden mit",prometheusDescription:"Druckerdaten im Prometheus-Format bereitstellen",noSmartPlugsTitle:"Keine Smart Plugs konfiguriert",noSmartPlugsDescription:"Fügen Sie einen Tasmota-basierten Smart Plug hinzu, um den Energieverbrauch zu verfolgen und die Stromsteuerung zu automatisieren.",noProvidersTitle:"Keine Anbieter konfiguriert",noProvidersDescription:"Fügen Sie einen Anbieter hinzu, um Benachrichtigungen zu erhalten.",noTemplatesAvailable:"Keine Vorlagen verfügbar. Starten Sie das Backend neu, um Standardvorlagen zu laden.",apiPermissionView:"Druckerstatus und Warteschlange anzeigen",apiPermissionEdit:"Elemente zur Druckwarteschlange hinzufügen und entfernen",apiKeysEmptyTitle:"Keine API-Schlüssel",apiKeysEmptyDescription:"Erstellen Sie einen API-Schlüssel zur Integration mit externen Diensten.",noUsersFound:"Keine Benutzer gefunden",noGroupsFound:"Keine Gruppen gefunden",noGroupsAvailable:"Keine Gruppen verfügbar",passwordsDoNotMatch:"Passwörter stimmen nicht überein",systemGroupWarning:"System-Gruppennamen können nicht geändert werden",authDisabledTitle:"Authentifizierung ist deaktiviert",authDisabledFeature1:"Anmeldung zum Zugriff auf das System erforderlich",authDisabledFeature2:"Mehrere Benutzer mit gruppenbasierten Berechtigungen erstellen",authDisabledFeature3:"Zugriff mit über 50 granularen Berechtigungen steuern",userHasCreated:"Dieser Benutzer hat erstellt:",userItemsQuestion:"Was möchten Sie mit diesen Elementen tun?",deleteUserConfirm:"Möchten Sie diesen Benutzer wirklich löschen?",actionCannotBeUndone:"Diese Aktion kann nicht rückgängig gemacht werden.",addFirstSmartPlug:"Ersten Smart Plug hinzufügen",providers:"Anbieter",log:"Protokoll",testAll:"Alle testen",testResults:"Testergebnisse",testPassedCount:"{{count}} bestanden",testFailedCount:"{{count}} fehlgeschlagen",messageTemplates:"Nachrichtenvorlagen",messageTemplatesDescription:"Passen Sie Benachrichtigungen für jedes Ereignis an.",apiKeys:"API-Schlüssel",apiKeysDescription:"Erstellen Sie API-Schlüssel für externe Integrationen und Webhooks.",createKey:"Schlüssel erstellen",apiKeyCreated:"API-Schlüssel erfolgreich erstellt",apiKeyCopyWarning:"Kopieren Sie diesen Schlüssel jetzt - er wird nicht mehr angezeigt!",useInApiBrowser:"Im API-Browser verwenden",createNewApiKey:"Neuen API-Schlüssel erstellen",keyName:"Schlüsselname",keyNamePlaceholder:"z.B. Home Assistant, OctoPrint",readStatus:"Status lesen",readStatusDescription:"Druckerstatus und Warteschlange anzeigen",manageQueue:"Warteschlange verwalten",manageQueueDescription:"Elemente zur Druckwarteschlange hinzufügen und entfernen",controlPrinter:"Drucker steuern",controlPrinterDescription:"Drucke pausieren, fortsetzen und stoppen",unnamedKey:"Unbenannter Schlüssel",lastUsed:"Zuletzt verwendet",read:"Lesen",control:"Steuern",createFirstKey:"Ersten Schlüssel erstellen",webhookEndpoints:"Webhook-Endpunkte",webhookApiKeyHint:"Verwenden Sie Ihren API-Schlüssel im X-API-Key-Header.",webhook:{getAllStatus:"Alle Druckerstatus abrufen",getSpecificStatus:"Spezifischen Druckerstatus abrufen",addToQueue:"Zur Druckwarteschlange hinzufügen",pausePrint:"Druck pausieren",resumePrint:"Druck fortsetzen",stopPrint:"Druck stoppen"},apiBrowser:"API-Browser",apiBrowserDescription:"Erkunden und testen Sie alle verfügbaren API-Endpunkte.",apiKeyForTesting:"API-Schlüssel zum Testen",apiKeyPlaceholder:"Fügen Sie hier Ihren API-Schlüssel ein, um authentifizierte Endpunkte zu testen...",apiKeyHint:"Dieser Schlüssel wird als X-API-Key-Header mit Anfragen gesendet.",deleteApiKeyTitle:"API-Schlüssel löschen",deleteApiKeyMessage:"Möchten Sie diesen API-Schlüssel wirklich löschen? Alle Integrationen, die diesen Schlüssel verwenden, funktionieren nicht mehr.",deleteKey:"Schlüssel löschen",amsDisplayThresholds:"AMS-Anzeigeschwellenwerte",amsThresholdsDescription:"Konfigurieren Sie Farbschwellenwerte für AMS-Feuchtigkeits- und Temperaturanzeigen.",humidity:"Luftfeuchtigkeit",goodGreen:"Gut (grün)",fairOrange:"Mittel (orange)",aboveFairBad:"Über dem mittleren Schwellenwert wird rot angezeigt (schlecht)",temperature:"Temperatur",goodBlue:"Gut (blau)",aboveFairHot:"Über dem mittleren Schwellenwert wird rot angezeigt (heiß)",historyRetention:"Verlaufsaufbewahrung",keepSensorHistory:"Sensorverlauf behalten für",historyRetentionDescription:"Ältere Feuchtigkeits- und Temperaturdaten werden automatisch gelöscht",printModal:"Druckdialog",expandCustomMapping:"Benutzerdefinierte Zuordnung standardmäßig erweitern",expandCustomMappingDescription:"Bei Druck auf mehrere Drucker die AMS-Zuordnung pro Drucker erweitert anzeigen",authentication:"Authentifizierung",authEnabledDescription:"Ihre Instanz ist mit Benutzerauthentifizierung gesichert",authDisabledDescription:"Aktivieren Sie die Anmeldepflicht und verwalten Sie den Benutzerzugriff",authDisabledMessage:"Aktivieren Sie die Authentifizierung, um Benutzerkonten zu erstellen, Berechtigungen zu verwalten und Ihre Bambuddy-Instanz zu sichern.",enableAuthentication:"Authentifizierung aktivieren",currentUser:"Aktueller Benutzer",changePassword:"Passwort ändern",admin:"Admin",users:"Benutzer",addUser:"Benutzer hinzufügen",groups:"Gruppen",addGroup:"Gruppe hinzufügen",system:"System",noDescription:"Keine Beschreibung",userCount:"{{count}} Benutzer",permissionCount:"{{count}} Berechtigungen",createUser:"Benutzer erstellen",username:"Benutzername",enterUsername:"Benutzername eingeben",password:"Passwort",enterPassword:"Passwort eingeben (min. 6 Zeichen)",confirmPassword:"Passwort bestätigen",confirmPasswordPlaceholder:"Passwort bestätigen",viewReleaseOnGitHub:"Release auf GitHub anzeigen",turnAllPlugsOn:"Alle Stecker einschalten",turnAllPlugsOff:"Alle Stecker ausschalten",clearNotificationLogs:"Benachrichtigungsprotokolle löschen",clearLogsMessage:"Dadurch werden alle Benachrichtigungsprotokolle, die älter als 30 Tage sind, dauerhaft gelöscht. Diese Aktion kann nicht rückgängig gemacht werden.",clearLogs:"Protokolle löschen",resetUiPreferences:"UI-Einstellungen zurücksetzen",resetUiPreferencesMessage:"Dadurch werden alle UI-Einstellungen auf Standardwerte zurückgesetzt: Seitenleisten-Reihenfolge, Theme, Dashboard-Layout, Ansichtsmodi und Sortiereinstellungen. Ihre Drucker, Archive und Servereinstellungen werden NICHT beeinträchtigt. Die Seite wird nach dem Löschen neu geladen.",resetPreferences:"Einstellungen zurücksetzen",deleteGroupTitle:"Gruppe löschen",deleteGroupMessage:"Möchten Sie diese Gruppe wirklich löschen? Benutzer in dieser Gruppe verlieren diese Berechtigungen.",deleteGroup:"Gruppe löschen",disableAuthenticationTitle:"Authentifizierung deaktivieren",disableAuthenticationMessage:"Möchten Sie die Authentifizierung wirklich deaktivieren? Dadurch wird Ihre Bambuddy-Instanz ohne Anmeldung zugänglich. Alle Benutzer bleiben in der Datenbank, aber die Authentifizierung wird deaktiviert.",disableAuthentication:"Authentifizierung deaktivieren",configureBambuddy:"Bambuddy konfigurieren",systemDefault:"Systemstandard",archiveSettings:"Archiv-Einstellungen",newWindow:"Neues Fenster",embeddedOverlay:"Eingebettetes Overlay",externalCameras:"Externe Kameras",costTracking:"Kostenverfolgung",printsOnly:"Nur Drucke",totalConsumption:"Gesamtverbrauch",dataManagement:"Datenverwaltung",clearNotificationLogsDescription:"Benachrichtigungsprotokolle älter als 30 Tage löschen",resetUiPreferencesDescription:"Seitenleisten-Reihenfolge, Theme, Ansichtsmodi und Layout-Einstellungen zurücksetzen. Drucker, Archive und Einstellungen werden nicht beeinflusst.",enableHomeAssistant:"Home Assistant aktivieren",enableMqtt:"MQTT aktivieren",useTls:"TLS verwenden",enableMetricsEndpoint:"Metrik-Endpunkt aktivieren",availableMetrics:"Verfügbare Metriken",editUser:"Benutzer bearbeiten",deleteUserTitle:"Benutzer löschen",groupName:"Gruppenname",leaveEmptyForAnonymous:"Leer lassen für anonym",leaveEmptyForNoAuth:"Leer lassen für keine Authentifizierung",enterNewPassword:"Neues Passwort eingeben",confirmNewPassword:"Neues Passwort bestätigen",enterGroupName:"Gruppenname eingeben",enterDescriptionOptional:"Beschreibung eingeben (optional)",enterCurrentPassword:"Aktuelles Passwort eingeben",enterNewPasswordMin6:"Neues Passwort eingeben (min. 6 Zeichen)",toast:{keyCopied:"Schlüssel in Zwischenablage kopiert",copyFailed:"Schlüssel konnte nicht kopiert werden",keyAddedToBrowser:"Schlüssel zum API-Browser hinzugefügt",clearLogsFailed:"Protokolle konnten nicht gelöscht werden",uiPreferencesReset:"UI-Einstellungen zurückgesetzt. Wird neu geladen...",authDisabled:"Authentifizierung erfolgreich deaktiviert",authDisableFailed:"Authentifizierung konnte nicht deaktiviert werden",apiKeyCreated:"API-Schlüssel erstellt",apiKeyDeleted:"API-Schlüssel gelöscht",userCreated:"Benutzer erfolgreich erstellt",userUpdated:"Benutzer erfolgreich aktualisiert",userDeleted:"Benutzer erfolgreich gelöscht",groupCreated:"Gruppe erfolgreich erstellt",groupUpdated:"Gruppe erfolgreich aktualisiert",groupDeleted:"Gruppe erfolgreich gelöscht",fillRequiredFields:"Bitte füllen Sie alle erforderlichen Felder aus",passwordsDoNotMatch:"Passwörter stimmen nicht überein",passwordTooShort:"Passwort muss mindestens 6 Zeichen lang sein",enterGroupName:"Bitte geben Sie einen Gruppennamen ein",settingsSaved:"Einstellungen gespeichert",cameraSettingsSaved:"Kamera-Einstellungen gespeichert",enterCameraUrl:"Bitte geben Sie eine Kamera-URL ein",passwordChanged:"Passwort erfolgreich geändert",connectionFailed:"Verbindung fehlgeschlagen",testFailed:"Test fehlgeschlagen",cameraConnected:"Kamera verbunden{{resolution}}"},testConnection:"Verbindung testen"},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"},hmsErrors:{title:"Fehler - {{name}}",noErrors:"Keine Fehler",viewOnWiki:"Im Bambu Lab Wiki ansehen",clearInstructions:"Löschen Sie die Fehler am Drucker, um sie hier zu entfernen."},mqttDebug:{title:"MQTT-Debug-Protokoll",searchPlaceholder:"Topic oder Payload suchen...",noMessages:"Noch keine Nachrichten protokolliert",startLoggingHint:'Klicken Sie auf "Protokollierung starten", um MQTT-Nachrichten aufzuzeichnen',noMessagesMatch:"Keine Nachrichten entsprechen Ihrem Filter",adjustFilterHint:"Versuchen Sie, Ihre Such- oder Filterkriterien anzupassen",incoming:"Eingehend",outgoing:"Ausgehend",loggingStopped:"Protokollierung gestoppt",loggingActive:"Protokollierung aktiv - Nachrichten werden automatisch aktualisiert",startLogging:"Protokollierung starten",stopLogging:"Protokollierung stoppen",clearLog:"Protokoll löschen",topic:"Topic",timestamp:"Zeitstempel",direction:"Richtung",all:"Alle"},printerFiles:{title:"Dateimanager",storageUsed:"Belegt:",storageFree:"Frei:",filterPlaceholder:"Dateien filtern...",deleteButton:"Löschen",deleteFiles:"{{count}} Dateien löschen",deleteFileConfirm:'"{{name}}" löschen? Dies kann nicht rückgängig gemacht werden.',deleteFilesConfirm:"{{count}} ausgewählte Dateien löschen? Dies kann nicht rückgängig gemacht werden.",noFiles:"Keine Dateien auf dem Drucker",loadingFiles:"Dateien werden geladen...",failedToLoad:"Dateien konnten nicht geladen werden",toast:{filesDeleted:"{{count}} Datei(en) gelöscht",deleteFailed:"Löschen fehlgeschlagen: {{error}}"}},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?"},login:{title:"Bambuddy Anmeldung",subtitle:"Melden Sie sich bei Ihrem Konto an",username:"Benutzername",usernamePlaceholder:"Benutzername eingeben",password:"Passwort",passwordPlaceholder:"Passwort eingeben",signIn:"Anmelden",signingIn:"Anmeldung läuft...",forgotPassword:"Passwort vergessen?",loginSuccess:"Erfolgreich angemeldet",loginFailed:"Anmeldung fehlgeschlagen",enterCredentials:"Bitte Benutzername und Passwort eingeben",forgotPasswordTitle:"Passwort vergessen",forgotPasswordMessage:"Wenn Sie Ihr Passwort vergessen haben, wenden Sie sich bitte an Ihren Systemadministrator.",howToReset:"So setzen Sie Ihr Passwort zurück:",resetStep1:"Kontaktieren Sie Ihren Bambuddy-Administrator",resetStep2:"Bitten Sie ihn, Ihr Passwort in der Benutzerverwaltung zurückzusetzen",resetStep3:"Er kann ein neues temporäres Passwort für Sie festlegen",resetStep4:"Melden Sie sich mit dem neuen Passwort an und ändern Sie es in den Einstellungen",gotIt:"Verstanden"},setup:{title:"Bambuddy Einrichtung",subtitle:"Konfigurieren Sie die Authentifizierung für Ihre Bambuddy-Instanz",enableAuth:"Authentifizierung aktivieren",adminAccount:"Admin-Konto",adminAccountDesc:"Wenn bereits Admin-Benutzer existieren, wird die Authentifizierung mit den vorhandenen Admin-Konten aktiviert. Lassen Sie die Felder unten leer, um vorhandene Admins zu verwenden, oder geben Sie neue Anmeldedaten ein, um einen neuen Admin-Benutzer zu erstellen.",adminUsername:"Admin-Benutzername",adminPassword:"Admin-Passwort",optionalIfAdminExists:"(optional, wenn Admin-Benutzer existieren)",adminUsernamePlaceholder:"Admin-Benutzernamen eingeben (optional)",adminPasswordPlaceholder:"Admin-Passwort eingeben (optional)",confirmPassword:"Passwort bestätigen",confirmPasswordPlaceholder:"Admin-Passwort bestätigen",settingUp:"Einrichtung läuft...",completeSetup:"Einrichtung abschließen",toast:{authEnabledAdminCreated:"Authentifizierung aktiviert und Admin-Benutzer erstellt",authEnabledExistingAdmins:"Authentifizierung mit vorhandenen Admin-Benutzern aktiviert",setupCompleted:"Einrichtung abgeschlossen",enterBothCredentials:"Bitte geben Sie sowohl Admin-Benutzernamen als auch Passwort ein, oder lassen Sie beide leer, um vorhandene Admin-Benutzer zu verwenden",passwordsDoNotMatch:"Passwörter stimmen nicht überein",passwordTooShort:"Passwort muss mindestens 6 Zeichen lang sein"}},changePassword:{title:"Passwort ändern",currentPassword:"Aktuelles Passwort",currentPasswordPlaceholder:"Aktuelles Passwort eingeben",newPassword:"Neues Passwort",newPasswordPlaceholder:"Neues Passwort eingeben (min. 6 Zeichen)",confirmPassword:"Neues Passwort bestätigen",confirmPasswordPlaceholder:"Neues Passwort bestätigen",passwordsDoNotMatch:"Passwörter stimmen nicht überein",passwordTooShort:"Passwort muss mindestens 6 Zeichen lang sein",changing:"Wird geändert...",success:"Passwort erfolgreich geändert",failed:"Passwortänderung fehlgeschlagen"},plateAlert:{title:"Druck pausiert!",message:"Objekte auf dem Druckbett erkannt. Der Druck wurde automatisch pausiert. Bitte räumen Sie das Druckbett und setzen Sie den Druck fort.",understand:"Verstanden"},camera:{title:"Kameraansicht",invalidPrinterId:"Ungültige Drucker-ID",live:"Live",snapshot:"Schnappschuss",restartStream:"Stream neu starten",refreshSnapshot:"Schnappschuss aktualisieren",fullscreen:"Vollbild",exitFullscreen:"Vollbild beenden",connectingToCamera:"Verbinde mit Kamera...",capturingSnapshot:"Schnappschuss wird aufgenommen...",connectionLost:"Verbindung verloren",connectionFailed:"Kameraverbindung fehlgeschlagen",reconnecting:"Neuverbindung in {{countdown}}s... (Versuch {{attempt}}/{{max}})",reconnectNow:"Jetzt verbinden",cameraUnavailable:"Kamera nicht verfügbar",cameraUnavailableDesc:"Stellen Sie sicher, dass der Drucker eingeschaltet und verbunden ist.",noCamera:"Keine Kamera verfügbar",retry:"Erneut versuchen",cameraStream:"Kamera-Stream",zoomOut:"Verkleinern",zoomIn:"Vergrößern",resetZoom:"Zoom zurücksetzen",recording:"Aufnahme",startRecording:"Aufnahme starten",stopRecording:"Aufnahme stoppen"},groups:{title:"Gruppenverwaltung",subtitle:"Berechtigungsgruppen für Zugriffskontrolle verwalten",backToSettings:"Zurück zu Einstellungen",createGroup:"Gruppe erstellen",noPermission:"Sie haben keine Berechtigung, auf diese Seite zuzugreifen.",system:"System",noDescription:"Keine Beschreibung",usersCount:"{{count}} Benutzer",permissionsCount:"{{count}} Berechtigungen",edit:"Bearbeiten",delete:"Löschen",toast:{created:"Gruppe erfolgreich erstellt",updated:"Gruppe erfolgreich aktualisiert",deleted:"Gruppe erfolgreich gelöscht",enterGroupName:"Bitte geben Sie einen Gruppennamen ein"},modal:{editGroup:"Gruppe bearbeiten",createGroup:"Gruppe erstellen",cancel:"Abbrechen",saving:"Speichern...",creating:"Erstellen...",saveChanges:"Änderungen speichern"},form:{groupName:"Gruppenname",groupNamePlaceholder:"Gruppennamen eingeben",systemGroupWarning:"Systemgruppennamen können nicht geändert werden",description:"Beschreibung",descriptionPlaceholder:"Beschreibung eingeben (optional)",permissions:"Berechtigungen ({{count}} ausgewählt)"},deleteModal:{title:"Gruppe löschen",message:"Sind Sie sicher, dass Sie diese Gruppe löschen möchten? Benutzer in dieser Gruppe verlieren diese Berechtigungen.",confirm:"Gruppe löschen"}},users:{title:"Benutzerverwaltung",subtitle:"Benutzer und deren Zugriff auf Ihre Bambuddy-Instanz verwalten",backToSettings:"Zurück zu Einstellungen",createUser:"Benutzer erstellen",noPermission:"Sie haben keine Berechtigung, auf diese Seite zuzugreifen.",admin:"Admin",noGroups:"Keine Gruppen",active:"Aktiv",inactive:"Inaktiv",edit:"Bearbeiten",delete:"Löschen",system:"System",noGroupsAvailable:"Keine Gruppen verfügbar",table:{username:"Benutzername",groups:"Gruppen",status:"Status",actions:"Aktionen"},toast:{created:"Benutzer erfolgreich erstellt",updated:"Benutzer erfolgreich aktualisiert",deleted:"Benutzer erfolgreich gelöscht",fillRequired:"Bitte füllen Sie alle Pflichtfelder aus",passwordsDoNotMatch:"Passwörter stimmen nicht überein",passwordTooShort:"Passwort muss mindestens 6 Zeichen lang sein"},modal:{createUser:"Benutzer erstellen",editUser:"Benutzer bearbeiten",cancel:"Abbrechen",creating:"Erstellen...",saving:"Speichern...",saveChanges:"Änderungen speichern"},form:{username:"Benutzername",usernamePlaceholder:"Benutzernamen eingeben",password:"Passwort",passwordPlaceholder:"Passwort eingeben",confirmPassword:"Passwort bestätigen",confirmPasswordPlaceholder:"Passwort bestätigen",newPasswordPlaceholder:"Neues Passwort eingeben",confirmNewPasswordPlaceholder:"Neues Passwort bestätigen",leaveBlankToKeep:"leer lassen, um das aktuelle zu behalten",groups:"Gruppen"},deleteModal:{title:"Benutzer löschen",message:"Sind Sie sicher, dass Sie diesen Benutzer löschen möchten? Diese Aktion kann nicht rückgängig gemacht werden.",confirm:"Benutzer löschen"}},streamOverlay:{title:"Stream-Overlay",invalidPrinterId:"Ungültige Drucker-ID",cameraStream:"Kamera-Stream",progress:"Fortschritt",eta:"ETA",tomorrow:"Morgen",printerIdle:"Drucker ist inaktiv",printerOffline:"Drucker offline",status:{printing:"Druckt",paused:"Pausiert",finished:"Fertig",failed:"Fehlgeschlagen",idle:"Inaktiv",unknown:"Unbekannt"}},profiles:{title:"Profile",subtitle:"Verwalten Sie Ihre Slicer-Voreinstellungen und Druckvorschub-Kalibrierungen",tabs:{cloud:"Cloud-Profile",kprofiles:"K-Profile"},connectedAs:"Verbunden als",logout:"Abmelden",noLogoutPermission:"Sie haben keine Berechtigung zum Abmelden",failedToLoad:"Profile konnten nicht geladen werden",retry:"Erneut versuchen",time:{justNow:"Gerade eben",minsAgo:"vor {{count}}m",hoursAgo:"vor {{count}}h",daysAgo:"vor {{count}}d"},toast:{loggedOut:"Abgemeldet"},login:{title:"Mit Bambu Cloud verbinden",subtitle:"Synchronisieren Sie Ihre Slicer-Voreinstellungen geräteübergreifend",email:"E-Mail",password:"Passwort",region:"Region",regionGlobal:"Global",regionChina:"China",verificationCode:"Bestätigungscode",checkEmail:"Prüfen Sie Ihre E-Mail ({{email}}) für einen 6-stelligen Code",accessToken:"Zugriffstoken",accessTokenHint:"Fügen Sie Ihr Bambu Lab Zugriffstoken ein (aus Bambu Studio)",back:"Zurück",loginButton:"Anmelden",verifyButton:"Bestätigen",setTokenButton:"Token setzen",useToken:"Stattdessen Zugriffstoken verwenden",useEmail:"Stattdessen mit E-Mail anmelden",toast:{loggedIn:"Erfolgreich angemeldet",codeSent:"Bestätigungscode an Ihre E-Mail gesendet",tokenSet:"Token erfolgreich gesetzt"}},presets:{myPreset:"Mein Profil (bearbeitbar)",duplicate:"Duplizieren",editable:"Bearbeitbar",failedToLoadDetails:"Profil-Details konnten nicht geladen werden",deleteConfirm:"Dieses Profil löschen?",deleteWarning:'"{{name}}" wird dauerhaft aus Bambu Cloud gelöscht. Dies kann nicht rückgängig gemacht werden.',noDuplicatePermission:"Sie haben keine Berechtigung zum Duplizieren von Profilen",noEditPermission:"Sie haben keine Berechtigung zum Bearbeiten von Profilen",noDeletePermission:"Sie haben keine Berechtigung zum Löschen von Profilen",types:{filament:"Filament-Profil",printer:"Drucker-Profil",process:"Prozess-Profil"},toast:{deleted:"Profil gelöscht",created:"Profil erstellt",updated:"Profil aktualisiert",duplicated:"Profil dupliziert",fieldAdded:'Feld "{{key}}" hinzugefügt',exported:"Profil exportiert"},baseLabel:"Basis: {{name}}",currentLabel:"Aktuell: {{name}}",newPreset:"Neues Profil",editPreset:"Profil bearbeiten",duplicatePreset:"Profil duplizieren",createNewPreset:"Neues Profil erstellen",customizeSettings:"Passen Sie die Einstellungen für Ihr neues Profil an",compareWithBase:"Mit Basis-Profil vergleichen",compare:"Vergleichen",basePreset:"Basis-Profil",selectBasePreset:"Basis-Profil auswählen...",presetName:"Profilname",myCustomPreset:"Mein eigenes Profil",inheritsFrom:"Erbt von",dropJsonToImport:"JSON zum Importieren ablegen",tabs:{common:"Allgemein",allFields:"Alle Felder"},availableFields:"Verfügbare Felder",searchFieldsPlaceholder:"Felder suchen...",noMatchingFields:"Keine passenden Felder",allFieldsAdded:"Alle Felder hinzugefügt",addCustomField:"Eigenes Feld hinzufügen",yourOverrides:"Ihre Überschreibungen",noOverridesYet:"Noch keine Überschreibungen",clickFieldsToAdd:"Klicken Sie links auf Felder, um sie hinzuzufügen",saveAsTemplate:"Als Vorlage speichern",jsonTip:"Tipp: Ziehen Sie eine .json-Datei auf dieses Fenster, um Einstellungen zu importieren"},cloudView:{searchPlaceholder:"Profile suchen...",templates:"Vorlagen",refresh:"Aktualisieren",newPreset:"Neues Profil",clearFilters:"Filter zurücksetzen",compareMode:"Vergleichsmodus",selectAnotherPreset:"Wählen Sie ein weiteres {{type}}-Profil",clickTwoPresets:"Klicken Sie auf zwei Profile des gleichen Typs zum Vergleichen",selectFirst:"1. Erstes auswählen",selectSecond:"2. Zweites auswählen",compareNow:"Jetzt vergleichen",lastSynced:"Zuletzt synchronisiert:",showingCount:"{{showing}} von {{total}} Profilen",noPresetsFound:"Keine Profile gefunden",columns:{filament:"Filament",process:"Prozess",printer:"Drucker"},noFilamentPresets:"Keine Filament-Profile",noProcessPresets:"Keine Prozess-Profile",noPrinterPresets:"Keine Drucker-Profile",filters:{type:"Typ",owner:"Besitzer",printer:"Drucker",nozzle:"Düse",filament:"Filament",layer:"Schicht",all:"Alle",myPresets:"Meine Profile",builtIn:"Voreingestellt",process:"Prozess"},noTemplatesPermission:"Sie haben keine Berechtigung, Vorlagen zu verwalten",noRefreshPermission:"Sie haben keine Berechtigung, Profile zu aktualisieren",noCreatePermission:"Sie haben keine Berechtigung, Profile zu erstellen"},templates:{title:"Schnellvorlagen",noTemplates:"Noch keine Vorlagen",createFirst:"Erstellen Sie Vorlagen aus dem Preset-Editor",typeFilter:"Typ:",deleteTitle:"Vorlage löschen",deleteWarning:"Diese Aktion kann nicht rückgängig gemacht werden",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',namePlaceholder:"Vorlagenname",descriptionPlaceholder:"Beschreibung",settingsJson:"Einstellungen (JSON)",fieldsCount:"{{count}} Felder",shownInModals:"In Dialogen angezeigt",hiddenInModals:"In Dialogen ausgeblendet",apply:"Anwenden",toast:{deleted:"Vorlage gelöscht",updated:"Vorlage aktualisiert",created:"Vorlage erstellt",applied:"Vorlage angewendet"}}},support:{debugLoggingActive:"Debug-Protokollierung ist aktiv",manageLogs:"Verwalten"},fileManager:{title:"Dateimanager",subtitle:"Organisieren und verwalten Sie Ihre Druckdateien",uploadFiles:"Dateien hochladen",newFolder:"Neuer Ordner",folderName:"Ordnername",folderNamePlaceholder:"z.B. Funktionsteile",renameFile:"Datei umbenennen",renameFolder:"Ordner umbenennen",moveFiles:"{{count}} Datei(en) verschieben",rootNoFolder:"Stammverzeichnis (Kein Ordner)",current:"aktuell",linkFolder:"Ordner verknüpfen",linkFolderDescription:'"{{name}}" mit einem Projekt oder Archiv verknüpfen für schnellen Zugriff.',project:"Projekt",archive:"Archiv",noProjectsFound:"Keine Projekte gefunden",noArchivesFound:"Keine Archive gefunden",unlink:"Verknüpfung aufheben",link:"Verknüpfen",dragDropFiles:"Dateien hierher ziehen",dropFilesHere:"Dateien hier ablegen",orClickToBrowse:"oder klicken zum Durchsuchen",allFileTypesSupported:"Alle Dateitypen werden unterstützt. ZIP-Dateien werden extrahiert.",zipFilesDetected:"ZIP-Dateien erkannt",zipExtractOptions:"ZIP-Dateien werden extrahiert. Wählen Sie, wie die Ordnerstruktur behandelt werden soll:",preserveZipStructure:"Ordnerstruktur aus ZIP beibehalten",createFolderFromZip:"Ordner aus ZIP-Dateiname erstellen",stlThumbnailGeneration:"STL-Vorschaubildgenerierung",zipMayContainStl:"ZIP-Dateien können STL-Dateien enthalten. Vorschaubilder können während der Extraktion generiert werden.",thumbnailsCanBeGenerated:"Vorschaubilder können für STL-Dateien generiert werden. Große Modelle benötigen möglicherweise mehr Zeit.",generateThumbnailsForStl:"Vorschaubilder für STL-Dateien generieren",willBeExtracted:"Wird extrahiert",filesExtracted:"{{count}} Dateien extrahiert",uploadComplete:"Upload abgeschlossen: {{succeeded}} erfolgreich",uploadFailed:"{{count}} fehlgeschlagen",uploading:"Hochladen...",changeLink:"Verknüpfung ändern...",linkTo:"Verknüpfen mit...",linkToProjectOrArchive:"Mit Projekt oder Archiv verknüpfen",addToQueue:"Zur Warteschlange",generateThumbnail:"Vorschaubild generieren",generateThumbnails:"Vorschaubilder generieren",generateThumbnailsForMissing:"Vorschaubilder für STL-Dateien ohne Vorschau generieren",gridView:"Rasteransicht",listView:"Listenansicht",lowDiskSpaceWarning:"Warnung: Wenig Speicherplatz",lowDiskSpaceDetails:"Nur {{free}} frei von {{total}} gesamt. Schwellenwert ist auf {{threshold}} GB eingestellt.",files:"Dateien",folders:"Ordner",size:"Größe",free:"Frei",allFiles:"Alle Dateien",wrap:"Umbrechen",enableTextWrapping:"Textumbruch aktivieren",disableTextWrapping:"Textumbruch deaktivieren",dragToResizeTooltip:"Ziehen zum Ändern der Größe, Doppelklick zum Zurücksetzen",searchFiles:"Dateien suchen...",allTypes:"Alle Typen",prints:"Drucke",ascending:"Aufsteigend",descending:"Absteigend",resultsCount:"{{showing}} von {{total}} Dateien",selectAll:"Alle auswählen",deselectAll:"Auswahl aufheben",selected:"{{count}} ausgewählt",adding:"Hinzufügen...",loadingFiles:"Dateien werden geladen...",folderIsEmpty:"Ordner ist leer",noFilesYet:"Noch keine Dateien",folderEmptyDescription:"Laden Sie Dateien hoch oder verschieben Sie Dateien in diesen Ordner.",noFilesDescription:"Laden Sie Dateien hoch, um Ihre Druckdateien zu organisieren.",noMatchingFiles:"Keine passenden Dateien",noMatchingFilesDescription:"Keine Dateien entsprechen Ihren aktuellen Such- oder Filterkriterien.",clearFilters:"Filter zurücksetzen",printedCount:"{{count}}x gedruckt",uploadedBy:"Hochgeladen von {{name}}",deleteFolder:"Ordner löschen",deleteFile:"Datei löschen",deleteFilesCount:"{{count}} Dateien löschen",deleteFolderConfirm:"Möchten Sie diesen Ordner wirklich löschen? Alle Dateien darin werden ebenfalls gelöscht.",deleteFileConfirm:"Möchten Sie diese Datei wirklich löschen?",deleteFilesConfirm:"Möchten Sie {{count}} ausgewählte Dateien wirklich löschen? Diese Aktion kann nicht rückgängig gemacht werden.",deleting:"Wird gelöscht...",noPermissionRenameFolder:"Sie haben keine Berechtigung, Ordner umzubenennen",noPermissionLinkFolder:"Sie haben keine Berechtigung, Ordner zu verknüpfen",noPermissionDeleteFolder:"Sie haben keine Berechtigung, Ordner zu löschen",noPermissionPrint:"Sie haben keine Berechtigung zum Drucken",noPermissionAddToQueue:"Sie haben keine Berechtigung, zur Warteschlange hinzuzufügen",noPermissionDownload:"Sie haben keine Berechtigung, Dateien herunterzuladen",noPermissionRenameFile:"Sie haben keine Berechtigung, diese Datei umzubenennen",noPermissionGenerateThumbnail:"Sie haben keine Berechtigung, Vorschaubilder zu generieren",noPermissionDeleteFile:"Sie haben keine Berechtigung, diese Datei zu löschen",noPermissionCreateFolder:"Sie haben keine Berechtigung, Ordner zu erstellen",noPermissionUpload:"Sie haben keine Berechtigung, Dateien hochzuladen",noPermissionMoveFiles:"Sie haben keine Berechtigung, Dateien zu verschieben",noPermissionDeleteFiles:"Sie haben keine Berechtigung, Dateien zu löschen",toast:{folderCreated:"Ordner erstellt",folderDeleted:"Ordner gelöscht",fileDeleted:"Datei gelöscht",filesDeleted:"{{count}} Dateien gelöscht",filesMoved:"Dateien verschoben",folderLinked:"Ordner verknüpft",folderUnlinked:"Ordnerverknüpfung aufgehoben",addedToQueue:"{{count}} Datei(en) zur Warteschlange hinzugefügt",addedToQueuePartial:"{{added}} Datei(en) hinzugefügt, {{failed}} fehlgeschlagen",failedToAddToQueue:"Fehler beim Hinzufügen: {{error}}",fileRenamed:"Datei umbenannt",folderRenamed:"Ordner umbenannt",thumbnailsGenerated:"{{count}} Vorschaubild(er) generiert",thumbnailsGeneratedPartial:"{{succeeded}} Vorschaubild(er) generiert, {{failed}} fehlgeschlagen",noStlMissingThumbnails:"Keine STL-Dateien ohne Vorschaubild",failedToGenerateThumbnails:"Fehler beim Generieren der Vorschaubilder: {{error}}",thumbnailGenerated:"Vorschaubild generiert",failedToGenerateThumbnail:"Fehler beim Generieren des Vorschaubildes: {{error}}"}},projects:{title:"Projekte",subtitle:"Organisieren und verfolgen Sie Ihre 3D-Druckprojekte",newProject:"Neues Projekt",editProject:"Projekt bearbeiten",deleteProject:"Projekt löschen",projectName:"Projektname",description:"Beschreibung",noProjects:"Noch keine Projekte",noProjectsFiltered:"Keine {{status}} Projekte",noProjectsFilteredHelp:"Sie haben keine {{status}} Projekte. Projekte werden hier angezeigt, wenn sich ihr Status ändert.",createFirst:"Erstellen Sie Ihr erstes Projekt, um verwandte Drucke zu organisieren, den Fortschritt zu verfolgen und Ihre Builds zu verwalten.",createFirstButton:"Erstes Projekt erstellen",create:"Erstellen",files:"Dateien",prints:"Drucke",plates:"Platten",parts:"Teile",lastModified:"Zuletzt geändert",deleteConfirm:"Möchten Sie dieses Projekt wirklich löschen? Archive und Warteschlangenelemente werden getrennt, aber nicht gelöscht.",addFiles:"Dateien hinzufügen",removeFile:"Datei entfernen",viewDetails:"Details anzeigen",namePlaceholder:"z.B. Voron 2.4 Build",descriptionPlaceholder:"Optionale Beschreibung...",color:"Farbe",targetPlates:"Ziel-Platten",targetPlatesPlaceholder:"z.B. 25",targetPlatesHelp:"Anzahl der Druckaufträge",targetParts:"Ziel-Teile",targetPartsPlaceholder:"z.B. 150",targetPartsHelp:"Benötigte Objekte insgesamt",tagsLabel:"Tags (kommagetrennt)",tagsPlaceholder:"z.B. voron, funktional, geschenk",dueDate:"Fälligkeitsdatum",priority:"Priorität",priorityLow:"Niedrig",priorityNormal:"Normal",priorityHigh:"Hoch",priorityUrgent:"Dringend",statusActive:"Aktiv",statusCompleted:"Abgeschlossen",statusArchived:"Archiviert",done:"Fertig",completed:"abgeschlossen",failed:"fehlgeschlagen",inQueue:"in Warteschlange",noPrintsYet:"Noch keine Drucke",printJobs:"Druckaufträge (Platten)",partsPrinted:"Gedruckte Teile",failedParts:"Fehlgeschlagene Teile",import:"Importieren",export:"Exportieren",importProject:"Projekt importieren",exportAll:"Alle Projekte exportieren",loading:"Projekte werden geladen...",noEditPermission:"Sie haben keine Berechtigung, Projekte zu bearbeiten",noDeletePermission:"Sie haben keine Berechtigung, Projekte zu löschen",noCreatePermission:"Sie haben keine Berechtigung, Projekte zu erstellen",noImportPermission:"Sie haben keine Berechtigung, Projekte zu importieren",noExportPermission:"Sie haben keine Berechtigung, Projekte zu exportieren",toast:{created:"Projekt erstellt",updated:"Projekt aktualisiert",deleted:"Projekt gelöscht",imported:"Projekt importiert",multipleImported:"{{count}} Projekte importiert",importFailed:"Import fehlgeschlagen",exported:"Projekte exportiert (nur Metadaten)"}},projectDetail:{notFound:"Projekt nicht gefunden",backToProjects:"Zurück zu Projekten",export:"Exportieren",exportProject:"Projekt exportieren",noExportPermission:"Sie haben keine Berechtigung, Projekte zu exportieren",noEditPermission:"Sie haben keine Berechtigung, Projekte zu bearbeiten",partOf:"Teil von:",priorityLabel:"Priorität:",noPrints:"Noch keine Drucke in diesem Projekt",status:{active:"Aktiv",completed:"Abgeschlossen",archived:"Archiviert"},priority:{low:"Niedrig",normal:"Normal",high:"Hoch",urgent:"Dringend"},dueDate:{overdue:"Überfällig",today:"Heute fällig",daysLeft:"{{count}} Tage übrig"},progress:{platesProgress:"Platten-Fortschritt",partsProgress:"Teile-Fortschritt",printJobs:"Druckaufträge",parts:"Teile",percentComplete:"{{percent}}% abgeschlossen",remaining:"{{count}} verbleibend"},stats:{printJobs:"Druckaufträge",total:"gesamt",failed:"{{count}} fehlgeschlagen",partsPrinted:"{{count}} Teile gedruckt",printTime:"Druckzeit",filamentUsed:"Filament verbraucht"},cost:{title:"Kostenverfolgung",filamentCost:"Filamentkosten",energy:"Energie",budget:"Budget",remaining:"Verbleibend"},subProjects:{title:"Unterprojekte ({{count}})"},notes:{title:"Notizen",noEditPermission:"Sie haben keine Berechtigung, Notizen zu bearbeiten",placeholder:"Notizen zu diesem Projekt hinzufügen...",empty:"Noch keine Notizen. Klicken Sie auf Bearbeiten, um Notizen hinzuzufügen."},files:{title:"Dateien",linkFolders:"Ordner aus dem Dateimanager verknüpfen",forQuickAccess:"für schnellen Zugriff auf dieses Projekt.",fileCount:"{{count}} Datei(en)",empty:"Keine Ordner verknüpft. Gehen Sie zum Dateimanager und verknüpfen Sie einen Ordner mit diesem Projekt."},bom:{title:"Stückliste",acquired:"{{completed}}/{{total}} beschafft",showAll:"Alle anzeigen",hideDone:"Erledigte ausblenden",addPart:"Teil hinzufügen",noAddPermission:"Sie haben keine Berechtigung, Teile hinzuzufügen",partNamePlaceholder:"Teilename (z.B. M3x8 Schrauben)",partName:"Teilename",qty:"Menge",price:"Preis ({{currency}})",sourcingUrlPlaceholder:"Bezugsquelle-URL (optional)",remarksPlaceholder:"Bemerkungen (optional)",deletePart:"Teil löschen",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',noUpdatePermission:"Sie haben keine Berechtigung, Teile zu aktualisieren",noEditPermission:"Sie haben keine Berechtigung, Teile zu bearbeiten",noDeletePermission:"Sie haben keine Berechtigung, Teile zu löschen",totalCost:"Gesamtkosten:",empty:"Keine Teile in der Stückliste. Fügen Sie Hardware, Elektronik oder andere Komponenten hinzu, um zu verfolgen, was beschafft werden muss."},timeline:{title:"Aktivitätsverlauf",empty:"Noch keine Aktivität."},template:{saveAsTemplate:"Als Vorlage speichern",noCreatePermission:"Sie haben keine Berechtigung, Vorlagen zu erstellen"},queue:{title:"Warteschlange",viewAll:"Alle anzeigen",printing:"{{count}} druckend",queued:"{{count}} in Warteschlange"},prints:{title:"Drucke ({{count}})"},toast:{projectUpdated:"Projekt aktualisiert",partAdded:"Teil hinzugefügt",partRemoved:"Teil entfernt",exportFailed:"Export fehlgeschlagen",projectExported:"Projekt exportiert",templateCreated:"Vorlage erstellt"}},system:{title:"Systeminformationen",version:"Version",uptime:"Laufzeit",cpuUsage:"CPU-Auslastung",memoryUsage:"Speicherauslastung",diskUsage:"Festplattenauslastung",networkInfo:"Netzwerkinformationen",logs:"Protokolle",debugMode:"Debug-Modus",enableDebug:"Debug-Protokollierung aktivieren",disableDebug:"Debug-Protokollierung deaktivieren",downloadLogs:"Protokolle herunterladen",clearLogs:"Protokolle löschen",dockerInfo:"Docker-Info",containerName:"Container-Name",imageName:"Image-Name",platform:"Plattform",architecture:"Architektur"},library:{title:"Filament-Bibliothek",addFilament:"Filament hinzufügen",editFilament:"Filament bearbeiten",deleteFilament:"Filament löschen",vendor:"Hersteller",material:"Material",color:"Farbe",kFactor:"K-Faktor",temperature:"Temperatur",noFilaments:"Keine Filamente in der Bibliothek",deleteConfirm:"Möchten Sie dieses Filament wirklich löschen?",importFromPrinter:"Vom Drucker importieren",exportToFile:"In Datei exportieren"},spoolman:{title:"Spoolman-Integration",enabled:"Spoolman aktiviert",url:"Spoolman URL",connected:"Verbunden",disconnected:"Nicht verbunden",testConnection:"Verbindung testen",sync:"Synchronisieren",syncing:"Synchronisiert...",lastSync:"Letzte Synchronisierung",linkToSpoolman:"Mit Spoolman verknüpfen",openInSpoolman:"In Spoolman öffnen",unlinkSpool:"Spule trennen",selectSpool:"Spule auswählen",noUnlinkedSpools:"Keine nicht verknüpften Spulen verfügbar",linkSuccess:"Spule erfolgreich mit Spoolman verknüpft",linkFailed:"Verknüpfung mit Spoolman fehlgeschlagen",spoolId:"Spulen-ID",weight:"Gewicht",remaining:"Verbleibend"},timelapse:{title:"Zeitraffer",create:"Zeitraffer erstellen",download:"Herunterladen",delete:"Löschen",preview:"Vorschau",frameRate:"Bildrate",quality:"Qualität",processing:"Wird verarbeitet...",noTimelapses:"Keine Zeitraffer verfügbar"},ams:{title:"AMS",slot:"Slot",empty:"Leer",emptySlot:"Leerer Slot",unknown:"Unbekannt",humidity:"Luftfeuchtigkeit",temperature:"Temperatur",filamentType:"Filamenttyp",filamentColor:"Farbe",remaining:"Verbleibend",history:"AMS-Verlauf",noHistory:"Kein Verlauf verfügbar",configureSlot:"Slot konfigurieren",externalSpool:"Externe Spule",profile:"Profil",kFactor:"K-Faktor",fill:"Füllstand",configure:"Konfigurieren"},printModal:{title:"Druck starten",selectPrinter:"Drucker auswählen",selectPlate:"Platte auswählen",filamentMapping:"Filamentzuordnung",printSettings:"Druckeinstellungen",bedLeveling:"Bett-Nivellierung",flowCalibration:"Fluss-Kalibrierung",vibrationCalibration:"Vibrations-Kalibrierung",layerInspection:"Erste-Schicht-Prüfung",timelapse:"Zeitraffer",startPrint:"Druck starten",addToQueue:"Zur Warteschlange hinzufügen",cancel:"Abbrechen",noPrintersAvailable:"Keine Drucker verfügbar",printerBusy:"Drucker ist beschäftigt",printerOffline:"Drucker ist offline"},backup:{title:"Sichern & Wiederherstellen",createBackup:"Sicherung erstellen",restoreBackup:"Sicherung wiederherstellen",downloadBackup:"Sicherung herunterladen",uploadBackup:"Sicherung hochladen",lastBackup:"Letzte Sicherung",autoBackup:"Automatische Sicherung",backupNow:"Jetzt sichern",restoreWarning:"Warnung: Das Wiederherstellen einer Sicherung überschreibt alle aktuellen Daten.",includeArchives:"Archive einschließen",includeSettings:"Einstellungen einschließen",includeProfiles:"Profile einschließen",backupSuccess:"Sicherung erfolgreich erstellt",restoreSuccess:"Sicherung erfolgreich wiederhergestellt",backupFailed:"Sicherung fehlgeschlagen",restoreFailed:"Wiederherstellung fehlgeschlagen"},tags:{title:"Tags",addTag:"Tag hinzufügen",editTag:"Tag bearbeiten",deleteTag:"Tag löschen",tagName:"Tag-Name",tagColor:"Tag-Farbe",noTags:"Keine Tags",deleteConfirm:"Möchten Sie diesen Tag wirklich löschen?",manageTags:"Tags verwalten"},uploadModal:{title:"3MF-Dateien hochladen",dragDrop:"3MF-Dateien hierher ziehen",or:"oder",browseFiles:"Dateien durchsuchen",extractionInfo:"Das Druckermodell wird automatisch aus den 3MF-Datei-Metadaten extrahiert.",uploaded:"hochgeladen",failed:"fehlgeschlagen",uploading:"Wird hochgeladen...",upload:"Hochladen",uploadFailed:"Hochladen fehlgeschlagen"},editArchive:{title:"Archiv bearbeiten",name:"Name",namePlaceholder:"Druckname",printer:"Drucker",noPrinter:"Kein Drucker",project:"Projekt",noProject:"Kein Projekt",itemsPrinted:"Gedruckte Teile",itemsPrintedHelp:"Anzahl der in diesem Druckauftrag produzierten Teile",notes:"Notizen",notesPlaceholder:"Notizen zu diesem Druck hinzufügen...",externalLink:"Externer Link",externalLinkPlaceholder:"https://printables.com/model/...",externalLinkHelp:"Link zu Printables, Thingiverse oder anderer Quelle",tags:"Tags",tagsPlaceholder:"Tags hinzufügen...",addMoreTags:"Weitere Tags hinzufügen...",matchingTags:'Übereinstimmend mit "{{query}}"',existingTags:"Vorhandene Tags",clickToAdd:"(zum Hinzufügen klicken)",status:"Status",failureReason:"Fehlergrund",selectReason:"Grund auswählen...",photos:"Fotos des Druckergebnisses",photosHelp:"Klicken Sie auf + um Fotos Ihres Druckergebnisses hinzuzufügen",printResult:"Druckergebnis",saving:"Wird gespeichert...",failureReasons:{adhesionFailure:"Haftungsfehler",spaghettiDetached:"Spaghetti / Abgelöst",layerShift:"Schichtversatz",cloggedNozzle:"Verstopfte Düse",filamentRunout:"Filament aufgebraucht",warping:"Verformung",stringing:"Fadenziehen",underExtrusion:"Unterextrusion",powerFailure:"Stromausfall",userCancelled:"Vom Benutzer abgebrochen",other:"Sonstiges"},statuses:{completed:"Abgeschlossen",failed:"Fehlgeschlagen",aborted:"Abgebrochen",printing:"Druckt"}},kProfiles:{title:"K-Profile",noPrintersConfigured:"Keine Drucker konfiguriert",addPrinterInSettings:"Fügen Sie einen Drucker in den Einstellungen hinzu, um K-Profile zu verwalten",noActivePrinters:"Keine aktiven Drucker",enablePrinterConnection:"Aktivieren Sie eine Druckerverbindung, um K-Profile anzuzeigen",loadingProfiles:"Lade K-Profile...",printerOffline:"Drucker offline",printerOfflineDesc:"Der ausgewählte Drucker ist nicht verbunden. Schalten Sie ihn ein, um K-Profile anzuzeigen.",noMatchingProfiles:"Keine passenden Profile",noMatchingProfilesDesc:"Keine Profile entsprechen Ihren Suchkriterien",noKProfiles:"Keine K-Profile",noKProfilesDesc:"Keine Druckvorschub-Profile für {{diameter}}mm Düse gefunden",createFirstProfile:"Erstes Profil erstellen",printer:"Drucker",nozzle:"Düse",refresh:"Aktualisieren",addProfile:"Profil hinzufügen",export:"Exportieren",import:"Importieren",select:"Auswählen",selectAll:"Alle auswählen",delete:"Löschen",searchPlaceholder:"Nach Name oder Filament suchen...",allExtruders:"Alle Extruder",leftOnly:"Nur links",rightOnly:"Nur rechts",allFlow:"Alle Flusstypen",hfOnly:"Nur HF",sOnly:"Nur S",sortName:"Sortieren: Name",sortKValue:"Sortieren: K-Wert",sortFilament:"Sortieren: Filament",leftExtruder:"Linker Extruder",rightExtruder:"Rechter Extruder",modal:{addTitle:"K-Profil hinzufügen",editTitle:"K-Profil bearbeiten",profileName:"Profilname",profileNamePlaceholder:"Mein PLA-Profil",kValue:"K-Wert",kValuePlaceholder:"0,020",kValueHelp:"Typischer Bereich: 0,01 - 0,06 für PLA, 0,02 - 0,10 für PETG",filament:"Filament",selectFilament:"Filament auswählen...",noFilamentsHelp:"Keine Filamente gefunden. Erstellen Sie zuerst ein K-Profil in Bambu Studio.",flowType:"Flusstyp",highFlow:"High Flow",standard:"Standard",nozzleSize:"Düsengröße",extruder:"Extruder",extruders:"Extruder",left:"Links",right:"Rechts",notes:"Notizen (lokal gespeichert)",notesPlaceholder:"Notizen zu diesem Profil hinzufügen...",notesHelp:"Notizen werden in Bambuddy gespeichert, nicht auf dem Drucker",syncing:"Synchronisiert mit Drucker...",savingExtruder:"Speichern auf Extruder {{current}}/{{total}}...",pleaseWait:"Bitte warten"},deleteConfirm:{title:"Profil löschen",cannotUndo:"Dies kann nicht rückgängig gemacht werden",message:'Möchten Sie "{{name}}" wirklich vom Drucker löschen?'},bulkDelete:{title:"Profile löschen",cannotUndo:"Dies kann nicht rückgängig gemacht werden",message:"Möchten Sie wirklich {{count}} ausgewählte Profile vom Drucker löschen?"},toast:{profileSaved:"K-Profil gespeichert",profilesSaved:"K-Profil auf {{count}} Extrudern gespeichert",selectAtLeastOneExtruder:"Bitte wählen Sie mindestens einen Extruder aus",profileDeleted:"K-Profil gelöscht",profilesDeleted:"{{count}} Profile gelöscht",exportedProfiles:"{{count}} Profile exportiert",importedProfiles:"{{count}} von {{total}} Profilen importiert",noProfilesToExport:"Keine Profile zum Exportieren",invalidFileFormat:"Ungültiges Dateiformat",failedToParseImport:"Import-Datei konnte nicht gelesen werden",failedToSaveBatch:"K-Profile konnten nicht gespeichert werden",noteSaved:"Notiz gespeichert",failedToSaveNote:"Notiz konnte nicht gespeichert werden"},permission:{noRead:"Sie haben keine Berechtigung, Profile zu aktualisieren",noCreate:"Sie haben keine Berechtigung, Profile hinzuzufügen",noUpdate:"Sie haben keine Berechtigung, K-Profile zu aktualisieren",noDelete:"Sie haben keine Berechtigung, K-Profile zu löschen",noExport:"Sie haben keine Berechtigung, Profile zu exportieren",noImport:"Sie haben keine Berechtigung, Profile zu importieren"}},maintenanceDescriptions:{lubricateRails:"Schmiermittel auf Linearschienen für sanfte Bewegung auftragen",cleanNozzle:"Hotend und Düse reinigen, um Verstopfungen zu verhindern",checkBelts:"Riemenspannung für präzise Drucke überprüfen",cleanBuildPlate:"Druckplatte für bessere Haftung reinigen",checkExtruder:"Extruderzahnräder auf Verschleiß prüfen",checkCooling:"Sicherstellen, dass Lüfter ordnungsgemäß funktionieren",generalInspection:"Allgemeine Druckerinspektion",cleanCarbonRods:"Karbonstäbe reinigen, um Reibung zu reduzieren",checkPtfeTube:"PTFE-Schlauch auf Verschleiß oder Beschädigung prüfen",replaceHepaFilter:"HEPA-Filter für Luftqualität ersetzen",replaceCarbonFilter:"Aktivkohlefilter ersetzen",lubricateLeftNozzleRail:"Linke Düsenschiene schmieren (H2-Serie)"}},Bse={en:{translation:Use},de:{translation:zse}};_s.use(Aq).use(xse).init({resources:Bse,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const mz=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var pz="popstate";function $se(t={}){function e(r,i){let{pathname:a,search:o,hash:l}=r.location;return eP("",{pathname:a,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 Vse(e,n,null,t)}function ni(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function bo(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Hse(){return Math.random().toString(36).substring(2,10)}function gz(t,e){return{usr:t.state,key:t.key,idx:e}}function eP(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||Hse()}}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 Vse(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:a=!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 p(y,v){l="PUSH";let S=eP(b.location,y,v);u=d()+1;let M=gz(S,u),T=b.createHref(S);try{o.pushState(M,"",T)}catch(E){if(E instanceof DOMException&&E.name==="DataCloneError")throw E;i.location.assign(T)}a&&c&&c({action:l,location:b.location,delta:1})}function m(y,v){l="REPLACE";let S=eP(b.location,y,v);u=d();let M=gz(S,u),T=b.createHref(S);o.replaceState(M,"",T),a&&c&&c({action:l,location:b.location,delta:0})}function x(y){return Gse(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(pz,f),c=y,()=>{i.removeEventListener(pz,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:p,replace:m,go(y){return o.go(y)}};return b}function Gse(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),ni(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 Cq(t,e,n="/"){return qse(t,e,n,!1)}function qse(t,e,n,r){let i=typeof e=="string"?gx(e):e,a=Du(i.pathname||"/",n);if(a==null)return null;let o=jq(t);Wse(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let u=ioe(a);l=noe(o[c],u,r)}return l}function jq(t,e=[],n=[],r="",i=!1){let a=(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;ni(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=Nu([r,d.relativePath]),p=n.concat(d);o.children&&o.children.length>0&&(ni(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),jq(o.children,e,p,f,c)),!(o.path==null&&!o.index)&&e.push({path:f,score:eoe(f,o.index),routesMeta:p})};return t.forEach((o,l)=>{if(o.path===""||!o.path?.includes("?"))a(o,l);else for(let c of Pq(o.path))a(o,l,!0,c)}),e}function Pq(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,i=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return i?[a,""]:[a];let o=Pq(r.join("/")),l=[];return l.push(...o.map(c=>c===""?a:[a,c].join("/"))),i&&l.push(...o),l.map(c=>t.startsWith("/")&&c===""?"/":c)}function Wse(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:toe(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Kse=/^:[\w-]+$/,Xse=3,Yse=2,Qse=1,Zse=10,Jse=-2,xz=t=>t==="*";function eoe(t,e){let n=t.split("/"),r=n.length;return n.some(xz)&&(r+=Jse),e&&(r+=Yse),n.filter(i=>!xz(i)).reduce((i,a)=>i+(Kse.test(a)?Xse:a===""?Qse:Zse),r)}function toe(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 noe(t,e,n=!1){let{routesMeta:r}=t,i={},a="/",o=[];for(let l=0;l<r.length;++l){let c=r[l],u=l===r.length-1,d=a==="/"?e:e.slice(a.length)||"/",f=$1({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),p=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=$1({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),o.push({params:i,pathname:Nu([a,f.pathname]),pathnameBase:loe(Nu([a,f.pathnameBase])),route:p}),f.pathnameBase!=="/"&&(a=Nu([a,f.pathnameBase]))}return o}function $1(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=roe(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,"$1"),l=i.slice(1);return{params:r.reduce((u,{paramName:d,isOptional:f},p)=>{if(d==="*"){let x=l[p]||"";o=a.slice(0,a.length-x.length).replace(/(.)\/+$/,"$1")}const m=l[p];return f&&!m?u[d]=void 0:u[d]=(m||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:o,pattern:t}}function roe(t,e=!1,n=!0){bo(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 ioe(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return bo(!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 Du(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 Dq=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,aoe=t=>Dq.test(t);function soe(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?gx(t):t,a;if(n)if(aoe(n))a=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),bo(!1,`Pathnames cannot have embedded double slashes - normalizing ${o} -> ${n}`)}n.startsWith("/")?a=bz(n.substring(1),"/"):a=bz(n,e)}else a=e;return{pathname:a,search:coe(r),hash:uoe(i)}}function bz(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 Yk(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 ooe(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function mR(t){let e=ooe(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function pR(t,e,n,r=!1){let i;typeof t=="string"?i=gx(t):(i={...t},ni(!i.pathname||!i.pathname.includes("?"),Yk("?","pathname","search",i)),ni(!i.pathname||!i.pathname.includes("#"),Yk("#","pathname","hash",i)),ni(!i.search||!i.search.includes("#"),Yk("#","search","hash",i)));let a=t===""||i.pathname==="",o=a?"/":i.pathname,l;if(o==null)l=n;else{let f=e.length-1;if(!r&&o.startsWith("..")){let p=o.split("/");for(;p[0]==="..";)p.shift(),f-=1;i.pathname=p.join("/")}l=f>=0?e[f]:"/"}let c=soe(i,l),u=o&&o!=="/"&&o.endsWith("/"),d=(a||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var Nu=t=>t.join("/").replace(/\/\/+/g,"/"),loe=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),coe=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,uoe=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,doe=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 hoe(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function foe(t){return t.map(e=>e.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Rq=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Oq(t,e){let n=t;if(typeof n!="string"||!Dq.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Rq)try{let a=new URL(window.location.href),o=n.startsWith("//")?new URL(a.protocol+n):new URL(n),l=Du(o.pathname,e);o.origin===a.origin&&l!=null?n=l+o.search+o.hash:i=!0}catch{bo(!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 Lq=["POST","PUT","PATCH","DELETE"];new Set(Lq);var moe=["GET",...Lq];new Set(moe);var xx=_.createContext(null);xx.displayName="DataRouter";var n2=_.createContext(null);n2.displayName="DataRouterState";var poe=_.createContext(!1),Fq=_.createContext({isTransitioning:!1});Fq.displayName="ViewTransition";var goe=_.createContext(new Map);goe.displayName="Fetchers";var xoe=_.createContext(null);xoe.displayName="Await";var wo=_.createContext(null);wo.displayName="Navigation";var Oy=_.createContext(null);Oy.displayName="Location";var fl=_.createContext({outlet:null,matches:[],isDataRoute:!1});fl.displayName="Route";var gR=_.createContext(null);gR.displayName="RouteError";var Iq="REACT_ROUTER_ERROR",boe="REDIRECT",yoe="ROUTE_ERROR_RESPONSE";function voe(t){if(t.startsWith(`${Iq}:${boe}:{`))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 woe(t){if(t.startsWith(`${Iq}:${yoe}:{`))try{let e=JSON.parse(t.slice(40));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string")return new doe(e.status,e.statusText,e.data)}catch{}}function _oe(t,{relative:e}={}){ni(bx(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=_.useContext(wo),{hash:i,pathname:a,search:o}=Ly(t,{relative:e}),l=a;return n!=="/"&&(l=a==="/"?n:Nu([n,a])),r.createHref({pathname:l,search:o,hash:i})}function bx(){return _.useContext(Oy)!=null}function Nc(){return ni(bx(),"useLocation() may be used only in the context of a <Router> component."),_.useContext(Oy).location}var Uq="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function zq(t){_.useContext(wo).static||_.useLayoutEffect(t)}function Mc(){let{isDataRoute:t}=_.useContext(fl);return t?Foe():Soe()}function Soe(){ni(bx(),"useNavigate() may be used only in the context of a <Router> component.");let t=_.useContext(xx),{basename:e,navigator:n}=_.useContext(wo),{matches:r}=_.useContext(fl),{pathname:i}=Nc(),a=JSON.stringify(mR(r)),o=_.useRef(!1);return zq(()=>{o.current=!0}),_.useCallback((c,u={})=>{if(bo(o.current,Uq),!o.current)return;if(typeof c=="number"){n.go(c);return}let d=pR(c,JSON.parse(a),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:Nu([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,a,i,t])}var Noe=_.createContext(null);function Moe(t){let e=_.useContext(fl).outlet;return _.useMemo(()=>e&&_.createElement(Noe.Provider,{value:t},e),[e,t])}function r2(){let{matches:t}=_.useContext(fl),e=t[t.length-1];return e?e.params:{}}function Ly(t,{relative:e}={}){let{matches:n}=_.useContext(fl),{pathname:r}=Nc(),i=JSON.stringify(mR(n));return _.useMemo(()=>pR(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function Eoe(t,e){return Bq(t,e)}function Bq(t,e,n,r,i){ni(bx(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=_.useContext(wo),{matches:o}=_.useContext(fl),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||"";Hq(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 p=Nc(),m;if(e){let S=typeof e=="string"?gx(e):e;ni(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.`),m=S}else m=p;let x=m.pathname||"/",b=x;if(d!=="/"){let S=d.replace(/^\//,"").split("/");b="/"+x.replace(/^\//,"").split("/").slice(S.length).join("/")}let y=Cq(t,{pathname:b});bo(f||y!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),bo(y==null||y[y.length-1].route.element!==void 0||y[y.length-1].route.Component!==void 0||y[y.length-1].route.lazy!==void 0,`Matched leaf route at location "${m.pathname}${m.search}${m.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let v=joe(y&&y.map(S=>Object.assign({},S,{params:Object.assign({},c,S.params),pathname:Nu([d,a.encodeLocation?a.encodeLocation(S.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?d:Nu([d,a.encodeLocation?a.encodeLocation(S.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathnameBase])})),o,n,r,i);return e&&v?_.createElement(Oy.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...m},navigationType:"POP"}},v):v}function koe(){let t=Loe(),e=hoe(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,r="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:r},a={padding:"2px 4px",backgroundColor:r},o=null;return console.error("Error handled by React Router default ErrorBoundary:",t),o=_.createElement(_.Fragment,null,_.createElement("p",null,"💿 Hey developer 👋"),_.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",_.createElement("code",{style:a},"ErrorBoundary")," or"," ",_.createElement("code",{style:a},"errorElement")," prop on your route.")),_.createElement(_.Fragment,null,_.createElement("h2",null,"Unexpected Application Error!"),_.createElement("h3",{style:{fontStyle:"italic"}},e),n?_.createElement("pre",{style:i},n):null,o)}var Toe=_.createElement(koe,null),$q=class extends _.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=woe(t.digest);n&&(t=n)}let e=t!==void 0?_.createElement(fl.Provider,{value:this.props.routeContext},_.createElement(gR.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?_.createElement(Aoe,{error:t},e):e}};$q.contextType=poe;var Qk=new WeakMap;function Aoe({children:t,error:e}){let{basename:n}=_.useContext(wo);if(typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){let r=voe(e.digest);if(r){let i=Qk.get(e);if(i)throw i;let a=Oq(r.location,n);if(Rq&&!Qk.get(e))if(a.isExternal||r.reloadDocument)window.location.href=a.absoluteURL||a.to;else{const o=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:r.replace}));throw Qk.set(e,o),o}return _.createElement("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return t}function Coe({routeContext:t,match:e,children:n}){let r=_.useContext(xx);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),_.createElement(fl.Provider,{value:t},n)}function joe(t,e=[],n=null,r=null,i=null){if(t==null){if(!n)return null;if(n.errors)t=n.matches;else if(e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let a=t,o=n?.errors;if(o!=null){let d=a.findIndex(f=>f.route.id&&o?.[f.route.id]!==void 0);ni(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),a=a.slice(0,Math.min(a.length,d+1))}let l=!1,c=-1;if(n)for(let d=0;d<a.length;d++){let f=a[d];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(c=d),f.route.id){let{loaderData:p,errors:m}=n,x=f.route.loader&&!p.hasOwnProperty(f.route.id)&&(!m||m[f.route.id]===void 0);if(f.route.lazy||x){l=!0,c>=0?a=a.slice(0,c+1):a=[a[0]];break}}}let u=n&&r?(d,f)=>{r(d,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:foe(n.matches),errorInfo:f})}:void 0;return a.reduceRight((d,f,p)=>{let m,x=!1,b=null,y=null;n&&(m=o&&f.route.id?o[f.route.id]:void 0,b=f.route.errorElement||Toe,l&&(c<0&&p===0?(Hq("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,y=null):c===p&&(x=!0,y=f.route.hydrateFallbackElement||null)));let v=e.concat(a.slice(0,p+1)),S=()=>{let M;return m?M=b:x?M=y:f.route.Component?M=_.createElement(f.route.Component,null):f.route.element?M=f.route.element:M=d,_.createElement(Coe,{match:f,routeContext:{outlet:d,matches:v,isDataRoute:n!=null},children:M})};return n&&(f.route.ErrorBoundary||f.route.errorElement||p===0)?_.createElement($q,{location:n.location,revalidation:n.revalidation,component:b,error:m,children:S(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:u}):S()},null)}function xR(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Poe(t){let e=_.useContext(xx);return ni(e,xR(t)),e}function Doe(t){let e=_.useContext(n2);return ni(e,xR(t)),e}function Roe(t){let e=_.useContext(fl);return ni(e,xR(t)),e}function bR(t){let e=Roe(t),n=e.matches[e.matches.length-1];return ni(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function Ooe(){return bR("useRouteId")}function Loe(){let t=_.useContext(gR),e=Doe("useRouteError"),n=bR("useRouteError");return t!==void 0?t:e.errors?.[n]}function Foe(){let{router:t}=Poe("useNavigate"),e=bR("useNavigate"),n=_.useRef(!1);return zq(()=>{n.current=!0}),_.useCallback(async(i,a={})=>{bo(n.current,Uq),n.current&&(typeof i=="number"?await t.navigate(i):await t.navigate(i,{fromRouteId:e,...a}))},[t,e])}var yz={};function Hq(t,e,n){!e&&!yz[t]&&(yz[t]=!0,bo(!1,n))}_.memo(Ioe);function Ioe({routes:t,future:e,state:n,onError:r}){return Bq(t,void 0,n,r,e)}function Fg({to:t,replace:e,state:n,relative:r}){ni(bx(),"<Navigate> may be used only in the context of a <Router> component.");let{static:i}=_.useContext(wo);bo(!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:a}=_.useContext(fl),{pathname:o}=Nc(),l=Mc(),c=pR(t,mR(a),o,r==="path"),u=JSON.stringify(c);return _.useEffect(()=>{l(JSON.parse(u),{replace:e,state:n,relative:r})},[l,u,r,e,n]),null}function Uoe(t){return Moe(t.context)}function Li(t){ni(!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 zoe({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:a=!1,unstable_useTransitions:o}){ni(!bx(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=t.replace(/^\/*/,"/"),c=_.useMemo(()=>({basename:l,navigator:i,static:a,unstable_useTransitions:o,future:{}}),[l,i,a,o]);typeof n=="string"&&(n=gx(n));let{pathname:u="/",search:d="",hash:f="",state:p=null,key:m="default"}=n,x=_.useMemo(()=>{let b=Du(u,l);return b==null?null:{location:{pathname:b,search:d,hash:f,state:p,key:m},navigationType:r}},[l,u,d,f,p,m,r]);return bo(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:_.createElement(wo.Provider,{value:c},_.createElement(Oy.Provider,{children:e,value:x}))}function Boe({children:t,location:e}){return Eoe(tP(t),e)}function tP(t,e=[]){let n=[];return _.Children.forEach(t,(r,i)=>{if(!_.isValidElement(r))return;let a=[...e,i];if(r.type===_.Fragment){n.push.apply(n,tP(r.props.children,a));return}ni(r.type===Li,`[${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>`),ni(!r.props.index||!r.props.children,"An index route cannot have child routes.");let o={id:r.props.id||a.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=tP(r.props.children,a)),n.push(o)}),n}var f1="get",m1="application/x-www-form-urlencoded";function i2(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function $oe(t){return i2(t)&&t.tagName.toLowerCase()==="button"}function Hoe(t){return i2(t)&&t.tagName.toLowerCase()==="form"}function Voe(t){return i2(t)&&t.tagName.toLowerCase()==="input"}function Goe(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function qoe(t,e){return t.button===0&&(!e||e==="_self")&&!Goe(t)}function nP(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 Woe(t,e){let n=nP(t);return e&&e.forEach((r,i)=>{n.has(i)||e.getAll(i).forEach(a=>{n.append(i,a)})}),n}var jw=null;function Koe(){if(jw===null)try{new FormData(document.createElement("form"),0),jw=!1}catch{jw=!0}return jw}var Xoe=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Zk(t){return t!=null&&!Xoe.has(t)?(bo(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${m1}"`),null):t}function Yoe(t,e){let n,r,i,a,o;if(Hoe(t)){let l=t.getAttribute("action");r=l?Du(l,e):null,n=t.getAttribute("method")||f1,i=Zk(t.getAttribute("enctype"))||m1,a=new FormData(t)}else if($oe(t)||Voe(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?Du(c,e):null,n=t.getAttribute("formmethod")||l.getAttribute("method")||f1,i=Zk(t.getAttribute("formenctype"))||Zk(l.getAttribute("enctype"))||m1,a=new FormData(l,t),!Koe()){let{name:u,type:d,value:f}=t;if(d==="image"){let p=u?`${u}.`:"";a.append(`${p}x`,"0"),a.append(`${p}y`,"0")}else u&&a.append(u,f)}}else{if(i2(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=f1,r=null,i=m1,o=t}return a&&i==="text/plain"&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function yR(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Qoe(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&&Du(i.pathname,e)==="/"?i.pathname=`${e.replace(/\/$/,"")}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,"")}.${r}`,i}async function Zoe(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 Joe(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 ele(t,e,n){let r=await Promise.all(t.map(async i=>{let a=e.routes[i.route.id];if(a){let o=await Zoe(a,n);return o.links?o.links():[]}return[]}));return ile(r.flat(1).filter(Joe).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function vz(t,e,n,r,i,a){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 a==="assets"?e.filter((c,u)=>o(c,u)||l(c,u)):a==="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 tle(t,e,{includeHydrateFallback:n}={}){return nle(t.map(r=>{let i=e.routes[r.route.id];if(!i)return[];let a=[i.module];return i.clientActionModule&&(a=a.concat(i.clientActionModule)),i.clientLoaderModule&&(a=a.concat(i.clientLoaderModule)),n&&i.hydrateFallbackModule&&(a=a.concat(i.hydrateFallbackModule)),i.imports&&(a=a.concat(i.imports)),a}).flat(1))}function nle(t){return[...new Set(t)]}function rle(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function ile(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let a=JSON.stringify(rle(i));return n.has(a)||(n.add(a),r.push({key:a,link:i})),r},[])}function Vq(){let t=_.useContext(xx);return yR(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function ale(){let t=_.useContext(n2);return yR(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var vR=_.createContext(void 0);vR.displayName="FrameworkContext";function Gq(){let t=_.useContext(vR);return yR(t,"You must render this element inside a <HydratedRouter> element"),t}function sle(t,e){let n=_.useContext(vR),[r,i]=_.useState(!1),[a,o]=_.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=e,p=_.useRef(null);_.useEffect(()=>{if(t==="render"&&o(!0),t==="viewport"){let b=v=>{v.forEach(S=>{o(S.isIntersecting)})},y=new IntersectionObserver(b,{threshold:.5});return p.current&&y.observe(p.current),()=>{y.disconnect()}}},[t]),_.useEffect(()=>{if(r){let b=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(b)}}},[r]);let m=()=>{i(!0)},x=()=>{i(!1),o(!1)};return n?t!=="intent"?[a,p,{}]:[a,p,{onFocus:Cb(l,m),onBlur:Cb(c,x),onMouseEnter:Cb(u,m),onMouseLeave:Cb(d,x),onTouchStart:Cb(f,m)}]:[!1,p,{}]}function Cb(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function ole({page:t,...e}){let{router:n}=Vq(),r=_.useMemo(()=>Cq(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?_.createElement(cle,{page:t,matches:r,...e}):null}function lle(t){let{manifest:e,routeModules:n}=Gq(),[r,i]=_.useState([]);return _.useEffect(()=>{let a=!1;return ele(t,e,n).then(o=>{a||i(o)}),()=>{a=!0}},[t,e,n]),r}function cle({page:t,matches:e,...n}){let r=Nc(),{future:i,manifest:a,routeModules:o}=Gq(),{basename:l}=Vq(),{loaderData:c,matches:u}=ale(),d=_.useMemo(()=>vz(t,e,u,a,r,"data"),[t,e,u,a,r]),f=_.useMemo(()=>vz(t,e,u,a,r,"assets"),[t,e,u,a,r]),p=_.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let b=new Set,y=!1;if(e.forEach(S=>{let M=a.routes[S.route.id];!M||!M.hasLoader||(!d.some(T=>T.route.id===S.route.id)&&S.route.id in c&&o[S.route.id]?.shouldRevalidate||M.hasClientLoader?y=!0:b.add(S.route.id))}),b.size===0)return[];let v=Qoe(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,a,d,e,t,o]),m=_.useMemo(()=>tle(f,a),[f,a]),x=lle(f);return _.createElement(_.Fragment,null,p.map(b=>_.createElement("link",{key:b,rel:"prefetch",as:"fetch",href:b,...n})),m.map(b=>_.createElement("link",{key:b,rel:"modulepreload",href:b,...n})),x.map(({key:b,link:y})=>_.createElement("link",{key:b,nonce:n.nonce,...y})))}function ule(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var dle=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{dle&&(window.__reactRouterVersion="7.12.0")}catch{}function hle({basename:t,children:e,unstable_useTransitions:n,window:r}){let i=_.useRef();i.current==null&&(i.current=$se({window:r,v5Compat:!0}));let a=i.current,[o,l]=_.useState({action:a.action,location:a.location}),c=_.useCallback(u=>{n===!1?l(u):_.startTransition(()=>l(u))},[n]);return _.useLayoutEffect(()=>a.listen(c),[a,c]),_.createElement(zoe,{basename:t,children:e,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}var qq=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ds=_.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:a,replace:o,state:l,target:c,to:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:p,...m},x){let{basename:b,unstable_useTransitions:y}=_.useContext(wo),v=typeof u=="string"&&qq.test(u),S=Oq(u,b);u=S.to;let M=_oe(u,{relative:i}),[T,E,C]=sle(r,m),k=ple(u,{replace:o,state:l,target:c,preventScrollReset:d,relative:i,viewTransition:f,unstable_defaultShouldRevalidate:p,unstable_useTransitions:y});function R(D){e&&e(D),D.defaultPrevented||k(D)}let A=_.createElement("a",{...m,...C,href:S.absoluteURL||M,onClick:S.isExternal||a?e:R,ref:ule(x,E),target:c,"data-discover":!v&&n==="render"?"true":void 0});return T&&!v?_.createElement(_.Fragment,null,A,_.createElement(ole,{page:M})):A});Ds.displayName="Link";var n0=_.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:a,to:o,viewTransition:l,children:c,...u},d){let f=Ly(o,{relative:u.relative}),p=Nc(),m=_.useContext(n2),{navigator:x,basename:b}=_.useContext(wo),y=m!=null&&vle(f)&&l===!0,v=x.encodeLocation?x.encodeLocation(f).pathname:f.pathname,S=p.pathname,M=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;n||(S=S.toLowerCase(),M=M?M.toLowerCase():null,v=v.toLowerCase()),M&&b&&(M=Du(M,b)||M);const T=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let E=S===v||!i&&S.startsWith(v)&&S.charAt(T)==="/",C=M!=null&&(M===v||!i&&M.startsWith(v)&&M.charAt(v.length)==="/"),k={isActive:E,isPending:C,isTransitioning:y},R=E?e:void 0,A;typeof r=="function"?A=r(k):A=[r,E?"active":null,C?"pending":null,y?"transitioning":null].filter(Boolean).join(" ");let D=typeof a=="function"?a(k):a;return _.createElement(Ds,{...u,"aria-current":R,className:A,ref:d,style:D,to:o,viewTransition:l},typeof c=="function"?c(k):c)});n0.displayName="NavLink";var fle=_.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:a,method:o=f1,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:p,...m},x)=>{let{unstable_useTransitions:b}=_.useContext(wo),y=ble(),v=yle(l,{relative:u}),S=o.toLowerCase()==="get"?"get":"post",M=typeof l=="string"&&qq.test(l),T=E=>{if(c&&c(E),E.defaultPrevented)return;E.preventDefault();let C=E.nativeEvent.submitter,k=C?.getAttribute("formmethod")||o,R=()=>y(C||E.currentTarget,{fetcherKey:e,method:k,navigate:n,replace:i,state:a,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:p});b&&n!==!1?_.startTransition(()=>R()):R()};return _.createElement("form",{ref:x,method:S,action:v,onSubmit:r?c:T,...m,"data-discover":!M&&t==="render"?"true":void 0})});fle.displayName="Form";function mle(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Wq(t){let e=_.useContext(xx);return ni(e,mle(t)),e}function ple(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:l,unstable_useTransitions:c}={}){let u=Mc(),d=Nc(),f=Ly(t,{relative:a});return _.useCallback(p=>{if(qoe(p,e)){p.preventDefault();let m=n!==void 0?n:$0(d)===$0(f),x=()=>u(t,{replace:m,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:l});c?_.startTransition(()=>x()):x()}},[d,u,f,n,r,e,t,i,a,o,l,c])}function wR(t){bo(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=_.useRef(nP(t)),n=_.useRef(!1),r=Nc(),i=_.useMemo(()=>Woe(r.search,n.current?null:e.current),[r.search]),a=Mc(),o=_.useCallback((l,c)=>{const u=nP(typeof l=="function"?l(new URLSearchParams(i)):l);n.current=!0,a("?"+u,c)},[a,i]);return[i,o]}var gle=0,xle=()=>`__${String(++gle)}__`;function ble(){let{router:t}=Wq("useSubmit"),{basename:e}=_.useContext(wo),n=Ooe(),r=t.fetch,i=t.navigate;return _.useCallback(async(a,o={})=>{let{action:l,method:c,encType:u,formData:d,body:f}=Yoe(a,e);if(o.navigate===!1){let p=o.fetcherKey||xle();await r(p,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 yle(t,{relative:e}={}){let{basename:n}=_.useContext(wo),r=_.useContext(fl);ni(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),a={...Ly(t||".",{relative:e})},o=Nc();if(t==null){a.search=o.search;let l=new URLSearchParams(a.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();a.search=d?`?${d}`:""}}return(!t||t===".")&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:Nu([n,a.pathname])),$0(a)}function vle(t,{relative:e}={}){let n=_.useContext(Fq);ni(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Wq("useViewTransitionState"),i=Ly(t,{relative:e});if(!n.isTransitioning)return!1;let a=Du(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Du(n.nextLocation.pathname,r)||n.nextLocation.pathname;return $1(i.pathname,o)!=null||$1(i.pathname,a)!=null}var gu=yq();const wle=hl(gu);var Em=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(){}},_le={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Sle=class{#t=_le;#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 Sle;function Nle(t){setTimeout(t,0)}var tm=typeof window>"u"||"Deno"in globalThis;function Ya(){}function Mle(t,e){return typeof t=="function"?t(e):t}function rP(t){return typeof t=="number"&&t>=0&&t!==1/0}function Kq(t,e){return Math.max(t+(e||0)-Date.now(),0)}function rh(t,e){return typeof t=="function"?t(e):t}function $o(t,e){return typeof t=="function"?t(e):t}function wz(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:l}=t;if(o){if(r){if(e.queryHash!==_R(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||a&&!a(e))}function _z(t,e){const{exact:n,status:r,predicate:i,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(nm(e.options.mutationKey)!==nm(a))return!1}else if(!H0(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function _R(t,e){return(e?.queryKeyHashFn||nm)(t)}function nm(t){return JSON.stringify(t,(e,n)=>iP(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 Ele=Object.prototype.hasOwnProperty;function SR(t,e){if(t===e)return t;const n=Sz(t)&&Sz(e);if(!n&&!(iP(t)&&iP(e)))return e;const i=(n?t:Object.keys(t)).length,a=n?e:Object.keys(e),o=a.length,l=n?new Array(o):{};let c=0;for(let u=0;u<o;u++){const d=n?u:a[u],f=t[d],p=e[d];if(f===p){l[d]=f,(n?u<i:Ele.call(t,d))&&c++;continue}if(f===null||p===null||typeof f!="object"||typeof p!="object"){l[d]=p;continue}const m=SR(f,p);l[d]=m,m===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 Sz(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function iP(t){if(!Nz(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!Nz(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Nz(t){return Object.prototype.toString.call(t)==="[object Object]"}function kle(t){return new Promise(e=>{jf.setTimeout(e,t)})}function aP(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?SR(t,e):e}function Tle(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function Ale(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var NR=Symbol();function Xq(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===NR?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function Yq(t,e){return typeof t=="function"?t(...e):!!t}var Cle=class extends Em{#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"}},MR=new Cle;function sP(){let t,e;const n=new Promise((i,a)=>{t=i,e=a});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),t(i)},n.reject=i=>{r({status:"rejected",reason:i}),e(i)},n}var jle=Nle;function Ple(){let t=[],e=0,n=l=>{l()},r=l=>{l()},i=jle;const a=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)=>{a(()=>{l(...c)})},schedule:a,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{i=l}}}var xi=Ple(),Dle=class extends Em{#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}},H1=new Dle;function Rle(t){return Math.min(1e3*2**t,3e4)}function Qq(t){return(t??"online")==="online"?H1.isOnline():!0}var oP=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Zq(t){let e=!1,n=0,r;const i=sP(),a=()=>i.status!=="pending",o=b=>{if(!a()){const y=new oP(b);p(y),t.onCancel?.(y)}},l=()=>{e=!0},c=()=>{e=!1},u=()=>MR.isFocused()&&(t.networkMode==="always"||H1.isOnline())&&t.canRun(),d=()=>Qq(t.networkMode)&&t.canRun(),f=b=>{a()||(r?.(),i.resolve(b))},p=b=>{a()||(r?.(),i.reject(b))},m=()=>new Promise(b=>{r=y=>{(a()||u())&&b(y)},t.onPause?.()}).then(()=>{r=void 0,a()||t.onContinue?.()}),x=()=>{if(a())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(a())return;const S=t.retry??(tm?0:3),M=t.retryDelay??Rle,T=typeof M=="function"?M(n,v):M,E=S===!0||typeof S=="number"&&n<S||typeof S=="function"&&S(n,v);if(e||!E){p(v);return}n++,t.onFail?.(n,v),kle(T).then(()=>u()?void 0:m()).then(()=>{e?p(v):x()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?x():m().then(x),i)}}var Jq=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),rP(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)}},Ole=class extends Jq{#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=Ez(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=Ez(this.options);e.data!==void 0&&(this.setState(Mz(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=aP(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(Ya).catch(Ya):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===NR||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>rh(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:!Kq(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=Xq(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=Zq({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:l=>{l instanceof oP&&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 oP){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,...eW(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...Mz(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),xi.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function eW(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Qq(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function Mz(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Ez(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 ER=class extends Em{constructor(t,e){super(),this.options=e,this.#t=t,this.#s=null,this.#o=sP(),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 lP(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return lP(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#v(),this.#w(),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.#_(),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&&Tz(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)||rh(this.options.staleTime,this.#e)!==rh(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 Fle(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.#_();let e=this.#e.fetch(this.options,t);return t?.throwOnError||(e=e.catch(Ya)),e}#g(){this.#v();const t=rh(this.options.staleTime,this.#e);if(tm||this.#i.isStale||!rP(t))return;const n=Kq(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.#w(),this.#l=t,!(tm||$o(this.options.enabled,this.#e)===!1||!rP(this.#l)||this.#l===0)&&(this.#u=jf.setInterval(()=>{(this.options.refetchIntervalInBackground||MR.isFocused())&&this.#m()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){this.#c&&(jf.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(jf.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const n=this.#e,r=this.options,i=this.#i,a=this.#r,o=this.#a,c=t!==n?t.state:this.#n,{state:u}=t;let d={...u},f=!1,p;if(e._optimisticResults){const R=this.hasListeners(),A=!R&&kz(t,e),D=R&&Tz(t,n,e,r);(A||D)&&(d={...d,...eW(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:m,errorUpdatedAt:x,status:b}=d;p=d.data;let y=!1;if(e.placeholderData!==void 0&&p===void 0&&b==="pending"){let R;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(R=i.data,y=!0):R=typeof e.placeholderData=="function"?e.placeholderData(this.#h?.state.data,this.#h):e.placeholderData,R!==void 0&&(b="success",p=aP(i?.data,R,e),f=!0)}if(e.select&&p!==void 0&&!y)if(i&&p===a?.data&&e.select===this.#f)p=this.#d;else try{this.#f=e.select,p=e.select(p),p=aP(i?.data,p,e),this.#d=p,this.#s=null}catch(R){this.#s=R}this.#s&&(m=this.#s,p=this.#d,x=Date.now(),b="error");const v=d.fetchStatus==="fetching",S=b==="pending",M=b==="error",T=S&&v,E=p!==void 0,k={status:b,fetchStatus:d.fetchStatus,isPending:S,isSuccess:b==="success",isError:M,isInitialLoading:T,isLoading:T,data:p,dataUpdatedAt:d.dataUpdatedAt,error:m,errorUpdatedAt:x,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:v,isRefetching:v&&!S,isLoadingError:M&&!E,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:M&&E,isStale:kR(t,e),refetch:this.refetch,promise:this.#o,isEnabled:$o(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const R=U=>{k.status==="error"?U.reject(k.error):k.data!==void 0&&U.resolve(k.data)},A=()=>{const U=this.#o=k.promise=sP();R(U)},D=this.#o;switch(D.status){case"pending":t.queryHash===n.queryHash&&R(D);break;case"fulfilled":(k.status==="error"||k.data!==D.value)&&A();break;case"rejected":(k.status!=="error"||k.error!==D.reason)&&A();break}}return k}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 a=new Set(i??this.#p);return this.options.throwOnError&&a.add("error"),Object.keys(this.#i).some(o=>{const l=o;return this.#i[l]!==t[l]&&a.has(l)})};this.#S({listeners:n()})}#_(){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){xi.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function Lle(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 Lle(t,e)||t.state.data!==void 0&&lP(t,e,e.refetchOnMount)}function lP(t,e,n){if($o(e.enabled,t)!==!1&&rh(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&kR(t,e)}return!1}function Tz(t,e,n,r){return(t!==e||$o(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&kR(t,n)}function kR(t,e){return $o(e.enabled,t)!==!1&&t.isStaleByTime(rh(e.staleTime,t))}function Fle(t,e){return!V0(t.getCurrentResult(),e)}function Az(t){return{onFetch:(e,n)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,a=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)})},p=Xq(e.options,e.fetchOptions),m=async(x,b,y)=>{if(d)return Promise.reject();if(b==null&&x.pages.length)return Promise.resolve(x);const S=(()=>{const C={client:e.client,queryKey:e.queryKey,pageParam:b,direction:y?"backward":"forward",meta:e.options.meta};return f(C),C})(),M=await p(S),{maxPages:T}=e.options,E=y?Ale:Tle;return{pages:E(x.pages,M,T),pageParams:E(x.pageParams,b,T)}};if(i&&a.length){const x=i==="backward",b=x?Ile:Cz,y={pages:a,pageParams:o},v=b(r,y);l=await m(y,v,x)}else{const x=t??a.length;do{const b=c===0?o[0]??r.initialPageParam:Cz(r,l);if(c>0&&b==null)break;l=await m(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 Cz(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 Ile(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var Ule=class extends Jq{#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||tW(),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=Zq({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(a,o)=>{this.#r({type:"failed",failureCount:a,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 a=await this.#i.start();return await this.#n.config.onSuccess?.(a,t,this.state.context,this,n),await this.options.onSuccess?.(a,t,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,t,this.state.context,n),this.#r({type:"success",data:a}),a}catch(a){try{throw await this.#n.config.onError?.(a,t,this.state.context,this,n),await this.options.onError?.(a,t,this.state.context,n),await this.#n.config.onSettled?.(void 0,a,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(void 0,a,t,this.state.context,n),a}finally{this.#r({type:"error",error:a})}}finally{this.#n.runNext(this)}}#r(t){const e=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=e(this.state),xi.batch(()=>{this.#e.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function tW(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var zle=class extends Em{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 Ule({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=Pw(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=Pw(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=Pw(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=Pw(t);return typeof e=="string"?this.#e.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){xi.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=>_z(e,n))}findAll(t={}){return this.getAll().filter(e=>_z(t,e))}notify(t){xi.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return xi.batch(()=>Promise.all(t.map(e=>e.continue().catch(Ya))))}};function Pw(t){return t.options.scope?.id}var Ble=class extends Em{#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??tW();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){xi.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 jz(t,e){const n=new Set(e);return t.filter(r=>!n.has(r))}function $le(t,e,n){const r=t.slice(0);return r[e]=n,r}var Hle=class extends Em{#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,xi.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),a=i.map(d=>d.getCurrentResult()),o=n.length!==i.length,l=i.some((d,f)=>d!==n[f]),c=o||l,u=c?!0:a.some((d,f)=>{const p=this.#e[f];return!p||!V0(d,p)});!c&&!u||(c&&(this.#r=i),this.#e=a,this.hasListeners()&&(c&&(jz(n,i).forEach(d=>{d.destroy()}),jz(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,a=>{e.forEach(o=>{o.observer.trackProp(a)})})})}#h(t,e){return e?((!this.#a||this.#e!==this.#s||e!==this.#o)&&(this.#o=e,this.#s=this.#e,this.#a=SR(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 a=e.get(i);a?a.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 ER(this.#t,i);n.push({defaultedQueryOptions:i,observer:o})}),n}#u(t,e){const n=this.#r.indexOf(t);n!==-1&&(this.#e=$le(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&&xi.batch(()=>{this.listeners.forEach(r=>{r(this.#e)})})}}},Vle=class extends Em{constructor(t={}){super(),this.config=t,this.#t=new Map}#t;build(t,e,n){const r=e.queryKey,i=e.queryHash??_R(r,e);let a=this.get(i);return a||(a=new Ole({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(a)),a}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(){xi.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=>wz(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>wz(t,n)):e}notify(t){xi.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){xi.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){xi.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Gle=class{#t;#e;#n;#i;#r;#a;#o;#s;constructor(t={}){this.#t=t.queryCache||new Vle,this.#e=t.mutationCache||new zle,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=MR.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#s=H1.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(rh(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}),a=this.#t.get(r.queryHash)?.state.data,o=Mle(e,a);if(o!==void 0)return this.#t.build(this,r).setData(o,{...n,manual:!0})}setQueriesData(t,e,n){return xi.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;xi.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#t;return xi.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=xi.batch(()=>this.#t.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(Ya).catch(Ya)}invalidateQueries(t,e={}){return xi.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=xi.batch(()=>this.#t.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let a=i.fetch(void 0,n);return n.throwOnError||(a=a.catch(Ya)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Ya)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#t.build(this,e);return n.isStaleByTime(rh(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Ya).catch(Ya)}fetchInfiniteQuery(t){return t.behavior=Az(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Ya).catch(Ya)}ensureInfiniteQueryData(t){return t.behavior=Az(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return H1.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=_R(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===NR&&(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()}},nW=_.createContext(void 0),an=t=>{const e=_.useContext(nW);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},qle=({client:t,children:e})=>(_.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),s.jsx(nW.Provider,{value:t,children:e})),rW=_.createContext(!1),iW=()=>_.useContext(rW);rW.Provider;function Wle(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Kle=_.createContext(Wle()),aW=()=>_.useContext(Kle),sW=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},oW=t=>{_.useEffect(()=>{t.clearReset()},[t])},lW=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||Yq(n,[t.error,r])),cW=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))}},uW=(t,e)=>t.isLoading&&t.isFetching&&!e,cP=(t,e)=>t?.suspense&&e.isPending,V1=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function dW({queries:t,...e},n){const r=an(),i=iW(),a=aW(),o=_.useMemo(()=>t.map(b=>{const y=r.defaultQueryOptions(b);return y._optimisticResults=i?"isRestoring":"optimistic",y}),[t,r,i]);o.forEach(b=>{cW(b),sW(b,a)}),oW(a);const[l]=_.useState(()=>new Hle(r,o,e)),[c,u,d]=l.getOptimisticResult(o,e.combine),f=!i&&e.subscribed!==!1;_.useSyncExternalStore(_.useCallback(b=>f?l.subscribe(xi.batchCalls(b)):Ya,[l,f]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),_.useEffect(()=>{l.setQueries(o,e)},[o,e,l]);const m=c.some((b,y)=>cP(o[y],b))?c.flatMap((b,y)=>{const v=o[y];if(v){const S=new ER(r,v);if(cP(v,b))return V1(v,S,a);uW(b,i)&&V1(v,S,a)}return[]}):[];if(m.length>0)throw Promise.all(m);const x=c.find((b,y)=>{const v=o[y];return v&&lW({result:b,errorResetBoundary:a,throwOnError:v.throwOnError,query:r.getQueryCache().get(v.queryHash),suspense:v.suspense})});if(x?.error)throw x.error;return u(d())}function Xle(t,e,n){const r=iW(),i=aW(),a=an(),o=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?"isRestoring":"optimistic",cW(o),sW(o,i),oW(i);const l=!a.getQueryCache().get(o.queryHash),[c]=_.useState(()=>new e(a,o)),u=c.getOptimisticResult(o),d=!r&&t.subscribed!==!1;if(_.useSyncExternalStore(_.useCallback(f=>{const p=d?c.subscribe(xi.batchCalls(f)):Ya;return c.updateResult(),p},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),_.useEffect(()=>{c.setOptions(o)},[o,c]),cP(o,u))throw V1(o,c,i);if(lW({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!tm&&uW(u,r)&&(l?V1(o,c,i):a.getQueryCache().get(o.queryHash)?.promise)?.catch(Ya).finally(()=>{c.updateResult()}),o.notifyOnChangeProps?u:c.trackResult(u)}function at(t,e){return Xle(t,ER)}function mt(t,e){const n=an(),[r]=_.useState(()=>new Ble(n,t));_.useEffect(()=>{r.setOptions(t)},[r,t]);const i=_.useSyncExternalStore(_.useCallback(o=>r.subscribe(xi.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=_.useCallback((o,l)=>{r.mutate(o,l).catch(Ya)},[r]);if(i.error&&Yq(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const Yle=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Qle=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Pz=t=>{const e=Qle(t);return e.charAt(0).toUpperCase()+e.slice(1)},hW=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),Zle=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var Jle={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 ece=_.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:o,...l},c)=>_.createElement("svg",{ref:c,...Jle,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:hW("lucide",i),...!a&&!Zle(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,d])=>_.createElement(u,d)),...Array.isArray(a)?a:[a]]));const Qe=(t,e)=>{const n=_.forwardRef(({className:r,...i},a)=>_.createElement(ece,{ref:a,iconNode:e,className:hW(`lucide-${Yle(Pz(t))}`,`lucide-${t}`,r),...i}));return n.displayName=Pz(t),n};const tce=[["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"}]],nce=Qe("air-vent",tce);const rce=[["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=Qe("archive",rce);const ice=[["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"}]],ace=Qe("arrow-down-wide-narrow",ice);const sce=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],G0=Qe("arrow-down",sce);const oce=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],lce=Qe("arrow-left",oce);const cce=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],uP=Qe("arrow-right",cce);const uce=[["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"}]],fW=Qe("arrow-up-down",uce);const dce=[["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"}]],hce=Qe("arrow-up-narrow-wide",dce);const fce=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Ig=Qe("arrow-up",fce);const mce=[["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"}]],wg=Qe("bell",mce);const pce=[["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"}]],gce=Qe("bold",pce);const xce=[["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"}]],bce=Qe("book",xce);const yce=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],vce=Qe("bookmark",yce);const wce=[["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"}]],lo=Qe("box",wce);const _ce=[["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"}]],mW=Qe("briefcase",_ce);const Sce=[["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"}]],a2=Qe("bug",Sce);const Nce=[["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"}]],Mce=Qe("cable",Nce);const Ece=[["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"}]],kce=Qe("calculator",Ece);const Tce=[["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"}]],Ace=Qe("calendar-days",Tce);const Cce=[["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"}]],si=Qe("calendar",Cce);const jce=[["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=Qe("camera",jce);const Pce=[["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"}]],Dce=Qe("chart-column",Pce);const Rce=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ia=Qe("check",Rce);const Oce=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],ei=Qe("chevron-down",Oce);const Lce=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],gs=Qe("chevron-right",Lce);const Fce=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],gh=Qe("chevron-left",Fce);const Ice=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],xh=Qe("chevron-up",Ice);const Uce=[["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"}]],$i=Qe("circle-alert",Uce);const zce=[["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"}]],Jk=Qe("circle-arrow-up",zce);const Bce=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Ar=Qe("circle-check-big",Bce);const $ce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],s2=Qe("circle-check",$ce);const Hce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Vce=Qe("circle-dot",Hce);const Gce=[["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"}]],qce=Qe("circle-question-mark",Gce);const Wce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],Kce=Qe("circle-stop",Wce);const Xce=[["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"}]],Yi=Qe("circle-x",Xce);const Yce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],dP=Qe("circle",Yce);const Qce=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Jn=Qe("clock",Qce);const Zce=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],o2=Qe("cloud",Zce);const Jce=[["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"}]],eue=Qe("code-xml",Jce);const tue=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],pW=Qe("code",tue);const nue=[["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"}]],rue=Qe("coffee",nue);const iue=[["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"}]],aue=Qe("cog",iue);const sue=[["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"}]],oue=Qe("compass",sue);const lue=[["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"}]],Fl=Qe("copy",lue);const cue=[["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"}]],Dw=Qe("cpu",cue);const uue=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]],due=Qe("cylinder",uue);const hue=[["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"}]],Mu=Qe("database",hue);const fue=[["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"}]],hP=Qe("dollar-sign",fue);const mue=[["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"}]],yi=Qe("download",mue);const pue=[["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"}]],TR=Qe("droplet",pue);const gue=[["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"}]],AR=Qe("droplets",gue);const xue=[["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"}]],ih=Qe("ellipsis-vertical",xue);const bue=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],eT=Qe("equal",bue);const yue=[["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"}]],Kr=Qe("external-link",yue);const vue=[["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"}]],l2=Qe("eye-off",vue);const wue=[["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=Qe("eye",wue);const _ue=[["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"}]],gW=Qe("fan",_ue);const Sue=[["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=Qe("file-box",Sue);const Nue=[["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"}]],G1=Qe("file-code",Nue);const Mue=[["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"}]],Eue=Qe("file-exclamation-point",Mue);const kue=[["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"}]],q1=Qe("file-spreadsheet",kue);const Tue=[["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"}]],Ls=Qe("file-text",Tue);const Aue=[["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"}]],c2=Qe("file",Aue);const Cue=[["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"}]],ah=Qe("film",Cue);const jue=[["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"}]],Pue=Qe("flame",jue);const Due=[["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"}]],Ja=Qe("folder-kanban",Due);const Rue=[["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=Qe("folder-open",Rue);const Oue=[["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"}]],Lue=Qe("folder-plus",Oue);const Fue=[["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"}]],Iue=Qe("folder-tree",Fue);const Uue=[["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"}]],xW=Qe("folder",Uue);const zue=[["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"}]],Bue=Qe("fullscreen",zue);const $ue=[["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"}]],u2=Qe("funnel",$ue);const Hue=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],d2=Qe("gauge",Hue);const Vue=[["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"}]],Gue=Qe("gift",Vue);const que=[["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"}]],_g=Qe("git-compare",que);const Wue=[["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"}]],fP=Qe("github",Wue);const Kue=[["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"}]],sh=Qe("globe",Kue);const Xue=[["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=Qe("grip-vertical",Xue);const Yue=[["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"}]],bW=Qe("hand",Yue);const Que=[["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"}]],h2=Qe("hard-drive",Que);const Zue=[["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"}]],Jue=Qe("hash",Zue);const ede=[["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"}]],tde=Qe("headphones",ede);const nde=[["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"}]],rde=Qe("heart",nde);const ide=[["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=Qe("history",ide);const ade=[["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"}]],f2=Qe("house",ade);const sde=[["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"}]],Ou=Qe("image",sde);const ode=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Zo=Qe("info",ode);const lde=[["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"}]],cde=Qe("italic",lde);const ude=[["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=Qe("key",ude);const dde=[["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"}]],mP=Qe("keyboard",dde);const hde=[["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"}]],sl=Qe("layers",hde);const fde=[["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"}]],m2=Qe("layout-grid",fde);const mde=[["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"}]],pde=Qe("link-2-off",mde);const gde=[["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"}]],uc=Qe("link-2",gde);const xde=[["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=Qe("link",xde);const bde=[["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"}]],yW=Qe("list-ordered",bde);const yde=[["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"}]],pP=Qe("list-todo",yde);const vde=[["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"}]],p2=Qe("list",vde);const wde=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ht=Qe("loader-circle",wde);const _de=[["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"}]],tT=Qe("lock-open",_de);const Sde=[["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"}]],nT=Qe("lock",Sde);const Nde=[["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"}]],Dz=Qe("log-in",Nde);const Mde=[["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"}]],gP=Qe("log-out",Mde);const Ede=[["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"}]],kde=Qe("mail",Ede);const Tde=[["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"}]],Ade=Qe("map",Tde);const Cde=[["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"}]],vW=Qe("maximize-2",Cde);const jde=[["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"}]],Pde=Qe("maximize",jde);const Dde=[["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"}]],Rde=Qe("memory-stick",Dde);const Ode=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],Lde=Qe("menu",Ode);const Fde=[["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"}]],wW=Qe("minimize-2",Fde);const Ide=[["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"}]],_W=Qe("minimize",Ide);const Ude=[["path",{d:"M5 12h14",key:"1ays0h"}]],xP=Qe("minus",Ude);const zde=[["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"}]],Bde=Qe("monitor",zde);const $de=[["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"}]],W1=Qe("moon",$de);const Hde=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],Vde=Qe("move-right",Hde);const Gde=[["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"}]],bP=Qe("music",Gde);const qde=[["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"}]],mc=Qe("package",qde);const Wde=[["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"}]],SW=Qe("palette",Wde);const Kde=[["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"}]],CR=Qe("pause",Kde);const Xde=[["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=Qe("pen-line",Xde);const Yde=[["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"}]],fg=Qe("pen",Yde);const Qde=[["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"}]],Qi=Qe("pencil",Qde);const Zde=[["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"}]],Jde=Qe("phone",Zde);const ehe=[["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"}]],Is=Qe("play",ehe);const the=[["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"}]],tl=Qe("plug",the);const nhe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],ur=Qe("plus",nhe);const rhe=[["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"}]],g2=Qe("power-off",rhe);const ihe=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Gu=Qe("power",ihe);const ahe=[["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"}]],Ur=Qe("printer",ahe);const she=[["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"}]],NW=Qe("qr-code",she);const ohe=[["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"}]],jR=Qe("radio",ohe);const lhe=[["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"}]],Dr=Qe("refresh-cw",lhe);const che=[["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"}]],Rh=Qe("rotate-ccw",che);const uhe=[["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"}]],dhe=Qe("ruler",uhe);const hhe=[["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"}]],hs=Qe("save",hhe);const fhe=[["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"}]],K1=Qe("scan-search",fhe);const mhe=[["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"}]],phe=Qe("scissors",mhe);const ghe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],ba=Qe("search",ghe);const xhe=[["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"}]],PR=Qe("send",xhe);const bhe=[["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=Qe("server",bhe);const yhe=[["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=Qe("settings-2",yhe);const vhe=[["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"}]],x2=Qe("settings",vhe);const whe=[["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"}]],rT=Qe("shield",whe);const _he=[["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"}]],MW=Qe("shopping-cart",_he);const She=[["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"}]],Nhe=Qe("signal",She);const Mhe=[["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"}]],Ehe=Qe("skip-back",Mhe);const khe=[["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"}]],DR=Qe("skip-forward",khe);const The=[["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"}]],Rz=Qe("sliders-vertical",The);const Ahe=[["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=Qe("sparkles",Ahe);const Che=[["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"}]],ol=Qe("square-check-big",Che);const jhe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}]],Phe=Qe("square-minus",jhe);const Dhe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],ll=Qe("square",Dhe);const Rhe=[["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=Qe("star",Rhe);const Ohe=[["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"}]],EW=Qe("sticky-note",Ohe);const Lhe=[["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"}]],Oz=Qe("sun",Lhe);const Fhe=[["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=Qe("tag",Fhe);const Ihe=[["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"}]],kW=Qe("target",Ihe);const Uhe=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],TW=Qe("terminal",Uhe);const zhe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Bhe=Qe("text-align-center",zhe);const $he=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Hhe=Qe("text-align-end",$he);const Vhe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],Ghe=Qe("text-align-start",Vhe);const qhe=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],b2=Qe("thermometer",qhe);const Whe=[["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"}]],xu=Qe("timer",Whe);const Khe=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],rn=Qe("trash-2",Khe);const Xhe=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],AW=Qe("trending-down",Xhe);const Yhe=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],yP=Qe("trending-up",Yhe);const Qhe=[["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"}]],Cn=Qe("triangle-alert",Qhe);const Zhe=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Jhe=Qe("underline",Zhe);const efe=[["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"}]],RR=Qe("unlink",efe);const tfe=[["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"}]],Ua=Qe("upload",tfe);const nfe=[["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=Qe("user",nfe);const rfe=[["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"}]],mg=Qe("users",rfe);const ife=[["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"}]],OR=Qe("video",ife);const afe=[["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"}]],sfe=Qe("volume-2",afe);const ofe=[["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"}]],lfe=Qe("volume-x",ofe);const cfe=[["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"}]],ufe=Qe("wand-sparkles",cfe);const dfe=[["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=Qe("wifi-off",dfe);const hfe=[["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=Qe("wifi",hfe);const ffe=[["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"}]],CW=Qe("wind",ffe);const mfe=[["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=Qe("wrench",mfe);const pfe=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Rt=Qe("x",pfe);const gfe=[["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"}]],LR=Qe("zoom-in",gfe);const xfe=[["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=Qe("zap",xfe);const bfe=[["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"}]],FR=Qe("zoom-out",bfe),pn="/api/v1";let Nr=localStorage.getItem("auth_token");function r0(t){Nr=t,t?localStorage.setItem("auth_token",t):localStorage.removeItem("auth_token")}function Lz(){return Nr}async function Re(t,e={}){const n={"Content-Type":"application/json",...e.headers};Nr&&(n.Authorization=`Bearer ${Nr}`);const r=await fetch(`${pn}${t}`,{...e,cache:"no-store",headers:n});if(!r.ok){r.status===401&&r0(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)=>`${pn}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,downloadPrinterFilesAsZip:async(t,e)=>{const n=await fetch(`${pn}/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(`${pn}/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(`${pn}/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=>`${pn}/archives/${t}/thumbnail?v=${Date.now()}`,getArchivePlateThumbnail:(t,e)=>`${pn}/archives/${t}/plate-thumbnail/${e}`,getArchiveDownload:t=>`${pn}/archives/${t}/download`,getArchiveGcode:t=>`${pn}/archives/${t}/gcode`,getArchivePlatePreview:t=>`${pn}/archives/${t}/plate-preview`,getArchiveTimelapse:t=>`${pn}/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={};Nr&&(r.Authorization=`Bearer ${Nr}`);const i=await fetch(`${pn}/archives/${t}/timelapse/upload`,{method:"POST",headers:r,body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.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={};Nr&&(i.Authorization=`Bearer ${Nr}`);const a=await fetch(`${pn}/archives/${t}/timelapse/process`,{method:"POST",headers:i,body:r});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${a.status}`)}return a.json()},getArchivePhotoUrl:(t,e)=>`${pn}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};Nr&&(r.Authorization=`Bearer ${Nr}`);const i=await fetch(`${pn}/archives/${t}/photos`,{headers:r,method:"POST",body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},deleteArchivePhoto:(t,e)=>Re(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${pn}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${pn}/archives/${t}/source/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,uploadSource3mf:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};Nr&&(r.Authorization=`Bearer ${Nr}`);const i=await fetch(`${pn}/archives/${t}/source`,{method:"POST",headers:r,body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},deleteSource3mf:t=>Re(`/archives/${t}/source`,{method:"DELETE"}),getF3dDownloadUrl:t=>`${pn}/archives/${t}/f3d`,uploadF3d:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};Nr&&(r.Authorization=`Bearer ${Nr}`);const i=await fetch(`${pn}/archives/${t}/f3d`,{method:"POST",headers:r,body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},deleteF3d:t=>Re(`/archives/${t}/f3d`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${pn}/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)=>`${pn}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${pn}/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?`${pn}/archives/upload?printer_id=${e}`:`${pn}/archives/upload`,i={};Nr&&(i.Authorization=`Bearer ${Nr}`);const a=await fetch(r,{method:"POST",headers:i,body:n});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${a.status}`)}return a.json()},uploadArchivesBulk:async(t,e)=>{const n=new FormData;t.forEach(o=>n.append("files",o));const r=e?`${pn}/archives/upload-bulk?printer_id=${e}`:`${pn}/archives/upload-bulk`,i={};Nr&&(i.Authorization=`Bearer ${Nr}`);const a=await fetch(r,{method:"POST",headers:i,body:n});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${a.status}`)}return a.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=`${pn}/settings/backup`,e=await fetch(t);if(!e.ok){const a=await e.text();throw new Error(a||`Backup failed with status ${e.status}`)}const n=e.headers.get("Content-Disposition");let r="bambuddy-backup.zip";if(n){const a=n.match(/filename=([^;]+)/);a&&(r=a[1].trim())}return{blob:await e.blob(),filename:r}},importBackup:async t=>{const e=new FormData;e.append("file",t);const n=`${pn}/settings/restore`,r={};return Nr&&(r.Authorization=`Bearer ${Nr}`),(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(`${pn}/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(`${pn}/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"),getLinkedSpools:()=>Re("/spoolman/spools/linked"),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)=>`${pn}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${pn}/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)=>`${pn}/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={};Nr&&(r.Authorization=`Bearer ${Nr}`);const i=await fetch(`${pn}/external-links/${t}/icon`,{method:"POST",headers:r,body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},deleteExternalLinkIcon:t=>Re(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${pn}/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={};Nr&&(r.Authorization=`Bearer ${Nr}`);const i=await fetch(`${pn}/projects/${t}/attachments`,{method:"POST",headers:r,body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},getProjectAttachmentUrl:(t,e)=>`${pn}/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 a={};Nr&&(a.Authorization=`Bearer ${Nr}`);const o=await fetch(`${pn}/library/files?${i}`,{method:"POST",headers:a,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 a=new FormData;a.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={};Nr&&(l.Authorization=`Bearer ${Nr}`);const c=await fetch(`${pn}/library/files/extract-zip?${o}`,{method:"POST",headers:l,body:a});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=>`${pn}/library/files/${t}/download`,getLibraryFileThumbnailUrl:t=>`${pn}/library/files/${t}/thumbnail`,getLibraryFilePlateThumbnail:(t,e)=>`${pn}/library/files/${t}/plate-thumbnail/${e}`,getLibraryFileGcodeUrl:t=>`${pn}/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"})},p1={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"})}},ag={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"})},g1={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(`${pn}/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(),a=window.URL.createObjectURL(i),o=document.createElement("a");o.href=a,o.download=r,document.body.appendChild(o),o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(a)},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"})},jW=_.createContext(void 0);function yfe({children:t}){const[e,n]=_.useState(()=>{const k=localStorage.getItem("theme-mode"),R=localStorage.getItem("theme");return k||R||"dark"}),[r,i]=_.useState(()=>localStorage.getItem("dark-style")||"classic"),[a,o]=_.useState(()=>localStorage.getItem("dark-background")||"neutral"),[l,c]=_.useState(()=>localStorage.getItem("dark-accent")||"green"),[u,d]=_.useState(()=>localStorage.getItem("light-style")||"classic"),[f,p]=_.useState(()=>localStorage.getItem("light-background")||"neutral"),[m,x]=_.useState(()=>localStorage.getItem("light-accent")||"green");_.useEffect(()=>{ue.getSettings().then(k=>{k.dark_style&&(i(k.dark_style),localStorage.setItem("dark-style",k.dark_style)),k.dark_background&&(o(k.dark_background),localStorage.setItem("dark-background",k.dark_background)),k.dark_accent&&(c(k.dark_accent),localStorage.setItem("dark-accent",k.dark_accent)),k.light_style&&(d(k.light_style),localStorage.setItem("light-style",k.light_style)),k.light_background&&(p(k.light_background),localStorage.setItem("light-background",k.light_background)),k.light_accent&&(x(k.light_accent),localStorage.setItem("light-accent",k.light_accent))}).catch(()=>{})},[]),_.useEffect(()=>{const k=document.documentElement;k.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"?(k.classList.add("dark"),k.classList.add(`style-${r}`),k.classList.add(`bg-${a}`),k.classList.add(`accent-${l}`)):(k.classList.add(`style-${u}`),k.classList.add(`bg-${f}`),k.classList.add(`accent-${m}`)),localStorage.setItem("theme-mode",e),localStorage.removeItem("theme")},[e,r,a,l,u,f,m]);const b=()=>n(k=>k==="dark"?"light":"dark"),y=k=>n(k),v=k=>{i(k),localStorage.setItem("dark-style",k),ue.updateSettings({dark_style:k}).catch(()=>{})},S=k=>{o(k),localStorage.setItem("dark-background",k),ue.updateSettings({dark_background:k}).catch(()=>{})},M=k=>{c(k),localStorage.setItem("dark-accent",k),ue.updateSettings({dark_accent:k}).catch(()=>{})},T=k=>{d(k),localStorage.setItem("light-style",k),ue.updateSettings({light_style:k}).catch(()=>{})},E=k=>{p(k),localStorage.setItem("light-background",k),ue.updateSettings({light_background:k}).catch(()=>{})},C=k=>{x(k),localStorage.setItem("light-accent",k),ue.updateSettings({light_accent:k}).catch(()=>{})};return s.jsx(jW.Provider,{value:{mode:e,darkStyle:r,darkBackground:a,darkAccent:l,lightStyle:u,lightBackground:f,lightAccent:m,toggleMode:b,setMode:y,setDarkStyle:v,setDarkBackground:S,setDarkAccent:M,setLightStyle:T,setLightBackground:E,setLightAccent:C},children:t})}function Oh(){const t=_.useContext(jW);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}function _t({children:t,className:e="",onClick:n,onContextMenu:r,...i}){return s.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 Wn({children:t,className:e=""}){return s.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Nt({children:t,className:e=""}){return s.jsx("div",{className:`p-6 ${e}`,children:t})}function vfe(t,e,n){return[{category:"Navigation",items:t?t.slice(0,9).map((i,a)=>({keys:[String(a+1)],description:i.type==="external"?`Open ${i.label}`:`Go to ${i.labelKey?n(i.labelKey):i.label}`,isExternal:i.type==="external"})):e?e.map((i,a)=>({keys:[String(a+1)],description:`Go to ${n(i.labelKey)}`,isExternal:!1})):[{keys:["1"],description:"Go to Printers",isExternal:!1},{keys:["2"],description:"Go to Archives",isExternal:!1},{keys:["3"],description:"Go to Queue",isExternal:!1},{keys:["4"],description:"Go to Statistics",isExternal:!1},{keys:["5"],description:"Go to Cloud Profiles",isExternal:!1},{keys:["6"],description:"Go to Settings",isExternal:!1}]},{category:"Archives",items:[{keys:["/"],description:"Focus search",isExternal:!1},{keys:["U"],description:"Open upload modal",isExternal:!1},{keys:["Esc"],description:"Clear selection / blur input",isExternal:!1},{keys:["Right-click"],description:"Context menu on cards",isExternal:!1}]},{category:"K-Profiles",items:[{keys:["R"],description:"Refresh profiles",isExternal:!1},{keys:["N"],description:"New profile",isExternal:!1},{keys:["Esc"],description:"Exit selection mode",isExternal:!1}]},{category:"General",items:[{keys:["?"],description:"Show this help",isExternal:!1}]}]}function Fz({children:t}){return s.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 wfe({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=$n(),i=vfe(n,e,r);return _.useEffect(()=>{const a=o=>{o.key==="Escape"&&t()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:s.jsx(_t,{className:"w-full max-w-md",onClick:a=>a.stopPropagation(),children:s.jsxs(Nt,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(mP,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:i.map(a=>s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:a.category}),s.jsx("div",{className:"space-y-2",children:a.items.map(o=>s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"text-white text-sm flex items-center gap-1.5",children:[o.description,o.isExternal&&s.jsx(Kr,{className:"w-3 h-3 text-bambu-gray"})]}),s.jsx("div",{className:"flex gap-1",children:o.keys.map(l=>s.jsx(Fz,{children:l},l))})]},o.description))})]},a.category))}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",s.jsx(Fz,{children:"Esc"})," or click outside to close"]})})]})})})}function Te({variant:t="primary",size:e="md",className:n="",children:r,...i}){const a="inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-bambu-dark disabled:opacity-50 disabled:cursor-not-allowed",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 s.jsx("button",{className:`${a} ${o[t]} ${l[e]} ${n}`,...i,children:r})}function Qn({title:t,message:e,confirmText:n,cancelText:r,variant:i="default",isLoading:a=!1,loadingText:o,onConfirm:l,onCancel:c}){const{t:u}=$n(),d=n??u("common.confirm"),f=r??u("common.cancel"),p=o??u("common.loading");_.useEffect(()=>{const b=y=>{y.key==="Escape"&&!a&&c()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[c,a]);const x={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 s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:a?void 0:c,children:s.jsx(_t,{className:"w-full max-w-md",onClick:b=>b.stopPropagation(),children:s.jsxs(Nt,{className:"p-6",children:[s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${x.icon}`,children:s.jsx(Cn,{className:"w-6 h-6"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),s.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),s.jsxs("div",{className:"flex gap-3 mt-6",children:[s.jsx(Te,{variant:"secondary",onClick:c,className:"flex-1",disabled:a,children:f}),s.jsx(Te,{onClick:l,className:`flex-1 ${x.button}`,disabled:a,children:a?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 mr-2 animate-spin"}),p]}):d})]})]})})})}function _fe({plug:t}){const e=an(),[n,r]=_.useState(null),{data:i,isLoading:a}=at({queryKey:["smart-plug-status",t.id],queryFn:()=>ue.getSmartPlugStatus(t.id),refetchInterval:1e4}),o=mt({mutationFn:m=>ue.controlSmartPlug(t.id,m),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",p=()=>{n&&(o.mutate(n),r(null))};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between py-2 px-3 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.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?s.jsx(jR,{className:`w-4 h-4 ${u?"text-teal-400":"text-red-400"}`}):s.jsx(tl,{className:`w-4 h-4 ${u?l?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white font-medium",children:t.name}),s.jsx("div",{className:"flex items-center gap-1 text-xs",children:a?s.jsx(ht,{className:"w-3 h-3 text-bambu-gray animate-spin"}):f?u?s.jsxs(s.Fragment,{children:[s.jsx(vh,{className:"w-3 h-3 text-teal-400"}),s.jsxs("span",{className:"text-teal-400",children:[Math.round(i?.energy?.power??0),"W"]}),s.jsx("span",{className:"text-bambu-gray mx-1",children:"|"}),s.jsx(Ru,{className:"w-3 h-3 text-bambu-gray"}),s.jsx("span",{className:"text-bambu-gray",children:"Monitor"})]}):s.jsxs(s.Fragment,{children:[s.jsx(sm,{className:"w-3 h-3 text-status-error"}),s.jsx("span",{className:"text-status-error",children:"Waiting"})]}):u?s.jsxs(s.Fragment,{children:[s.jsx(Sg,{className:"w-3 h-3 text-status-ok"}),s.jsx("span",{className:l?"text-status-ok":"text-bambu-gray",children:i?.state||"Unknown"}),i?.energy?.power!==null&&i?.energy?.power!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-bambu-gray mx-1",children:"|"}),s.jsx(vh,{className:"w-3 h-3 text-yellow-400"}),s.jsxs("span",{className:"text-yellow-400",children:[Math.round(i.energy.power),"W"]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(sm,{className:"w-3 h-3 text-status-error"}),s.jsx("span",{className:"text-status-error",children:"Offline"})]})})]})]}),!f&&s.jsxs("div",{className:"flex gap-1",children:[s.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?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Gu,{className:"w-4 h-4"})}),s.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?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(g2,{className:"w-4 h-4"})})]})]}),n&&s.jsx(Qn,{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:p,onCancel:()=>r(null)})]})}function Iz({onClose:t}){const{data:e,isLoading:n}=at({queryKey:["smart-plugs"],queryFn:ue.getSmartPlugs}),r=e?.filter(i=>i.show_in_switchbar)||[];return s.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:[s.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary",children:s.jsxs("h3",{className:"text-sm font-semibold text-white flex items-center gap-2",children:[s.jsx(tl,{className:"w-4 h-4 text-bambu-green"}),"Smart Switches"]})}),s.jsx("div",{className:"p-2 max-h-80 overflow-y-auto",children:n?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-gray animate-spin"})}):r.length===0?s.jsxs("div",{className:"text-center py-6 px-4",children:[s.jsx(tl,{className:"w-8 h-8 text-bambu-gray mx-auto mb-2"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"No switches in switchbar"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:'Enable "Show in Switchbar" in Settings > Smart Plugs'})]}):s.jsx("div",{className:"space-y-1",children:r.map(i=>s.jsx(_fe,{plug:i},i.id))})})]})}const PW=[{name:"globe",icon:sh},{name:"link",icon:Fy},{name:"external-link",icon:Kr},{name:"book",icon:bce},{name:"file-text",icon:Ls},{name:"home",icon:f2},{name:"star",icon:im},{name:"heart",icon:rde},{name:"bookmark",icon:vce},{name:"shopping-cart",icon:MW},{name:"music",icon:bP},{name:"video",icon:OR},{name:"image",icon:Ou},{name:"camera",icon:Ug},{name:"map",icon:Ade},{name:"compass",icon:oue},{name:"coffee",icon:rue},{name:"gift",icon:Gue},{name:"wrench",icon:om},{name:"zap",icon:vh},{name:"cloud",icon:o2},{name:"database",icon:Mu},{name:"folder",icon:xW},{name:"mail",icon:kde},{name:"phone",icon:Jde},{name:"user",icon:am},{name:"users",icon:mg},{name:"server",icon:yf},{name:"terminal",icon:TW},{name:"code",icon:pW}];function y2(t){return PW.find(n=>n.name===t)?.icon||Fy}function Sfe({value:t,onChange:e}){const[n,r]=_.useState(!1),i=y2(t);return s.jsxs("div",{className:"relative",children:[s.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:[s.jsx(i,{className:"w-5 h-5"}),s.jsx("span",{className:"text-sm text-bambu-gray flex-1 text-left",children:t})]}),n&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>r(!1)}),s.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:s.jsx("div",{className:"grid grid-cols-5 gap-1 p-2",children:PW.map(({name:a,icon:o})=>s.jsx("button",{type:"button",onClick:()=>{e(a),r(!1)},className:`p-2 rounded-lg transition-colors flex items-center justify-center ${t===a?"bg-bambu-green text-white":"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:a,children:s.jsx(o,{className:"w-5 h-5"})},a))})})]})]})}const Uz=768;function IR(){const[t,e]=_.useState(()=>typeof window<"u"?window.innerWidth<Uz:!1);return _.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Uz-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const DW=_.createContext(void 0);function Nfe({children:t}){const[e,n]=_.useState(null),[r,i]=_.useState(!1),[a,o]=_.useState(!1),[l,c]=_.useState(!0),u=_.useRef(!1),d=_.useRef(!0),f=async()=>{try{const C=await ue.getAuthStatus();if(!d.current)return;if(i(C.auth_enabled),o(C.requires_setup),C.auth_enabled)if(Lz())try{const R=await ue.getCurrentUser();if(!d.current)return;n(R)}catch{if(r0(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)}};_.useEffect(()=>(d.current=!0,f(),()=>{d.current=!1}),[]),_.useEffect(()=>{if(!l&&a&&!r){const C=window.location.pathname;C!=="/setup"&&!C.startsWith("/camera/")&&!u.current&&(u.current=!0,window.location.href="/setup")}else a||(u.current=!1)},[l,a,r]);const p=async(C,k)=>{const R=await ue.login({username:C,password:k});r0(R.access_token),n(R.user)},m=()=>{r0(null),n(null),ue.logout().catch(()=>{}),window.location.href="/login"},x=async()=>{if(r&&Lz())try{const C=await ue.getCurrentUser();d.current&&n(C)}catch{r0(null),d.current&&n(null)}},b=async()=>{await f()},y=_.useMemo(()=>new Set(e?.permissions??[]),[e?.permissions]),v=_.useMemo(()=>r?e?.is_admin??!1:!0,[r,e?.is_admin]),S=_.useCallback(C=>!r||v?!0:y.has(C),[r,v,y]),M=_.useCallback((...C)=>!r||v?!0:C.some(k=>y.has(k)),[r,v,y]),T=_.useCallback((...C)=>!r||v?!0:C.every(k=>y.has(k)),[r,v,y]),E=_.useCallback((C,k,R)=>{if(!r||v)return!0;const A=`${C}:${k}_all`,D=`${C}:${k}_own`;return y.has(A)?!0:y.has(D)?R==null?!1:R===e?.id:!1},[r,v,y,e?.id]);return s.jsx(DW.Provider,{value:{user:e,authEnabled:r,requiresSetup:a,loading:l,isAdmin:v,login:p,logout:m,refreshUser:x,refreshAuth:b,hasPermission:S,hasAnyPermission:M,hasAllPermissions:T,canModify:E},children:t})}function Ai(){const t=_.useContext(DW);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}const RW=_.createContext(void 0);function Hn(){const t=_.useContext(RW);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const Mfe={success:s.jsx(Ar,{className:"w-5 h-5 text-green-400"}),error:s.jsx(Yi,{className:"w-5 h-5 text-red-400"}),warning:s.jsx($i,{className:"w-5 h-5 text-yellow-400"}),info:s.jsx(Zo,{className:"w-5 h-5 text-blue-400"}),loading:s.jsx(ht,{className:"w-5 h-5 text-bambu-green animate-spin"})},Efe={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 kfe({children:t}){const[e,n]=_.useState([]),r=_.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=_.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}])},[]),a=_.useCallback(o=>{n(l=>l.filter(c=>c.id!==o))},[]);return s.jsxs(RW.Provider,{value:{showToast:r,showPersistentToast:i,dismissToast:a},children:[t,s.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(o=>s.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${Efe[o.type]}`,children:[Mfe[o.type],s.jsx("span",{className:"text-white text-sm",children:o.message}),s.jsx("button",{onClick:()=>a(o.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-4 h-4"})})]},o.id))})]})}const K0=[{id:"printers",to:"/",icon:Ur,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:fo,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:si,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:Dce,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:o2,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:om,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:Ja,labelKey:"nav.projects"},{id:"files",to:"/files",icon:Il,labelKey:"nav.files"},{id:"settings",to:"/settings",icon:x2,labelKey:"nav.settings"}];function Tfe(){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 Afe(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function iT(t){return t.startsWith("ext-")}function OW(){return localStorage.getItem("defaultView")||"/"}function Cfe(t){localStorage.setItem("defaultView",t)}function jfe(){const t=Mc(),e=Nc(),{mode:n,toggleMode:r}=Oh(),{t:i}=$n(),a=IR(),{user:o,authEnabled:l,logout:c,hasPermission:u}=Ai(),{showToast:d}=Hn(),[f,p]=_.useState(!1),[m,x]=_.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[b,y]=_.useState(!1),[v,S]=_.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[M,T]=_.useState(!1),[E,C]=_.useState(!1),[k,R]=_.useState(!1),[A,D]=_.useState(Tfe),[U,F]=_.useState(null),[H,j]=_.useState(null),$=_.useRef(!1),[K,V]=_.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),[Q,Z]=_.useState(null),{data:ae}=at({queryKey:["version"],queryFn:ue.getVersion,staleTime:1/0}),{data:B}=at({queryKey:["settings"],queryFn:ue.getSettings,staleTime:300*1e3}),{data:X}=at({queryKey:["updateCheck"],queryFn:ue.checkForUpdates,enabled:B?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:ne}=at({queryKey:["external-links"],queryFn:ue.getExternalLinks}),{data:se}=at({queryKey:["smart-plugs"],queryFn:ue.getSmartPlugs,staleTime:30*1e3}),be=se?.some(O=>O.show_in_switchbar)??!1,{data:xe}=at({queryKey:["debugLogging"],queryFn:Ng.getDebugLoggingState,staleTime:60*1e3,refetchInterval:60*1e3}),{data:de}=at({queryKey:["queue","pending"],queryFn:()=>ue.getQueue(void 0,"pending"),staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),Pe=de?.length??0,{data:ie}=at({queryKey:["pending-uploads","count"],queryFn:ag.getCount,staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),Me=ie?.count??0,[Oe,ge]=_.useState(null);_.useEffect(()=>{if(!xe?.enabled||!xe.enabled_at){ge(null);return}const O=new Date(xe.enabled_at).getTime(),ee=()=>{ge(Math.floor((Date.now()-O)/1e3))};ee();const le=setInterval(ee,1e3);return()=>clearInterval(le)},[xe?.enabled,xe?.enabled_at]);const Ke=_.useMemo(()=>new Map(K0.map(O=>[O.id,O])),[]),G=_.useMemo(()=>new Map((ne||[]).map(O=>[`ext-${O.id}`,O])),[ne]),Y=(()=>{const O=[],ee=new Set,le=l&&o?.role==="user";for(const _e of A)le&&_e==="settings"||(Ke.has(_e)||G.has(_e))&&(O.push(_e),ee.add(_e));for(const _e of K0)le&&_e.id==="settings"||ee.has(_e.id)||(O.push(_e.id),ee.add(_e.id));for(const _e of ne||[]){const we=`ext-${_e.id}`;ee.has(we)||(O.push(we),ee.add(we))}return O})(),ce=(O,ee)=>{F(ee),O.dataTransfer.effectAllowed="move",O.dataTransfer.setData("text/plain",ee)},q=(O,ee)=>{O.preventDefault(),O.dataTransfer.dropEffect="move",j(ee)},te=()=>{j(null)},I=(O,ee)=>{if(O.preventDefault(),U===null||U===ee){F(null),j(null);return}const le=[...Y],_e=le.indexOf(U),we=le.indexOf(ee);if(_e===-1||we===-1){F(null),j(null);return}le.splice(_e,1),le.splice(we,0,U),D(le),Afe(le),F(null),j(null)},fe=()=>{F(null),j(null)},me=X?.update_available&&X.latest_version&&X.latest_version!==K,ke=()=>{X?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",X.latest_version),V(X.latest_version))};_.useEffect(()=>{if(!$.current&&e.pathname==="/"){const O=OW();O!=="/"&&($.current=!0,t(O,{replace:!0}))}},[e.pathname,t]),_.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(v))},[v]),_.useEffect(()=>{a&&T(!1)},[e.pathname,a]),_.useEffect(()=>{const O=ee=>{const le=ee.detail;Z({printer_id:le.printer_id,printer_name:le.printer_name,message:le.message})};return window.addEventListener("plate-not-empty",O),()=>window.removeEventListener("plate-not-empty",O)},[]);const z=_.useCallback(O=>{const ee=O.target;if(!(ee.tagName==="INPUT"||ee.tagName==="TEXTAREA"||ee.isContentEditable)&&!O.metaKey&&!O.ctrlKey&&!O.altKey){const le=parseInt(O.key);if(le>=1&&le<=Y.length&&le<=9){const _e=Y[le-1];if(O.preventDefault(),iT(_e)){const we=_e.replace("ext-","");t(`/external/${we}`)}else{const we=Ke.get(_e);we&&t(we.to)}return}switch(O.key){case"?":O.preventDefault(),C(!0);break;case"Escape":C(!1);break}}},[t,Y,Ke]);return _.useEffect(()=>(document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)),[z]),s.jsxs("div",{className:"flex min-h-screen",children:[a&&s.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:[s.jsx("button",{onClick:()=>T(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:s.jsx(Lde,{className:"w-6 h-6 text-white"})}),s.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-8 ml-3"})]}),a&&M&&s.jsx("div",{className:"fixed inset-0 bg-black/60 z-40 transition-opacity",onClick:()=>T(!1)}),s.jsxs("aside",{className:`bg-bambu-dark-secondary border-r border-bambu-dark-tertiary flex flex-col transition-all duration-300 ${a?`fixed inset-y-0 left-0 z-50 w-72 transform ${M?"translate-x-0":"-translate-x-full"}`:`fixed inset-y-0 left-0 z-30 ${v?"w-64":"w-16"}`}`,children:[s.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${a||v?"p-4":"p-2"}`,children:s.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:a||v?"h-16 w-auto":"h-8 w-8 object-cover object-left"})}),s.jsx("nav",{className:"flex-1 p-2",children:s.jsx("ul",{className:"space-y-2",children:Y.map(O=>{if(iT(O)){const le=G.get(O);if(!le)return null;const _e=le.custom_icon?null:y2(le.icon);return s.jsx("li",{draggable:!0,onDragStart:we=>ce(we,O),onDragOver:we=>q(we,O),onDragLeave:te,onDrop:we=>I(we,O),onDragEnd:fe,className:`relative ${U===O?"opacity-50":""} ${H===O&&U!==O?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(n0,{to:`/external/${le.id}`,className:({isActive:we})=>`flex items-center ${a||v?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${we?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!v?le.name:void 0,children:[v&&!a&&s.jsx(zg,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),le.custom_icon?s.jsx("img",{src:`/api/v1/external-links/${le.id}/icon`,alt:"",className:`w-5 h-5 flex-shrink-0 ${n==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):_e&&s.jsx(_e,{className:"w-5 h-5 flex-shrink-0"}),(a||v)&&s.jsx("span",{children:le.name})]})},O)}else{const le=Ke.get(O);if(!le)return null;const{to:_e,icon:we,labelKey:re}=le,Fe=O==="queue"&&Pe>0,$e=O==="archives"&&Me>0,Ve=Fe?Pe:$e?Me:0,He=Fe||$e;return s.jsx("li",{draggable:!0,onDragStart:ye=>ce(ye,O),onDragOver:ye=>q(ye,O),onDragLeave:te,onDrop:ye=>I(ye,O),onDragEnd:fe,className:`relative ${U===O?"opacity-50":""} ${H===O&&U!==O?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(n0,{to:_e,className:({isActive:ye})=>`flex items-center ${a||v?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${ye?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!v?i(re):void 0,children:[v&&!a&&s.jsx(zg,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),s.jsxs("div",{className:"relative",children:[s.jsx(we,{className:"w-5 h-5 flex-shrink-0"}),He&&s.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:Ve>99?"99+":Ve})]}),(a||v)&&s.jsx("span",{children:i(re)})]})},O)}})})}),!a&&s.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?s.jsx(gh,{className:"w-5 h-5"}):s.jsx(gs,{className:"w-5 h-5"})}),s.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:a||v?s.jsxs("div",{className:"flex flex-col gap-2 px-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-1",children:[be&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>R(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${k?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:s.jsx(tl,{className:"w-5 h-5"})}),k&&s.jsx(Iz,{onClose:()=>R(!1)})]}),u("system:read")?s.jsx(n0,{to:"/system",className:({isActive:O})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${O?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(Zo,{className:"w-5 h-5"})}):s.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:s.jsx(Zo,{className:"w-5 h-5"})}),s.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:s.jsx(fP,{className:"w-5 h-5"})}),s.jsx("button",{onClick:()=>C(!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:s.jsx(mP,{className:"w-5 h-5"})}),s.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"?s.jsx(Oz,{className:"w-5 h-5"}):s.jsx(W1,{className:"w-5 h-5"})}),l&&o&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>p(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("changePassword.title"),children:s.jsx(Ho,{className:"w-5 h-5"})}),s.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:s.jsx(gP,{className:"w-5 h-5"})})]})]}),s.jsxs("div",{className:"flex items-center justify-center gap-2",children:[s.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",ae?.version||"..."]}),X?.update_available&&s.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:X.latest_version}),children:[s.jsx(Jk,{className:"w-4 h-4"}),s.jsx("span",{children:i("nav.update")})]})]})]}):s.jsxs("div",{className:"flex flex-col items-center gap-1",children:[X?.update_available&&s.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:X.latest_version}),children:s.jsx(Jk,{className:"w-5 h-5"})}),be&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>R(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${k?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:s.jsx(tl,{className:"w-5 h-5"})}),k&&s.jsx(Iz,{onClose:()=>R(!1)})]}),u("system:read")?s.jsx(n0,{to:"/system",className:({isActive:O})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${O?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(Zo,{className:"w-5 h-5"})}):s.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:s.jsx(Zo,{className:"w-5 h-5"})}),s.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:s.jsx(fP,{className:"w-5 h-5"})}),s.jsx("button",{onClick:()=>C(!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:s.jsx(mP,{className:"w-5 h-5"})}),s.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"?s.jsx(Oz,{className:"w-5 h-5"}):s.jsx(W1,{className:"w-5 h-5"})}),l&&o&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>p(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("changePassword.title"),children:s.jsx(Ho,{className:"w-5 h-5"})}),s.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:s.jsx(gP,{className:"w-5 h-5"})})]})]})})]}),s.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto transition-all duration-300 ${a?"mt-14":v?"ml-64":"ml-16"}`,children:[xe?.enabled&&s.jsx("div",{className:"bg-amber-500/20 border-b border-amber-500/30 px-4 py-2 flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(a2,{className:"w-4 h-4 text-amber-500 animate-pulse"}),s.jsxs("span",{className:"text-amber-200",children:[i("support.debugLoggingActive",{defaultValue:"Debug logging is active"}),Oe!==null&&s.jsxs("span",{className:"text-amber-300/70 ml-2",children:["(",Math.floor(Oe/60),"m ",Oe%60,"s)"]})]}),s.jsx("button",{onClick:()=>t("/system"),className:"text-amber-400 hover:text-amber-300 font-medium underline ml-2",children:i("support.manageLogs",{defaultValue:"Manage"})})]})}),me&&s.jsxs("div",{className:"bg-bambu-green/20 border-b border-bambu-green/30 px-4 py-2 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(Jk,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{children:i("nav.updateAvailableBanner",{version:X?.latest_version,defaultValue:`Version ${X?.latest_version} is available!`})}),s.jsx("button",{onClick:()=>t("/settings"),className:"text-bambu-green hover:text-bambu-green/80 font-medium underline",children:i("nav.viewUpdate",{defaultValue:"View update"})})]}),s.jsx("button",{onClick:ke,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:s.jsx(Rt,{className:"w-4 h-4"})})]}),s.jsx(Uoe,{})]}),E&&s.jsx(wfe,{onClose:()=>C(!1),sidebarItems:Y.map(O=>{if(iT(O)){const ee=G.get(O);return ee?{type:"external",label:ee.name}:null}else{const ee=Ke.get(O);return ee?{type:"nav",label:ee.labelKey,labelKey:ee.labelKey}:null}}).filter(Boolean)}),Q&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[100] p-4",children:s.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:s.jsxs("div",{className:"p-6 text-center",children:[s.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-yellow-500/20 flex items-center justify-center",children:s.jsx("svg",{className:"w-10 h-10 text-yellow-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.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"})})}),s.jsx("h2",{className:"text-xl font-bold text-yellow-400 mb-2",children:i("plateAlert.title")}),s.jsx("p",{className:"text-lg text-white mb-2",children:Q.printer_name}),s.jsx("p",{className:"text-bambu-gray mb-6",children:i("plateAlert.message")}),s.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("plateAlert.understand")})]})})}),f&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>{p(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})},children:s.jsxs(_t,{className:"w-full max-w-md",onClick:O=>O.stopPropagation(),children:[s.jsx(Wn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ho,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("changePassword.title")})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{p(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})},children:s.jsx(Rt,{className:"w-5 h-5"})})]})}),s.jsxs(Nt,{children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("changePassword.currentPassword")}),s.jsx("input",{type:"password",value:m.currentPassword,onChange:O=>x({...m,currentPassword:O.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:i("changePassword.currentPasswordPlaceholder"),autoComplete:"current-password"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("changePassword.newPassword")}),s.jsx("input",{type:"password",value:m.newPassword,onChange:O=>x({...m,newPassword:O.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:i("changePassword.newPasswordPlaceholder"),autoComplete:"new-password",minLength:6})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("changePassword.confirmPassword")}),s.jsx("input",{type:"password",value:m.confirmPassword,onChange:O=>x({...m,confirmPassword:O.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 ${m.confirmPassword&&m.newPassword!==m.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("changePassword.confirmPasswordPlaceholder"),autoComplete:"new-password",minLength:6}),m.confirmPassword&&m.newPassword!==m.confirmPassword&&s.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("changePassword.passwordsDoNotMatch")})]})]}),s.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:()=>{p(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})},children:i("common.cancel")}),s.jsx(Te,{onClick:async()=>{if(m.newPassword!==m.confirmPassword){d(i("changePassword.passwordsDoNotMatch"),"error");return}if(m.newPassword.length<6){d(i("changePassword.passwordTooShort"),"error");return}y(!0);try{await ue.changePassword(m.currentPassword,m.newPassword),d(i("changePassword.success"),"success"),p(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})}catch(O){const ee=O instanceof Error?O.message:i("changePassword.failed");d(ee,"error")}finally{y(!1)}},disabled:b||!m.currentPassword||!m.newPassword||m.newPassword!==m.confirmPassword||m.newPassword.length<6,children:b?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),i("changePassword.changing")]}):s.jsxs(s.Fragment,{children:[s.jsx(Ho,{className:"w-4 h-4"}),i("changePassword.title")]})})]})]})]})})]})}function y0(t,e="system"){return e==="12h"?t.hour12=!0:e==="24h"&&(t.hour12=!1),t}function Ii(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=Ii(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=Ii(t);if(!r)return"";const a=y0(n??{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},e);return r.toLocaleString(void 0,a)}function Pfe(t,e="system",n){const i=y0({...{hour:"2-digit",minute:"2-digit"},...n},e);return t.toLocaleTimeString([],i)}function Dfe(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 zz(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 Rfe(t,e){if(e)return xW;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return zf;case"gcode":return Ls;case"mp4":case"avi":return ah;case"png":case"jpg":case"jpeg":return Ou;default:return c2}}const Ofe=[{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 Lfe({printerId:t,printerName:e,onClose:n}){const{t:r}=$n(),{showToast:i}=Hn(),a=an(),[o,l]=_.useState("/"),[c,u]=_.useState(new Set),[d,f]=_.useState(""),[p,m]=_.useState([]),[x,b]=_.useState("name-asc"),[y,v]=_.useState(null);_.useEffect(()=>{const $=K=>{K.key==="Escape"&&n()};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[n]);const{data:S,isLoading:M,refetch:T}=at({queryKey:["printerFiles",t,o],queryFn:()=>ue.getPrinterFiles(t,o)}),{data:E}=at({queryKey:["printerStorage",t],queryFn:()=>ue.getPrinterStorage(t),staleTime:3e4}),C=mt({mutationFn:async $=>{for(const K of $)await ue.deletePrinterFile(t,K)},onSuccess:()=>{i(r("printerFiles.toast.filesDeleted",{count:p.length})),a.invalidateQueries({queryKey:["printerFiles",t]}),u(new Set),m([])},onError:$=>{i(r("printerFiles.toast.deleteFailed",{error:$.message}),"error")}}),k=$=>{l($),u(new Set)},R=()=>{if(o==="/")return;const $=o.split("/").filter(Boolean);$.pop(),l($.length?"/"+$.join("/"):"/"),u(new Set)},A=($,K)=>{K.stopPropagation(),u(V=>{const Q=new Set(V);return Q.has($)?Q.delete($):Q.add($),Q})},D=()=>{if(!S?.files)return;const $=S.files.filter(K=>!K.is_directory&&(!d||K.name.toLowerCase().includes(d.toLowerCase()))).map(K=>K.path);u(new Set($))},U=()=>{u(new Set)},F=async()=>{if(c.size===0)return;const $=Array.from(c);if($.length===1){window.open(ue.getPrinterFileDownloadUrl(t,$[0]),"_blank"),u(new Set);return}v({current:0,total:$.length});try{const K=await ue.downloadPrinterFilesAsZip(t,$),V=URL.createObjectURL(K),Q=document.createElement("a");Q.href=V,Q.download=`${e.replace(/[^a-zA-Z0-9]/g,"_")}-files.zip`,document.body.appendChild(Q),Q.click(),document.body.removeChild(Q),URL.revokeObjectURL(V),i(`Downloaded ${$.length} files as ZIP`),u(new Set)}catch(K){i(`Download failed: ${K instanceof Error?K.message:"Unknown error"}`,"error")}finally{v(null)}},H=()=>{c.size!==0&&m(Array.from(c))},j=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[s.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:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(h2,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r("printerFiles.title")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[E&&(E.used_bytes!=null||E.free_bytes!=null)&&s.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[E.used_bytes!=null&&s.jsxs("span",{children:[r("printerFiles.storageUsed")," ",zz(E.used_bytes)]}),E.used_bytes!=null&&E.free_bytes!=null&&s.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),E.free_bytes!=null&&s.jsxs("span",{children:[r("printerFiles.storageFree")," ",zz(E.free_bytes)]})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]})]}),s.jsxs("div",{className:"flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[j.map($=>s.jsx("button",{onClick:()=>{k($.path),f("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${o===$.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:$.label},$.path)),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"relative",children:[s.jsx(ba,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:r("printerFiles.filterPlaceholder"),value:d,onChange:$=>f($.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"})]}),s.jsxs("div",{className:"relative flex items-center gap-1",children:[s.jsx(fW,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("select",{value:x,onChange:$=>b($.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",children:Ofe.map($=>s.jsx("option",{value:$.value,children:$.label},$.value))})]}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>T(),disabled:M,children:s.jsx(Dr,{className:`w-4 h-4 ${M?"animate-spin":""}`})})]}),s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[s.jsx("button",{onClick:R,disabled:o==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:s.jsx(gh,{className:"w-4 h-4"})}),s.jsx("span",{className:"text-bambu-gray font-mono",children:o})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:M?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):S?.files?.length?s.jsx("div",{className:"space-y-1",children:[...S.files].filter($=>!d||$.name.toLowerCase().includes(d.toLowerCase())).sort(($,K)=>{if($.is_directory&&!K.is_directory)return-1;if(!$.is_directory&&K.is_directory)return 1;switch(x){case"name-asc":return $.name.localeCompare(K.name);case"name-desc":return K.name.localeCompare($.name);case"size-asc":return $.size-K.size;case"size-desc":return K.size-$.size;case"date-asc":{const V=$.mtime?new Date($.mtime).getTime():0,Q=K.mtime?new Date(K.mtime).getTime():0;return V-Q}case"date-desc":{const V=$.mtime?new Date($.mtime).getTime():0;return(K.mtime?new Date(K.mtime).getTime():0)-V}default:return $.name.localeCompare(K.name)}}).map($=>{const K=Rfe($.name,$.is_directory),V=c.has($.path);return s.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${V?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{$.is_directory&&k($.path)},children:[$.is_directory?null:s.jsx("button",{onClick:Q=>A($.path,Q),className:"flex-shrink-0 text-bambu-gray hover:text-white",children:V?s.jsx(ol,{className:"w-5 h-5 text-bambu-green"}):s.jsx(ll,{className:"w-5 h-5"})}),s.jsx(K,{className:`w-5 h-5 flex-shrink-0 ${$.is_directory?"text-bambu-green":"text-bambu-gray"}`}),s.jsx("span",{className:"flex-1 text-white truncate",children:$.name}),!$.is_directory&&s.jsx("span",{className:"text-sm text-bambu-gray",children:Dfe($.size)}),$.is_directory&&s.jsx(gh,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},$.path)})}):s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"text-sm text-bambu-gray",children:c.size>0?`${c.size} selected`:d?`${S?.files?.filter($=>$.name.toLowerCase().includes(d.toLowerCase())).length||0} of ${S?.files?.length||0} items`:`${S?.files?.length||0} items`}),S?.files?.some($=>!$.is_directory)&&s.jsx("div",{className:"flex items-center gap-2",children:c.size>0?s.jsxs("button",{onClick:U,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[s.jsx(Phe,{className:"w-4 h-4"}),"Deselect All"]}):s.jsxs("button",{onClick:D,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[s.jsx(ol,{className:"w-4 h-4"}),"Select All"]})})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{variant:"secondary",disabled:c.size===0||y!==null,onClick:F,children:y?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),y.current,"/",y.total]}):s.jsxs(s.Fragment,{children:[s.jsx(yi,{className:"w-4 h-4"}),"Download",c.size>1?` (${c.size})`:""]})}),s.jsxs(Te,{variant:"secondary",disabled:c.size===0||C.isPending,onClick:H,className:"text-red-400 hover:text-red-300",children:[C.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(rn,{className:"w-4 h-4"}),r("printerFiles.deleteButton"),c.size>1?` (${c.size})`:""]})]})]})]}),p.length>0&&s.jsx(Qn,{title:p.length>1?r("printerFiles.deleteFiles",{count:p.length}):r("fileManager.deleteFile"),message:p.length>1?r("printerFiles.deleteFilesConfirm",{count:p.length}):r("printerFiles.deleteFileConfirm",{name:p[0].split("/").pop()}),confirmText:r("common.delete"),variant:"danger",onConfirm:()=>{C.mutate(p)},onCancel:()=>m([])})]})}const Ffe="embeddedCameraState_",Bz=5,Ife=2e3,Ufe=3e4,zfe=5e3,aT={x:window.innerWidth-420,y:20,width:400,height:300};function Bfe({printerId:t,printerName:e,viewerIndex:n=0,onClose:r}){const i=`${Ffe}${t}`,a=()=>{try{const je=localStorage.getItem(i);if(je){const Be=JSON.parse(je);return{x:Math.min(Math.max(0,Be.x),window.innerWidth-100),y:Math.min(Math.max(0,Be.y),window.innerHeight-100),width:Math.max(200,Math.min(Be.width,window.innerWidth-20)),height:Math.max(150,Math.min(Be.height,window.innerHeight-20))}}}catch{}const ye=n*30;return{...aT,x:Math.max(0,aT.x-ye),y:Math.max(0,aT.y+ye)}},[o,l]=_.useState(a),[c,u]=_.useState(!1),[d,f]=_.useState(!1),[p,m]=_.useState({x:0,y:0}),[x,b]=_.useState(!1),[y,v]=_.useState(!1),[S,M]=_.useState(1),[T,E]=_.useState({x:0,y:0}),[C,k]=_.useState(!1),[R,A]=_.useState({x:0,y:0}),[D,U]=_.useState(null),[F,H]=_.useState(null),[j,$]=_.useState(!1),[K,V]=_.useState(!0),[Q,Z]=_.useState(Date.now()),[ae,B]=_.useState(0),[X,ne]=_.useState(!1),[se,be]=_.useState(0),xe=_.useRef(null),de=_.useRef(null),Pe=_.useRef(null),ie=_.useRef(null),Me=_.useRef(null),{data:Oe}=at({queryKey:["printer",t],queryFn:()=>ue.getPrinter(t),enabled:t>0});_.useEffect(()=>{const ye=setTimeout(()=>{localStorage.setItem(i,JSON.stringify(o))},500);return()=>clearTimeout(ye)},[o,i]);const ge=_.useRef(!1);_.useEffect(()=>{ge.current=!1;const ye=`/api/v1/printers/${t}/camera/stop`,je=()=>{t>0&&!ge.current&&(ge.current=!0,navigator.sendBeacon(ye))},Be=de.current;return()=>{Be&&(Be.src=""),je(),Pe.current&&clearTimeout(Pe.current),ie.current&&clearInterval(ie.current),Me.current&&clearInterval(Me.current)}},[t]),_.useEffect(()=>{if(K){const ye=setTimeout(()=>V(!1),3e3);return()=>clearTimeout(ye)}},[K,Q]);const Ke=_.useCallback(()=>{if(ae>=Bz){ne(!1),$(!0);return}const ye=Math.min(Ife*Math.pow(2,ae),Ufe);ne(!0),be(Math.ceil(ye/1e3)),ie.current=setInterval(()=>{be(je=>je<=1?(ie.current&&clearInterval(ie.current),0):je-1)},1e3),Pe.current=setTimeout(()=>{B(je=>je+1),ne(!1),V(!0),$(!1),de.current&&(de.current.src=""),Z(Date.now())},ye)},[ae]);_.useEffect(()=>{if(K||X||x){Me.current&&(clearInterval(Me.current),Me.current=null);return}return Me.current=setInterval(async()=>{try{const ye=await fetch(`/api/v1/printers/${t}/camera/status`);if(ye.ok){const je=await ye.json();(je.stalled||!je.active&&!j)&&(Me.current&&(clearInterval(Me.current),Me.current=null),V(!1),Ke())}}catch{}},zfe),()=>{Me.current&&(clearInterval(Me.current),Me.current=null)}},[K,j,X,x,t,Ke]),_.useEffect(()=>{const ye=()=>{const je=!!document.fullscreenElement;v(je),je||(M(1),E({x:0,y:0}))};return document.addEventListener("fullscreenchange",ye),()=>document.removeEventListener("fullscreenchange",ye)},[]);const G=()=>{xe.current&&(document.fullscreenElement?document.exitFullscreen():xe.current.requestFullscreen())},Y=()=>{M(ye=>Math.min(ye+.5,4))},ce=()=>{M(ye=>{const je=Math.max(ye-.5,1);return je===1&&E({x:0,y:0}),je})},q=ye=>{ye.preventDefault(),ye.deltaY<0?Y():ce()},te=ye=>{S>1&&(ye.preventDefault(),k(!0),A({x:ye.clientX-T.x,y:ye.clientY-T.y}))},I=_.useCallback(()=>{if(!xe.current||!de.current)return{x:200,y:150};const ye=xe.current.getBoundingClientRect(),je=ye.width*(S-1)/2,Be=ye.height*(S-1)/2;return{x:Math.max(50,je),y:Math.max(50,Be)}},[S]),fe=ye=>{if(C&&S>1){const je=ye.clientX-R.x,Be=ye.clientY-R.y,Se=I();E({x:Math.max(-Se.x,Math.min(Se.x,je)),y:Math.max(-Se.y,Math.min(Se.y,Be))})}},me=()=>{k(!1)},ke=ye=>{if(ye.length<2)return 0;const je=ye[0].clientX-ye[1].clientX,Be=ye[0].clientY-ye[1].clientY;return Math.sqrt(je*je+Be*Be)},z=ye=>ye.length<2?{x:ye[0].clientX,y:ye[0].clientY}:{x:(ye[0].clientX+ye[1].clientX)/2,y:(ye[0].clientY+ye[1].clientY)/2},O=ye=>{ye.touches.length===2?(ye.preventDefault(),U(ke(ye.touches)),H(z(ye.touches))):ye.touches.length===1&&S>1&&(ye.preventDefault(),k(!0),A({x:ye.touches[0].clientX-T.x,y:ye.touches[0].clientY-T.y}))},ee=ye=>{if(ye.touches.length===2&&D!==null){ye.preventDefault();const je=ke(ye.touches),Be=je/D;M(Xe=>{const Ne=Math.max(1,Math.min(4,Xe*Be));return Ne===1&&E({x:0,y:0}),Ne}),U(je);const Se=z(ye.touches);if(F){const Xe=I();E(Ne=>({x:Math.max(-Xe.x,Math.min(Xe.x,Ne.x+(Se.x-F.x))),y:Math.max(-Xe.y,Math.min(Xe.y,Ne.y+(Se.y-F.y)))}))}H(Se)}else if(ye.touches.length===1&&C&&S>1){ye.preventDefault();const je=ye.touches[0].clientX-R.x,Be=ye.touches[0].clientY-R.y,Se=I();E({x:Math.max(-Se.x,Math.min(Se.x,je)),y:Math.max(-Se.y,Math.min(Se.y,Be))})}},le=ye=>{ye.touches.length<2&&(U(null),H(null)),ye.touches.length===0&&k(!1)},_e=()=>{M(1),E({x:0,y:0})},we=()=>{V(!1),ae<Bz?Ke():$(!0)},re=()=>{V(!1),$(!1),B(0),ne(!1),Pe.current&&clearTimeout(Pe.current),ie.current&&clearInterval(ie.current)},Fe=()=>{V(!0),$(!1),B(0),ne(!1),Pe.current&&clearTimeout(Pe.current),ie.current&&clearInterval(ie.current),fetch(`/api/v1/printers/${t}/camera/stop`).catch(()=>{}),de.current&&(de.current.src=""),setTimeout(()=>Z(Date.now()),100)},$e=ye=>{ye.target.closest(".no-drag")||(u(!0),m({x:ye.clientX-o.x,y:ye.clientY-o.y}))},Ve=ye=>{ye.stopPropagation(),f(!0)};_.useEffect(()=>{const ye=Be=>{if(c)l(Se=>({...Se,x:Math.max(0,Math.min(Be.clientX-p.x,window.innerWidth-Se.width)),y:Math.max(0,Math.min(Be.clientY-p.y,window.innerHeight-Se.height))}));else if(d&&xe.current){const Se=xe.current.getBoundingClientRect();l(Xe=>({...Xe,width:Math.max(200,Math.min(Be.clientX-Se.left,window.innerWidth-Xe.x-10)),height:Math.max(150,Math.min(Be.clientY-Se.top,window.innerHeight-Xe.y-10))}))}},je=()=>{u(!1),f(!1)};if(c||d)return document.addEventListener("mousemove",ye),document.addEventListener("mouseup",je),()=>{document.removeEventListener("mousemove",ye),document.removeEventListener("mouseup",je)}},[c,d,p]);const He=`/api/v1/printers/${t}/camera/stream?fps=15&t=${Q}`;return s.jsxs("div",{ref:xe,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:[s.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:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-white truncate",children:[s.jsx(zg,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"truncate",children:Oe?.name||e})]}),s.jsxs("div",{className:"flex items-center gap-1 no-drag",children:[s.jsx("button",{onClick:Fe,disabled:K||X,className:"p-1 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:"Refresh stream",children:s.jsx(Dr,{className:`w-3.5 h-3.5 text-bambu-gray ${K?"animate-spin":""}`})}),s.jsx("button",{onClick:G,className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:y?"Exit fullscreen":"Fullscreen",children:y?s.jsx(_W,{className:"w-3.5 h-3.5 text-bambu-gray"}):s.jsx(Bue,{className:"w-3.5 h-3.5 text-bambu-gray"})}),s.jsx("button",{onClick:()=>b(!x),className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:x?"Expand":"Minimize",children:x?s.jsx(vW,{className:"w-3.5 h-3.5 text-bambu-gray"}):s.jsx(wW,{className:"w-3.5 h-3.5 text-bambu-gray"})}),s.jsx("button",{onClick:r,className:"p-1 hover:bg-red-500/20 rounded",title:"Close",children:s.jsx(Rt,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-red-400"})})]})]}),!x&&s.jsxs("div",{className:"relative w-full bg-black flex items-center justify-center overflow-hidden h-[calc(100%-40px)]",onWheel:q,onMouseMove:fe,onMouseUp:me,onMouseLeave:me,onTouchStart:O,onTouchMove:ee,onTouchEnd:le,style:{touchAction:"none"},children:[K&&!X&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:s.jsx(Dr,{className:"w-6 h-6 text-bambu-gray animate-spin"})}),X&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:s.jsxs("div",{className:"text-center p-2",children:[s.jsx(sm,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Reconnecting in ",se,"s..."]})]})}),j&&!X&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:s.jsxs("div",{className:"text-center p-2",children:[s.jsx(Cn,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Camera unavailable"}),s.jsx("button",{onClick:Fe,className:"px-2 py-1 text-xs bg-bambu-green text-white rounded hover:bg-bambu-green/80",children:"Retry"})]})}),s.jsx("img",{ref:de,src:He,alt:"Camera stream",className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${S}) translate(${T.x/S}px, ${T.y/S}px)`,cursor:S>1?C?"grabbing":"grab":"default"},onError:we,onLoad:re,onMouseDown:te,draggable:!1},Q),s.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:[s.jsx("button",{onClick:ce,disabled:S<=1,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:s.jsx(FR,{className:"w-3.5 h-3.5 text-white"})}),s.jsxs("button",{onClick:_e,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),"%"]}),s.jsx("button",{onClick:Y,disabled:S>=4,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:s.jsx(LR,{className:"w-3.5 h-3.5 text-white"})})]}),!y&&s.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:Ve,title:"Drag to resize",children:s.jsx("svg",{className:"w-6 h-6 text-bambu-gray/70 hover:text-bambu-gray",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M22 22H20V20H22V22ZM22 18H20V16H22V18ZM18 22H16V20H18V22ZM22 14H20V12H22V14ZM18 18H16V16H18V18ZM14 22H12V20H14V22ZM22 10H20V8H22V10ZM18 14H16V12H18V14ZM14 18H12V16H14V18ZM10 22H8V20H10V22Z"})})})]})]})}function $fe({printerId:t,printerName:e,onClose:n}){const{t:r}=$n(),i=an(),[a,o]=_.useState(!0),[l,c]=_.useState(new Set),[u,d]=_.useState(""),[f,p]=_.useState("all"),m=_.useRef(null),{data:x,isLoading:b,refetch:y}=at({queryKey:["mqtt-logs",t],queryFn:()=>ue.getMQTTLogs(t),refetchInterval:1e3}),v=mt({mutationFn:()=>ue.enableMQTTLogging(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}}),S=mt({mutationFn:()=>ue.disableMQTTLogging(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}}),M=mt({mutationFn:()=>ue.clearMQTTLogs(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}});_.useEffect(()=>{const D=U=>{U.key==="Escape"&&n()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[n]),_.useEffect(()=>{a&&m.current&&(m.current.scrollTop=m.current.scrollHeight)},[x?.logs,a]);const T=D=>{c(U=>{const F=new Set(U);return F.has(D)?F.delete(D):F.add(D),F})},E=D=>new Date(D).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),C=(D,U)=>{if(D==null)return"<empty>";const F=typeof D=="string"?JSON.parse(D):D,H=JSON.stringify(F,null,U?2:0);return!U&&H.length>100?H.substring(0,100)+"...":H},k=x?.logging_enabled??!1,R=_.useMemo(()=>x?.logs??[],[x?.logs]),A=_.useMemo(()=>R.filter(D=>{if(f!=="all"&&D.direction!==f)return!1;if(u.trim()){const U=u.toLowerCase(),F=D.topic.toLowerCase().includes(U),j=JSON.stringify(D.payload).toLowerCase().includes(U);return F||j}return!0}),[R,u,f]);return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r("mqttDebug.title")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[k?s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>S.mutate(),disabled:S.isPending,children:[s.jsx(ll,{className:"w-4 h-4"}),r("mqttDebug.stopLogging")]}):s.jsxs(Te,{size:"sm",onClick:()=>v.mutate(),disabled:v.isPending,children:[s.jsx(Is,{className:"w-4 h-4"}),r("mqttDebug.startLogging")]}),s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>M.mutate(),disabled:M.isPending||R.length===0,children:[s.jsx(rn,{className:"w-4 h-4"}),r("mqttDebug.clearLog")]}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>y(),disabled:b,children:s.jsx(Dr,{className:`w-4 h-4 ${b?"animate-spin":""}`})}),s.jsx("div",{className:"flex-1"}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:D=>o(D.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:[A.length,"/",R.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(ba,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:r("mqttDebug.searchPlaceholder"),value:u,onChange:D=>d(D.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"}),u&&s.jsx("button",{onClick:()=>d(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:s.jsx(Rt,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>p("all"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${f==="all"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:r("mqttDebug.all")}),s.jsxs("button",{onClick:()=>p("in"),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${f==="in"?"bg-blue-500 text-white":"text-bambu-gray hover:text-white"}`,children:[s.jsx(G0,{className:"w-3 h-3"}),r("mqttDebug.incoming")]}),s.jsxs("button",{onClick:()=>p("out"),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${f==="out"?"bg-green-500 text-white":"text-bambu-gray hover:text-white"}`,children:[s.jsx(Ig,{className:"w-3 h-3"}),r("mqttDebug.outgoing")]})]})]})]}),s.jsx("div",{ref:m,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:R.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:r("mqttDebug.noMessages")}),!k&&s.jsx("p",{className:"text-sm",children:r("mqttDebug.startLoggingHint")})]}):A.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:r("mqttDebug.noMessagesMatch")}),s.jsx("p",{className:"text-sm",children:r("mqttDebug.adjustFilterHint")})]}):s.jsx("div",{className:"space-y-1",children:A.map((D,U)=>{const F=l.has(U),H=D.direction==="in";return s.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${F?"bg-bambu-dark-secondary":""}`,onClick:()=>T(U),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-bambu-gray shrink-0",children:E(D.timestamp)}),s.jsx("span",{className:`shrink-0 ${H?"text-blue-400":"text-green-400"}`,title:r(H?"mqttDebug.incoming":"mqttDebug.outgoing"),children:H?s.jsx(G0,{className:"w-3 h-3"}):s.jsx(Ig,{className:"w-3 h-3"})}),s.jsx("span",{className:"text-purple-400 shrink-0",children:D.topic})]}),F?s.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:C(D.payload,!0)}):s.jsx("pre",{className:"mt-1 text-white/80 truncate",children:C(D.payload,!1)})]},U)})})}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-sm text-bambu-gray",children:k?s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),r("mqttDebug.loggingActive")]}):s.jsx("span",{children:r("mqttDebug.loggingStopped")})}),s.jsx(Te,{variant:"secondary",onClick:n,children:r("common.close")})]})]})})}const vP={"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 Hfe(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:Cn};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:Cn};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:$i};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:Zo}}}function wP(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 Vfe(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=wP(e.attr,n);return vP[r]!==void 0})}function Gfe(){return"https://wiki.bambulab.com/en/hms/home"}function qfe({printerName:t,errors:e,onClose:n}){const{t:r}=$n();console.log("HMSErrorModal errors:",JSON.stringify(e,null,2));const i=e.filter(a=>{const o=parseInt(a.code.replace("0x",""),16)||0,l=wP(a.attr,o);return vP[l]!==void 0});return _.useEffect(()=>{const a=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[n]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Cn,{className:"w-5 h-5 text-orange-400"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:r("hmsErrors.title",{name:t})})]}),s.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:i.length===0?s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx($i,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{children:r("hmsErrors.noErrors")})]}):s.jsx("div",{className:"space-y-3",children:i.map((a,o)=>{const{label:l,color:c,bgColor:u,Icon:d}=Hfe(a.severity),f=parseInt(a.code.replace("0x",""),16)||0,p=wP(a.attr,f),m=vP[p],x=Gfe(),b=p.replace("_","-");return s.jsx("div",{className:`p-4 rounded-lg ${u} border border-white/10`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(d,{className:`w-5 h-5 ${c} flex-shrink-0 mt-0.5`}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsxs("span",{className:`font-mono text-sm ${c}`,children:["[",b,"]"]}),s.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${u} ${c}`,children:l})]}),s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:m}),s.jsxs("a",{href:x,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[s.jsx(Kr,{className:"w-3 h-3"}),r("hmsErrors.viewOnWiki")]})]})]})},`${a.code}-${o}`)})})}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsx("p",{className:"text-xs text-bambu-gray",children:r("hmsErrors.clearInstructions")})})]})})}function Wfe(t){if(!t)return"ASAP";const e=Ii(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 Kfe({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:s.jsx(Ds,{to:"/queue",className:"block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx(si,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Next in queue"}),s.jsx("p",{className:"text-sm text-white truncate",children:n?.archive_name||`Archive #${n?.archive_id}`})]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[s.jsx(Jn,{className:"w-3 h-3"}),Wfe(n?.scheduled_time||null)]}),r>1&&s.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",r-1]}),s.jsx(gs,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function LW(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=LW(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function er(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=LW(t))&&(r&&(r+=" "),r+=e);return r}var Xfe=["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 UR(t){if(typeof t!="string")return!1;var e=Xfe;return e.includes(t)}var Yfe=["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"],Qfe=new Set(Yfe);function FW(t){return typeof t!="string"?!1:Qfe.has(t)}function IW(t){return typeof t=="string"&&t.startsWith("data-")}function xs(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(FW(n)||IW(n))&&(e[n]=t[n]);return e}function lm(t){if(t==null)return null;if(_.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return xs(e)}return typeof t=="object"&&!Array.isArray(t)?xs(t):null}function za(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(FW(n)||IW(n)||UR(n))&&(e[n]=t[n]);return e}function Zfe(t){return t==null?null:_.isValidElement(t)?za(t.props):typeof t=="object"&&!Array.isArray(t)?za(t):null}var Jfe=["children","width","height","viewBox","className","style","title","desc"];function _P(){return _P=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},_P.apply(null,arguments)}function eme(t,e){if(t==null)return{};var n,r,i=tme(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function 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 zR=_.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:a,className:o,style:l,title:c,desc:u}=t,d=eme(t,Jfe),f=a||{width:r,height:i,x:0,y:0},p=er("recharts-surface",o);return _.createElement("svg",_P({},za(d),{className:p,width:r,height:i,style:l,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:e}),_.createElement("title",null,c),_.createElement("desc",null,u),n)}),nme=["children","className"];function SP(){return SP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},SP.apply(null,arguments)}function rme(t,e){if(t==null)return{};var n,r,i=ime(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function 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 oi=_.forwardRef((t,e)=>{var{children:n,className:r}=t,i=rme(t,nme),a=er("recharts-layer",r);return _.createElement("g",SP({className:a},za(i),{ref:e}),n)}),UW=_.createContext(null),ame=()=>_.useContext(UW);function Ir(t){return function(){return t}}const zW=Math.cos,X1=Math.sin,Bl=Math.sqrt,Y1=Math.PI,v2=2*Y1,NP=Math.PI,MP=2*NP,vf=1e-6,sme=MP-vf;function BW(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 BW;const n=10**e;return function(r){this._+=r[0];for(let i=1,a=r.length;i<a;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class lme{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?BW: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,a,o){this._append`C${+e},${+n},${+r},${+i},${this._x1=+a},${this._y1=+o}`}arcTo(e,n,r,i,a){if(e=+e,n=+n,r=+r,i=+i,a=+a,a<0)throw new Error(`negative radius: ${a}`);let o=this._x1,l=this._y1,c=r-e,u=i-n,d=o-e,f=l-n,p=d*d+f*f;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(p>vf)if(!(Math.abs(f*c-u*d)>vf)||!a)this._append`L${this._x1=e},${this._y1=n}`;else{let m=r-o,x=i-l,b=c*c+u*u,y=m*m+x*x,v=Math.sqrt(b),S=Math.sqrt(p),M=a*Math.tan((NP-Math.acos((b+p-y)/(2*v*S)))/2),T=M/S,E=M/v;Math.abs(T-1)>vf&&this._append`L${e+T*d},${n+T*f}`,this._append`A${a},${a},0,0,${+(f*m>d*x)},${this._x1=e+E*c},${this._y1=n+E*u}`}}arc(e,n,r,i,a,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,p=o?i-a:a-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>vf||Math.abs(this._y1-d)>vf)&&this._append`L${u},${d}`,r&&(p<0&&(p=p%MP+MP),p>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}`:p>vf&&this._append`A${r},${r},0,${+(p>=NP)},${f},${this._x1=e+r*Math.cos(a)},${this._y1=n+r*Math.sin(a)}`)}rect(e,n,r,i){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function BR(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 $R(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function $W(t){this._context=t}$W.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 w2(t){return new $W(t)}function HW(t){return t[0]}function VW(t){return t[1]}function GW(t,e){var n=Ir(!0),r=null,i=w2,a=null,o=BR(l);t=typeof t=="function"?t:t===void 0?HW:Ir(t),e=typeof e=="function"?e:e===void 0?VW:Ir(e);function l(c){var u,d=(c=$R(c)).length,f,p=!1,m;for(r==null&&(a=i(m=o())),u=0;u<=d;++u)!(u<d&&n(f=c[u],u,c))===p&&((p=!p)?a.lineStart():a.lineEnd()),p&&a.point(+t(f,u,c),+e(f,u,c));if(m)return a=null,m+""||null}return l.x=function(c){return arguments.length?(t=typeof c=="function"?c:Ir(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:Ir(+c),l):e},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:Ir(!!c),l):n},l.curve=function(c){return arguments.length?(i=c,r!=null&&(a=i(r)),l):i},l.context=function(c){return arguments.length?(c==null?r=a=null:a=i(r=c),l):r},l}function Rw(t,e,n){var r=null,i=Ir(!0),a=null,o=w2,l=null,c=BR(u);t=typeof t=="function"?t:t===void 0?HW:Ir(+t),e=typeof e=="function"?e:Ir(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?VW:Ir(+n);function u(f){var p,m,x,b=(f=$R(f)).length,y,v=!1,S,M=new Array(b),T=new Array(b);for(a==null&&(l=o(S=c())),p=0;p<=b;++p){if(!(p<b&&i(y=f[p],p,f))===v)if(v=!v)m=p,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),x=p-1;x>=m;--x)l.point(M[x],T[x]);l.lineEnd(),l.areaEnd()}v&&(M[p]=+t(y,p,f),T[p]=+e(y,p,f),l.point(r?+r(y,p,f):M[p],n?+n(y,p,f):T[p]))}if(S)return l=null,S+""||null}function d(){return GW().defined(i).curve(o).context(a)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:Ir(+f),r=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Ir(+f),u):t},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Ir(+f),u):r},u.y=function(f){return arguments.length?(e=typeof f=="function"?f:Ir(+f),n=null,u):e},u.y0=function(f){return arguments.length?(e=typeof f=="function"?f:Ir(+f),u):e},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Ir(+f),u):n},u.lineX0=u.lineY0=function(){return d().x(t).y(e)},u.lineY1=function(){return d().x(t).y(n)},u.lineX1=function(){return d().x(r).y(e)},u.defined=function(f){return arguments.length?(i=typeof f=="function"?f:Ir(!!f),u):i},u.curve=function(f){return arguments.length?(o=f,a!=null&&(l=o(a)),u):o},u.context=function(f){return arguments.length?(f==null?a=l=null:l=o(a=f),u):a},u}class qW{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 qW(t,!0)}function ume(t){return new qW(t,!1)}const HR={draw(t,e){const n=Bl(e/Y1);t.moveTo(n,0),t.arc(0,0,n,0,v2)}},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()}},WW=Bl(1/3),hme=WW*2,fme={draw(t,e){const n=Bl(e/hme),r=n*WW;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,KW=X1(Y1/10)/X1(7*Y1/10),gme=X1(v2/10)*KW,xme=-zW(v2/10)*KW,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 a=1;a<5;++a){const o=v2*a/5,l=zW(o),c=X1(o);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},sT=Bl(3),yme={draw(t,e){const n=-Bl(e/(sT*3));t.moveTo(0,n*2),t.lineTo(-sT*n,-n),t.lineTo(sT*n,-n),t.closePath()}},Ro=-.5,Oo=Bl(3)/2,EP=1/Bl(12),vme=(EP/2+1)*3,wme={draw(t,e){const n=Bl(e/vme),r=n/2,i=n*EP,a=r,o=n*EP+n,l=-a,c=o;t.moveTo(r,i),t.lineTo(a,o),t.lineTo(l,c),t.lineTo(Ro*r-Oo*i,Oo*r+Ro*i),t.lineTo(Ro*a-Oo*o,Oo*a+Ro*o),t.lineTo(Ro*l-Oo*c,Oo*l+Ro*c),t.lineTo(Ro*r+Oo*i,Ro*i-Oo*r),t.lineTo(Ro*a+Oo*o,Ro*o-Oo*a),t.lineTo(Ro*l+Oo*c,Ro*c-Oo*l),t.closePath()}};function _me(t,e){let n=null,r=BR(i);t=typeof t=="function"?t:Ir(t||HR),e=typeof e=="function"?e:Ir(e===void 0?64:+e);function i(){let a;if(n||(n=a=r()),t.apply(this,arguments).draw(n,+e.apply(this,arguments)),a)return n=null,a+""||null}return i.type=function(a){return arguments.length?(t=typeof a=="function"?a:Ir(a),i):t},i.size=function(a){return arguments.length?(e=typeof a=="function"?a:Ir(+a),i):e},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function Q1(){}function Z1(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 XW(t){this._context=t}XW.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:Z1(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:Z1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Sme(t){return new XW(t)}function YW(t){this._context=t}YW.prototype={areaStart:Q1,areaEnd:Q1,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:Z1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Nme(t){return new YW(t)}function QW(t){this._context=t}QW.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:Z1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Mme(t){return new QW(t)}function ZW(t){this._context=t}ZW.prototype={areaStart:Q1,areaEnd:Q1,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 ZW(t)}function $z(t){return t<0?-1:1}function Hz(t,e,n){var r=t._x1-t._x0,i=e-t._x1,a=(t._y1-t._y0)/(r||i<0&&-0),o=(n-t._y1)/(i||r<0&&-0),l=(a*i+o*r)/(r+i);return($z(a)+$z(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(l))||0}function Vz(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function oT(t,e,n){var r=t._x0,i=t._y0,a=t._x1,o=t._y1,l=(a-r)/3;t._context.bezierCurveTo(r+l,i+l*e,a-l,o-l*n,a,o)}function J1(t){this._context=t}J1.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:oT(this,this._t0,Vz(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,oT(this,Vz(this,n=Hz(this,t,e)),n);break;default:oT(this,this._t0,n=Hz(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function JW(t){this._context=new eK(t)}(JW.prototype=Object.create(J1.prototype)).point=function(t,e){J1.prototype.point.call(this,e,t)};function eK(t){this._context=t}eK.prototype={moveTo:function(t,e){this._context.moveTo(e,t)},closePath:function(){this._context.closePath()},lineTo:function(t,e){this._context.lineTo(e,t)},bezierCurveTo:function(t,e,n,r,i,a){this._context.bezierCurveTo(e,t,r,n,a,i)}};function kme(t){return new J1(t)}function Tme(t){return new JW(t)}function tK(t){this._context=t}tK.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=Gz(t),i=Gz(e),a=0,o=1;o<n;++a,++o)this._context.bezierCurveTo(r[0][a],i[0][a],r[1][a],i[1][a],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 Gz(t){var e,n=t.length-1,r,i=new Array(n),a=new Array(n),o=new Array(n);for(i[0]=0,a[0]=2,o[0]=t[0]+2*t[1],e=1;e<n-1;++e)i[e]=1,a[e]=4,o[e]=4*t[e]+2*t[e+1];for(i[n-1]=2,a[n-1]=7,o[n-1]=8*t[n-1]+t[n],e=1;e<n;++e)r=i[e]/a[e-1],a[e]-=r,o[e]-=r*o[e-1];for(i[n-1]=o[n-1]/a[n-1],e=n-2;e>=0;--e)i[e]=(o[e]-i[e+1])/a[e];for(a[n-1]=(t[n]+i[n-1])/2,e=0;e<n-1;++e)a[e]=2*t[e+1]-i[e+1];return[i,a]}function Ame(t){return new tK(t)}function _2(t,e){this._context=t,this._t=e}_2.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 Cme(t){return new _2(t,.5)}function jme(t){return new _2(t,0)}function Pme(t){return new _2(t,1)}function Hg(t,e){if((o=t.length)>1)for(var n=1,r,i,a=t[e[0]],o,l=a.length;n<o;++n)for(i=a,a=t[e[n]],r=0;r<l;++r)a[r][1]+=a[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function kP(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function Dme(t,e){return t[e]}function Rme(t){const e=[];return e.key=t,e}function Ome(){var t=Ir([]),e=kP,n=Hg,r=Dme;function i(a){var o=Array.from(t.apply(this,arguments),Rme),l,c=o.length,u=-1,d;for(const f of a)for(l=0,++u;l<c;++l)(o[l][u]=[0,+r(f,o[l].key,u,a)]).data=f;for(l=0,d=$R(e(o));l<c;++l)o[d[l]].index=l;return n(o,d),o}return i.keys=function(a){return arguments.length?(t=typeof a=="function"?a:Ir(Array.from(a)),i):t},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:Ir(+a),i):r},i.order=function(a){return arguments.length?(e=a==null?kP:typeof a=="function"?a:Ir(Array.from(a)),i):e},i.offset=function(a){return arguments.length?(n=a??Hg,i):n},i}function Lme(t,e){if((r=t.length)>0){for(var n,r,i=0,a=t[0].length,o;i<a;++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}Hg(t,e)}}function Fme(t,e){if((i=t.length)>0){for(var n=0,r=t[e[0]],i,a=r.length;n<a;++n){for(var o=0,l=0;o<i;++o)l+=t[o][n][1]||0;r[n][1]+=r[n][0]=-l/2}Hg(t,e)}}function Ime(t,e){if(!(!((o=t.length)>0)||!((a=(i=t[e[0]]).length)>0))){for(var n=0,r=1,i,a,o;r<a;++r){for(var l=0,c=0,u=0;l<o;++l){for(var d=t[e[l]],f=d[r][1]||0,p=d[r-1][1]||0,m=(f-p)/2,x=0;x<l;++x){var b=t[e[x]],y=b[r][1]||0,v=b[r-1][1]||0;m+=y-v}c+=f,u+=m*f}i[r-1][1]+=i[r-1][0]=n,c&&(n-=u/c)}i[r-1][1]+=i[r-1][0]=n,Hg(t,e)}}var lT={},cT={},qz;function Ume(){return qz||(qz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(cT)),cT}var uT={},Wz;function nK(){return Wz||(Wz=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})(uT)),uT}var dT={},Kz;function VR(){return Kz||(Kz=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})(dT)),dT}var hT={},fT={},Xz;function zme(){return Xz||(Xz=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})(fT)),fT}var Yz;function GR(){return Yz||(Yz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=zme(),n=VR();function r(i){if(Array.isArray(i))return i.map(n.toKey);if(typeof i=="symbol")return[i];i=e.toString(i);const a=[],o=i.length;if(o===0)return a;let l=0,c="",u="",d=!1;for(i.charCodeAt(0)===46&&(a.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,a.push(c),c=""):c+=f:f==="["?(d=!0,c&&(a.push(c),c="")):f==="."?c&&(a.push(c),c=""):c+=f,l++}return c&&a.push(c),a}t.toPath=r})(hT)),hT}var Qz;function qR(){return Qz||(Qz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Ume(),n=nK(),r=VR(),i=GR();function a(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)?a(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=a})(lT)),lT}var mT,Zz;function Bme(){return Zz||(Zz=1,mT=qR().get),mT}var $me=Bme();const cm=hl($me);var ya=t=>t===0?0:t>0?1:-1,Hs=t=>typeof t=="number"&&t!=+t,Lu=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,zt=t=>(typeof t=="number"||t instanceof Number)&&!Hs(t),cl=t=>zt(t)||typeof t=="string",Hme=0,X0=t=>{var e=++Hme;return"".concat(t||"").concat(e)},es=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(!zt(e)&&typeof e!="string")return r;var a;if(Lu(e)){if(n==null)return r;var o=e.indexOf("%");a=n*parseFloat(e.slice(0,o))/100}else a=+e;return Hs(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},rK=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 dr(t,e,n){return zt(t)&&zt(e)?t+n*(e-t):e}function iK(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):cm(r,e))===n)}var Xr=t=>t===null||typeof t>"u",Iy=t=>Xr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function Vme(t){return t!=null}function Uy(){}var Gme=["type","size","sizeType"];function TP(){return TP=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},TP.apply(null,arguments)}function Jz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function eB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Jz(Object(n),!0).forEach(function(r){qme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Jz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function 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 aK={symbolCircle:HR,symbolCross:dme,symbolDiamond:fme,symbolSquare:mme,symbolStar:bme,symbolTriangle:yme,symbolWye:wme},Qme=Math.PI/180,Zme=t=>{var e="symbol".concat(Iy(t));return aK[e]||HR},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}},epe=(t,e)=>{aK["symbol".concat(Iy(t))]=e},WR=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=Xme(t,Gme),a=eB(eB({},i),{},{type:e,size:n,sizeType:r}),o="circle";typeof e=="string"&&(o=e);var l=()=>{var p=Zme(o),m=_me().type(p).size(Jme(n,r,o)),x=m();if(x!==null)return x},{className:c,cx:u,cy:d}=a,f=za(a);return zt(u)&&zt(d)&&zt(n)?_.createElement("path",TP({},f,{className:er("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:l()})):null};WR.registerSymbol=epe;var sK=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,KR=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(_.isValidElement(t)&&(n=t.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{UR(i)&&(r[i]=(a=>n[i](n,a)))}),r},tpe=(t,e,n)=>r=>(t(e,n,r),null),zy=(t,e,n)=>{if(t===null||typeof t!="object"&&typeof t!="function")return null;var r=null;return Object.keys(t).forEach(i=>{var a=t[i];UR(i)&&typeof a=="function"&&(r||(r={}),r[i]=tpe(a,e,n))}),r};function tB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function npe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?tB(Object(n),!0).forEach(function(r){rpe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):tB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function rpe(t,e,n){return(e=ipe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ipe(t){var e=ape(t,"string");return typeof e=="symbol"?e:e+""}function ape(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function li(t,e){var n=npe({},t),r=e,i=Object.keys(e),a=i.reduce((o,l)=>(o[l]===void 0&&r[l]!==void 0&&(o[l]=r[l]),o),n);return a}function eS(){return eS=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},eS.apply(null,arguments)}function nB(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 spe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?nB(Object(n),!0).forEach(function(r){ope(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):nB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ope(t,e,n){return(e=lpe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lpe(t){var e=cpe(t,"string");return typeof e=="symbol"?e:e+""}function cpe(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,upe={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function dpe(t){var{data:e,iconType:n,inactiveColor:r}=t,i=zo/2,a=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 _.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 _.createElement("path",{strokeWidth:4,fill:"none",stroke:l,d:"M0,".concat(i,"h").concat(o,`
  11. A`).concat(a,",").concat(a,",0,1,1,").concat(2*o,",").concat(i,`
  12. H`).concat(zo,"M").concat(2*o,",").concat(i,`
  13. A`).concat(a,",").concat(a,",0,1,1,").concat(o,",").concat(i),className:"recharts-legend-icon"});if(c==="rect")return _.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(_.isValidElement(e.legendIcon)){var d=spe({},e);return delete d.legendIcon,_.cloneElement(e.legendIcon,d)}return _.createElement(WR,{fill:l,cx:i,cy:i,size:zo,sizeType:"diameter",type:c})}function hpe(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:a,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 p=d.formatter||i,m=er({"recharts-legend-item":!0,["legend-item-".concat(f)]:!0,inactive:d.inactive});if(d.type==="none")return null;var x=d.inactive?a:d.color,b=p?p(d.value,d,f):d.value;return _.createElement("li",eS({className:m,style:c,key:"legend-item-".concat(f)},zy(t,d,f)),_.createElement(zR,{width:n,height:n,viewBox:l,style:u,"aria-label":"".concat(b," legend icon")},_.createElement(dpe,{data:d,iconType:o,inactiveColor:a})),_.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},b))})}var fpe=t=>{var e=li(t,upe),{payload:n,layout:r,align:i}=e;if(!n||!n.length)return null;var a={padding:0,margin:0,textAlign:r==="horizontal"?i:"left"};return _.createElement("ul",{className:"recharts-default-legend",style:a},_.createElement(hpe,eS({},e,{payload:n})))},pT={},gT={},rB;function mpe(){return rB||(rB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){const i=new Map;for(let a=0;a<n.length;a++){const o=n[a],l=r(o);i.has(l)||i.set(l,o)}return Array.from(i.values())}t.uniqBy=e})(gT)),gT}var xT={},iB;function oK(){return iB||(iB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(xT)),xT}var bT={},yT={},vT={},aB;function ppe(){return aB||(aB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(vT)),vT}var sB;function XR(){return sB||(sB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ppe();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(yT)),yT}var wT={},oB;function gpe(){return oB||(oB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(wT)),wT}var lB;function xpe(){return lB||(lB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=XR(),n=gpe();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(bT)),bT}var _T={},ST={},cB;function bpe(){return cB||(cB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=qR();function n(r){return function(i){return e.get(i,r)}}t.property=n})(ST)),ST}var NT={},MT={},ET={},kT={},uB;function lK(){return uB||(uB=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})(kT)),kT}var TT={},dB;function cK(){return dB||(dB=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})(TT)),TT}var AT={},hB;function uK(){return hB||(hB=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})(AT)),AT}var fB;function ype(){return fB||(fB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lK(),n=cK(),r=uK();function i(d,f,p){return typeof p!="function"?i(d,f,()=>{}):a(d,f,function m(x,b,y,v,S,M){const T=p(x,b,y,v,S,M);return T!==void 0?!!T:a(x,b,m,M)},new Map)}function a(d,f,p,m){if(f===d)return!0;switch(typeof f){case"object":return o(d,f,p,m);case"function":return Object.keys(f).length>0?a(d,{...f},p,m):r.eq(d,f);default:return e.isObject(d)?typeof f=="string"?f==="":!0:r.eq(d,f)}}function o(d,f,p,m){if(f==null)return!0;if(Array.isArray(f))return c(d,f,p,m);if(f instanceof Map)return l(d,f,p,m);if(f instanceof Set)return u(d,f,p,m);const x=Object.keys(f);if(d==null)return x.length===0;if(x.length===0)return!0;if(m?.has(f))return m.get(f)===d;m?.set(f,d);try{for(let 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||!p(d[y],f[y],y,d,f,m))return!1}return!0}finally{m?.delete(f)}}function l(d,f,p,m){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(p(y,b,x,d,f,m)===!1)return!1}return!0}function c(d,f,p,m){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 M=d[S];let T=!1;if(p(M,y,b,d,f,m)&&(T=!0),T){x.add(S),v=!0;break}}if(!v)return!1}return!0}function u(d,f,p,m){return f.size===0?!0:d instanceof Set?c([...d],[...f],p,m):!1}t.isMatchWith=i,t.isSetMatch=u})(ET)),ET}var mB;function dK(){return mB||(mB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ype();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(MT)),MT}var CT={},jT={},PT={},pB;function vpe(){return pB||(pB=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})(PT)),PT}var DT={},gB;function hK(){return gB||(gB=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})(DT)),DT}var RT={},xB;function fK(){return xB||(xB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e="[object RegExp]",n="[object String]",r="[object Number]",i="[object Boolean]",a="[object Arguments]",o="[object Symbol]",l="[object Date]",c="[object Map]",u="[object Set]",d="[object Array]",f="[object Function]",p="[object ArrayBuffer]",m="[object Object]",x="[object Error]",b="[object DataView]",y="[object Uint8Array]",v="[object Uint8ClampedArray]",S="[object Uint16Array]",M="[object Uint32Array]",T="[object BigUint64Array]",E="[object Int8Array]",C="[object Int16Array]",k="[object Int32Array]",R="[object BigInt64Array]",A="[object Float32Array]",D="[object Float64Array]";t.argumentsTag=a,t.arrayBufferTag=p,t.arrayTag=d,t.bigInt64ArrayTag=R,t.bigUint64ArrayTag=T,t.booleanTag=i,t.dataViewTag=b,t.dateTag=l,t.errorTag=x,t.float32ArrayTag=A,t.float64ArrayTag=D,t.functionTag=f,t.int16ArrayTag=C,t.int32ArrayTag=k,t.int8ArrayTag=E,t.mapTag=c,t.numberTag=r,t.objectTag=m,t.regexpTag=e,t.setTag=u,t.stringTag=n,t.symbolTag=o,t.uint16ArrayTag=S,t.uint32ArrayTag=M,t.uint8ArrayTag=y,t.uint8ClampedArrayTag=v})(RT)),RT}var OT={},bB;function wpe(){return bB||(bB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(OT)),OT}var yB;function mK(){return yB||(yB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=vpe(),n=hK(),r=fK(),i=cK(),a=wpe();function o(d,f){return l(d,void 0,d,new Map,f)}function l(d,f,p,m=new Map,x=void 0){const b=x?.(d,f,p,m);if(b!==void 0)return b;if(i.isPrimitive(d))return d;if(m.has(d))return m.get(d);if(Array.isArray(d)){const y=new Array(d.length);m.set(d,y);for(let v=0;v<d.length;v++)y[v]=l(d[v],v,p,m,x);return Object.hasOwn(d,"index")&&(y.index=d.index),Object.hasOwn(d,"input")&&(y.input=d.input),y}if(d instanceof Date)return new Date(d.getTime());if(d instanceof RegExp){const y=new RegExp(d.source,d.flags);return y.lastIndex=d.lastIndex,y}if(d instanceof Map){const y=new Map;m.set(d,y);for(const[v,S]of d)y.set(v,l(S,v,p,m,x));return y}if(d instanceof Set){const y=new Set;m.set(d,y);for(const v of d)y.add(l(v,void 0,p,m,x));return y}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(a.isTypedArray(d)){const y=new(Object.getPrototypeOf(d)).constructor(d.length);m.set(d,y);for(let v=0;v<d.length;v++)y[v]=l(d[v],v,p,m,x);return y}if(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer)return d.slice(0);if(d instanceof DataView){const y=new DataView(d.buffer.slice(0),d.byteOffset,d.byteLength);return m.set(d,y),c(y,d,p,m,x),y}if(typeof File<"u"&&d instanceof File){const y=new File([d],d.name,{type:d.type});return m.set(d,y),c(y,d,p,m,x),y}if(typeof Blob<"u"&&d instanceof Blob){const y=new Blob([d],{type:d.type});return m.set(d,y),c(y,d,p,m,x),y}if(d instanceof Error){const y=new d.constructor;return m.set(d,y),y.message=d.message,y.name=d.name,y.stack=d.stack,y.cause=d.cause,c(y,d,p,m,x),y}if(d instanceof Boolean){const y=new Boolean(d.valueOf());return m.set(d,y),c(y,d,p,m,x),y}if(d instanceof Number){const y=new Number(d.valueOf());return m.set(d,y),c(y,d,p,m,x),y}if(d instanceof String){const y=new String(d.valueOf());return m.set(d,y),c(y,d,p,m,x),y}if(typeof d=="object"&&u(d)){const y=Object.create(Object.getPrototypeOf(d));return m.set(d,y),c(y,d,p,m,x),y}return d}function c(d,f,p=d,m,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,p,m,x))}}function u(d){switch(n.getTag(d)){case r.argumentsTag:case r.arrayTag:case r.arrayBufferTag:case r.dataViewTag:case r.booleanTag:case r.dateTag:case r.float32ArrayTag:case r.float64ArrayTag:case r.int8ArrayTag:case r.int16ArrayTag:case r.int32ArrayTag:case r.mapTag:case r.numberTag:case r.objectTag:case r.regexpTag:case r.setTag:case r.stringTag:case r.symbolTag:case r.uint8ArrayTag:case r.uint8ClampedArrayTag:case r.uint16ArrayTag:case r.uint32ArrayTag:return!0;default:return!1}}t.cloneDeepWith=o,t.cloneDeepWithImpl=l,t.copyProperties=c})(jT)),jT}var vB;function _pe(){return vB||(vB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=mK();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(CT)),CT}var wB;function Spe(){return wB||(wB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=dK(),n=_pe();function r(i){return i=n.cloneDeep(i),a=>e.isMatch(a,i)}t.matches=r})(NT)),NT}var LT={},FT={},IT={},_B;function Npe(){return _B||(_B=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=mK(),n=fK();function r(i,a){return e.cloneDeepWith(i,(o,l,c,u)=>{const d=a?.(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})(IT)),IT}var SB;function Mpe(){return SB||(SB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Npe();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(FT)),FT}var UT={},zT={},NB;function pK(){return NB||(NB=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})(zT)),zT}var BT={},MB;function Epe(){return MB||(MB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=hK();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(BT)),BT}var EB;function kpe(){return EB||(EB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=nK(),n=pK(),r=Epe(),i=GR();function a(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=a})(UT)),UT}var kB;function Tpe(){return kB||(kB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=dK(),n=VR(),r=Mpe(),i=qR(),a=kpe();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?a.has(u,l):c===void 0?d===void 0:e.isMatch(d,c)}}t.matchesProperty=o})(LT)),LT}var TB;function Ape(){return TB||(TB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oK(),n=bpe(),r=Spe(),i=Tpe();function a(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=a})(_T)),_T}var AB;function Cpe(){return AB||(AB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=mpe(),n=oK(),r=xpe(),i=Ape();function a(o,l=n.identity){return r.isArrayLikeObject(o)?e.uniqBy(Array.from(o),i.iteratee(l)):[]}t.uniqBy=a})(pT)),pT}var $T,CB;function jpe(){return CB||(CB=1,$T=Cpe().uniqBy),$T}var Ppe=jpe();const jB=hl(Ppe);function gK(t,e,n){return e===!0?jB(t,n):typeof e=="function"?jB(t,e):t}var HT={exports:{}},VT={};var PB;function Dpe(){if(PB)return VT;PB=1;var t=px(),e=Eq();function n(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,a=t.useRef,o=t.useEffect,l=t.useMemo,c=t.useDebugValue;return VT.useSyncExternalStoreWithSelector=function(u,d,f,p,m){var x=a(null);if(x.current===null){var b={hasValue:!1,value:null};x.current=b}else b=x.current;x=l(function(){function v(C){if(!S){if(S=!0,M=C,C=p(C),m!==void 0&&b.hasValue){var k=b.value;if(m(k,C))return T=k}return T=C}if(k=T,r(M,C))return k;var R=p(C);return m!==void 0&&m(k,R)?(M=C,k):(M=C,T=R)}var S=!1,M,T,E=f===void 0?null:f;return[function(){return v(d())},E===null?void 0:function(){return v(E())}]},[d,f,p,m]);var y=i(u,x[0],x[1]);return o(function(){b.hasValue=!0,b.value=y},[y]),c(y),y},VT}var DB;function Rpe(){return DB||(DB=1,HT.exports=Dpe()),HT.exports}var xK=Rpe(),YR=_.createContext(null),Ope=t=>t,Lr=()=>{var t=_.useContext(YR);return t?t.store.dispatch:Ope},x1=()=>{},Lpe=()=>x1,Fpe=(t,e)=>t===e;function It(t){var e=_.useContext(YR);return xK.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:Lpe,e?e.store.getState:x1,e?e.store.getState:x1,e?t:x1,Fpe)}function Ipe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function Upe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function zpe(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 RB=t=>Array.isArray(t)?t:[t];function Bpe(t){const e=Array.isArray(t[0])?t[0]:t;return zpe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function $pe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var Hpe=class{constructor(t){this.value=t}deref(){return this.value}},Vpe=typeof WeakRef<"u"?WeakRef:Hpe,Gpe=0,OB=1;function Ow(){return{s:Gpe,v:void 0,o:null,p:null}}function bK(t,e={}){let n=Ow();const{resultEqualityCheck:r}=e;let i,a=0;function o(){let l=n;const{length:c}=arguments;for(let f=0,p=c;f<p;f++){const m=arguments[f];if(typeof m=="function"||typeof m=="object"&&m!==null){let x=l.o;x===null&&(l.o=x=new WeakMap);const b=x.get(m);b===void 0?(l=Ow(),x.set(m,l)):l=b}else{let x=l.p;x===null&&(l.p=x=new Map);const b=x.get(m);b===void 0?(l=Ow(),x.set(m,l)):l=b}}const u=l;let d;if(l.s===OB)d=l.v;else if(d=t.apply(null,arguments),a++,r){const f=i?.deref?.()??i;f!=null&&r(f,d)&&(d=f,a!==0&&a--),i=typeof d=="object"&&d!==null||typeof d=="function"?new Vpe(d):d}return u.s=OB,u.v=d,d}return o.clearCache=()=>{n=Ow(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function qpe(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,r=(...i)=>{let a=0,o=0,l,c={},u=i.pop();typeof u=="object"&&(c=u,u=i.pop()),Ipe(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:f,memoizeOptions:p=[],argsMemoize:m=bK,argsMemoizeOptions:x=[]}=d,b=RB(p),y=RB(x),v=Bpe(i),S=f(function(){return a++,u.apply(null,arguments)},...b),M=m(function(){o++;const E=$pe(v,arguments);return l=S.apply(null,E),l},...y);return Object.assign(M,{resultFunc:u,memoizedResultFunc:S,dependencies:v,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>l,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:f,argsMemoize:m})};return Object.assign(r,{withTypes:()=>r}),r}var nt=qpe(bK),Wpe=Object.assign((t,e=nt)=>{Upe(t,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof t}`);const n=Object.keys(t),r=n.map(a=>t[a]);return e(r,(...a)=>a.reduce((o,l,c)=>(o[n[c]]=l,o),{}))},{withTypes:()=>Wpe}),GT={},qT={},WT={},LB;function Kpe(){return LB||(LB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(r){return typeof r=="symbol"?1:r===null?2:r===void 0?3:r!==r?4:0}const n=(r,i,a)=>{if(r!==i){const o=e(r),l=e(i);if(o===l&&o===0){if(r<i)return a==="desc"?1:-1;if(r>i)return a==="desc"?-1:1}return a==="desc"?l-o:o-l}return 0};t.compareValues=n})(WT)),WT}var KT={},XT={},FB;function yK(){return FB||(FB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(XT)),XT}var IB;function Xpe(){return IB||(IB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=yK(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(a,o){return Array.isArray(a)?!1:typeof a=="number"||typeof a=="boolean"||a==null||e.isSymbol(a)?!0:typeof a=="string"&&(r.test(a)||!n.test(a))||o!=null&&Object.hasOwn(o,a)}t.isKey=i})(KT)),KT}var UB;function Ype(){return UB||(UB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Kpe(),n=Xpe(),r=GR();function i(a,o,l,c){if(a==null)return[];l=c?void 0:l,Array.isArray(a)||(a=Object.values(a)),Array.isArray(o)||(o=o==null?[null]:[o]),o.length===0&&(o=[null]),Array.isArray(l)||(l=l==null?[]:[l]),l=l.map(m=>String(m));const u=(m,x)=>{let b=m;for(let y=0;y<x.length&&b!=null;++y)b=b[x[y]];return b},d=(m,x)=>x==null||m==null?x:typeof m=="object"&&"key"in m?Object.hasOwn(x,m.key)?x[m.key]:u(x,m.path):typeof m=="function"?m(x):Array.isArray(m)?u(x,m):typeof x=="object"?x[m]:x,f=o.map(m=>(Array.isArray(m)&&m.length===1&&(m=m[0]),m==null||typeof m=="function"||Array.isArray(m)||n.isKey(m)?m:{key:m,path:r.toPath(m)}));return a.map(m=>({original:m,criteria:f.map(x=>d(x,m))})).slice().sort((m,x)=>{for(let b=0;b<f.length;b++){const y=e.compareValues(m.criteria[b],x.criteria[b],l[b]);if(y!==0)return y}return 0}).map(m=>m.original)}t.orderBy=i})(qT)),qT}var YT={},zB;function Qpe(){return zB||(zB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r=1){const i=[],a=Math.floor(r),o=(l,c)=>{for(let u=0;u<l.length;u++){const d=l[u];Array.isArray(d)&&c<a?o(d,c+1):i.push(d)}};return o(n,0),i}t.flatten=e})(YT)),YT}var QT={},BB;function vK(){return BB||(BB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=pK(),n=XR(),r=lK(),i=uK();function a(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=a})(QT)),QT}var $B;function Zpe(){return $B||($B=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Ype(),n=Qpe(),r=vK();function i(a,...o){const l=o.length;return l>1&&r.isIterateeCall(a,o[0],o[1])?o=[]:l>2&&r.isIterateeCall(o[0],o[1],o[2])&&(o=[o[0]]),e.orderBy(a,n.flatten(o),["asc"])}t.sortBy=i})(GT)),GT}var ZT,HB;function Jpe(){return HB||(HB=1,ZT=Zpe().sortBy),ZT}var ege=Jpe();const S2=hl(ege);var wK=t=>t.legend.settings,tge=t=>t.legend.size,nge=t=>t.legend.payload,rge=nt([nge,wK],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?S2(r,n):r});function ige(){return It(rge)}var Lw=1;function _K(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=_.useState({height:0,left:0,top:0,width:0}),r=_.useCallback(i=>{if(i!=null){var a=i.getBoundingClientRect(),o={height:a.height,left:a.left,top:a.top,width:a.width};(Math.abs(o.height-e.height)>Lw||Math.abs(o.left-e.left)>Lw||Math.abs(o.top-e.top)>Lw||Math.abs(o.width-e.width)>Lw)&&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 ja(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 age=typeof Symbol=="function"&&Symbol.observable||"@@observable",VB=age,JT=()=>Math.random().toString(36).substring(7).split("").join("."),sge={INIT:`@@redux/INIT${JT()}`,REPLACE:`@@redux/REPLACE${JT()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${JT()}`},tS=sge;function QR(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 SK(t,e,n){if(typeof t!="function")throw new Error(ja(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(ja(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(ja(1));return n(SK)(t,e)}let r=t,i=e,a=new Map,o=a,l=0,c=!1;function u(){o===a&&(o=new Map,a.forEach((y,v)=>{o.set(v,y)}))}function d(){if(c)throw new Error(ja(3));return i}function f(y){if(typeof y!="function")throw new Error(ja(4));if(c)throw new Error(ja(5));let v=!0;u();const S=l++;return o.set(S,y),function(){if(v){if(c)throw new Error(ja(6));v=!1,u(),o.delete(S),a=null}}}function p(y){if(!QR(y))throw new Error(ja(7));if(typeof y.type>"u")throw new Error(ja(8));if(typeof y.type!="string")throw new Error(ja(17));if(c)throw new Error(ja(9));try{c=!0,i=r(i,y)}finally{c=!1}return(a=o).forEach(S=>{S()}),y}function m(y){if(typeof y!="function")throw new Error(ja(10));r=y,p({type:tS.REPLACE})}function x(){const y=f;return{subscribe(v){if(typeof v!="object"||v===null)throw new Error(ja(11));function S(){const T=v;T.next&&T.next(d())}return S(),{unsubscribe:y(S)}},[VB](){return this}}}return p({type:tS.INIT}),{dispatch:p,subscribe:f,getState:d,replaceReducer:m,[VB]:x}}function oge(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:tS.INIT})>"u")throw new Error(ja(12));if(typeof n(void 0,{type:tS.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(ja(13))})}function NK(t){const e=Object.keys(t),n={};for(let a=0;a<e.length;a++){const o=e[a];typeof t[o]=="function"&&(n[o]=t[o])}const r=Object.keys(n);let i;try{oge(n)}catch(a){i=a}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],p=n[f],m=o[f],x=p(m,l);if(typeof x>"u")throw l&&l.type,new Error(ja(14));u[f]=x,c=c||x!==m}return c=c||r.length!==Object.keys(o).length,c?u:o}}function nS(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function lge(...t){return e=>(n,r)=>{const i=e(n,r);let a=()=>{throw new Error(ja(15))};const o={getState:i.getState,dispatch:(c,...u)=>a(c,...u)},l=t.map(c=>c(o));return a=nS(...l)(i.dispatch),{...i,dispatch:a}}}function MK(t){return QR(t)&&"type"in t&&typeof t.type=="string"}var EK=Symbol.for("immer-nothing"),GB=Symbol.for("immer-draftable"),bs=Symbol.for("immer-state");function kl(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var ho=Object,Vg=ho.getPrototypeOf,rS="constructor",N2="prototype",AP="configurable",iS="enumerable",b1="writable",Y0="value",Fu=t=>!!t&&!!t[bs];function Ul(t){return t?kK(t)||M2(t)||!!t[GB]||!!t[rS]?.[GB]||E2(t)||k2(t):!1}var cge=ho[N2][rS].toString(),qB=new WeakMap;function kK(t){if(!t||!ZR(t))return!1;const e=Vg(t);if(e===null||e===ho[N2])return!0;const n=ho.hasOwnProperty.call(e,rS)&&e[rS];if(n===Object)return!0;if(!sg(n))return!1;let r=qB.get(n);return r===void 0&&(r=Function.toString.call(n),qB.set(n,r)),r===cge}function By(t,e,n=!0){$y(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 $y(t){const e=t[bs];return e?e.type_:M2(t)?1:E2(t)?2:k2(t)?3:0}var WB=(t,e,n=$y(t))=>n===2?t.has(e):ho[N2].hasOwnProperty.call(t,e),CP=(t,e,n=$y(t))=>n===2?t.get(e):t[e],aS=(t,e,n,r=$y(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function uge(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var M2=Array.isArray,E2=t=>t instanceof Map,k2=t=>t instanceof Set,ZR=t=>typeof t=="object",sg=t=>typeof t=="function",eA=t=>typeof t=="boolean",du=t=>t.copy_||t.base_,JR=t=>t.modified_?t.copy_:t.base_;function jP(t,e){if(E2(t))return new Map(t);if(k2(t))return new Set(t);if(M2(t))return Array[N2].slice.call(t);const n=kK(t);if(e===!0||e==="class_only"&&!n){const r=ho.getOwnPropertyDescriptors(t);delete r[bs];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],l=r[o];l[b1]===!1&&(l[b1]=!0,l[AP]=!0),(l.get||l.set)&&(r[o]={[AP]:!0,[b1]:!0,[iS]:l[iS],[Y0]:t[o]})}return ho.create(Vg(t),r)}else{const r=Vg(t);if(r!==null&&n)return{...t};const i=ho.create(r);return ho.assign(i,t)}}function eO(t,e=!1){return T2(t)||Fu(t)||!Ul(t)||($y(t)>1&&ho.defineProperties(t,{set:Fw,add:Fw,clear:Fw,delete:Fw}),ho.freeze(t),e&&By(t,(n,r)=>{eO(r,!0)},!1)),t}function dge(){kl(2)}var Fw={[Y0]:dge};function T2(t){return t===null||!ZR(t)?!0:ho.isFrozen(t)}var sS="MapSet",PP="Patches",TK={};function Gg(t){const e=TK[t];return e||kl(0,t),e}var hge=t=>!!TK[t],Q0,AK=()=>Q0,fge=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:hge(sS)?Gg(sS):void 0});function KB(t,e){e&&(t.patchPlugin_=Gg(PP),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function DP(t){RP(t),t.drafts_.forEach(mge),t.drafts_=null}function RP(t){t===Q0&&(Q0=t.parent_)}var XB=t=>Q0=fge(Q0,t);function mge(t){const e=t[bs];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function YB(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[bs].modified_&&(DP(e),kl(4)),Ul(t)&&(t=QB(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[bs].base_,t,e)}else t=QB(e,n);return pge(e,t,!0),DP(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==EK?t:void 0}function QB(t,e){if(T2(e))return e;const n=e[bs];if(!n)return tO(e,t.handledSet_,t);if(!A2(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);PK(n,t)}return n.copy_}function pge(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&eO(e,n)}function CK(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var A2=(t,e)=>t.scope_===e,gge=[];function jK(t,e,n,r){const i=du(t),a=t.type_;if(r!==void 0&&CP(i,r,a)===e){aS(i,r,n,a);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;By(i,(c,u)=>{if(Fu(u)){const d=l.get(u)||[];d.push(c),l.set(u,d)}})}const o=t.draftLocations_.get(e)??gge;for(const l of o)aS(i,l,n,a)}function xge(t,e,n){t.callbacks_.push(function(i){const a=e;if(!a||!A2(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=JR(a);jK(t,a.draft_??a,o,n),PK(a,i)})}function PK(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)}CK(t)}}function bge(t,e,n){const{scope_:r}=t;if(Fu(n)){const i=n[bs];A2(i,r)&&i.callbacks_.push(function(){y1(t);const o=JR(i);jK(t,n,o,e)})}else Ul(n)&&t.callbacks_.push(function(){const a=du(t);CP(a,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&tO(CP(t.copy_,e,t.type_),r.handledSet_,r)})}function tO(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Fu(t)||e.has(t)||!Ul(t)||T2(t)||(e.add(t),By(t,(r,i)=>{if(Fu(i)){const a=i[bs];if(A2(a,n)){const o=JR(a);aS(t,r,o,t.type_),CK(a)}}else Ul(i)&&tO(i,e,n)})),t}function yge(t,e){const n=M2(t),r={type_:n?1:0,scope_:e?e.scope_:AK(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,a=nO;n&&(i=[r],a=Z0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,[l,r]}var nO={get(t,e){if(e===bs)return t;const n=du(t);if(!WB(n,e,t.type_))return vge(t,n,e);const r=n[e];if(t.finalized_||!Ul(r))return r;if(r===tA(t.base_,e)){y1(t);const i=t.type_===1?+e:e,a=LP(t.scope_,r,t,i);return t.copy_[i]=a}return r},has(t,e){return e in du(t)},ownKeys(t){return Reflect.ownKeys(du(t))},set(t,e,n){const r=DK(du(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=tA(du(t),e),a=i?.[bs];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(uge(n,i)&&(n!==void 0||WB(t.base_,e,t.type_)))return!0;y1(t),OP(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),bge(t,e,n)),!0},deleteProperty(t,e){return y1(t),tA(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),OP(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&&{[b1]:!0,[AP]:t.type_!==1||e!=="length",[iS]:r[iS],[Y0]:n[e]}},defineProperty(){kl(11)},getPrototypeOf(t){return Vg(t.base_)},setPrototypeOf(){kl(12)}},Z0={};By(nO,(t,e)=>{Z0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});Z0.deleteProperty=function(t,e){return Z0.set.call(this,t,e,void 0)};Z0.set=function(t,e,n){return nO.set.call(this,t[0],e,n,t[0])};function tA(t,e){const n=t[bs];return(n?du(n):t)[e]}function vge(t,e,n){const r=DK(e,n);return r?Y0 in r?r[Y0]:r.get?.call(t.draft_):void 0}function DK(t,e){if(!(e in t))return;let n=Vg(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=Vg(n)}}function OP(t){t.modified_||(t.modified_=!0,t.parent_&&OP(t.parent_))}function y1(t){t.copy_||(t.assigned_=new Map,t.copy_=jP(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var wge=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)||kl(6),i!==void 0&&!sg(i)&&kl(7);let a;if(Ul(n)){const o=XB(this),l=LP(o,n,void 0);let c=!0;try{a=r(l),c=!1}finally{c?DP(o):RP(o)}return KB(o,i),YB(a,o)}else if(!n||!ZR(n)){if(a=r(n),a===void 0&&(a=n),a===EK&&(a=void 0),this.autoFreeze_&&eO(a,!0),i){const o=[],l=[];Gg(PP).generateReplacementPatches_(n,a,{patches_:o,inversePatches_:l}),i(o,l)}return a}else kl(1,n)},this.produceWithPatches=(n,r)=>{if(sg(n))return(l,...c)=>this.produceWithPatches(l,u=>n(u,...c));let i,a;return[this.produce(n,r,(l,c)=>{i=l,a=c}),i,a]},eA(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),eA(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),eA(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Ul(e)||kl(8),Fu(e)&&(e=Ol(e));const n=XB(this),r=LP(n,e,void 0);return r[bs].isManual_=!0,RP(n),r}finishDraft(e,n){const r=e&&e[bs];(!r||!r.isManual_)&&kl(9);const{scope_:i}=r;return KB(i,n),YB(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,n){let r;for(r=n.length-1;r>=0;r--){const a=n[r];if(a.path.length===0&&a.op==="replace"){e=a.value;break}}r>-1&&(n=n.slice(r+1));const i=Gg(PP).applyPatches_;return Fu(e)?i(e,n):this.produce(e,a=>i(a,n))}};function LP(t,e,n,r){const[i,a]=E2(e)?Gg(sS).proxyMap_(e,n):k2(e)?Gg(sS).proxySet_(e,n):yge(e,n);return(n?.scope_??AK()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?xge(n,a,r):a.callbacks_.push(function(c){c.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:u}=c;a.modified_&&u&&u.generatePatches_(a,[],c)}),i}function Ol(t){return Fu(t)||kl(10,t),RK(t)}function RK(t){if(!Ul(t)||T2(t))return t;const e=t[bs];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=jP(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=jP(t,!0);return By(n,(i,a)=>{aS(n,i,RK(a))},r),e&&(e.finalized_=!1),n}var _ge=new wge,OK=_ge.produce;function LK(t){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,t):i(a)}var Sge=LK(),Nge=LK,Mge=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?nS:nS.apply(null,arguments)};function ul(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(mo(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=>MK(r)&&r.type===t,n}var FK=class i0 extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,i0.prototype)}static get[Symbol.species](){return i0}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new i0(...e[0].concat(this)):new i0(...e.concat(this))}};function ZB(t){return Ul(t)?OK(t,()=>{}):t}function Iw(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function Ege(t){return typeof t=="boolean"}var kge=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=e??{};let o=new FK;return n&&(Ege(n)?o.push(Sge):o.push(Nge(n.extraArgument))),o},IK="RTK_autoBatch",Zr=()=>t=>({payload:t,meta:{[IK]:!0}}),JB=t=>e=>{setTimeout(e,t)},UK=(t={type:"raf"})=>e=>(...n)=>{const r=e(...n);let i=!0,a=!1,o=!1;const l=new Set,c=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:JB(10):t.type==="callback"?t.queueNotification:JB(t.timeout),u=()=>{o=!1,a&&(a=!1,l.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const f=()=>i&&d(),p=r.subscribe(f);return l.add(d),()=>{p(),l.delete(d)}},dispatch(d){try{return i=!d?.meta?.[IK],a=!i,a&&(o||(o=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},Tge=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new FK(t);return r&&i.push(UK(typeof r=="object"?r:void 0)),i};function Age(t){const e=kge(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:a=void 0,enhancers:o=void 0}=t||{};let l;if(typeof n=="function")l=n;else if(QR(n))l=NK(n);else throw new Error(mo(1));let c;typeof r=="function"?c=r(e):c=e();let u=nS;i&&(u=Mge({trace:!1,...typeof i=="object"&&i}));const d=lge(...c),f=Tge(d);let p=typeof o=="function"?o(f):f();const m=u(...p);return SK(l,a,m)}function zK(t){const e={},n=[];let r;const i={addCase(a,o){const l=typeof a=="string"?a:a.type;if(!l)throw new Error(mo(28));if(l in e)throw new Error(mo(29));return e[l]=o,i},addAsyncThunk(a,o){return o.pending&&(e[a.pending.type]=o.pending),o.rejected&&(e[a.rejected.type]=o.rejected),o.fulfilled&&(e[a.fulfilled.type]=o.fulfilled),o.settled&&n.push({matcher:a.settled,reducer:o.settled}),i},addMatcher(a,o){return n.push({matcher:a,reducer:o}),i},addDefaultCase(a){return r=a,i}};return t(i),[e,n,r]}function Cge(t){return typeof t=="function"}function jge(t,e){let[n,r,i]=zK(e),a;if(Cge(t))a=()=>ZB(t());else{const l=ZB(t);a=()=>l}function o(l=a(),c){let u=[n[c.type],...r.filter(({matcher:d})=>d(c)).map(({reducer:d})=>d)];return u.filter(d=>!!d).length===0&&(u=[i]),u.reduce((d,f)=>{if(f)if(Fu(d)){const m=f(d,c);return m===void 0?d:m}else{if(Ul(d))return OK(d,p=>f(p,c));{const p=f(d,c);if(p===void 0){if(d===null)return d;throw Error("A case reducer on a non-draftable value must not return undefined")}return p}}return d},l)}return o.getInitialState=a,o}var Pge="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",Dge=(t=21)=>{let e="",n=t;for(;n--;)e+=Pge[Math.random()*64|0];return e},Rge=Symbol.for("rtk-slice-createasyncthunk");function Oge(t,e){return`${t}/${e}`}function Lge({creators:t}={}){const e=t?.asyncThunk?.[Rge];return function(r){const{name:i,reducerPath:a=i}=r;if(!i)throw new Error(mo(11));const o=(typeof r.reducers=="function"?r.reducers(Ige()):r.reducers)||{},l=Object.keys(o),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(M,T){const E=typeof M=="string"?M:M.type;if(!E)throw new Error(mo(12));if(E in c.sliceCaseReducersByType)throw new Error(mo(13));return c.sliceCaseReducersByType[E]=T,u},addMatcher(M,T){return c.sliceMatchers.push({matcher:M,reducer:T}),u},exposeAction(M,T){return c.actionCreators[M]=T,u},exposeCaseReducer(M,T){return c.sliceCaseReducersByName[M]=T,u}};l.forEach(M=>{const T=o[M],E={reducerName:M,type:Oge(i,M),createNotation:typeof r.reducers=="function"};zge(T)?$ge(E,T,u,e):Uge(E,T,u)});function d(){const[M={},T=[],E=void 0]=typeof r.extraReducers=="function"?zK(r.extraReducers):[r.extraReducers],C={...M,...c.sliceCaseReducersByType};return jge(r.initialState,k=>{for(let R in C)k.addCase(R,C[R]);for(let R of c.sliceMatchers)k.addMatcher(R.matcher,R.reducer);for(let R of T)k.addMatcher(R.matcher,R.reducer);E&&k.addDefaultCase(E)})}const f=M=>M,p=new Map,m=new WeakMap;let x;function b(M,T){return x||(x=d()),x(M,T)}function y(){return x||(x=d()),x.getInitialState()}function v(M,T=!1){function E(k){let R=k[M];return typeof R>"u"&&T&&(R=Iw(m,E,y)),R}function C(k=f){const R=Iw(p,T,()=>new WeakMap);return Iw(R,k,()=>{const A={};for(const[D,U]of Object.entries(r.selectors??{}))A[D]=Fge(U,k,()=>Iw(m,k,y),T);return A})}return{reducerPath:M,getSelectors:C,get selectors(){return C(E)},selectSlice:E}}const S={name:i,reducer:b,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:y,...v(a),injectInto(M,{reducerPath:T,...E}={}){const C=T??a;return M.inject({reducerPath:C,reducer:b},E),{...S,...v(C,!0)}}};return S}}function Fge(t,e,n,r){function i(a,...o){let l=e(a);return typeof l>"u"&&r&&(l=n()),t(l,...o)}return i.unwrapped=t,i}var Vs=Lge();function Ige(){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 Uge({type:t,reducerName:e,createNotation:n},r,i){let a,o;if("reducer"in r){if(n&&!Bge(r))throw new Error(mo(17));a=r.reducer,o=r.prepare}else a=r;i.addCase(t,a).exposeCaseReducer(e,a).exposeAction(e,o?ul(t,o):ul(t))}function zge(t){return t._reducerDefinitionType==="asyncThunk"}function Bge(t){return t._reducerDefinitionType==="reducerWithPrepare"}function $ge({type:t,reducerName:e},n,r,i){if(!i)throw new Error(mo(18));const{payloadCreator:a,fulfilled:o,pending:l,rejected:c,settled:u,options:d}=n,f=i(t,a,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||Uw,pending:l||Uw,rejected:c||Uw,settled:u||Uw})}function Uw(){}var Hge="task",BK="listener",$K="completed",rO="cancelled",Vge=`task-${rO}`,Gge=`task-${$K}`,FP=`${BK}-${rO}`,qge=`${BK}-${$K}`,C2=class{constructor(t){this.code=t,this.message=`${Hge} ${rO} (reason: ${t})`}name="TaskAbortError";message},iO=(t,e)=>{if(typeof t!="function")throw new TypeError(mo(32))},oS=()=>{},HK=(t,e=oS)=>(t.catch(e),t),VK=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),Bf=(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))},$f=t=>{if(t.aborted){const{reason:e}=t;throw new C2(e)}};function GK(t,e){let n=oS;return new Promise((r,i)=>{const a=()=>i(new C2(t.reason));if(t.aborted){a();return}n=VK(t,a),e.finally(()=>n()).then(r,i)}).finally(()=>{n=oS})}var Wge=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof C2?"cancelled":"rejected",error:n}}finally{e?.()}},lS=t=>e=>HK(GK(t,e).then(n=>($f(t),n))),qK=t=>{const e=lS(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:Mg}=Object,e8={},j2="listenerMiddleware",Kge=(t,e)=>{const n=r=>VK(t,()=>Bf(r,t.reason));return(r,i)=>{iO(r);const a=new AbortController;n(a);const o=Wge(async()=>{$f(t),$f(a.signal);const l=await r({pause:lS(a.signal),delay:qK(a.signal),signal:a.signal});return $f(a.signal),l},()=>Bf(a,Gge));return i?.autoJoin&&e.push(o.catch(oS)),{result:lS(t)(o),cancel(){Bf(a,Vge)}}}},Xge=(t,e)=>{const n=async(r,i)=>{$f(e);let a=()=>{};const l=[new Promise((c,u)=>{let d=t({predicate:r,effect:(f,p)=>{p.unsubscribe(),c([f,p.getState(),p.getOriginalState()])}});a=()=>{d(),u()}})];i!=null&&l.push(new Promise(c=>setTimeout(c,i,null)));try{const c=await GK(e,Promise.race(l));return $f(e),c}finally{a()}};return(r,i)=>HK(n(r,i))},WK=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:a}=t;if(e)i=ul(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(mo(21));return iO(a),{predicate:i,type:e,effect:a}},KK=Mg(t=>{const{type:e,predicate:n,effect:r}=WK(t);return{id:Dge(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(mo(22))}}},{withTypes:()=>KK}),t8=(t,e)=>{const{type:n,effect:r,predicate:i}=WK(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},IP=t=>{t.pending.forEach(e=>{Bf(e,FP)})},Yge=(t,e)=>()=>{for(const n of e.keys())IP(n);t.clear()},n8=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},XK=Mg(ul(`${j2}/add`),{withTypes:()=>XK}),Qge=ul(`${j2}/removeAll`),YK=Mg(ul(`${j2}/remove`),{withTypes:()=>YK}),Zge=(...t)=>{console.error(`${j2}/error`,...t)},Hy=(t={})=>{const e=new Map,n=new Map,r=m=>{const x=n.get(m)??0;n.set(m,x+1)},i=m=>{const x=n.get(m)??1;x===1?n.delete(m):n.set(m,x-1)},{extra:a,onError:o=Zge}=t;iO(o);const l=m=>(m.unsubscribe=()=>e.delete(m.id),e.set(m.id,m),x=>{m.unsubscribe(),x?.cancelActive&&IP(m)}),c=m=>{const x=t8(e,m)??KK(m);return l(x)};Mg(c,{withTypes:()=>c});const u=m=>{const x=t8(e,m);return x&&(x.unsubscribe(),m.cancelActive&&IP(x)),!!x};Mg(u,{withTypes:()=>u});const d=async(m,x,b,y)=>{const v=new AbortController,S=Xge(c,v.signal),M=[];try{m.pending.add(v),r(m),await Promise.resolve(m.effect(x,Mg({},b,{getOriginalState:y,condition:(T,E)=>S(T,E).then(Boolean),take:S,delay:qK(v.signal),pause:lS(v.signal),extra:a,signal:v.signal,fork:Kge(v.signal,M),unsubscribe:m.unsubscribe,subscribe:()=>{e.set(m.id,m)},cancelActiveListeners:()=>{m.pending.forEach((T,E,C)=>{T!==v&&(Bf(T,FP),C.delete(T))})},cancel:()=>{Bf(v,FP),m.pending.delete(v)},throwIfCancelled:()=>{$f(v.signal)}})))}catch(T){T instanceof C2||n8(o,T,{raisedBy:"effect"})}finally{await Promise.all(M),Bf(v,qge),i(m),m.pending.delete(v)}},f=Yge(e,n);return{middleware:m=>x=>b=>{if(!MK(b))return x(b);if(XK.match(b))return c(b.payload);if(Qge.match(b)){f();return}if(YK.match(b))return u(b.payload);let y=m.getState();const v=()=>{if(y===e8)throw new Error(mo(23));return y};let S;try{if(S=x(b),e.size>0){const M=m.getState(),T=Array.from(e.values());for(const E of T){let C=!1;try{C=E.predicate(b,M,y)}catch(k){C=!1,n8(o,k,{raisedBy:"predicate"})}C&&d(E,b,m,v)}}}finally{y=e8}return S},startListening:c,stopListening:u,clearListeners:f}};function mo(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 Jge={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},QK=Vs({name:"chartLayout",initialState:Jge,reducers:{setLayout(t,e){t.layoutType=e.payload},setChartSize(t,e){t.width=e.payload.width,t.height=e.payload.height},setMargin(t,e){var n,r,i,a;t.margin.top=(n=e.payload.top)!==null&&n!==void 0?n:0,t.margin.right=(r=e.payload.right)!==null&&r!==void 0?r:0,t.margin.bottom=(i=e.payload.bottom)!==null&&i!==void 0?i:0,t.margin.left=(a=e.payload.left)!==null&&a!==void 0?a:0},setScale(t,e){t.scale=e.payload}}}),{setMargin:exe,setLayout:txe,setChartSize:nxe,setScale:rxe}=QK.actions,ixe=QK.reducer;function ZK(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function r8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function pg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?r8(Object(n),!0).forEach(function(r){axe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function axe(t,e,n){return(e=sxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sxe(t){var e=oxe(t,"string");return typeof e=="symbol"?e:e+""}function oxe(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 br(t,e,n){return Xr(t)||Xr(e)?n:cl(e)?cm(t,e,n):typeof e=="function"?e(t):n}var lxe=(t,e,n)=>{if(e&&n){var{width:r,height:i}=n,{align:a,verticalAlign:o,layout:l}=e;if((l==="vertical"||l==="horizontal"&&o==="middle")&&a!=="center"&&zt(t[a]))return pg(pg({},t),{},{[a]:t[a]+(r||0)});if((l==="horizontal"||l==="vertical"&&a==="center")&&o!=="middle"&&zt(t[o]))return pg(pg({},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",JK=(t,e,n,r)=>{if(r)return t.map(l=>l.coordinate);var i,a,o=t.map(l=>(l.coordinate===e&&(i=!0),l.coordinate===n&&(a=!0),l.coordinate));return i||o.push(e),a||o.push(n),o},eX=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:a,scale:o,realScaleType:l,isCategorical:c,categoricalDomain:u,tickCount:d,ticks:f,niceTicks:p,axisType:m}=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=m==="angleAxis"&&a&&a.length>=2?ya(a[0]-a[1])*2*b:b,f||p){var y=(f||p||[]).map((v,S)=>{var M=r?r.indexOf(v):v;return{coordinate:o(M)+b,value:v,offset:b,index:S}});return y.filter(v=>!Hs(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}))},i8=1e-4,cxe=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-i8,a=Math.max(r[0],r[1])+i8,o=t(e[0]),l=t(e[n-1]);(o<i||o>a||l<i||l>a)&&t.domain([e[0],e[n-1]])}},uxe=(t,e)=>{if(!e||e.length!==2||!zt(e[0])||!zt(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(!zt(t[0])||t[0]<n)&&(i[0]=n),(!zt(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},dxe=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,a=0,o=0;o<e;++o){var l=Hs(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]=a,t[o][n][1]=a+l,a=t[o][n][1])}},hxe=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,a=0;a<e;++a){var o=Hs(t[a][n][1])?t[a][n][0]:t[a][n][1];o>=0?(t[a][n][0]=i,t[a][n][1]=i+o,i=t[a][n][1]):(t[a][n][0]=0,t[a][n][1]=0)}},fxe={sign:dxe,expand:Lme,none:Hg,silhouette:Fme,wiggle:Ime,positive:hxe},mxe=(t,e,n)=>{var r=fxe[n],i=Ome().keys(e).value((a,o)=>Number(br(a,o,0))).order(kP).offset(r);return i(t)};function tX(t){return t==null?void 0:String(t)}function cS(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:a,dataKey:o}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!Xr(i[e.dataKey])){var l=iK(n,"value",i[e.dataKey]);if(l)return l.coordinate+r/2}return n[a]?n[a].coordinate+r/2:null}var c=br(i,Xr(o)?e.dataKey:o);return Xr(c)?null:e.scale(c)}var a8=t=>{var{axis:e,ticks:n,offset:r,bandSize:i,entry:a,index:o}=t;if(e.type==="category")return n[o]?n[o].coordinate+r:null;var l=br(a,e.dataKey,e.scale.domain()[o]);return Xr(l)?null:e.scale(l)-i/2+r},pxe=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]},gxe=t=>{var e=t.flat(2).filter(zt);return[Math.min(...e),Math.max(...e)]},xxe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],bxe=(t,e,n)=>{if(t!=null)return xxe(Object.keys(t).reduce((r,i)=>{var a=t[i],{stackedData:o}=a,l=o.reduce((c,u)=>{var d=ZK(u,e,n),f=gxe(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]))},s8=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,o8=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,wh=(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=S2(e,d=>d.coordinate),a=1/0,o=1,l=i.length;o<l;o++){var c=i[o],u=i[o-1];a=Math.min((c.coordinate||0)-(u.coordinate||0),a)}return a===1/0?0:a}return n?void 0:0};function l8(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:a}=t;return pg(pg({},e),{},{dataKey:n,payload:r,value:i,name:a})}function Lh(t,e){if(t)return String(t);if(typeof e=="string")return e}var yxe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},vxe=(t,e)=>e==="centric"?t.angle:t.radius,qu=t=>t.layout.width,Wu=t=>t.layout.height,wxe=t=>t.layout.scale,nX=t=>t.layout.margin,P2=nt(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),D2=nt(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),rX="data-recharts-item-index",iX="data-recharts-item-data-key",Vy=60;function c8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function zw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?c8(Object(n),!0).forEach(function(r){_xe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):c8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _xe(t,e,n){return(e=Sxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Sxe(t){var e=Nxe(t,"string");return typeof e=="symbol"?e:e+""}function Nxe(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 Mxe=t=>t.brush.height;function Exe(t){var e=D2(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Vy;return n+i}return n},0)}function kxe(t){var e=D2(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Vy;return n+i}return n},0)}function Txe(t){var e=P2(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function Axe(t){var e=P2(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var na=nt([qu,Wu,nX,Mxe,Exe,kxe,Txe,Axe,wK,tge],(t,e,n,r,i,a,o,l,c,u)=>{var d={left:(n.left||0)+i,right:(n.right||0)+a},f={top:(n.top||0)+o,bottom:(n.bottom||0)+l},p=zw(zw({},f),d),m=p.bottom;p.bottom+=r,p=lxe(p,c,u);var x=t-p.left-p.right,b=e-p.top-p.bottom;return zw(zw({brushBottom:m},p),{},{width:Math.max(x,0),height:Math.max(b,0)})}),Cxe=nt(na,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),aO=nt(qu,Wu,(t,e)=>({x:0,y:0,width:t,height:e})),jxe=_.createContext(null),ra=()=>_.useContext(jxe)!=null,R2=t=>t.brush,O2=nt([R2,na,nX],(t,e,n)=>({height:t.height,x:zt(t.x)?t.x:e.left,y:zt(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:zt(t.width)?t.width:e.width})),nA={},rA={},iA={},u8;function Pxe(){return u8||(u8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:a}={}){let o,l=null;const c=a!=null&&a.includes("leading"),u=a==null||a.includes("trailing"),d=()=>{l!==null&&(n.apply(o,l),o=void 0,l=null)},f=()=>{u&&d(),b()};let p=null;const m=()=>{p!=null&&clearTimeout(p),p=setTimeout(()=>{p=null,f()},r)},x=()=>{p!==null&&(clearTimeout(p),p=null)},b=()=>{x(),o=void 0,l=null},y=()=>{d()},v=function(...S){if(i?.aborted)return;o=this,l=S;const M=p==null;m(),c&&M&&d()};return v.schedule=m,v.cancel=b,v.flush=y,i?.addEventListener("abort",b,{once:!0}),v}t.debounce=e})(iA)),iA}var d8;function Dxe(){return d8||(d8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Pxe();function n(r,i=0,a={}){typeof a!="object"&&(a={});const{leading:o=!1,trailing:l=!0,maxWait:c}=a,u=Array(2);o&&(u[0]="leading"),l&&(u[1]="trailing");let d,f=null;const p=e.debounce(function(...b){d=r.apply(this,b),f=null},i,{edges:u}),m=function(...b){return c!=null&&(f===null&&(f=Date.now()),Date.now()-f>=c)?(d=r.apply(this,b),f=Date.now(),p.cancel(),p.schedule(),d):(p.apply(this,b),d)},x=()=>(p.flush(),d);return m.cancel=p.cancel,m.flush=x,m}t.debounce=n})(rA)),rA}var h8;function Rxe(){return h8||(h8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Dxe();function n(r,i=0,a={}){const{leading:o=!0,trailing:l=!0}=a;return e.debounce(r,i,{leading:o,maxWait:i,trailing:l})}t.throttle=n})(nA)),nA}var aA,f8;function Oxe(){return f8||(f8=1,aA=Rxe().throttle),aA}var Lxe=Oxe();const Fxe=hl(Lxe);var uS=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),a=2;a<r;a++)i[a-2]=arguments[a];if(typeof console<"u"&&console.warn&&(n===void 0&&console.warn("LogUtils requires an error message argument"),!e))if(n===void 0)console.warn("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var o=0;console.warn(n.replace(/%s/g,()=>i[o++]))}},aX=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:a,maxHeight:o}=n,l=Lu(r)?t:Number(r),c=Lu(i)?e:Number(i);return a&&a>0&&(l?c=l/a:c&&(l=c*a),o&&c!=null&&c>o&&(c=o)),{calculatedWidth:l,calculatedHeight:c}},Ixe={width:0,height:0,overflow:"visible"},Uxe={width:0,overflowX:"visible"},zxe={height:0,overflowY:"visible"},Bxe={},$xe=t=>{var{width:e,height:n}=t,r=Lu(e),i=Lu(n);return r&&i?Ixe:r?Uxe:i?zxe:Bxe};function Hxe(t){var{width:e,height:n,aspect:r}=t,i=e,a=n;return i===void 0&&a===void 0?(i="100%",a="100%"):i===void 0?i=r&&r>0?void 0:"100%":a===void 0&&(a=r&&r>0?void 0:"100%"),{width:i,height:a}}function yr(t){return Number.isFinite(t)}function pc(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function UP(){return UP=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},UP.apply(null,arguments)}function m8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function p8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?m8(Object(n),!0).forEach(function(r){Vxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):m8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Vxe(t,e,n){return(e=Gxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Gxe(t){var e=qxe(t,"string");return typeof e=="symbol"?e:e+""}function qxe(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 sX=_.createContext({width:-1,height:-1});function Wxe(t){return pc(t.width)&&pc(t.height)}function oX(t){var{children:e,width:n,height:r}=t,i=_.useMemo(()=>({width:n,height:r}),[n,r]);return Wxe(i)?_.createElement(sX.Provider,{value:i},e):null}var sO=()=>_.useContext(sX),Kxe=_.forwardRef((t,e)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:a,minWidth:o=0,minHeight:l,maxHeight:c,children:u,debounce:d=0,id:f,className:p,onResize:m,style:x={}}=t,b=_.useRef(null),y=_.useRef();y.current=m,_.useImperativeHandle(e,()=>b.current);var[v,S]=_.useState({containerWidth:r.width,containerHeight:r.height}),M=_.useCallback((R,A)=>{S(D=>{var U=Math.round(R),F=Math.round(A);return D.containerWidth===U&&D.containerHeight===F?D:{containerWidth:U,containerHeight:F}})},[]);_.useEffect(()=>{if(b.current==null||typeof ResizeObserver>"u")return Uy;var R=F=>{var H,{width:j,height:$}=F[0].contentRect;M(j,$),(H=y.current)===null||H===void 0||H.call(y,j,$)};d>0&&(R=Fxe(R,d,{trailing:!0,leading:!1}));var A=new ResizeObserver(R),{width:D,height:U}=b.current.getBoundingClientRect();return M(D,U),A.observe(b.current),()=>{A.disconnect()}},[M,d]);var{containerWidth:T,containerHeight:E}=v;uS(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:C,calculatedHeight:k}=aX(T,E,{width:i,height:a,aspect:n,maxHeight:c});return uS(C!=null&&C>0||k!=null&&k>0,`The width(%s) and height(%s) of chart should be greater than 0,
  14. please check the style of container, or the props width(%s) and height(%s),
  15. or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
  16. height and width.`,C,k,i,a,o,l,n),_.createElement("div",{id:f?"".concat(f):void 0,className:er("recharts-responsive-container",p),style:p8(p8({},x),{},{width:i,height:a,minWidth:o,minHeight:l,maxHeight:c}),ref:b},_.createElement("div",{style:$xe({width:i,height:a})},_.createElement(oX,{width:C,height:k},u)))}),v1=_.forwardRef((t,e)=>{var n=sO();if(pc(n.width)&&pc(n.height))return t.children;var{width:r,height:i}=Hxe({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:o}=aX(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return zt(a)&&zt(o)?_.createElement(oX,{width:a,height:o},t.children):_.createElement(Kxe,UP({},t,{width:r,height:i,ref:e}))});function lX(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 Gy=()=>{var t,e=ra(),n=It(Cxe),r=It(O2),i=(t=It(R2))===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}},Xxe={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},cX=()=>{var t;return(t=It(na))!==null&&t!==void 0?t:Xxe},oO=()=>It(qu),lO=()=>It(Wu),Yxe=()=>It(t=>t.layout.margin),Vn=t=>t.layout.layoutType,km=()=>It(Vn),Qxe=()=>{var t=km();if(t==="horizontal"||t==="vertical")return t},Zxe=()=>{var t=km();return t!==void 0},L2=t=>{var e=Lr(),n=ra(),{width:r,height:i}=t,a=sO(),o=r,l=i;return a&&(o=a.width>0?a.width:r,l=a.height>0?a.height:i),_.useEffect(()=>{!n&&pc(o)&&pc(l)&&e(nxe({width:o,height:l}))},[e,n,o,l]),null},uX=Symbol.for("immer-nothing"),g8=Symbol.for("immer-draftable"),yo=Symbol.for("immer-state");function Tl(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var J0=Object.getPrototypeOf;function qg(t){return!!t&&!!t[yo]}function um(t){return t?dX(t)||Array.isArray(t)||!!t[g8]||!!t.constructor?.[g8]||qy(t)||I2(t):!1}var Jxe=Object.prototype.constructor.toString(),x8=new WeakMap;function dX(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=x8.get(n);return r===void 0&&(r=Function.toString.call(n),x8.set(n,r)),r===Jxe}function dS(t,e,n=!0){F2(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 F2(t){const e=t[yo];return e?e.type_:Array.isArray(t)?1:qy(t)?2:I2(t)?3:0}function zP(t,e){return F2(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function hX(t,e,n){const r=F2(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function ebe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function qy(t){return t instanceof Map}function I2(t){return t instanceof Set}function wf(t){return t.copy_||t.base_}function BP(t,e){if(qy(t))return new Map(t);if(I2(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=dX(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[yo];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],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(J0(t),r)}else{const r=J0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function cO(t,e=!1){return U2(t)||qg(t)||!um(t)||(F2(t)>1&&Object.defineProperties(t,{set:Bw,add:Bw,clear:Bw,delete:Bw}),Object.freeze(t),e&&Object.values(t).forEach(n=>cO(n,!0))),t}function tbe(){Tl(2)}var Bw={value:tbe};function U2(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var nbe={};function dm(t){const e=nbe[t];return e||Tl(0,t),e}var ey;function fX(){return ey}function rbe(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function b8(t,e){e&&(dm("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function $P(t){HP(t),t.drafts_.forEach(ibe),t.drafts_=null}function HP(t){t===ey&&(ey=t.parent_)}function y8(t){return ey=rbe(ey,t)}function ibe(t){const e=t[yo];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function v8(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[yo].modified_&&($P(e),Tl(4)),um(t)&&(t=hS(e,t),e.parent_||fS(e,t)),e.patches_&&dm("Patches").generateReplacementPatches_(n[yo].base_,t,e.patches_,e.inversePatches_)):t=hS(e,n,[]),$P(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==uX?t:void 0}function hS(t,e,n){if(U2(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[yo];if(!i)return dS(e,(a,o)=>w8(t,i,e,a,o,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return fS(t,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const a=i.copy_;let o=a,l=!1;i.type_===3&&(o=new Set(a),a.clear(),l=!0),dS(o,(c,u)=>w8(t,i,a,c,u,n,l),r),fS(t,a,!1),n&&t.patches_&&dm("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function w8(t,e,n,r,i,a,o){if(i==null||typeof i!="object"&&!o)return;const l=U2(i);if(!(l&&!o)){if(qg(i)){const c=a&&e&&e.type_!==3&&!zP(e.assigned_,r)?a.concat(r):void 0,u=hS(t,i,c);if(hX(n,r,u),qg(u))t.canAutoFreeze_=!1;else return}else o&&n.add(i);if(um(i)&&!l){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&l)return;hS(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(qy(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&fS(t,i)}}}function fS(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&cO(e,n)}function abe(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:fX(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=uO;n&&(i=[r],a=ty);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,l}var uO={get(t,e){if(e===yo)return t;const n=wf(t);if(!zP(n,e))return sbe(t,n,e);const r=n[e];return t.finalized_||!um(r)?r:r===sA(t.base_,e)?(oA(t),t.copy_[e]=GP(r,t)):r},has(t,e){return e in wf(t)},ownKeys(t){return Reflect.ownKeys(wf(t))},set(t,e,n){const r=mX(wf(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=sA(wf(t),e),a=i?.[yo];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(ebe(n,i)&&(n!==void 0||zP(t.base_,e)))return!0;oA(t),VP(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 sA(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,oA(t),VP(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(){Tl(11)},getPrototypeOf(t){return J0(t.base_)},setPrototypeOf(){Tl(12)}},ty={};dS(uO,(t,e)=>{ty[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});ty.deleteProperty=function(t,e){return ty.set.call(this,t,e,void 0)};ty.set=function(t,e,n){return uO.set.call(this,t[0],e,n,t[0])};function sA(t,e){const n=t[yo];return(n?wf(n):t)[e]}function sbe(t,e,n){const r=mX(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function mX(t,e){if(!(e in t))return;let n=J0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=J0(n)}}function VP(t){t.modified_||(t.modified_=!0,t.parent_&&VP(t.parent_))}function oA(t){t.copy_||(t.copy_=BP(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var obe=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,n,r)=>{if(typeof e=="function"&&typeof n!="function"){const a=n;n=e;const o=this;return function(c=a,...u){return o.produce(c,d=>n.call(this,d,...u))}}typeof n!="function"&&Tl(6),r!==void 0&&typeof r!="function"&&Tl(7);let i;if(um(e)){const a=y8(this),o=GP(e,void 0);let l=!0;try{i=n(o),l=!1}finally{l?$P(a):HP(a)}return b8(a,r),v8(i,a)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===uX&&(i=void 0),this.autoFreeze_&&cO(i,!0),r){const a=[],o=[];dm("Patches").generateReplacementPatches_(e,i,a,o),r(a,o)}return i}else Tl(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){um(t)||Tl(8),qg(t)&&(t=lbe(t));const e=y8(this),n=GP(t,void 0);return n[yo].isManual_=!0,HP(e),n}finishDraft(t,e){const n=t&&t[yo];(!n||!n.isManual_)&&Tl(9);const{scope_:r}=n;return b8(r,e),v8(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=dm("Patches").applyPatches_;return qg(t)?r(t,e):this.produce(t,i=>r(i,e))}};function GP(t,e){const n=qy(t)?dm("MapSet").proxyMap_(t,e):I2(t)?dm("MapSet").proxySet_(t,e):abe(t,e);return(e?e.scope_:fX()).drafts_.push(n),n}function lbe(t){return qg(t)||Tl(10,t),pX(t)}function pX(t){if(!um(t)||U2(t))return t;const e=t[yo];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=BP(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=BP(t,!0);return dS(n,(i,a)=>{hX(n,i,pX(a))},r),e&&(e.finalized_=!1),n}var cbe=new obe;cbe.produce;var ube={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},gX=Vs({name:"legend",initialState:ube,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:Zr()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ol(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:Zr()},removeLegendPayload:{reducer(t,e){var n=Ol(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:Zr()}}}),{setLegendSize:_8,setLegendSettings:dbe,addLegendPayload:xX,replaceLegendPayload:bX,removeLegendPayload:yX}=gX.actions,hbe=gX.reducer,fbe=["contextPayload"];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 S8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Wg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?S8(Object(n),!0).forEach(function(r){mbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):S8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function mbe(t,e,n){return(e=pbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pbe(t){var e=gbe(t,"string");return typeof e=="symbol"?e:e+""}function gbe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function xbe(t,e){if(t==null)return{};var n,r,i=bbe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function bbe(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 ybe(t){return t.value}function vbe(t){var{contextPayload:e}=t,n=xbe(t,fbe),r=gK(e,t.payloadUniqBy,ybe),i=Wg(Wg({},n),{},{payload:r});return _.isValidElement(t.content)?_.cloneElement(t.content,i):typeof t.content=="function"?_.createElement(t.content,i):_.createElement(fpe,i)}function wbe(t,e,n,r,i,a){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)-a.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)-a.height)/2}:d=c==="bottom"?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),Wg(Wg({},u),d)}function _be(t){var e=Lr();return _.useEffect(()=>{e(dbe(t))},[e,t]),null}function Sbe(t){var e=Lr();return _.useEffect(()=>(e(_8(t)),()=>{e(_8({width:0,height:0}))}),[e,t]),null}function Nbe(t,e,n,r){return t==="vertical"&&zt(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var Mbe={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function dO(t){var e=li(t,Mbe),n=ige(),r=ame(),i=Yxe(),{width:a,height:o,wrapperStyle:l,portal:c}=e,[u,d]=_K([n]),f=oO(),p=lO();if(f==null||p==null)return null;var m=f-(i?.left||0)-(i?.right||0),x=Nbe(e.layout,o,a,m),b=c?l:Wg(Wg({position:"absolute",width:x?.width||a||"auto",height:x?.height||o||"auto"},wbe(l,e,i,f,p,u)),l),y=c??r;if(y==null||n==null)return null;var v=_.createElement("div",{className:"recharts-legend-wrapper",style:b,ref:d},_.createElement(_be,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&_.createElement(Sbe,{width:u.width,height:u.height}),_.createElement(vbe,qP({},e,x,{margin:i,chartWidth:f,chartHeight:p,contextPayload:n})));return gu.createPortal(v,y)}dO.displayName="Legend";function WP(){return WP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},WP.apply(null,arguments)}function N8(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 lA(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?N8(Object(n),!0).forEach(function(r){Ebe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):N8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Ebe(t,e,n){return(e=kbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function kbe(t){var e=Tbe(t,"string");return typeof e=="symbol"?e:e+""}function Tbe(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 Abe(t){return Array.isArray(t)&&cl(t[0])&&cl(t[1])?t.join(" ~ "):t}var Cbe=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:a,formatter:o,itemSorter:l,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:f,accessibilityLayer:p=!1}=t,m=()=>{if(a&&a.length){var E={padding:0,margin:0},C=(l?S2(a,l):a).map((k,R)=>{if(k.type==="none")return null;var A=k.formatter||o||Abe,{value:D,name:U}=k,F=D,H=U;if(A){var j=A(D,U,k,R,a);if(Array.isArray(j))[F,H]=j;else if(j!=null)F=j;else return null}var $=lA({display:"block",paddingTop:4,paddingBottom:4,color:k.color||"#000"},r);return _.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(R),style:$},cl(H)?_.createElement("span",{className:"recharts-tooltip-item-name"},H):null,cl(H)?_.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,_.createElement("span",{className:"recharts-tooltip-item-value"},F),_.createElement("span",{className:"recharts-tooltip-item-unit"},k.unit||""))});return _.createElement("ul",{className:"recharts-tooltip-item-list",style:E},C)}return null},x=lA({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),b=lA({margin:0},i),y=!Xr(d),v=y?d:"",S=er("recharts-default-tooltip",c),M=er("recharts-tooltip-label",u);y&&f&&a!==void 0&&a!==null&&(v=f(d,a));var T=p?{role:"status","aria-live":"assertive"}:{};return _.createElement("div",WP({className:S,style:x},T),_.createElement("p",{className:M,style:b},_.isValidElement(v)?v:"".concat(v)),m())},jb="recharts-tooltip-wrapper",jbe={visibility:"hidden"};function Pbe(t){var{coordinate:e,translateX:n,translateY:r}=t;return er(jb,{["".concat(jb,"-right")]:zt(n)&&e&&zt(e.x)&&n>=e.x,["".concat(jb,"-left")]:zt(n)&&e&&zt(e.x)&&n<e.x,["".concat(jb,"-bottom")]:zt(r)&&e&&zt(e.y)&&r>=e.y,["".concat(jb,"-top")]:zt(r)&&e&&zt(e.y)&&r<e.y})}function M8(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:a,reverseDirection:o,tooltipDimension:l,viewBox:c,viewBoxDimension:u}=t;if(a&&zt(a[r]))return a[r];var d=n[r]-l-(i>0?i:0),f=n[r]+i;if(e[r])return o[r]?d:f;var p=c[r];if(p==null)return 0;if(o[r]){var m=d,x=p;return m<x?Math.max(f,p):Math.max(d,p)}if(u==null)return 0;var b=f+l,y=p+u;return b>y?Math.max(d,p):Math.max(f,p)}function Dbe(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 Rbe(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:a,tooltipBox:o,useTranslate3d:l,viewBox:c}=t,u,d,f;return o.height>0&&o.width>0&&n?(d=M8({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:o.width,viewBox:c,viewBoxDimension:c.width}),f=M8({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:o.height,viewBox:c,viewBoxDimension:c.height}),u=Dbe({translateX:d,translateY:f,useTranslate3d:l})):u=jbe,{cssProperties:u,cssClasses:Pbe({translateX:d,translateY:f,coordinate:n})}}function E8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function $w(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?E8(Object(n),!0).forEach(function(r){KP(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):E8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function KP(t,e,n){return(e=Obe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Obe(t){var e=Lbe(t,"string");return typeof e=="symbol"?e:e+""}function Lbe(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 Fbe extends _.PureComponent{constructor(){super(...arguments),KP(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),KP(this,"handleKeyDown",e=>{if(e.key==="Escape"){var n,r,i,a;this.setState({dismissed:!0,dismissedAtCoordinate:{x:(n=(r=this.props.coordinate)===null||r===void 0?void 0:r.x)!==null&&n!==void 0?n:0,y:(i=(a=this.props.coordinate)===null||a===void 0?void 0:a.y)!==null&&i!==void 0?i:0}})}})}componentDidMount(){document.addEventListener("keydown",this.handleKeyDown)}componentWillUnmount(){document.removeEventListener("keydown",this.handleKeyDown)}componentDidUpdate(){var e,n;this.state.dismissed&&(((e=this.props.coordinate)===null||e===void 0?void 0:e.x)!==this.state.dismissedAtCoordinate.x||((n=this.props.coordinate)===null||n===void 0?void 0:n.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}render(){var{active:e,allowEscapeViewBox:n,animationDuration:r,animationEasing:i,children:a,coordinate:o,hasPayload:l,isAnimationActive:c,offset:u,position:d,reverseDirection:f,useTranslate3d:p,viewBox:m,wrapperStyle:x,lastBoundingBox:b,innerRef:y,hasPortalFromProps:v}=this.props,{cssClasses:S,cssProperties:M}=Rbe({allowEscapeViewBox:n,coordinate:o,offsetTopLeft:u,position:d,reverseDirection:f,tooltipBox:{height:b.height,width:b.width},useTranslate3d:p,viewBox:m}),T=v?{}:$w($w({transition:c&&e?"transform ".concat(r,"ms ").concat(i):void 0},M),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&l?"visible":"hidden",position:"absolute",top:0,left:0}),E=$w($w({},T),{},{visibility:!this.state.dismissed&&e&&l?"visible":"hidden"},x);return _.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:S,style:E,ref:y},a)}}var vX=()=>{var t;return(t=It(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function XP(){return XP=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},XP.apply(null,arguments)}function k8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function T8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?k8(Object(n),!0).forEach(function(r){Ibe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):k8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Ibe(t,e,n){return(e=Ube(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ube(t){var e=zbe(t,"string");return typeof e=="symbol"?e:e+""}function zbe(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 A8={curveBasisClosed:Nme,curveBasisOpen:Mme,curveBasis:Sme,curveBumpX:cme,curveBumpY:ume,curveLinearClosed:Eme,curveLinear:w2,curveMonotoneX:kme,curveMonotoneY:Tme,curveNatural:Ame,curveStep:Cme,curveStepAfter:Pme,curveStepBefore:jme},mS=t=>yr(t.x)&&yr(t.y),C8=t=>t.base!=null&&mS(t.base)&&mS(t),Pb=t=>t.x,Db=t=>t.y,Bbe=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(Iy(t));return(n==="curveMonotone"||n==="curveBump")&&e?A8["".concat(n).concat(e==="vertical"?"Y":"X")]:A8[n]||w2},$be=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:a=!1}=t,o=Bbe(e,i),l=a?n.filter(mS):n,c;if(Array.isArray(r)){var u=n.map((m,x)=>T8(T8({},m),{},{base:r[x]}));i==="vertical"?c=Rw().y(Db).x1(Pb).x0(m=>m.base.x):c=Rw().x(Pb).y1(Db).y0(m=>m.base.y);var d=c.defined(C8).curve(o),f=a?u.filter(C8):u;return d(f)}i==="vertical"&&zt(r)?c=Rw().y(Db).x1(Pb).x0(r):zt(r)?c=Rw().x(Pb).y1(Db).y0(r):c=GW().x(Pb).y(Db);var p=c.defined(mS).curve(o);return p(l)},Eg=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var a=n&&n.length?$be(t):r;return _.createElement("path",XP({},xs(t),KR(t),{className:er("recharts-curve",e),d:a===null?void 0:a,ref:i}))},Hbe=["x","y","top","left","width","height","className"];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 j8(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 Vbe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?j8(Object(n),!0).forEach(function(r){Gbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):j8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Gbe(t,e,n){return(e=qbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function qbe(t){var e=Wbe(t,"string");return typeof e=="symbol"?e:e+""}function Wbe(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 Kbe(t,e){if(t==null)return{};var n,r,i=Xbe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Xbe(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 Ybe=(t,e,n,r,i,a)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(a,",").concat(e,"h").concat(n),Qbe=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:a=0,height:o=0,className:l}=t,c=Kbe(t,Hbe),u=Vbe({x:e,y:n,top:r,left:i,width:a,height:o},c);return!zt(e)||!zt(n)||!zt(a)||!zt(o)||!zt(r)||!zt(i)?null:_.createElement("path",YP({},za(u),{className:er("recharts-cross",l),d:Ybe(e,n,a,o,r,i)}))};function Zbe(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 P8(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 D8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?P8(Object(n),!0).forEach(function(r){Jbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):P8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Jbe(t,e,n){return(e=e0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function e0e(t){var e=t0e(t,"string");return typeof e=="symbol"?e:e+""}function t0e(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 n0e=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),wX=(t,e,n)=>t.map(r=>"".concat(n0e(r)," ").concat(e,"ms ").concat(n)).join(","),r0e=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),ny=(t,e)=>Object.keys(e).reduce((n,r)=>D8(D8({},n),{},{[r]:t(r,e[r])}),{});function R8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ki(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?R8(Object(n),!0).forEach(function(r){i0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):R8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function i0e(t,e,n){return(e=a0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a0e(t){var e=s0e(t,"string");return typeof e=="symbol"?e:e+""}function s0e(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=(t,e,n)=>t+(e-t)*n,QP=t=>{var{from:e,to:n}=t;return e!==n},_X=(t,e,n)=>{var r=ny((i,a)=>{if(QP(a)){var[o,l]=t(a.from,a.to,a.velocity);return Ki(Ki({},a),{},{from:o,velocity:l})}return a},e);return n<1?ny((i,a)=>QP(a)?Ki(Ki({},a),{},{velocity:pS(a.velocity,r[i].velocity,n),from:pS(a.from,r[i].from,n)}):a,e):_X(t,r,n-1)};function o0e(t,e,n,r,i,a){var o,l=r.reduce((p,m)=>Ki(Ki({},p),{},{[m]:{from:t[m],velocity:0,to:e[m]}}),{}),c=()=>ny((p,m)=>m.from,l),u=()=>!Object.values(l).filter(QP).length,d=null,f=p=>{o||(o=p);var m=p-o,x=m/n.dt;l=_X(n,l,x),i(Ki(Ki(Ki({},t),e),c())),o=p,u()||(d=a.setTimeout(f))};return()=>(d=a.setTimeout(f),()=>{var p;(p=d)===null||p===void 0||p()})}function l0e(t,e,n,r,i,a,o){var l=null,c=i.reduce((f,p)=>Ki(Ki({},f),{},{[p]:[t[p],e[p]]}),{}),u,d=f=>{u||(u=f);var p=(f-u)/r,m=ny((b,y)=>pS(...y,n(p)),c);if(a(Ki(Ki(Ki({},t),e),m)),p<1)l=o.setTimeout(d);else{var x=ny((b,y)=>pS(...y,n(1)),c);a(Ki(Ki(Ki({},t),e),x))}};return()=>(l=o.setTimeout(d),()=>{var f;(f=l)===null||f===void 0||f()})}const c0e=(t,e,n,r,i,a)=>{var o=r0e(t,e);return n==null?()=>(i(Ki(Ki({},t),e)),()=>{}):n.isStepper===!0?o0e(t,e,n,o,i,a):l0e(t,e,n,r,o,i,a)};var gS=1e-4,SX=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],NX=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),O8=(t,e)=>n=>{var r=SX(t,e);return NX(r,n)},u0e=(t,e)=>n=>{var r=SX(t,e),i=[...r.map((a,o)=>a*o).slice(1),0];return NX(i,n)},d0e=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(n.length===1)switch(n[0]){case"linear":return[0,0,1,1];case"ease":return[.25,.1,.25,1];case"ease-in":return[.42,0,1,1];case"ease-out":return[.42,0,.58,1];case"ease-in-out":return[0,0,.58,1];default:{var i,a=n[0].split("(");if(a[0]==="cubic-bezier"&&((i=a[1])===null||i===void 0?void 0:i.split(")")[0].split(",").length)===4){var o=a[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]},h0e=(t,e,n,r)=>{var i=O8(t,n),a=O8(e,r),o=u0e(t,n),l=u=>u>1?1:u<0?0:u,c=u=>{for(var d=u>1?1:u,f=d,p=0;p<8;++p){var m=i(f)-d,x=o(f);if(Math.abs(m-d)<gS||x<gS)return a(f);f=l(f-m/x)}return a(f)};return c.isStepper=!1,c},L8=function(){return h0e(...d0e(...arguments))},f0e=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=e,a=(o,l,c)=>{var u=-(o-l)*n,d=c*r,f=c+(u-d)*i/1e3,p=c*i/1e3+o;return Math.abs(p-l)<gS&&Math.abs(f)<gS?[l,0]:[p,f]};return a.isStepper=!0,a.dt=i,a},m0e=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return L8(t);case"spring":return f0e();default:if(t.split("(")[0]==="cubic-bezier")return L8(t)}return typeof t=="function"?t:null};function p0e(t){var e,n=()=>null,r=!1,i=null,a=o=>{if(!r){if(Array.isArray(o)){if(!o.length)return;var l=o,[c,...u]=l;if(typeof c=="number"){i=t.setTimeout(a.bind(null,u),c);return}a(c),i=t.setTimeout(a.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),a(o)},subscribe:o=>(n=o,()=>{n=()=>null}),getTimeoutController:()=>t}}class g0e{setTimeout(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=performance.now(),i=null,a=o=>{o-r>=n?e(o):typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(a))};return i=requestAnimationFrame(a),()=>{i!=null&&cancelAnimationFrame(i)}}}function x0e(){return p0e(new g0e)}var b0e=_.createContext(x0e);function y0e(t,e){var n=_.useContext(b0e);return _.useMemo(()=>e??n(t),[t,e,n])}var v0e=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),yx={devToolsEnabled:!1,isSsr:v0e()},w0e={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},F8={t:0},cA={t:1};function vx(t){var e=li(t,w0e),{isActive:n,canBegin:r,duration:i,easing:a,begin:o,onAnimationEnd:l,onAnimationStart:c,children:u}=e,d=n==="auto"?!yx.isSsr:n,f=y0e(e.animationId,e.animationManager),[p,m]=_.useState(d?F8:cA),x=_.useRef(null);return _.useEffect(()=>{d||m(cA)},[d]),_.useEffect(()=>{if(!d||!r)return Uy;var b=c0e(F8,cA,m0e(a),i,m,f.getTimeoutController()),y=()=>{x.current=b()};return f.start([c,o,y,i,l]),()=>{f.stop(),x.current&&x.current(),l()}},[d,r,i,a,o,c,l,f]),u(p.t)}function wx(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=_.useRef(X0(e)),r=_.useRef(t);return r.current!==t&&(n.current=X0(e),r.current=t),n.current}var _0e=["radius"],S0e=["radius"];function I8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function U8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?I8(Object(n),!0).forEach(function(r){N0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):I8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function N0e(t,e,n){return(e=M0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function M0e(t){var e=E0e(t,"string");return typeof e=="symbol"?e:e+""}function E0e(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 z8(t,e){if(t==null)return{};var n,r,i=k0e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function k0e(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 B8=(t,e,n,r,i)=>{var a=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(a>0&&i instanceof Array){for(var d=[0,0,0,0],f=0,p=4;f<p;f++)d[f]=i[f]>a?a: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,`,
  17. `).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,`,
  18. `).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,`,
  19. `).concat(t,",").concat(e+r-o*d[3])),u+="Z"}else if(a>0&&i===+i&&i>0){var m=Math.min(a,i);u="M ".concat(t,",").concat(e+o*m,`
  20. A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t+l*m,",").concat(e,`
  21. L `).concat(t+n-l*m,",").concat(e,`
  22. A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t+n,",").concat(e+o*m,`
  23. L `).concat(t+n,",").concat(e+r-o*m,`
  24. A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t+n-l*m,",").concat(e+r,`
  25. L `).concat(t+l*m,",").concat(e+r,`
  26. A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t,",").concat(e+r-o*m," Z")}else u="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return u},$8={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},MX=t=>{var e=li(t,$8),n=_.useRef(null),[r,i]=_.useState(-1);_.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var V=n.current.getTotalLength();V&&i(V)}catch{}},[]);var{x:a,y:o,width:l,height:c,radius:u,className:d}=e,{animationEasing:f,animationDuration:p,animationBegin:m,isAnimationActive:x,isUpdateAnimationActive:b}=e,y=_.useRef(l),v=_.useRef(c),S=_.useRef(a),M=_.useRef(o),T=_.useMemo(()=>({x:a,y:o,width:l,height:c,radius:u}),[a,o,l,c,u]),E=wx(T,"rectangle-");if(a!==+a||o!==+o||l!==+l||c!==+c||l===0||c===0)return null;var C=er("recharts-rectangle",d);if(!b){var k=za(e),{radius:R}=k,A=z8(k,_0e);return _.createElement("path",xS({},A,{radius:typeof u=="number"?u:void 0,className:C,d:B8(a,o,l,c,u)}))}var D=y.current,U=v.current,F=S.current,H=M.current,j="0px ".concat(r===-1?1:r,"px"),$="".concat(r,"px 0px"),K=wX(["strokeDasharray"],p,typeof f=="string"?f:$8.animationEasing);return _.createElement(vx,{animationId:E,key:E,canBegin:r>0,duration:p,easing:f,isActive:b,begin:m},V=>{var Q=dr(D,l,V),Z=dr(U,c,V),ae=dr(F,a,V),B=dr(H,o,V);n.current&&(y.current=Q,v.current=Z,S.current=ae,M.current=B);var X;x?V>0?X={transition:K,strokeDasharray:$}:X={strokeDasharray:j}:X={strokeDasharray:$};var ne=za(e),{radius:se}=ne,be=z8(ne,S0e);return _.createElement("path",xS({},be,{radius:typeof u=="number"?u:void 0,className:C,d:B8(ae,B,Q,Z,u),ref:n,style:U8(U8({},X),e.style)}))})};function H8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function V8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?H8(Object(n),!0).forEach(function(r){T0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):H8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function T0e(t,e,n){return(e=A0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function A0e(t){var e=C0e(t,"string");return typeof e=="symbol"?e:e+""}function C0e(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 bS=Math.PI/180,j0e=t=>t*180/Math.PI,zi=(t,e,n,r)=>({x:t+Math.cos(-bS*r)*n,y:e+Math.sin(-bS*r)*n}),EX=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},P0e=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return Math.sqrt((n-i)**2+(r-a)**2)},D0e=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:a}=e,o=P0e({x:n,y:r},{x:i,y:a});if(o<=0)return{radius:o,angle:0};var l=(n-i)/o,c=Math.acos(l);return r>a&&(c=2*Math.PI-c),{radius:o,angle:j0e(c),angleInRadian:c}},R0e=t=>{var{startAngle:e,endAngle:n}=t,r=Math.floor(e/360),i=Math.floor(n/360),a=Math.min(r,i);return{startAngle:e-a*360,endAngle:n-a*360}},O0e=(t,e)=>{var{startAngle:n,endAngle:r}=e,i=Math.floor(n/360),a=Math.floor(r/360),o=Math.min(i,a);return t+o*360},L0e=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:a}=D0e({x:n,y:r},e),{innerRadius:o,outerRadius:l}=e;if(i<o||i>l||i===0)return null;var{startAngle:c,endAngle:u}=R0e(e),d=a,f;if(c<=u){for(;d>u;)d-=360;for(;d<c;)d+=360;f=d>=c&&d<=u}else{for(;d>c;)d-=360;for(;d<u;)d+=360;f=d>=u&&d<=c}return f?V8(V8({},e),{},{radius:i,angle:O0e(d,e)}):null};function kX(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:a}=t,o=zi(e,n,r,i),l=zi(e,n,r,a);return{points:[o,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:a}}function ZP(){return ZP=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},ZP.apply(null,arguments)}var F0e=(t,e)=>{var n=ya(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},Hw=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:a,isExternal:o,cornerRadius:l,cornerIsExternal:c}=t,u=l*(o?1:-1)+r,d=Math.asin(l/u)/bS,f=c?i:i+a*d,p=zi(e,n,u,f),m=zi(e,n,r,f),x=c?i-a*d:i,b=zi(e,n,u*Math.cos(d*bS),x);return{center:p,circleTangency:m,lineTangency:b,theta:d}},TX=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:o}=t,l=F0e(a,o),c=a+l,u=zi(e,n,i,a),d=zi(e,n,i,c),f="M ".concat(u.x,",").concat(u.y,`
  27. A `).concat(i,",").concat(i,`,0,
  28. `).concat(+(Math.abs(l)>180),",").concat(+(a>c),`,
  29. `).concat(d.x,",").concat(d.y,`
  30. `);if(r>0){var p=zi(e,n,r,a),m=zi(e,n,r,c);f+="L ".concat(m.x,",").concat(m.y,`
  31. A `).concat(r,",").concat(r,`,0,
  32. `).concat(+(Math.abs(l)>180),",").concat(+(a<=c),`,
  33. `).concat(p.x,",").concat(p.y," Z")}else f+="L ".concat(e,",").concat(n," Z");return f},I0e=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u}=t,d=ya(u-c),{circleTangency:f,lineTangency:p,theta:m}=Hw({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:a,cornerIsExternal:l}),{circleTangency:x,lineTangency:b,theta:y}=Hw({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:a,cornerIsExternal:l}),v=l?Math.abs(c-u):Math.abs(c-u)-m-y;if(v<0)return o?"M ".concat(p.x,",").concat(p.y,`
  34. a`).concat(a,",").concat(a,",0,0,1,").concat(a*2,`,0
  35. a`).concat(a,",").concat(a,",0,0,1,").concat(-a*2,`,0
  36. `):TX({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var S="M ".concat(p.x,",").concat(p.y,`
  37. A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(f.x,",").concat(f.y,`
  38. A`).concat(i,",").concat(i,",0,").concat(+(v>180),",").concat(+(d<0),",").concat(x.x,",").concat(x.y,`
  39. A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(b.x,",").concat(b.y,`
  40. `);if(r>0){var{circleTangency:M,lineTangency:T,theta:E}=Hw({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),{circleTangency:C,lineTangency:k,theta:R}=Hw({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),A=l?Math.abs(c-u):Math.abs(c-u)-E-R;if(A<0&&a===0)return"".concat(S,"L").concat(e,",").concat(n,"Z");S+="L".concat(k.x,",").concat(k.y,`
  41. A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(C.x,",").concat(C.y,`
  42. A`).concat(r,",").concat(r,",0,").concat(+(A>180),",").concat(+(d>0),",").concat(M.x,",").concat(M.y,`
  43. A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(T.x,",").concat(T.y,"Z")}else S+="L".concat(e,",").concat(n,"Z");return S},U0e={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},AX=t=>{var e=li(t,U0e),{cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:o,forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d,className:f}=e;if(a<i||u===d)return null;var p=er("recharts-sector",f),m=a-i,x=es(o,m,0,!0),b;return x>0&&Math.abs(u-d)<360?b=I0e({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(x,m/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d}):b=TX({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:u,endAngle:d}),_.createElement("path",ZP({},za(e),{className:p,d:b}))};function z0e(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(sK(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:o,angle:l}=e,c=zi(r,i,a,l),u=zi(r,i,o,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return kX(e)}}var uA={},dA={},hA={},G8;function B0e(){return G8||(G8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=yK();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(hA)),hA}var q8;function $0e(){return q8||(q8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=B0e();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})(dA)),dA}var W8;function H0e(){return W8||(W8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=vK(),n=$0e();function r(i,a,o){o&&typeof o!="number"&&e.isIterateeCall(i,a,o)&&(a=o=void 0),i=n.toFinite(i),a===void 0?(a=i,i=0):a=n.toFinite(a),o=o===void 0?i<a?1:-1:n.toFinite(o);const l=Math.max(Math.ceil((a-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})(uA)),uA}var fA,K8;function V0e(){return K8||(K8=1,fA=H0e().range),fA}var G0e=V0e();const CX=hl(G0e);function oh(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function q0e(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function hO(t){let e,n,r;t.length!==2?(e=oh,n=(l,c)=>oh(t(l),c),r=(l,c)=>t(l)-c):(e=t===oh||t===q0e?t:W0e,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 a(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:a}}function W0e(){return 0}function jX(t){return t===null?NaN:+t}function*K0e(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const X0e=hO(oh),Wy=X0e.right;hO(jX).center;class X8 extends Map{constructor(e,n=Z0e){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(Y8(this,e))}has(e){return super.has(Y8(this,e))}set(e,n){return super.set(Y0e(this,e),n)}delete(e){return super.delete(Q0e(this,e))}}function Y8({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function Y0e({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function Q0e({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function Z0e(t){return t!==null&&typeof t=="object"?t.valueOf():t}function J0e(t=oh){if(t===oh)return PX;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 PX(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const eye=Math.sqrt(50),tye=Math.sqrt(10),nye=Math.sqrt(2);function yS(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/Math.pow(10,i),o=a>=eye?10:a>=tye?5:a>=nye?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?yS(t,e,n*2):[l,c,u]}function JP(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[i,a,o]=r?yS(e,t,n):yS(t,e,n);if(!(a>=i))return[];const l=a-i+1,c=new Array(l);if(r)if(o<0)for(let u=0;u<l;++u)c[u]=(a-u)/-o;else for(let u=0;u<l;++u)c[u]=(a-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 e3(t,e,n){return e=+e,t=+t,n=+n,yS(t,e,n)[2]}function t3(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?e3(e,t,n):e3(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function Q8(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function Z8(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function DX(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?PX:J0e(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),p=.5*Math.sqrt(d*f*(c-f)/c)*(u-c/2<0?-1:1),m=Math.max(n,Math.floor(e-u*f/c+p)),x=Math.min(r,Math.floor(e+(c-u)*f/c+p));DX(t,e,m,x,i)}const a=t[e];let o=n,l=r;for(Rb(t,n,e),i(t[r],a)>0&&Rb(t,n,r);o<l;){for(Rb(t,o,l),++o,--l;i(t[o],a)<0;)++o;for(;i(t[l],a)>0;)--l}i(t[n],a)===0?Rb(t,n,l):(++l,Rb(t,l,r)),l<=e&&(n=l+1),e<=l&&(r=l-1)}return t}function Rb(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function rye(t,e,n){if(t=Float64Array.from(K0e(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return Z8(t);if(e>=1)return Q8(t);var r,i=(r-1)*e,a=Math.floor(i),o=Q8(DX(t,a).subarray(0,a+1)),l=Z8(t.subarray(a+1));return o+(l-o)*(i-a)}}function iye(t,e,n=jX){if(!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return+n(t[0],0,t);if(e>=1)return+n(t[r-1],r-1,t);var r,i=(r-1)*e,a=Math.floor(i),o=+n(t[a],a,t),l=+n(t[a+1],a+1,t);return o+(l-o)*(i-a)}}function aye(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((e-t)/n))|0,a=new Array(i);++r<i;)a[r]=t+r*n;return a}function ml(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Ku(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 n3=Symbol("implicit");function fO(){var t=new X8,e=[],n=[],r=n3;function i(a){let o=t.get(a);if(o===void 0){if(r!==n3)return r;t.set(a,o=e.push(a)-1)}return n[o%n.length]}return i.domain=function(a){if(!arguments.length)return e.slice();e=[],t=new X8;for(const o of a)t.has(o)||t.set(o,e.push(o)-1);return i},i.range=function(a){return arguments.length?(n=Array.from(a),i):n.slice()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return fO(e,n).unknown(r)},ml.apply(i,arguments),i}function mO(){var t=fO().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,a,o,l=!1,c=0,u=0,d=.5;delete t.unknown;function f(){var p=e().length,m=i<r,x=m?i:r,b=m?r:i;a=(b-x)/Math.max(1,p-c+u*2),l&&(a=Math.floor(a)),x+=(b-x-a*(p-c))*d,o=a*(1-c),l&&(x=Math.round(x),o=Math.round(o));var y=aye(p).map(function(v){return x+a*v});return n(m?y.reverse():y)}return t.domain=function(p){return arguments.length?(e(p),f()):e()},t.range=function(p){return arguments.length?([r,i]=p,r=+r,i=+i,f()):[r,i]},t.rangeRound=function(p){return[r,i]=p,r=+r,i=+i,l=!0,f()},t.bandwidth=function(){return o},t.step=function(){return a},t.round=function(p){return arguments.length?(l=!!p,f()):l},t.padding=function(p){return arguments.length?(c=Math.min(1,u=+p),f()):c},t.paddingInner=function(p){return arguments.length?(c=Math.min(1,p),f()):c},t.paddingOuter=function(p){return arguments.length?(u=+p,f()):u},t.align=function(p){return arguments.length?(d=Math.max(0,Math.min(1,p)),f()):d},t.copy=function(){return mO(e(),[r,i]).round(l).paddingInner(c).paddingOuter(u).align(d)},ml.apply(f(),arguments)}function RX(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return RX(e())},t}function sye(){return RX(mO.apply(null,arguments).paddingInner(1))}function pO(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function OX(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Ky(){}var ry=.7,vS=1/ry,kg="\\s*([+-]?\\d+)\\s*",iy="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",dc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",oye=/^#([0-9a-f]{3,8})$/,lye=new RegExp(`^rgb\\(${kg},${kg},${kg}\\)$`),cye=new RegExp(`^rgb\\(${dc},${dc},${dc}\\)$`),uye=new RegExp(`^rgba\\(${kg},${kg},${kg},${iy}\\)$`),dye=new RegExp(`^rgba\\(${dc},${dc},${dc},${iy}\\)$`),hye=new RegExp(`^hsl\\(${iy},${dc},${dc}\\)$`),fye=new RegExp(`^hsla\\(${iy},${dc},${dc},${iy}\\)$`),J8={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};pO(Ky,ay,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:e6,formatHex:e6,formatHex8:mye,formatHsl:pye,formatRgb:t6,toString:t6});function e6(){return this.rgb().formatHex()}function mye(){return this.rgb().formatHex8()}function pye(){return LX(this).formatHsl()}function t6(){return this.rgb().formatRgb()}function ay(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=oye.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?n6(e):n===3?new Fs(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?Vw(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?Vw(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=lye.exec(t))?new Fs(e[1],e[2],e[3],1):(e=cye.exec(t))?new Fs(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=uye.exec(t))?Vw(e[1],e[2],e[3],e[4]):(e=dye.exec(t))?Vw(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=hye.exec(t))?a6(e[1],e[2]/100,e[3]/100,1):(e=fye.exec(t))?a6(e[1],e[2]/100,e[3]/100,e[4]):J8.hasOwnProperty(t)?n6(J8[t]):t==="transparent"?new Fs(NaN,NaN,NaN,0):null}function n6(t){return new Fs(t>>16&255,t>>8&255,t&255,1)}function Vw(t,e,n,r){return r<=0&&(t=e=n=NaN),new Fs(t,e,n,r)}function gye(t){return t instanceof Ky||(t=ay(t)),t?(t=t.rgb(),new Fs(t.r,t.g,t.b,t.opacity)):new Fs}function r3(t,e,n,r){return arguments.length===1?gye(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}pO(Fs,r3,OX(Ky,{brighter(t){return t=t==null?vS:Math.pow(vS,t),new Fs(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?ry:Math.pow(ry,t),new Fs(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Fs(Hf(this.r),Hf(this.g),Hf(this.b),wS(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:r6,formatHex:r6,formatHex8:xye,formatRgb:i6,toString:i6}));function r6(){return`#${Pf(this.r)}${Pf(this.g)}${Pf(this.b)}`}function xye(){return`#${Pf(this.r)}${Pf(this.g)}${Pf(this.b)}${Pf((isNaN(this.opacity)?1:this.opacity)*255)}`}function i6(){const t=wS(this.opacity);return`${t===1?"rgb(":"rgba("}${Hf(this.r)}, ${Hf(this.g)}, ${Hf(this.b)}${t===1?")":`, ${t})`}`}function wS(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Hf(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Pf(t){return t=Hf(t),(t<16?"0":"")+t.toString(16)}function a6(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Al(t,e,n,r)}function LX(t){if(t instanceof Al)return new Al(t.h,t.s,t.l,t.opacity);if(t instanceof Ky||(t=ay(t)),!t)return new Al;if(t instanceof Al)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),a=Math.max(e,n,r),o=NaN,l=a-i,c=(a+i)/2;return l?(e===a?o=(n-r)/l+(n<r)*6:n===a?o=(r-e)/l+2:o=(e-n)/l+4,l/=c<.5?a+i:2-a-i,o*=60):l=c>0&&c<1?0:o,new Al(o,l,c,t.opacity)}function bye(t,e,n,r){return arguments.length===1?LX(t):new Al(t,e,n,r??1)}function Al(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}pO(Al,bye,OX(Ky,{brighter(t){return t=t==null?vS:Math.pow(vS,t),new Al(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?ry:Math.pow(ry,t),new Al(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(mA(t>=240?t-240:t+120,i,r),mA(t,i,r),mA(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Al(s6(this.h),Gw(this.s),Gw(this.l),wS(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=wS(this.opacity);return`${t===1?"hsl(":"hsla("}${s6(this.h)}, ${Gw(this.s)*100}%, ${Gw(this.l)*100}%${t===1?")":`, ${t})`}`}}));function s6(t){return t=(t||0)%360,t<0?t+360:t}function Gw(t){return Math.max(0,Math.min(1,t||0))}function mA(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 gO=t=>()=>t;function yye(t,e){return function(n){return t+n*e}}function vye(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 wye(t){return(t=+t)==1?FX:function(e,n){return n-e?vye(e,n,t):gO(isNaN(e)?n:e)}}function FX(t,e){var n=e-t;return n?yye(t,n):gO(isNaN(t)?e:t)}const o6=(function t(e){var n=wye(e);function r(i,a){var o=n((i=r3(i)).r,(a=r3(a)).r),l=n(i.g,a.g),c=n(i.b,a.b),u=FX(i.opacity,a.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 _ye(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=t[i]*(1-a)+e[i]*a;return r}}function Sye(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Nye(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),a=new Array(n),o;for(o=0;o<r;++o)i[o]=_x(t[o],e[o]);for(;o<n;++o)a[o]=e[o];return function(l){for(o=0;o<r;++o)a[o]=i[o](l);return a}}function Mye(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function _S(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Eye(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]=_x(t[i],e[i]):r[i]=e[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var i3=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,pA=new RegExp(i3.source,"g");function kye(t){return function(){return t}}function Tye(t){return function(e){return t(e)+""}}function Aye(t,e){var n=i3.lastIndex=pA.lastIndex=0,r,i,a,o=-1,l=[],c=[];for(t=t+"",e=e+"";(r=i3.exec(t))&&(i=pA.exec(e));)(a=i.index)>n&&(a=e.slice(n,a),l[o]?l[o]+=a:l[++o]=a),(r=r[0])===(i=i[0])?l[o]?l[o]+=i:l[++o]=i:(l[++o]=null,c.push({i:o,x:_S(r,i)})),n=pA.lastIndex;return n<e.length&&(a=e.slice(n),l[o]?l[o]+=a:l[++o]=a),l.length<2?c[0]?Tye(c[0].x):kye(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 _x(t,e){var n=typeof e,r;return e==null||n==="boolean"?gO(e):(n==="number"?_S:n==="string"?(r=ay(e))?(e=r,o6):Aye:e instanceof ay?o6:e instanceof Date?Mye:Sye(e)?_ye:Array.isArray(e)?Nye:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Eye:_S)(t,e)}function xO(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function Cye(t,e){e===void 0&&(e=t,t=_x);for(var n=0,r=e.length-1,i=e[0],a=new Array(r<0?0:r);n<r;)a[n]=t(i,i=e[++n]);return function(o){var l=Math.max(0,Math.min(r-1,Math.floor(o*=r)));return a[l](o-l)}}function jye(t){return function(){return t}}function SS(t){return+t}var l6=[0,1];function fs(t){return t}function a3(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:jye(isNaN(e)?NaN:.5)}function Pye(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function Dye(t,e,n){var r=t[0],i=t[1],a=e[0],o=e[1];return i<r?(r=a3(i,r),a=n(o,a)):(r=a3(r,i),a=n(a,o)),function(l){return a(r(l))}}function Rye(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),a=new Array(r),o=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++o<r;)i[o]=a3(t[o],t[o+1]),a[o]=n(e[o],e[o+1]);return function(l){var c=Wy(t,l,1,r)-1;return a[c](i[c](l))}}function Xy(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function z2(){var t=l6,e=l6,n=_x,r,i,a,o=fs,l,c,u;function d(){var p=Math.min(t.length,e.length);return o!==fs&&(o=Pye(t[0],t[p-1])),l=p>2?Rye:Dye,c=u=null,f}function f(p){return p==null||isNaN(p=+p)?a:(c||(c=l(t.map(r),e,n)))(r(o(p)))}return f.invert=function(p){return o(i((u||(u=l(e,t.map(r),_S)))(p)))},f.domain=function(p){return arguments.length?(t=Array.from(p,SS),d()):t.slice()},f.range=function(p){return arguments.length?(e=Array.from(p),d()):e.slice()},f.rangeRound=function(p){return e=Array.from(p),n=xO,d()},f.clamp=function(p){return arguments.length?(o=p?!0:fs,d()):o!==fs},f.interpolate=function(p){return arguments.length?(n=p,d()):n},f.unknown=function(p){return arguments.length?(a=p,f):a},function(p,m){return r=p,i=m,d()}}function bO(){return z2()(fs,fs)}function Oye(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function NS(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 Kg(t){return t=NS(Math.abs(t)),t?t[1]:NaN}function Lye(t,e){return function(n,r){for(var i=n.length,a=[],o=0,l=t[0],c=0;i>0&&l>0&&(c+l+1>r&&(l=Math.max(1,r-c)),a.push(n.substring(i-=l,i+l)),!((c+=l+1)>r));)l=t[o=(o+1)%t.length];return a.reverse().join(e)}}function Fye(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var Iye=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function sy(t){if(!(e=Iye.exec(t)))throw new Error("invalid format: "+t);var e;return new yO({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]})}sy.prototype=yO.prototype;function yO(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+""}yO.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 Uye(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 IX;function zye(t,e){var n=NS(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(IX=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+new Array(a-o+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+NS(t,Math.max(0,e+a-1))[0]}function c6(t,e){var n=NS(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 u6={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Oye,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)=>c6(t*100,e),r:c6,s:zye,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function d6(t){return t}var h6=Array.prototype.map,f6=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Bye(t){var e=t.grouping===void 0||t.thousands===void 0?d6:Lye(h6.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",i=t.decimal===void 0?".":t.decimal+"",a=t.numerals===void 0?d6:Fye(h6.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=sy(f);var p=f.fill,m=f.align,x=f.sign,b=f.symbol,y=f.zero,v=f.width,S=f.comma,M=f.precision,T=f.trim,E=f.type;E==="n"?(S=!0,E="g"):u6[E]||(M===void 0&&(M=12),T=!0,E="g"),(y||p==="0"&&m==="=")&&(y=!0,p="0",m="=");var C=b==="$"?n:b==="#"&&/[boxX]/.test(E)?"0"+E.toLowerCase():"",k=b==="$"?r:/[%p]/.test(E)?o:"",R=u6[E],A=/[defgprs%]/.test(E);M=M===void 0?6:/[gprs]/.test(E)?Math.max(1,Math.min(21,M)):Math.max(0,Math.min(20,M));function D(U){var F=C,H=k,j,$,K;if(E==="c")H=R(U)+H,U="";else{U=+U;var V=U<0||1/U<0;if(U=isNaN(U)?c:R(Math.abs(U),M),T&&(U=Uye(U)),V&&+U==0&&x!=="+"&&(V=!1),F=(V?x==="("?x:l:x==="-"||x==="("?"":x)+F,H=(E==="s"?f6[8+IX/3]:"")+H+(V&&x==="("?")":""),A){for(j=-1,$=U.length;++j<$;)if(K=U.charCodeAt(j),48>K||K>57){H=(K===46?i+U.slice(j+1):U.slice(j))+H,U=U.slice(0,j);break}}}S&&!y&&(U=e(U,1/0));var Q=F.length+U.length+H.length,Z=Q<v?new Array(v-Q+1).join(p):"";switch(S&&y&&(U=e(Z+U,Z.length?v-H.length:1/0),Z=""),m){case"<":U=F+U+H+Z;break;case"=":U=F+Z+U+H;break;case"^":U=Z.slice(0,Q=Z.length>>1)+F+U+H+Z.slice(Q);break;default:U=Z+F+U+H;break}return a(U)}return D.toString=function(){return f+""},D}function d(f,p){var m=u((f=sy(f),f.type="f",f)),x=Math.max(-8,Math.min(8,Math.floor(Kg(p)/3)))*3,b=Math.pow(10,-x),y=f6[8+x/3];return function(v){return m(b*v)+y}}return{format:u,formatPrefix:d}}var qw,vO,UX;$ye({thousands:",",grouping:[3],currency:["$",""]});function $ye(t){return qw=Bye(t),vO=qw.format,UX=qw.formatPrefix,qw}function Hye(t){return Math.max(0,-Kg(Math.abs(t)))}function Vye(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Kg(e)/3)))*3-Kg(Math.abs(t)))}function Gye(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Kg(e)-Kg(t))+1}function zX(t,e,n,r){var i=t3(t,e,n),a;switch(r=sy(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(a=Vye(i,o))&&(r.precision=a),UX(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=Gye(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=Hye(i))&&(r.precision=a-(r.type==="%")*2);break}}return vO(r)}function Fh(t){var e=t.domain;return t.ticks=function(n){var r=e();return JP(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return zX(i[0],i[i.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),i=0,a=r.length-1,o=r[i],l=r[a],c,u,d=10;for(l<o&&(u=o,o=l,l=u,u=i,i=a,a=u);d-- >0;){if(u=e3(o,l,n),u===c)return r[i]=o,r[a]=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 BX(){var t=bO();return t.copy=function(){return Xy(t,BX())},ml.apply(t,arguments),Fh(t)}function $X(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,SS),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return $X(t).unknown(e)},t=arguments.length?Array.from(t,SS):[0,1],Fh(n)}function HX(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],a=t[r],o;return a<i&&(o=n,n=r,r=o,o=i,i=a,a=o),t[n]=e.floor(i),t[r]=e.ceil(a),t}function m6(t){return Math.log(t)}function p6(t){return Math.exp(t)}function qye(t){return-Math.log(-t)}function Wye(t){return-Math.exp(-t)}function Kye(t){return isFinite(t)?+("1e"+t):t<0?0:t}function Xye(t){return t===10?Kye:t===Math.E?Math.exp:e=>Math.pow(t,e)}function Yye(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 g6(t){return(e,n)=>-t(-e,n)}function wO(t){const e=t(m6,p6),n=e.domain;let r=10,i,a;function o(){return i=Yye(r),a=Xye(r),n()[0]<0?(i=g6(i),a=g6(a),t(qye,Wye)):t(m6,p6),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 p=i(u),m=i(d),x,b;const y=l==null?10:+l;let v=[];if(!(r%1)&&m-p<y){if(p=Math.floor(p),m=Math.ceil(m),u>0){for(;p<=m;++p)for(x=1;x<r;++x)if(b=p<0?x/a(-p):x*a(p),!(b<u)){if(b>d)break;v.push(b)}}else for(;p<=m;++p)for(x=r-1;x>=1;--x)if(b=p>0?x/a(-p):x*a(p),!(b<u)){if(b>d)break;v.push(b)}v.length*2<y&&(v=JP(u,d,y))}else v=JP(p,m,Math.min(m-p,y)).map(a);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=sy(c)).precision==null&&(c.trim=!0),c=vO(c)),l===1/0)return c;const u=Math.max(1,r*l/e.ticks().length);return d=>{let f=d/a(Math.round(i(d)));return f*r<r-.5&&(f*=r),f<=u?c(d):""}},e.nice=()=>n(HX(n(),{floor:l=>a(Math.floor(i(l))),ceil:l=>a(Math.ceil(i(l)))})),e}function VX(){const t=wO(z2()).domain([1,10]);return t.copy=()=>Xy(t,VX()).base(t.base()),ml.apply(t,arguments),t}function x6(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function b6(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function _O(t){var e=1,n=t(x6(e),b6(e));return n.constant=function(r){return arguments.length?t(x6(e=+r),b6(e)):e},Fh(n)}function GX(){var t=_O(z2());return t.copy=function(){return Xy(t,GX()).constant(t.constant())},ml.apply(t,arguments)}function y6(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function Qye(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function Zye(t){return t<0?-t*t:t*t}function SO(t){var e=t(fs,fs),n=1;function r(){return n===1?t(fs,fs):n===.5?t(Qye,Zye):t(y6(n),y6(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},Fh(e)}function NO(){var t=SO(z2());return t.copy=function(){return Xy(t,NO()).exponent(t.exponent())},ml.apply(t,arguments),t}function Jye(){return NO.apply(null,arguments).exponent(.5)}function v6(t){return Math.sign(t)*t*t}function eve(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function qX(){var t=bO(),e=[0,1],n=!1,r;function i(a){var o=eve(t(a));return isNaN(o)?r:n?Math.round(o):o}return i.invert=function(a){return t.invert(v6(a))},i.domain=function(a){return arguments.length?(t.domain(a),i):t.domain()},i.range=function(a){return arguments.length?(t.range((e=Array.from(a,SS)).map(v6)),i):e.slice()},i.rangeRound=function(a){return i.range(a).round(!0)},i.round=function(a){return arguments.length?(n=!!a,i):n},i.clamp=function(a){return arguments.length?(t.clamp(a),i):t.clamp()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return qX(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},ml.apply(i,arguments),Fh(i)}function WX(){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]=iye(t,o/l);return a}function a(o){return o==null||isNaN(o=+o)?r:e[Wy(n,o)]}return a.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]]},a.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(oh),i()},a.range=function(o){return arguments.length?(e=Array.from(o),i()):e.slice()},a.unknown=function(o){return arguments.length?(r=o,a):r},a.quantiles=function(){return n.slice()},a.copy=function(){return WX().domain(t).range(e).unknown(r)},ml.apply(a,arguments)}function KX(){var t=0,e=1,n=1,r=[.5],i=[0,1],a;function o(c){return c!=null&&c<=c?i[Wy(r,c,0,n)]:a}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&&(a=c),o},o.thresholds=function(){return r.slice()},o.copy=function(){return KX().domain([t,e]).range(i).unknown(a)},ml.apply(Fh(o),arguments)}function XX(){var t=[.5],e=[0,1],n,r=1;function i(a){return a!=null&&a<=a?e[Wy(t,a,0,r)]:n}return i.domain=function(a){return arguments.length?(t=Array.from(a),r=Math.min(t.length,e.length-1),i):t.slice()},i.range=function(a){return arguments.length?(e=Array.from(a),r=Math.min(t.length,e.length-1),i):e.slice()},i.invertExtent=function(a){var o=e.indexOf(a);return[t[o-1],t[o]]},i.unknown=function(a){return arguments.length?(n=a,i):n},i.copy=function(){return XX().domain(t).range(e).unknown(n)},ml.apply(i,arguments)}const gA=new Date,xA=new Date;function ia(t,e,n,r){function i(a){return t(a=arguments.length===0?new Date:new Date(+a)),a}return i.floor=a=>(t(a=new Date(+a)),a),i.ceil=a=>(t(a=new Date(a-1)),e(a,1),t(a),a),i.round=a=>{const o=i(a),l=i.ceil(a);return a-o<l-a?o:l},i.offset=(a,o)=>(e(a=new Date(+a),o==null?1:Math.floor(o)),a),i.range=(a,o,l)=>{const c=[];if(a=i.ceil(a),l=l==null?1:Math.floor(l),!(a<o)||!(l>0))return c;let u;do c.push(u=new Date(+a)),e(a,l),t(a);while(u<a&&a<o);return c},i.filter=a=>ia(o=>{if(o>=o)for(;t(o),!a(o);)o.setTime(o-1)},(o,l)=>{if(o>=o)if(l<0)for(;++l<=0;)for(;e(o,-1),!a(o););else for(;--l>=0;)for(;e(o,1),!a(o););}),n&&(i.count=(a,o)=>(gA.setTime(+a),xA.setTime(+o),t(gA),t(xA),Math.floor(n(gA,xA))),i.every=a=>(a=Math.floor(a),!isFinite(a)||!(a>0)?null:a>1?i.filter(r?o=>r(o)%a===0:o=>i.count(0,o)%a===0):i)),i}const MS=ia(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);MS.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?ia(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):MS);MS.range;const bu=1e3,Jo=bu*60,yu=Jo*60,Iu=yu*24,MO=Iu*7,w6=Iu*30,bA=Iu*365,Df=ia(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*bu)},(t,e)=>(e-t)/bu,t=>t.getUTCSeconds());Df.range;const EO=ia(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*bu)},(t,e)=>{t.setTime(+t+e*Jo)},(t,e)=>(e-t)/Jo,t=>t.getMinutes());EO.range;const kO=ia(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*Jo)},(t,e)=>(e-t)/Jo,t=>t.getUTCMinutes());kO.range;const TO=ia(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*bu-t.getMinutes()*Jo)},(t,e)=>{t.setTime(+t+e*yu)},(t,e)=>(e-t)/yu,t=>t.getHours());TO.range;const AO=ia(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*yu)},(t,e)=>(e-t)/yu,t=>t.getUTCHours());AO.range;const Yy=ia(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Jo)/Iu,t=>t.getDate()-1);Yy.range;const B2=ia(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Iu,t=>t.getUTCDate()-1);B2.range;const YX=ia(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Iu,t=>Math.floor(t/Iu));YX.range;function Tm(t){return ia(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)/MO)}const $2=Tm(0),ES=Tm(1),tve=Tm(2),nve=Tm(3),Xg=Tm(4),rve=Tm(5),ive=Tm(6);$2.range;ES.range;tve.range;nve.range;Xg.range;rve.range;ive.range;function Am(t){return ia(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)/MO)}const H2=Am(0),kS=Am(1),ave=Am(2),sve=Am(3),Yg=Am(4),ove=Am(5),lve=Am(6);H2.range;kS.range;ave.range;sve.range;Yg.range;ove.range;lve.range;const CO=ia(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());CO.range;const jO=ia(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());jO.range;const Uu=ia(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());Uu.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:ia(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)});Uu.range;const zu=ia(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());zu.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:ia(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)});zu.range;function QX(t,e,n,r,i,a){const o=[[Df,1,bu],[Df,5,5*bu],[Df,15,15*bu],[Df,30,30*bu],[a,1,Jo],[a,5,5*Jo],[a,15,15*Jo],[a,30,30*Jo],[i,1,yu],[i,3,3*yu],[i,6,6*yu],[i,12,12*yu],[r,1,Iu],[r,2,2*Iu],[n,1,MO],[e,1,w6],[e,3,3*w6],[t,1,bA]];function l(u,d,f){const p=d<u;p&&([u,d]=[d,u]);const m=f&&typeof f.range=="function"?f:c(u,d,f),x=m?m.range(u,+d+1):[];return p?x.reverse():x}function c(u,d,f){const p=Math.abs(d-u)/f,m=hO(([,,y])=>y).right(o,p);if(m===o.length)return t.every(t3(u/bA,d/bA,f));if(m===0)return MS.every(Math.max(t3(u,d,f),1));const[x,b]=o[p/o[m-1][2]<o[m][2]/p?m-1:m];return x.every(b)}return[l,c]}const[cve,uve]=QX(zu,jO,H2,YX,AO,kO),[dve,hve]=QX(Uu,CO,$2,Yy,TO,EO);function yA(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 vA(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 Ob(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function fve(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,a=t.days,o=t.shortDays,l=t.months,c=t.shortMonths,u=Lb(i),d=Fb(i),f=Lb(a),p=Fb(a),m=Lb(o),x=Fb(o),b=Lb(l),y=Fb(l),v=Lb(c),S=Fb(c),M={a:V,A:Q,b:Z,B:ae,c:null,d:k6,e:k6,f:Lve,g:qve,G:Kve,H:Dve,I:Rve,j:Ove,L:ZX,m:Fve,M:Ive,p:B,q:X,Q:C6,s:j6,S:Uve,u:zve,U:Bve,V:$ve,w:Hve,W:Vve,x:null,X:null,y:Gve,Y:Wve,Z:Xve,"%":A6},T={a:ne,A:se,b:be,B:xe,c:null,d:T6,e:T6,f:Jve,g:cwe,G:dwe,H:Yve,I:Qve,j:Zve,L:eY,m:ewe,M:twe,p:de,q:Pe,Q:C6,s:j6,S:nwe,u:rwe,U:iwe,V:awe,w:swe,W:owe,x:null,X:null,y:lwe,Y:uwe,Z:hwe,"%":A6},E={a:D,A:U,b:F,B:H,c:j,d:M6,e:M6,f:Ave,g:N6,G:S6,H:E6,I:E6,j:Mve,L:Tve,m:Nve,M:Eve,p:A,q:Sve,Q:jve,s:Pve,S:kve,u:bve,U:yve,V:vve,w:xve,W:wve,x:$,X:K,y:N6,Y:S6,Z:_ve,"%":Cve};M.x=C(n,M),M.X=C(r,M),M.c=C(e,M),T.x=C(n,T),T.X=C(r,T),T.c=C(e,T);function C(ie,Me){return function(Oe){var ge=[],Ke=-1,G=0,Y=ie.length,ce,q,te;for(Oe instanceof Date||(Oe=new Date(+Oe));++Ke<Y;)ie.charCodeAt(Ke)===37&&(ge.push(ie.slice(G,Ke)),(q=_6[ce=ie.charAt(++Ke)])!=null?ce=ie.charAt(++Ke):q=ce==="e"?" ":"0",(te=Me[ce])&&(ce=te(Oe,q)),ge.push(ce),G=Ke+1);return ge.push(ie.slice(G,Ke)),ge.join("")}}function k(ie,Me){return function(Oe){var ge=Ob(1900,void 0,1),Ke=R(ge,ie,Oe+="",0),G,Y;if(Ke!=Oe.length)return null;if("Q"in ge)return new Date(ge.Q);if("s"in ge)return new Date(ge.s*1e3+("L"in ge?ge.L:0));if(Me&&!("Z"in ge)&&(ge.Z=0),"p"in ge&&(ge.H=ge.H%12+ge.p*12),ge.m===void 0&&(ge.m="q"in ge?ge.q:0),"V"in ge){if(ge.V<1||ge.V>53)return null;"w"in ge||(ge.w=1),"Z"in ge?(G=vA(Ob(ge.y,0,1)),Y=G.getUTCDay(),G=Y>4||Y===0?kS.ceil(G):kS(G),G=B2.offset(G,(ge.V-1)*7),ge.y=G.getUTCFullYear(),ge.m=G.getUTCMonth(),ge.d=G.getUTCDate()+(ge.w+6)%7):(G=yA(Ob(ge.y,0,1)),Y=G.getDay(),G=Y>4||Y===0?ES.ceil(G):ES(G),G=Yy.offset(G,(ge.V-1)*7),ge.y=G.getFullYear(),ge.m=G.getMonth(),ge.d=G.getDate()+(ge.w+6)%7)}else("W"in ge||"U"in ge)&&("w"in ge||(ge.w="u"in ge?ge.u%7:"W"in ge?1:0),Y="Z"in ge?vA(Ob(ge.y,0,1)).getUTCDay():yA(Ob(ge.y,0,1)).getDay(),ge.m=0,ge.d="W"in ge?(ge.w+6)%7+ge.W*7-(Y+5)%7:ge.w+ge.U*7-(Y+6)%7);return"Z"in ge?(ge.H+=ge.Z/100|0,ge.M+=ge.Z%100,vA(ge)):yA(ge)}}function R(ie,Me,Oe,ge){for(var Ke=0,G=Me.length,Y=Oe.length,ce,q;Ke<G;){if(ge>=Y)return-1;if(ce=Me.charCodeAt(Ke++),ce===37){if(ce=Me.charAt(Ke++),q=E[ce in _6?Me.charAt(Ke++):ce],!q||(ge=q(ie,Oe,ge))<0)return-1}else if(ce!=Oe.charCodeAt(ge++))return-1}return ge}function A(ie,Me,Oe){var ge=u.exec(Me.slice(Oe));return ge?(ie.p=d.get(ge[0].toLowerCase()),Oe+ge[0].length):-1}function D(ie,Me,Oe){var ge=m.exec(Me.slice(Oe));return ge?(ie.w=x.get(ge[0].toLowerCase()),Oe+ge[0].length):-1}function U(ie,Me,Oe){var ge=f.exec(Me.slice(Oe));return ge?(ie.w=p.get(ge[0].toLowerCase()),Oe+ge[0].length):-1}function F(ie,Me,Oe){var ge=v.exec(Me.slice(Oe));return ge?(ie.m=S.get(ge[0].toLowerCase()),Oe+ge[0].length):-1}function H(ie,Me,Oe){var ge=b.exec(Me.slice(Oe));return ge?(ie.m=y.get(ge[0].toLowerCase()),Oe+ge[0].length):-1}function j(ie,Me,Oe){return R(ie,e,Me,Oe)}function $(ie,Me,Oe){return R(ie,n,Me,Oe)}function K(ie,Me,Oe){return R(ie,r,Me,Oe)}function V(ie){return o[ie.getDay()]}function Q(ie){return a[ie.getDay()]}function Z(ie){return c[ie.getMonth()]}function ae(ie){return l[ie.getMonth()]}function B(ie){return i[+(ie.getHours()>=12)]}function X(ie){return 1+~~(ie.getMonth()/3)}function ne(ie){return o[ie.getUTCDay()]}function se(ie){return a[ie.getUTCDay()]}function be(ie){return c[ie.getUTCMonth()]}function xe(ie){return l[ie.getUTCMonth()]}function de(ie){return i[+(ie.getUTCHours()>=12)]}function Pe(ie){return 1+~~(ie.getUTCMonth()/3)}return{format:function(ie){var Me=C(ie+="",M);return Me.toString=function(){return ie},Me},parse:function(ie){var Me=k(ie+="",!1);return Me.toString=function(){return ie},Me},utcFormat:function(ie){var Me=C(ie+="",T);return Me.toString=function(){return ie},Me},utcParse:function(ie){var Me=k(ie+="",!0);return Me.toString=function(){return ie},Me}}}var _6={"-":"",_:" ",0:"0"},Sa=/^\s*\d+/,mve=/^%/,pve=/[\\^$*+?|[\]().{}]/g;function or(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",a=i.length;return r+(a<n?new Array(n-a+1).join(e)+i:i)}function gve(t){return t.replace(pve,"\\$&")}function Lb(t){return new RegExp("^(?:"+t.map(gve).join("|")+")","i")}function Fb(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function xve(t,e,n){var r=Sa.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function bve(t,e,n){var r=Sa.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function yve(t,e,n){var r=Sa.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function vve(t,e,n){var r=Sa.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function wve(t,e,n){var r=Sa.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function S6(t,e,n){var r=Sa.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function N6(t,e,n){var r=Sa.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function _ve(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 Sve(t,e,n){var r=Sa.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function Nve(t,e,n){var r=Sa.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function M6(t,e,n){var r=Sa.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Mve(t,e,n){var r=Sa.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function E6(t,e,n){var r=Sa.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function Eve(t,e,n){var r=Sa.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function kve(t,e,n){var r=Sa.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Tve(t,e,n){var r=Sa.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Ave(t,e,n){var r=Sa.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Cve(t,e,n){var r=mve.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function jve(t,e,n){var r=Sa.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Pve(t,e,n){var r=Sa.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function k6(t,e){return or(t.getDate(),e,2)}function Dve(t,e){return or(t.getHours(),e,2)}function Rve(t,e){return or(t.getHours()%12||12,e,2)}function Ove(t,e){return or(1+Yy.count(Uu(t),t),e,3)}function ZX(t,e){return or(t.getMilliseconds(),e,3)}function Lve(t,e){return ZX(t,e)+"000"}function Fve(t,e){return or(t.getMonth()+1,e,2)}function Ive(t,e){return or(t.getMinutes(),e,2)}function Uve(t,e){return or(t.getSeconds(),e,2)}function zve(t){var e=t.getDay();return e===0?7:e}function Bve(t,e){return or($2.count(Uu(t)-1,t),e,2)}function JX(t){var e=t.getDay();return e>=4||e===0?Xg(t):Xg.ceil(t)}function $ve(t,e){return t=JX(t),or(Xg.count(Uu(t),t)+(Uu(t).getDay()===4),e,2)}function Hve(t){return t.getDay()}function Vve(t,e){return or(ES.count(Uu(t)-1,t),e,2)}function Gve(t,e){return or(t.getFullYear()%100,e,2)}function qve(t,e){return t=JX(t),or(t.getFullYear()%100,e,2)}function Wve(t,e){return or(t.getFullYear()%1e4,e,4)}function Kve(t,e){var n=t.getDay();return t=n>=4||n===0?Xg(t):Xg.ceil(t),or(t.getFullYear()%1e4,e,4)}function Xve(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+or(e/60|0,"0",2)+or(e%60,"0",2)}function T6(t,e){return or(t.getUTCDate(),e,2)}function Yve(t,e){return or(t.getUTCHours(),e,2)}function Qve(t,e){return or(t.getUTCHours()%12||12,e,2)}function Zve(t,e){return or(1+B2.count(zu(t),t),e,3)}function eY(t,e){return or(t.getUTCMilliseconds(),e,3)}function Jve(t,e){return eY(t,e)+"000"}function ewe(t,e){return or(t.getUTCMonth()+1,e,2)}function twe(t,e){return or(t.getUTCMinutes(),e,2)}function nwe(t,e){return or(t.getUTCSeconds(),e,2)}function rwe(t){var e=t.getUTCDay();return e===0?7:e}function iwe(t,e){return or(H2.count(zu(t)-1,t),e,2)}function tY(t){var e=t.getUTCDay();return e>=4||e===0?Yg(t):Yg.ceil(t)}function awe(t,e){return t=tY(t),or(Yg.count(zu(t),t)+(zu(t).getUTCDay()===4),e,2)}function swe(t){return t.getUTCDay()}function owe(t,e){return or(kS.count(zu(t)-1,t),e,2)}function lwe(t,e){return or(t.getUTCFullYear()%100,e,2)}function cwe(t,e){return t=tY(t),or(t.getUTCFullYear()%100,e,2)}function uwe(t,e){return or(t.getUTCFullYear()%1e4,e,4)}function dwe(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Yg(t):Yg.ceil(t),or(t.getUTCFullYear()%1e4,e,4)}function hwe(){return"+0000"}function A6(){return"%"}function C6(t){return+t}function j6(t){return Math.floor(+t/1e3)}var xp,nY,rY;fwe({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 fwe(t){return xp=fve(t),nY=xp.format,xp.parse,rY=xp.utcFormat,xp.utcParse,xp}function mwe(t){return new Date(t)}function pwe(t){return t instanceof Date?+t:+new Date(+t)}function PO(t,e,n,r,i,a,o,l,c,u){var d=bO(),f=d.invert,p=d.domain,m=u(".%L"),x=u(":%S"),b=u("%I:%M"),y=u("%I %p"),v=u("%a %d"),S=u("%b %d"),M=u("%B"),T=u("%Y");function E(C){return(c(C)<C?m:l(C)<C?x:o(C)<C?b:a(C)<C?y:r(C)<C?i(C)<C?v:S:n(C)<C?M:T)(C)}return d.invert=function(C){return new Date(f(C))},d.domain=function(C){return arguments.length?p(Array.from(C,pwe)):p().map(mwe)},d.ticks=function(C){var k=p();return t(k[0],k[k.length-1],C??10)},d.tickFormat=function(C,k){return k==null?E:u(k)},d.nice=function(C){var k=p();return(!C||typeof C.range!="function")&&(C=e(k[0],k[k.length-1],C??10)),C?p(HX(k,C)):d},d.copy=function(){return Xy(d,PO(t,e,n,r,i,a,o,l,c,u))},d}function gwe(){return ml.apply(PO(dve,hve,Uu,CO,$2,Yy,TO,EO,Df,nY).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function xwe(){return ml.apply(PO(cve,uve,zu,jO,H2,B2,AO,kO,Df,rY).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function V2(){var t=0,e=1,n,r,i,a,o=fs,l=!1,c;function u(f){return f==null||isNaN(f=+f)?c:o(i===0?.5:(f=(a(f)-n)*i,l?Math.max(0,Math.min(1,f)):f))}u.domain=function(f){return arguments.length?([t,e]=f,n=a(t=+t),r=a(e=+e),i=n===r?0:1/(r-n),u):[t,e]},u.clamp=function(f){return arguments.length?(l=!!f,u):l},u.interpolator=function(f){return arguments.length?(o=f,u):o};function d(f){return function(p){var m,x;return arguments.length?([m,x]=p,o=f(m,x),u):[o(0),o(1)]}}return u.range=d(_x),u.rangeRound=d(xO),u.unknown=function(f){return arguments.length?(c=f,u):c},function(f){return a=f,n=f(t),r=f(e),i=n===r?0:1/(r-n),u}}function Ih(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function iY(){var t=Fh(V2()(fs));return t.copy=function(){return Ih(t,iY())},Ku.apply(t,arguments)}function aY(){var t=wO(V2()).domain([1,10]);return t.copy=function(){return Ih(t,aY()).base(t.base())},Ku.apply(t,arguments)}function sY(){var t=_O(V2());return t.copy=function(){return Ih(t,sY()).constant(t.constant())},Ku.apply(t,arguments)}function DO(){var t=SO(V2());return t.copy=function(){return Ih(t,DO()).exponent(t.exponent())},Ku.apply(t,arguments)}function bwe(){return DO.apply(null,arguments).exponent(.5)}function oY(){var t=[],e=fs;function n(r){if(r!=null&&!isNaN(r=+r))return e((Wy(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(oh),n},n.interpolator=function(r){return arguments.length?(e=r,n):e},n.range=function(){return t.map((r,i)=>e(i/(t.length-1)))},n.quantiles=function(r){return Array.from({length:r+1},(i,a)=>rye(t,a/r))},n.copy=function(){return oY(e).domain(t)},Ku.apply(n,arguments)}function G2(){var t=0,e=.5,n=1,r=1,i,a,o,l,c,u=fs,d,f=!1,p;function m(b){return isNaN(b=+b)?p:(b=.5+((b=+d(b))-a)*(r*b<r*a?l:c),u(f?Math.max(0,Math.min(1,b)):b))}m.domain=function(b){return arguments.length?([t,e,n]=b,i=d(t=+t),a=d(e=+e),o=d(n=+n),l=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,m):[t,e,n]},m.clamp=function(b){return arguments.length?(f=!!b,m):f},m.interpolator=function(b){return arguments.length?(u=b,m):u};function x(b){return function(y){var v,S,M;return arguments.length?([v,S,M]=y,u=Cye(b,[v,S,M]),m):[u(0),u(.5),u(1)]}}return m.range=x(_x),m.rangeRound=x(xO),m.unknown=function(b){return arguments.length?(p=b,m):p},function(b){return d=b,i=b(t),a=b(e),o=b(n),l=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,m}}function lY(){var t=Fh(G2()(fs));return t.copy=function(){return Ih(t,lY())},Ku.apply(t,arguments)}function cY(){var t=wO(G2()).domain([.1,1,10]);return t.copy=function(){return Ih(t,cY()).base(t.base())},Ku.apply(t,arguments)}function uY(){var t=_O(G2());return t.copy=function(){return Ih(t,uY()).constant(t.constant())},Ku.apply(t,arguments)}function RO(){var t=SO(G2());return t.copy=function(){return Ih(t,RO()).exponent(t.exponent())},Ku.apply(t,arguments)}function ywe(){return RO.apply(null,arguments).exponent(.5)}const a0=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:mO,scaleDiverging:lY,scaleDivergingLog:cY,scaleDivergingPow:RO,scaleDivergingSqrt:ywe,scaleDivergingSymlog:uY,scaleIdentity:$X,scaleImplicit:n3,scaleLinear:BX,scaleLog:VX,scaleOrdinal:fO,scalePoint:sye,scalePow:NO,scaleQuantile:WX,scaleQuantize:KX,scaleRadial:qX,scaleSequential:iY,scaleSequentialLog:aY,scaleSequentialPow:DO,scaleSequentialQuantile:oY,scaleSequentialSqrt:bwe,scaleSequentialSymlog:sY,scaleSqrt:Jye,scaleSymlog:GX,scaleThreshold:XX,scaleTime:gwe,scaleUtc:xwe,tickFormat:zX},Symbol.toStringTag,{value:"Module"}));var Uh=t=>t.chartData,OO=nt([Uh],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),Qy=(t,e,n,r)=>r?OO(t):Uh(t);function _h(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(yr(e)&&yr(n))return!0}return!1}function P6(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function dY(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,a;if(yr(n))i=n;else if(typeof n=="function")return;if(yr(r))a=r;else if(typeof r=="function")return;var o=[i,a];if(_h(o))return o}}function vwe(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(_h(r))return P6(r,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[i,a]=t,o,l;if(i==="auto")e!=null&&(o=Math.min(...e));else if(zt(i))o=i;else if(typeof i=="function")try{e!=null&&(o=i(e?.[0]))}catch{}else if(typeof i=="string"&&s8.test(i)){var c=s8.exec(i);if(c==null||e==null)o=void 0;else{var u=+c[1];o=e[0]-u}}else o=e?.[0];if(a==="auto")e!=null&&(l=Math.max(...e));else if(zt(a))l=a;else if(typeof a=="function")try{e!=null&&(l=a(e?.[1]))}catch{}else if(typeof a=="string"&&o8.test(a)){var d=o8.exec(a);if(d==null||e==null)l=void 0;else{var f=+d[1];l=e[1]+f}}else l=e?.[1];var p=[o,l];if(_h(p))return e==null?p:P6(p,e,n)}}}var Sx=1e9,wwe={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},FO,ti=!0,dl="[DecimalError] ",Vf=dl+"Invalid argument: ",LO=dl+"Exponent out of range: ",Nx=Math.floor,_f=Math.pow,_we=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,co,pa=1e7,Wr=7,hY=9007199254740991,TS=Nx(hY/Wr),Ht={};Ht.absoluteValue=Ht.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};Ht.comparedTo=Ht.cmp=function(t){var e,n,r,i,a=this;if(t=new a.constructor(t),a.s!==t.s)return a.s||-t.s;if(a.e!==t.e)return a.e>t.e^a.s<0?1:-1;for(r=a.d.length,i=t.d.length,e=0,n=r<i?r:i;e<n;++e)if(a.d[e]!==t.d[e])return a.d[e]>t.d[e]^a.s<0?1:-1;return r===i?0:r>i^a.s<0?1:-1};Ht.decimalPlaces=Ht.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*Wr;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};Ht.dividedBy=Ht.div=function(t){return Eu(this,new this.constructor(t))};Ht.dividedToIntegerBy=Ht.idiv=function(t){var e=this,n=e.constructor;return Or(Eu(e,new n(t),0,1),n.precision)};Ht.equals=Ht.eq=function(t){return!this.cmp(t)};Ht.exponent=function(){return Hi(this)};Ht.greaterThan=Ht.gt=function(t){return this.cmp(t)>0};Ht.greaterThanOrEqualTo=Ht.gte=function(t){return this.cmp(t)>=0};Ht.isInteger=Ht.isint=function(){return this.e>this.d.length-2};Ht.isNegative=Ht.isneg=function(){return this.s<0};Ht.isPositive=Ht.ispos=function(){return this.s>0};Ht.isZero=function(){return this.s===0};Ht.lessThan=Ht.lt=function(t){return this.cmp(t)<0};Ht.lessThanOrEqualTo=Ht.lte=function(t){return this.cmp(t)<1};Ht.logarithm=Ht.log=function(t){var e,n=this,r=n.constructor,i=r.precision,a=i+5;if(t===void 0)t=new r(10);else if(t=new r(t),t.s<1||t.eq(co))throw Error(dl+"NaN");if(n.s<1)throw Error(dl+(n.s?"NaN":"-Infinity"));return n.eq(co)?new r(0):(ti=!1,e=Eu(oy(n,a),oy(t,a),a),ti=!0,Or(e,i))};Ht.minus=Ht.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?pY(e,t):fY(e,(t.s=-t.s,t))};Ht.modulo=Ht.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(dl+"NaN");return n.s?(ti=!1,e=Eu(n,t,0,1).times(t),ti=!0,n.minus(e)):Or(new r(n),i)};Ht.naturalExponential=Ht.exp=function(){return mY(this)};Ht.naturalLogarithm=Ht.ln=function(){return oy(this)};Ht.negated=Ht.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Ht.plus=Ht.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?fY(e,t):pY(e,(t.s=-t.s,t))};Ht.precision=Ht.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Vf+t);if(e=Hi(i)+1,r=i.d.length-1,n=r*Wr+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};Ht.squareRoot=Ht.sqrt=function(){var t,e,n,r,i,a,o,l=this,c=l.constructor;if(l.s<1){if(!l.s)return new c(0);throw Error(dl+"NaN")}for(t=Hi(l),ti=!1,i=Math.sqrt(+l),i==0||i==1/0?(e=oc(l.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=Nx((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(a=r,r=a.plus(Eu(l,a,o+2)).times(.5),oc(a.d).slice(0,o)===(e=oc(r.d)).slice(0,o)){if(e=e.slice(o-3,o+1),i==o&&e=="4999"){if(Or(a,n+1,0),a.times(a).eq(l)){r=a;break}}else if(e!="9999")break;o+=4}return ti=!0,Or(r,n)};Ht.times=Ht.mul=function(t){var e,n,r,i,a,o,l,c,u,d=this,f=d.constructor,p=d.d,m=(t=new f(t)).d;if(!d.s||!t.s)return new f(0);for(t.s*=d.s,n=d.e+t.e,c=p.length,u=m.length,c<u&&(a=p,p=m,m=a,o=c,c=u,u=o),a=[],o=c+u,r=o;r--;)a.push(0);for(r=u;--r>=0;){for(e=0,i=c+r;i>r;)l=a[i]+m[r]*p[i-r-1]+e,a[i--]=l%pa|0,e=l/pa|0;a[i]=(a[i]+e)%pa|0}for(;!a[--o];)a.pop();return e?++n:a.shift(),t.d=a,t.e=n,ti?Or(t,f.precision):t};Ht.toDecimalPlaces=Ht.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(gc(t,0,Sx),e===void 0?e=r.rounding:gc(e,0,8),Or(n,t+Hi(n)+1,e))};Ht.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=hm(r,!0):(gc(t,0,Sx),e===void 0?e=i.rounding:gc(e,0,8),r=Or(new i(r),t+1,e),n=hm(r,!0,t+1)),n};Ht.toFixed=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?hm(i):(gc(t,0,Sx),e===void 0?e=a.rounding:gc(e,0,8),r=Or(new a(i),t+Hi(i)+1,e),n=hm(r.abs(),!1,t+Hi(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};Ht.toInteger=Ht.toint=function(){var t=this,e=t.constructor;return Or(new e(t),Hi(t)+1,e.rounding)};Ht.toNumber=function(){return+this};Ht.toPower=Ht.pow=function(t){var e,n,r,i,a,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(dl+"Infinity");return l}if(l.eq(co))return l;if(r=c.precision,t.eq(co))return Or(l,r);if(e=t.e,n=t.d.length-1,o=e>=n,a=l.s,o){if((n=d<0?-d:d)<=hY){for(i=new c(co),e=Math.ceil(r/Wr+4),ti=!1;n%2&&(i=i.times(l),R6(i.d,e)),n=Nx(n/2),n!==0;)l=l.times(l),R6(l.d,e);return ti=!0,t.s<0?new c(co).div(i):Or(i,r)}}else if(a<0)throw Error(dl+"NaN");return a=a<0&&t.d[Math.max(e,n)]&1?-1:1,l.s=1,ti=!1,i=t.times(oy(l,r+u)),ti=!0,i=mY(i),i.s=a,i};Ht.toPrecision=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?(n=Hi(i),r=hm(i,n<=a.toExpNeg||n>=a.toExpPos)):(gc(t,1,Sx),e===void 0?e=a.rounding:gc(e,0,8),i=Or(new a(i),t,e),n=Hi(i),r=hm(i,t<=n||n<=a.toExpNeg,t)),r};Ht.toSignificantDigits=Ht.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(gc(t,1,Sx),e===void 0?e=r.rounding:gc(e,0,8)),Or(new r(n),t,e)};Ht.toString=Ht.valueOf=Ht.val=Ht.toJSON=Ht[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=Hi(t),n=t.constructor;return hm(t,e<=n.toExpNeg||e>=n.toExpPos)};function fY(t,e){var n,r,i,a,o,l,c,u,d=t.constructor,f=d.precision;if(!t.s||!e.s)return e.s||(e=new d(t)),ti?Or(e,f):e;if(c=t.d,u=e.d,o=t.e,i=e.e,c=c.slice(),a=o-i,a){for(a<0?(r=c,a=-a,l=u.length):(r=u,i=o,l=c.length),o=Math.ceil(f/Wr),l=o>l?o+1:l+1,a>l&&(a=l,r.length=1),r.reverse();a--;)r.push(0);r.reverse()}for(l=c.length,a=u.length,l-a<0&&(a=l,r=u,u=c,c=r),n=0;a;)n=(c[--a]=c[a]+u[a]+n)/pa|0,c[a]%=pa;for(n&&(c.unshift(n),++i),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=i,ti?Or(e,f):e}function gc(t,e,n){if(t!==~~t||t<e||t>n)throw Error(Vf+t)}function oc(t){var e,n,r,i=t.length-1,a="",o=t[0];if(i>0){for(a+=o,e=1;e<i;e++)r=t[e]+"",n=Wr-r.length,n&&(a+=Ud(n)),a+=r;o=t[e],r=o+"",n=Wr-r.length,n&&(a+=Ud(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return a+o}var Eu=(function(){function t(r,i){var a,o=0,l=r.length;for(r=r.slice();l--;)a=r[l]*i+o,r[l]=a%pa|0,o=a/pa|0;return o&&r.unshift(o),r}function e(r,i,a,o){var l,c;if(a!=o)c=a>o?1:-1;else for(l=c=0;l<a;l++)if(r[l]!=i[l]){c=r[l]>i[l]?1:-1;break}return c}function n(r,i,a){for(var o=0;a--;)r[a]-=o,o=r[a]<i[a]?1:0,r[a]=o*pa+r[a]-i[a];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,a,o){var l,c,u,d,f,p,m,x,b,y,v,S,M,T,E,C,k,R,A=r.constructor,D=r.s==i.s?1:-1,U=r.d,F=i.d;if(!r.s)return new A(r);if(!i.s)throw Error(dl+"Division by zero");for(c=r.e-i.e,k=F.length,E=U.length,m=new A(D),x=m.d=[],u=0;F[u]==(U[u]||0);)++u;if(F[u]>(U[u]||0)&&--c,a==null?S=a=A.precision:o?S=a+(Hi(r)-Hi(i))+1:S=a,S<0)return new A(0);if(S=S/Wr+2|0,u=0,k==1)for(d=0,F=F[0],S++;(u<E||d)&&S--;u++)M=d*pa+(U[u]||0),x[u]=M/F|0,d=M%F|0;else{for(d=pa/(F[0]+1)|0,d>1&&(F=t(F,d),U=t(U,d),k=F.length,E=U.length),T=k,b=U.slice(0,k),y=b.length;y<k;)b[y++]=0;R=F.slice(),R.unshift(0),C=F[0],F[1]>=pa/2&&++C;do d=0,l=e(F,b,k,y),l<0?(v=b[0],k!=y&&(v=v*pa+(b[1]||0)),d=v/C|0,d>1?(d>=pa&&(d=pa-1),f=t(F,d),p=f.length,y=b.length,l=e(f,b,p,y),l==1&&(d--,n(f,k<p?R:F,p))):(d==0&&(l=d=1),f=F.slice()),p=f.length,p<y&&f.unshift(0),n(b,f,y),l==-1&&(y=b.length,l=e(F,b,k,y),l<1&&(d++,n(b,k<y?R:F,y))),y=b.length):l===0&&(d++,b=[0]),x[u++]=d,l&&b[0]?b[y++]=U[T]||0:(b=[U[T]],y=1);while((T++<E||b[0]!==void 0)&&S--)}return x[0]||x.shift(),m.e=c,Or(m,o?a+Hi(m)+1:a)}})();function mY(t,e){var n,r,i,a,o,l,c=0,u=0,d=t.constructor,f=d.precision;if(Hi(t)>16)throw Error(LO+Hi(t));if(!t.s)return new d(co);for(ti=!1,l=f,o=new d(.03125);t.abs().gte(.1);)t=t.times(o),u+=5;for(r=Math.log(_f(2,u))/Math.LN10*2+5|0,l+=r,n=i=a=new d(co),d.precision=l;;){if(i=Or(i.times(t),l),n=n.times(++c),o=a.plus(Eu(i,n,l)),oc(o.d).slice(0,l)===oc(a.d).slice(0,l)){for(;u--;)a=Or(a.times(a),l);return d.precision=f,e==null?(ti=!0,Or(a,f)):a}a=o}}function Hi(t){for(var e=t.e*Wr,n=t.d[0];n>=10;n/=10)e++;return e}function wA(t,e,n){if(e>t.LN10.sd())throw ti=!0,n&&(t.precision=n),Error(dl+"LN10 precision limit exceeded");return Or(new t(t.LN10),e)}function Ud(t){for(var e="";t--;)e+="0";return e}function oy(t,e){var n,r,i,a,o,l,c,u,d,f=1,p=10,m=t,x=m.d,b=m.constructor,y=b.precision;if(m.s<1)throw Error(dl+(m.s?"NaN":"-Infinity"));if(m.eq(co))return new b(0);if(e==null?(ti=!1,u=y):u=e,m.eq(10))return e==null&&(ti=!0),wA(b,u);if(u+=p,b.precision=u,n=oc(x),r=n.charAt(0),a=Hi(m),Math.abs(a)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)m=m.times(t),n=oc(m.d),r=n.charAt(0),f++;a=Hi(m),r>1?(m=new b("0."+n),a++):m=new b(r+"."+n.slice(1))}else return c=wA(b,u+2,y).times(a+""),m=oy(new b(r+"."+n.slice(1)),u-p).plus(c),b.precision=y,e==null?(ti=!0,Or(m,y)):m;for(l=o=m=Eu(m.minus(co),m.plus(co),u),d=Or(m.times(m),u),i=3;;){if(o=Or(o.times(d),u),c=l.plus(Eu(o,new b(i),u)),oc(c.d).slice(0,u)===oc(l.d).slice(0,u))return l=l.times(2),a!==0&&(l=l.plus(wA(b,u+2,y).times(a+""))),l=Eu(l,new b(f),u),b.precision=y,e==null?(ti=!0,Or(l,y)):l;l=c,i+=2}}function D6(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=Nx(n/Wr),t.d=[],r=(n+1)%Wr,n<0&&(r+=Wr),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=Wr;r<i;)t.d.push(+e.slice(r,r+=Wr));e=e.slice(r),r=Wr-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),ti&&(t.e>TS||t.e<-TS))throw Error(LO+n)}else t.s=0,t.e=0,t.d=[0];return t}function Or(t,e,n){var r,i,a,o,l,c,u,d,f=t.d;for(o=1,a=f[0];a>=10;a/=10)o++;if(r=e-o,r<0)r+=Wr,i=e,u=f[d=0];else{if(d=Math.ceil((r+1)/Wr),a=f.length,d>=a)return t;for(u=a=f[d],o=1;a>=10;a/=10)o++;r%=Wr,i=r-Wr+o}if(n!==void 0&&(a=_f(10,o-i-1),l=u/a%10|0,c=e<0||f[d+1]!==void 0||u%a,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/_f(10,o-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return c?(a=Hi(t),f.length=1,e=e-a-1,f[0]=_f(10,(Wr-e%Wr)%Wr),t.e=Nx(-e/Wr)||0):(f.length=1,f[0]=t.e=t.s=0),t;if(r==0?(f.length=d,a=1,d--):(f.length=d+1,a=_f(10,Wr-r),f[d]=i>0?(u/_f(10,o-i)%_f(10,i)|0)*a:0),c)for(;;)if(d==0){(f[0]+=a)==pa&&(f[0]=1,++t.e);break}else{if(f[d]+=a,f[d]!=pa)break;f[d--]=0,a=1}for(r=f.length;f[--r]===0;)f.pop();if(ti&&(t.e>TS||t.e<-TS))throw Error(LO+Hi(t));return t}function pY(t,e){var n,r,i,a,o,l,c,u,d,f,p=t.constructor,m=p.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new p(t),ti?Or(e,m):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(m/Wr),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(a=i;a&&c[--a]===0;)c[a]=pa-1;--c[a],c[i]+=pa}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,ti?Or(e,m):e):new p(0)}function hm(t,e,n){var r,i=Hi(t),a=oc(t.d),o=a.length;return e?(n&&(r=n-o)>0?a=a.charAt(0)+"."+a.slice(1)+Ud(r):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+Ud(-i-1)+a,n&&(r=n-o)>0&&(a+=Ud(r))):i>=o?(a+=Ud(i+1-o),n&&(r=n-i-1)>0&&(a=a+"."+Ud(r))):((r=i+1)<o&&(a=a.slice(0,r)+"."+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+="."),a+=Ud(r))),t.s<0?"-"+a:a}function R6(t,e){if(t.length>e)return t.length=e,!0}function gY(t){var e,n,r;function i(a){var o=this;if(!(o instanceof i))return new i(a);if(o.constructor=i,a instanceof i){o.s=a.s,o.e=a.e,o.d=(a=a.d)?a.slice():a;return}if(typeof a=="number"){if(a*0!==0)throw Error(Vf+a);if(a>0)o.s=1;else if(a<0)a=-a,o.s=-1;else{o.s=0,o.e=0,o.d=[0];return}if(a===~~a&&a<1e7){o.e=0,o.d=[a];return}return D6(o,a.toString())}else if(typeof a!="string")throw Error(Vf+a);if(a.charCodeAt(0)===45?(a=a.slice(1),o.s=-1):o.s=1,_we.test(a))D6(o,a);else throw Error(Vf+a)}if(i.prototype=Ht,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=gY,i.config=i.set=Swe,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 Swe(t){if(!t||typeof t!="object")throw Error(dl+"Object expected");var e,n,r,i=["precision",1,Sx,"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(Nx(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(Vf+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Vf+n+": "+r);return this}var FO=gY(wwe);co=new FO(1);const xr=FO;var Nwe=t=>t,xY={},bY=t=>t===xY,O6=t=>function e(){return arguments.length===0||arguments.length===1&&bY(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},yY=(t,e)=>t===1?e:O6(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var a=r.filter(o=>o!==xY).length;return a>=t?e(...r):yY(t-a,O6(function(){for(var o=arguments.length,l=new Array(o),c=0;c<o;c++)l[c]=arguments[c];var u=r.map(d=>bY(d)?l.shift():d);return e(...u,...l)}))}),Mwe=t=>yY(t.length,t),s3=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},Ewe=Mwe((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),kwe=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return Nwe;var i=n.reverse(),a=i[0],o=i.slice(1);return function(){return o.reduce((l,c)=>c(l),a(...arguments))}},o3=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function vY(t){var e;return t===0?e=1:e=Math.floor(new xr(t).abs().log(10).toNumber())+1,e}function wY(t,e,n){for(var r=new xr(t),i=0,a=[];r.lt(e)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var _Y=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},SY=(t,e,n)=>{if(t.lte(0))return new xr(0);var r=vY(t.toNumber()),i=new xr(10).pow(r),a=t.div(i),o=r!==1?.05:.1,l=new xr(Math.ceil(a.div(o).toNumber())).add(n).mul(o),c=l.mul(i);return e?new xr(c.toNumber()):new xr(Math.ceil(c.toNumber()))},Twe=(t,e,n)=>{var r=new xr(1),i=new xr(t);if(!i.isint()&&n){var a=Math.abs(t);a<1?(r=new xr(10).pow(vY(t)-1),i=new xr(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new xr(Math.floor(t)))}else t===0?i=new xr(Math.floor((e-1)/2)):n||(i=new xr(Math.floor(t)));var o=Math.floor((e-1)/2),l=kwe(Ewe(c=>i.add(new xr(c-o).mul(r)).toNumber()),s3);return l(0,e)},NY=function(e,n,r,i){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((n-e)/(r-1)))return{step:new xr(0),tickMin:new xr(0),tickMax:new xr(0)};var o=SY(new xr(n).sub(e).div(r-1),i,a),l;e<=0&&n>=0?l=new xr(0):(l=new xr(e).add(n).div(2),l=l.sub(new xr(l).mod(o)));var c=Math.ceil(l.sub(e).div(o).toNumber()),u=Math.ceil(new xr(n).sub(l).div(o).toNumber()),d=c+u+1;return d>r?NY(e,n,r,i,a+1):(d<r&&(u=n>0?u+(r-d):u,c=n>0?c:c+(r-d)),{step:o,tickMin:l.sub(new xr(c).mul(o)),tickMax:l.add(new xr(u).mul(o))})},Awe=function(e){var[n,r]=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=Math.max(i,2),[l,c]=_Y([n,r]);if(l===-1/0||c===1/0){var u=c===1/0?[l,...s3(0,i-1).map(()=>1/0)]:[...s3(0,i-1).map(()=>-1/0),c];return n>r?o3(u):u}if(l===c)return Twe(l,i,a);var{step:d,tickMin:f,tickMax:p}=NY(l,c,o,a,0),m=wY(f,p.add(new xr(.1).mul(d)),d);return n>r?o3(m):m},Cwe=function(e,n){var[r,i]=e,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[o,l]=_Y([r,i]);if(o===-1/0||l===1/0)return[r,i];if(o===l)return[o];var c=Math.max(n,2),u=SY(new xr(l).sub(o).div(c-1),a,0),d=[...wY(new xr(o),new xr(l),u),l];return a===!1&&(d=d.map(f=>Math.round(f))),r>i?o3(d):d},MY=t=>t.rootProps.maxBarSize,jwe=t=>t.rootProps.barGap,EY=t=>t.rootProps.barCategoryGap,Pwe=t=>t.rootProps.barSize,Zy=t=>t.rootProps.stackOffset,kY=t=>t.rootProps.reverseStackOrder,IO=t=>t.options.chartName,UO=t=>t.rootProps.syncId,TY=t=>t.rootProps.syncMethod,zO=t=>t.options.eventEmitter,Dwe=t=>t.rootProps.baseValue,bi={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},hu={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},so={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},q2=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},Rwe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:hu.angleAxisId,includeHidden:!1,name:void 0,reversed:hu.reversed,scale:hu.scale,tick:hu.tick,tickCount:void 0,ticks:void 0,type:hu.type,unit:void 0},Owe={allowDataOverflow:so.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:so.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:so.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:so.scale,tick:so.tick,tickCount:so.tickCount,ticks:void 0,type:so.type,unit:void 0},Lwe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:hu.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:hu.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:hu.scale,tick:hu.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},Fwe={allowDataOverflow:so.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:so.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:so.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:so.scale,tick:so.tick,tickCount:so.tickCount,ticks:void 0,type:"category",unit:void 0},BO=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?Lwe:Rwe,$O=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?Fwe:Owe,W2=t=>t.polarOptions,HO=nt([qu,Wu,na],EX),AY=nt([W2,HO],(t,e)=>{if(t!=null)return es(t.innerRadius,e,0)}),CY=nt([W2,HO],(t,e)=>{if(t!=null)return es(t.outerRadius,e,e*.8)}),Iwe=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},jY=nt([W2],Iwe);nt([BO,jY],q2);var PY=nt([HO,AY,CY],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});nt([$O,PY],q2);var DY=nt([Vn,W2,AY,CY,qu,Wu],(t,e,n,r,i,a)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:o,cy:l,startAngle:c,endAngle:u}=e;return{cx:es(o,i,i/2),cy:es(l,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),ri=(t,e)=>e,Jy=(t,e,n)=>n;function K2(t){return t?.id}function RY(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:a}=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=K2(l);u.forEach((f,p)=>{var m=a==null||i?p:String(br(f,a,null)),x=br(f,l.dataKey,0),b;o.has(m)?b=o.get(m):b={},Object.assign(b,{[d]:x}),o.set(m,b)})}}),Array.from(o.values())}function X2(t){return t.stackId!=null&&t.dataKey!=null}var Y2=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function Q2(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function Uwe(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 aa=t=>{var e=Vn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},Mx=t=>t.tooltip.settings.axisId;function L6(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 AS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?L6(Object(n),!0).forEach(function(r){zwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):L6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function zwe(t,e,n){return(e=Bwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Bwe(t){var e=$we(t,"string");return typeof e=="symbol"?e:e+""}function $we(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 l3=[0,"auto"],fa={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},OY=(t,e)=>t.cartesianAxis.xAxis[e],kc=(t,e)=>{var n=OY(t,e);return n??fa},ma={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:l3,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:Vy},LY=(t,e)=>t.cartesianAxis.yAxis[e],Tc=(t,e)=>{var n=LY(t,e);return n??ma},Hwe={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:""},VO=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??Hwe},ci=(t,e,n)=>{switch(e){case"xAxis":return kc(t,n);case"yAxis":return Tc(t,n);case"zAxis":return VO(t,n);case"angleAxis":return BO(t,n);case"radiusAxis":return $O(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},Vwe=(t,e,n)=>{switch(e){case"xAxis":return kc(t,n);case"yAxis":return Tc(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},ev=(t,e,n)=>{switch(e){case"xAxis":return kc(t,n);case"yAxis":return Tc(t,n);case"angleAxis":return BO(t,n);case"radiusAxis":return $O(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},FY=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function GO(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 tv=t=>t.graphicalItems.cartesianItems,Gwe=nt([ri,Jy],GO),qO=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),nv=nt([tv,ci,Gwe],qO,{memoizeOptions:{resultEqualityCheck:Q2}}),IY=nt([nv],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(X2)),UY=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),qwe=nt([nv],UY),WO=t=>t.map(e=>e.data).filter(Boolean).flat(1),Wwe=nt([nv],WO,{memoizeOptions:{resultEqualityCheck:Q2}}),KO=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},XO=nt([Wwe,Qy],KO),YO=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:br(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:br(i,r)}))):t.map(r=>({value:r})),Z2=nt([XO,ci,nv],YO);function zY(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function w1(t){if(cl(t)||t instanceof Date){var e=Number(t);if(yr(e))return e}}function F6(t){if(Array.isArray(t)){var e=[w1(t[0]),w1(t[1])];return _h(e)?e:void 0}var n=w1(t);if(n!=null)return[n,n]}function Bu(t){return t.map(w1).filter(Vme)}function Kwe(t,e,n){return!n||typeof e!="number"||Hs(e)?[]:n.length?Bu(n.flatMap(r=>{var i=br(t,r.dataKey),a,o;if(Array.isArray(i)?[a,o]=i:a=o=i,!(!yr(a)||!yr(o)))return[e-a,e+o]})):[]}var sa=t=>{var e=aa(t),n=Mx(t);return ev(t,e,n)},rv=nt([sa],t=>t?.dataKey),Xwe=nt([IY,Qy,sa],RY),BY=(t,e,n,r)=>{var i={},a=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(a).map(o=>{var[l,c]=o,u=r?[...c].reverse():c,d=u.map(K2);return[l,{stackedData:mxe(t,d,n),graphicalItems:u}]}))},ly=nt([Xwe,IY,Zy,kY],BY),$Y=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=e;if(r==null&&n!=="zAxis"){var o=bxe(t,i,a);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},Ywe=nt([ci],t=>t.allowDataOverflow),QO=t=>{var e;if(t==null||!("domain"in t))return l3;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=Bu(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:l3},ZO=nt([ci],QO),JO=nt([ZO,Ywe],dY),Qwe=nt([ly,Uh,ri,JO],$Y,{memoizeOptions:{resultEqualityCheck:Y2}}),J2=t=>t.errorBars,Zwe=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>zY(n,r)),CS=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var i=n.filter(Boolean);if(i.length!==0){var a=i.flat(),o=Math.min(...a),l=Math.max(...a);return[o,l]}},e4=(t,e,n,r,i)=>{var a,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=>zY(i,v)),p=br(l,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),m=Kwe(l,p,f);if(m.length>=2){var x=Math.min(...m),b=Math.max(...m);(a==null||x<a)&&(a=x),(o==null||b>o)&&(o=b)}var y=F6(p);y!=null&&(a=a==null?y[0]:Math.min(a,y[0]),o=o==null?y[1]:Math.max(o,y[1]))})}),e?.dataKey!=null&&t.forEach(l=>{var c=F6(br(l,e.dataKey));c!=null&&(a=a==null?c[0]:Math.min(a,c[0]),o=o==null?c[1]:Math.max(o,c[1]))}),yr(a)&&yr(o))return[a,o]},Jwe=nt([XO,ci,qwe,J2,ri],e4,{memoizeOptions:{resultEqualityCheck:Y2}});function e_e(t){var{value:e}=t;if(cl(e)||e instanceof Date)return e}var t_e=(t,e,n)=>{var r=t.map(e_e).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&rK(r))?CX(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},HY=t=>t.referenceElements.dots,Ex=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),n_e=nt([HY,ri,Jy],Ex),VY=t=>t.referenceElements.areas,r_e=nt([VY,ri,Jy],Ex),GY=t=>t.referenceElements.lines,i_e=nt([GY,ri,Jy],Ex),qY=(t,e)=>{var n=Bu(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},a_e=nt(n_e,ri,qY),WY=(t,e)=>{var n=Bu(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)]},s_e=nt([r_e,ri],WY);function o_e(t){var e;if(t.x!=null)return Bu([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:Bu(n)}function l_e(t){var e;if(t.y!=null)return Bu([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:Bu(n)}var KY=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?o_e(r):l_e(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},c_e=nt([i_e,ri],KY),u_e=nt(a_e,c_e,s_e,(t,e,n)=>CS(t,n,e)),t4=(t,e,n,r,i,a,o,l)=>{if(n!=null)return n;var c=o==="vertical"&&l==="xAxis"||o==="horizontal"&&l==="yAxis",u=c?CS(r,a,i):CS(a,i);return vwe(e,u,t.allowDataOverflow)},d_e=nt([ci,ZO,JO,Qwe,Jwe,u_e,Vn,ri],t4,{memoizeOptions:{resultEqualityCheck:Y2}}),h_e=[0,1],n4=(t,e,n,r,i,a,o)=>{if(!((t==null||n==null||n.length===0)&&o===void 0)){var{dataKey:l,type:c}=t,u=Ec(e,a);if(u&&l==null){var d;return CX(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?t_e(r,t,u):i==="expand"?h_e:o}},r4=nt([ci,Vn,XO,Z2,Zy,ri,d_e],n4),XY=(t,e,n,r,i)=>{if(t!=null){var{scale:a,type:o}=t;if(a==="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 a=="string"){var l="scale".concat(Iy(a));return l in a0?l:"point"}}},kx=nt([ci,Vn,FY,IO,ri],XY);function f_e(t){if(t!=null){if(t in a0)return a0[t]();var e="scale".concat(Iy(t));if(e in a0)return a0[e]()}}function i4(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=f_e(e);if(i!=null){var a=i.domain(n).range(r);return cxe(a),a}}}var a4=(t,e,n)=>{var r=QO(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&_h(t))return Awe(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&_h(t))return Cwe(t,e.tickCount,e.allowDecimals)}},s4=nt([r4,ev,kx],a4),o4=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&_h(e)&&Array.isArray(n)&&n.length>0){var i=e[0],a=n[0],o=e[1],l=n[n.length-1];return[Math.min(i,a),Math.max(o,l)]}return e},m_e=nt([ci,r4,s4,ri],o4),p_e=nt(Z2,ci,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(Bu(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 a=0;a<r.length-1;a++){var o=r[a+1]-r[a];n=Math.min(n,o)}return n/i}}),YY=nt(p_e,Vn,EY,na,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!yr(t))return 0;var a=e==="vertical"?r.height:r.width;if(i==="gap")return t*a/2;if(i==="no-gap"){var o=es(n,t*a),l=t*a/2;return l-o-(l-o)/a*o}return 0}),g_e=(t,e)=>{var n=kc(t,e);return n==null||typeof n.padding!="string"?0:YY(t,"xAxis",e,n.padding)},x_e=(t,e)=>{var n=Tc(t,e);return n==null||typeof n.padding!="string"?0:YY(t,"yAxis",e,n.padding)},b_e=nt(kc,g_e,(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}}),y_e=nt(Tc,x_e,(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}}),v_e=nt([na,b_e,O2,R2,(t,e,n)=>n],(t,e,n,r,i)=>{var{padding:a}=r;return i?[a.left,n.width-a.right]:[t.left+e.left,t.left+t.width-e.right]}),w_e=nt([na,Vn,y_e,O2,R2,(t,e,n)=>n],(t,e,n,r,i,a)=>{var{padding:o}=i;return a?[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]}),iv=(t,e,n,r)=>{var i;switch(e){case"xAxis":return v_e(t,n,r);case"yAxis":return w_e(t,n,r);case"zAxis":return(i=VO(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return jY(t);case"radiusAxis":return PY(t,n);default:return}},QY=nt([ci,iv],q2),Sh=nt([ci,kx,m_e,QY],i4);nt([nv,J2,ri],Zwe);function ZY(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var eM=(t,e)=>e,tM=(t,e,n)=>n,__e=nt(P2,eM,tM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(ZY)),S_e=nt(D2,eM,tM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(ZY)),JY=(t,e)=>({width:t.width,height:e.height}),N_e=(t,e)=>{var n=typeof e.width=="number"?e.width:Vy;return{width:n,height:t.height}},eQ=nt(na,kc,JY),M_e=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},E_e=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},k_e=nt(Wu,na,__e,eM,tM,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=JY(e,l);o==null&&(o=M_e(e,r,t));var u=r==="top"&&!i||r==="bottom"&&i;a[l.id]=o-Number(u)*c.height,o+=(u?-1:1)*c.height}),a}),T_e=nt(qu,na,S_e,eM,tM,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=N_e(e,l);o==null&&(o=E_e(e,r,t));var u=r==="left"&&!i||r==="right"&&i;a[l.id]=o-Number(u)*c.width,o+=(u?-1:1)*c.width}),a}),A_e=(t,e)=>{var n=kc(t,e);if(n!=null)return k_e(t,n.orientation,n.mirror)},C_e=nt([na,kc,A_e,(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}}}),j_e=(t,e)=>{var n=Tc(t,e);if(n!=null)return T_e(t,n.orientation,n.mirror)},P_e=nt([na,Tc,j_e,(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}}}),tQ=nt(na,Tc,(t,e)=>{var n=typeof e.width=="number"?e.width:Vy;return{width:n,height:t.height}}),I6=(t,e,n)=>{switch(e){case"xAxis":return eQ(t,n).width;case"yAxis":return tQ(t,n).height;default:return}},nQ=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:o}=n,l=Ec(t,r),c=e.map(u=>u.value);if(o&&l&&a==="category"&&i&&rK(c))return c}},l4=nt([Vn,Z2,ci,ri],nQ),rQ=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n,o=Ec(t,r);if(o&&(i==="number"||a!=="auto"))return e.map(l=>l.value)}},c4=nt([Vn,Z2,ev,ri],rQ),U6=nt([Vn,Vwe,kx,Sh,l4,c4,iv,s4,ri],(t,e,n,r,i,a,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:a,duplicateDomain:i,isCategorical:u,niceTicks:l,range:o,realScaleType:n,scale:r}}}),D_e=(t,e,n,r,i,a,o,l,c)=>{if(!(e==null||r==null)){var u=Ec(t,c),{type:d,ticks:f,tickCount:p}=e,m=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,x=d==="category"&&r.bandwidth?r.bandwidth()/m:0;x=c==="angleAxis"&&a!=null&&a.length>=2?ya(a[0]-a[1])*2*x:x;var b=f||i;if(b){var y=b.map((v,S)=>{var M=o?o.indexOf(v):v;return{index:S,coordinate:r(M)+x,value:v,offset:x}});return y.filter(v=>yr(v.coordinate))}return u&&l?l.map((v,S)=>({coordinate:r(v)+x,value:v,index:S,offset:x})).filter(v=>yr(v.coordinate)):r.ticks?r.ticks(p).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}))}},iQ=nt([Vn,ev,kx,Sh,s4,iv,l4,c4,ri],D_e),R_e=(t,e,n,r,i,a,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?ya(r[0]-r[1])*2*u:u,l&&a?a.map((d,f)=>({coordinate:n(d)+u,value:d,index:f,offset:u})):n.ticks?n.ticks(c).map(d=>({coordinate:n(d)+u,value:d,offset:u})):n.domain().map((d,f)=>({coordinate:n(d)+u,value:i?i[d]:d,index:f,offset:u}))}},xc=nt([Vn,ev,Sh,iv,l4,c4,ri],R_e),bc=nt(ci,Sh,(t,e)=>{if(!(t==null||e==null))return AS(AS({},t),{},{scale:e})}),O_e=nt([ci,kx,r4,QY],i4);nt((t,e,n)=>VO(t,n),O_e,(t,e)=>{if(!(t==null||e==null))return AS(AS({},t),{},{scale:e})});var L_e=nt([Vn,P2,D2],(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}}),aQ=t=>t.options.defaultTooltipEventType,sQ=t=>t.options.validateTooltipEventTypes;function oQ(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function u4(t,e){var n=aQ(t),r=sQ(t);return oQ(e,n,r)}function F_e(t){return It(e=>u4(e,t))}var lQ=(t,e)=>{var n,r=Number(e);if(!(Hs(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},I_e=t=>t.tooltip.settings,Wd={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},U_e={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}},cQ=Vs({name:"tooltip",initialState:U_e,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:Zr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ol(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:Zr()},removeTooltipEntrySettings:{reducer(t,e){var n=Ol(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:Zr()},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:z_e,replaceTooltipEntrySettings:B_e,removeTooltipEntrySettings:$_e,setTooltipSettingsState:H_e,setActiveMouseOverItemIndex:uQ,mouseLeaveItem:V_e,mouseLeaveChart:dQ,setActiveClickItemIndex:G_e,setMouseOverAxisIndex:hQ,setMouseClickAxisIndex:q_e,setSyncInteraction:c3,setKeyboardInteraction:u3}=cQ.actions,W_e=cQ.reducer;function z6(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 Ww(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?z6(Object(n),!0).forEach(function(r){K_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):z6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function K_e(t,e,n){return(e=X_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function X_e(t){var e=Y_e(t,"string");return typeof e=="symbol"?e:e+""}function Y_e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Q_e(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function Z_e(t){return t.index!=null}var fQ=(t,e,n,r)=>{if(e==null)return Wd;var i=Q_e(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 a=t.settings.active===!0;if(Z_e(i)){if(a)return Ww(Ww({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return Ww(Ww({},Wd),{},{coordinate:i.coordinate})};function J_e(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 e1e(t,e){var n=J_e(t),r=e[0],i=e[1];if(n===void 0)return!1;var a=Math.min(r,i),o=Math.max(r,i);return n>=a&&n<=o}function t1e(t,e,n){if(n==null||e==null)return!0;var r=br(t,e);return r==null||!_h(n)?!0:e1e(r,n)}var d4=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var a=Number(i);if(!yr(a))return i;var o=0,l=1/0;e.length>0&&(l=e.length-1);var c=Math.max(o,Math.min(a,l)),u=e[c];return u==null||t1e(u,n,r)?String(c):null},mQ=(t,e,n,r,i,a,o,l)=>{if(!(a==null||l==null)){var c=o[0],u=c==null?void 0:l(c.positions,a);if(u!=null)return u;var d=i?.[Number(a)];if(d)switch(n){case"horizontal":return{x:d.coordinate,y:(r.top+e)/2};default:return{x:(r.left+t)/2,y:d.coordinate}}}},pQ=(t,e,n,r)=>{if(e==="axis")return t.tooltipItemPayloads;if(t.tooltipItemPayloads.length===0)return[];var i;return n==="hover"?i=t.itemInteraction.hover.dataKey:i=t.itemInteraction.click.dataKey,i==null&&r!=null?[t.tooltipItemPayloads[0]]:t.tooltipItemPayloads.filter(a=>{var o;return((o=a.settings)===null||o===void 0?void 0:o.dataKey)===i})},av=t=>t.options.tooltipPayloadSearcher,Tx=t=>t.tooltip;function B6(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 $6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?B6(Object(n),!0).forEach(function(r){n1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):B6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function n1e(t,e,n){return(e=r1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function r1e(t){var e=i1e(t,"string");return typeof e=="symbol"?e:e+""}function i1e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function a1e(t,e){return t??e}var gQ=(t,e,n,r,i,a,o)=>{if(!(e==null||a==null)){var{chartData:l,computedData:c,dataStartIndex:u,dataEndIndex:d}=n,f=[];return t.reduce((p,m)=>{var x,{dataDefinedOnItem:b,settings:y}=m,v=a1e(b,l),S=Array.isArray(v)?ZK(v,u,d):v,M=(x=y?.dataKey)!==null&&x!==void 0?x:r,T=y?.nameKey,E;if(r&&Array.isArray(S)&&!Array.isArray(S[0])&&o==="axis"?E=iK(S,r,i):E=a(S,e,c,T),Array.isArray(E))E.forEach(k=>{var R=$6($6({},y),{},{name:k.name,unit:k.unit,color:void 0,fill:void 0});p.push(l8({tooltipEntrySettings:R,dataKey:k.dataKey,payload:k.payload,value:br(k.payload,k.dataKey),name:k.name}))});else{var C;p.push(l8({tooltipEntrySettings:y,dataKey:M,payload:E,value:br(E,M),name:(C=br(E,T))!==null&&C!==void 0?C:y?.name}))}return p},f)}},h4=nt([sa,Vn,FY,IO,aa],XY),s1e=nt([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),o1e=nt([aa,Mx],GO),sv=nt([s1e,sa,o1e],qO,{memoizeOptions:{resultEqualityCheck:Q2}}),l1e=nt([sv],t=>t.filter(X2)),c1e=nt([sv],WO,{memoizeOptions:{resultEqualityCheck:Q2}}),Ax=nt([c1e,Uh],KO),u1e=nt([l1e,Uh,sa],RY),f4=nt([Ax,sa,sv],YO),xQ=nt([sa],QO),d1e=nt([sa],t=>t.allowDataOverflow),bQ=nt([xQ,d1e],dY),h1e=nt([sv],t=>t.filter(X2)),f1e=nt([u1e,h1e,Zy,kY],BY),m1e=nt([f1e,Uh,aa,bQ],$Y),p1e=nt([sv],UY),g1e=nt([Ax,sa,p1e,J2,aa],e4,{memoizeOptions:{resultEqualityCheck:Y2}}),x1e=nt([HY,aa,Mx],Ex),b1e=nt([x1e,aa],qY),y1e=nt([VY,aa,Mx],Ex),v1e=nt([y1e,aa],WY),w1e=nt([GY,aa,Mx],Ex),_1e=nt([w1e,aa],KY),S1e=nt([b1e,_1e,v1e],CS),N1e=nt([sa,xQ,bQ,m1e,g1e,S1e,Vn,aa],t4),ov=nt([sa,Vn,Ax,f4,Zy,aa,N1e],n4),M1e=nt([ov,sa,h4],a4),E1e=nt([sa,ov,M1e,aa],o4),yQ=t=>{var e=aa(t),n=Mx(t),r=!1;return iv(t,e,n,r)},vQ=nt([sa,yQ],q2),wQ=nt([sa,h4,E1e,vQ],i4),k1e=nt([Vn,f4,sa,aa],nQ),T1e=nt([Vn,f4,sa,aa],rQ),A1e=(t,e,n,r,i,a,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?ya(i[0]-i[1])*2*f:f,u&&o?o.map((p,m)=>({coordinate:r(p)+f,value:p,index:m,offset:f})):r.domain().map((p,m)=>({coordinate:r(p)+f,value:a?a[p]:p,index:m,offset:f}))}}},Xu=nt([Vn,sa,h4,wQ,yQ,k1e,T1e,aa],A1e),m4=nt([aQ,sQ,I_e],(t,e,n)=>oQ(n.shared,t,e)),_Q=t=>t.tooltip.settings.trigger,p4=t=>t.tooltip.settings.defaultIndex,lv=nt([Tx,m4,_Q,p4],fQ),Nh=nt([lv,Ax,rv,ov],d4),SQ=nt([Xu,Nh],lQ),g4=nt([lv],t=>{if(t)return t.dataKey}),C1e=nt([lv],t=>{if(t)return t.graphicalItemId}),NQ=nt([Tx,m4,_Q,p4],pQ),j1e=nt([qu,Wu,Vn,na,Xu,p4,NQ,av],mQ),P1e=nt([lv,j1e],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),D1e=nt([lv],t=>t.active),R1e=nt([NQ,Nh,Uh,rv,SQ,av,m4],gQ),O1e=nt([R1e],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function H6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function V6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?H6(Object(n),!0).forEach(function(r){L1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):H6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function L1e(t,e,n){return(e=F1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function F1e(t){var e=I1e(t,"string");return typeof e=="symbol"?e:e+""}function I1e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var U1e=()=>It(sa),z1e=()=>{var t=U1e(),e=It(Xu),n=It(wQ);return wh(!t||!n?void 0:V6(V6({},t),{},{scale:n}),e)};function G6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function bp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?G6(Object(n),!0).forEach(function(r){B1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):G6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function B1e(t,e,n){return(e=$1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $1e(t){var e=H1e(t,"string");return typeof e=="symbol"?e:e+""}function H1e(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 V1e=(t,e,n,r)=>{var i=e.find(a=>a&&a.index===n);if(i){if(t==="horizontal")return{x:i.coordinate,y:r.chartY};if(t==="vertical")return{x:r.chartX,y:i.coordinate}}return{x:0,y:0}},G1e=(t,e,n,r)=>{var i=e.find(u=>u&&u.index===n);if(i){if(t==="centric"){var a=i.coordinate,{radius:o}=r;return bp(bp(bp({},r),zi(r.cx,r.cy,o,a)),{},{angle:a,radius:o})}var l=i.coordinate,{angle:c}=r;return bp(bp(bp({},r),zi(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 q1e(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 MQ=(t,e,n,r,i)=>{var a,o=-1,l=(a=e?.length)!==null&&a!==void 0?a: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,p=void 0;if(ya(d-u)!==ya(f-d)){var m=[];if(ya(f-d)===ya(i[1]-i[0])){p=f;var x=d+i[1]-i[0];m[0]=Math.min(x,(x+u)/2),m[1]=Math.max(x,(x+u)/2)}else{p=u;var b=f+i[1]-i[0];m[0]=Math.min(d,(b+d)/2),m[1]=Math.max(d,(b+d)/2)}var y=[Math.min(d,(p+d)/2),Math.max(d,(p+d)/2)];if(t>y[0]&&t<=y[1]||t>=m[0]&&t<=m[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 M=0;M<l;M++)if(M===0&&t<=(e[M].coordinate+e[M+1].coordinate)/2||M>0&&M<l-1&&t>(e[M].coordinate+e[M-1].coordinate)/2&&t<=(e[M].coordinate+e[M+1].coordinate)/2||M===l-1&&t>(e[M].coordinate+e[M-1].coordinate)/2){({index:o}=e[M]);break}}return o},EQ=()=>It(IO),x4=(t,e)=>e,kQ=(t,e,n)=>n,b4=(t,e,n,r)=>r,W1e=nt(Xu,t=>S2(t,e=>e.coordinate)),y4=nt([Tx,x4,kQ,b4],fQ),v4=nt([y4,Ax,rv,ov],d4),K1e=(t,e,n)=>{if(e!=null){var r=Tx(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},TQ=nt([Tx,x4,kQ,b4],pQ),jS=nt([qu,Wu,Vn,na,Xu,b4,TQ,av],mQ),X1e=nt([y4,jS],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),AQ=nt([Xu,v4],lQ),Y1e=nt([TQ,v4,Uh,rv,AQ,av,x4],gQ),Q1e=nt([y4,v4],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),Z1e=(t,e,n,r,i,a,o)=>{if(!(!t||!n||!r||!i)&&q1e(t,o)){var l=yxe(t,e),c=MQ(l,a,i,n,r),u=V1e(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},J1e=(t,e,n,r,i,a,o)=>{if(!(!t||!r||!i||!a||!n)){var l=L0e(t,n);if(l){var c=vxe(l,e),u=MQ(c,o,a,r,i),d=G1e(e,a,u,l);return{activeIndex:String(u),activeCoordinate:d}}}},eSe=(t,e,n,r,i,a,o,l)=>{if(!(!t||!e||!r||!i||!a))return e==="horizontal"||e==="vertical"?Z1e(t,e,r,i,a,o,l):J1e(t,e,n,r,i,a,o)},tSe=nt(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}}),nSe=nt(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(bi)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:Uwe}});function q6(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 W6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?q6(Object(n),!0).forEach(function(r){rSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):q6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function rSe(t,e,n){return(e=iSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function iSe(t){var e=aSe(t,"string");return typeof e=="symbol"?e:e+""}function aSe(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 sSe={},oSe={zIndexMap:Object.values(bi).reduce((t,e)=>W6(W6({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),sSe)},lSe=new Set(Object.values(bi));function cSe(t){return lSe.has(t)}var CQ=Vs({name:"zIndex",initialState:oSe,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:Zr()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!cSe(n)&&delete t.zIndexMap[n])},prepare:Zr()},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:Zr()},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:Zr()}}}),{registerZIndexPortal:uSe,unregisterZIndexPortal:dSe,registerZIndexPortalId:hSe,unregisterZIndexPortalId:fSe}=CQ.actions,mSe=CQ.reducer;function ts(t){var{zIndex:e,children:n}=t,r=Zxe(),i=r&&e!==void 0&&e!==0,a=ra(),o=Lr();_.useLayoutEffect(()=>i?(o(uSe({zIndex:e})),()=>{o(dSe({zIndex:e}))}):Uy,[o,e,i]);var l=It(u=>tSe(u,e,a));if(!i)return n;if(!l)return null;var c=document.getElementById(l);return c?gu.createPortal(n,c):null}function d3(){return d3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},d3.apply(null,arguments)}function K6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Kw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?K6(Object(n),!0).forEach(function(r){pSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):K6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function pSe(t,e,n){return(e=gSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gSe(t){var e=xSe(t,"string");return typeof e=="symbol"?e:e+""}function xSe(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 bSe(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return _.isValidElement(e)?_.cloneElement(e,r):_.createElement(n,r)}function ySe(t){var e,{coordinate:n,payload:r,index:i,offset:a,tooltipAxisBandSize:o,layout:l,cursor:c,tooltipEventType:u,chartName:d}=t,f=n,p=r,m=i;if(!c||!f||d!=="ScatterChart"&&u!=="axis")return null;var x,b,y;if(d==="ScatterChart")x=f,b=Qbe,y=bi.cursorLine;else if(d==="BarChart")x=Zbe(l,f,a,o),b=MX,y=bi.cursorRectangle;else if(l==="radial"&&sK(f)){var{cx:v,cy:S,radius:M,startAngle:T,endAngle:E}=kX(f);x={cx:v,cy:S,startAngle:T,endAngle:E,innerRadius:M,outerRadius:M},b=AX,y=bi.cursorLine}else x={points:z0e(l,f,a)},b=Eg,y=bi.cursorLine;var C=typeof c=="object"&&"className"in c?c.className:void 0,k=Kw(Kw(Kw(Kw({stroke:"#ccc",pointerEvents:"none"},a),x),lm(c)),{},{payload:p,payloadIndex:m,className:er("recharts-tooltip-cursor",C)});return _.createElement(ts,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:y},_.createElement(bSe,{cursor:c,cursorComp:b,cursorProps:k}))}function vSe(t){var e=z1e(),n=cX(),r=km(),i=EQ();return e==null||n==null||r==null||i==null?null:_.createElement(ySe,d3({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var jQ=_.createContext(null),wSe=()=>_.useContext(jQ),_A={exports:{}},X6;function _Se(){return X6||(X6=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function a(c,u,d,f,p){if(typeof d!="function")throw new TypeError("The listener must be a function");var m=new i(d,f||c,p),x=n?n+u:u;return c._events[x]?c._events[x].fn?c._events[x]=[c._events[x],m]:c._events[x].push(m):(c._events[x]=m,c._eventsCount++),c}function 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 p=0,m=f.length,x=new Array(m);p<m;p++)x[p]=f[p].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,p,m,x){var b=n?n+u:u;if(!this._events[b])return!1;var y=this._events[b],v=arguments.length,S,M;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,p),!0;case 5:return y.fn.call(y.context,d,f,p,m),!0;case 6:return y.fn.call(y.context,d,f,p,m,x),!0}for(M=1,S=new Array(v-1);M<v;M++)S[M-1]=arguments[M];y.fn.apply(y.context,S)}else{var T=y.length,E;for(M=0;M<T;M++)switch(y[M].once&&this.removeListener(u,y[M].fn,void 0,!0),v){case 1:y[M].fn.call(y[M].context);break;case 2:y[M].fn.call(y[M].context,d);break;case 3:y[M].fn.call(y[M].context,d,f);break;case 4:y[M].fn.call(y[M].context,d,f,p);break;default:if(!S)for(E=1,S=new Array(v-1);E<v;E++)S[E-1]=arguments[E];y[M].fn.apply(y[M].context,S)}}return!0},l.prototype.on=function(u,d,f){return a(this,u,d,f,!1)},l.prototype.once=function(u,d,f){return a(this,u,d,f,!0)},l.prototype.removeListener=function(u,d,f,p){var m=n?n+u:u;if(!this._events[m])return this;if(!d)return o(this,m),this;var x=this._events[m];if(x.fn)x.fn===d&&(!p||x.once)&&(!f||x.context===f)&&o(this,m);else{for(var b=0,y=[],v=x.length;b<v;b++)(x[b].fn!==d||p&&!x[b].once||f&&x[b].context!==f)&&y.push(x[b]);y.length?this._events[m]=y.length===1?y[0]:y:o(this,m)}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})(_A)),_A.exports}var SSe=_Se();const NSe=hl(SSe);var cy=new NSe,h3="recharts.syncEvent.tooltip",Y6="recharts.syncEvent.brush";function nM(t,e){if(e){var n=Number.parseInt(e,10);if(!Hs(n))return t?.[n]}}var MSe={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},PQ=Vs({name:"options",initialState:MSe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),ESe=PQ.reducer,{createEventEmitter:kSe}=PQ.actions;function TSe(t){return t.tooltip.syncInteraction}var ASe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},DQ=Vs({name:"chartData",initialState:ASe,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:Q6,setDataStartEndIndexes:CSe,setComputedData:PXe}=DQ.actions,jSe=DQ.reducer,PSe=["x","y"];function Z6(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?Z6(Object(n),!0).forEach(function(r){DSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Z6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function DSe(t,e,n){return(e=RSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function RSe(t){var e=OSe(t,"string");return typeof e=="symbol"?e:e+""}function OSe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function LSe(t,e){if(t==null)return{};var n,r,i=FSe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function FSe(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 ISe(){var t=It(UO),e=It(zO),n=Lr(),r=It(TY),i=It(Xu),a=km(),o=Gy(),l=It(c=>c.rootProps.className);_.useEffect(()=>{if(t==null)return Uy;var c=(u,d,f)=>{if(e!==f&&t===u){if(r==="index"){var p;if(o&&d!==null&&d!==void 0&&(p=d.payload)!==null&&p!==void 0&&p.coordinate&&d.payload.sourceViewBox){var m=d.payload.coordinate,{x,y:b}=m,y=LSe(m,PSe),{x:v,y:S,width:M,height:T}=d.payload.sourceViewBox,E=yp(yp({},y),{},{x:o.x+(M?(x-v)/M:0)*o.width,y:o.y+(T?(b-S)/T:0)*o.height});n(yp(yp({},d),{},{payload:yp(yp({},d.payload),{},{coordinate:E})}))}else n(d);return}if(i!=null){var C;if(typeof r=="function"){var k={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},R=r(i,k);C=i[R]}else r==="value"&&(C=i.find(K=>String(K.value)===d.payload.label));var{coordinate:A}=d.payload;if(C==null||d.payload.active===!1||A==null||o==null){n(c3({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:D,y:U}=A,F=Math.min(D,o.x+o.width),H=Math.min(U,o.y+o.height),j={x:a==="horizontal"?C.coordinate:F,y:a==="horizontal"?H:C.coordinate},$=c3({active:d.payload.active,coordinate:j,dataKey:d.payload.dataKey,index:String(C.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n($)}}};return cy.on(h3,c),()=>{cy.off(h3,c)}},[l,n,e,t,r,i,a,o])}function USe(){var t=It(UO),e=It(zO),n=Lr();_.useEffect(()=>{if(t==null)return Uy;var r=(i,a,o)=>{e!==o&&t===i&&n(CSe(a))};return cy.on(Y6,r),()=>{cy.off(Y6,r)}},[n,e,t])}function zSe(){var t=Lr();_.useEffect(()=>{t(kSe())},[t]),ISe(),USe()}function BSe(t,e,n,r,i,a){var o=It(m=>K1e(m,t,e)),l=It(zO),c=It(UO),u=It(TY),d=It(TSe),f=d?.active,p=Gy();_.useEffect(()=>{if(!f&&c!=null&&l!=null){var m=c3({active:a,coordinate:n,dataKey:o,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:p,graphicalItemId:void 0});cy.emit(h3,c,m,l)}},[f,n,o,i,r,l,c,u,a,p])}function J6(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 e$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?J6(Object(n),!0).forEach(function(r){$Se(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):J6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $Se(t,e,n){return(e=HSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function HSe(t){var e=VSe(t,"string");return typeof e=="symbol"?e:e+""}function VSe(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 GSe(t){return t.dataKey}function qSe(t,e){return _.isValidElement(t)?_.cloneElement(t,e):typeof t=="function"?_.createElement(t,e):_.createElement(Cbe,e)}var t$=[],WSe={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 _1(t){var e,n,r=li(t,WSe),{active:i,allowEscapeViewBox:a,animationDuration:o,animationEasing:l,content:c,filterNull:u,isAnimationActive:d,offset:f,payloadUniqBy:p,position:m,reverseDirection:x,useTranslate3d:b,wrapperStyle:y,cursor:v,shared:S,trigger:M,defaultIndex:T,portal:E,axisId:C}=r,k=Lr(),R=typeof T=="number"?String(T):T;_.useEffect(()=>{k(H_e({shared:S,trigger:M,axisId:C,active:i,defaultIndex:R}))},[k,S,M,C,i,R]);var A=Gy(),D=vX(),U=F_e(S),{activeIndex:F,isActive:H}=(e=It(de=>Q1e(de,U,M,R)))!==null&&e!==void 0?e:{},j=It(de=>Y1e(de,U,M,R)),$=It(de=>AQ(de,U,M,R)),K=It(de=>X1e(de,U,M,R)),V=j,Q=wSe(),Z=(n=i??H)!==null&&n!==void 0?n:!1,[ae,B]=_K([V,Z]),X=U==="axis"?$:void 0;BSe(U,M,K,X,F,Z);var ne=E??Q;if(ne==null||A==null||U==null)return null;var se=V??t$;Z||(se=t$),u&&se.length&&(se=gK(se.filter(de=>de.value!=null&&(de.hide!==!0||r.includeHidden)),p,GSe));var be=se.length>0,xe=_.createElement(Fbe,{allowEscapeViewBox:a,animationDuration:o,animationEasing:l,isAnimationActive:d,active:Z,coordinate:K,hasPayload:be,offset:f,position:m,reverseDirection:x,useTranslate3d:b,viewBox:A,wrapperStyle:y,lastBoundingBox:ae,innerRef:B,hasPortalFromProps:!!E},qSe(c,e$(e$({},r),{},{payload:se,label:X,active:Z,activeIndex:F,coordinate:K,accessibilityLayer:D})));return _.createElement(_.Fragment,null,gu.createPortal(xe,ne),Z&&_.createElement(vSe,{cursor:v,tooltipEventType:U,coordinate:K,payload:se,index:F}))}var cv=t=>null;cv.displayName="Cell";function KSe(t,e,n){return(e=XSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function XSe(t){var e=YSe(t,"string");return typeof e=="symbol"?e:e+""}function YSe(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 QSe{constructor(e){KSe(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 n$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ZSe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?n$(Object(n),!0).forEach(function(r){JSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):n$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function JSe(t,e,n){return(e=eNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function eNe(t){var e=tNe(t,"string");return typeof e=="symbol"?e:e+""}function tNe(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 nNe={cacheSize:2e3,enableCache:!0},RQ=ZSe({},nNe),r$=new QSe(RQ.cacheSize),rNe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},i$="recharts_measurement_span";function iNe(t,e){var n=e.fontSize||"",r=e.fontFamily||"",i=e.fontWeight||"",a=e.fontStyle||"",o=e.letterSpacing||"",l=e.textTransform||"";return"".concat(t,"|").concat(n,"|").concat(r,"|").concat(i,"|").concat(a,"|").concat(o,"|").concat(l)}var a$=(t,e)=>{try{var n=document.getElementById(i$);n||(n=document.createElement("span"),n.setAttribute("id",i$),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,rNe,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},v0=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||yx.isSsr)return{width:0,height:0};if(!RQ.enableCache)return a$(e,n);var r=iNe(e,n),i=r$.get(r);if(i)return i;var a=a$(e,n);return r$.set(r,a),a},s$=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,o$=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,aNe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,sNe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,OQ={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},oNe=Object.keys(OQ),gg="NaN";function lNe(t,e){return t*OQ[e]}class Ps{static parse(e){var n,[,r,i]=(n=sNe.exec(e))!==null&&n!==void 0?n:[];return new Ps(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,Hs(e)&&(this.unit=""),n!==""&&!aNe.test(n)&&(this.num=NaN,this.unit=""),oNe.includes(n)&&(this.num=lNe(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new Ps(NaN,""):new Ps(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new Ps(NaN,""):new Ps(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Ps(NaN,""):new Ps(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Ps(NaN,""):new Ps(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return Hs(this.num)}}function LQ(t){if(t.includes(gg))return gg;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,a]=(n=s$.exec(e))!==null&&n!==void 0?n:[],o=Ps.parse(r??""),l=Ps.parse(a??""),c=i==="*"?o.multiply(l):o.divide(l);if(c.isNaN())return gg;e=e.replace(s$,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,p]=(u=o$.exec(e))!==null&&u!==void 0?u:[],m=Ps.parse(d??""),x=Ps.parse(p??""),b=f==="+"?m.add(x):m.subtract(x);if(b.isNaN())return gg;e=e.replace(o$,b.toString())}return e}var l$=/\(([^()]*)\)/;function cNe(t){for(var e=t,n;(n=l$.exec(e))!=null;){var[,r]=n;e=e.replace(l$,LQ(r))}return e}function uNe(t){var e=t.replace(/\s+/g,"");return e=cNe(e),e=LQ(e),e}function dNe(t){try{return uNe(t)}catch{return gg}}function SA(t){var e=dNe(t.slice(5,-1));return e===gg?"":e}var hNe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],fNe=["dx","dy","angle","className","breakAll"];function f3(){return f3=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},f3.apply(null,arguments)}function c$(t,e){if(t==null)return{};var n,r,i=mNe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function mNe(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 FQ=/[ \f\n\r\t\v\u2028\u2029]+/,IQ=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];Xr(e)||(n?i=e.toString().split(""):i=e.toString().split(FQ));var a=i.map(l=>({word:l,width:v0(l,r).width})),o=n?0:v0(" ",r).width;return{wordsWithComputedWidth:a,spaceWidth:o}}catch{return null}};function pNe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var UQ=(t,e,n,r)=>t.reduce((i,a)=>{var{word:o,width:l}=a,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},[]),zQ=t=>t.reduce((e,n)=>e.width>n.width?e:n),gNe="…",u$=(t,e,n,r,i,a,o,l)=>{var c=t.slice(0,e),u=IQ({breakAll:n,style:r,children:c+gNe});if(!u)return[!1,[]];var d=UQ(u.wordsWithComputedWidth,a,o,l),f=d.length>i||zQ(d).width>Number(a);return[f,d]},xNe=(t,e,n,r,i)=>{var{maxLines:a,children:o,style:l,breakAll:c}=t,u=zt(a),d=String(o),f=UQ(e,r,n,i);if(!u||i)return f;var p=f.length>a||zQ(f).width>Number(r);if(!p)return f;for(var m=0,x=d.length-1,b=0,y;m<=x&&b<=d.length-1;){var v=Math.floor((m+x)/2),S=v-1,[M,T]=u$(d,S,c,l,a,r,n,i),[E]=u$(d,v,c,l,a,r,n,i);if(!M&&!E&&(m=v+1),M&&E&&(x=v-1),!M&&E){y=T;break}b++}return y||f},d$=t=>{var e=Xr(t)?[]:t.toString().split(FQ);return[{words:e,width:void 0}]},bNe=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:o}=t;if((e||n)&&!yx.isSsr){var l,c,u=IQ({breakAll:a,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;l=d,c=f}else return d$(r);return xNe({breakAll:a,children:r,maxLines:o,style:i},l,c,e,!!n)}return d$(r)},BQ="#808080",yNe={angle:0,breakAll:!1,capHeight:"0.71em",fill:BQ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},rM=_.forwardRef((t,e)=>{var n=li(t,yNe),{x:r,y:i,lineHeight:a,capHeight:o,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=c$(n,hNe),p=_.useMemo(()=>bNe({breakAll:f.breakAll,children:f.children,maxLines:f.maxLines,scaleToFit:c,style:f.style,width:f.width}),[f.breakAll,f.children,f.maxLines,c,f.style,f.width]),{dx:m,dy:x,angle:b,className:y,breakAll:v}=f,S=c$(f,fNe);if(!cl(r)||!cl(i)||p.length===0)return null;var M=Number(r)+(zt(m)?m:0),T=Number(i)+(zt(x)?x:0);if(!yr(M)||!yr(T))return null;var E;switch(d){case"start":E=SA("calc(".concat(o,")"));break;case"middle":E=SA("calc(".concat((p.length-1)/2," * -").concat(a," + (").concat(o," / 2))"));break;default:E=SA("calc(".concat(p.length-1," * -").concat(a,")"));break}var C=[];if(c){var k=p[0].width,{width:R}=f;C.push("scale(".concat(zt(R)&&zt(k)?R/k:1,")"))}return b&&C.push("rotate(".concat(b,", ").concat(M,", ").concat(T,")")),C.length&&(S.transform=C.join(" ")),_.createElement("text",f3({},za(S),{ref:e,x:M,y:T,className:er("recharts-text",y),textAnchor:u,fill:l.includes("url")?BQ:l}),p.map((A,D)=>{var U=A.words.join(v?"":" ");return _.createElement("tspan",{x:M,dy:D===0?E:a,key:"".concat(U,"-").concat(D)},U)}))});rM.displayName="Text";var vNe=["labelRef"];function wNe(t,e){if(t==null)return{};var n,r,i=_Ne(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function _Ne(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 h$(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 Ei(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?h$(Object(n),!0).forEach(function(r){SNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):h$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function SNe(t,e,n){return(e=NNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function NNe(t){var e=MNe(t,"string");return typeof e=="symbol"?e:e+""}function MNe(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 fu(){return fu=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},fu.apply(null,arguments)}var $Q=_.createContext(null),HQ=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:o,children:l}=t,c=_.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:o}),[e,n,r,i,a,o]);return _.createElement($Q.Provider,{value:c},l)},VQ=()=>{var t=_.useContext($Q),e=Gy();return t||lX(e)},ENe=_.createContext(null),kNe=()=>{var t=_.useContext(ENe),e=It(DY);return t||e},TNe=t=>{var{value:e,formatter:n}=t,r=Xr(t.children)?e:t.children;return typeof n=="function"?n(r):r},w4=t=>t!=null&&typeof t=="function",ANe=(t,e)=>{var n=ya(e-t),r=Math.min(Math.abs(e-t),360);return n*r},CNe=(t,e,n,r,i)=>{var{offset:a,className:o}=t,{cx:l,cy:c,innerRadius:u,outerRadius:d,startAngle:f,endAngle:p,clockWise:m}=i,x=(u+d)/2,b=ANe(f,p),y=b>=0?1:-1,v,S;switch(e){case"insideStart":v=f+y*a,S=m;break;case"insideEnd":v=p-y*a,S=!m;break;case"end":v=p+y*a,S=m;break;default:throw new Error("Unsupported position ".concat(e))}S=b<=0?S:!S;var M=zi(l,c,x,v),T=zi(l,c,x,v+(S?1:-1)*359),E="M".concat(M.x,",").concat(M.y,`
  44. A`).concat(x,",").concat(x,",0,1,").concat(S?0:1,`,
  45. `).concat(T.x,",").concat(T.y),C=Xr(t.id)?X0("recharts-radial-line-"):t.id;return _.createElement("text",fu({},r,{dominantBaseline:"central",className:er("recharts-radial-bar-label",o)}),_.createElement("defs",null,_.createElement("path",{id:C,d:E})),_.createElement("textPath",{xlinkHref:"#".concat(C)},n))},jNe=(t,e,n)=>{var{cx:r,cy:i,innerRadius:a,outerRadius:o,startAngle:l,endAngle:c}=t,u=(l+c)/2;if(n==="outside"){var{x:d,y:f}=zi(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 p=(a+o)/2,{x:m,y:x}=zi(r,i,p,u);return{x:m,y:x,textAnchor:"middle",verticalAnchor:"middle"}},m3=t=>"cx"in t&&zt(t.cx),PNe=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,a;n!=null&&!m3(n)&&(a=n);var{x:o,y:l,upperWidth:c,lowerWidth:u,height:d}=e,f=o,p=o+(c-u)/2,m=(f+p)/2,x=(c+u)/2,b=f+c/2,y=d>=0?1:-1,v=y*r,S=y>0?"end":"start",M=y>0?"start":"end",T=c>=0?1:-1,E=T*r,C=T>0?"end":"start",k=T>0?"start":"end";if(i==="top"){var R={x:f+c/2,y:l-v,textAnchor:"middle",verticalAnchor:S};return Ei(Ei({},R),a?{height:Math.max(l-a.y,0),width:c}:{})}if(i==="bottom"){var A={x:p+u/2,y:l+d+v,textAnchor:"middle",verticalAnchor:M};return Ei(Ei({},A),a?{height:Math.max(a.y+a.height-(l+d),0),width:u}:{})}if(i==="left"){var D={x:m-E,y:l+d/2,textAnchor:C,verticalAnchor:"middle"};return Ei(Ei({},D),a?{width:Math.max(D.x-a.x,0),height:d}:{})}if(i==="right"){var U={x:m+x+E,y:l+d/2,textAnchor:k,verticalAnchor:"middle"};return Ei(Ei({},U),a?{width:Math.max(a.x+a.width-U.x,0),height:d}:{})}var F=a?{width:x,height:d}:{};return i==="insideLeft"?Ei({x:m+E,y:l+d/2,textAnchor:k,verticalAnchor:"middle"},F):i==="insideRight"?Ei({x:m+x-E,y:l+d/2,textAnchor:C,verticalAnchor:"middle"},F):i==="insideTop"?Ei({x:f+c/2,y:l+v,textAnchor:"middle",verticalAnchor:M},F):i==="insideBottom"?Ei({x:p+u/2,y:l+d-v,textAnchor:"middle",verticalAnchor:S},F):i==="insideTopLeft"?Ei({x:f+E,y:l+v,textAnchor:k,verticalAnchor:M},F):i==="insideTopRight"?Ei({x:f+c-E,y:l+v,textAnchor:C,verticalAnchor:M},F):i==="insideBottomLeft"?Ei({x:p+E,y:l+d-v,textAnchor:k,verticalAnchor:S},F):i==="insideBottomRight"?Ei({x:p+u-E,y:l+d-v,textAnchor:C,verticalAnchor:S},F):i&&typeof i=="object"&&(zt(i.x)||Lu(i.x))&&(zt(i.y)||Lu(i.y))?Ei({x:o+es(i.x,x),y:l+es(i.y,d),textAnchor:"end",verticalAnchor:"end"},F):Ei({x:b,y:l+d/2,textAnchor:"middle",verticalAnchor:"middle"},F)},DNe={angle:0,offset:5,zIndex:bi.label,position:"middle",textBreakAll:!1};function zd(t){var e=li(t,DNe),{viewBox:n,position:r,value:i,children:a,content:o,className:l="",textBreakAll:c,labelRef:u}=e,d=kNe(),f=VQ(),p=r==="center"?f:d??f,m,x,b;if(n==null?m=p:m3(n)?m=n:m=lX(n),!m||Xr(i)&&Xr(a)&&!_.isValidElement(o)&&typeof o!="function")return null;var y=Ei(Ei({},e),{},{viewBox:m});if(_.isValidElement(o)){var{labelRef:v}=y,S=wNe(y,vNe);return _.cloneElement(o,S)}if(typeof o=="function"){if(x=_.createElement(o,y),_.isValidElement(x))return x}else x=TNe(e);var M=za(e);if(m3(m)){if(r==="insideStart"||r==="insideEnd"||r==="end")return CNe(e,r,x,M,m);b=jNe(m,e.offset,e.position)}else b=PNe(e,m);return _.createElement(ts,{zIndex:e.zIndex},_.createElement(rM,fu({ref:u,className:er("recharts-label",l)},M,b,{textAnchor:pNe(M.textAnchor)?M.textAnchor:b.textAnchor,breakAll:c}),x))}zd.displayName="Label";var RNe=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?_.createElement(zd,fu({key:"label-implicit"},r)):cl(t)?_.createElement(zd,fu({key:"label-implicit",value:t},r)):_.isValidElement(t)?t.type===zd?_.cloneElement(t,Ei({key:"label-implicit"},r)):_.createElement(zd,fu({key:"label-implicit",content:t},r)):w4(t)?_.createElement(zd,fu({key:"label-implicit",content:t},r)):t&&typeof t=="object"?_.createElement(zd,fu({},t,{key:"label-implicit"},r)):null};function GQ(t){var{label:e,labelRef:n}=t,r=VQ();return RNe(e,r,n)||null}var NA={},MA={},f$;function ONe(){return f$||(f$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(MA)),MA}var EA={},m$;function LNe(){return m$||(m$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(EA)),EA}var p$;function FNe(){return p$||(p$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ONe(),n=LNe(),r=XR();function i(a){if(r.isArrayLike(a))return e.last(n.toArray(a))}t.last=i})(NA)),NA}var kA,g$;function INe(){return g$||(g$=1,kA=FNe().last),kA}var UNe=INe();const zNe=hl(UNe);var BNe=["valueAccessor"],$Ne=["dataKey","clockWise","id","textBreakAll","zIndex"];function PS(){return PS=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},PS.apply(null,arguments)}function x$(t,e){if(t==null)return{};var n,r,i=HNe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function HNe(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 VNe=t=>Array.isArray(t.value)?zNe(t.value):t.value,qQ=_.createContext(void 0),_4=qQ.Provider,WQ=_.createContext(void 0),GNe=WQ.Provider;function qNe(){return _.useContext(qQ)}function WNe(){return _.useContext(WQ)}function S1(t){var{valueAccessor:e=VNe}=t,n=x$(t,BNe),{dataKey:r,clockWise:i,id:a,textBreakAll:o,zIndex:l}=n,c=x$(n,$Ne),u=qNe(),d=WNe(),f=u||d;return!f||!f.length?null:_.createElement(ts,{zIndex:l??bi.label},_.createElement(oi,{className:"recharts-label-list"},f.map((p,m)=>{var x,b=Xr(r)?e(p,m):br(p&&p.payload,r),y=Xr(a)?{}:{id:"".concat(a,"-").concat(m)};return _.createElement(zd,PS({key:"label-".concat(m)},za(p),c,y,{fill:(x=n.fill)!==null&&x!==void 0?x:p.fill,parentViewBox:p.parentViewBox,value:b,textBreakAll:o,viewBox:p.viewBox,index:m,zIndex:0}))})))}S1.displayName="LabelList";function iM(t){var{label:e}=t;return e?e===!0?_.createElement(S1,{key:"labelList-implicit"}):_.isValidElement(e)||w4(e)?_.createElement(S1,{key:"labelList-implicit",content:e}):typeof e=="object"?_.createElement(S1,PS({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function p3(){return p3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},p3.apply(null,arguments)}var KQ=t=>{var{cx:e,cy:n,r,className:i}=t,a=er("recharts-dot",i);return zt(e)&&zt(n)&&zt(r)?_.createElement("circle",p3({},xs(t),KR(t),{className:a,cx:e,cy:n,r})):null},XQ=t=>t.graphicalItems.polarItems,KNe=nt([ri,Jy],GO),aM=nt([XQ,ci,KNe],qO),XNe=nt([aM],WO),sM=nt([XNe,OO],KO),YNe=nt([sM,ci,aM],YO);nt([sM,ci,aM],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var a,o=br(r,(a=e.dataKey)!==null&&a!==void 0?a:i.dataKey);return{value:o,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:br(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var b$=()=>{},QNe=nt([sM,ci,aM,J2,ri],e4),ZNe=nt([ci,ZO,JO,b$,QNe,b$,Vn,ri],t4),YQ=nt([ci,Vn,sM,YNe,Zy,ri,ZNe],n4),JNe=nt([YQ,ci,kx],a4);nt([ci,YQ,JNe,ri],o4);var e2e={radiusAxis:{},angleAxis:{}},QQ=Vs({name:"polarAxis",initialState:e2e,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:DXe,removeRadiusAxis:RXe,addAngleAxis:OXe,removeAngleAxis:LXe}=QQ.actions,t2e=QQ.reducer;function y$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function v$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?y$(Object(n),!0).forEach(function(r){n2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):y$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function n2e(t,e,n){return(e=r2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function r2e(t){var e=i2e(t,"string");return typeof e=="symbol"?e:e+""}function i2e(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 a2e=(t,e)=>e,S4=nt([XQ,a2e],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),s2e=[],N4=(t,e,n)=>n?.length===0?s2e:n,ZQ=nt([OO,S4,N4],(t,e,n)=>{var{chartData:r}=t;if(e!=null){var i;if(e?.data!=null&&e.data.length>0?i=e.data:i=r,(!i||!i.length)&&n!=null&&(i=n.map(a=>v$(v$({},e.presentationProps),a.props))),i!=null)return i}}),o2e=nt([ZQ,S4,N4],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var a,o=br(r,e.nameKey,e.name),l;return n!=null&&(a=n[i])!==null&&a!==void 0&&(a=a.props)!==null&&a!==void 0&&a.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}})}),l2e=nt([ZQ,S4,N4,na],(t,e,n,r)=>{if(!(e==null||t==null))return cMe({offset:r,pieSettings:e,displayedData:t,cells:n})}),TA={exports:{}},Sr={};var w$;function c2e(){if(w$)return Sr;w$=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),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"),p=Symbol.for("react.view_transition"),m=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 p:return b;default:switch(b=b&&b.$$typeof,b){case o:case l:case f:case d:return b;case a:return b;default:return y}}case e:return y}}}return Sr.ContextConsumer=a,Sr.ContextProvider=o,Sr.Element=t,Sr.ForwardRef=l,Sr.Fragment=n,Sr.Lazy=f,Sr.Memo=d,Sr.Portal=e,Sr.Profiler=i,Sr.StrictMode=r,Sr.Suspense=c,Sr.SuspenseList=u,Sr.isContextConsumer=function(b){return x(b)===a},Sr.isContextProvider=function(b){return x(b)===o},Sr.isElement=function(b){return typeof b=="object"&&b!==null&&b.$$typeof===t},Sr.isForwardRef=function(b){return x(b)===l},Sr.isFragment=function(b){return x(b)===n},Sr.isLazy=function(b){return x(b)===f},Sr.isMemo=function(b){return x(b)===d},Sr.isPortal=function(b){return x(b)===e},Sr.isProfiler=function(b){return x(b)===i},Sr.isStrictMode=function(b){return x(b)===r},Sr.isSuspense=function(b){return x(b)===c},Sr.isSuspenseList=function(b){return x(b)===u},Sr.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===a||b.$$typeof===l||b.$$typeof===m||b.getModuleId!==void 0)},Sr.typeOf=x,Sr}var _$;function u2e(){return _$||(_$=1,TA.exports=c2e()),TA.exports}var d2e=u2e(),S$=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",N$=null,AA=null,JQ=t=>{if(t===N$&&Array.isArray(AA))return AA;var e=[];return _.Children.forEach(t,n=>{Xr(n)||(d2e.isFragment(n)?e=e.concat(JQ(n.props.children)):e.push(n))}),AA=e,N$=t,e};function M4(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>S$(i)):r=[S$(e)],JQ(t).forEach(i=>{var a=cm(i,"type.displayName")||cm(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var E4=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,CA={},M$;function h2e(){return M$||(M$=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})(CA)),CA}var jA,E$;function f2e(){return E$||(E$=1,jA=h2e().isPlainObject),jA}var m2e=f2e();const p2e=hl(m2e);function k$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function T$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?k$(Object(n),!0).forEach(function(r){g2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):k$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function g2e(t,e,n){return(e=x2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function x2e(t){var e=b2e(t,"string");return typeof e=="symbol"?e:e+""}function b2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function DS(){return DS=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},DS.apply(null,arguments)}var A$=(t,e,n,r,i)=>{var a=n-r,o;return o="M ".concat(t,",").concat(e),o+="L ".concat(t+n,",").concat(e),o+="L ".concat(t+n-a/2,",").concat(e+i),o+="L ".concat(t+n-a/2-r,",").concat(e+i),o+="L ".concat(t,",").concat(e," Z"),o},y2e={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},v2e=t=>{var e=li(t,y2e),{x:n,y:r,upperWidth:i,lowerWidth:a,height:o,className:l}=e,{animationEasing:c,animationDuration:u,animationBegin:d,isUpdateAnimationActive:f}=e,p=_.useRef(null),[m,x]=_.useState(-1),b=_.useRef(i),y=_.useRef(a),v=_.useRef(o),S=_.useRef(n),M=_.useRef(r),T=wx(t,"trapezoid-");if(_.useEffect(()=>{if(p.current&&p.current.getTotalLength)try{var j=p.current.getTotalLength();j&&x(j)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||o!==+o||i===0&&a===0||o===0)return null;var E=er("recharts-trapezoid",l);if(!f)return _.createElement("g",null,_.createElement("path",DS({},za(e),{className:E,d:A$(n,r,i,a,o)})));var C=b.current,k=y.current,R=v.current,A=S.current,D=M.current,U="0px ".concat(m===-1?1:m,"px"),F="".concat(m,"px 0px"),H=wX(["strokeDasharray"],u,c);return _.createElement(vx,{animationId:T,key:T,canBegin:m>0,duration:u,easing:c,isActive:f,begin:d},j=>{var $=dr(C,i,j),K=dr(k,a,j),V=dr(R,o,j),Q=dr(A,n,j),Z=dr(D,r,j);p.current&&(b.current=$,y.current=K,v.current=V,S.current=Q,M.current=Z);var ae=j>0?{transition:H,strokeDasharray:F}:{strokeDasharray:U};return _.createElement("path",DS({},za(e),{className:E,d:A$(Q,Z,$,K,V),ref:p,style:T$(T$({},ae),e.style)}))})},w2e=["option","shapeType","propTransformer","activeClassName"];function _2e(t,e){if(t==null)return{};var n,r,i=S2e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function S2e(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 C$(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 RS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?C$(Object(n),!0).forEach(function(r){N2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):C$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function N2e(t,e,n){return(e=M2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function M2e(t){var e=E2e(t,"string");return typeof e=="symbol"?e:e+""}function E2e(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 k2e(t,e){return RS(RS({},e),t)}function T2e(t,e){return t==="symbols"}function j$(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return _.createElement(MX,n);case"trapezoid":return _.createElement(v2e,n);case"sector":return _.createElement(AX,n);case"symbols":if(T2e(e))return _.createElement(WR,n);break;case"curve":return _.createElement(Eg,n);default:return null}}function A2e(t){return _.isValidElement(t)?t.props:t}function k4(t){var{option:e,shapeType:n,propTransformer:r=k2e,activeClassName:i="recharts-active-shape"}=t,a=_2e(t,w2e),o;if(_.isValidElement(e))o=_.cloneElement(e,RS(RS({},a),A2e(e)));else if(typeof e=="function")o=e(a,a.index);else if(p2e(e)&&typeof e!="boolean"){var l=r(e,a);o=_.createElement(j$,{shapeType:n,elementProps:l})}else{var c=a;o=_.createElement(j$,{shapeType:n,elementProps:c})}return a.isActive?_.createElement(oi,{className:i},o):o}var T4=(t,e,n)=>{var r=Lr();return(i,a)=>o=>{t?.(i,a,o),r(uQ({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},A4=t=>{var e=Lr();return(n,r)=>i=>{t?.(n,r,i),e(V_e())}},C4=(t,e,n)=>{var r=Lr();return(i,a)=>o=>{t?.(i,a,o),r(G_e({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function oM(t){var{tooltipEntrySettings:e}=t,n=Lr(),r=ra(),i=_.useRef(null);return _.useLayoutEffect(()=>{r||(i.current===null?n(z_e(e)):i.current!==e&&n(B_e({prev:i.current,next:e})),i.current=e)},[e,n,r]),_.useLayoutEffect(()=>()=>{i.current&&(n($_e(i.current)),i.current=null)},[n]),null}function j4(t){var{legendPayload:e}=t,n=Lr(),r=ra(),i=_.useRef(null);return _.useLayoutEffect(()=>{r||(i.current===null?n(xX(e)):i.current!==e&&n(bX({prev:i.current,next:e})),i.current=e)},[n,r,e]),_.useLayoutEffect(()=>()=>{i.current&&(n(yX(i.current)),i.current=null)},[n]),null}function C2e(t){var{legendPayload:e}=t,n=Lr(),r=It(Vn),i=_.useRef(null);return _.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(xX(e)):i.current!==e&&n(bX({prev:i.current,next:e})),i.current=e)},[n,r,e]),_.useLayoutEffect(()=>()=>{i.current&&(n(yX(i.current)),i.current=null)},[n]),null}var PA,j2e=()=>{var[t]=_.useState(()=>X0("uid-"));return t},P2e=(PA=Dae.useId)!==null&&PA!==void 0?PA:j2e;function eZ(t,e){var n=P2e();return e||(t?"".concat(t,"-").concat(n):n)}var D2e=_.createContext(void 0),lM=t=>{var{id:e,type:n,children:r}=t,i=eZ("recharts-".concat(n),e);return _.createElement(D2e.Provider,{value:i},r(i))},R2e={cartesianItems:[],polarItems:[]},tZ=Vs({name:"graphicalItems",initialState:R2e,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:Zr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ol(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:Zr()},removeCartesianGraphicalItem:{reducer(t,e){var n=Ol(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:Zr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:Zr()},removePolarGraphicalItem:{reducer(t,e){var n=Ol(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:Zr()}}}),{addCartesianGraphicalItem:O2e,replaceCartesianGraphicalItem:L2e,removeCartesianGraphicalItem:F2e,addPolarGraphicalItem:I2e,removePolarGraphicalItem:U2e}=tZ.actions,z2e=tZ.reducer,B2e=t=>{var e=Lr(),n=_.useRef(null);return _.useLayoutEffect(()=>{n.current===null?e(O2e(t)):n.current!==t&&e(L2e({prev:n.current,next:t})),n.current=t},[e,t]),_.useLayoutEffect(()=>()=>{n.current&&(e(F2e(n.current)),n.current=null)},[e]),null},P4=_.memo(B2e);function $2e(t){var e=Lr();return _.useLayoutEffect(()=>(e(I2e(t)),()=>{e(U2e(t))}),[e,t]),null}var H2e=["key"],V2e=["onMouseEnter","onClick","onMouseLeave"],G2e=["id"],q2e=["id"];function P$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function pi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?P$(Object(n),!0).forEach(function(r){W2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):P$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function W2e(t,e,n){return(e=K2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function K2e(t){var e=X2e(t,"string");return typeof e=="symbol"?e:e+""}function X2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Mh(){return Mh=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Mh.apply(null,arguments)}function cM(t,e){if(t==null)return{};var n,r,i=Y2e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Y2e(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 Q2e(t){var e=_.useMemo(()=>M4(t.children,cv),[t.children]),n=It(r=>o2e(r,t.id,e));return n==null?null:_.createElement(C2e,{legendPayload:n})}var Z2e=_.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:a,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:a,fill:o,dataKey:e,nameKey:n,name:Lh(l,e),hide:c,type:u,color:o,unit:""}};return _.createElement(oM,{tooltipEntrySettings:d})}),J2e=(t,e)=>t>e?"start":t<e?"end":"middle",eMe=(t,e,n)=>es(typeof e=="function"?e(t):e,n,n*.8),tMe=(t,e,n)=>{var{top:r,left:i,width:a,height:o}=e,l=EX(a,o),c=i+es(t.cx,a,a/2),u=r+es(t.cy,o,o/2),d=es(t.innerRadius,l,0),f=eMe(n,t.outerRadius,l),p=t.maxRadius||Math.sqrt(a*a+o*o)/2;return{cx:c,cy:u,innerRadius:d,outerRadius:f,maxRadius:p}},nMe=(t,e)=>{var n=ya(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function rMe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var iMe=(t,e)=>{if(_.isValidElement(t))return _.cloneElement(t,e);if(typeof t=="function")return t(e);var n=er("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=cM(e,H2e);return _.createElement(Eg,Mh({},i,{type:"linear",className:n}))},aMe=(t,e,n)=>{if(_.isValidElement(t))return _.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),_.isValidElement(r)))return r;var i=er("recharts-pie-label-text",rMe(t));return _.createElement(rM,Mh({},e,{alignmentBaseline:"middle",className:i}),r)};function sMe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:a,dataKey:o}=n;if(!r||!i||!e)return null;var l=xs(n),c=lm(i),u=lm(a),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,f=e.map((p,m)=>{var x=(p.startAngle+p.endAngle)/2,b=zi(p.cx,p.cy,p.outerRadius+d,x),y=pi(pi(pi(pi({},l),p),{},{stroke:"none"},c),{},{index:m,textAnchor:J2e(b.x,p.cx)},b),v=pi(pi(pi(pi({},l),p),{},{fill:"none",stroke:p.fill},u),{},{index:m,points:[zi(p.cx,p.cy,p.outerRadius,x),b],key:"line"});return _.createElement(ts,{zIndex:bi.label,key:"label-".concat(p.startAngle,"-").concat(p.endAngle,"-").concat(p.midAngle,"-").concat(m)},_.createElement(oi,null,a&&iMe(a,v),aMe(i,y,br(p,o))))});return _.createElement(oi,{className:"recharts-pie-labels"},f)}function oMe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?_.createElement(iM,{label:i}):_.createElement(sMe,{sectors:e,props:n,showLabels:r})}function lMe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:o}=t,l=It(Nh),c=It(g4),u=It(C1e),{onMouseEnter:d,onClick:f,onMouseLeave:p}=i,m=cM(i,V2e),x=T4(d,i.dataKey,o),b=A4(p),y=C4(f,i.dataKey,o);return e==null||e.length===0?null:_.createElement(_.Fragment,null,e.map((v,S)=>{if(v?.startAngle===0&&v?.endAngle===0&&e.length!==1)return null;var M=u==null||u===o,T=String(S)===l&&(c==null||i.dataKey===c)&&M,E=l?r:null,C=n&&T?n:E,k=pi(pi({},v),{},{stroke:v.stroke,tabIndex:-1,[rX]:S,[iX]:i.dataKey});return _.createElement(oi,Mh({key:"sector-".concat(v?.startAngle,"-").concat(v?.endAngle,"-").concat(v.midAngle,"-").concat(S),tabIndex:-1,className:"recharts-pie-sector"},zy(m,v,S),{onMouseEnter:x(v,S),onMouseLeave:b(v,S),onClick:y(v,S)}),_.createElement(k4,Mh({option:a??C,index:S,shapeType:"sector",isActive:T},k)))}))}function cMe(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:a}=t,{cornerRadius:o,startAngle:l,endAngle:c,dataKey:u,nameKey:d,tooltipType:f}=n,p=Math.abs(n.minAngle),m=nMe(l,c),x=Math.abs(m),b=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,y=r.filter(C=>br(C,u,0)!==0).length,v=(x>=360?y:y-1)*b,S=x-y*p-v,M=r.reduce((C,k)=>{var R=br(k,u,0);return C+(zt(R)?R:0)},0),T;if(M>0){var E;T=r.map((C,k)=>{var R=br(C,u,0),A=br(C,d,k),D=tMe(n,a,C),U=(zt(R)?R:0)/M,F,H=pi(pi({},C),i&&i[k]&&i[k].props);k?F=E.endAngle+ya(m)*b*(R!==0?1:0):F=l;var j=F+ya(m)*((R!==0?p:0)+U*S),$=(F+j)/2,K=(D.innerRadius+D.outerRadius)/2,V=[{name:A,value:R,payload:H,dataKey:u,type:f}],Q=zi(D.cx,D.cy,K,$);return E=pi(pi(pi(pi({},n.presentationProps),{},{percent:U,cornerRadius:typeof o=="string"?parseFloat(o):o,name:A,tooltipPayload:V,midAngle:$,middleRadius:K,tooltipPosition:Q},H),D),{},{value:R,dataKey:u,startAngle:F,endAngle:j,payload:H,paddingAngle:ya(m)*b}),E})}return T}function uMe(t){var{showLabels:e,sectors:n,children:r}=t,i=_.useMemo(()=>!e||!n?[]:n.map(a=>({value:a.value,payload:a.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:a.cx,cy:a.cy,innerRadius:a.innerRadius,outerRadius:a.outerRadius,startAngle:a.startAngle,endAngle:a.endAngle,clockWise:!1},fill:a.fill})),[n,e]);return _.createElement(GNe,{value:e?i:void 0},r)}function dMe(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:a,animationBegin:o,animationDuration:l,animationEasing:c,activeShape:u,inactiveShape:d,onAnimationStart:f,onAnimationEnd:p}=e,m=wx(e,"recharts-pie-"),x=n.current,[b,y]=_.useState(!1),v=_.useCallback(()=>{typeof p=="function"&&p(),y(!1)},[p]),S=_.useCallback(()=>{typeof f=="function"&&f(),y(!0)},[f]);return _.createElement(uMe,{showLabels:!b,sectors:i},_.createElement(vx,{animationId:m,begin:o,duration:l,isActive:a,easing:c,onAnimationStart:S,onAnimationEnd:v,key:m},M=>{var T=[],E=i&&i[0],C=E?.startAngle;return i?.forEach((k,R)=>{var A=x&&x[R],D=R>0?cm(k,"paddingAngle",0):0;if(A){var U=dr(A.endAngle-A.startAngle,k.endAngle-k.startAngle,M),F=pi(pi({},k),{},{startAngle:C+D,endAngle:C+U+D});T.push(F),C=F.endAngle}else{var{endAngle:H,startAngle:j}=k,$=dr(0,H-j,M),K=pi(pi({},k),{},{startAngle:C+D,endAngle:C+$+D});T.push(K),C=K.endAngle}}),n.current=T,_.createElement(oi,null,_.createElement(lMe,{sectors:T,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),_.createElement(oMe,{showLabels:!b,sectors:i,props:e}),e.children)}var hMe={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:bi.area};function fMe(t){var{id:e}=t,n=cM(t,G2e),{hide:r,className:i,rootTabIndex:a}=t,o=_.useMemo(()=>M4(t.children,cv),[t.children]),l=It(d=>l2e(d,e,o)),c=_.useRef(null),u=er("recharts-pie",i);return r||l==null?(c.current=null,_.createElement(oi,{tabIndex:a,className:u})):_.createElement(ts,{zIndex:t.zIndex},_.createElement(Z2e,{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}),_.createElement(oi,{tabIndex:a,className:u},_.createElement(dMe,{props:pi(pi({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function nZ(t){var e=li(t,hMe),{id:n}=e,r=cM(e,q2e),i=xs(r);return _.createElement(lM,{id:n,type:"pie"},a=>_.createElement(_.Fragment,null,_.createElement($2e,{type:"pie",id:a,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:e.maxRadius}),_.createElement(Q2e,Mh({},r,{id:a})),_.createElement(fMe,Mh({},r,{id:a}))))}nZ.displayName="Pie";var mMe=["points"];function D$(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 DA(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?D$(Object(n),!0).forEach(function(r){pMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):D$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function pMe(t,e,n){return(e=gMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gMe(t){var e=xMe(t,"string");return typeof e=="symbol"?e:e+""}function xMe(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 OS(){return OS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},OS.apply(null,arguments)}function bMe(t,e){if(t==null)return{};var n,r,i=yMe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function 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}function vMe(t){var{option:e,dotProps:n,className:r}=t;if(_.isValidElement(e))return _.cloneElement(e,n);if(typeof e=="function")return e(n);var i=er(r,typeof e!="boolean"?e.className:""),a=n??{},{points:o}=a,l=bMe(a,mMe);return _.createElement(KQ,OS({},l,{className:i}))}function wMe(t,e){return t==null?!1:e?!0:t.length===1}function rZ(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:l,clipPathId:c,zIndex:u=bi.scatter}=t;if(!wMe(e,n))return null;var d=E4(n),f=Zfe(n),p=e.map((x,b)=>{var y,v,S=DA(DA(DA({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:a,value:x.value,payload:x.payload,points:e});return _.createElement(vMe,{key:"dot-".concat(b),option:n,dotProps:S,className:i})}),m={};return l&&c!=null&&(m.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(c,")")),_.createElement(ts,{zIndex:u},_.createElement(oi,OS({className:r},m),p))}function R$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function O$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?R$(Object(n),!0).forEach(function(r){_Me(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):R$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _Me(t,e,n){return(e=SMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function SMe(t){var e=NMe(t,"string");return typeof e=="symbol"?e:e+""}function NMe(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 MMe={xAxis:{},yAxis:{},zAxis:{}},iZ=Vs({name:"cartesianAxis",initialState:MMe,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:Zr()},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:Zr()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:Zr()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:Zr()},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:Zr()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:Zr()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:Zr()},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:Zr()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:Zr()},updateYAxisWidth(t,e){var{id:n,width:r}=e.payload,i=t.yAxis[n];if(i){var a=i.widthHistory||[];if(a.length===3&&a[0]===a[2]&&r===a[1]&&r!==i.width&&Math.abs(r-a[0])<=1)return;var o=[...a,r].slice(-3);t.yAxis[n]=O$(O$({},t.yAxis[n]),{},{width:r,widthHistory:o})}}}}),{addXAxis:EMe,replaceXAxis:kMe,removeXAxis:TMe,addYAxis:AMe,replaceYAxis:CMe,removeYAxis:jMe,addZAxis:FXe,replaceZAxis:IXe,removeZAxis:UXe,updateYAxisWidth:PMe}=iZ.actions,DMe=iZ.reducer,RMe=nt([na],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),OMe=nt([RMe,qu,Wu],(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)}}),uM=()=>It(OMe),LMe=()=>It(O1e);function L$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function RA(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?L$(Object(n),!0).forEach(function(r){FMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):L$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function FMe(t,e,n){return(e=IMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function IMe(t){var e=UMe(t,"string");return typeof e=="symbol"?e:e+""}function UMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var zMe=t=>{var{point:e,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=t;if(i===!1||e.x==null||e.y==null)return null;var l={index:n,dataKey:a,cx:e.x,cy:e.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:e.payload,value:e.value},c=RA(RA(RA({},l),lm(i)),KR(i)),u;return _.isValidElement(i)?u=_.cloneElement(i,c):typeof i=="function"?u=i(c):u=_.createElement(KQ,c),_.createElement(oi,{className:"recharts-active-dot",clipPath:o},u)};function g3(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=bi.activeDot}=t,l=It(Nh),c=LMe();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return Xr(u)?null:_.createElement(ts,{zIndex:o},_.createElement(zMe,{point:u,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var BMe="Invariant failed";function $Me(t,e){throw new Error(BMe)}var HMe=["x","y"];function x3(){return x3=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},x3.apply(null,arguments)}function F$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ib(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?F$(Object(n),!0).forEach(function(r){VMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):F$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function VMe(t,e,n){return(e=GMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function GMe(t){var e=qMe(t,"string");return typeof e=="symbol"?e:e+""}function qMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function WMe(t,e){if(t==null)return{};var n,r,i=KMe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function KMe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function XMe(t,e){var{x:n,y:r}=t,i=WMe(t,HMe),a="".concat(n),o=parseInt(a,10),l="".concat(r),c=parseInt(l,10),u="".concat(e.height||i.height),d=parseInt(u,10),f="".concat(e.width||i.width),p=parseInt(f,10);return Ib(Ib(Ib(Ib(Ib({},e),i),o?{x:o}:{}),c?{y:c}:{}),{},{height:d,width:p,name:e.name,radius:e.radius})}function LS(t){return _.createElement(k4,x3({shapeType:"rectangle",propTransformer:XMe,activeClassName:"recharts-active-bar"},t))}var YMe=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(zt(e))return e;var a=zt(r)||Xr(r);return a?e(r,i):(a||$Me(),n)}},QMe={},aZ=Vs({name:"errorBars",initialState:QMe,reducers:{addErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]||(t[n]=[]),t[n].push(r)},replaceErrorBar:(t,e)=>{var{itemId:n,prev:r,next:i}=e.payload;t[n]&&(t[n]=t[n].map(a=>a.dataKey===r.dataKey&&a.direction===r.direction?i:a))},removeErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]&&(t[n]=t[n].filter(i=>i.dataKey!==r.dataKey||i.direction!==r.direction))}}}),{addErrorBar:zXe,replaceErrorBar:BXe,removeErrorBar:$Xe}=aZ.actions,ZMe=aZ.reducer,JMe=["children"];function eEe(t,e){if(t==null)return{};var n,r,i=tEe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function tEe(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 nEe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},rEe=_.createContext(nEe);function sZ(t){var{children:e}=t,n=eEe(t,JMe);return _.createElement(rEe.Provider,{value:n},e)}function dM(t,e){var n,r,i=It(u=>kc(u,t)),a=It(u=>Tc(u,e)),o=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:fa.allowDataOverflow,l=(r=a?.allowDataOverflow)!==null&&r!==void 0?r:ma.allowDataOverflow,c=o||l;return{needClip:c,needClipX:o,needClipY:l}}function D4(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=uM(),{needClipX:a,needClipY:o,needClip:l}=dM(e,n);if(!l||!i)return null;var{x:c,y:u,width:d,height:f}=i;return _.createElement("clipPath",{id:"clipPath-".concat(r)},_.createElement("rect",{x:a?c:c-d/2,y:o?u:u-f/2,width:a?d:d*2,height:o?f:f*2}))}function iEe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&yr(t.zIndex)?t.zIndex:e}var OA={exports:{}},LA={};var I$;function aEe(){if(I$)return LA;I$=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,a=t.useEffect,o=t.useMemo,l=t.useDebugValue;return LA.useSyncExternalStoreWithSelector=function(c,u,d,f,p){var m=i(null);if(m.current===null){var x={hasValue:!1,value:null};m.current=x}else x=m.current;m=o(function(){function y(E){if(!v){if(v=!0,S=E,E=f(E),p!==void 0&&x.hasValue){var C=x.value;if(p(C,E))return M=C}return M=E}if(C=M,n(S,E))return C;var k=f(E);return p!==void 0&&p(C,k)?(S=E,C):(S=E,M=k)}var v=!1,S,M,T=d===void 0?null:d;return[function(){return y(u())},T===null?void 0:function(){return y(T())}]},[u,d,f,p]);var b=r(c,m[0],m[1]);return a(function(){x.hasValue=!0,x.value=b},[b]),l(b),b},LA}var U$;function sEe(){return U$||(U$=1,OA.exports=aEe()),OA.exports}sEe();function oEe(t){t()}function lEe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){oEe(()=>{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 z$={notify(){},get:()=>[]};function cEe(t,e){let n,r=z$,i=0,a=!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 a}function d(){i++,n||(n=t.subscribe(c),r=lEe())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=z$)}function p(){a||(a=!0,d())}function m(){a&&(a=!1,f())}const x={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:u,trySubscribe:p,tryUnsubscribe:m,getListeners:()=>r};return x}var uEe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",dEe=uEe(),hEe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",fEe=hEe(),mEe=()=>dEe||fEe?_.useLayoutEffect:_.useEffect,pEe=mEe();function B$(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function gEe(t,e){if(B$(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])||!B$(t[n[i]],e[n[i]]))return!1;return!0}var xEe=Symbol.for("react-redux-context"),bEe=typeof globalThis<"u"?globalThis:{};function yEe(){if(!_.createContext)return{};const t=bEe[xEe]??=new Map;let e=t.get(_.createContext);return e||(e=_.createContext(null),t.set(_.createContext,e)),e}var vEe=yEe();function wEe(t){const{children:e,context:n,serverState:r,store:i}=t,a=_.useMemo(()=>{const c=cEe(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),o=_.useMemo(()=>i.getState(),[i]);pEe(()=>{const{subscription:c}=a;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),o!==i.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[a,o]);const l=n||vEe;return _.createElement(l.Provider,{value:a},e)}var _Ee=wEe,SEe=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function NEe(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function uv(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(SEe.has(r)){if(t[r]==null&&e[r]==null)continue;if(!gEe(t[r],e[r]))return!1}else if(!NEe(t[r],e[r]))return!1;return!0}var MEe=["onMouseEnter","onMouseLeave","onClick"],EEe=["value","background","tooltipPosition"],kEe=["id"],TEe=["onMouseEnter","onClick","onMouseLeave"];function $u(){return $u=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},$u.apply(null,arguments)}function $$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ds(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$$(Object(n),!0).forEach(function(r){AEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function AEe(t,e,n){return(e=CEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function CEe(t){var e=jEe(t,"string");return typeof e=="symbol"?e:e+""}function jEe(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 FS(t,e){if(t==null)return{};var n,r,i=PEe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function PEe(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 DEe=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Lh(n,e),payload:t}]},REe=_.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:a,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(a,e),hide:o,type:c,color:i,unit:l}};return _.createElement(oM,{tooltipEntrySettings:u})});function OEe(t){var e=It(Nh),{data:n,dataKey:r,background:i,allOtherBarProps:a}=t,{onMouseEnter:o,onMouseLeave:l,onClick:c}=a,u=FS(a,MEe),d=T4(o,r),f=A4(l),p=C4(c,r);if(!i||n==null)return null;var m=lm(i);return _.createElement(ts,{zIndex:iEe(i,bi.barBackground)},n.map((x,b)=>{var{value:y,background:v,tooltipPosition:S}=x,M=FS(x,EEe);if(!v)return null;var T=d(x,b),E=f(x,b),C=p(x,b),k=ds(ds(ds(ds(ds({option:i,isActive:String(b)===e},M),{},{fill:"#eee"},v),m),zy(u,x,b)),{},{onMouseEnter:T,onMouseLeave:E,onClick:C,dataKey:r,index:b,className:"recharts-bar-background-rectangle"});return _.createElement(LS,$u({key:"background-bar-".concat(b)},k))}))}function LEe(t){var{showLabels:e,children:n,rects:r}=t,i=r?.map(a=>{var o={x:a.x,y:a.y,width:a.width,lowerWidth:a.width,upperWidth:a.width,height:a.height};return ds(ds({},o),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:o,fill:a.fill})});return _.createElement(_4,{value:e?i:void 0},n)}function FEe(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:a,dataKey:o}=t,l=It(Nh),c=It(g4),u=n&&String(a)===l&&(c==null||o===c),d=u?n:e;return u?_.createElement(ts,{zIndex:bi.activeBar},_.createElement(LS,$u({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o}))):_.createElement(LS,$u({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o}))}function IEe(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:a}=t;return _.createElement(LS,$u({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:a}))}function UEe(t){var e,{data:n,props:r}=t,i=(e=xs(r))!==null&&e!==void 0?e:{},{id:a}=i,o=FS(i,kEe),{shape:l,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:p}=r,m=FS(r,TEe),x=T4(d,c),b=A4(p),y=C4(f,c);return n?_.createElement(_.Fragment,null,n.map((v,S)=>_.createElement(oi,$u({key:"rectangle-".concat(v?.x,"-").concat(v?.y,"-").concat(v?.value,"-").concat(S),className:"recharts-bar-rectangle"},zy(m,v,S),{onMouseEnter:x(v,S),onMouseLeave:b(v,S),onClick:y(v,S)}),u?_.createElement(FEe,{shape:l,activeBar:u,baseProps:o,entry:v,index:S,dataKey:c}):_.createElement(IEe,{shape:l,baseProps:o,entry:v,index:S,dataKey:c})))):null}function zEe(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:a,animationBegin:o,animationDuration:l,animationEasing:c,onAnimationEnd:u,onAnimationStart:d}=e,f=n.current,p=wx(e,"recharts-bar-"),[m,x]=_.useState(!1),b=!m,y=_.useCallback(()=>{typeof u=="function"&&u(),x(!1)},[u]),v=_.useCallback(()=>{typeof d=="function"&&d(),x(!0)},[d]);return _.createElement(LEe,{showLabels:b,rects:r},_.createElement(vx,{animationId:p,begin:o,duration:l,isActive:a,easing:c,onAnimationEnd:y,onAnimationStart:v,key:p},S=>{var M=S===1?r:r?.map((T,E)=>{var C=f&&f[E];if(C)return ds(ds({},T),{},{x:dr(C.x,T.x,S),y:dr(C.y,T.y,S),width:dr(C.width,T.width,S),height:dr(C.height,T.height,S)});if(i==="horizontal"){var k=dr(0,T.height,S),R=dr(T.stackedBarStart,T.y,S);return ds(ds({},T),{},{y:R,height:k})}var A=dr(0,T.width,S),D=dr(T.stackedBarStart,T.x,S);return ds(ds({},T),{},{width:A,x:D})});return S>0&&(n.current=M??null),M==null?null:_.createElement(oi,null,_.createElement(UEe,{props:e,data:M}))}),_.createElement(iM,{label:e.label}),e.children)}function BEe(t){var e=_.useRef(null);return _.createElement(zEe,{previousRectanglesRef:e,props:t})}var oZ=0,$Ee=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:br(t,e)}};class HEe extends _.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:a,yAxisId:o,needClip:l,background:c,id:u}=this.props;if(e||n==null)return null;var d=er("recharts-bar",i),f=u;return _.createElement(oi,{className:d,id:u},l&&_.createElement("defs",null,_.createElement(D4,{clipPathId:f,xAxisId:a,yAxisId:o})),_.createElement(oi,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(f,")"):void 0},_.createElement(OEe,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),_.createElement(BEe,this.props)))}}var VEe={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:oZ,xAxisId:0,yAxisId:0,zIndex:bi.bar};function GEe(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d}=t,{needClip:f}=dM(e,n),p=km(),m=ra(),x=M4(t.children,cv),b=It(S=>yke(S,e,n,m,t.id,x));if(p!=="vertical"&&p!=="horizontal")return null;var y,v=b?.[0];return v==null||v.height==null||v.width==null?y=0:y=p==="vertical"?v.height/2:v.width/2,_.createElement(sZ,{xAxisId:e,yAxisId:n,data:b,dataPointFormatter:$Ee,errorBarOffset:y},_.createElement(HEe,$u({},t,{layout:p,needClip:f,data:b,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d})))}function qEe(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:a,xAxis:o,yAxis:l,xAxisTicks:c,yAxisTicks:u,stackedData:d,displayedData:f,offset:p,cells:m,parentViewBox:x,dataStartIndex:b}=t,y=e==="horizontal"?l:o,v=d?y.scale.domain():null,S=pxe({numericAxis:y}),M=y.scale(S);return f.map((T,E)=>{var C,k,R,A,D,U;d?C=uxe(d[E+b],v):(C=br(T,n),Array.isArray(C)||(C=[S,C]));var F=YMe(r,oZ)(C[1],E);if(e==="horizontal"){var H,[j,$]=[l.scale(C[0]),l.scale(C[1])];k=a8({axis:o,ticks:c,bandSize:a,offset:i.offset,entry:T,index:E}),R=(H=$??j)!==null&&H!==void 0?H:void 0,A=i.size;var K=j-$;if(D=Hs(K)?0:K,U={x:k,y:p.top,width:A,height:p.height},Math.abs(F)>0&&Math.abs(D)<Math.abs(F)){var V=ya(D||F)*(Math.abs(F)-Math.abs(D));R-=V,D+=V}}else{var[Q,Z]=[o.scale(C[0]),o.scale(C[1])];if(k=Q,R=a8({axis:l,ticks:u,bandSize:a,offset:i.offset,entry:T,index:E}),A=Z-Q,D=i.size,U={x:p.left,y:R,width:p.width,height:D},Math.abs(F)>0&&Math.abs(A)<Math.abs(F)){var ae=ya(A||F)*(Math.abs(F)-Math.abs(A));A+=ae}}if(k==null||R==null||A==null||D==null)return null;var B=ds(ds({},T),{},{stackedBarStart:M,x:k,y:R,width:A,height:D,value:d?C:C[1],payload:T,background:U,tooltipPosition:{x:k+A/2,y:R+D/2},parentViewBox:x},m&&m[E]&&m[E].props);return B}).filter(Boolean)}function WEe(t){var e=li(t,VEe),n=ra();return _.createElement(lM,{id:e.id,type:"bar"},r=>_.createElement(_.Fragment,null,_.createElement(j4,{legendPayload:DEe(e)}),_.createElement(REe,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),_.createElement(P4,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:tX(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),_.createElement(ts,{zIndex:e.zIndex},_.createElement(GEe,$u({},e,{id:r})))))}var lZ=_.memo(WEe,uv);lZ.displayName="Bar";function H$(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?H$(Object(n),!0).forEach(function(r){KEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):H$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function KEe(t,e,n){return(e=XEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function XEe(t){var e=YEe(t,"string");return typeof e=="symbol"?e:e+""}function YEe(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 QEe=(t,e)=>e,ZEe=(t,e,n)=>n,JEe=(t,e,n,r)=>r,eke=(t,e,n,r,i)=>i,dv=nt([tv,eke],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),tke=nt([dv],t=>t?.maxBarSize),nke=(t,e,n,r,i,a)=>a,V$=(t,e,n)=>{var r=n??t;if(!Xr(r))return es(r,e,0)},rke=nt([Vn,tv,QEe,ZEe,JEe],(t,e,n,r,i)=>e.filter(a=>t==="horizontal"?a.xAxisId===n:a.yAxisId===r).filter(a=>a.isPanorama===i).filter(a=>a.hide===!1).filter(a=>a.type==="bar")),ike=(t,e,n,r)=>{var i=Vn(t);return i==="horizontal"?ly(t,"yAxis",n,r):ly(t,"xAxis",e,r)},ake=(t,e,n)=>{var r=Vn(t);return r==="horizontal"?I6(t,"xAxis",e):I6(t,"yAxis",n)},ske=(t,e,n)=>{var r={},i=t.filter(X2),a=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,p=f.map(x=>x.dataKey),m=V$(e,n,f[0].barSize);return{stackId:d,dataKeys:p,barSize:m}}),c=a.map(u=>{var d=[u.dataKey].filter(p=>p!=null),f=V$(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...l,...c]},oke=nt([rke,Pwe,ake],ske),lke=(t,e,n,r,i)=>{var a,o,l=dv(t,e,n,r,i);if(l!=null){var c=Vn(t),u=MY(t),{maxBarSize:d}=l,f=Xr(d)?u:d,p,m;return c==="horizontal"?(p=bc(t,"xAxis",e,r),m=xc(t,"xAxis",e,r)):(p=bc(t,"yAxis",n,r),m=xc(t,"yAxis",n,r)),(a=(o=wh(p,m,!0))!==null&&o!==void 0?o:f)!==null&&a!==void 0?a:0}},cZ=(t,e,n,r)=>{var i=Vn(t),a,o;return i==="horizontal"?(a=bc(t,"xAxis",e,r),o=xc(t,"xAxis",e,r)):(a=bc(t,"yAxis",n,r),o=xc(t,"yAxis",n,r)),wh(a,o)};function cke(t,e,n,r,i){var a=r.length;if(!(a<1)){var o=es(t,n,0,!0),l,c=[];if(yr(r[0].barSize)){var u=!1,d=n/a,f=r.reduce((v,S)=>v+(S.barSize||0),0);f+=(a-1)*o,f>=n&&(f-=(a-1)*o,o=0),f>=n&&d>0&&(u=!0,d*=.9,f=a*d);var p=(n-f)/2>>0,m={offset:p-o,size:0};l=r.reduce((v,S)=>{var M,T={stackId:S.stackId,dataKeys:S.dataKeys,position:{offset:m.offset+m.size+o,size:u?d:(M=S.barSize)!==null&&M!==void 0?M:0}},E=[...v,T];return m=E[E.length-1].position,E},c)}else{var x=es(e,n,0,!0);n-2*x-(a-1)*o<=0&&(o=0);var b=(n-2*x-(a-1)*o)/a;b>1&&(b>>=0);var y=yr(i)?Math.min(b,i):b;l=r.reduce((v,S,M)=>[...v,{stackId:S.stackId,dataKeys:S.dataKeys,position:{offset:x+(b+o)*M+(b-y)/2,size:y}}],c)}return l}}var uke=(t,e,n,r,i,a,o)=>{var l=Xr(o)?e:o,c=cke(n,r,i!==a?i:a,t,l);return i!==a&&c!=null&&(c=c.map(u=>Xw(Xw({},u),{},{position:Xw(Xw({},u.position),{},{offset:u.position.offset-i/2})}))),c},dke=nt([oke,MY,jwe,EY,lke,cZ,tke],uke),hke=(t,e,n,r)=>bc(t,"xAxis",e,r),fke=(t,e,n,r)=>bc(t,"yAxis",n,r),mke=(t,e,n,r)=>xc(t,"xAxis",e,r),pke=(t,e,n,r)=>xc(t,"yAxis",n,r),gke=nt([dke,dv],(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}}),xke=(t,e)=>{var n=K2(e);if(!(!t||n==null||e==null)){var{stackId:r}=e;if(r!=null){var i=t[r];if(i){var{stackedData:a}=i;if(a)return a.find(o=>o.key===n)}}}},bke=nt([ike,dv],xke),yke=nt([na,aO,hke,fke,mke,pke,gke,Vn,Qy,cZ,bke,dv,nke],(t,e,n,r,i,a,o,l,c,u,d,f,p)=>{var{chartData:m,dataStartIndex:x,dataEndIndex:b}=c;if(!(f==null||o==null||e==null||l!=="horizontal"&&l!=="vertical"||n==null||r==null||i==null||a==null||u==null)){var{data:y}=f,v;if(y!=null&&y.length>0?v=y:v=m?.slice(x,b+1),v!=null)return qEe({layout:l,barSettings:f,pos:o,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:d,displayedData:v,offset:t,cells:p,dataStartIndex:x})}}),uZ=t=>{var{chartData:e}=t,n=Lr(),r=ra();return _.useEffect(()=>r?()=>{}:(n(Q6(e)),()=>{n(Q6(void 0))}),[e,n,r]),null},G$={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},dZ=Vs({name:"brush",initialState:G$,reducers:{setBrushSettings(t,e){return e.payload==null?G$:e.payload}}}),{setBrushSettings:HXe}=dZ.actions,vke=dZ.reducer;function q$(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?q$(Object(n),!0).forEach(function(r){hZ(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):q$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function hZ(t,e,n){return(e=wke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wke(t){var e=_ke(t,"string");return typeof e=="symbol"?e:e+""}function _ke(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 Ske=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return{x:Math.min(n,i),y:Math.min(r,a),width:Math.abs(i-n),height:Math.abs(a-r)}},Nke=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return Ske({x:e,y:n},{x:r,y:i})};class hM{static create(e){return new hM(e)}constructor(e){this.scale=e}get domain(){return this.scale.domain}get range(){return this.scale.range}get rangeMin(){return this.range()[0]}get rangeMax(){return this.range()[1]}get bandwidth(){return this.scale.bandwidth}apply(e){var{bandAware:n,position:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e!==void 0){if(r)switch(r){case"start":return this.scale(e);case"middle":{var i=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+i}case"end":{var a=this.bandwidth?this.bandwidth():0;return this.scale(e)+a}default:return this.scale(e)}if(n){var 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}}hZ(hM,"EPS",1e-4);var Mke=t=>{var e=Object.keys(t).reduce((n,r)=>Yw(Yw({},n),{},{[r]:hM.create(t[r])}),{});return Yw(Yw({},e),{},{apply(n){var{bandAware:r,position:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Object.fromEntries(Object.entries(n).map(a=>{var[o,l]=a;return[o,e[o].apply(l,{bandAware:r,position:i})]}))},isInRange(n){return Object.keys(n).every(r=>e[r].isInRange(n[r]))}})};function Eke(t){return(t%180+180)%180}var kke=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=Eke(i),o=a*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)},Tke={dots:[],areas:[],lines:[]},fZ=Vs({name:"referenceElements",initialState:Tke,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:VXe,removeDot:GXe,addArea:qXe,removeArea:WXe,addLine:Ake,removeLine:Cke}=fZ.actions,jke=fZ.reducer,mZ=_.createContext(void 0),Pke=t=>{var{children:e}=t,[n]=_.useState("".concat(X0("recharts"),"-clip")),r=uM();if(r==null)return null;var{x:i,y:a,width:o,height:l}=r;return _.createElement(mZ.Provider,{value:n},_.createElement("defs",null,_.createElement("clipPath",{id:n},_.createElement("rect",{x:i,y:a,height:l,width:o}))),e)},Dke=()=>_.useContext(mZ);function W$(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 K$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?W$(Object(n),!0).forEach(function(r){Rke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):W$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Rke(t,e,n){return(e=Oke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Oke(t){var e=Lke(t,"string");return typeof e=="symbol"?e:e+""}function Lke(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 IS(){return IS=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},IS.apply(null,arguments)}var Fke=(t,e)=>{var n;if(_.isValidElement(t))n=_.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!yr(e.x1)||!yr(e.y1)||!yr(e.x2)||!yr(e.y2))return null;n=_.createElement("line",IS({},e,{className:"recharts-reference-line-line"}))}return n},Ike=(t,e,n,r,i,a)=>{var{x:o,width:l}=a,c=i.y.apply(t,{position:n});if(Hs(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},Uke=(t,e,n,r,i,a)=>{var{y:o,height:l}=a,c=i.x.apply(t,{position:n});if(Hs(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},zke=(t,e,n,r)=>{var i=t.map(a=>r.apply(a,{position:n}));return e==="discard"&&i.some(a=>!r.isInRange(a))?null:i},Bke=(t,e,n,r,i,a)=>{var{x:o,y:l,segment:c,ifOverflow:u}=a,d=cl(o),f=cl(l);return f?Ike(l,u,n,i,t,e):d?Uke(o,u,n,r,t,e):c!=null&&c.length===2?zke(c,u,n,t):null};function $ke(t){var e=Lr();return _.useEffect(()=>(e(Ake(t)),()=>{e(Cke(t))})),null}function Hke(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:a}=t,o=ra(),l=Dke(),c=It(C=>kc(C,e)),u=It(C=>Tc(C,n)),d=It(C=>Sh(C,"xAxis",e,o)),f=It(C=>Sh(C,"yAxis",n,o)),p=Gy();if(!l||!p||c==null||u==null||d==null||f==null)return null;var m=Mke({x:d,y:f}),x=Bke(m,p,t.position,c.orientation,u.orientation,t);if(!x)return null;var[{x:b,y},{x:v,y:S}]=x,M=a==="hidden"?"url(#".concat(l,")"):void 0,T=K$(K$({clipPath:M},za(t)),{},{x1:b,y1:y,x2:v,y2:S}),E=Nke({x1:b,y1:y,x2:v,y2:S});return _.createElement(ts,{zIndex:t.zIndex},_.createElement(oi,{className:er("recharts-reference-line",i)},Fke(r,T),_.createElement(HQ,IS({},E,{lowerWidth:E.width,upperWidth:E.width}),_.createElement(GQ,{label:t.label}),t.children)))}var Vke={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:bi.line};function s0(t){var e=li(t,Vke);return _.createElement(_.Fragment,null,_.createElement($ke,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),_.createElement(Hke,e))}s0.displayName="ReferenceLine";function pZ(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 Gke(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return kke(r,n)}function qke(t,e,n){var r=n==="width",{x:i,y:a,width:o,height:l}=t;return e===1?{start:r?i:a,end:r?i+o:a+l}:{start:r?i+o:a+l,end:r?i:a}}function US(t,e,n,r,i){if(t*e<t*r||t*e>t*i)return!1;var a=n();return t*(e-t*a/2-r)>=0&&t*(e+t*a/2-i)<=0}function Wke(t,e){return pZ(t,e+1)}function Kke(t,e,n,r,i){for(var a=(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:pZ(r,u)};var b=c,y,v=()=>(y===void 0&&(y=n(x,b)),y),S=x.coordinate,M=c===0||US(t,S,v,d,l);M||(c=0,d=o,u+=1),M&&(d=S+t*(v()/2+i),c+=u)},p;u<=a.length;)if(p=f(),p)return p.v;return[]}function X$(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 Ka(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?X$(Object(n),!0).forEach(function(r){Xke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):X$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Xke(t,e,n){return(e=Yke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Yke(t){var e=Qke(t,"string");return typeof e=="symbol"?e:e+""}function Qke(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 Zke(t,e,n,r,i){for(var a=(r||[]).slice(),o=a.length,{start:l}=e,{end:c}=e,u=function(p){var m=a[p],x,b=()=>(x===void 0&&(x=n(m,p)),x);if(p===o-1){var y=t*(m.coordinate+t*b()/2-c);a[p]=m=Ka(Ka({},m),{},{tickCoord:y>0?m.coordinate-y*t:m.coordinate})}else a[p]=m=Ka(Ka({},m),{},{tickCoord:m.coordinate});if(m.tickCoord!=null){var v=US(t,m.tickCoord,b,l,c);v&&(c=m.tickCoord-t*(b()/2+i),a[p]=Ka(Ka({},m),{},{isShow:!0}))}},d=o-1;d>=0;d--)u(d);return a}function Jke(t,e,n,r,i,a){var o=(r||[]).slice(),l=o.length,{start:c,end:u}=e;if(a){var d=r[l-1],f=n(d,l-1),p=t*(d.coordinate+t*f/2-u);if(o[l-1]=d=Ka(Ka({},d),{},{tickCoord:p>0?d.coordinate-p*t:d.coordinate}),d.tickCoord!=null){var m=US(t,d.tickCoord,()=>f,c,u);m&&(u=d.tickCoord-t*(f/2+i),o[l-1]=Ka(Ka({},d),{},{isShow:!0}))}}for(var x=a?l-1:l,b=function(S){var M=o[S],T,E=()=>(T===void 0&&(T=n(M,S)),T);if(S===0){var C=t*(M.coordinate-t*E()/2-c);o[S]=M=Ka(Ka({},M),{},{tickCoord:C<0?M.coordinate-C*t:M.coordinate})}else o[S]=M=Ka(Ka({},M),{},{tickCoord:M.coordinate});if(M.tickCoord!=null){var k=US(t,M.tickCoord,E,c,u);k&&(c=M.tickCoord+t*(E()/2+i),o[S]=Ka(Ka({},M),{},{isShow:!0}))}},y=0;y<x;y++)b(y);return o}function R4(t,e,n){var{tick:r,ticks:i,viewBox:a,minTickGap:o,orientation:l,interval:c,tickFormatter:u,unit:d,angle:f}=t;if(!i||!i.length||!r)return[];if(zt(c)||yx.isSsr){var p;return(p=Wke(i,zt(c)?c:0))!==null&&p!==void 0?p:[]}var m=[],x=l==="top"||l==="bottom"?"width":"height",b=d&&x==="width"?v0(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},y=(M,T)=>{var E=typeof u=="function"?u(M.value,T):M.value;return x==="width"?Gke(v0(E,{fontSize:e,letterSpacing:n}),b,f):v0(E,{fontSize:e,letterSpacing:n})[x]},v=i.length>=2?ya(i[1].coordinate-i[0].coordinate):1,S=qke(a,v,x);return c==="equidistantPreserveStart"?Kke(v,S,y,i,o):(c==="preserveStart"||c==="preserveStartEnd"?m=Jke(v,S,y,i,o,c==="preserveStartEnd"):m=Zke(v,S,y,i,o),m.filter(M=>M.isShow))}var eTe=t=>{var{ticks:e,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:a=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+a,u=o+c+l+(n?r:0);return Math.round(u)}return 0},tTe=["axisLine","width","height","className","hide","ticks","axisType"];function nTe(t,e){if(t==null)return{};var n,r,i=rTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function rTe(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 fm(){return fm=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},fm.apply(null,arguments)}function Y$(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 Fi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Y$(Object(n),!0).forEach(function(r){iTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Y$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function iTe(t,e,n){return(e=aTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function aTe(t){var e=sTe(t,"string");return typeof e=="symbol"?e:e+""}function sTe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var ku={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:bi.axis};function oTe(t){var{x:e,y:n,width:r,height:i,orientation:a,mirror:o,axisLine:l,otherSvgProps:c}=t;if(!l)return null;var u=Fi(Fi(Fi({},c),xs(l)),{},{fill:"none"});if(a==="top"||a==="bottom"){var d=+(a==="top"&&!o||a==="bottom"&&o);u=Fi(Fi({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var f=+(a==="left"&&!o||a==="right"&&o);u=Fi(Fi({},u),{},{x1:e+f*r,y1:n,x2:e+f*r,y2:n+i})}return _.createElement("line",fm({},u,{className:er("recharts-cartesian-axis-line",cm(l,"className"))}))}function lTe(t,e,n,r,i,a,o,l,c){var u,d,f,p,m,x,b=l?-1:1,y=t.tickSize||o,v=zt(t.tickCoord)?t.tickCoord:t.coordinate;switch(a){case"top":u=d=t.coordinate,p=n+ +!l*i,f=p-b*y,x=f-b*c,m=v;break;case"left":f=p=t.coordinate,d=e+ +!l*r,u=d-b*y,m=u-b*c,x=v;break;case"right":f=p=t.coordinate,d=e+ +l*r,u=d+b*y,m=u+b*c,x=v;break;default:u=d=t.coordinate,p=n+ +l*i,f=p+b*y,x=f+b*c,m=v;break}return{line:{x1:u,y1:f,x2:d,y2:p},tick:{x:m,y:x}}}function cTe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function uTe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function dTe(t){var{option:e,tickProps:n,value:r}=t,i,a=er(n.className,"recharts-cartesian-axis-tick-value");if(_.isValidElement(e))i=_.cloneElement(e,Fi(Fi({},n),{},{className:a}));else if(typeof e=="function")i=e(Fi(Fi({},n),{},{className:a}));else{var o="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(o=er(o,e?.className)),i=_.createElement(rM,fm({},n,{className:o}),r)}return i}var hTe=_.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:a,tickFormatter:o,unit:l,padding:c,tickTextProps:u,orientation:d,mirror:f,x:p,y:m,width:x,height:b,tickSize:y,tickMargin:v,fontSize:S,letterSpacing:M,getTicksConfig:T,events:E,axisType:C}=t,k=R4(Fi(Fi({},T),{},{ticks:n}),S,M),R=cTe(d,f),A=uTe(d,f),D=xs(T),U=lm(r),F={};typeof i=="object"&&(F=i);var H=Fi(Fi({},D),{},{fill:"none"},F),j=k.map(V=>Fi({entry:V},lTe(V,p,m,x,b,d,y,f,v))),$=j.map(V=>{var{entry:Q,line:Z}=V;return _.createElement(oi,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(Q.value,"-").concat(Q.coordinate,"-").concat(Q.tickCoord)},i&&_.createElement("line",fm({},H,Z,{className:er("recharts-cartesian-axis-tick-line",cm(i,"className"))})))}),K=j.map((V,Q)=>{var{entry:Z,tick:ae}=V,B=Fi(Fi(Fi(Fi({textAnchor:R,verticalAnchor:A},D),{},{stroke:"none",fill:a},U),ae),{},{index:Q,payload:Z,visibleTicksCount:k.length,tickFormatter:o,padding:c},u);return _.createElement(oi,fm({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(Z.value,"-").concat(Z.coordinate,"-").concat(Z.tickCoord)},zy(E,Z,Q)),r&&_.createElement(dTe,{option:r,tickProps:B,value:"".concat(typeof o=="function"?o(Z.value,Q):Z.value).concat(l||"")}))});return _.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(C,"-ticks")},K.length>0&&_.createElement(ts,{zIndex:bi.label},_.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(C,"-tick-labels"),ref:e},K)),$.length>0&&_.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(C,"-tick-lines")},$))}),fTe=_.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:a,hide:o,ticks:l,axisType:c}=t,u=nTe(t,tTe),[d,f]=_.useState(""),[p,m]=_.useState(""),x=_.useRef(null);_.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var y;return eTe({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=_.useCallback(y=>{if(y){var v=y.getElementsByClassName("recharts-cartesian-axis-tick-value");x.current=v;var S=v[0];if(S){var M=window.getComputedStyle(S),T=M.fontSize,E=M.letterSpacing;(T!==d||E!==p)&&(f(T),m(E))}}},[d,p]);return o||r!=null&&r<=0||i!=null&&i<=0?null:_.createElement(ts,{zIndex:t.zIndex},_.createElement(oi,{className:er("recharts-cartesian-axis",a)},_.createElement(oTe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:xs(t)}),_.createElement(hTe,{ref:b,axisType:c,events:u,fontSize:d,getTicksConfig:t,height:t.height,letterSpacing:p,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}),_.createElement(HQ,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},_.createElement(GQ,{label:t.label,labelRef:t.labelRef}),t.children)))}),O4=_.forwardRef((t,e)=>{var n=li(t,ku);return _.createElement(fTe,fm({},n,{ref:e}))});O4.displayName="CartesianAxis";var mTe=["x1","y1","x2","y2","key"],pTe=["offset"],gTe=["xAxisId","yAxisId"],xTe=["xAxisId","yAxisId"];function Q$(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?Q$(Object(n),!0).forEach(function(r){bTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Q$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function bTe(t,e,n){return(e=yTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yTe(t){var e=vTe(t,"string");return typeof e=="symbol"?e:e+""}function vTe(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 Rf(){return Rf=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},Rf.apply(null,arguments)}function zS(t,e){if(t==null)return{};var n,r,i=wTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function wTe(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 _Te=t=>{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:a,height:o,ry:l}=t;return _.createElement("rect",{x:r,y:i,ry:l,width:a,height:o,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function gZ(t){var{option:e,lineItemProps:n}=t,r;if(_.isValidElement(e))r=_.cloneElement(e,n);else if(typeof e=="function")r=e(n);else{var i,{x1:a,y1:o,x2:l,y2:c,key:u}=n,d=zS(n,mTe),f=(i=xs(d))!==null&&i!==void 0?i:{},{offset:p}=f,m=zS(f,pTe);r=_.createElement("line",Rf({},m,{x1:a,y1:o,x2:l,y2:c,fill:"none",key:u}))}return r}function STe(t){var{x:e,width:n,horizontal:r=!0,horizontalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=t,l=zS(t,gTe),c=i.map((u,d)=>{var f=Qa(Qa({},l),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return _.createElement(gZ,{key:"line-".concat(d),option:r,lineItemProps:f})});return _.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function NTe(t){var{y:e,height:n,vertical:r=!0,verticalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=t,l=zS(t,xTe),c=i.map((u,d)=>{var f=Qa(Qa({},l),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return _.createElement(gZ,{option:r,lineItemProps:f,key:"line-".concat(d)})});return _.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function MTe(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:a,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,p)=>f-p);i!==u[0]&&u.unshift(0);var d=u.map((f,p)=>{var m=!u[p+1],x=m?i+o-f:u[p+1]-f;if(x<=0)return null;var b=p%e.length;return _.createElement("rect",{key:"react-".concat(p),y:f,x:r,height:x,width:a,stroke:"none",fill:e[b],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return _.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function ETe(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:a,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,p)=>f-p);i!==u[0]&&u.unshift(0);var d=u.map((f,p)=>{var m=!u[p+1],x=m?i+o-f:u[p+1]-f;if(x<=0)return null;var b=p%n.length;return _.createElement("rect",{key:"react-".concat(p),x:f,y:a,width:x,height:l,stroke:"none",fill:n[b],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return _.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var kTe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:a}=t;return JK(R4(Qa(Qa(Qa({},ku),n),{},{ticks:eX(n),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,e)},TTe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:a}=t;return JK(R4(Qa(Qa(Qa({},ku),n),{},{ticks:eX(n),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,e)},ATe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:bi.grid};function BS(t){var e=oO(),n=lO(),r=cX(),i=Qa(Qa({},li(t,ATe)),{},{x:zt(t.x)?t.x:r.left,y:zt(t.y)?t.y:r.top,width:zt(t.width)?t.width:r.width,height:zt(t.height)?t.height:r.height}),{xAxisId:a,yAxisId:o,x:l,y:c,width:u,height:d,syncWithTicks:f,horizontalValues:p,verticalValues:m}=i,x=ra(),b=It(A=>U6(A,"xAxis",a,x)),y=It(A=>U6(A,"yAxis",o,x));if(!pc(u)||!pc(d)||!zt(l)||!zt(c))return null;var v=i.verticalCoordinatesGenerator||kTe,S=i.horizontalCoordinatesGenerator||TTe,{horizontalPoints:M,verticalPoints:T}=i;if((!M||!M.length)&&typeof S=="function"){var E=p&&p.length,C=S({yAxis:y?Qa(Qa({},y),{},{ticks:E?p:y.ticks}):void 0,width:e??u,height:n??d,offset:r},E?!0:f);uS(Array.isArray(C),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof C,"]")),Array.isArray(C)&&(M=C)}if((!T||!T.length)&&typeof v=="function"){var k=m&&m.length,R=v({xAxis:b?Qa(Qa({},b),{},{ticks:k?m:b.ticks}):void 0,width:e??u,height:n??d,offset:r},k?!0:f);uS(Array.isArray(R),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof R,"]")),Array.isArray(R)&&(T=R)}return _.createElement(ts,{zIndex:i.zIndex},_.createElement("g",{className:"recharts-cartesian-grid"},_.createElement(_Te,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),_.createElement(MTe,Rf({},i,{horizontalPoints:M})),_.createElement(ETe,Rf({},i,{verticalPoints:T})),_.createElement(STe,Rf({},i,{offset:r,horizontalPoints:M,xAxis:b,yAxis:y})),_.createElement(NTe,Rf({},i,{offset:r,verticalPoints:T,xAxis:b,yAxis:y}))))}BS.displayName="CartesianGrid";var xZ=(t,e,n,r)=>bc(t,"xAxis",e,r),bZ=(t,e,n,r)=>xc(t,"xAxis",e,r),yZ=(t,e,n,r)=>bc(t,"yAxis",n,r),vZ=(t,e,n,r)=>xc(t,"yAxis",n,r),CTe=nt([Vn,xZ,yZ,bZ,vZ],(t,e,n,r,i)=>Ec(t,"xAxis")?wh(e,r,!1):wh(n,i,!1)),jTe=(t,e,n,r,i)=>i;function PTe(t){return t.type==="line"}var DTe=nt([tv,jTe],(t,e)=>t.filter(PTe).find(n=>n.id===e)),RTe=nt([Vn,xZ,yZ,bZ,vZ,DTe,CTe,Qy],(t,e,n,r,i,a,o,l)=>{var{chartData:c,dataStartIndex:u,dataEndIndex:d}=l;if(!(a==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:p}=a,m;if(p!=null&&p.length>0?m=p:m=c?.slice(u,d+1),m!=null)return eAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:f,bandSize:o,displayedData:m})}});function wZ(t){var e=lm(t),n=3,r=2;if(e!=null){var{r:i,strokeWidth:a}=e,o=Number(i),l=Number(a);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 OTe=["id"],LTe=["type","layout","connectNulls","needClip","shape"],FTe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function uy(){return uy=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},uy.apply(null,arguments)}function Z$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function nc(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Z$(Object(n),!0).forEach(function(r){ITe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Z$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ITe(t,e,n){return(e=UTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function UTe(t){var e=zTe(t,"string");return typeof e=="symbol"?e:e+""}function zTe(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 L4(t,e){if(t==null)return{};var n,r,i=BTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function BTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var $Te=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Lh(n,e),payload:t}]},HTe=_.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:Lh(o,e),hide:l,type:u,color:r,unit:c}};return _.createElement(oM,{tooltipEntrySettings:d})}),_Z=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function VTe(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var GTe=(t,e,n)=>{var r=n.reduce((f,p)=>f+p);if(!r)return _Z(e,t);for(var i=Math.floor(t/r),a=t%r,o=e-t,l=[],c=0,u=0;c<n.length;u+=n[c],++c)if(u+n[c]>a){l=[...n.slice(0,c),a-u];break}var d=l.length%2===0?[0,o]:[o];return[...VTe(n,i),...l,...d].map(f=>"".concat(f,"px")).join(", ")};function qTe(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:a,needClip:o}=r,{id:l}=r,c=L4(r,OTe),u=xs(c);return _.createElement(rZ,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:a,baseProps:u,needClip:o,clipPathId:e})}function WTe(t){var{showLabels:e,children:n,points:r}=t,i=_.useMemo(()=>r?.map(a=>{var o,l,c={x:(o=a.x)!==null&&o!==void 0?o:0,y:(l=a.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return nc(nc({},c),{},{value:a.value,payload:a.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return _.createElement(_4,{value:e?i:void 0},n)}function J$(t){var{clipPathId:e,pathRef:n,points:r,strokeDasharray:i,props:a}=t,{type:o,layout:l,connectNulls:c,needClip:u,shape:d}=a,f=L4(a,LTe),p=nc(nc({},za(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??a.strokeDasharray});return _.createElement(_.Fragment,null,r?.length>1&&_.createElement(k4,uy({shapeType:"curve",option:d},p,{pathRef:n})),_.createElement(qTe,{points:r,clipPathId:e,props:a}))}function KTe(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function XTe(t){var{clipPathId:e,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=t,{points:o,strokeDasharray:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,animateNewValues:p,width:m,height:x,onAnimationEnd:b,onAnimationStart:y}=n,v=i.current,S=wx(o,"recharts-line-"),M=_.useRef(S),[T,E]=_.useState(!1),C=!T,k=_.useCallback(()=>{typeof b=="function"&&b(),E(!1)},[b]),R=_.useCallback(()=>{typeof y=="function"&&y(),E(!0)},[y]),A=KTe(r.current),D=_.useRef(0);M.current!==S&&(D.current=a.current,M.current=S);var U=D.current;return _.createElement(WTe,{points:o,showLabels:C},n.children,_.createElement(vx,{animationId:S,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:k,onAnimationStart:R,key:S},F=>{var H=dr(U,A+U,F),j=Math.min(H,A),$;if(c)if(l){var K="".concat(l).split(/[,\s]+/gim).map(Z=>parseFloat(Z));$=GTe(j,A,K)}else $=_Z(A,j);else $=l==null?void 0:String(l);if(F>0&&A>0&&(i.current=o,a.current=Math.max(a.current,j)),v){var V=v.length/o.length,Q=F===1?o:o.map((Z,ae)=>{var B=Math.floor(ae*V);if(v[B]){var X=v[B];return nc(nc({},Z),{},{x:dr(X.x,Z.x,F),y:dr(X.y,Z.y,F)})}return p?nc(nc({},Z),{},{x:dr(m*2,Z.x,F),y:dr(x/2,Z.y,F)}):nc(nc({},Z),{},{x:Z.x,y:Z.y})});return i.current=Q,_.createElement(J$,{props:n,points:Q,clipPathId:e,pathRef:r,strokeDasharray:$})}return _.createElement(J$,{props:n,points:o,clipPathId:e,pathRef:r,strokeDasharray:$})}),_.createElement(iM,{label:n.label}))}function YTe(t){var{clipPathId:e,props:n}=t,r=_.useRef(null),i=_.useRef(0),a=_.useRef(null);return _.createElement(XTe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var QTe=(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:br(t.payload,e)}};class ZTe extends _.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:a,yAxisId:o,top:l,left:c,width:u,height:d,id:f,needClip:p,zIndex:m}=this.props;if(e)return null;var x=er("recharts-line",i),b=f,{r:y,strokeWidth:v}=wZ(n),S=E4(n),M=y*2+v,T=p?"url(#clipPath-".concat(S?"":"dots-").concat(b,")"):void 0;return _.createElement(ts,{zIndex:m},_.createElement(oi,{className:x},p&&_.createElement("defs",null,_.createElement(D4,{clipPathId:b,xAxisId:a,yAxisId:o}),!S&&_.createElement("clipPath",{id:"clipPath-dots-".concat(b)},_.createElement("rect",{x:c-M/2,y:l-M/2,width:u+M,height:d+M}))),_.createElement(sZ,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:QTe,errorBarOffset:0},_.createElement(YTe,{props:this.props,clipPathId:b}))),_.createElement(g3,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:T}))}}var SZ={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:bi.line,type:"linear"};function JTe(t){var e=li(t,SZ),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:l,dot:c,hide:u,isAnimationActive:d,label:f,legendType:p,xAxisId:m,yAxisId:x,id:b}=e,y=L4(e,FTe),{needClip:v}=dM(m,x),S=uM(),M=km(),T=ra(),E=It(D=>RTe(D,m,x,T,b));if(M!=="horizontal"&&M!=="vertical"||E==null||S==null)return null;var{height:C,width:k,x:R,y:A}=S;return _.createElement(ZTe,uy({},y,{id:b,connectNulls:l,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:d,hide:u,label:f,legendType:p,xAxisId:m,yAxisId:x,points:E,layout:M,height:C,width:k,left:R,top:A,needClip:v}))}function eAe(t){var{layout:e,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:l,displayedData:c}=t;return c.map((u,d)=>{var f=br(u,o);if(e==="horizontal"){var p=cS({axis:n,ticks:i,bandSize:l,entry:u,index:d}),m=Xr(f)?null:r.scale(f);return{x:p,y:m,value:f,payload:u}}var x=Xr(f)?null:n.scale(f),b=cS({axis:r,ticks:a,bandSize:l,entry:u,index:d});return x==null||b==null?null:{x,y:b,value:f,payload:u}}).filter(Boolean)}function tAe(t){var e=li(t,SZ),n=ra();return _.createElement(lM,{id:e.id,type:"line"},r=>_.createElement(_.Fragment,null,_.createElement(j4,{legendPayload:$Te(e)}),_.createElement(HTe,{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}),_.createElement(P4,{type:"line",id:r,data:e.data,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,hide:e.hide,isPanorama:n}),_.createElement(JTe,uy({},e,{id:r}))))}var NZ=_.memo(tAe,uv);NZ.displayName="Line";var MZ=(t,e,n,r)=>bc(t,"xAxis",e,r),EZ=(t,e,n,r)=>xc(t,"xAxis",e,r),kZ=(t,e,n,r)=>bc(t,"yAxis",n,r),TZ=(t,e,n,r)=>xc(t,"yAxis",n,r),nAe=nt([Vn,MZ,kZ,EZ,TZ],(t,e,n,r,i)=>Ec(t,"xAxis")?wh(e,r,!1):wh(n,i,!1)),rAe=(t,e,n,r,i)=>i,AZ=nt([tv,rAe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),iAe=(t,e,n,r,i)=>{var a,o=AZ(t,e,n,r,i);if(o!=null){var l=Vn(t),c=Ec(l,"xAxis"),u;if(c?u=ly(t,"yAxis",n,r):u=ly(t,"xAxis",e,r),u!=null){var{stackId:d}=o,f=K2(o);if(!(d==null||f==null)){var p=(a=u[d])===null||a===void 0?void 0:a.stackedData;return p?.find(m=>m.key===f)}}}},aAe=nt([Vn,MZ,kZ,EZ,TZ,iAe,Qy,nAe,AZ,Dwe],(t,e,n,r,i,a,o,l,c,u)=>{var{chartData:d,dataStartIndex:f,dataEndIndex:p}=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:m}=c,x;if(m&&m.length>0?x=m:x=d?.slice(f,p+1),x!=null)return NAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:x,chartBaseValue:u,bandSize:l})}}),sAe=["id"],oAe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Gf(){return Gf=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},Gf.apply(null,arguments)}function CZ(t,e){if(t==null)return{};var n,r,i=lAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function lAe(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 eH(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?eH(Object(n),!0).forEach(function(r){cAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):eH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function cAe(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=dAe(t,"string");return typeof e=="symbol"?e:e+""}function dAe(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 $S(t,e){return t&&t!=="none"?t:e}var hAe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:a,hide:o}=t;return[{inactive:o,dataKey:e,type:a,color:$S(r,i),value:Lh(n,e),payload:t}]},fAe=_.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:Lh(o,e),hide:l,type:u,color:$S(r,a),unit:c}};return _.createElement(oM,{tooltipEntrySettings:d})});function mAe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:a,dataKey:o}=r,l=xs(r);return _.createElement(rZ,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:i,clipPathId:e})}function pAe(t){var{showLabels:e,children:n,points:r}=t,i=r.map(a=>{var o,l,c={x:(o=a.x)!==null&&o!==void 0?o:0,y:(l=a.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return xg(xg({},c),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return _.createElement(_4,{value:e?i:void 0},n)}function tH(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:a}=t,{layout:o,type:l,stroke:c,connectNulls:u,isRange:d}=a,{id:f}=a,p=CZ(a,sAe),m=xs(p),x=za(p);return _.createElement(_.Fragment,null,e?.length>1&&_.createElement(oi,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},_.createElement(Eg,Gf({},x,{id:f,points:e,connectNulls:u,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),c!=="none"&&_.createElement(Eg,Gf({},m,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&_.createElement(Eg,Gf({},m,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:n}))),_.createElement(mAe,{points:e,props:p,clipPathId:i}))}function gAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].y,o=r[r.length-1].y;if(!yr(a)||!yr(o))return null;var l=e*Math.abs(a-o),c=Math.max(...r.map(u=>u.x||0));return zt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.x||0),c)),zt(c)?_.createElement("rect",{x:0,y:a<o?a:a-l,width:c+(i?parseInt("".concat(i),10):1),height:Math.floor(l)}):null}function xAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].x,o=r[r.length-1].x;if(!yr(a)||!yr(o))return null;var l=e*Math.abs(a-o),c=Math.max(...r.map(u=>u.y||0));return zt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.y||0),c)),zt(c)?_.createElement("rect",{x:a<o?a:a-l,y:0,width:l,height:Math.floor(c+(i?parseInt("".concat(i),10):1))}):null}function bAe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:a}=t;return n==="vertical"?_.createElement(gAe,{alpha:e,points:r,baseLine:i,strokeWidth:a}):_.createElement(xAe,{alpha:e,points:r,baseLine:i,strokeWidth:a})}function yAe(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a}=t,{points:o,baseLine:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,onAnimationStart:p,onAnimationEnd:m}=r,x=_.useMemo(()=>({points:o,baseLine:l}),[o,l]),b=wx(x,"recharts-area-"),y=Qxe(),[v,S]=_.useState(!1),M=!v,T=_.useCallback(()=>{typeof m=="function"&&m(),S(!1)},[m]),E=_.useCallback(()=>{typeof p=="function"&&p(),S(!0)},[p]);if(y==null)return null;var C=i.current,k=a.current;return _.createElement(pAe,{showLabels:M,points:o},r.children,_.createElement(vx,{animationId:b,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:T,onAnimationStart:E,key:b},R=>{if(C){var A=C.length/o.length,D=R===1?o:o.map((F,H)=>{var j=Math.floor(H*A);if(C[j]){var $=C[j];return xg(xg({},F),{},{x:dr($.x,F.x,R),y:dr($.y,F.y,R)})}return F}),U;return zt(l)?U=dr(k,l,R):Xr(l)||Hs(l)?U=dr(k,0,R):U=l.map((F,H)=>{var j=Math.floor(H*A);if(Array.isArray(k)&&k[j]){var $=k[j];return xg(xg({},F),{},{x:dr($.x,F.x,R),y:dr($.y,F.y,R)})}return F}),R>0&&(i.current=D,a.current=U),_.createElement(tH,{points:D,baseLine:U,needClip:e,clipPathId:n,props:r})}return R>0&&(i.current=o,a.current=l),_.createElement(oi,null,c&&_.createElement("defs",null,_.createElement("clipPath",{id:"animationClipPath-".concat(n)},_.createElement(bAe,{alpha:R,points:o,baseLine:l,layout:y,strokeWidth:r.strokeWidth}))),_.createElement(oi,{clipPath:"url(#animationClipPath-".concat(n,")")},_.createElement(tH,{points:o,baseLine:l,needClip:e,clipPathId:n,props:r})))}),_.createElement(iM,{label:r.label}))}function vAe(t){var{needClip:e,clipPathId:n,props:r}=t,i=_.useRef(null),a=_.useRef();return _.createElement(yAe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}class wAe extends _.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:a,left:o,needClip:l,xAxisId:c,yAxisId:u,width:d,height:f,id:p,baseLine:m,zIndex:x}=this.props;if(e)return null;var b=er("recharts-area",i),y=p,{r:v,strokeWidth:S}=wZ(n),M=E4(n),T=v*2+S,E=l?"url(#clipPath-".concat(M?"":"dots-").concat(y,")"):void 0;return _.createElement(ts,{zIndex:x},_.createElement(oi,{className:b},l&&_.createElement("defs",null,_.createElement(D4,{clipPathId:y,xAxisId:c,yAxisId:u}),!M&&_.createElement("clipPath",{id:"clipPath-dots-".concat(y)},_.createElement("rect",{x:o-T/2,y:a-T/2,width:d+T,height:f+T}))),_.createElement(vAe,{needClip:l,clipPathId:y,props:this.props})),_.createElement(g3,{points:r,mainColor:$S(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:E}),this.props.isRange&&Array.isArray(m)&&_.createElement(g3,{points:m,mainColor:$S(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:E}))}}var jZ={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:bi.area};function _Ae(t){var e,n=li(t,jZ),{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:l,dot:c,fill:u,fillOpacity:d,hide:f,isAnimationActive:p,legendType:m,stroke:x,xAxisId:b,yAxisId:y}=n,v=CZ(n,oAe),S=km(),M=EQ(),{needClip:T}=dM(b,y),E=ra(),{points:C,isRange:k,baseLine:R}=(e=It(j=>aAe(j,b,y,E,t.id)))!==null&&e!==void 0?e:{},A=uM();if(S!=="horizontal"&&S!=="vertical"||A==null||M!=="AreaChart"&&M!=="ComposedChart")return null;var{height:D,width:U,x:F,y:H}=A;return!C||!C.length?null:_.createElement(wAe,Gf({},v,{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,baseLine:R,connectNulls:l,dot:c,fill:u,fillOpacity:d,height:D,hide:f,layout:S,isAnimationActive:p==="auto"?!yx.isSsr:p,isRange:k,legendType:m,needClip:T,points:C,stroke:x,width:U,left:F,top:H,xAxisId:b,yAxisId:y}))}var SAe=(t,e,n,r,i)=>{var a=n??e;if(zt(a))return a;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 a==="dataMin"?u:a==="dataMax"||c<0?c:Math.max(Math.min(l[0],l[1]),0)}return a==="dataMin"?l[0]:a==="dataMax"?l[1]:l[0]};function NAe(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:o,xAxis:l,yAxis:c,displayedData:u,dataStartIndex:d,xAxisTicks:f,yAxisTicks:p,bandSize:m}=t,x=i&&i.length,b=SAe(a,o,n,l,c),y=a==="horizontal",v=!1,S=u.map((T,E)=>{var C;x?C=i[d+E]:(C=br(T,r),Array.isArray(C)?v=!0:C=[b,C]);var k=C[1]==null||x&&!e&&br(T,r)==null;return y?{x:cS({axis:l,ticks:f,bandSize:m,entry:T,index:E}),y:k?null:c.scale(C[1]),value:C,payload:T}:{x:k?null:l.scale(C[1]),y:cS({axis:c,ticks:p,bandSize:m,entry:T,index:E}),value:C,payload:T}}),M;return x||v?M=S.map(T=>{var E=Array.isArray(T.value)?T.value[0]:null;return y?{x:T.x,y:E!=null&&T.y!=null?c.scale(E):null,payload:T.payload}:{x:E!=null?l.scale(E):null,y:T.y,payload:T.payload}}):M=y?c.scale(b):l.scale(b),{points:S,baseLine:M,isRange:v}}function MAe(t){var e=li(t,jZ),n=ra();return _.createElement(lM,{id:e.id,type:"area"},r=>_.createElement(_.Fragment,null,_.createElement(j4,{legendPayload:hAe(e)}),_.createElement(fAe,{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}),_.createElement(P4,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:tX(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),_.createElement(_Ae,Gf({},e,{id:r}))))}var PZ=_.memo(MAe,uv);PZ.displayName="Area";var EAe=["domain","range"],kAe=["domain","range"];function nH(t,e){if(t==null)return{};var n,r,i=TAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function TAe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function rH(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 DZ(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=nH(t,EAe),{domain:a,range:o}=e,l=nH(e,kAe);return!rH(n,a)||!rH(r,o)?!1:uv(i,l)}var AAe=["dangerouslySetInnerHTML","ticks"],CAe=["id"];function b3(){return b3=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},b3.apply(null,arguments)}function iH(t,e){if(t==null)return{};var n,r,i=jAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function jAe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function PAe(t){var e=Lr(),n=_.useRef(null);return _.useLayoutEffect(()=>{n.current===null?e(EMe(t)):n.current!==t&&e(kMe({prev:n.current,next:t})),n.current=t},[t,e]),_.useLayoutEffect(()=>()=>{n.current&&(e(TMe(n.current)),n.current=null)},[e]),null}var DAe=t=>{var{xAxisId:e,className:n}=t,r=It(aO),i=ra(),a="xAxis",o=It(y=>Sh(y,a,e,i)),l=It(y=>iQ(y,a,e,i)),c=It(y=>eQ(y,e)),u=It(y=>C_e(y,e)),d=It(y=>OY(y,e));if(c==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:f,ticks:p}=t,m=iH(t,AAe),{id:x}=d,b=iH(d,CAe);return _.createElement(O4,b3({},m,b,{scale:o,x:u.x,y:u.y,width:c.width,height:c.height,className:er("recharts-".concat(a," ").concat(a),n),viewBox:r,ticks:l,axisType:a}))},RAe={allowDataOverflow:fa.allowDataOverflow,allowDecimals:fa.allowDecimals,allowDuplicatedCategory:fa.allowDuplicatedCategory,angle:fa.angle,axisLine:ku.axisLine,height:fa.height,hide:!1,includeHidden:fa.includeHidden,interval:fa.interval,minTickGap:fa.minTickGap,mirror:fa.mirror,orientation:fa.orientation,padding:fa.padding,reversed:fa.reversed,scale:fa.scale,tick:fa.tick,tickCount:fa.tickCount,tickLine:ku.tickLine,tickSize:ku.tickSize,type:fa.type,xAxisId:0},OAe=t=>{var e=li(t,RAe);return _.createElement(_.Fragment,null,_.createElement(PAe,{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}),_.createElement(DAe,e))},HS=_.memo(OAe,DZ);HS.displayName="XAxis";var LAe=["dangerouslySetInnerHTML","ticks"],FAe=["id"];function y3(){return y3=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},y3.apply(null,arguments)}function aH(t,e){if(t==null)return{};var n,r,i=IAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function IAe(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 UAe(t){var e=Lr(),n=_.useRef(null);return _.useLayoutEffect(()=>{n.current===null?e(AMe(t)):n.current!==t&&e(CMe({prev:n.current,next:t})),n.current=t},[t,e]),_.useLayoutEffect(()=>()=>{n.current&&(e(jMe(n.current)),n.current=null)},[e]),null}var zAe=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,a=_.useRef(null),o=_.useRef(null),l=It(aO),c=ra(),u=Lr(),d="yAxis",f=It(E=>Sh(E,d,e,c)),p=It(E=>tQ(E,e)),m=It(E=>P_e(E,e)),x=It(E=>iQ(E,d,e,c)),b=It(E=>LY(E,e));if(_.useLayoutEffect(()=>{if(!(r!=="auto"||!p||w4(i)||_.isValidElement(i)||b==null)){var E=a.current;if(E){var C=E.getCalculatedWidth();Math.round(p.width)!==Math.round(C)&&u(PMe({id:e,width:C}))}}},[x,p,u,i,e,r,b]),p==null||m==null||b==null)return null;var{dangerouslySetInnerHTML:y,ticks:v}=t,S=aH(t,LAe),{id:M}=b,T=aH(b,FAe);return _.createElement(O4,y3({},S,T,{ref:a,labelRef:o,scale:f,x:m.x,y:m.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:p.width,height:p.height,className:er("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:x,axisType:d}))},BAe={allowDataOverflow:ma.allowDataOverflow,allowDecimals:ma.allowDecimals,allowDuplicatedCategory:ma.allowDuplicatedCategory,angle:ma.angle,axisLine:ku.axisLine,hide:!1,includeHidden:ma.includeHidden,interval:ma.interval,minTickGap:ma.minTickGap,mirror:ma.mirror,orientation:ma.orientation,padding:ma.padding,reversed:ma.reversed,scale:ma.scale,tick:ma.tick,tickCount:ma.tickCount,tickLine:ku.tickLine,tickSize:ku.tickSize,type:ma.type,width:ma.width,yAxisId:0},$Ae=t=>{var e=li(t,BAe);return _.createElement(_.Fragment,null,_.createElement(UAe,{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}),_.createElement(zAe,e))},VS=_.memo($Ae,DZ);VS.displayName="YAxis";var HAe=(t,e)=>e,F4=nt([HAe,Vn,DY,aa,vQ,Xu,W1e,na],eSe),I4=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)}},RZ=ul("mouseClick"),OZ=Hy();OZ.startListening({actionCreator:RZ,effect:(t,e)=>{var n=t.payload,r=F4(e.getState(),I4(n));r?.activeIndex!=null&&e.dispatch(q_e({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var v3=ul("mouseMove"),LZ=Hy(),Qw=null;LZ.startListening({actionCreator:v3,effect:(t,e)=>{var n=t.payload;Qw!==null&&cancelAnimationFrame(Qw);var r=I4(n);Qw=requestAnimationFrame(()=>{var i=e.getState(),a=u4(i,i.tooltip.settings.shared);if(a==="axis"){var o=F4(i,r);o?.activeIndex!=null?e.dispatch(hQ({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate})):e.dispatch(dQ())}Qw=null})}});var sH={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},FZ=Vs({name:"rootProps",initialState:sH,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:sH.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}}}),VAe=FZ.reducer,{updateOptions:GAe}=FZ.actions,IZ=Vs({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:qAe}=IZ.actions,WAe=IZ.reducer,UZ=ul("keyDown"),zZ=ul("focus"),U4=Hy();U4.startListening({actionCreator:UZ,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip,a=t.payload;if(!(a!=="ArrowRight"&&a!=="ArrowLeft"&&a!=="Enter")){var o=d4(i,Ax(n),rv(n),ov(n)),l=o==null?-1:Number(o);if(!(!Number.isFinite(l)||l<0)){var c=Xu(n);if(a==="Enter"){var u=jS(n,"axis","hover",String(i.index));e.dispatch(u3({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:u}));return}var d=L_e(n),f=d==="left-to-right"?1:-1,p=a==="ArrowRight"?1:-1,m=l+p*f;if(!(c==null||m>=c.length||m<0)){var x=jS(n,"axis","hover",String(m));e.dispatch(u3({active:!0,activeIndex:m.toString(),activeDataKey:void 0,activeCoordinate:x}))}}}}}});U4.startListening({actionCreator:zZ,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip;if(!i.active&&i.index==null){var a="0",o=jS(n,"axis","hover",String(a));e.dispatch(u3({activeDataKey:void 0,active:!0,activeIndex:a,activeCoordinate:o}))}}}});var Uo=ul("externalEvent"),BZ=Hy(),FA=new Map;BZ.startListening({actionCreator:Uo,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,a=FA.get(i);a!==void 0&&cancelAnimationFrame(a);var o=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:P1e(l),activeDataKey:g4(l),activeIndex:Nh(l),activeLabel:SQ(l),activeTooltipIndex:Nh(l),isTooltipActive:D1e(l)};n(c,r)}finally{FA.delete(i)}});FA.set(i,o)}}});var KAe=nt([Tx],t=>t.tooltipItemPayloads),XAe=nt([KAe,av,(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:a}=i;if(a!=null){var o=e(a,n);return o}}}),$Z=ul("touchMove"),HZ=Hy();HZ.startListening({actionCreator:$Z,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=u4(r,r.tooltip.settings.shared);if(i==="axis"){var a=F4(r,I4({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));a?.activeIndex!=null&&e.dispatch(hQ({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.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(rX),d=(o=c.getAttribute(iX))!==null&&o!==void 0?o:void 0,f=XAe(e.getState(),u,d);e.dispatch(uQ({activeDataKey:d,activeIndex:u,activeCoordinate:f}))}}}});var YAe=NK({brush:vke,cartesianAxis:DMe,chartData:jSe,errorBars:ZMe,graphicalItems:z2e,layout:ixe,legend:hbe,options:ESe,polarAxis:t2e,polarOptions:WAe,referenceElements:jke,rootProps:VAe,tooltip:W_e,zIndex:mSe}),QAe=function(e){return Age({reducer:YAe,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([OZ.middleware,LZ.middleware,U4.middleware,BZ.middleware,HZ.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(UK({type:"raf"}))},devTools:yx.devToolsEnabled})};function VZ(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=ra(),a=_.useRef(null);if(i)return n;a.current==null&&(a.current=QAe(e));var o=YR;return _.createElement(_Ee,{context:o,store:a.current},n)}function ZAe(t){var{layout:e,margin:n}=t,r=Lr(),i=ra();return _.useEffect(()=>{i||(r(txe(e)),r(exe(n)))},[r,i,e,n]),null}var GZ=_.memo(ZAe,uv);function qZ(t){var e=Lr();return _.useEffect(()=>{e(GAe(t))},[e,t]),null}function oH(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=eZ("".concat(r).concat(e)),a=Lr();return _.useLayoutEffect(()=>(a(hSe({zIndex:e,elementId:i,isPanorama:n})),()=>{a(fSe({zIndex:e,isPanorama:n}))}),[a,e,i,n]),_.createElement("g",{tabIndex:-1,id:i})}function lH(t){var{children:e,isPanorama:n}=t,r=It(nSe);if(!r||r.length===0)return e;var i=r.filter(o=>o<0),a=r.filter(o=>o>0);return _.createElement(_.Fragment,null,i.map(o=>_.createElement(oH,{key:o,zIndex:o,isPanorama:n})),e,a.map(o=>_.createElement(oH,{key:o,zIndex:o,isPanorama:n})))}var JAe=["children"];function eCe(t,e){if(t==null)return{};var n,r,i=tCe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function tCe(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 GS(){return GS=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},GS.apply(null,arguments)}var nCe={width:"100%",height:"100%",display:"block"},rCe=_.forwardRef((t,e)=>{var n=oO(),r=lO(),i=vX();if(!pc(n)||!pc(r))return null;var{children:a,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),_.createElement(zR,GS({},o,{title:l,desc:c,role:d,tabIndex:u,width:n,height:r,style:nCe,ref:e}),a)}),iCe=t=>{var{children:e}=t,n=It(O2);if(!n)return null;var{width:r,height:i,y:a,x:o}=n;return _.createElement(zR,{width:r,height:i,x:o,y:a},e)},cH=_.forwardRef((t,e)=>{var{children:n}=t,r=eCe(t,JAe),i=ra();return i?_.createElement(iCe,null,_.createElement(lH,{isPanorama:!0},n)):_.createElement(rCe,GS({ref:e},r),_.createElement(lH,{isPanorama:!1},n))});function aCe(){var t=Lr(),[e,n]=_.useState(null),r=It(wxe);return _.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),a=i.width/e.offsetWidth;yr(a)&&a!==r&&t(rxe(a))}},[e,t,r]),n}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 sCe(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){oCe(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 oCe(t,e,n){return(e=lCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lCe(t){var e=cCe(t,"string");return typeof e=="symbol"?e:e+""}function cCe(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 mm(){return mm=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},mm.apply(null,arguments)}var uCe=()=>(zSe(),null);function qS(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var dCe=_.forwardRef((t,e)=>{var n,r,i=_.useRef(null),[a,o]=_.useState({containerWidth:qS((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:qS((r=t.style)===null||r===void 0?void 0:r.height)}),l=_.useCallback((u,d)=>{o(f=>{var p=Math.round(u),m=Math.round(d);return f.containerWidth===p&&f.containerHeight===m?f:{containerWidth:p,containerHeight:m}})},[]),c=_.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:f}=u.getBoundingClientRect();l(d,f);var p=x=>{var{width:b,height:y}=x[0].contentRect;l(b,y)},m=new ResizeObserver(p);m.observe(u),i.current=m}},[e,l]);return _.useEffect(()=>()=>{var u=i.current;u?.disconnect()},[l]),_.createElement(_.Fragment,null,_.createElement(L2,{width:a.containerWidth,height:a.containerHeight}),_.createElement("div",mm({ref:c},t)))}),hCe=_.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,a]=_.useState({containerWidth:qS(n),containerHeight:qS(r)}),o=_.useCallback((c,u)=>{a(d=>{var f=Math.round(c),p=Math.round(u);return d.containerWidth===f&&d.containerHeight===p?d:{containerWidth:f,containerHeight:p}})},[]),l=_.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null){var{width:u,height:d}=c.getBoundingClientRect();o(u,d)}},[e,o]);return _.createElement(_.Fragment,null,_.createElement(L2,{width:i.containerWidth,height:i.containerHeight}),_.createElement("div",mm({ref:l},t)))}),fCe=_.forwardRef((t,e)=>{var{width:n,height:r}=t;return _.createElement(_.Fragment,null,_.createElement(L2,{width:n,height:r}),_.createElement("div",mm({ref:e},t)))}),mCe=_.forwardRef((t,e)=>{var{width:n,height:r}=t;return Lu(n)||Lu(r)?_.createElement(hCe,mm({},t,{ref:e})):_.createElement(fCe,mm({},t,{ref:e}))});function pCe(t){return t===!0?dCe:mCe}var gCe=_.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:a,onContextMenu:o,onDoubleClick:l,onMouseDown:c,onMouseEnter:u,onMouseLeave:d,onMouseMove:f,onMouseUp:p,onTouchEnd:m,onTouchMove:x,onTouchStart:b,style:y,width:v,responsive:S,dispatchTouchEvents:M=!0}=t,T=_.useRef(null),E=Lr(),[C,k]=_.useState(null),[R,A]=_.useState(null),D=aCe(),U=sO(),F=U?.width>0?U.width:v,H=U?.height>0?U.height:i,j=_.useCallback(ie=>{D(ie),typeof e=="function"&&e(ie),k(ie),A(ie),ie!=null&&(T.current=ie)},[D,e,k,A]),$=_.useCallback(ie=>{E(RZ(ie)),E(Uo({handler:a,reactEvent:ie}))},[E,a]),K=_.useCallback(ie=>{E(v3(ie)),E(Uo({handler:u,reactEvent:ie}))},[E,u]),V=_.useCallback(ie=>{E(dQ()),E(Uo({handler:d,reactEvent:ie}))},[E,d]),Q=_.useCallback(ie=>{E(v3(ie)),E(Uo({handler:f,reactEvent:ie}))},[E,f]),Z=_.useCallback(()=>{E(zZ())},[E]),ae=_.useCallback(ie=>{E(UZ(ie.key))},[E]),B=_.useCallback(ie=>{E(Uo({handler:o,reactEvent:ie}))},[E,o]),X=_.useCallback(ie=>{E(Uo({handler:l,reactEvent:ie}))},[E,l]),ne=_.useCallback(ie=>{E(Uo({handler:c,reactEvent:ie}))},[E,c]),se=_.useCallback(ie=>{E(Uo({handler:p,reactEvent:ie}))},[E,p]),be=_.useCallback(ie=>{E(Uo({handler:b,reactEvent:ie}))},[E,b]),xe=_.useCallback(ie=>{M&&E($Z(ie)),E(Uo({handler:x,reactEvent:ie}))},[E,M,x]),de=_.useCallback(ie=>{E(Uo({handler:m,reactEvent:ie}))},[E,m]),Pe=pCe(S);return _.createElement(jQ.Provider,{value:C},_.createElement(UW.Provider,{value:R},_.createElement(Pe,{width:F??y?.width,height:H??y?.height,className:er("recharts-wrapper",r),style:sCe({position:"relative",cursor:"default",width:F,height:H},y),onClick:$,onContextMenu:B,onDoubleClick:X,onFocus:Z,onKeyDown:ae,onMouseDown:ne,onMouseEnter:K,onMouseLeave:V,onMouseMove:Q,onMouseUp:se,onTouchEnd:de,onTouchMove:xe,onTouchStart:be,ref:j},_.createElement(uCe,null),n)))}),xCe=["width","height","responsive","children","className","style","compact","title","desc"];function bCe(t,e){if(t==null)return{};var n,r,i=yCe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function yCe(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 WZ=_.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:a,className:o,style:l,compact:c,title:u,desc:d}=t,f=bCe(t,xCe),p=xs(f);return c?_.createElement(_.Fragment,null,_.createElement(L2,{width:n,height:r}),_.createElement(cH,{otherAttributes:p,title:u,desc:d},a)):_.createElement(gCe,{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},_.createElement(cH,{otherAttributes:p,title:u,desc:d,ref:e},_.createElement(Pke,null,a)))});function w3(){return w3=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},w3.apply(null,arguments)}var vCe={top:5,right:5,bottom:5,left:5},wCe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:vCe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},z4=_.forwardRef(function(e,n){var r,i=li(e.categoricalChartProps,wCe),{chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,categoricalChartProps:u}=e,d={chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,eventEmitter:void 0};return _.createElement(VZ,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:a},_.createElement(uZ,{chartData:u.data}),_.createElement(GZ,{layout:i.layout,margin:i.margin}),_.createElement(qZ,{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}),_.createElement(WZ,w3({},i,{ref:n})))}),_Ce=["axis"],SCe=_.forwardRef((t,e)=>_.createElement(z4,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:_Ce,tooltipPayloadSearcher:nM,categoricalChartProps:t,ref:e})),NCe=["axis","item"],MCe=_.forwardRef((t,e)=>_.createElement(z4,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:NCe,tooltipPayloadSearcher:nM,categoricalChartProps:t,ref:e}));function ECe(t){var e=Lr();return _.useEffect(()=>{e(qAe(t))},[e,t]),null}var kCe=["layout"];function _3(){return _3=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},_3.apply(null,arguments)}function TCe(t,e){if(t==null)return{};var n,r,i=ACe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function ACe(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 CCe={top:5,right:5,bottom:5,left:5},KZ={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:CCe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},jCe=_.forwardRef(function(e,n){var r,i=li(e.categoricalChartProps,KZ),{layout:a}=i,o=TCe(i,kCe),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return _.createElement(VZ,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},_.createElement(uZ,{chartData:i.data}),_.createElement(GZ,{layout:a,margin:i.margin}),_.createElement(qZ,{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}),_.createElement(ECe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),_.createElement(WZ,_3({},o,{ref:n})))});function dH(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 hH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?dH(Object(n),!0).forEach(function(r){PCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):dH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function PCe(t,e,n){return(e=DCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function DCe(t){var e=RCe(t,"string");return typeof e=="symbol"?e:e+""}function RCe(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 OCe=["item"],LCe=hH(hH({},KZ),{},{layout:"centric",startAngle:0,endAngle:360}),FCe=_.forwardRef((t,e)=>{var n=li(t,LCe);return _.createElement(jCe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:OCe,tooltipPayloadSearcher:nM,categoricalChartProps:n,ref:e})}),ICe=["axis"],UCe=_.forwardRef((t,e)=>_.createElement(z4,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:ICe,tooltipPayloadSearcher:nM,categoricalChartProps:t,ref:e}));const fH=[{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 zCe({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:a,initialMode:o="humidity",thresholds:l}){const{t:c}=$n(),{mode:u}=Oh(),[d,f]=_.useState("24h"),[p,m]=_.useState(o),x=u==="dark",{data:b}=at({queryKey:["settings"],queryFn:ue.getSettings}),y=b?.time_format||"system";_.useEffect(()=>{if(!t)return;const se=be=>{be.key==="Escape"&&e()};return window.addEventListener("keydown",se),()=>window.removeEventListener("keydown",se)},[t,e]);const v=fH.find(se=>se.value===d)?.hours||24,{data:S,isLoading:M,error:T}=at({queryKey:["ams-history",n,i,v],queryFn:()=>ue.getAMSHistory(n,i,v),enabled:t,refetchInterval:6e4});if(!t)return null;const E=S?.data.map(se=>{const be=Ii(se.recorded_at)||new Date,xe={hour:"2-digit",minute:"2-digit",...v>24?{day:"numeric",month:"short"}:{}};return{time:be.getTime(),humidity:se.humidity,temperature:se.temperature,timeLabel:be.toLocaleTimeString([],y0(xe,y))}})||[],C=l?.humidityGood||40,k=l?.humidityFair||60,R=l?.tempGood||30,A=l?.tempFair||35,D=E[E.length-1],U=D?.humidity,F=D?.temperature,H=se=>{const be=se.filter(Oe=>Oe!=null);if(be.length<4)return"stable";const xe=be.slice(0,Math.floor(be.length/4)),de=be.slice(-Math.floor(be.length/4)),Pe=xe.reduce((Oe,ge)=>Oe+ge,0)/xe.length,Me=de.reduce((Oe,ge)=>Oe+ge,0)/de.length-Pe;return Math.abs(Me)<2?"stable":Me>0?"up":"down"},j=H(E.map(se=>se.humidity)),$=H(E.map(se=>se.temperature)),K=({trend:se})=>se==="up"?s.jsx(yP,{className:"w-4 h-4 text-red-400"}):se==="down"?s.jsx(AW,{className:"w-4 h-4 text-green-400"}):s.jsx(xP,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),V=se=>se==null?"#9ca3af":se<=C?"#22a352":se<=k?"#d4a017":"#c62828",Q=se=>se==null?"#9ca3af":se<=R?"#22a352":se<=A?"#d4a017":"#c62828",Z=x?"#2d2d2d":"#ffffff",ae=x?"#1d1d1d":"#f3f4f6",B=x?"#3d3d3d":"#e5e7eb",X=x?"#ffffff":"#111827",ne=x?"#9ca3af":"#4b5563";return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:s.jsxs("div",{className:"rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl",style:{backgroundColor:Z},onClick:se=>se.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:B},children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold",style:{color:X},children:[a," ",c("common.history","History")]}),s.jsx("p",{className:"text-sm",style:{color:ne},children:r})]}),s.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:ne},children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:ae},children:[s.jsxs("button",{onClick:()=>m("humidity"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${p==="humidity"?"bg-blue-600 text-white":""}`,style:p!=="humidity"?{color:ne}:void 0,children:[s.jsx(AR,{className:"w-4 h-4"}),c("common.humidity","Humidity")]}),s.jsxs("button",{onClick:()=>m("temperature"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${p==="temperature"?"bg-orange-600 text-white":""}`,style:p!=="temperature"?{color:ne}:void 0,children:[s.jsx(b2,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),s.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:ae},children:fH.map(se=>s.jsx("button",{onClick:()=>f(se.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===se.value?"bg-bambu-green text-white":""}`,style:d!==se.value?{color:ne}:void 0,children:se.label},se.value))})]}),s.jsx("div",{className:"grid grid-cols-4 gap-4",children:p==="humidity"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ae},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.current","Current")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-2xl font-bold",style:{color:V(U)},children:U!=null?`${U}%`:"—"}),s.jsx(K,{trend:j})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ae},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:X},children:S?.avg_humidity!=null?`${S.avg_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ae},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.min","Min")}),s.jsx("p",{className:"text-2xl font-bold text-green-500",children:S?.min_humidity!=null?`${S.min_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ae},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.max","Max")}),s.jsx("p",{className:"text-2xl font-bold text-red-500",children:S?.max_humidity!=null?`${S.max_humidity}%`:"—"})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ae},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.current","Current")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-2xl font-bold",style:{color:Q(F)},children:F!=null?`${F}°C`:"—"}),s.jsx(K,{trend:$})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ae},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:X},children:S?.avg_temperature!=null?`${S.avg_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ae},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.min","Min")}),s.jsx("p",{className:"text-2xl font-bold text-blue-500",children:S?.min_temperature!=null?`${S.min_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ae},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.max","Max")}),s.jsx("p",{className:"text-2xl font-bold text-red-500",children:S?.max_temperature!=null?`${S.max_temperature}°C`:"—"})]})]})}),s.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:ae},children:M?s.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:ne},children:c("common.loading","Loading...")}):T?s.jsx("div",{className:"h-[300px] flex items-center justify-center text-red-500",children:c("common.error","Error loading data")}):E.length===0?s.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:ne},children:c("common.noData","No data available for this time range")}):s.jsx(v1,{width:"100%",height:300,children:s.jsxs(SCe,{data:E,children:[s.jsx(BS,{strokeDasharray:"3 3",stroke:x?"#3d3d3d":"#e5e7eb"}),s.jsx(HS,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:se=>{const be=new Date(se);return v>24?be.toLocaleDateString([],{day:"numeric",month:"short"}):be.toLocaleTimeString([],y0({hour:"2-digit",minute:"2-digit"},y))},stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12}}),s.jsx(VS,{stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:p==="humidity"?[0,100]:["auto","auto"],tickFormatter:se=>p==="humidity"?`${se}%`:`${se}°C`}),s.jsx(_1,{contentStyle:{backgroundColor:x?"#2d2d2d":"#ffffff",border:`1px solid ${x?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:x?"#fff":"#000"},labelFormatter:se=>new Date(se).toLocaleString(void 0,y0({year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},y)),formatter:se=>[p==="humidity"?`${se??0}%`:`${se??0}°C`,p==="humidity"?"Humidity":"Temperature"]}),s.jsx(dO,{}),p==="humidity"?s.jsxs(s.Fragment,{children:[s.jsx(s0,{y:C,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(s0,{y:k,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):s.jsxs(s.Fragment,{children:[s.jsx(s0,{y:R,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(s0,{y:A,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),s.jsx(NZ,{type:"monotone",dataKey:p,name:p==="humidity"?"Humidity":"Temperature",stroke:p==="humidity"?"#3b82f6":"#f97316",strokeWidth:2,dot:!1,activeDot:{r:4}})]})})}),s.jsx("div",{className:"text-xs text-center",style:{color:ne},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function IA({data:t,children:e,disabled:n,className:r="",spoolman:i,configureSlot:a}){const{t:o}=$n(),[l,c]=_.useState(!1),[u,d]=_.useState("top"),[f,p]=_.useState(!1),m=_.useRef(null),x=_.useRef(null),b=_.useRef(null),y=()=>{const k=t.trayUuid;k&&(navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(k).then(()=>{p(!0),setTimeout(()=>p(!1),2e3)}).catch(()=>{v(k)}):v(k))},v=k=>{const R=document.createElement("textarea");R.value=k,R.style.position="fixed",R.style.opacity="0",document.body.appendChild(R),R.select();try{document.execCommand("copy"),p(!0),setTimeout(()=>p(!1),2e3)}catch{console.error("Failed to copy to clipboard")}document.body.removeChild(R)};_.useEffect(()=>{if(l&&m.current&&x.current){const k=m.current.getBoundingClientRect(),R=x.current.offsetHeight,A=k.top,D=window.innerHeight-k.bottom;A<R+12&&D>A?d("bottom"):d("top")}},[l]);const S=()=>{n||(b.current&&clearTimeout(b.current),b.current=setTimeout(()=>c(!0),80))},M=()=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>c(!1),100)};_.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const T=k=>k<=15?"#ef4444":k<=30?"#f97316":k<=50?"#eab308":"#22c55e",E=k=>{if(!k)return!1;const R=k.replace("#",""),A=parseInt(R.slice(0,2),16),D=parseInt(R.slice(2,4),16),U=parseInt(R.slice(4,6),16);return(.299*A+.587*D+.114*U)/255>.6},C=t.colorHex?`#${t.colorHex.replace("#","")}`:null;return s.jsxs("div",{ref:m,className:`relative ${r}`,onMouseEnter:S,onMouseLeave:M,children:[e,l&&s.jsxs("div",{ref:x,className:`
  46. absolute left-1/2 -translate-x-1/2 z-50
  47. ${u==="top"?"bottom-full mb-2":"top-full mt-2"}
  48. animate-in fade-in-0 zoom-in-95 duration-150
  49. `,style:{maxWidth:"calc(100vw - 24px)"},children:[s.jsxs("div",{className:`
  50. w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary
  51. rounded-lg shadow-xl overflow-hidden
  52. backdrop-blur-sm
  53. `,children:[s.jsxs("div",{className:"h-12 relative overflow-hidden",style:{backgroundColor:C||"#3d3d3d"},children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10 to-transparent"}),s.jsx("div",{className:`
  54. absolute inset-0 flex items-center justify-center
  55. font-semibold text-sm tracking-wide
  56. ${E(C)?"text-black/80":"text-white/90"}
  57. `,children:t.colorName}),s.jsx("div",{className:`
  58. absolute top-1.5 right-1.5 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider
  59. ${t.vendor==="Bambu Lab"?"bg-black/60 text-white":"bg-black/50 text-white/90"}
  60. `,children:t.vendor==="Bambu Lab"?"BBL":"GEN"})]}),s.jsxs("div",{className:"p-3 space-y-2.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:o("ams.profile")}),s.jsx("span",{className:"text-xs text-white font-semibold truncate max-w-[120px]",children:t.profile})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:o("ams.kFactor")}),s.jsx("span",{className:"text-xs text-bambu-green font-mono font-bold",children:t.kFactor})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium flex items-center gap-1",children:[s.jsx(AR,{className:"w-3 h-3"}),o("ams.fill")]}),s.jsx("span",{className:"text-xs text-white font-semibold",children:t.fillLevel!==null?`${t.fillLevel}%`:"—"})]}),s.jsx("div",{className:"h-1.5 bg-black/40 rounded-full overflow-hidden",children:t.fillLevel!==null?s.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${t.fillLevel}%`,backgroundColor:T(t.fillLevel)}}):s.jsx("div",{className:"h-full w-full bg-bambu-gray/30 rounded-full"})})]}),i?.enabled&&t.trayUuid&&s.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:o("spoolman.spoolId")}),s.jsxs("button",{onClick:k=>{k.stopPropagation(),y()},className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",title:"Copy spool UUID",children:[s.jsxs("span",{className:"font-mono text-[10px] truncate max-w-[80px]",children:[t.trayUuid.slice(0,8),"..."]}),f?s.jsx(Ia,{className:"w-3 h-3 text-bambu-green"}):s.jsx(Fl,{className:"w-3 h-3"})]})]}),i.linkedSpoolId&&i.spoolmanUrl&&s.jsxs("a",{href:`${i.spoolmanUrl.replace(/\/$/,"")}/spool/show/${i.linkedSpoolId}`,target:"_blank",rel:"noopener noreferrer",onClick:k=>k.stopPropagation(),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-green/20 hover:bg-bambu-green/30 text-bambu-green",title:o("spoolman.openInSpoolman"),children:[s.jsx(Kr,{className:"w-3.5 h-3.5"}),o("spoolman.openInSpoolman")]}),!i.linkedSpoolId&&i.onLinkSpool&&s.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?o("spoolman.noUnlinkedSpools"):o("spoolman.linkToSpoolman"),children:[s.jsx(uc,{className:"w-3.5 h-3.5"}),o("spoolman.linkToSpoolman")]})]}),a?.enabled&&s.jsx("div",{className:`${i?.enabled&&t.trayUuid?"":"pt-2 mt-2 border-t border-bambu-dark-tertiary"}`,children:s.jsxs("button",{onClick:k=>{k.stopPropagation(),a.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:o("ams.configureSlot"),children:[s.jsx(bh,{className:"w-3.5 h-3.5"}),o("ams.configure")]})})]})]}),s.jsx("div",{className:`
  61. absolute left-1/2 -translate-x-1/2 w-0 h-0
  62. border-l-[6px] border-l-transparent
  63. border-r-[6px] border-r-transparent
  64. ${u==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
  65. `})]})]})}function mH({children:t,className:e="",configureSlot:n}){const{t:r}=$n(),[i,a]=_.useState(!1),o=_.useRef(null),l=()=>{o.current&&clearTimeout(o.current),o.current=setTimeout(()=>a(!0),80)},c=()=>{o.current&&clearTimeout(o.current),o.current=setTimeout(()=>a(!1),100)};return _.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]),s.jsxs("div",{className:`relative ${e}`,onMouseEnter:l,onMouseLeave:c,children:[t,i&&s.jsxs("div",{className:`
  66. absolute left-1/2 -translate-x-1/2 bottom-full mb-2 z-50
  67. animate-in fade-in-0 zoom-in-95 duration-150
  68. `,children:[s.jsxs("div",{className:`
  69. bg-bambu-dark-secondary border border-bambu-dark-tertiary
  70. rounded-md shadow-lg overflow-hidden
  71. `,children:[s.jsx("div",{className:"px-3 py-1.5 text-xs text-bambu-gray whitespace-nowrap",children:r("ams.emptySlot")}),n?.enabled&&s.jsx("div",{className:"px-2 pb-2",children:s.jsxs("button",{onClick:u=>{u.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:r("ams.configureSlot"),children:[s.jsx(bh,{className:"w-3.5 h-3.5"}),r("ams.configure")]})})]}),s.jsx("div",{className:`
  72. absolute left-1/2 -translate-x-1/2 top-full w-0 h-0
  73. border-l-[5px] border-l-transparent
  74. border-r-[5px] border-r-transparent
  75. border-t-[5px] border-t-bambu-dark-tertiary
  76. `})]})]})}function BCe({isOpen:t,onClose:e,trayUuid:n,trayInfo:r}){const{t:i}=$n(),a=an(),{showToast:o}=Hn(),[l,c]=_.useState(null),{data:u,isLoading:d}=at({queryKey:["unlinked-spools"],queryFn:ue.getUnlinkedSpools,enabled:t}),f=mt({mutationFn:m=>ue.linkSpool(m,n),onSuccess:()=>{a.invalidateQueries({queryKey:["unlinked-spools"]}),a.invalidateQueries({queryKey:["linked-spools"]}),a.invalidateQueries({queryKey:["spoolman-status"]}),o(i("spoolman.linkSuccess"),"success"),e()},onError:m=>{o(`${i("spoolman.linkFailed")}: ${m.message}`,"error")}});if(!t)return null;const p=()=>{l&&f.mutate(l)};return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),s.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:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(uc,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("spoolman.linkToSpoolman")})]}),s.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[r&&s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Linking AMS tray:"}),s.jsxs("div",{className:"flex items-center gap-2",children:[r.color&&s.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${r.color}`}}),s.jsx("span",{className:"text-white font-medium",children:r.type}),s.jsxs("span",{className:"text-bambu-gray",children:["(",r.location,")"]})]})]}),s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("p",{className:"text-xs text-bambu-gray mb-1",children:[i("spoolman.spoolId"),":"]}),s.jsx("code",{className:"text-xs text-bambu-green font-mono break-all",children:n})]}),s.jsxs("div",{children:[s.jsxs("p",{className:"text-sm text-bambu-gray mb-2",children:[i("spoolman.selectSpool"),":"]}),d?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?s.jsx("div",{className:"max-h-64 overflow-y-auto space-y-2",children:u.map(m=>s.jsx("button",{onClick:()=>c(m.id),className:`w-full p-3 rounded-lg border text-left transition-colors ${l===m.id?"bg-bambu-green/20 border-bambu-green":"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:s.jsxs("div",{className:"flex items-center gap-2",children:[m.filament_color_hex&&s.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:`#${m.filament_color_hex}`}}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-white font-medium truncate",children:m.filament_name||"Unknown filament"}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[m.filament_material||"Unknown",m.remaining_weight!==null&&` - ${Math.round(m.remaining_weight)}g`,m.location&&` - ${m.location}`]})]}),l===m.id&&s.jsx(Ia,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]})},m.id))}):s.jsx("div",{className:"text-center py-8 text-bambu-gray",children:s.jsx("p",{children:i("spoolman.noUnlinkedSpools")})})]})]}),s.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Te,{variant:"secondary",onClick:e,children:i("common.cancel")}),s.jsx(Te,{onClick:p,disabled:!l||f.isPending,children:f.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),i("spoolman.syncing")]}):s.jsxs(s.Fragment,{children:[s.jsx(uc,{className:"w-4 h-4"}),i("spoolman.linkToSpoolman")]})})]}),f.isError&&s.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:f.error.message})]})]})}function $Ce(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 pH(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 HCe=["PLA","PETG","ABS","ASA","TPU","PC","PA","NYLON","PVA","HIPS","PP","PET"];function gH(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const i of HCe){const a=new RegExp(`\\b${i}\\b`,"i");if(a.test(n)){const o=e.split(a),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 UA(t){return!t.startsWith("GF")&&!t.startsWith("P1")}const VCe={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"},GCe=[{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"}],qCe=[{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 WCe(t){const e=t.toLowerCase().trim();return VCe[e]||null}function KCe({isOpen:t,onClose:e,printerId:n,slotInfo:r,nozzleDiameter:i="0.4",onSuccess:a}){const[o,l]=_.useState(""),[c,u]=_.useState(null),[d,f]=_.useState(""),[p,m]=_.useState(""),[x,b]=_.useState(""),[y,v]=_.useState(!1),[S,M]=_.useState(!1),{data:T,isLoading:E}=at({queryKey:["cloudSettings"],queryFn:()=>ue.getCloudSettings(),enabled:t}),{data:C,isLoading:k}=at({queryKey:["kprofiles",n,i],queryFn:()=>ue.getKProfiles(n,i),enabled:t&&!!n}),R=mt({mutationFn:async()=>{if(!o)throw new Error("No filament preset selected");const Q=T?.filament.find(ie=>ie.setting_id===o);if(!Q)throw new Error("Selected preset not found");const Z=gH(Q.name),ae=c?.slot_id??-1,B=d||r.trayColor?.slice(0,6)||"FFFFFF",X=Q.name.replace(/@.+$/,"").trim();let ne=pH(o);if(!o.startsWith("GFS"))try{const ie=await ue.getCloudSettingDetail(o);ie.filament_id?ne=ie.filament_id:ie.base_id&&(ne=pH(ie.base_id),console.log(`Derived tray_info_idx from base_id: ${ie.base_id} -> ${ne}`))}catch(ie){console.warn("Failed to fetch preset detail for filament_id:",ie)}let se=190,be=230;const xe=Z.material.toUpperCase();xe.includes("PLA")?(se=190,be=230):xe.includes("PETG")?(se=220,be=260):xe.includes("ABS")||xe.includes("ASA")?(se=240,be=280):xe.includes("TPU")?(se=200,be=240):xe.includes("PC")?(se=260,be=300):(xe.includes("PA")||xe.includes("NYLON"))&&(se=250,be=290);const de=c?.k_value?parseFloat(c.k_value):0,Pe=await ue.configureAmsSlot(n,r.amsId,r.trayId,{tray_info_idx:ne,tray_type:Z.material||"PLA",tray_sub_brands:X,tray_color:B+"FF",nozzle_temp_min:se,nozzle_temp_max:be,cali_idx:ae,nozzle_diameter:i,setting_id:o,kprofile_filament_id:c?.filament_id,kprofile_setting_id:c?.setting_id||void 0,k_value:de});try{await ue.saveSlotPreset(n,r.amsId,r.trayId,o,X)}catch(ie){console.warn("Failed to save slot preset mapping:",ie)}return Pe},onSuccess:()=>{v(!0),a?.(),setTimeout(()=>{v(!1),e()},1500)}}),A=mt({mutationFn:async()=>ue.resetAmsSlot(n,r.amsId,r.trayId),onSuccess:()=>{v(!0),a?.(),setTimeout(()=>{v(!1),e()},1500)}}),D=_.useMemo(()=>{if(!T?.filament)return[];const Q=x.toLowerCase();return T.filament.filter(Z=>Q?Z.name.toLowerCase().includes(Q):!0).sort((Z,ae)=>{const B=UA(Z.setting_id),X=UA(ae.setting_id);return B&&!X?-1:!B&&X?1:Z.name.localeCompare(ae.name)})},[T?.filament,x]),U=_.useMemo(()=>{if(!o||!T?.filament)return null;const Q=T.filament.find(B=>B.setting_id===o);if(!Q)return null;let Z=Q.name.replace(/@.+$/,"").trim();Z.startsWith("# ")&&(Z=Z.slice(2).trim());const ae=gH(Z);return{fullName:Z,material:ae.material,brand:ae.brand}},[o,T?.filament]),F=U?.fullName||"",H=_.useMemo(()=>{if(!C?.profiles||!U)return[];const{fullName:Q,material:Z,brand:ae}=U,B=Q.toUpperCase(),X=Z.toUpperCase(),ne=ae.toUpperCase();if(!X||X.length<2)return[];const se=C.profiles.filter(xe=>{const de=xe.name.toUpperCase();if(ne)return!(!de.includes(ne)||!de.includes(X));if(de.includes(B)||de.includes(X))return!0;const ie={NYLON:["PA","PA-CF","PA6"],PA:["NYLON"]}[X]||[];for(const Me of ie)if(de.includes(Me))return!0;return!1}),be=new Map;for(const xe of se){const de=`${xe.name}|${xe.k_value}`,Pe=be.get(de);Pe?xe.extruder_id===1&&Pe.extruder_id===0&&be.set(de,xe):be.set(de,xe)}return Array.from(be.values())},[C?.profiles,U]);_.useEffect(()=>{if(t&&T?.filament){if(r.trayInfoIdx){const Q=T.filament.find(Z=>Z.setting_id===r.trayInfoIdx);Q&&l(Q.setting_id)}}else t||(l(""),u(null),f(""),m(""),b(""),v(!1))},[t,T?.filament,r.trayInfoIdx]),_.useEffect(()=>{H.length>0?u(H[0]):u(null)},[o,H]);const j=_.useCallback(Q=>{Q.key==="Escape"&&e()},[e]);if(_.useEffect(()=>{if(t)return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[t,j]),!t)return null;const $=E||k,K=o&&!R.isPending,V=d||r.trayColor?.slice(0,6)||"FFFFFF";return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),s.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:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(bh,{className:"w-5 h-5 text-bambu-blue"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Configure AMS Slot"})]}),s.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4 max-h-[60vh] overflow-y-auto",children:[y&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-secondary/95 z-10 flex items-center justify-center rounded-xl",children:s.jsxs("div",{className:"text-center space-y-3",children:[s.jsx(s2,{className:"w-16 h-16 text-bambu-green mx-auto"}),s.jsx("p",{className:"text-lg font-semibold text-white",children:"Slot Configured!"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Settings sent to printer"})]})}),s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Configuring slot:"}),s.jsxs("div",{className:"flex items-center gap-2",children:[r.trayColor&&s.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${r.trayColor.slice(0,6)}`}}),s.jsxs("span",{className:"text-white font-medium",children:[$Ce(r.amsId,r.trayCount)," Slot ",r.trayId+1]}),r.traySubBrands&&s.jsxs("span",{className:"text-bambu-gray",children:["(",r.traySubBrands,")"]})]})]}),$?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-green animate-spin"})}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["Filament Profile ",s.jsx("span",{className:"text-red-400",children:"*"})]}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"text",placeholder:"Search presets...",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 placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none mb-2"}),s.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:D.length===0?s.jsx("p",{className:"text-center py-4 text-bambu-gray",children:T?.filament?.length===0?"No cloud presets. Login to Bambu Cloud to sync.":"No matching presets found."}):D.map(Q=>s.jsx("button",{onClick:()=>l(Q.setting_id),className:`w-full p-2 rounded-lg border text-left transition-colors ${o===Q.setting_id?"bg-bambu-green/20 border-bambu-green":"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-white text-sm truncate",children:Q.name}),UA(Q.setting_id)&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bambu-blue/20 text-bambu-blue",children:"Custom"})]})},Q.setting_id))})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["K Profile (Pressure Advance)",F&&s.jsxs("span",{className:"ml-2 text-xs text-bambu-blue",children:["Filtering for: ",F]})]}),H.length>0?s.jsxs("div",{className:"relative",children:[s.jsxs("select",{value:c?.name||"",onChange:Q=>{const Z=H.find(ae=>ae.name===Q.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:[s.jsx("option",{value:"",children:"No K profile (use default 0.020)"}),H.map(Q=>s.jsxs("option",{value:Q.name,children:[Q.name," (K=",Q.k_value,")"]},`${Q.name}-${Q.extruder_id}`))]}),s.jsx(ei,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}):o?s.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:"No matching K profiles found. Default K=0.020 will be used."}):s.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&&s.jsxs("p",{className:"text-xs text-bambu-green mt-1",children:["K=",c.k_value," from printer calibration"]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Custom Color (optional)"}),s.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[GCe.map(Q=>s.jsx("button",{onClick:()=>{f(Q.hex),m(Q.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===Q.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${Q.hex}`},title:Q.name},Q.hex)),s.jsx("button",{onClick:()=>M(!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&&s.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:qCe.map(Q=>s.jsx("button",{onClick:()=>{f(Q.hex),m(Q.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===Q.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${Q.hex}`},title:Q.name},Q.hex))}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg border-2 border-white/20 flex-shrink-0",style:{backgroundColor:`#${V}`}}),s.jsx("input",{type:"text",placeholder:"Color name or hex (e.g., brown, FF8800)",value:p,onChange:Q=>{const Z=Q.target.value;m(Z);const ae=WCe(Z);if(ae)f(ae);else{const B=Z.replace(/[^0-9A-Fa-f]/g,"").toUpperCase();B.length===6?f(B):B.length===3&&f(B.split("").map(X=>X+X).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&&s.jsx("button",{onClick:()=>{f(""),m("")},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&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-1.5",children:["Hex: #",d]})]})]})]}),s.jsxs("div",{className:"flex justify-between p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Te,{variant:"secondary",onClick:()=>A.mutate(),disabled:A.isPending||R.isPending,className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:A.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),"Resetting..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Rh,{className:"w-4 h-4"}),"Reset Slot"]})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Te,{onClick:()=>R.mutate(),disabled:!K,children:R.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),"Configuring..."]}):s.jsxs(s.Fragment,{children:[s.jsx(bh,{className:"w-4 h-4"}),"Configure Slot"]})})]})]}),(R.isError||A.isError)&&s.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:R.error?.message||A.error?.message})]})]})}function XCe({on:t,className:e="w-5 h-5"}){const n=t?"#facc15":"none",r=t?"#78350f":"currentColor",i=t?1:0;return s.jsxs("svg",{viewBox:"0 0 32 32",fill:"none",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[s.jsxs("g",{stroke:r,opacity:i,children:[s.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),s.jsx("line",{x1:"6.1",y1:"6.1",x2:"8.9",y2:"8.9"}),s.jsx("line",{x1:"25.9",y1:"6.1",x2:"23.1",y2:"8.9"}),s.jsx("line",{x1:"2",y1:"16",x2:"6",y2:"16"}),s.jsx("line",{x1:"30",y1:"16",x2:"26",y2:"16"})]}),s.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}),s.jsx("path",{d:"M12 24h8",stroke:r}),s.jsx("path",{d:"M12 27h8",stroke:r}),s.jsx("path",{d:"M13 30h6",stroke:r})]})}const xH=({className:t})=>s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"2",y:"15",width:"5",height:"5",rx:"0.5"}),s.jsx("rect",{x:"9.5",y:"15",width:"5",height:"5",rx:"0.5",fill:"currentColor",opacity:"0.3"}),s.jsx("rect",{x:"17",y:"15",width:"5",height:"5",rx:"0.5"}),s.jsx("path",{d:"M4 12 C4 6, 14 6, 14 12"}),s.jsx("polyline",{points:"12,10 14,12 12,14"})]}),bH={"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"},YCe={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 zA(t){if(!t)return null;if(bH[t])return bH[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return YCe[n]||null}function BA(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,a=Math.min(e,n,r)/255,o=(i+a)/2;let l=0,c=0;if(i!==a){const u=i-a;c=o>.5?u/(2-i-a):u/(i+a);const d=e/255,f=n/255,p=r/255;i===d?l=((f-p)/u+(f<p?6:0))/6:i===f?l=((p-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 $A(t){return(t??.02).toFixed(3)}function yH({side:t}){const{mode:e}=Oh(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return s.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 vH({className:t}){return s.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.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 QCe({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.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"}),s.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 ZCe({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.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"}),s.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 JCe({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.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"}),s.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function eje({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{x:"4.5",y:"8",width:"3",height:"4.5",fill:"#d4a017",rx:"0.5"}),s.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#d4a017"}),s.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 tje({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:"#c62828",rx:"0.5"}),s.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#c62828"}),s.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 HA({className:t,color:e,isHeating:n}){const i={"text-orange-400":"#fb923c","text-blue-400":"#60a5fa","text-green-400":"#4ade80"}[e]||"#888",a=n?{filter:`drop-shadow(0 0 4px ${i}) drop-shadow(0 0 8px ${i})`}:{};return n?s.jsxs("svg",{className:t,style:a,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:i,rx:"0.5"}),s.jsx("circle",{cx:"6",cy:"15",r:"2",fill:i}),s.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"})]}):s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.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"}),s.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:i,strokeWidth:"1",fill:"none"})]})}function wH({humidity:t,goodThreshold:e=40,fairThreshold:n=60,onClick:r,compact:i}){const a=typeof t=="string"?parseInt(t,10):t,o=typeof e=="number"?e:40,l=typeof n=="number"?n:60;let c,u;isNaN(a)?(c="#C3C2C1",u="Unknown"):a<=o?(c="#22a352",u="Good"):a<=l?(c="#d4a017",u="Fair"):(c="#c62828",u="Bad");let d;return isNaN(a)||a<=o?d=vH:a<=l?d=QCe:d=ZCe,s.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Humidity: ${a}% - ${u}${r?" (click for history)":""}`,children:[s.jsx(d,{className:i?"w-2.5 h-3":"w-3 h-4"}),s.jsxs("span",{className:`font-medium tabular-nums ${i?"text-[10px]":"text-xs"}`,style:{color:c},children:[a,"%"]})]})}function _H({temp:t,goodThreshold:e=28,fairThreshold:n=35,onClick:r,compact:i}){const a=typeof e=="number"?e:28,o=typeof n=="number"?n:35;let l,c,u;return t<=a?(l="#22a352",c="Good",u=JCe):t<=o?(l="#d4a017",c="Fair",u=eje):(l="#c62828",c="Bad",u=tje),s.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:[s.jsx(u,{className:i?"w-2.5 h-3":"w-3 h-4"}),s.jsxs("span",{className:`tabular-nums text-right ${i?"text-[10px] w-8":"w-12"}`,style:{color:l},children:[t,"°C"]})]})}function _d(t,e){const n=typeof t=="string"?parseInt(t,10):t,r=isNaN(n)?0:n,i=e===1,a=r>=128?r-128:r,o=String.fromCharCode(65+a);return i?`HT-${o}`:`AMS-${o}`}function SH(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function nje(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function rje(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 a=new Date(r);a.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((a.getTime()-i.getTime())/(1e3*60*60*24));return c===0?l:c===1?`Tomorrow ${l}`:r.toLocaleDateString([],{weekday:"short"})+" "+l}function ije(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 aje(t){return t==null?{labelKey:"",color:"text-bambu-gray",bars:0}:t>=-50?{labelKey:"printers.wifiSignal.excellent",color:"text-bambu-green",bars:4}:t>=-60?{labelKey:"printers.wifiSignal.good",color:"text-bambu-green",bars:3}:t>=-70?{labelKey:"printers.wifiSignal.fair",color:"text-yellow-400",bars:2}:t>=-80?{labelKey:"printers.wifiSignal.weak",color:"text-orange-400",bars:1}:{labelKey:"printers.wifiSignal.veryWeak",color:"text-red-400",bars:1}}function VA(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 sje({url:t,printName:e}){const{t:n}=$n(),[r,i]=_.useState(!1),[a,o]=_.useState(!1),[l,c]=_.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:`w-20 h-20 flex-shrink-0 rounded-lg overflow-hidden bg-bambu-dark-tertiary flex items-center justify-center ${t&&r?"cursor-pointer":""}`,onClick:()=>t&&r&&c(!0),children:t&&!a?s.jsxs(s.Fragment,{children:[s.jsx("img",{src:t,alt:n("printers.printPreview"),className:`w-full h-full object-cover ${r?"block":"hidden"}`,onLoad:()=>i(!0),onError:()=>o(!0)}),!r&&s.jsx(lo,{className:"w-8 h-8 text-bambu-gray"})]}):s.jsx(lo,{className:"w-8 h-8 text-bambu-gray"})}),l&&t&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>c(!1),children:s.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[s.jsx("img",{src:t,alt:n("printers.printPreview"),className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&s.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function oje({printers:t}){const{t:e}=$n(),n=an(),r=_.useMemo(()=>{let a=0,o=0,l=0,c=0;return t?.forEach(u=>{const d=n.getQueryData(["printerStatus",u.id]);d===void 0?c++:d.connected?d.state==="RUNNING"?a++:o++:l++}),{printing:a,idle:o,offline:l,loading:c,total:t?.length||0}},[t,n]),[,i]=_.useState(0);return _.useEffect(()=>{let a=!1;const o=n.getQueryCache().subscribe(()=>{a||(a=!0,requestAnimationFrame(()=>{i(l=>l+1),a=!1}))});return()=>o()},[n]),t?.length?s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[r.printing>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white font-medium",children:r.printing})," ",e("printers.status.printing").toLowerCase()]})]}),r.idle>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white font-medium",children:r.idle})," ",e("printers.status.idle").toLowerCase()]})]}),r.offline>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white font-medium",children:r.offline})," ",e("printers.status.offline").toLowerCase()]})]})]}):null}function NH(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 MH({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",cardSize:i=2,amsThresholds:a,spoolmanEnabled:o=!1,hasUnlinkedSpools:l=!1,linkedSpools:c,spoolmanUrl:u,timeFormat:d="system",cameraViewMode:f="window",onOpenEmbeddedCamera:p,checkPrinterFirmware:m=!0}){const{t:x}=$n(),b=an(),y=Mc(),{showToast:v}=Hn(),{hasPermission:S}=Ai(),[M,T]=_.useState(!1),[E,C]=_.useState(!1),[k,R]=_.useState(!0),[A,D]=_.useState(!1),[U,F]=_.useState(!1),[H,j]=_.useState(!1),[$,K]=_.useState(!1),[V,Q]=_.useState(!1),[Z,ae]=_.useState(!1),[B,X]=_.useState(!1),[ne,se]=_.useState(!1),[be,xe]=_.useState(!1),[de,Pe]=_.useState(!1),[ie,Me]=_.useState(null),[Oe,ge]=_.useState(null),[Ke,G]=_.useState(null),[Y,ce]=_.useState(!1),[q,te]=_.useState(null),[I,fe]=_.useState(!1),[me,ke]=_.useState(!1),[z,O]=_.useState(null),[ee,le]=_.useState(!1),[_e,we]=_.useState(!1),{data:re}=at({queryKey:["printerStatus",t.id],queryFn:()=>ue.getPrinterStatus(t.id),refetchInterval:3e4}),{data:Fe}=at({queryKey:["firmwareUpdate",t.id],queryFn:()=>g1.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3,enabled:m}),$e=_.useMemo(()=>{const et=new Set;if(re?.ams)for(const jt of re.ams)for(const qt of jt.tray||[])qt.tray_info_idx&&et.add(qt.tray_info_idx);return re?.vt_tray?.tray_info_idx&&et.add(re.vt_tray.tray_info_idx),Array.from(et)},[re?.ams,re?.vt_tray]),{data:Ve}=at({queryKey:["filamentInfo",$e],queryFn:()=>ue.getFilamentInfo($e),enabled:$e.length>0,staleTime:300*1e3}),{data:He}=at({queryKey:["slotPresets",t.id],queryFn:()=>ue.getSlotPresets(t.id),staleTime:120*1e3}),[ye,je]=_.useState(null);_.useEffect(()=>{re?.wifi_signal!=null&&je(re.wifi_signal)},[re?.wifi_signal]);const Be=re?.wifi_signal??ye,Se=_.useRef(void 0);_.useEffect(()=>{re?.connected!==void 0&&(Se.current=re.connected)},[re?.connected]);const Xe=re?.connected??Se.current,Ne=_.useRef({});_.useEffect(()=>{re?.ams_extruder_map&&Object.keys(re.ams_extruder_map).length>0&&(Ne.current=re.ams_extruder_map)},[re?.ams_extruder_map]);const tt=re?.ams_extruder_map&&Object.keys(re.ams_extruder_map).length>0?re.ams_extruder_map:Ne.current,Ee=_.useRef([]);_.useEffect(()=>{re?.ams&&re.ams.length>0&&(Ee.current=re.ams)},[re?.ams]);const We=re?.ams&&re.ams.length>0?re.ams:Ee.current,ze=_.useRef(255),W=re?.tray_now;W!==void 0&&W!==255&&(ze.current=W);const De=W===void 0||W===255?ze.current:W,{data:Ye}=at({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>ue.getSmartPlugByPrinter(t.id)}),{data:xt}=at({queryKey:["scriptPlugsByPrinter",t.id],queryFn:()=>ue.getScriptPlugsByPrinter(t.id)}),{data:ft}=at({queryKey:["smartPlugStatus",Ye?.id],queryFn:()=>Ye?ue.getSmartPlugStatus(Ye.id):null,enabled:!!Ye,refetchInterval:1e4}),{data:Bt}=at({queryKey:["queue",t.id,"pending"],queryFn:()=>ue.getQueue(t.id,"pending")}),Lt=Bt?.length||0,{data:vn}=at({queryKey:["queue",t.id,"printing"],queryFn:()=>ue.getQueue(t.id,"printing"),enabled:re?.state==="RUNNING"}),{data:Jt}=at({queryKey:["currentPrintUser",t.id],queryFn:()=>ue.getCurrentPrintUser(t.id),enabled:re?.state==="RUNNING"}),rr=vn?.[0]?.created_by_username||Jt?.username,{data:hr}=at({queryKey:["archives",t.id,"last"],queryFn:()=>ue.getArchives(t.id,1,0),enabled:re?.connected&&re?.state!=="RUNNING"}),Dn=hr?.[0],ln=e&&Xe===!1,fr=mt({mutationFn:et=>ue.deletePrinter(t.id,et.deleteArchives),onSuccess:()=>{b.invalidateQueries({queryKey:["printers"]}),b.invalidateQueries({queryKey:["archives"]}),b.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:et=>v(et.message||x("printers.toast.failedToDelete"),"error")}),Fn=mt({mutationFn:()=>ue.connectPrinter(t.id),onSuccess:()=>{b.invalidateQueries({queryKey:["printerStatus",t.id]})}}),Kn=mt({mutationFn:et=>Ye?ue.controlSmartPlug(Ye.id,et):Promise.reject("No plug"),onSuccess:()=>{b.invalidateQueries({queryKey:["smartPlugStatus",Ye?.id]})}}),bn=mt({mutationFn:et=>Ye?ue.updateSmartPlug(Ye.id,{auto_off:et}):Promise.reject("No plug"),onSuccess:()=>{b.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),b.invalidateQueries({queryKey:["smart-plugs"]})}}),wi=mt({mutationFn:et=>ue.controlSmartPlug(et,"on"),onSuccess:()=>{v(x("printers.toast.scriptTriggered"))},onError:et=>v(et.message||x("printers.toast.failedToRunScript"),"error")}),Ba=mt({mutationFn:()=>ue.stopPrint(t.id),onSuccess:()=>{v(x("printers.toast.printStopped")),b.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:et=>v(et.message||x("printers.toast.failedToStopPrint"),"error")}),Ae=mt({mutationFn:()=>ue.pausePrint(t.id),onSuccess:()=>{v(x("printers.toast.printPaused")),b.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:et=>v(et.message||x("printers.toast.failedToPausePrint"),"error")}),Ze=mt({mutationFn:()=>ue.resumePrint(t.id),onSuccess:()=>{v(x("printers.toast.printResumed")),b.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:et=>v(et.message||x("printers.toast.failedToResumePrint"),"error")}),st=mt({mutationFn:et=>ue.setChamberLight(t.id,et),onMutate:async et=>{await b.cancelQueries({queryKey:["printerStatus",t.id]});const jt=b.getQueryData(["printerStatus",t.id]);return b.setQueryData(["printerStatus",t.id],qt=>({...qt,chamber_light:et})),{previousStatus:jt}},onSuccess:(et,jt)=>{v(`Chamber light ${jt?"on":"off"}`)},onError:(et,jt,qt)=>{qt?.previousStatus&&b.setQueryData(["printerStatus",t.id],qt.previousStatus),v(et.message||x("printers.toast.failedToControlChamberLight"),"error")}}),lt=mt({mutationFn:et=>ue.updatePrinter(t.id,{plate_detection_enabled:et}),onSuccess:()=>{b.invalidateQueries({queryKey:["printers"]}),v(lt.variables?x("printers.toast.plateCheckEnabled"):x("printers.toast.plateCheckDisabled"))},onError:et=>v(et.message||x("printers.toast.failedToUpdateSetting"),"error")}),ot=(re?.state==="RUNNING"||re?.state==="PAUSE"||re?.state==="PAUSED")&&(re?.printable_objects_count??0)>=2,{data:kt,refetch:he}=at({queryKey:["printableObjects",t.id],queryFn:()=>ue.getPrintableObjects(t.id),enabled:de||ot,refetchInterval:de?5e3:ot?3e4:!1}),pe=mt({mutationFn:et=>ue.skipObjects(t.id,et),onSuccess:et=>{v(et.message||x("printers.skipObjects.objectsSkipped")),he()},onError:et=>v(et.message||x("printers.toast.failedToSkipObjects"),"error")}),[Ie,Le]=_.useState(null),Ce=_.useRef(!1),ut=_.useRef(null),St=_.useRef(!1),At=mt({mutationFn:({amsId:et,slotId:jt})=>ue.refreshAmsSlot(t.id,et,jt),onMutate:({amsId:et,slotId:jt})=>{ut.current&&clearTimeout(ut.current),Ce.current=!1,St.current=!1,Le({amsId:et,slotId:jt}),setTimeout(()=>{St.current=!0},2e3),ut.current=setTimeout(()=>{Le(null)},3e4)},onSuccess:et=>{v(et.message||x("printers.toast.rfidRereadInitiated"))},onError:et=>{v(et.message||x("printers.toast.failedToRereadRfid"),"error"),ut.current&&clearTimeout(ut.current),Le(null)}}),[Tt,Ft]=_.useState(null),[Pt,Mt]=_.useState(null),en=async()=>{try{const et=await ue.getPlateReferences(t.id);Ft(et)}catch{}},$t=()=>{lt.mutate(!t.plate_detection_enabled)},dn=async()=>{fe(!0),te(null);const et=re?.chamber_light===!1;we(et),et&&(await ue.setChamberLight(t.id,!0),await new Promise(jt=>setTimeout(jt,2500)));try{const jt=await ue.checkPlateEmpty(t.id,{includeDebugImage:!0});te(jt),en()}catch(jt){v(jt instanceof Error?jt.message:x("printers.toast.failedToCheckPlate"),"error"),et&&(await ue.setChamberLight(t.id,!1),we(!1))}finally{fe(!1)}},cn=_.useCallback(async()=>{te(null),_e&&(await ue.setChamberLight(t.id,!1),we(!1))},[_e,t.id]),Sn=async et=>{ke(!0);try{const jt=await ue.calibratePlateDetection(t.id,{label:et});if(jt.success){v(jt.message||x("printers.toast.calibrationSaved"),"success"),en();const qt=await ue.checkPlateEmpty(t.id,{includeDebugImage:!0});te(qt)}else v(jt.message||x("printers.toast.calibrationFailed"),"error")}catch(jt){v(jt instanceof Error?jt.message:x("printers.toast.calibrationFailed"),"error")}finally{ke(!1)}},Gt=async(et,jt)=>{try{await ue.updatePlateReferenceLabel(t.id,et,jt),Mt(null),en()}catch(qt){v(qt instanceof Error?qt.message:x("printers.toast.failedToUpdateLabel"),"error")}},sn=async et=>{try{await ue.deletePlateReference(t.id,et),v(x("printers.toast.referenceDeleted"),"success"),en();const jt=await ue.checkPlateEmpty(t.id,{includeDebugImage:!0});te(jt)}catch(jt){v(jt instanceof Error?jt.message:x("printers.toast.failedToDeleteReference"),"error")}},un=async()=>{if(z){le(!0);try{await ue.updatePrinter(t.id,{plate_detection_roi:z}),v(x("printers.toast.detectionAreaSaved"),"success"),O(null);const et=await ue.checkPlateEmpty(t.id,{includeDebugImage:!0});te(et)}catch(et){v(et instanceof Error?et.message:x("printers.toast.failedToSaveDetectionArea"),"error")}finally{le(!1)}}};_.useEffect(()=>{const et=jt=>{jt.key==="Escape"&&q&&cn()};return window.addEventListener("keydown",et),()=>window.removeEventListener("keydown",et)},[q,cn]);const Yt=_.useRef(null);_.useEffect(()=>{if(!Ie)return;const et=re?.ams_status_main??0;return et!==0&&(Ce.current=!0,Yt.current&&(clearTimeout(Yt.current),Yt.current=null)),Ce.current&&et===0&&(St.current?(ut.current&&clearTimeout(ut.current),Le(null)):Yt.current||(Yt.current=setTimeout(()=>{ut.current&&clearTimeout(ut.current),Le(null)},2e3))),()=>{Yt.current&&clearTimeout(Yt.current)}},[re?.ams_status_main,Ie]);const[tr,jn]=_.useState(null);if(ln)return null;const ii=()=>{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"}},nr=()=>{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"}},lr=()=>{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 s.jsxs(_t,{className:"relative",children:[s.jsxs(Nt,{className:i>=3?"p-5":"",children:[s.jsxs("div",{className:lr(),children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx("img",{src:ije(t.model),alt:t.model||x("common.printer"),className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${ii()}`}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:`font-semibold text-white ${nr()}`,children:t.name}),r==="compact"&&s.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${re?.connected?"bg-status-ok":"bg-status-error"}`,title:re?.connected?x("printers.connection.connected"):x("printers.connection.offline")})]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&re?.nozzles&&re.nozzles[0]?.nozzle_diameter&&s.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:re.nozzles[0].nozzle_type||"Nozzle",children:["• ",re.nozzles[0].nozzle_diameter,"mm"]}),r==="expanded"&&n&&n.total_print_hours>0&&s.jsxs("span",{className:"ml-2 text-bambu-gray",children:[s.jsx(Jn,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),s.jsxs("div",{className:"relative flex-shrink-0",children:[s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>T(!M),children:s.jsx(ih,{className:"w-4 h-4"})}),M&&s.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:[s.jsxs("button",{className:`w-full px-4 py-2 text-left text-sm flex items-center gap-2 ${S("printers:update")?"hover:bg-bambu-dark-tertiary":"opacity-50 cursor-not-allowed"}`,onClick:()=>{S("printers:update")&&(D(!0),T(!1))},title:S("printers:update")?void 0:x("printers.permission.noEdit"),children:[s.jsx(Qi,{className:"w-4 h-4"}),x("common.edit")]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{Fn.mutate(),T(!1)},children:[s.jsx(Dr,{className:"w-4 h-4"}),x("printers.reconnect")]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{j(!0),T(!1)},children:[s.jsx(TW,{className:"w-4 h-4"}),x("printers.mqttDebug")]}),s.jsxs("button",{className:`w-full px-4 py-2 text-left text-sm flex items-center gap-2 ${S("printers:delete")?"text-red-400 hover:bg-bambu-dark-tertiary":"text-red-400/50 cursor-not-allowed"}`,onClick:()=>{S("printers:delete")&&(C(!0),T(!1))},title:S("printers:delete")?void 0:x("printers.permission.noDelete"),children:[s.jsx(rn,{className:"w-4 h-4"}),x("common.delete")]})]})]})]}),r==="expanded"&&s.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[s.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${re?.connected?"bg-status-ok/20 text-status-ok":"bg-status-error/20 text-status-error"}`,children:[re?.connected?s.jsx(Fy,{className:"w-3 h-3"}):s.jsx(RR,{className:"w-3 h-3"}),re?.connected?x("printers.connection.connected"):x("printers.connection.offline")]}),re?.connected&&Be!=null&&s.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${Be>=-50||Be>=-60?"bg-status-ok/20 text-status-ok":Be>=-70?"bg-status-warning/20 text-status-warning":Be>=-80?"bg-orange-500/20 text-orange-600":"bg-status-error/20 text-status-error"}`,title:`WiFi: ${Be} dBm - ${x(aje(Be).labelKey)}`,children:[s.jsx(Nhe,{className:"w-3 h-3"}),Be,"dBm"]}),re?.connected&&(()=>{const et=re.hms_errors?Vfe(re.hms_errors):[];return s.jsxs("button",{onClick:()=>ae(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${et.length>0?et.some(jt=>jt.severity<=2)?"bg-status-error/20 text-status-error":"bg-status-warning/20 text-status-warning":"bg-status-ok/20 text-status-ok"}`,title:x("printers.clickToViewHmsErrors"),children:[s.jsx(Cn,{className:"w-3 h-3"}),et.length>0?et.length:"OK"]})})(),n&&s.jsxs("button",{onClick:()=>y("/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`:x("printers.maintenanceUpToDate"),children:[s.jsx(om,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),Lt>0&&s.jsxs("button",{onClick:()=>y("/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:x("printers.queue.inQueue",{count:Lt}),children:[s.jsx(sl,{className:"w-3 h-3"}),Lt]}),Fe?.update_available&&s.jsxs("button",{onClick:()=>ce(!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:x("printers.firmwareUpdateAvailable",{current:Fe.current_version,latest:Fe.latest_version}),children:[s.jsx(yi,{className:"w-3 h-3"}),x("printers.firmwareUpdateButton")]})]})]}),E&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsx(_t,{className:"w-full max-w-md mx-4",children:s.jsxs(Nt,{children:[s.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[s.jsx("div",{className:"p-2 rounded-full bg-red-500/20",children:s.jsx(Cn,{className:"w-5 h-5 text-red-400"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:x("printers.confirm.deleteTitle")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:x("printers.confirm.deleteMessage",{name:t.name})})]})]}),s.jsx("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:s.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:k,onChange:et=>R(et.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"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-white",children:x("printers.deleteArchives")}),s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:x(k?"printers.confirm.deleteArchivesNote":"printers.confirm.keepArchivesNote")})]})]})}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(Te,{variant:"secondary",onClick:()=>{C(!1),R(!0)},children:x("common.cancel")}),s.jsx(Te,{variant:"danger",onClick:()=>{fr.mutate({deleteArchives:k}),C(!1),R(!0)},children:"Delete"})]})]})})}),re?.connected&&s.jsxs(s.Fragment,{children:[r==="compact"?s.jsx("div",{className:"mt-2",children:re.state==="RUNNING"?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:s.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${re.progress||0}%`}})}),s.jsxs("span",{className:"text-xs text-white",children:[Math.round(re.progress||0),"%"]})]}):s.jsx("p",{className:"text-xs text-bambu-gray",children:NH(re.state,re.stg_cur_name)})}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg relative",children:[s.jsxs("button",{onClick:()=>Pe(!0),disabled:!(re.state==="RUNNING"||re.state==="PAUSE"||re.state==="PAUSED")||(re.printable_objects_count??0)<2||!S("printers:control"),className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${(re.state==="RUNNING"||re.state==="PAUSE"||re.state==="PAUSED")&&(re.printable_objects_count??0)>=2&&S("printers:control")?"text-bambu-gray hover:text-white hover:bg-white/10":"text-bambu-gray/30 cursor-not-allowed"}`,title:S("printers:control")?re.state==="RUNNING"||re.state==="PAUSE"||re.state==="PAUSED"?(re.printable_objects_count??0)>=2?x("printers.skipObjects.tooltip"):x("printers.skipObjects.requiresMultiple"):x("printers.skipObjects.onlyWhilePrinting"):x("printers.permission.noControl"),children:[s.jsx(xH,{className:"w-4 h-4"}),kt&&kt.skipped_count>0&&s.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:kt.skipped_count})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(sje,{url:re.state==="RUNNING"?re.cover_url:null,printName:re.state==="RUNNING"&&(re.subtask_name||re.current_print)||void 0}),s.jsx("div",{className:"flex-1 min-w-0",children:re.current_print&&re.state==="RUNNING"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:re.stg_cur_name||"Printing"}),s.jsx("p",{className:"text-white text-sm mb-2 truncate",children:re.subtask_name||re.current_print}),s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:s.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${re.progress||0}%`}})}),s.jsxs("span",{className:"text-white",children:[Math.round(re.progress||0),"%"]})]}),s.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[re.remaining_time!=null&&re.remaining_time>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Jn,{className:"w-3 h-3"}),nje(re.remaining_time*60)]}),s.jsxs("span",{className:"text-bambu-green font-medium",title:x("printers.estimatedCompletion"),children:["ETA ",rje(re.remaining_time,d)]})]}),re.layer_num!=null&&re.total_layers!=null&&re.total_layers>0&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(sl,{className:"w-3 h-3"}),re.layer_num,"/",re.total_layers]}),rr&&s.jsxs("span",{className:"flex items-center gap-1",title:`Started by ${rr}`,children:[s.jsx(am,{className:"w-3 h-3"}),rr]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:x("printers.sort.status")}),s.jsx("p",{className:"text-white text-sm mb-2",children:NH(re.state,re.stg_cur_name)}),s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:s.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),s.jsx("span",{className:"text-bambu-gray",children:"—"})]}),Dn?s.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:Dn.print_name||Dn.filename,children:["Last: ",Dn.print_name||Dn.filename,Dn.completed_at&&s.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",Bg(Dn.completed_at,{month:"short",day:"numeric"})]})]}):s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:x("printers.readyToPrint")})]})})]})]}),re.state!=="RUNNING"&&s.jsx(Kfe,{printerId:t.id})]}),re.temperatures&&r==="expanded"&&(()=>{const et=re.temperatures.nozzle_heating||re.temperatures.nozzle_2_heating||!1,jt=re.temperatures.bed_heating||!1,qt=re.temperatures.chamber_heating||!1,yt=t.nozzle_count===2||re.temperatures.nozzle_2!==void 0,wn=re.active_extruder===1?"L":"R";return s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[s.jsx(HA,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-orange-400",isHeating:et}),re.temperatures.nozzle_2!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"L / R"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(re.temperatures.nozzle||0),"° / ",Math.round(re.temperatures.nozzle_2||0),"°"]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.nozzle")}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(re.temperatures.nozzle||0),"°C"]})]})]}),s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[s.jsx(HA,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-blue-400",isHeating:jt}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.bed")}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(re.temperatures.bed||0),"°C"]})]}),re.temperatures.chamber!==void 0&&s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[s.jsx(HA,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-green-400",isHeating:qt}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.chamber")}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(re.temperatures.chamber||0),"°C"]})]}),yt&&s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg",title:x("printers.activeNozzle",{nozzle:x(wn==="L"?"common.left":"common.right")}),children:[s.jsx("p",{className:`text-[11px] font-bold ${wn==="L"?"text-amber-400":"text-gray-500"}`,children:"L"}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.nozzle")}),s.jsx("p",{className:`text-[11px] font-bold ${wn==="R"?"text-amber-400":"text-gray-500"}`,children:"R"})]})]})})(),r==="expanded"&&(()=>{const et=re.state==="RUNNING",jt=re.state==="PAUSED"||re.state==="PAUSE",qt=et||jt,yt=Ba.isPending||Ae.isPending||Ze.isPending,wn=re.cooling_fan_speed,Fr=re.big_fan1_speed,Yr=re.big_fan2_speed;return s.jsxs("div",{className:"mt-3",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:x("printers.controls")}),s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${wn&&wn>0?"bg-cyan-500/10":"bg-bambu-dark"}`,title:x("printers.fans.partCooling"),children:[s.jsx(gW,{className:`w-3.5 h-3.5 ${wn&&wn>0?"text-cyan-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${wn&&wn>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[wn??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Fr&&Fr>0?"bg-blue-500/10":"bg-bambu-dark"}`,title:x("printers.fans.auxiliary"),children:[s.jsx(CW,{className:`w-3.5 h-3.5 ${Fr&&Fr>0?"text-blue-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Fr&&Fr>0?"text-blue-400":"text-bambu-gray/50"}`,children:[Fr??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Yr&&Yr>0?"bg-green-500/10":"bg-bambu-dark"}`,title:x("printers.fans.chamber"),children:[s.jsx(nce,{className:`w-3.5 h-3.5 ${Yr&&Yr>0?"text-green-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Yr&&Yr>0?"text-green-400":"text-bambu-gray/50"}`,children:[Yr??0,"%"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>X(!0),disabled:!qt||yt||!S("printers:control"),className:`
  77. flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
  78. transition-colors
  79. ${qt&&S("printers:control")?"bg-red-500/20 text-red-400 hover:bg-red-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}
  80. `,title:S("printers:control")?x("printers.stop"):x("printers.permission.noControl"),children:[s.jsx(ll,{className:"w-3 h-3"}),x("printers.stop")]}),s.jsxs("button",{onClick:()=>jt?xe(!0):se(!0),disabled:!qt||yt||!S("printers:control"),className:`
  81. flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
  82. transition-colors
  83. ${qt&&S("printers:control")?jt?"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"}
  84. `,title:S("printers:control")?x(jt?"printers.resume":"printers.pause"):x("printers.permission.noControl"),children:[jt?s.jsx(Is,{className:"w-3 h-3"}):s.jsx(CR,{className:"w-3 h-3"}),x(jt?"printers.resume":"printers.pause")]})]})]})]})})(),We&&We.length>0&&r==="expanded"&&(()=>{const et=We.filter(yt=>yt.tray.length>1),jt=We.filter(yt=>yt.tray.length===1),qt=t.nozzle_count===2||re?.temperatures?.nozzle_2!==void 0;return s.jsxs("div",{className:"mt-3",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:x("printers.filaments")}),s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),s.jsxs("div",{className:"space-y-3",children:[et.length>0&&s.jsx("div",{className:"grid grid-cols-2 gap-3",children:et.map(yt=>{const wn=tt[String(yt.id)],Fr=yt.id>=128?yt.id-128:yt.id,Yr=wn!==void 0?wn:Fr,Br=Yr===1,Ws=Yr===0;return s.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[10px] text-white font-medium",children:_d(yt.id,yt.tray.length)}),qt&&(Br||Ws)&&s.jsx(yH,{side:Br?"L":"R"})]}),(yt.humidity!=null||yt.temp!=null)&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[yt.humidity!=null&&s.jsx(wH,{humidity:yt.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>Me({amsId:yt.id,amsLabel:_d(yt.id,yt.tray.length),mode:"humidity"}),compact:!0}),yt.temp!=null&&s.jsx(_H,{temp:yt.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>Me({amsId:yt.id,amsLabel:_d(yt.id,yt.tray.length),mode:"temperature"}),compact:!0})]})]}),s.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:[0,1,2,3].map(tn=>{const on=yt.tray[tn]||yt.tray.find($r=>$r.id===tn),_i=on?.tray_type&&on.remain>=0,Ss=!on?.tray_type,_o=yt.id*4+tn,So=De===_o,No=on?.tray_info_idx?Ve?.[on.tray_info_idx]:null,Ns=He?.[_o],Si=on?.tray_type?{vendor:VA(on)?"Bambu Lab":"Generic",profile:No?.name||Ns?.preset_name||on.tray_sub_brands||on.tray_type,colorName:zA(on.tray_id_name)||BA(on.tray_color),colorHex:on.tray_color||null,kFactor:$A(on.k),fillLevel:_i?on.remain:null,trayUuid:on.tray_uuid||null}:null,Ks=Ie?.amsId===yt.id&&Ie?.slotId===tn,la=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${Ss?"opacity-50":""} ${So?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[s.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:on?.tray_color?`#${on.tray_color}`:on?.tray_type?"#333":"transparent",borderColor:Ss?"#666":"rgba(255,255,255,0.1)",borderStyle:Ss?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:on?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:_i&&on?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${on.remain}%`,backgroundColor:SH(on.remain)}}):on?.tray_type?s.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return s.jsxs("div",{className:"relative group",children:[Ks&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(Dr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),re?.state!=="RUNNING"&&s.jsx("button",{onClick:$r=>{$r.stopPropagation(),jn(tr?.amsId===yt.id&&tr?.slotId===tn?null:{amsId:yt.id,slotId:tn})},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:x("printers.slotOptions"),children:s.jsx(ih,{className:"w-2.5 h-2.5 text-bambu-gray"})}),re?.state!=="RUNNING"&&tr?.amsId===yt.id&&tr?.slotId===tn&&s.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:s.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-xs flex items-center gap-2 ${S("printers:ams_rfid")?"text-white hover:bg-bambu-dark-tertiary":"text-bambu-gray/50 cursor-not-allowed"}`,onClick:$r=>{$r.stopPropagation(),S("printers:ams_rfid")&&(At.mutate({amsId:yt.id,slotId:tn}),jn(null))},disabled:Ks||!S("printers:ams_rfid"),title:S("printers:ams_rfid")?void 0:x("printers.permission.noAmsRfid"),children:[s.jsx(Dr,{className:`w-3 h-3 ${Ks?"animate-spin":""}`}),x("printers.rfid.reread")]})}),Si?s.jsx(IA,{data:Si,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:Si.trayUuid?c?.[Si.trayUuid.toUpperCase()]:void 0,spoolmanUrl:u,onLinkSpool:o&&Si.trayUuid?$r=>{ge({trayUuid:$r,trayInfo:{type:Si.profile,color:Si.colorHex||"",location:`${_d(yt.id,yt.tray.length)} Slot ${tn+1}`}})}:void 0},configureSlot:{enabled:S("printers:control"),onConfigure:()=>G({amsId:yt.id,trayId:tn,trayCount:yt.tray.length,trayType:on?.tray_type||void 0,trayColor:on?.tray_color||void 0,traySubBrands:on?.tray_sub_brands||void 0,trayInfoIdx:on?.tray_info_idx||void 0})},children:la}):s.jsx(mH,{configureSlot:{enabled:S("printers:control"),onConfigure:()=>G({amsId:yt.id,trayId:tn,trayCount:yt.tray.length})},children:la})]},tn)})})]},yt.id)})}),(jt.length>0||re.vt_tray&&re.vt_tray.tray_type)&&s.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[jt.map(yt=>{const wn=tt[String(yt.id)],Fr=yt.id>=128?yt.id-128:yt.id,Yr=wn!==void 0?wn:Fr,Br=Yr===1,Ws=Yr===0,tn=yt.tray[0],on=tn?.tray_type&&tn.remain>=0,_i=!tn?.tray_type,Ss=yt.id*4+(tn?.id??0),_o=De===Ss,So=tn?.tray_info_idx?Ve?.[tn.tray_info_idx]:null,No=He?.[Ss],Ns=tn?.tray_type?{vendor:VA(tn)?"Bambu Lab":"Generic",profile:So?.name||No?.preset_name||tn.tray_sub_brands||tn.tray_type,colorName:zA(tn.tray_id_name)||BA(tn.tray_color),colorHex:tn.tray_color||null,kFactor:$A(tn.k),fillLevel:on?tn.remain:null,trayUuid:tn.tray_uuid||null}:null,Si=tn?.id??0,Ks=Ie?.amsId===yt.id&&Ie?.slotId===Si,la=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${_i?"opacity-50":""} ${_o?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[s.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:tn?.tray_color?`#${tn.tray_color}`:tn?.tray_type?"#333":"transparent",borderColor:_i?"#666":"rgba(255,255,255,0.1)",borderStyle:_i?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:tn?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:on?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${tn.remain}%`,backgroundColor:SH(tn.remain)}}):tn?.tray_type?s.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return s.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[s.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[s.jsx("span",{className:"text-[10px] text-white font-medium",children:_d(yt.id,yt.tray.length)}),qt&&(Br||Ws)&&s.jsx(yH,{side:Br?"L":"R"})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsxs("div",{className:"relative group flex-1",children:[Ks&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(Dr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),re?.state!=="RUNNING"&&s.jsx("button",{onClick:$r=>{$r.stopPropagation(),jn(tr?.amsId===yt.id&&tr?.slotId===Si?null:{amsId:yt.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:x("printers.slotOptions"),children:s.jsx(ih,{className:"w-2.5 h-2.5 text-bambu-gray"})}),re?.state!=="RUNNING"&&tr?.amsId===yt.id&&tr?.slotId===Si&&s.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:s.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-xs flex items-center gap-2 ${S("printers:ams_rfid")?"text-white hover:bg-bambu-dark-tertiary":"text-bambu-gray/50 cursor-not-allowed"}`,onClick:$r=>{$r.stopPropagation(),S("printers:ams_rfid")&&(At.mutate({amsId:yt.id,slotId:Si}),jn(null))},disabled:Ks||!S("printers:ams_rfid"),title:S("printers:ams_rfid")?void 0:x("printers.permission.noAmsRfid"),children:[s.jsx(Dr,{className:`w-3 h-3 ${Ks?"animate-spin":""}`}),x("printers.rfid.reread")]})}),Ns?s.jsx(IA,{data:Ns,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:Ns.trayUuid?c?.[Ns.trayUuid.toUpperCase()]:void 0,spoolmanUrl:u,onLinkSpool:o&&Ns.trayUuid?$r=>{ge({trayUuid:$r,trayInfo:{type:Ns.profile,color:Ns.colorHex||"",location:_d(yt.id,yt.tray.length)}})}:void 0},configureSlot:{enabled:S("printers:control"),onConfigure:()=>G({amsId:yt.id,trayId:Si,trayCount:yt.tray.length,trayType:tn?.tray_type||void 0,trayColor:tn?.tray_color||void 0,traySubBrands:tn?.tray_sub_brands||void 0,trayInfoIdx:tn?.tray_info_idx||void 0})},children:la}):s.jsx(mH,{configureSlot:{enabled:S("printers:control"),onConfigure:()=>G({amsId:yt.id,trayId:Si,trayCount:yt.tray.length})},children:la})]}),(yt.humidity!=null||yt.temp!=null)&&s.jsxs("div",{className:"flex flex-col justify-center gap-1 shrink-0",children:[yt.temp!=null&&s.jsx(_H,{temp:yt.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>Me({amsId:yt.id,amsLabel:_d(yt.id,yt.tray.length),mode:"temperature"}),compact:!0}),yt.humidity!=null&&s.jsx(wH,{humidity:yt.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>Me({amsId:yt.id,amsLabel:_d(yt.id,yt.tray.length),mode:"humidity"}),compact:!0})]})]})]},yt.id)}),re.vt_tray&&re.vt_tray.tray_type&&(()=>{const yt=re.vt_tray,wn=De===254,Fr=yt.tray_info_idx?Ve?.[yt.tray_info_idx]:null,Yr=He?.[1020],Br={vendor:VA(yt)?"Bambu Lab":"Generic",profile:Fr?.name||Yr?.preset_name||yt.tray_sub_brands||yt.tray_type||"Unknown",colorName:zA(yt.tray_id_name)||BA(yt.tray_color),colorHex:yt.tray_color||null,kFactor:$A(yt.k),fillLevel:null,trayUuid:yt.tray_uuid||null},Ws=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center cursor-default ${wn?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[s.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:yt.tray_color?`#${yt.tray_color}`:"#333",borderColor:wn?"var(--accent)":"rgba(255,255,255,0.1)"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:yt.tray_type||"Spool"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"})})]});return s.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[s.jsx("div",{className:"flex items-center gap-1 mb-2",children:s.jsx("span",{className:"text-[10px] text-white font-medium",children:x("printers.external")})}),s.jsx(IA,{data:Br,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:Br.trayUuid?c?.[Br.trayUuid.toUpperCase()]:void 0,spoolmanUrl:u,onLinkSpool:o&&Br.trayUuid?tn=>{ge({trayUuid:tn,trayInfo:{type:Br.profile,color:Br.colorHex||"",location:"External Spool"}})}:void 0},configureSlot:{enabled:S("printers:control"),onConfigure:()=>G({amsId:255,trayId:0,trayCount:1,trayType:yt.tray_type||void 0,trayColor:yt.tray_color||void 0,traySubBrands:yt.tray_sub_brands||void 0,trayInfoIdx:yt.tray_info_idx||void 0})},children:Ws})]})})()]})]})]})})()]}),Ye&&r==="expanded"&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(vh,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"text-sm text-white truncate",children:Ye.name}),ft&&s.jsxs("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${ft.state==="ON"?"bg-bambu-green/20 text-bambu-green":ft.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:[ft.state||"?",ft.state==="ON"&&ft.energy?.power!=null&&s.jsxs("span",{className:"text-yellow-400 ml-1.5",children:["· ",ft.energy.power,"W"]})]})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{onClick:()=>K(!0),disabled:Kn.isPending||ft?.state==="ON"||!S("smart_plugs:control"),className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${S("smart_plugs:control")?ft?.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:S("smart_plugs:control")?void 0:x("printers.permission.noSmartPlugControl"),children:[s.jsx(Gu,{className:"w-3 h-3"}),"On"]}),s.jsxs("button",{onClick:()=>Q(!0),disabled:Kn.isPending||ft?.state==="OFF"||!S("smart_plugs:control"),className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${S("smart_plugs:control")?ft?.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:S("smart_plugs:control")?void 0:x("printers.permission.noSmartPlugControl"),children:[s.jsx(g2,{className:"w-3 h-3"}),"Off"]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx("span",{className:`text-xs hidden sm:inline ${Ye.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:Ye.auto_off_executed?"Auto-off done":"Auto-off"}),s.jsx("button",{onClick:()=>bn.mutate(!Ye.auto_off),disabled:bn.isPending||Ye.auto_off_executed||!S("smart_plugs:control"),title:S("smart_plugs:control")?Ye.auto_off_executed?x("printers.autoOffExecuted"):x("printers.autoOffAfterPrint"):x("printers.permission.noSmartPlugControl"),className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${S("smart_plugs:control")?Ye.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":Ye.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary":"bg-bambu-dark-tertiary/50 cursor-not-allowed"}`,children:s.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${Ye.auto_off||Ye.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]}),xt&&xt.length>0&&s.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-bambu-dark-tertiary/50",children:[s.jsx(Is,{className:"w-3.5 h-3.5 text-blue-400 flex-shrink-0"}),s.jsx("span",{className:"text-xs text-bambu-gray",children:"Scripts:"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:xt.map(et=>s.jsxs("button",{onClick:()=>wi.mutate(et.id),disabled:wi.isPending,title:`Run ${et.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:[s.jsx(Is,{className:"w-2.5 h-2.5"}),et.name]},et.id))})]})]}),r==="expanded"&&s.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:[s.jsxs("div",{className:"text-xs text-bambu-gray",children:[s.jsx("p",{children:t.ip_address}),s.jsx("p",{className:"truncate",children:t.serial_number})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>st.mutate(!re?.chamber_light),disabled:!re?.connected||st.isPending||!S("printers:control"),title:S("printers:control")?re?.chamber_light?x("printers.chamberLightOff"):x("printers.chamberLightOn"):x("printers.permission.noControl"),className:re?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30 border-yellow-500/30":"",children:s.jsx(XCe,{on:re?.chamber_light??!1,className:"w-4 h-4"})}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>{if(f==="embedded"&&p)p(t.id,t.name);else{const et=localStorage.getItem("cameraWindowState"),jt=et?JSON.parse(et):{width:640,height:400},qt=[`width=${jt.width}`,`height=${jt.height}`,jt.left!==void 0?`left=${jt.left}`:"",jt.top!==void 0?`top=${jt.top}`:"","menubar=no,toolbar=no,location=no,status=no,noopener"].filter(Boolean).join(",");window.open(`/camera/${t.id}`,`camera-${t.id}`,qt)}},disabled:!re?.connected,title:x(f==="embedded"?"printers.openCameraOverlay":"printers.openCameraWindow"),children:s.jsx(OR,{className:"w-4 h-4"})}),s.jsxs("div",{className:`inline-flex rounded-md ${t.plate_detection_enabled?"ring-1 ring-green-500":""}`,children:[s.jsx(Te,{variant:"secondary",size:"sm",onClick:$t,disabled:!re?.connected||lt.isPending||!S("printers:update"),title:S("printers:update")?t.plate_detection_enabled?x("printers.plateDetection.enabledClick"):x("printers.plateDetection.disabledClick"):x("printers.plateDetection.noPermission"),className:`!rounded-r-none !border-r-0 ${t.plate_detection_enabled?"!border-green-500 !text-green-400 hover:!bg-green-500/20":""}`,children:lt.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(K1,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:dn,disabled:!re?.connected||I||!S("printers:update"),title:S("printers:update")?x("printers.plateDetection.manageCalibration"):x("printers.plateDetection.noPermission"),className:`!rounded-l-none !px-1.5 ${t.plate_detection_enabled?"!border-green-500 !text-green-400 hover:!bg-green-500/20":""}`,children:I?s.jsx(ht,{className:"w-3 h-3 animate-spin"}):s.jsx(ei,{className:"w-3 h-3"})})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>F(!0),disabled:!S("printers:files"),title:S("printers:files")?x("printers.browseFiles"):x("printers.permission.noFiles"),children:[s.jsx(h2,{className:"w-4 h-4"}),"Files"]})]})]})]}),U&&s.jsx(Lfe,{printerId:t.id,printerName:t.name,onClose:()=>F(!1)}),H&&s.jsx($fe,{printerId:t.id,printerName:t.name,onClose:()=>j(!1)}),q&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>cn(),children:s.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-w-lg w-full",onClick:et=>et.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[q.needs_calibration?s.jsx(K1,{className:"w-5 h-5 text-blue-500"}):q.is_empty?s.jsx(Ar,{className:"w-5 h-5 text-green-500"}):s.jsx(Yi,{className:"w-5 h-5 text-yellow-500"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Build Plate Check"}),q.reference_count!==void 0&&q.max_references&&s.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded",children:[q.reference_count,"/",q.max_references," refs"]})]}),s.jsx("button",{onClick:()=>cn(),className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[q.needs_calibration?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-3 rounded-lg bg-blue-500/20 border border-blue-500/50",children:[s.jsx("p",{className:"font-medium text-blue-400",children:x("printers.plateDetection.calibrationRequired")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",dangerouslySetInnerHTML:{__html:x("printers.plateDetection.calibrationInstructions")}})]}),s.jsxs("div",{className:"text-sm text-bambu-gray space-y-2",children:[s.jsx("p",{children:x("printers.plateDetection.calibrationDescription")}),s.jsx("p",{dangerouslySetInnerHTML:{__html:x("printers.plateDetection.calibrationTip")}})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`p-3 rounded-lg ${q.is_empty?"bg-green-500/20 border border-green-500/50":"bg-yellow-500/20 border border-yellow-500/50"}`,children:[s.jsx("p",{className:`font-medium ${q.is_empty?"text-green-400":"text-yellow-400"}`,children:q.is_empty?x("printers.plateDetection.plateEmpty"):x("printers.plateDetection.objectsDetected")}),s.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:[x("printers.plateDetection.confidence"),": ",Math.round(q.confidence*100),"% | ",x("printers.plateDetection.difference"),": ",q.difference_percent.toFixed(1),"%"]})]}),q.debug_image_url&&s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:x("printers.plateDetection.analysisPreview")}),s.jsx("img",{src:q.debug_image_url,alt:x("printers.plateDetection.analysisPreview"),className:"w-full rounded-lg border border-bambu-dark-tertiary"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:x("printers.plateDetection.analysisLegend")})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:q.message})]}),Tt&&Tt.references.length>0&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-sm font-medium text-white mb-2",children:x("printers.plateDetection.savedReferences",{count:Tt.references.length,max:Tt.max_references})}),s.jsx("div",{className:"grid grid-cols-5 gap-2",children:Tt.references.map(et=>s.jsxs("div",{className:"relative group",children:[s.jsx("img",{src:ue.getPlateReferenceThumbnailUrl(t.id,et.index),alt:et.label||`Reference ${et.index+1}`,className:"w-full aspect-video object-cover rounded border border-bambu-dark-tertiary"}),s.jsx("button",{onClick:()=>sn(et.index),className:"absolute top-1 right-1 p-0.5 bg-red-500/80 rounded opacity-0 group-hover:opacity-100 transition-opacity",title:x("printers.plateDetection.deleteReference"),children:s.jsx(Rt,{className:"w-3 h-3 text-white"})}),Pt?.index===et.index?s.jsx("input",{type:"text",value:Pt.label,onChange:jt=>Mt({...Pt,label:jt.target.value}),onBlur:()=>Gt(et.index,Pt.label),onKeyDown:jt=>{jt.key==="Enter"&&Gt(et.index,Pt.label),jt.key==="Escape"&&Mt(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:x("printers.plateDetection.labelPlaceholder")}):s.jsx("p",{className:"text-xs text-bambu-gray mt-1 truncate cursor-pointer hover:text-white",onClick:()=>Mt({index:et.index,label:et.label}),title:et.label?x("printers.plateDetection.clickToEdit",{label:et.label}):x("printers.plateDetection.clickToAddLabel"),children:et.label||s.jsx("span",{className:"italic opacity-50",children:x("printers.noLabel")})}),s.jsx("p",{className:"text-[10px] text-bambu-gray/60",children:et.timestamp?new Date(et.timestamp).toLocaleDateString():""})]},et.index))})]}),!q.needs_calibration&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:x("printers.roi.title")}),z?s.jsxs("div",{className:"flex gap-1",children:[s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>O(null),disabled:ee,children:x("common.cancel")}),s.jsx(Te,{size:"sm",onClick:un,disabled:ee,children:ee?s.jsx(ht,{className:"w-3 h-3 animate-spin"}):x("common.save")})]}):s.jsxs(Te,{variant:"ghost",size:"sm",onClick:()=>O(q.roi||{x:.15,y:.35,w:.7,h:.55}),children:[s.jsx(Qi,{className:"w-3 h-3 mr-1"}),x("common.edit")]})]}),z?s.jsxs("div",{className:"space-y-3 bg-bambu-dark-tertiary/50 p-3 rounded-lg",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-bambu-gray",children:x("printers.roi.xStart")}),s.jsx("input",{type:"range",min:"0",max:"0.9",step:"0.01",value:z.x,onChange:et=>O({...z,x:parseFloat(et.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(z.x*100),"%"]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-bambu-gray",children:x("printers.roi.yStart")}),s.jsx("input",{type:"range",min:"0",max:"0.9",step:"0.01",value:z.y,onChange:et=>O({...z,y:parseFloat(et.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(z.y*100),"%"]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-bambu-gray",children:x("printers.width")}),s.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.01",value:z.w,onChange:et=>O({...z,w:parseFloat(et.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(z.w*100),"%"]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-bambu-gray",children:x("printers.height")}),s.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.01",value:z.h,onChange:et=>O({...z,h:parseFloat(et.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(z.h*100),"%"]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:x("printers.roi.instruction")})]}):s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Current: X=",Math.round((q.roi?.x||.15)*100),"%, Y=",Math.round((q.roi?.y||.35)*100),"%, W=",Math.round((q.roi?.w||.7)*100),"%, H=",Math.round((q.roi?.h||.55)*100),"%"]})]})]}),s.jsx("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:q.needs_calibration?s.jsxs(s.Fragment,{children:[s.jsx(Te,{variant:"ghost",onClick:()=>cn(),children:x("common.cancel")}),s.jsx(Te,{onClick:()=>Sn(),disabled:me,children:me?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 mr-2 animate-spin"}),"Calibrating..."]}):"Calibrate Empty Plate"})]}):s.jsxs(s.Fragment,{children:[s.jsx(Te,{variant:"ghost",onClick:()=>Sn(),disabled:me,children:me?"Adding...":`Add Reference (${Tt?.references.length||0}/${Tt?.max_references||5})`}),s.jsx(Te,{onClick:()=>cn(),children:"Close"})]})})]})}),$&&Ye&&s.jsx(Qn,{title:x("printers.confirm.powerOnTitle"),message:x("printers.confirm.powerOnMessage",{name:t.name}),confirmText:x("printers.confirm.powerOnButton"),variant:"default",onConfirm:()=>{Kn.mutate("on"),K(!1)},onCancel:()=>K(!1)}),V&&Ye&&s.jsx(Qn,{title:x("printers.confirm.powerOffTitle"),message:re?.state==="RUNNING"?x("printers.confirm.powerOffWarning",{name:t.name}):x("printers.confirm.powerOffMessage",{name:t.name}),confirmText:x("printers.confirm.powerOffButton"),variant:"danger",onConfirm:()=>{Kn.mutate("off"),Q(!1)},onCancel:()=>Q(!1)}),B&&s.jsx(Qn,{title:x("printers.confirm.stopTitle"),message:x("printers.confirm.stopMessage",{name:t.name}),confirmText:x("printers.confirm.stopButton"),variant:"danger",onConfirm:()=>{Ba.mutate(),X(!1)},onCancel:()=>X(!1)}),ne&&s.jsx(Qn,{title:x("printers.confirm.pauseTitle"),message:x("printers.confirm.pauseMessage",{name:t.name}),confirmText:x("printers.confirm.pauseButton"),variant:"default",onConfirm:()=>{Ae.mutate(),se(!1)},onCancel:()=>se(!1)}),be&&s.jsx(Qn,{title:x("printers.confirm.resumeTitle"),message:x("printers.confirm.resumeMessage",{name:t.name}),confirmText:x("printers.confirm.resumeButton"),variant:"default",onConfirm:()=>{Ze.mutate(),xe(!1)},onCancel:()=>xe(!1)}),de&&s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>Pe(!1),onKeyDown:et=>et.key==="Escape"&&Pe(!1),tabIndex:-1,ref:et=>et?.focus(),children:[s.jsx("div",{className:"absolute inset-0 bg-black/50 z-0"}),s.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:et=>et.stopPropagation(),children:[s.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:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xH,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:x("printers.skipObjects.title")})]}),s.jsx("button",{onClick:()=>Pe(!1),className:"p-1 text-gray-500 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white rounded transition-colors",children:s.jsx(Rt,{className:"w-4 h-4"})})]}),kt?kt.objects.length===0?s.jsxs("div",{className:"text-center py-8 px-4 text-bambu-gray",children:[s.jsx("p",{className:"text-sm",children:x("printers.noObjectsFound")}),s.jsx("p",{className:"text-xs mt-1 opacity-70",children:x("printers.objectsLoadedOnPrintStart")})]}):s.jsxs("div",{className:"flex flex-col overflow-hidden",children:[s.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:[s.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:s.jsx(Bde,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-300",children:x("printers.skipObjects.matchIdsInfo")}),s.jsx("p",{className:"text-[10px] text-blue-500/70 dark:text-blue-300/60",children:x("printers.skipObjects.printerShowsIds")})]}),s.jsxs("div",{className:"flex-shrink-0 text-xs text-gray-500 dark:text-bambu-gray",children:[kt.skipped_count,"/",kt.total," ",x("printers.skipObjects.skipped")]})]}),(re?.layer_num??0)<=1&&s.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:[s.jsx($i,{className:"w-4 h-4 text-amber-500 dark:text-amber-400 flex-shrink-0"}),s.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:x("printers.skipObjects.waitForLayer",{layer:re?.layer_num??0})})]}),s.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[s.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:s.jsxs("div",{className:"relative",children:[re?.cover_url?s.jsx("img",{src:`${re.cover_url}?view=top`,alt:x("printers.printPreview"),className:"w-full aspect-square object-contain rounded-lg bg-gray-900 dark:bg-gray-900 border border-gray-300 dark:border-gray-600"}):s.jsx("div",{className:"w-full aspect-square rounded-lg bg-gray-100 dark:bg-bambu-dark flex items-center justify-center",children:s.jsx(lo,{className:"w-8 h-8 text-gray-300 dark:text-bambu-gray/30"})}),kt.objects.length>0&&s.jsx("div",{className:"absolute inset-0 pointer-events-none",children:kt.objects.map((et,jt)=>{let qt,yt;if(et.x!=null&&et.y!=null&&kt.bbox_all){const[wn,Fr,Yr,Br]=kt.bbox_all,Ws=Yr-wn,tn=Br-Fr,on=8,_i=100-on*2;qt=on+(et.x-wn)/Ws*_i,yt=on+(Br-et.y)/tn*_i,qt=Math.max(5,Math.min(95,qt)),yt=Math.max(5,Math.min(95,yt))}else if(et.x!=null&&et.y!=null)qt=et.x/256*100,yt=100-et.y/256*100,qt=Math.max(5,Math.min(95,qt)),yt=Math.max(5,Math.min(95,yt));else{const wn=Math.ceil(Math.sqrt(kt.objects.length)),Fr=Math.floor(jt/wn),Yr=jt%wn,Br=Math.ceil(kt.objects.length/wn);qt=15+Yr*(70/wn)+35/wn,yt=15+Fr*(70/Br)+35/Br}return s.jsx("div",{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${et.skipped?"bg-red-500 text-white line-through":"bg-bambu-green text-black"}`,style:{left:`${qt}%`,top:`${yt}%`,transform:"translate(-50%, -50%)"},title:et.name,children:et.id},et.id)})}),s.jsx("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:x("printers.skipObjects.activeCount",{count:kt.objects.filter(et=>!et.skipped).length})})]})}),s.jsx("div",{className:"flex-1 min-w-0 overflow-y-auto",children:kt.objects.map(et=>s.jsxs("div",{className:`
  85. flex items-center gap-3 px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary/50 last:border-0
  86. ${et.skipped?"bg-red-50 dark:bg-red-500/10":"hover:bg-gray-50 dark:hover:bg-bambu-dark/50"}
  87. `,children:[s.jsxs("div",{className:`
  88. w-12 h-12 flex-shrink-0 rounded-lg flex flex-col items-center justify-center
  89. ${et.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"}
  90. `,children:[s.jsx("span",{className:`text-lg font-mono font-bold ${et.skipped?"text-red-500 dark:text-red-400":"text-green-600 dark:text-bambu-green"}`,children:et.id}),s.jsx("span",{className:`text-[8px] uppercase tracking-wider ${et.skipped?"text-red-400/60":"text-green-500/60 dark:text-bambu-green/60"}`,children:"ID"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("span",{className:`block text-sm truncate ${et.skipped?"text-red-500 dark:text-red-400 line-through":"text-gray-900 dark:text-white"}`,children:et.name}),et.skipped&&s.jsx("span",{className:"text-[10px] text-red-400/60",children:x("printers.willBeSkipped")})]}),et.skipped?s.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:x("printers.skipObjects.skipped")}):s.jsx("button",{onClick:()=>pe.mutate([et.id]),disabled:pe.isPending||(re?.layer_num??0)<=1||!S("printers:control"),className:`px-4 py-2 text-xs font-medium rounded-lg transition-colors ${(re?.layer_num??0)<=1||!S("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:S("printers:control")?(re?.layer_num??0)<=1?x("printers.skipObjects.waitForLayer",{layer:re?.layer_num??0}):x("printers.skipObjects.skip"):x("printers.permission.noControl"),children:x("printers.skipObjects.skip")})]},et.id))})]})]}):s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(ht,{className:"w-5 h-5 animate-spin text-bambu-gray"})})]})]}),Z&&s.jsx(qfe,{printerName:t.name,errors:re?.hms_errors||[],onClose:()=>ae(!1)}),ie&&s.jsx(zCe,{isOpen:!!ie,onClose:()=>Me(null),printerId:t.id,printerName:t.name,amsId:ie.amsId,amsLabel:ie.amsLabel,initialMode:ie.mode,thresholds:a}),Oe&&s.jsx(BCe,{isOpen:!!Oe,onClose:()=>ge(null),trayUuid:Oe.trayUuid,trayInfo:Oe.trayInfo}),Ke&&s.jsx(KCe,{isOpen:!!Ke,onClose:()=>G(null),printerId:t.id,slotInfo:Ke,onSuccess:()=>{b.invalidateQueries({queryKey:["slotPresets",t.id]}),b.invalidateQueries({queryKey:["printerStatus",t.id]})}}),A&&s.jsx(uje,{printer:t,onClose:()=>D(!1)}),Y&&Fe&&s.jsx(cje,{printer:t,firmwareInfo:Fe,onClose:()=>ce(!1)}),tr&&s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>jn(null)})]})}function lje({onClose:t,onAdd:e,existingSerials:n}){const{t:r}=$n(),[i,a]=_.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",location:"",auto_archive:!0}),[o,l]=_.useState(!1),[c,u]=_.useState([]),[d,f]=_.useState(""),[p,m]=_.useState(!1),[x,b]=_.useState(!1),[y,v]=_.useState("192.168.1.0/24"),[S,M]=_.useState({scanned:0,total:0});_.useEffect(()=>{Xl.getInfo().then(R=>{b(R.is_docker)}).catch(()=>{})},[]);const T=c.filter(R=>!n.includes(R.serial)),E=async()=>{f(""),u([]),l(!0),m(!1),M({scanned:0,total:0});try{if(x){await Xl.startSubnetScan(y);const R=setInterval(async()=>{try{const A=await Xl.getScanStatus();M({scanned:A.scanned,total:A.total});const D=await Xl.getDiscoveredPrinters();u(D),A.running||(clearInterval(R),l(!1),m(!0))}catch(A){console.error("Failed to get scan status:",A)}},500)}else{await Xl.startDiscovery(10);const R=setInterval(async()=>{try{const A=await Xl.getDiscoveredPrinters();u(A)}catch(A){console.error("Failed to get discovered printers:",A)}},1e3);setTimeout(async()=>{clearInterval(R);try{await Xl.stopDiscovery()}catch{}l(!1),m(!0);try{const A=await Xl.getDiscoveredPrinters();u(A)}catch(A){console.error("Failed to get final discovered printers:",A)}},1e4)}}catch(R){console.error("Failed to start discovery:",R),f(R instanceof Error?R.message:r("printers.discovery.failedToStart")),l(!1),m(!0)}},C=R=>R?{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"}[R]||R:"",k=R=>{const A=R.serial.startsWith("unknown-")?"":R.serial;a({...i,name:R.name||"",serial_number:A,ip_address:R.ip_address,model:C(R.model)}),u([])};return _.useEffect(()=>()=>{Xl.stopDiscovery().catch(()=>{}),Xl.stopSubnetScan().catch(()=>{})},[]),_.useEffect(()=>{const R=A=>{A.key==="Escape"&&t()};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:s.jsx(_t,{className:"w-full max-w-md",onClick:R=>R.stopPropagation(),children:s.jsxs(Nt,{children:[s.jsx("h2",{className:"text-xl font-semibold mb-4",children:r("printers.addPrinter")}),s.jsxs("div",{className:"mb-4 pb-4 border-b border-bambu-dark-tertiary",children:[x&&s.jsxs("div",{className:"mb-3",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.discovery.subnetToScan")}),s.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:y,onChange:R=>v(R.target.value),placeholder:"192.168.1.0/24",disabled:o}),s.jsx("p",{className:"mt-1 text-xs text-bambu-gray",children:r("printers.discovery.dockerNote")})]}),s.jsx(Te,{type:"button",variant:"secondary",onClick:E,disabled:o,className:"w-full",children:o?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),x&&S.total>0?r("printers.discovery.scanProgress",{scanned:S.scanned,total:S.total}):r("printers.discovery.scanning")]}):s.jsxs(s.Fragment,{children:[s.jsx(ba,{className:"w-4 h-4"}),r(x?"printers.discovery.scanSubnet":"printers.discovery.discoverNetwork")]})}),d&&s.jsx("div",{className:"mt-2 text-sm text-red-400",children:d}),T.length>0&&s.jsx("div",{className:"mt-3 space-y-2 max-h-40 overflow-y-auto",children:T.map(R=>s.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(R),children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"font-medium text-white text-sm truncate",children:R.name||R.serial}),s.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[C(R.model)||r("printers.discovery.unknown")," • ",R.ip_address,R.serial.startsWith("unknown-")&&s.jsxs("span",{className:"text-yellow-500",children:[" • ",r("printers.discovery.serialRequired")]})]})]}),s.jsx(ei,{className:"w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2"})]},R.serial))}),o&&s.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:r(x?"printers.discovery.scanningSubnet":"printers.discovery.scanningNetwork")}),p&&!o&&c.length===0&&s.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:r(x?"printers.discovery.noPrintersFoundSubnet":"printers.discovery.noPrintersFoundNetwork")}),p&&!o&&c.length>0&&T.length===0&&s.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:r("printers.discovery.allConfigured")})]}),s.jsxs("form",{onSubmit:R=>{R.preventDefault(),e(i)},className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.name")}),s.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:R=>a({...i,name:R.target.value}),placeholder:r("printers.modal.myPrinter")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.ipAddress")}),s.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:R=>a({...i,ip_address:R.target.value}),placeholder:"192.168.1.100"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.serialNumber")}),s.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.serial_number,onChange:R=>a({...i,serial_number:R.target.value}),placeholder:"01P00A000000000"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.accessCode")}),s.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:i.access_code,onChange:R=>a({...i,access_code:R.target.value}),placeholder:r("printers.modal.fromPrinterSettings")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.modal.modelOptional")}),s.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:R=>a({...i,model:R.target.value}),children:[s.jsx("option",{value:"",children:r("printers.modal.selectModel")}),s.jsxs("optgroup",{label:"H2 Series",children:[s.jsx("option",{value:"H2C",children:"H2C"}),s.jsx("option",{value:"H2D",children:"H2D"}),s.jsx("option",{value:"H2D Pro",children:"H2D Pro"}),s.jsx("option",{value:"H2S",children:"H2S"})]}),s.jsxs("optgroup",{label:"X1 Series",children:[s.jsx("option",{value:"X1E",children:"X1E"}),s.jsx("option",{value:"X1C",children:"X1 Carbon"}),s.jsx("option",{value:"X1",children:"X1"})]}),s.jsxs("optgroup",{label:"P Series",children:[s.jsx("option",{value:"P2S",children:"P2S"}),s.jsx("option",{value:"P1S",children:"P1S"}),s.jsx("option",{value:"P1P",children:"P1P"})]}),s.jsxs("optgroup",{label:"A1 Series",children:[s.jsx("option",{value:"A1",children:"A1"}),s.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.modal.locationGroup")}),s.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:R=>a({...i,location:R.target.value}),placeholder:r("printers.modal.locationPlaceholder")}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:r("printers.locationHelp")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"auto_archive",checked:i.auto_archive,onChange:R=>a({...i,auto_archive:R.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:r("printers.modal.autoArchiveLabel")})]}),s.jsxs("div",{className:"flex gap-3 pt-4",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:r("common.cancel")}),s.jsx(Te,{type:"submit",className:"flex-1",children:r("printers.addPrinter")})]})]})]})})})}function cje({printer:t,firmwareInfo:e,onClose:n}){const{t:r}=$n(),i=an(),{showToast:a}=Hn(),[o,l]=_.useState(null),[c,u]=_.useState(!1),[d,f]=_.useState(null),{data:p,isLoading:m}=at({queryKey:["firmwarePrepare",t.id],queryFn:()=>g1.prepareUpload(t.id),staleTime:3e4}),x=mt({mutationFn:()=>g1.startUpload(t.id),onSuccess:()=>{u(!0);const y=setInterval(async()=>{try{const v=await g1.getUploadStatus(t.id);l(v),(v.status==="complete"||v.status==="error")&&(clearInterval(y),f(null),u(!1),v.status==="complete"&&(a(r("printers.firmwareModal.uploadedToast"),"success"),i.invalidateQueries({queryKey:["firmwareUpdate",t.id]})))}catch{}},2e3);f(y)},onError:y=>{a(`Failed to start upload: ${y.message}`,"error"),u(!1)}});_.useEffect(()=>()=>{d&&clearInterval(d)},[d]);const b=()=>{l(null),x.mutate()};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsx(_t,{className:"w-full max-w-md mx-4",children:s.jsxs(Nt,{children:[s.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[s.jsx("div",{className:"p-2 rounded-full bg-orange-500/20",children:s.jsx(yi,{className:"w-5 h-5 text-orange-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:r("printers.firmwareModal.title")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:t.name})]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:[s.jsxs("div",{className:"flex justify-between items-center text-sm",children:[s.jsx("span",{className:"text-bambu-gray",children:r("printers.firmwareModal.currentVersion")}),s.jsx("span",{className:"text-white font-mono",children:e.current_version||r("common.unknown")})]}),s.jsxs("div",{className:"flex justify-between items-center text-sm mt-1",children:[s.jsx("span",{className:"text-bambu-gray",children:r("printers.firmwareModal.latestVersion")}),s.jsx("span",{className:"text-orange-400 font-mono",children:e.latest_version})]}),e.release_notes&&s.jsxs("details",{className:"mt-3 text-sm",children:[s.jsx("summary",{className:"text-orange-400 cursor-pointer hover:underline",children:r("printers.firmwareModal.releaseNotes")}),s.jsx("div",{className:"mt-2 text-bambu-gray text-xs max-h-40 overflow-y-auto whitespace-pre-wrap",children:e.release_notes})]})]}),m?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm mb-4",children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),r("printers.firmwareModal.checkingPrereqs")]}):p&&!c&&!o?s.jsx("div",{className:"mb-4",children:p.can_proceed?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-green text-sm",children:[s.jsx(lo,{className:"w-4 h-4"}),r("printers.firmwareModal.sdCardReady")]}):s.jsx("div",{className:"space-y-1",children:p.errors.map((y,v)=>s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx($i,{className:"w-4 h-4 flex-shrink-0"}),y]},v))})}):null,(c||o)&&o&&s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex items-center justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-bambu-gray capitalize",children:o.status}),s.jsxs("span",{className:"text-white",children:[o.progress,"%"]})]}),s.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:s.jsx("div",{className:`h-2 rounded-full transition-all ${o.status==="error"?"bg-status-error":o.status==="complete"?"bg-status-ok":"bg-orange-500"} ${o.status==="uploading"?"animate-pulse":""}`,style:{width:`${o.progress}%`}})}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:o.message}),o.error&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:o.error})]}),o?.status==="complete"&&s.jsxs("div",{className:"bg-bambu-green/10 border border-bambu-green/30 rounded-lg p-3 mb-4",children:[s.jsx("p",{className:"text-sm text-bambu-green font-medium mb-2",children:r("printers.firmwareModal.uploadedSuccess")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:r("printers.firmwareModal.applyInstructions")}),s.jsxs("ol",{className:"text-xs text-bambu-gray mt-1 list-decimal list-inside space-y-1",children:[s.jsx("li",{dangerouslySetInnerHTML:{__html:r("printers.firmwareModal.step1")}}),s.jsx("li",{dangerouslySetInnerHTML:{__html:r("printers.firmwareModal.step2")}}),s.jsx("li",{dangerouslySetInnerHTML:{__html:r("printers.firmwareModal.step3")}}),s.jsx("li",{children:r("printers.firmwareModal.step4")})]})]}),s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx(Te,{variant:"secondary",onClick:n,children:o?.status==="complete"?r("printers.firmwareModal.done"):r("common.cancel")}),p?.can_proceed&&!c&&o?.status!=="complete"&&s.jsx(Te,{onClick:b,disabled:x.isPending,children:x.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin mr-2"}),r("printers.firmwareModal.starting")]}):s.jsxs(s.Fragment,{children:[s.jsx(yi,{className:"w-4 h-4 mr-2"}),r("printers.firmwareModal.uploadFirmware")]})})]})]})})})}function uje({printer:t,onClose:e}){const{t:n}=$n(),r=an(),{showToast:i}=Hn(),[a,o]=_.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),l=mt({mutationFn:u=>ue.updatePrinter(t.id,u),onSuccess:()=>{r.invalidateQueries({queryKey:["printers"]}),r.invalidateQueries({queryKey:["printerStatus",t.id]}),e()},onError:u=>i(u.message||n("printers.toast.failedToUpdate"),"error")});_.useEffect(()=>{const u=d=>{d.key==="Escape"&&e()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[e]);const c=u=>{u.preventDefault();const d={name:a.name,ip_address:a.ip_address,model:a.model||void 0,location:a.location||void 0,auto_archive:a.auto_archive};a.access_code&&(d.access_code=a.access_code),l.mutate(d)};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:s.jsx(_t,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:s.jsxs(Nt,{children:[s.jsx("h2",{className:"text-xl font-semibold mb-4",children:n("printers.editPrinter")}),s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.name")}),s.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:a.name,onChange:u=>o({...a,name:u.target.value}),placeholder:n("printers.modal.myPrinter")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.ipAddress")}),s.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:a.ip_address,onChange:u=>o({...a,ip_address:u.target.value}),placeholder:"192.168.1.100"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.serialNumber")}),s.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}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n("printers.serialCannotBeChanged")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.accessCode")}),s.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:a.access_code,onChange:u=>o({...a,access_code:u.target.value}),placeholder:n("printers.accessCodePlaceholder")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.model")}),s.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:a.model,onChange:u=>o({...a,model:u.target.value}),children:[s.jsx("option",{value:"",children:n("printers.modal.selectModel")}),s.jsxs("optgroup",{label:"H2 Series",children:[s.jsx("option",{value:"H2C",children:"H2C"}),s.jsx("option",{value:"H2D",children:"H2D"}),s.jsx("option",{value:"H2D Pro",children:"H2D Pro"}),s.jsx("option",{value:"H2S",children:"H2S"})]}),s.jsxs("optgroup",{label:"X1 Series",children:[s.jsx("option",{value:"X1E",children:"X1E"}),s.jsx("option",{value:"X1C",children:"X1 Carbon"}),s.jsx("option",{value:"X1",children:"X1"})]}),s.jsxs("optgroup",{label:"P Series",children:[s.jsx("option",{value:"P2S",children:"P2S"}),s.jsx("option",{value:"P1S",children:"P1S"}),s.jsx("option",{value:"P1P",children:"P1P"})]}),s.jsxs("optgroup",{label:"A1 Series",children:[s.jsx("option",{value:"A1",children:"A1"}),s.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Location / Group"}),s.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:a.location,onChange:u=>o({...a,location:u.target.value}),placeholder:n("printers.modal.locationPlaceholder")}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n("printers.locationHelp")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"edit_auto_archive",checked:a.auto_archive,onChange:u=>o({...a,auto_archive:u.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:n("printers.modal.autoArchiveLabel")})]}),s.jsxs("div",{className:"flex gap-3 pt-4",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:n("common.cancel")}),s.jsx(Te,{type:"submit",className:"flex-1",disabled:l.isPending,children:l.isPending?n("common.saving"):n("printers.modal.saveChanges")})]})]})]})})})}function dje(t){const{data:e}=at({queryKey:["printerStatus",t],queryFn:()=>ue.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function hje({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=dje(t.id),{data:a}=at({queryKey:["smartPlugStatus",e.id],queryFn:()=>ue.getSmartPlugStatus(e.id),refetchInterval:1e4});return i?s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:t.name}),a&&s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${a.state==="ON"?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:a.state||"?"})]}),s.jsxs("button",{onClick:()=>n(e.id),disabled:r||a?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${a?.state==="ON"?"bg-bambu-green/20 text-bambu-green cursor-default":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green hover:text-white"}`,children:[s.jsx(Gu,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function fje(){const{t}=$n(),[e,n]=_.useState(!1),[r,i]=_.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[a,o]=_.useState(!1),[l,c]=_.useState(null),[u,d]=_.useState(()=>localStorage.getItem("printerSortBy")||"name"),[f,p]=_.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[m,x]=_.useState(()=>{const de=localStorage.getItem("printerCardSize");return de?parseInt(de,10):2}),b=m===1?"compact":"expanded",y=an(),{showToast:v}=Hn(),{hasPermission:S}=Ai(),[M,T]=_.useState(()=>{const de=localStorage.getItem("openEmbeddedCameras");if(de)try{const Pe=JSON.parse(de);return new Map(Pe.map(ie=>[ie.id,ie]))}catch{return new Map}return new Map});_.useEffect(()=>{const de=Array.from(M.values());de.length>0?localStorage.setItem("openEmbeddedCameras",JSON.stringify(de)):localStorage.removeItem("openEmbeddedCameras")},[M]);const{data:E,isLoading:C}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:k}=at({queryKey:["settings"],queryFn:ue.getSettings});_.useEffect(()=>{k?.camera_view_mode==="window"&&M.size>0&&T(new Map)},[k?.camera_view_mode,M.size]);const{data:R}=at({queryKey:["smart-plugs"],queryFn:ue.getSmartPlugs}),{data:A}=at({queryKey:["maintenanceOverview"],queryFn:ue.getMaintenanceOverview,staleTime:60*1e3}),{data:D}=at({queryKey:["spoolman-status"],queryFn:ue.getSpoolmanStatus,staleTime:60*1e3}),U=D?.enabled&&D?.connected,{data:F}=at({queryKey:["unlinked-spools"],queryFn:ue.getUnlinkedSpools,enabled:!!U,staleTime:30*1e3}),H=F&&F.length>0,{data:j}=at({queryKey:["linked-spools"],queryFn:ue.getLinkedSpools,enabled:!!U,staleTime:30*1e3}),$=j?.linked,K=A?.reduce((de,Pe)=>(de[Pe.printer_id]={due_count:Pe.due_count,warning_count:Pe.warning_count,total_print_hours:Pe.total_print_hours},de),{})||{},V=R?.reduce((de,Pe)=>(Pe.printer_id&&(de[Pe.printer_id]=Pe),de),{})||{},Q=mt({mutationFn:ue.createPrinter,onSuccess:()=>{y.invalidateQueries({queryKey:["printers"]}),y.invalidateQueries({queryKey:["maintenanceOverview"]}),n(!1)},onError:de=>v(de.message||t("printers.toast.failedToAdd"),"error")}),Z=mt({mutationFn:de=>ue.controlSmartPlug(de,"on"),onSuccess:()=>{y.invalidateQueries({queryKey:["smart-plugs"]}),c(null)},onError:()=>{c(null)}}),ae=()=>{const de=!r;i(de),localStorage.setItem("hideDisconnectedPrinters",String(de))},B=de=>{d(de),localStorage.setItem("printerSortBy",de)},X=()=>{const de=!f;p(de),localStorage.setItem("printerSortAsc",String(de))},ne=()=>{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"}},se=["S","M","L","XL"],be=_.useMemo(()=>{if(!E)return[];const de=[...E];switch(u){case"name":de.sort((Pe,ie)=>Pe.name.localeCompare(ie.name));break;case"model":de.sort((Pe,ie)=>(Pe.model||"").localeCompare(ie.model||""));break;case"location":de.sort((Pe,ie)=>{const Me=Pe.location||"",Oe=ie.location||"";return!Me&&Oe?1:Me&&!Oe?-1:Me.localeCompare(Oe)||Pe.name.localeCompare(ie.name)});break;case"status":de.sort((Pe,ie)=>{const Me=y.getQueryData(["printerStatus",Pe.id]),Oe=y.getQueryData(["printerStatus",ie.id]),ge=Ke=>Ke?.connected?Ke.state==="RUNNING"?0:1:2;return ge(Me)-ge(Oe)});break}return f||de.reverse(),de},[E,u,f,y]),xe=_.useMemo(()=>{if(u!=="location")return null;const de={};return be.forEach(Pe=>{const ie=Pe.location||"Ungrouped";de[ie]||(de[ie]=[]),de[ie].push(Pe)}),de},[u,be]);return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:t("printers.title")}),s.jsx(oje,{printers:E})]}),s.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 flex-wrap",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("select",{value:u,onChange:de=>B(de.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:[s.jsx("option",{value:"name",children:t("printers.sort.name")}),s.jsx("option",{value:"status",children:t("printers.sort.status")}),s.jsx("option",{value:"model",children:t("printers.sort.model")}),s.jsx("option",{value:"location",children:t("printers.sort.location")})]}),s.jsx("button",{onClick:X,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:t(f?"printers.sort.descending":"printers.sort.ascending"),children:f?s.jsx(Ig,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(G0,{className:"w-4 h-4 text-bambu-gray"})})]}),s.jsx("div",{className:"flex items-center bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:se.map((de,Pe)=>{const ie=Pe+1,Me=m===ie;return s.jsx("button",{onClick:()=>{x(ie),localStorage.setItem("printerCardSize",String(ie))},className:`px-2 py-1.5 text-xs font-medium transition-colors ${Pe===0?"rounded-l-lg":""} ${Pe===se.length-1?"rounded-r-lg":""} ${Me?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white"}`,title:t(de==="S"?"printers.cardSize.small":de==="M"?"printers.cardSize.medium":de==="L"?"printers.cardSize.large":"printers.cardSize.extraLarge"),children:de},de)})}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:r,onChange:ae,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),t("printers.hideOffline")]}),r&&Object.keys(V).length>0&&s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onClick:()=>o(!a),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:[s.jsx(Gu,{className:"w-4 h-4"}),t("printers.powerOn"),s.jsx(ei,{className:`w-3 h-3 transition-transform ${a?"rotate-180":""}`})]}),a&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>o(!1)}),s.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:[s.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:t("printers.offlinePrintersWithPlugs")}),E?.filter(de=>V[de.id]).map(de=>s.jsx(hje,{printer:de,plug:V[de.id],onPowerOn:Pe=>{c(Pe),Z.mutate(Pe)},isPowering:l===V[de.id]?.id},de.id)),E?.filter(de=>V[de.id]).length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),s.jsxs(Te,{onClick:()=>n(!0),disabled:!S("printers:create"),title:S("printers:create")?void 0:t("printers.permission.noAdd"),children:[s.jsx(ur,{className:"w-4 h-4"}),t("printers.addPrinter")]})]})]}),C?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("common.loading")}):E?.length===0?s.jsx(_t,{children:s.jsxs(Nt,{className:"text-center py-12",children:[s.jsx("p",{className:"text-bambu-gray mb-4",children:t("printers.noPrintersConfigured")}),s.jsxs(Te,{onClick:()=>n(!0),disabled:!S("printers:create"),title:S("printers:create")?void 0:t("printers.permission.noAdd"),children:[s.jsx(ur,{className:"w-4 h-4"}),t("printers.addPrinter")]})]})}):xe?s.jsx("div",{className:"space-y-6",children:Object.entries(xe).map(([de,Pe])=>s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),de,s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",Pe.length,")"]})]}),s.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${ne()}`,children:Pe.map(ie=>s.jsx(MH,{printer:ie,hideIfDisconnected:r,maintenanceInfo:K[ie.id],viewMode:b,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:U,hasUnlinkedSpools:H,linkedSpools:$,spoolmanUrl:D?.url,timeFormat:k?.time_format||"system",cameraViewMode:k?.camera_view_mode||"window",onOpenEmbeddedCamera:(Me,Oe)=>T(ge=>new Map(ge).set(Me,{id:Me,name:Oe})),checkPrinterFirmware:k?.check_printer_firmware!==!1},ie.id))})]},de))}):s.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${ne()}`,children:be.map(de=>s.jsx(MH,{printer:de,hideIfDisconnected:r,maintenanceInfo:K[de.id],viewMode:b,cardSize:m,spoolmanEnabled:U,hasUnlinkedSpools:H,linkedSpools:$,spoolmanUrl:D?.url,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:(Pe,ie)=>T(Me=>new Map(Me).set(Pe,{id:Pe,name:ie})),checkPrinterFirmware:k?.check_printer_firmware!==!1},de.id))}),e&&s.jsx(lje,{onClose:()=>n(!1),onAdd:de=>Q.mutate(de),existingSerials:E?.map(de=>de.serial_number)||[]}),Array.from(M.values()).map((de,Pe)=>s.jsx(Bfe,{printerId:de.id,printerName:de.name,viewerIndex:Pe,onClose:()=>T(ie=>{const Me=new Map(ie);return Me.delete(de.id),Me})},de.id))]})}function mje(){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 pje(){switch(mje()){case"windows":return"bambustudio://";case"macos":case"linux":default:return"bambustudioopen://"}}function mu(t){const e=pje();window.location.href=`${e}${encodeURIComponent(t)}`}const B4="181",Tg={ROTATE:0,DOLLY:1,PAN:2},bg={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},gje=0,EH=1,xje=2,XZ=1,bje=2,ou=3,Eh=0,Us=1,ic=2,Tu=0,Ag=1,kH=2,TH=3,AH=4,yje=5,Nf=100,vje=101,wje=102,_je=103,Sje=104,Nje=200,Mje=201,Eje=202,kje=203,S3=204,N3=205,Tje=206,Aje=207,Cje=208,jje=209,Pje=210,Dje=211,Rje=212,Oje=213,Lje=214,M3=0,E3=1,k3=2,Qg=3,T3=4,A3=5,C3=6,j3=7,$4=0,Fje=1,Ije=2,lh=0,Uje=1,zje=2,Bje=3,$je=4,Hje=5,Vje=6,Gje=7,YZ=300,Zg=301,Jg=302,P3=303,D3=304,fM=306,R3=1e3,vu=1001,O3=1002,po=1003,qje=1004,Zw=1005,el=1006,GA=1007,Of=1008,yc=1009,QZ=1010,ZZ=1011,dy=1012,H4=1013,pm=1014,wu=1015,Cx=1016,V4=1017,G4=1018,hy=1020,JZ=35902,eJ=35899,tJ=1021,nJ=1022,Pl=1023,fy=1026,my=1027,rJ=1028,q4=1029,W4=1030,K4=1031,X4=1033,N1=33776,M1=33777,E1=33778,k1=33779,L3=35840,F3=35841,I3=35842,U3=35843,z3=36196,B3=37492,$3=37496,H3=37808,V3=37809,G3=37810,q3=37811,W3=37812,K3=37813,X3=37814,Y3=37815,Q3=37816,Z3=37817,J3=37818,eD=37819,tD=37820,nD=37821,rD=36492,iD=36494,aD=36495,sD=36283,oD=36284,lD=36285,cD=36286,Wje=3200,Kje=3201,iJ=0,Xje=1,Kd="",Vo="srgb",ex="srgb-linear",WS="linear",Mr="srgb",vp=7680,CH=519,Yje=512,Qje=513,Zje=514,aJ=515,Jje=516,ePe=517,tPe=518,nPe=519,jH=35044,PH="300 es",lc=2e3,KS=2001;function sJ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function XS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function rPe(){const t=XS("canvas");return t.style.display="block",t}const DH={};function RH(...t){const e="THREE."+t.shift();console.log(e,...t)}function gn(...t){const e="THREE."+t.shift();console.warn(e,...t)}function ki(...t){const e="THREE."+t.shift();console.error(e,...t)}function py(...t){const e=t.join(" ");e in DH||(DH[e]=!0,gn(...t))}function iPe(t,e,n){return new Promise(function(r,i){function a(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}let Cm=class{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){const r=this._listeners;if(r===void 0)return;const i=r[e];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const r=n[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let a=0,o=i.length;a<o;a++)i[a].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"],T1=Math.PI/180,uD=180/Math.PI;function hv(){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 zn(t,e,n){return Math.max(e,Math.min(n,t))}function aPe(t,e){return(t%e+e)%e}function qA(t,e,n){return(1-n)*t+n*e}function Ub(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 Cs(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 sPe={DEG2RAD:T1};let Tn=class oJ{constructor(e=0,n=0){oJ.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=zn(this.x,e.x,n.x),this.y=zn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=zn(this.x,e,n),this.y=zn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(zn(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(zn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),a=this.x-e.x,o=this.y-e.y;return this.x=a*r-o*i+e.x,this.y=a*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}},gm=class{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,a,o,l){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3],p=a[o+0],m=a[o+1],x=a[o+2],b=a[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]=p,e[n+1]=m,e[n+2]=x,e[n+3]=b;return}if(f!==b||c!==p||u!==m||d!==x){let y=c*p+u*m+d*x+f*b;y<0&&(p=-p,m=-m,x=-x,b=-b,y=-y);let v=1-l;if(y<.9995){const S=Math.acos(y),M=Math.sin(S);v=Math.sin(v*S)/M,l=Math.sin(l*S)/M,c=c*v+p*l,u=u*v+m*l,d=d*v+x*l,f=f*v+b*l}else{c=c*v+p*l,u=u*v+m*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,a,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[o],p=a[o+1],m=a[o+2],x=a[o+3];return e[n]=l*x+d*f+c*m-u*p,e[n+1]=c*x+d*p+u*f-l*m,e[n+2]=u*x+d*m+l*p-c*f,e[n+3]=d*x-l*f-c*p-u*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n=!0){const r=e._x,i=e._y,a=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(a/2),p=c(r/2),m=c(i/2),x=c(a/2);switch(o){case"XYZ":this._x=p*d*f+u*m*x,this._y=u*m*f-p*d*x,this._z=u*d*x+p*m*f,this._w=u*d*f-p*m*x;break;case"YXZ":this._x=p*d*f+u*m*x,this._y=u*m*f-p*d*x,this._z=u*d*x-p*m*f,this._w=u*d*f+p*m*x;break;case"ZXY":this._x=p*d*f-u*m*x,this._y=u*m*f+p*d*x,this._z=u*d*x+p*m*f,this._w=u*d*f-p*m*x;break;case"ZYX":this._x=p*d*f-u*m*x,this._y=u*m*f+p*d*x,this._z=u*d*x-p*m*f,this._w=u*d*f+p*m*x;break;case"YZX":this._x=p*d*f+u*m*x,this._y=u*m*f+p*d*x,this._z=u*d*x-p*m*f,this._w=u*d*f-p*m*x;break;case"XZY":this._x=p*d*f-u*m*x,this._y=u*m*f-p*d*x,this._z=u*d*x+p*m*f,this._w=u*d*f+p*m*x;break;default:gn("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],a=n[8],o=n[1],l=n[5],c=n[9],u=n[2],d=n[6],f=n[10],p=r+l+f;if(p>0){const m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(d-c)*m,this._y=(a-u)*m,this._z=(o-i)*m}else if(r>l&&r>f){const m=2*Math.sqrt(1+r-l-f);this._w=(d-c)/m,this._x=.25*m,this._y=(i+o)/m,this._z=(a+u)/m}else if(l>f){const m=2*Math.sqrt(1+l-r-f);this._w=(a-u)/m,this._x=(i+o)/m,this._y=.25*m,this._z=(c+d)/m}else{const m=2*Math.sqrt(1+f-r-l);this._w=(o-i)/m,this._x=(a+u)/m,this._y=(c+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(zn(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,a=e._z,o=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+o*l+i*u-a*c,this._y=i*d+o*c+a*l-r*u,this._z=a*d+o*u+r*c-i*l,this._w=o*d-r*l-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){if(n<=0)return this;if(n>=1)return this.copy(e);let r=e._x,i=e._y,a=e._z,o=e._w,l=this.dot(e);l<0&&(r=-r,i=-i,a=-a,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+a*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+a*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),a=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),a*Math.sin(n),a*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},dt=class lJ{constructor(e=0,n=0,r=0){lJ.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(OH.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(OH.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,o=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*o,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*o,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-a*i),f=2*(a*r-o*n);return this.x=n+c*u+o*f-l*d,this.y=r+c*d+l*u-a*f,this.z=i+c*f+a*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,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=zn(this.x,e.x,n.x),this.y=zn(this.y,e.y,n.y),this.z=zn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=zn(this.x,e,n),this.y=zn(this.y,e,n),this.z=zn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(zn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,o=n.x,l=n.y,c=n.z;return this.x=i*c-a*l,this.y=a*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 WA.copy(this).projectOnVector(e),this.sub(WA)}reflect(e){return this.sub(WA.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(zn(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 WA=new dt,OH=new gm;let Pn=class cJ{constructor(e,n,r,i,a,o,l,c,u){cJ.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,o,l,c,u)}set(e,n,r,i,a,o,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=a,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,a=this.elements,o=r[0],l=r[3],c=r[6],u=r[1],d=r[4],f=r[7],p=r[2],m=r[5],x=r[8],b=i[0],y=i[3],v=i[6],S=i[1],M=i[4],T=i[7],E=i[2],C=i[5],k=i[8];return a[0]=o*b+l*S+c*E,a[3]=o*y+l*M+c*C,a[6]=o*v+l*T+c*k,a[1]=u*b+d*S+f*E,a[4]=u*y+d*M+f*C,a[7]=u*v+d*T+f*k,a[2]=p*b+m*S+x*E,a[5]=p*y+m*M+x*C,a[8]=p*v+m*T+x*k,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8];return n*o*d-n*l*u-r*a*d+r*l*c+i*a*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=d*o-l*u,p=l*c-d*a,m=u*a-o*c,x=n*f+r*p+i*m;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]=p*b,e[4]=(d*n-i*c)*b,e[5]=(i*a-l*n)*b,e[6]=m*b,e[7]=(r*c-u*n)*b,e[8]=(o*n-r*a)*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,a,o,l){const c=Math.cos(a),u=Math.sin(a);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(KA.makeScale(e,n)),this}rotate(e){return this.premultiply(KA.makeRotation(-e)),this}translate(e,n){return this.premultiply(KA.makeTranslation(e,n)),this}makeTranslation(e,n){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,n,0,0,1),this}makeRotation(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,r,n,0,0,0,1),this}makeScale(e,n){return this.set(e,0,0,0,n,0,0,0,1),this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<9;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<9;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const KA=new Pn,LH=new Pn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),FH=new Pn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function oPe(){const t={enabled:!0,workingColorSpace:ex,spaces:{},convert:function(i,a,o){return this.enabled===!1||a===o||!a||!o||(this.spaces[a].transfer===Mr&&(i.r=Au(i.r),i.g=Au(i.g),i.b=Au(i.b)),this.spaces[a].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[a].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===Mr&&(i.r=Cg(i.r),i.g=Cg(i.g),i.b=Cg(i.b))),i},workingToColorSpace:function(i,a){return this.convert(i,this.workingColorSpace,a)},colorSpaceToWorking:function(i,a){return this.convert(i,a,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Kd?WS:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,a=this.workingColorSpace){return i.fromArray(this.spaces[a].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,a,o){return i.copy(this.spaces[a].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,a){return py("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return py("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(i,a)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return t.define({[ex]:{primaries:e,whitePoint:r,transfer:WS,toXYZ:LH,fromXYZ:FH,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Vo},outputColorSpaceConfig:{drawingBufferColorSpace:Vo}},[Vo]:{primaries:e,whitePoint:r,transfer:Mr,toXYZ:LH,fromXYZ:FH,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Vo}}}),t}const sr=oPe();function Au(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 wp,lPe=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{wp===void 0&&(wp=XS("canvas")),wp.width=e.width,wp.height=e.height;const i=wp.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=wp}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=XS("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),a=i.data;for(let o=0;o<a.length;o++)a[o]=Au(a[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(Au(n[r]/255)*255):n[r]=Au(n[r]);return{data:n,width:e.width,height:e.height}}else return gn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},cPe=0,Y4=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:cPe++}),this.uuid=hv(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const n=this.data;return typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?e.set(n.videoWidth,n.videoHeight,0):n instanceof VideoFrame?e.set(n.displayHeight,n.displayWidth,0):n!==null?e.set(n.width,n.height,n.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let o=0,l=i.length;o<l;o++)i[o].isDataTexture?a.push(XA(i[o].image)):a.push(XA(i[o]))}else a=XA(i);r.url=a}return n||(e.images[this.uuid]=r),r}};function XA(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?lPe.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(gn("Texture: Unable to serialize Texture."),{})}let uPe=0;const YA=new dt;let $l=class A1 extends Cm{constructor(e=A1.DEFAULT_IMAGE,n=A1.DEFAULT_MAPPING,r=vu,i=vu,a=el,o=Of,l=Pl,c=yc,u=A1.DEFAULT_ANISOTROPY,d=Kd){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:uPe++}),this.uuid=hv(),this.name="",this.source=new Y4(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=u,this.format=l,this.internalFormat=null,this.type=c,this.offset=new Tn(0,0),this.repeat=new Tn(1,1),this.center=new Tn(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(YA).x}get height(){return this.source.getSize(YA).y}get depth(){return this.source.getSize(YA).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){gn(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){gn(`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!==YZ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case R3:e.x=e.x-Math.floor(e.x);break;case vu:e.x=e.x<0?0:1;break;case O3: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 R3:e.y=e.y-Math.floor(e.y);break;case vu:e.y=e.y<0?0:1;break;case O3: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++}};$l.DEFAULT_IMAGE=null;$l.DEFAULT_MAPPING=YZ;$l.DEFAULT_ANISOTROPY=1;let Ui=class uJ{constructor(e=0,n=0,r=0,i=1){uJ.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=this.w,o=e.elements;return this.x=o[0]*n+o[4]*r+o[8]*i+o[12]*a,this.y=o[1]*n+o[5]*r+o[9]*i+o[13]*a,this.z=o[2]*n+o[6]*r+o[10]*i+o[14]*a,this.w=o[3]*n+o[7]*r+o[11]*i+o[15]*a,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const c=e.elements,u=c[0],d=c[4],f=c[8],p=c[1],m=c[5],x=c[9],b=c[2],y=c[6],v=c[10];if(Math.abs(d-p)<.01&&Math.abs(f-b)<.01&&Math.abs(x-y)<.01){if(Math.abs(d+p)<.1&&Math.abs(f+b)<.1&&Math.abs(x+y)<.1&&Math.abs(u+m+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const M=(u+1)/2,T=(m+1)/2,E=(v+1)/2,C=(d+p)/4,k=(f+b)/4,R=(x+y)/4;return M>T&&M>E?M<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(M),i=C/r,a=k/r):T>E?T<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(T),r=C/i,a=R/i):E<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(E),r=k/a,i=R/a),this.set(r,i,a,n),this}let S=Math.sqrt((y-x)*(y-x)+(f-b)*(f-b)+(p-d)*(p-d));return Math.abs(S)<.001&&(S=1),this.x=(y-x)/S,this.y=(f-b)/S,this.z=(p-d)/S,this.w=Math.acos((u+m+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=zn(this.x,e.x,n.x),this.y=zn(this.y,e.y,n.y),this.z=zn(this.z,e.z,n.z),this.w=zn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=zn(this.x,e,n),this.y=zn(this.y,e,n),this.z=zn(this.z,e,n),this.w=zn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(zn(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}},dPe=class extends Cm{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:el,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 Ui(0,0,e,n),this.scissorTest=!1,this.viewport=new Ui(0,0,e,n);const i={width:e,height:n,depth:r.depth},a=new $l(i);this.textures=[];const o=r.count;for(let l=0;l<o;l++)this.textures[l]=a.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:el,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(n.mapping=e.mapping),e.wrapS!==void 0&&(n.wrapS=e.wrapS),e.wrapT!==void 0&&(n.wrapT=e.wrapT),e.wrapR!==void 0&&(n.wrapR=e.wrapR),e.magFilter!==void 0&&(n.magFilter=e.magFilter),e.minFilter!==void 0&&(n.minFilter=e.minFilter),e.format!==void 0&&(n.format=e.format),e.type!==void 0&&(n.type=e.type),e.anisotropy!==void 0&&(n.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(n.colorSpace=e.colorSpace),e.flipY!==void 0&&(n.flipY=e.flipY),e.generateMipmaps!==void 0&&(n.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(n.internalFormat=e.internalFormat);for(let r=0;r<this.textures.length;r++)this.textures[r].setValues(n)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,n,r=1){if(this.width!==e||this.height!==n||this.depth!==r){this.width=e,this.height=n,this.depth=r;for(let i=0,a=this.textures.length;i<a;i++)this.textures[i].image.width=e,this.textures[i].image.height=n,this.textures[i].image.depth=r,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,r=e.textures.length;n<r;n++){this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const i=Object.assign({},e.textures[n].image);this.textures[n].source=new Y4(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"})}},xm=class extends dPe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},dJ=class extends $l{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=po,this.minFilter=po,this.wrapR=vu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},hPe=class extends $l{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=po,this.minFilter=po,this.wrapR=vu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},bm=class{constructor(e=new dt(1/0,1/0,1/0),n=new dt(-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 a=r.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let o=0,l=a.count;o<l;o++)e.isMesh===!0?e.getVertexPosition(o,vl):vl.fromBufferAttribute(a,o),vl.applyMatrix4(e.matrixWorld),this.expandByPoint(vl);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Jw.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Jw.copy(r.boundingBox)),Jw.applyMatrix4(e.matrixWorld),this.union(Jw)}const i=e.children;for(let a=0,o=i.length;a<o;a++)this.expandByObject(i[a],n);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,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(zb),e_.subVectors(this.max,zb),_p.subVectors(e.a,zb),Sp.subVectors(e.b,zb),Np.subVectors(e.c,zb),Sd.subVectors(Sp,_p),Nd.subVectors(Np,Sp),of.subVectors(_p,Np);let n=[0,-Sd.z,Sd.y,0,-Nd.z,Nd.y,0,-of.z,of.y,Sd.z,0,-Sd.x,Nd.z,0,-Nd.x,of.z,0,-of.x,-Sd.y,Sd.x,0,-Nd.y,Nd.x,0,-of.y,of.x,0];return!QA(n,_p,Sp,Np,e_)||(n=[1,0,0,0,1,0,0,0,1],!QA(n,_p,Sp,Np,e_))?!1:(t_.crossVectors(Sd,Nd),n=[t_.x,t_.y,t_.z],QA(n,_p,Sp,Np,e_))}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:(qc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),qc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),qc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),qc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),qc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),qc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),qc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),qc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(qc),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 qc=[new dt,new dt,new dt,new dt,new dt,new dt,new dt,new dt],vl=new dt,Jw=new bm,_p=new dt,Sp=new dt,Np=new dt,Sd=new dt,Nd=new dt,of=new dt,zb=new dt,e_=new dt,t_=new dt,lf=new dt;function QA(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){lf.fromArray(t,a);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 fPe=new bm,Bb=new dt,ZA=new dt;let mM=class{constructor(e=new dt,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):fPe.setFromPoints(e).getCenter(r);let i=0;for(let a=0,o=e.length;a<o;a++)i=Math.max(i,r.distanceToSquared(e[a]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;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):(ZA.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Bb.copy(e.center).add(ZA)),this.expandByPoint(Bb.copy(e.center).sub(ZA))),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 Wc=new dt,JA=new dt,n_=new dt,Md=new dt,eC=new dt,r_=new dt,tC=new dt;let Q4=class{constructor(e=new dt,n=new dt(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,Wc)),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=Wc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Wc.copy(this.origin).addScaledVector(this.direction,n),Wc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){JA.copy(e).add(n).multiplyScalar(.5),n_.copy(n).sub(e).normalize(),Md.copy(this.origin).sub(JA);const a=e.distanceTo(n)*.5,o=-this.direction.dot(n_),l=Md.dot(this.direction),c=-Md.dot(n_),u=Md.lengthSq(),d=Math.abs(1-o*o);let f,p,m,x;if(d>0)if(f=o*c-l,p=o*l-c,x=a*d,f>=0)if(p>=-x)if(p<=x){const b=1/d;f*=b,p*=b,m=f*(f+o*p+2*l)+p*(o*f+p+2*c)+u}else p=a,f=Math.max(0,-(o*p+l)),m=-f*f+p*(p+2*c)+u;else p=-a,f=Math.max(0,-(o*p+l)),m=-f*f+p*(p+2*c)+u;else p<=-x?(f=Math.max(0,-(-o*a+l)),p=f>0?-a:Math.min(Math.max(-a,-c),a),m=-f*f+p*(p+2*c)+u):p<=x?(f=0,p=Math.min(Math.max(-a,-c),a),m=p*(p+2*c)+u):(f=Math.max(0,-(o*a+l)),p=f>0?a:Math.min(Math.max(-a,-c),a),m=-f*f+p*(p+2*c)+u);else p=o>0?-a:a,f=Math.max(0,-(o*p+l)),m=-f*f+p*(p+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(JA).addScaledVector(n_,p),m}intersectSphere(e,n){Wc.subVectors(e.center,this.origin);const r=Wc.dot(this.direction),i=Wc.dot(Wc)-r*r,a=e.radius*e.radius;if(i>a)return null;const o=Math.sqrt(a-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,a,o,l,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,p=this.origin;return u>=0?(r=(e.min.x-p.x)*u,i=(e.max.x-p.x)*u):(r=(e.max.x-p.x)*u,i=(e.min.x-p.x)*u),d>=0?(a=(e.min.y-p.y)*d,o=(e.max.y-p.y)*d):(a=(e.max.y-p.y)*d,o=(e.min.y-p.y)*d),r>o||a>i||((a>r||isNaN(r))&&(r=a),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-p.z)*f,c=(e.max.z-p.z)*f):(l=(e.max.z-p.z)*f,c=(e.min.z-p.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,Wc)!==null}intersectTriangle(e,n,r,i,a){eC.subVectors(n,e),r_.subVectors(r,e),tC.crossVectors(eC,r_);let o=this.direction.dot(tC),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;Md.subVectors(this.origin,e);const c=l*this.direction.dot(r_.crossVectors(Md,r_));if(c<0)return null;const u=l*this.direction.dot(eC.cross(Md));if(u<0||c+u>o)return null;const d=-l*Md.dot(tC);return d<0?null:this.at(d/o,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Vi=class dD{constructor(e,n,r,i,a,o,l,c,u,d,f,p,m,x,b,y){dD.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,o,l,c,u,d,f,p,m,x,b,y)}set(e,n,r,i,a,o,l,c,u,d,f,p,m,x,b,y){const v=this.elements;return v[0]=e,v[4]=n,v[8]=r,v[12]=i,v[1]=a,v[5]=o,v[9]=l,v[13]=c,v[2]=u,v[6]=d,v[10]=f,v[14]=p,v[3]=m,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 dD().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/Mp.setFromMatrixColumn(e,0).length(),a=1/Mp.setFromMatrixColumn(e,1).length(),o=1/Mp.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*a,n[5]=r[5]*a,n[6]=r[6]*a,n[7]=0,n[8]=r[8]*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,a=e.z,o=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const p=o*d,m=o*f,x=l*d,b=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=m+x*u,n[5]=p-b*u,n[9]=-l*c,n[2]=b-p*u,n[6]=x+m*u,n[10]=o*c}else if(e.order==="YXZ"){const p=c*d,m=c*f,x=u*d,b=u*f;n[0]=p+b*l,n[4]=x*l-m,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=m*l-x,n[6]=b+p*l,n[10]=o*c}else if(e.order==="ZXY"){const p=c*d,m=c*f,x=u*d,b=u*f;n[0]=p-b*l,n[4]=-o*f,n[8]=x+m*l,n[1]=m+x*l,n[5]=o*d,n[9]=b-p*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const p=o*d,m=o*f,x=l*d,b=l*f;n[0]=c*d,n[4]=x*u-m,n[8]=p*u+b,n[1]=c*f,n[5]=b*u+p,n[9]=m*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const p=o*c,m=o*u,x=l*c,b=l*u;n[0]=c*d,n[4]=b-p*f,n[8]=x*f+m,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=m*f+x,n[10]=p-b*f}else if(e.order==="XZY"){const p=o*c,m=o*u,x=l*c,b=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=p*f+b,n[5]=o*d,n[9]=m*f-x,n[2]=x*f-m,n[6]=l*d,n[10]=b*f+p}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(mPe,e,pPe)}lookAt(e,n,r){const i=this.elements;return no.subVectors(e,n),no.lengthSq()===0&&(no.z=1),no.normalize(),Ed.crossVectors(r,no),Ed.lengthSq()===0&&(Math.abs(r.z)===1?no.x+=1e-4:no.z+=1e-4,no.normalize(),Ed.crossVectors(r,no)),Ed.normalize(),i_.crossVectors(no,Ed),i[0]=Ed.x,i[4]=i_.x,i[8]=no.x,i[1]=Ed.y,i[5]=i_.y,i[9]=no.y,i[2]=Ed.z,i[6]=i_.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,a=this.elements,o=r[0],l=r[4],c=r[8],u=r[12],d=r[1],f=r[5],p=r[9],m=r[13],x=r[2],b=r[6],y=r[10],v=r[14],S=r[3],M=r[7],T=r[11],E=r[15],C=i[0],k=i[4],R=i[8],A=i[12],D=i[1],U=i[5],F=i[9],H=i[13],j=i[2],$=i[6],K=i[10],V=i[14],Q=i[3],Z=i[7],ae=i[11],B=i[15];return a[0]=o*C+l*D+c*j+u*Q,a[4]=o*k+l*U+c*$+u*Z,a[8]=o*R+l*F+c*K+u*ae,a[12]=o*A+l*H+c*V+u*B,a[1]=d*C+f*D+p*j+m*Q,a[5]=d*k+f*U+p*$+m*Z,a[9]=d*R+f*F+p*K+m*ae,a[13]=d*A+f*H+p*V+m*B,a[2]=x*C+b*D+y*j+v*Q,a[6]=x*k+b*U+y*$+v*Z,a[10]=x*R+b*F+y*K+v*ae,a[14]=x*A+b*H+y*V+v*B,a[3]=S*C+M*D+T*j+E*Q,a[7]=S*k+M*U+T*$+E*Z,a[11]=S*R+M*F+T*K+E*ae,a[15]=S*A+M*H+T*V+E*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],a=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],p=e[10],m=e[14],x=e[3],b=e[7],y=e[11],v=e[15];return x*(+a*c*f-i*u*f-a*l*p+r*u*p+i*l*m-r*c*m)+b*(+n*c*m-n*u*p+a*o*p-i*o*m+i*u*d-a*c*d)+y*(+n*u*f-n*l*m-a*o*f+r*o*m+a*l*d-r*u*d)+v*(-i*l*d-n*c*f+n*l*p+i*o*f-r*o*p+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9],p=e[10],m=e[11],x=e[12],b=e[13],y=e[14],v=e[15],S=f*y*u-b*p*u+b*c*m-l*y*m-f*c*v+l*p*v,M=x*p*u-d*y*u-x*c*m+o*y*m+d*c*v-o*p*v,T=d*b*u-x*f*u+x*l*m-o*b*m-d*l*v+o*f*v,E=x*f*c-d*b*c-x*l*p+o*b*p+d*l*y-o*f*y,C=n*S+r*M+i*T+a*E;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const k=1/C;return e[0]=S*k,e[1]=(b*p*a-f*y*a-b*i*m+r*y*m+f*i*v-r*p*v)*k,e[2]=(l*y*a-b*c*a+b*i*u-r*y*u-l*i*v+r*c*v)*k,e[3]=(f*c*a-l*p*a-f*i*u+r*p*u+l*i*m-r*c*m)*k,e[4]=M*k,e[5]=(d*y*a-x*p*a+x*i*m-n*y*m-d*i*v+n*p*v)*k,e[6]=(x*c*a-o*y*a-x*i*u+n*y*u+o*i*v-n*c*v)*k,e[7]=(o*p*a-d*c*a+d*i*u-n*p*u-o*i*m+n*c*m)*k,e[8]=T*k,e[9]=(x*f*a-d*b*a-x*r*m+n*b*m+d*r*v-n*f*v)*k,e[10]=(o*b*a-x*l*a+x*r*u-n*b*u-o*r*v+n*l*v)*k,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*m-n*l*m)*k,e[12]=E*k,e[13]=(d*b*i-x*f*i+x*r*p-n*b*p-d*r*y+n*f*y)*k,e[14]=(x*l*i-o*b*i-x*r*c+n*b*c+o*r*y-n*l*y)*k,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*p+n*l*p)*k,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,o=e.x,l=e.y,c=e.z,u=a*o,d=a*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,a*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,o){return this.set(1,r,a,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,o=n._y,l=n._z,c=n._w,u=a+a,d=o+o,f=l+l,p=a*u,m=a*d,x=a*f,b=o*d,y=o*f,v=l*f,S=c*u,M=c*d,T=c*f,E=r.x,C=r.y,k=r.z;return i[0]=(1-(b+v))*E,i[1]=(m+T)*E,i[2]=(x-M)*E,i[3]=0,i[4]=(m-T)*C,i[5]=(1-(p+v))*C,i[6]=(y+S)*C,i[7]=0,i[8]=(x+M)*k,i[9]=(y-S)*k,i[10]=(1-(p+b))*k,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let a=Mp.set(i[0],i[1],i[2]).length();const o=Mp.set(i[4],i[5],i[6]).length(),l=Mp.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),e.x=i[12],e.y=i[13],e.z=i[14],wl.copy(this);const u=1/a,d=1/o,f=1/l;return wl.elements[0]*=u,wl.elements[1]*=u,wl.elements[2]*=u,wl.elements[4]*=d,wl.elements[5]*=d,wl.elements[6]*=d,wl.elements[8]*=f,wl.elements[9]*=f,wl.elements[10]*=f,n.setFromRotationMatrix(wl),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=lc,c=!1){const u=this.elements,d=2*a/(n-e),f=2*a/(r-i),p=(n+e)/(n-e),m=(r+i)/(r-i);let x,b;if(c)x=a/(o-a),b=o*a/(o-a);else if(l===lc)x=-(o+a)/(o-a),b=-2*o*a/(o-a);else if(l===KS)x=-o/(o-a),b=-o*a/(o-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=p,u[12]=0,u[1]=0,u[5]=f,u[9]=m,u[13]=0,u[2]=0,u[6]=0,u[10]=x,u[14]=b,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,a,o,l=lc,c=!1){const u=this.elements,d=2/(n-e),f=2/(r-i),p=-(n+e)/(n-e),m=-(r+i)/(r-i);let x,b;if(c)x=1/(o-a),b=o/(o-a);else if(l===lc)x=-2/(o-a),b=-(o+a)/(o-a);else if(l===KS)x=-1/(o-a),b=-a/(o-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=0,u[12]=p,u[1]=0,u[5]=f,u[9]=0,u[13]=m,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 Mp=new dt,wl=new Vi,mPe=new dt(0,0,0),pPe=new dt(1,1,1),Ed=new dt,i_=new dt,no=new dt,IH=new Vi,UH=new gm;let kh=class hJ{constructor(e=0,n=0,r=0,i=hJ.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,a=i[0],o=i[4],l=i[8],c=i[1],u=i[5],d=i[9],f=i[2],p=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(zn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(p,u),this._z=0);break;case"YXZ":this._x=Math.asin(-zn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,m),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(zn(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-zn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(zn(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(l,m));break;case"XZY":this._z=Math.asin(-zn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,m),this._y=0);break;default:gn("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return IH.makeRotationFromQuaternion(e),this.setFromRotationMatrix(IH,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return UH.setFromEuler(this),this.setFromQuaternion(UH,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}};kh.DEFAULT_ORDER="XYZ";let fJ=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}},gPe=0;const zH=new dt,Ep=new gm,Kc=new Vi,a_=new dt,$b=new dt,xPe=new dt,bPe=new gm,BH=new dt(1,0,0),$H=new dt(0,1,0),HH=new dt(0,0,1),VH={type:"added"},yPe={type:"removed"},kp={type:"childadded",child:null},nC={type:"childremoved",child:null};let vo=class C1 extends Cm{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:gPe++}),this.uuid=hv(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=C1.DEFAULT_UP.clone();const e=new dt,n=new kh,r=new gm,i=new dt(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),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 Vi},normalMatrix:{value:new Pn}}),this.matrix=new Vi,this.matrixWorld=new Vi,this.matrixAutoUpdate=C1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=C1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new fJ,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 Ep.setFromAxisAngle(e,n),this.quaternion.multiply(Ep),this}rotateOnWorldAxis(e,n){return Ep.setFromAxisAngle(e,n),this.quaternion.premultiply(Ep),this}rotateX(e){return this.rotateOnAxis(BH,e)}rotateY(e){return this.rotateOnAxis($H,e)}rotateZ(e){return this.rotateOnAxis(HH,e)}translateOnAxis(e,n){return zH.copy(e).applyQuaternion(this.quaternion),this.position.add(zH.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(BH,e)}translateY(e){return this.translateOnAxis($H,e)}translateZ(e){return this.translateOnAxis(HH,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Kc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?a_.copy(e):a_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),$b.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Kc.lookAt($b,a_,this.up):Kc.lookAt(a_,$b,this.up),this.quaternion.setFromRotationMatrix(Kc),i&&(Kc.extractRotation(i.matrixWorld),Ep.setFromRotationMatrix(Kc),this.quaternion.premultiply(Ep.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(ki("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(VH),kp.child=e,this.dispatchEvent(kp),kp.child=null):ki("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(yPe),nC.child=e,this.dispatchEvent(nC),nC.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),Kc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Kc.multiply(e.parent.matrixWorld)),e.applyMatrix4(Kc),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(VH),kp.child=e,this.dispatchEvent(kp),kp.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 a=0,o=i.length;a<o;a++)i[a].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose($b,e,xPe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose($b,bPe,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].updateMatrixWorld(e)}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),n===!0){const i=this.children;for(let a=0,o=i.length;a<o;a++)i[a].updateWorldMatrix(!1,!0)}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(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 a(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=a(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];a(e.shapes,f)}else a(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let c=0,u=this.material.length;c<u;c++)l.push(a(e.materials,this.material[c]));i.material=l}else i.material=a(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(a(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),p=o(e.skeletons),m=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),p.length>0&&(r.skeletons=p),m.length>0&&(r.animations=m),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 dt(0,1,0);vo.DEFAULT_MATRIX_AUTO_UPDATE=!0;vo.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const _l=new dt,Xc=new dt,rC=new dt,Yc=new dt,Tp=new dt,Ap=new dt,GH=new dt,iC=new dt,aC=new dt,sC=new dt,oC=new Ui,lC=new Ui,cC=new Ui;let Hb=class og{constructor(e=new dt,n=new dt,r=new dt){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),_l.subVectors(e,n),i.cross(_l);const a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}static getBarycoord(e,n,r,i,a){_l.subVectors(i,n),Xc.subVectors(r,n),rC.subVectors(e,n);const o=_l.dot(_l),l=_l.dot(Xc),c=_l.dot(rC),u=Xc.dot(Xc),d=Xc.dot(rC),f=o*u-l*l;if(f===0)return a.set(0,0,0),null;const p=1/f,m=(u*c-l*d)*p,x=(o*d-l*c)*p;return a.set(1-m-x,x,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Yc)===null?!1:Yc.x>=0&&Yc.y>=0&&Yc.x+Yc.y<=1}static getInterpolation(e,n,r,i,a,o,l,c){return this.getBarycoord(e,n,r,i,Yc)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(a,Yc.x),c.addScaledVector(o,Yc.y),c.addScaledVector(l,Yc.z),c)}static getInterpolatedAttribute(e,n,r,i,a,o){return oC.setScalar(0),lC.setScalar(0),cC.setScalar(0),oC.fromBufferAttribute(e,n),lC.fromBufferAttribute(e,r),cC.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(oC,a.x),o.addScaledVector(lC,a.y),o.addScaledVector(cC,a.z),o}static isFrontFacing(e,n,r,i){return _l.subVectors(r,n),Xc.subVectors(e,n),_l.cross(Xc).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 _l.subVectors(this.c,this.b),Xc.subVectors(this.a,this.b),_l.cross(Xc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return og.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return og.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,a){return og.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return og.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return og.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,a=this.c;let o,l;Tp.subVectors(i,r),Ap.subVectors(a,r),iC.subVectors(e,r);const c=Tp.dot(iC),u=Ap.dot(iC);if(c<=0&&u<=0)return n.copy(r);aC.subVectors(e,i);const d=Tp.dot(aC),f=Ap.dot(aC);if(d>=0&&f<=d)return n.copy(i);const p=c*f-d*u;if(p<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(Tp,o);sC.subVectors(e,a);const m=Tp.dot(sC),x=Ap.dot(sC);if(x>=0&&m<=x)return n.copy(a);const b=m*u-c*x;if(b<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(Ap,l);const y=d*x-m*f;if(y<=0&&f-d>=0&&m-x>=0)return GH.subVectors(a,i),l=(f-d)/(f-d+(m-x)),n.copy(i).addScaledVector(GH,l);const v=1/(y+b+p);return o=b*v,l=p*v,n.copy(r).addScaledVector(Tp,o).addScaledVector(Ap,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const mJ={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},kd={h:0,s:0,l:0},s_={h:0,s:0,l:0};function uC(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 Bn=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=Vo){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,sr.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=sr.workingColorSpace){return this.r=e,this.g=n,this.b=r,sr.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=sr.workingColorSpace){if(e=aPe(e,1),n=zn(n,0,1),r=zn(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,o=2*r-a;this.r=uC(o,a,e+1/3),this.g=uC(o,a,e),this.b=uC(o,a,e-1/3)}return sr.colorSpaceToWorking(this,i),this}setStyle(e,n=Vo){function r(a){a!==void 0&&parseFloat(a)<1&&gn("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const o=i[1],l=i[2];switch(o){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:gn("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],o=a.length;if(o===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(o===6)return this.setHex(parseInt(a,16),n);gn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=Vo){const r=mJ[e.toLowerCase()];return r!==void 0?this.setHex(r,n):gn("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=Au(e.r),this.g=Au(e.g),this.b=Au(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=Vo){return sr.workingToColorSpace(Va.copy(this),e),Math.round(zn(Va.r*255,0,255))*65536+Math.round(zn(Va.g*255,0,255))*256+Math.round(zn(Va.b*255,0,255))}getHexString(e=Vo){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=sr.workingColorSpace){sr.workingToColorSpace(Va.copy(this),n);const r=Va.r,i=Va.g,a=Va.b,o=Math.max(r,i,a),l=Math.min(r,i,a);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-a)/f+(i<a?6:0);break;case i:c=(a-r)/f+2;break;case a:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=sr.workingColorSpace){return sr.workingToColorSpace(Va.copy(this),n),e.r=Va.r,e.g=Va.g,e.b=Va.b,e}getStyle(e=Vo){sr.workingToColorSpace(Va.copy(this),e);const n=Va.r,r=Va.g,i=Va.b;return e!==Vo?`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(kd),this.setHSL(kd.h+e,kd.s+n,kd.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(kd),e.getHSL(s_);const r=qA(kd.h,s_.h,n),i=qA(kd.s,s_.s,n),a=qA(kd.l,s_.l,n);return this.setHSL(r,i,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,a=e.elements;return this.r=a[0]*n+a[3]*r+a[6]*i,this.g=a[1]*n+a[4]*r+a[7]*i,this.b=a[2]*n+a[5]*r+a[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const Va=new Bn;Bn.NAMES=mJ;let vPe=0,jx=class extends Cm{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:vPe++}),this.uuid=hv(),this.name="",this.type="Material",this.blending=Ag,this.side=Eh,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=S3,this.blendDst=N3,this.blendEquation=Nf,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Bn(0,0,0),this.blendAlpha=0,this.depthFunc=Qg,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=CH,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=vp,this.stencilZFail=vp,this.stencilZPass=vp,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){gn(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){gn(`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!==Ag&&(r.blending=this.blending),this.side!==Eh&&(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!==S3&&(r.blendSrc=this.blendSrc),this.blendDst!==N3&&(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!==Qg&&(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!==CH&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==vp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==vp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==vp&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(a){const o=[];for(const l in a){const c=a[l];delete c.metadata,o.push(c)}return o}if(n){const a=i(e.textures),o=i(e.images);a.length>0&&(r.textures=a),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 a=0;a!==i;++a)r[a]=n[a].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},Z4=class extends jx{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Bn(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 kh,this.combine=$4,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 Ri=new dt,o_=new Tn;let wPe=0,nl=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:wPe++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=jH,this.updateRanges=[],this.gpuType=wu,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)o_.fromBufferAttribute(this,n),o_.applyMatrix3(e),this.setXY(n,o_.x,o_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Ri.fromBufferAttribute(this,n),Ri.applyMatrix3(e),this.setXYZ(n,Ri.x,Ri.y,Ri.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Ri.fromBufferAttribute(this,n),Ri.applyMatrix4(e),this.setXYZ(n,Ri.x,Ri.y,Ri.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Ri.fromBufferAttribute(this,n),Ri.applyNormalMatrix(e),this.setXYZ(n,Ri.x,Ri.y,Ri.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Ri.fromBufferAttribute(this,n),Ri.transformDirection(e),this.setXYZ(n,Ri.x,Ri.y,Ri.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=Ub(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Cs(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Ub(n,this.array)),n}setX(e,n){return this.normalized&&(n=Cs(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Ub(n,this.array)),n}setY(e,n){return this.normalized&&(n=Cs(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=Ub(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Cs(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=Ub(n,this.array)),n}setW(e,n){return this.normalized&&(n=Cs(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Cs(n,this.array),r=Cs(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=Cs(n,this.array),r=Cs(r,this.array),i=Cs(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e*=this.itemSize,this.normalized&&(n=Cs(n,this.array),r=Cs(r,this.array),i=Cs(i,this.array),a=Cs(a,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==jH&&(e.usage=this.usage),e}},pJ=class extends nl{constructor(e,n,r){super(new Uint16Array(e),n,r)}},gJ=class extends nl{constructor(e,n,r){super(new Uint32Array(e),n,r)}},Ll=class extends nl{constructor(e,n,r){super(new Float32Array(e),n,r)}},_Pe=0;const Lo=new Vi,dC=new vo,Cp=new dt,ro=new bm,Vb=new bm,da=new dt;let Ac=class xJ extends Cm{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:_Pe++}),this.uuid=hv(),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(sJ(e)?gJ:pJ)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const a=new Pn().getNormalMatrix(e);r.applyNormalMatrix(a),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Lo.makeRotationFromQuaternion(e),this.applyMatrix4(Lo),this}rotateX(e){return Lo.makeRotationX(e),this.applyMatrix4(Lo),this}rotateY(e){return Lo.makeRotationY(e),this.applyMatrix4(Lo),this}rotateZ(e){return Lo.makeRotationZ(e),this.applyMatrix4(Lo),this}translate(e,n,r){return Lo.makeTranslation(e,n,r),this.applyMatrix4(Lo),this}scale(e,n,r){return Lo.makeScale(e,n,r),this.applyMatrix4(Lo),this}lookAt(e){return dC.lookAt(e),dC.updateMatrix(),this.applyMatrix4(dC.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Cp).negate(),this.translate(Cp.x,Cp.y,Cp.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const r=[];for(let i=0,a=e.length;i<a;i++){const o=e[i];r.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Ll(r,3))}else{const r=Math.min(e.length,n.count);for(let i=0;i<r;i++){const a=e[i];n.setXYZ(i,a.x,a.y,a.z||0)}e.length>n.count&&gn("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 bm);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ki("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new dt(-1/0,-1/0,-1/0),new dt(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];ro.setFromBufferAttribute(a),this.morphTargetsRelative?(da.addVectors(this.boundingBox.min,ro.min),this.boundingBox.expandByPoint(da),da.addVectors(this.boundingBox.max,ro.max),this.boundingBox.expandByPoint(da)):(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))&&ki('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 mM);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ki("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new dt,1/0);return}if(e){const r=this.boundingSphere.center;if(ro.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];Vb.setFromBufferAttribute(l),this.morphTargetsRelative?(da.addVectors(ro.min,Vb.min),ro.expandByPoint(da),da.addVectors(ro.max,Vb.max),ro.expandByPoint(da)):(ro.expandByPoint(Vb.min),ro.expandByPoint(Vb.max))}ro.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)da.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(da));if(n)for(let a=0,o=n.length;a<o;a++){const l=n[a],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)da.fromBufferAttribute(l,u),c&&(Cp.fromBufferAttribute(e,u),da.add(Cp)),i=Math.max(i,r.distanceToSquared(da))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&ki('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){ki("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=n.position,i=n.normal,a=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new nl(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),l=[],c=[];for(let R=0;R<r.count;R++)l[R]=new dt,c[R]=new dt;const u=new dt,d=new dt,f=new dt,p=new Tn,m=new Tn,x=new Tn,b=new dt,y=new dt;function v(R,A,D){u.fromBufferAttribute(r,R),d.fromBufferAttribute(r,A),f.fromBufferAttribute(r,D),p.fromBufferAttribute(a,R),m.fromBufferAttribute(a,A),x.fromBufferAttribute(a,D),d.sub(u),f.sub(u),m.sub(p),x.sub(p);const U=1/(m.x*x.y-x.x*m.y);isFinite(U)&&(b.copy(d).multiplyScalar(x.y).addScaledVector(f,-m.y).multiplyScalar(U),y.copy(f).multiplyScalar(m.x).addScaledVector(d,-x.x).multiplyScalar(U),l[R].add(b),l[A].add(b),l[D].add(b),c[R].add(y),c[A].add(y),c[D].add(y))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let R=0,A=S.length;R<A;++R){const D=S[R],U=D.start,F=D.count;for(let H=U,j=U+F;H<j;H+=3)v(e.getX(H+0),e.getX(H+1),e.getX(H+2))}const M=new dt,T=new dt,E=new dt,C=new dt;function k(R){E.fromBufferAttribute(i,R),C.copy(E);const A=l[R];M.copy(A),M.sub(E.multiplyScalar(E.dot(A))).normalize(),T.crossVectors(C,A);const U=T.dot(c[R])<0?-1:1;o.setXYZW(R,M.x,M.y,M.z,U)}for(let R=0,A=S.length;R<A;++R){const D=S[R],U=D.start,F=D.count;for(let H=U,j=U+F;H<j;H+=3)k(e.getX(H+0)),k(e.getX(H+1)),k(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 nl(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let p=0,m=r.count;p<m;p++)r.setXYZ(p,0,0,0);const i=new dt,a=new dt,o=new dt,l=new dt,c=new dt,u=new dt,d=new dt,f=new dt;if(e)for(let p=0,m=e.count;p<m;p+=3){const x=e.getX(p+0),b=e.getX(p+1),y=e.getX(p+2);i.fromBufferAttribute(n,x),a.fromBufferAttribute(n,b),o.fromBufferAttribute(n,y),d.subVectors(o,a),f.subVectors(i,a),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 p=0,m=n.count;p<m;p+=3)i.fromBufferAttribute(n,p+0),a.fromBufferAttribute(n,p+1),o.fromBufferAttribute(n,p+2),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),r.setXYZ(p+0,d.x,d.y,d.z),r.setXYZ(p+1,d.x,d.y,d.z),r.setXYZ(p+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++)da.fromBufferAttribute(e,n),da.normalize(),e.setXYZ(n,da.x,da.y,da.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,p=new u.constructor(c.length*d);let m=0,x=0;for(let b=0,y=c.length;b<y;b++){l.isInterleavedBufferAttribute?m=c[b]*l.data.stride+l.offset:m=c[b]*d;for(let v=0;v<d;v++)p[x++]=u[m++]}return new nl(p,d,f)}if(this.index===null)return gn("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new xJ,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 a=this.morphAttributes;for(const l in a){const c=[],u=a[l];for(let d=0,f=u.length;d<f;d++){const p=u[d],m=e(p,r);c.push(m)}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 a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,p=u.length;f<p;f++){const m=u[f];d.push(m.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const 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 a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let p=0,m=f.length;p<m;p++)d.push(f[p].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 qH=new Vi,cf=new Q4,l_=new mM,WH=new dt,c_=new dt,u_=new dt,d_=new dt,hC=new dt,h_=new dt,KH=new dt,f_=new dt;let vc=class extends vo{constructor(e=new Ac,n=new Z4){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,o=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(a&&l){h_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(hC.fromBufferAttribute(f,e),o?h_.addScaledVector(hC,d):h_.addScaledVector(hC.sub(n),d))}n.add(h_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),l_.copy(r.boundingSphere),l_.applyMatrix4(a),cf.copy(e.ray).recast(e.near),!(l_.containsPoint(cf.origin)===!1&&(cf.intersectSphere(l_,WH)===null||cf.origin.distanceToSquared(WH)>(e.far-e.near)**2))&&(qH.copy(a).invert(),cf.copy(e.ray).applyMatrix4(qH),!(r.boundingBox!==null&&cf.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,cf)))}_computeIntersections(e,n,r){let i;const a=this.geometry,o=this.material,l=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,p=a.groups,m=a.drawRange;if(l!==null)if(Array.isArray(o))for(let x=0,b=p.length;x<b;x++){const y=p[x],v=o[y.materialIndex],S=Math.max(y.start,m.start),M=Math.min(l.count,Math.min(y.start+y.count,m.start+m.count));for(let T=S,E=M;T<E;T+=3){const C=l.getX(T),k=l.getX(T+1),R=l.getX(T+2);i=m_(this,v,e,r,u,d,f,C,k,R),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),b=Math.min(l.count,m.start+m.count);for(let y=x,v=b;y<v;y+=3){const S=l.getX(y),M=l.getX(y+1),T=l.getX(y+2);i=m_(this,o,e,r,u,d,f,S,M,T),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,b=p.length;x<b;x++){const y=p[x],v=o[y.materialIndex],S=Math.max(y.start,m.start),M=Math.min(c.count,Math.min(y.start+y.count,m.start+m.count));for(let T=S,E=M;T<E;T+=3){const C=T,k=T+1,R=T+2;i=m_(this,v,e,r,u,d,f,C,k,R),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),b=Math.min(c.count,m.start+m.count);for(let y=x,v=b;y<v;y+=3){const S=y,M=y+1,T=y+2;i=m_(this,o,e,r,u,d,f,S,M,T),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}}};function SPe(t,e,n,r,i,a,o,l){let c;if(e.side===Us?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===Eh,l),c===null)return null;f_.copy(l),f_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(f_);return u<n.near||u>n.far?null:{distance:u,point:f_.clone(),object:t}}function m_(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,c_),t.getVertexPosition(c,u_),t.getVertexPosition(u,d_);const d=SPe(t,e,n,r,c_,u_,d_,KH);if(d){const f=new dt;Hb.getBarycoord(KH,c_,u_,d_,f),i&&(d.uv=Hb.getInterpolatedAttribute(i,l,c,u,f,new Tn)),a&&(d.uv1=Hb.getInterpolatedAttribute(a,l,c,u,f,new Tn)),o&&(d.normal=Hb.getInterpolatedAttribute(o,l,c,u,f,new dt),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const p={a:l,b:c,c:u,normal:new dt,materialIndex:0};Hb.getNormal(c_,u_,d_,p.normal),d.face=p,d.barycoord=f}return d}let J4=class bJ extends Ac{constructor(e=1,n=1,r=1,i=1,a=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:o};const l=this;i=Math.floor(i),a=Math.floor(a),o=Math.floor(o);const c=[],u=[],d=[],f=[];let p=0,m=0;x("z","y","x",-1,-1,r,n,e,o,a,0),x("z","y","x",1,-1,r,n,-e,o,a,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,a,4),x("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new Ll(u,3)),this.setAttribute("normal",new Ll(d,3)),this.setAttribute("uv",new Ll(f,2));function x(b,y,v,S,M,T,E,C,k,R,A){const D=T/k,U=E/R,F=T/2,H=E/2,j=C/2,$=k+1,K=R+1;let V=0,Q=0;const Z=new dt;for(let ae=0;ae<K;ae++){const B=ae*U-H;for(let X=0;X<$;X++){const ne=X*D-F;Z[b]=ne*S,Z[y]=B*M,Z[v]=j,u.push(Z.x,Z.y,Z.z),Z[b]=0,Z[y]=0,Z[v]=C>0?1:-1,d.push(Z.x,Z.y,Z.z),f.push(X/k),f.push(1-ae/R),V+=1}}for(let ae=0;ae<R;ae++)for(let B=0;B<k;B++){const X=p+B+$*ae,ne=p+B+$*(ae+1),se=p+(B+1)+$*(ae+1),be=p+(B+1)+$*ae;c.push(X,ne,be),c.push(ne,se,be),Q+=6}l.addGroup(m,Q,A),m+=Q,p+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new bJ(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function tx(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?(gn("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 cs(t){const e={};for(let n=0;n<t.length;n++){const r=tx(t[n]);for(const i in r)e[i]=r[i]}return e}function NPe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function yJ(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:sr.workingColorSpace}const MPe={clone:tx,merge:cs};var EPe=`void main() {
  91. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  92. }`,kPe=`void main() {
  93. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  94. }`;let Hu=class extends jx{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=EPe,this.fragmentShader=kPe,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=tx(e.uniforms),this.uniformsGroups=NPe(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}},vJ=class extends vo{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Vi,this.projectionMatrix=new Vi,this.projectionMatrixInverse=new Vi,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 Td=new dt,XH=new Tn,YH=new Tn;let Wo=class extends vJ{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=uD*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(T1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return uD*2*Math.atan(Math.tan(T1*.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){Td.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Td.x,Td.y).multiplyScalar(-e/Td.z),Td.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(Td.x,Td.y).multiplyScalar(-e/Td.z)}getViewSize(e,n){return this.getViewBounds(e,XH,YH),n.subVectors(YH,XH)}setViewOffset(e,n,r,i,a,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=a,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(T1*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,a=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,u=o.fullHeight;a+=o.offsetX*i/c,n-=o.offsetY*r/u,i*=o.width/c,r*=o.height/u}const l=this.filmOffset;l!==0&&(a+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,n,n-r,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}};const jp=-90,Pp=1;let TPe=class extends vo{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Wo(jp,Pp,e,n);i.layers=this.layers,this.add(i);const a=new Wo(jp,Pp,e,n);a.layers=this.layers,this.add(a);const o=new Wo(jp,Pp,e,n);o.layers=this.layers,this.add(o);const l=new Wo(jp,Pp,e,n);l.layers=this.layers,this.add(l);const c=new Wo(jp,Pp,e,n);c.layers=this.layers,this.add(c);const u=new Wo(jp,Pp,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,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),a.up.set(0,0,-1),a.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===KS)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),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[a,o,l,c,u,d]=this.children,f=e.getRenderTarget(),p=e.getActiveCubeFace(),m=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,a),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,p,m),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}},wJ=class extends $l{constructor(e=[],n=Zg,r,i,a,o,l,c,u,d){super(e,n,r,i,a,o,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},APe=class extends xm{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 wJ(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:`
  95. varying vec3 vWorldDirection;
  96. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  97. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  98. }
  99. void main() {
  100. vWorldDirection = transformDirection( position, modelMatrix );
  101. #include <begin_vertex>
  102. #include <project_vertex>
  103. }
  104. `,fragmentShader:`
  105. uniform sampler2D tEquirect;
  106. varying vec3 vWorldDirection;
  107. #include <common>
  108. void main() {
  109. vec3 direction = normalize( vWorldDirection );
  110. vec2 sampleUV = equirectUv( direction );
  111. gl_FragColor = texture2D( tEquirect, sampleUV );
  112. }
  113. `},i=new J4(5,5,5),a=new Hu({name:"CubemapFromEquirect",uniforms:tx(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Us,blending:Tu});a.uniforms.tEquirect.value=n;const o=new vc(i,a),l=n.minFilter;return n.minFilter===Of&&(n.minFilter=el),new TPe(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 a=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(n,r,i);e.setRenderTarget(a)}},o0=class extends vo{constructor(){super(),this.isGroup=!0,this.type="Group"}};const CPe={type:"move"};let fC=class{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 dt,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new dt),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 dt,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new dt),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,a=null,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"],p=d.position.distanceTo(f.position),m=.02,x=.005;u.inputState.pinching&&p>m+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&p<=m-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),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(CPe)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=a!==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]}},jPe=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 kh,this.environmentIntensity=1,this.environmentRotation=new kh,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}},PPe=class extends $l{constructor(e=null,n=1,r=1,i,a,o,l,c,u=po,d=po,f,p){super(null,o,l,c,u,d,i,a,f,p),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const mC=new dt,DPe=new dt,RPe=new Pn;let Bd=class{constructor(e=new dt(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=mC.subVectors(r,n).cross(DPe.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(mC),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/i;return a<0||a>1?null:n.copy(e.start).addScaledVector(r,a)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||RPe.getNormalMatrix(e),i=this.coplanarPoint(mC).applyMatrix4(e),a=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};const uf=new mM,OPe=new Tn(.5,.5),p_=new dt;let eL=class{constructor(e=new Bd,n=new Bd,r=new Bd,i=new Bd,a=new Bd,o=new Bd){this.planes=[e,n,r,i,a,o]}set(e,n,r,i,a,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(a),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,a=e.elements,o=a[0],l=a[1],c=a[2],u=a[3],d=a[4],f=a[5],p=a[6],m=a[7],x=a[8],b=a[9],y=a[10],v=a[11],S=a[12],M=a[13],T=a[14],E=a[15];if(i[0].setComponents(u-o,m-d,v-x,E-S).normalize(),i[1].setComponents(u+o,m+d,v+x,E+S).normalize(),i[2].setComponents(u+l,m+f,v+b,E+M).normalize(),i[3].setComponents(u-l,m-f,v-b,E-M).normalize(),r)i[4].setComponents(c,p,y,T).normalize(),i[5].setComponents(u-c,m-p,v-y,E-T).normalize();else if(i[4].setComponents(u-c,m-p,v-y,E-T).normalize(),n===lc)i[5].setComponents(u+c,m+p,v+y,E+T).normalize();else if(n===KS)i[5].setComponents(c,p,y,T).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=OPe.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 a=0;a<6;a++)if(n[a].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(p_.x=i.normal.x>0?e.max.x:e.min.x,p_.y=i.normal.y>0?e.max.y:e.min.y,p_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(p_)<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)}},_J=class extends jx{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Bn(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 YS=new dt,QS=new dt,QH=new Vi,Gb=new Q4,g_=new mM,pC=new dt,ZH=new dt;let LPe=class extends vo{constructor(e=new Ac,n=new _J){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,a=n.count;i<a;i++)YS.fromBufferAttribute(n,i-1),QS.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=YS.distanceTo(QS);e.setAttribute("lineDistance",new Ll(r,1))}else gn("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,a=e.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),g_.copy(r.boundingSphere),g_.applyMatrix4(i),g_.radius+=a,e.ray.intersectsSphere(g_)===!1)return;QH.copy(i).invert(),Gb.copy(e.ray).applyMatrix4(QH);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=this.isLineSegments?2:1,d=r.index,p=r.attributes.position;if(d!==null){const m=Math.max(0,o.start),x=Math.min(d.count,o.start+o.count);for(let b=m,y=x-1;b<y;b+=u){const v=d.getX(b),S=d.getX(b+1),M=x_(this,e,Gb,c,v,S,b);M&&n.push(M)}if(this.isLineLoop){const b=d.getX(x-1),y=d.getX(m),v=x_(this,e,Gb,c,b,y,x-1);v&&n.push(v)}}else{const m=Math.max(0,o.start),x=Math.min(p.count,o.start+o.count);for(let b=m,y=x-1;b<y;b+=u){const v=x_(this,e,Gb,c,b,b+1,b);v&&n.push(v)}if(this.isLineLoop){const b=x_(this,e,Gb,c,x-1,m,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 a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}};function x_(t,e,n,r,i,a,o){const l=t.geometry.attributes.position;if(YS.fromBufferAttribute(l,i),QS.fromBufferAttribute(l,a),n.distanceSqToSegment(YS,QS,pC,ZH)>r)return;pC.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(pC);if(!(u<e.near||u>e.far))return{distance:u,point:ZH.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const JH=new dt,eV=new dt;let FPe=class extends LPe{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,a=n.count;i<a;i+=2)JH.fromBufferAttribute(n,i),eV.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+JH.distanceTo(eV);e.setAttribute("lineDistance",new Ll(r,1))}else gn("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},SJ=class extends $l{constructor(e,n,r=pm,i,a,o,l=po,c=po,u,d=fy,f=1){if(d!==fy&&d!==my)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const p={width:e,height:n,depth:f};super(p,i,a,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 Y4(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 NJ extends $l{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let tL=class MJ extends Ac{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const a=e/2,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,p=n/c,m=[],x=[],b=[],y=[];for(let v=0;v<d;v++){const S=v*p-o;for(let M=0;M<u;M++){const T=M*f-a;x.push(T,-S,0),b.push(0,0,1),y.push(M/l),y.push(1-v/c)}}for(let v=0;v<c;v++)for(let S=0;S<l;S++){const M=S+u*v,T=S+u*(v+1),E=S+1+u*(v+1),C=S+1+u*v;m.push(M,T,C),m.push(T,E,C)}this.setIndex(m),this.setAttribute("position",new Ll(x,3)),this.setAttribute("normal",new Ll(b,3)),this.setAttribute("uv",new Ll(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new MJ(e.width,e.height,e.widthSegments,e.heightSegments)}};class IPe extends jx{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Bn(16777215),this.specular=new Bn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Bn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=iJ,this.normalScale=new Tn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new kh,this.combine=$4,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 UPe=class extends jx{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Wje,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}},zPe=class extends jx{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}},EJ=class extends vo{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Bn(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 gC=new Vi,tV=new dt,nV=new dt;let BPe=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Tn(512,512),this.mapType=yc,this.map=null,this.mapPass=null,this.matrix=new Vi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new eL,this._frameExtents=new Tn(1,1),this._viewportCount=1,this._viewports=[new Ui(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;tV.setFromMatrixPosition(e.matrixWorld),n.position.copy(tV),nV.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(nV),n.updateMatrixWorld(),gC.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(gC,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(gC)}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}},kJ=class extends vJ{constructor(e=-1,n=1,r=1,i=-1,a=.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=a,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,a,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=a,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 a=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;a+=u*this.view.offsetX,o=a+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(a,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 $Pe extends BPe{constructor(){super(new kJ(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class rV extends EJ{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 $Pe}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let HPe=class extends EJ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},VPe=class extends Wo{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},iV=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=zn(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(zn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class GPe extends FPe{constructor(e=10,n=10,r=4473924,i=8947848){r=new Bn(r),i=new Bn(i);const a=n/2,o=e/n,l=e/2,c=[],u=[];for(let p=0,m=0,x=-l;p<=n;p++,x+=o){c.push(-l,0,x,l,0,x),c.push(x,0,-l,x,0,l);const b=p===a?r:i;b.toArray(u,m),m+=3,b.toArray(u,m),m+=3,b.toArray(u,m),m+=3,b.toArray(u,m),m+=3}const d=new Ac;d.setAttribute("position",new Ll(c,3)),d.setAttribute("color",new Ll(u,3));const f=new _J({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class qPe extends Cm{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){gn("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function aV(t,e,n,r){const i=WPe(r);switch(n){case tJ:return t*e;case rJ:return t*e/i.components*i.byteLength;case q4:return t*e/i.components*i.byteLength;case W4:return t*e*2/i.components*i.byteLength;case K4:return t*e*2/i.components*i.byteLength;case nJ:return t*e*3/i.components*i.byteLength;case Pl:return t*e*4/i.components*i.byteLength;case X4:return t*e*4/i.components*i.byteLength;case N1:case M1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case E1:case k1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case F3:case U3:return Math.max(t,16)*Math.max(e,8)/4;case L3:case I3:return Math.max(t,8)*Math.max(e,8)/2;case z3:case B3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case $3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case H3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case V3:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case G3:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case q3:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case W3:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case K3:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case X3:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case Y3:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case Q3:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case Z3:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case J3:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case eD:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case tD:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case nD:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case rD:case iD:case aD:return Math.ceil(t/4)*Math.ceil(e/4)*16;case sD:case oD:return Math.ceil(t/4)*Math.ceil(e/4)*8;case lD:case cD:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function WPe(t){switch(t){case yc:case QZ:return{byteLength:1,components:1};case dy:case ZZ:case Cx:return{byteLength:2,components:1};case V4:case G4:return{byteLength:2,components:4};case pm:case H4:case wu:return{byteLength:4,components:1};case JZ:case eJ:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:B4}}));typeof window<"u"&&(window.__THREE__?gn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=B4);function TJ(){let t=null,e=!1,n=null,r=null;function i(a,o){n(a,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(a){n=a},setContext:function(a){t=a}}}function KPe(t){const e=new WeakMap;function n(l,c){const u=l.array,d=l.usage,f=u.byteLength,p=t.createBuffer();t.bindBuffer(c,p),t.bufferData(c,u,d),l.onUploadCallback();let m;if(u instanceof Float32Array)m=t.FLOAT;else if(typeof Float16Array<"u"&&u instanceof Float16Array)m=t.HALF_FLOAT;else if(u instanceof Uint16Array)l.isFloat16BufferAttribute?m=t.HALF_FLOAT:m=t.UNSIGNED_SHORT;else if(u instanceof Int16Array)m=t.SHORT;else if(u instanceof Uint32Array)m=t.UNSIGNED_INT;else if(u instanceof Int32Array)m=t.INT;else if(u instanceof Int8Array)m=t.BYTE;else if(u instanceof Uint8Array)m=t.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)m=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:p,type:m,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((m,x)=>m.start-x.start);let p=0;for(let m=1;m<f.length;m++){const x=f[p],b=f[m];b.start<=x.start+x.count+1?x.count=Math.max(x.count,b.start+b.count-x.start):(++p,f[p]=b)}f.length=p+1;for(let m=0,x=f.length;m<x;m++){const b=f[m];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 a(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:a,update:o}}var XPe=`#ifdef USE_ALPHAHASH
  114. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  115. #endif`,YPe=`#ifdef USE_ALPHAHASH
  116. const float ALPHA_HASH_SCALE = 0.05;
  117. float hash2D( vec2 value ) {
  118. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  119. }
  120. float hash3D( vec3 value ) {
  121. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  122. }
  123. float getAlphaHashThreshold( vec3 position ) {
  124. float maxDeriv = max(
  125. length( dFdx( position.xyz ) ),
  126. length( dFdy( position.xyz ) )
  127. );
  128. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  129. vec2 pixScales = vec2(
  130. exp2( floor( log2( pixScale ) ) ),
  131. exp2( ceil( log2( pixScale ) ) )
  132. );
  133. vec2 alpha = vec2(
  134. hash3D( floor( pixScales.x * position.xyz ) ),
  135. hash3D( floor( pixScales.y * position.xyz ) )
  136. );
  137. float lerpFactor = fract( log2( pixScale ) );
  138. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  139. float a = min( lerpFactor, 1.0 - lerpFactor );
  140. vec3 cases = vec3(
  141. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  142. ( x - 0.5 * a ) / ( 1.0 - a ),
  143. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  144. );
  145. float threshold = ( x < ( 1.0 - a ) )
  146. ? ( ( x < a ) ? cases.x : cases.y )
  147. : cases.z;
  148. return clamp( threshold , 1.0e-6, 1.0 );
  149. }
  150. #endif`,QPe=`#ifdef USE_ALPHAMAP
  151. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  152. #endif`,ZPe=`#ifdef USE_ALPHAMAP
  153. uniform sampler2D alphaMap;
  154. #endif`,JPe=`#ifdef USE_ALPHATEST
  155. #ifdef ALPHA_TO_COVERAGE
  156. diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
  157. if ( diffuseColor.a == 0.0 ) discard;
  158. #else
  159. if ( diffuseColor.a < alphaTest ) discard;
  160. #endif
  161. #endif`,e3e=`#ifdef USE_ALPHATEST
  162. uniform float alphaTest;
  163. #endif`,t3e=`#ifdef USE_AOMAP
  164. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  165. reflectedLight.indirectDiffuse *= ambientOcclusion;
  166. #if defined( USE_CLEARCOAT )
  167. clearcoatSpecularIndirect *= ambientOcclusion;
  168. #endif
  169. #if defined( USE_SHEEN )
  170. sheenSpecularIndirect *= ambientOcclusion;
  171. #endif
  172. #if defined( USE_ENVMAP ) && defined( STANDARD )
  173. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  174. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  175. #endif
  176. #endif`,n3e=`#ifdef USE_AOMAP
  177. uniform sampler2D aoMap;
  178. uniform float aoMapIntensity;
  179. #endif`,r3e=`#ifdef USE_BATCHING
  180. #if ! defined( GL_ANGLE_multi_draw )
  181. #define gl_DrawID _gl_DrawID
  182. uniform int _gl_DrawID;
  183. #endif
  184. uniform highp sampler2D batchingTexture;
  185. uniform highp usampler2D batchingIdTexture;
  186. mat4 getBatchingMatrix( const in float i ) {
  187. int size = textureSize( batchingTexture, 0 ).x;
  188. int j = int( i ) * 4;
  189. int x = j % size;
  190. int y = j / size;
  191. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  192. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  193. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  194. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  195. return mat4( v1, v2, v3, v4 );
  196. }
  197. float getIndirectIndex( const in int i ) {
  198. int size = textureSize( batchingIdTexture, 0 ).x;
  199. int x = i % size;
  200. int y = i / size;
  201. return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
  202. }
  203. #endif
  204. #ifdef USE_BATCHING_COLOR
  205. uniform sampler2D batchingColorTexture;
  206. vec3 getBatchingColor( const in float i ) {
  207. int size = textureSize( batchingColorTexture, 0 ).x;
  208. int j = int( i );
  209. int x = j % size;
  210. int y = j / size;
  211. return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
  212. }
  213. #endif`,i3e=`#ifdef USE_BATCHING
  214. mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
  215. #endif`,a3e=`vec3 transformed = vec3( position );
  216. #ifdef USE_ALPHAHASH
  217. vPosition = vec3( position );
  218. #endif`,s3e=`vec3 objectNormal = vec3( normal );
  219. #ifdef USE_TANGENT
  220. vec3 objectTangent = vec3( tangent.xyz );
  221. #endif`,o3e=`float G_BlinnPhong_Implicit( ) {
  222. return 0.25;
  223. }
  224. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  225. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  226. }
  227. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  228. vec3 halfDir = normalize( lightDir + viewDir );
  229. float dotNH = saturate( dot( normal, halfDir ) );
  230. float dotVH = saturate( dot( viewDir, halfDir ) );
  231. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  232. float G = G_BlinnPhong_Implicit( );
  233. float D = D_BlinnPhong( shininess, dotNH );
  234. return F * ( G * D );
  235. } // validated`,l3e=`#ifdef USE_IRIDESCENCE
  236. const mat3 XYZ_TO_REC709 = mat3(
  237. 3.2404542, -0.9692660, 0.0556434,
  238. -1.5371385, 1.8760108, -0.2040259,
  239. -0.4985314, 0.0415560, 1.0572252
  240. );
  241. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  242. vec3 sqrtF0 = sqrt( fresnel0 );
  243. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  244. }
  245. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  246. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  247. }
  248. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  249. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  250. }
  251. vec3 evalSensitivity( float OPD, vec3 shift ) {
  252. float phase = 2.0 * PI * OPD * 1.0e-9;
  253. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  254. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  255. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  256. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  257. 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 ) );
  258. xyz /= 1.0685e-7;
  259. vec3 rgb = XYZ_TO_REC709 * xyz;
  260. return rgb;
  261. }
  262. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  263. vec3 I;
  264. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  265. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  266. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  267. if ( cosTheta2Sq < 0.0 ) {
  268. return vec3( 1.0 );
  269. }
  270. float cosTheta2 = sqrt( cosTheta2Sq );
  271. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  272. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  273. float T121 = 1.0 - R12;
  274. float phi12 = 0.0;
  275. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  276. float phi21 = PI - phi12;
  277. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  278. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  279. vec3 phi23 = vec3( 0.0 );
  280. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  281. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  282. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  283. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  284. vec3 phi = vec3( phi21 ) + phi23;
  285. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  286. vec3 r123 = sqrt( R123 );
  287. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  288. vec3 C0 = R12 + Rs;
  289. I = C0;
  290. vec3 Cm = Rs - T121;
  291. for ( int m = 1; m <= 2; ++ m ) {
  292. Cm *= r123;
  293. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  294. I += Cm * Sm;
  295. }
  296. return max( I, vec3( 0.0 ) );
  297. }
  298. #endif`,c3e=`#ifdef USE_BUMPMAP
  299. uniform sampler2D bumpMap;
  300. uniform float bumpScale;
  301. vec2 dHdxy_fwd() {
  302. vec2 dSTdx = dFdx( vBumpMapUv );
  303. vec2 dSTdy = dFdy( vBumpMapUv );
  304. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  305. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  306. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  307. return vec2( dBx, dBy );
  308. }
  309. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  310. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  311. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  312. vec3 vN = surf_norm;
  313. vec3 R1 = cross( vSigmaY, vN );
  314. vec3 R2 = cross( vN, vSigmaX );
  315. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  316. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  317. return normalize( abs( fDet ) * surf_norm - vGrad );
  318. }
  319. #endif`,u3e=`#if NUM_CLIPPING_PLANES > 0
  320. vec4 plane;
  321. #ifdef ALPHA_TO_COVERAGE
  322. float distanceToPlane, distanceGradient;
  323. float clipOpacity = 1.0;
  324. #pragma unroll_loop_start
  325. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  326. plane = clippingPlanes[ i ];
  327. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  328. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  329. clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  330. if ( clipOpacity == 0.0 ) discard;
  331. }
  332. #pragma unroll_loop_end
  333. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  334. float unionClipOpacity = 1.0;
  335. #pragma unroll_loop_start
  336. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  337. plane = clippingPlanes[ i ];
  338. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  339. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  340. unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  341. }
  342. #pragma unroll_loop_end
  343. clipOpacity *= 1.0 - unionClipOpacity;
  344. #endif
  345. diffuseColor.a *= clipOpacity;
  346. if ( diffuseColor.a == 0.0 ) discard;
  347. #else
  348. #pragma unroll_loop_start
  349. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  350. plane = clippingPlanes[ i ];
  351. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  352. }
  353. #pragma unroll_loop_end
  354. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  355. bool clipped = true;
  356. #pragma unroll_loop_start
  357. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  358. plane = clippingPlanes[ i ];
  359. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  360. }
  361. #pragma unroll_loop_end
  362. if ( clipped ) discard;
  363. #endif
  364. #endif
  365. #endif`,d3e=`#if NUM_CLIPPING_PLANES > 0
  366. varying vec3 vClipPosition;
  367. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  368. #endif`,h3e=`#if NUM_CLIPPING_PLANES > 0
  369. varying vec3 vClipPosition;
  370. #endif`,f3e=`#if NUM_CLIPPING_PLANES > 0
  371. vClipPosition = - mvPosition.xyz;
  372. #endif`,m3e=`#if defined( USE_COLOR_ALPHA )
  373. diffuseColor *= vColor;
  374. #elif defined( USE_COLOR )
  375. diffuseColor.rgb *= vColor;
  376. #endif`,p3e=`#if defined( USE_COLOR_ALPHA )
  377. varying vec4 vColor;
  378. #elif defined( USE_COLOR )
  379. varying vec3 vColor;
  380. #endif`,g3e=`#if defined( USE_COLOR_ALPHA )
  381. varying vec4 vColor;
  382. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  383. varying vec3 vColor;
  384. #endif`,x3e=`#if defined( USE_COLOR_ALPHA )
  385. vColor = vec4( 1.0 );
  386. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  387. vColor = vec3( 1.0 );
  388. #endif
  389. #ifdef USE_COLOR
  390. vColor *= color;
  391. #endif
  392. #ifdef USE_INSTANCING_COLOR
  393. vColor.xyz *= instanceColor.xyz;
  394. #endif
  395. #ifdef USE_BATCHING_COLOR
  396. vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
  397. vColor.xyz *= batchingColor.xyz;
  398. #endif`,b3e=`#define PI 3.141592653589793
  399. #define PI2 6.283185307179586
  400. #define PI_HALF 1.5707963267948966
  401. #define RECIPROCAL_PI 0.3183098861837907
  402. #define RECIPROCAL_PI2 0.15915494309189535
  403. #define EPSILON 1e-6
  404. #ifndef saturate
  405. #define saturate( a ) clamp( a, 0.0, 1.0 )
  406. #endif
  407. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  408. float pow2( const in float x ) { return x*x; }
  409. vec3 pow2( const in vec3 x ) { return x*x; }
  410. float pow3( const in float x ) { return x*x*x; }
  411. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  412. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  413. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  414. highp float rand( const in vec2 uv ) {
  415. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  416. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  417. return fract( sin( sn ) * c );
  418. }
  419. #ifdef HIGH_PRECISION
  420. float precisionSafeLength( vec3 v ) { return length( v ); }
  421. #else
  422. float precisionSafeLength( vec3 v ) {
  423. float maxComponent = max3( abs( v ) );
  424. return length( v / maxComponent ) * maxComponent;
  425. }
  426. #endif
  427. struct IncidentLight {
  428. vec3 color;
  429. vec3 direction;
  430. bool visible;
  431. };
  432. struct ReflectedLight {
  433. vec3 directDiffuse;
  434. vec3 directSpecular;
  435. vec3 indirectDiffuse;
  436. vec3 indirectSpecular;
  437. };
  438. #ifdef USE_ALPHAHASH
  439. varying vec3 vPosition;
  440. #endif
  441. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  442. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  443. }
  444. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  445. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  446. }
  447. bool isPerspectiveMatrix( mat4 m ) {
  448. return m[ 2 ][ 3 ] == - 1.0;
  449. }
  450. vec2 equirectUv( in vec3 dir ) {
  451. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  452. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  453. return vec2( u, v );
  454. }
  455. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  456. return RECIPROCAL_PI * diffuseColor;
  457. }
  458. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  459. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  460. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  461. }
  462. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  463. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  464. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  465. } // validated`,y3e=`#ifdef ENVMAP_TYPE_CUBE_UV
  466. #define cubeUV_minMipLevel 4.0
  467. #define cubeUV_minTileSize 16.0
  468. float getFace( vec3 direction ) {
  469. vec3 absDirection = abs( direction );
  470. float face = - 1.0;
  471. if ( absDirection.x > absDirection.z ) {
  472. if ( absDirection.x > absDirection.y )
  473. face = direction.x > 0.0 ? 0.0 : 3.0;
  474. else
  475. face = direction.y > 0.0 ? 1.0 : 4.0;
  476. } else {
  477. if ( absDirection.z > absDirection.y )
  478. face = direction.z > 0.0 ? 2.0 : 5.0;
  479. else
  480. face = direction.y > 0.0 ? 1.0 : 4.0;
  481. }
  482. return face;
  483. }
  484. vec2 getUV( vec3 direction, float face ) {
  485. vec2 uv;
  486. if ( face == 0.0 ) {
  487. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  488. } else if ( face == 1.0 ) {
  489. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  490. } else if ( face == 2.0 ) {
  491. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  492. } else if ( face == 3.0 ) {
  493. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  494. } else if ( face == 4.0 ) {
  495. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  496. } else {
  497. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  498. }
  499. return 0.5 * ( uv + 1.0 );
  500. }
  501. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  502. float face = getFace( direction );
  503. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  504. mipInt = max( mipInt, cubeUV_minMipLevel );
  505. float faceSize = exp2( mipInt );
  506. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  507. if ( face > 2.0 ) {
  508. uv.y += faceSize;
  509. face -= 3.0;
  510. }
  511. uv.x += face * faceSize;
  512. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  513. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  514. uv.x *= CUBEUV_TEXEL_WIDTH;
  515. uv.y *= CUBEUV_TEXEL_HEIGHT;
  516. #ifdef texture2DGradEXT
  517. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  518. #else
  519. return texture2D( envMap, uv ).rgb;
  520. #endif
  521. }
  522. #define cubeUV_r0 1.0
  523. #define cubeUV_m0 - 2.0
  524. #define cubeUV_r1 0.8
  525. #define cubeUV_m1 - 1.0
  526. #define cubeUV_r4 0.4
  527. #define cubeUV_m4 2.0
  528. #define cubeUV_r5 0.305
  529. #define cubeUV_m5 3.0
  530. #define cubeUV_r6 0.21
  531. #define cubeUV_m6 4.0
  532. float roughnessToMip( float roughness ) {
  533. float mip = 0.0;
  534. if ( roughness >= cubeUV_r1 ) {
  535. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  536. } else if ( roughness >= cubeUV_r4 ) {
  537. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  538. } else if ( roughness >= cubeUV_r5 ) {
  539. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  540. } else if ( roughness >= cubeUV_r6 ) {
  541. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  542. } else {
  543. mip = - 2.0 * log2( 1.16 * roughness ); }
  544. return mip;
  545. }
  546. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  547. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  548. float mipF = fract( mip );
  549. float mipInt = floor( mip );
  550. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  551. if ( mipF == 0.0 ) {
  552. return vec4( color0, 1.0 );
  553. } else {
  554. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  555. return vec4( mix( color0, color1, mipF ), 1.0 );
  556. }
  557. }
  558. #endif`,v3e=`vec3 transformedNormal = objectNormal;
  559. #ifdef USE_TANGENT
  560. vec3 transformedTangent = objectTangent;
  561. #endif
  562. #ifdef USE_BATCHING
  563. mat3 bm = mat3( batchingMatrix );
  564. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  565. transformedNormal = bm * transformedNormal;
  566. #ifdef USE_TANGENT
  567. transformedTangent = bm * transformedTangent;
  568. #endif
  569. #endif
  570. #ifdef USE_INSTANCING
  571. mat3 im = mat3( instanceMatrix );
  572. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  573. transformedNormal = im * transformedNormal;
  574. #ifdef USE_TANGENT
  575. transformedTangent = im * transformedTangent;
  576. #endif
  577. #endif
  578. transformedNormal = normalMatrix * transformedNormal;
  579. #ifdef FLIP_SIDED
  580. transformedNormal = - transformedNormal;
  581. #endif
  582. #ifdef USE_TANGENT
  583. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  584. #ifdef FLIP_SIDED
  585. transformedTangent = - transformedTangent;
  586. #endif
  587. #endif`,w3e=`#ifdef USE_DISPLACEMENTMAP
  588. uniform sampler2D displacementMap;
  589. uniform float displacementScale;
  590. uniform float displacementBias;
  591. #endif`,_3e=`#ifdef USE_DISPLACEMENTMAP
  592. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  593. #endif`,S3e=`#ifdef USE_EMISSIVEMAP
  594. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  595. #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
  596. emissiveColor = sRGBTransferEOTF( emissiveColor );
  597. #endif
  598. totalEmissiveRadiance *= emissiveColor.rgb;
  599. #endif`,N3e=`#ifdef USE_EMISSIVEMAP
  600. uniform sampler2D emissiveMap;
  601. #endif`,M3e="gl_FragColor = linearToOutputTexel( gl_FragColor );",E3e=`vec4 LinearTransferOETF( in vec4 value ) {
  602. return value;
  603. }
  604. vec4 sRGBTransferEOTF( in vec4 value ) {
  605. 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 );
  606. }
  607. vec4 sRGBTransferOETF( in vec4 value ) {
  608. 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 );
  609. }`,k3e=`#ifdef USE_ENVMAP
  610. #ifdef ENV_WORLDPOS
  611. vec3 cameraToFrag;
  612. if ( isOrthographic ) {
  613. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  614. } else {
  615. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  616. }
  617. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  618. #ifdef ENVMAP_MODE_REFLECTION
  619. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  620. #else
  621. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  622. #endif
  623. #else
  624. vec3 reflectVec = vReflect;
  625. #endif
  626. #ifdef ENVMAP_TYPE_CUBE
  627. vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  628. #else
  629. vec4 envColor = vec4( 0.0 );
  630. #endif
  631. #ifdef ENVMAP_BLENDING_MULTIPLY
  632. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  633. #elif defined( ENVMAP_BLENDING_MIX )
  634. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  635. #elif defined( ENVMAP_BLENDING_ADD )
  636. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  637. #endif
  638. #endif`,T3e=`#ifdef USE_ENVMAP
  639. uniform float envMapIntensity;
  640. uniform float flipEnvMap;
  641. uniform mat3 envMapRotation;
  642. #ifdef ENVMAP_TYPE_CUBE
  643. uniform samplerCube envMap;
  644. #else
  645. uniform sampler2D envMap;
  646. #endif
  647. #endif`,A3e=`#ifdef USE_ENVMAP
  648. uniform float reflectivity;
  649. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  650. #define ENV_WORLDPOS
  651. #endif
  652. #ifdef ENV_WORLDPOS
  653. varying vec3 vWorldPosition;
  654. uniform float refractionRatio;
  655. #else
  656. varying vec3 vReflect;
  657. #endif
  658. #endif`,C3e=`#ifdef USE_ENVMAP
  659. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  660. #define ENV_WORLDPOS
  661. #endif
  662. #ifdef ENV_WORLDPOS
  663. varying vec3 vWorldPosition;
  664. #else
  665. varying vec3 vReflect;
  666. uniform float refractionRatio;
  667. #endif
  668. #endif`,j3e=`#ifdef USE_ENVMAP
  669. #ifdef ENV_WORLDPOS
  670. vWorldPosition = worldPosition.xyz;
  671. #else
  672. vec3 cameraToVertex;
  673. if ( isOrthographic ) {
  674. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  675. } else {
  676. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  677. }
  678. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  679. #ifdef ENVMAP_MODE_REFLECTION
  680. vReflect = reflect( cameraToVertex, worldNormal );
  681. #else
  682. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  683. #endif
  684. #endif
  685. #endif`,P3e=`#ifdef USE_FOG
  686. vFogDepth = - mvPosition.z;
  687. #endif`,D3e=`#ifdef USE_FOG
  688. varying float vFogDepth;
  689. #endif`,R3e=`#ifdef USE_FOG
  690. #ifdef FOG_EXP2
  691. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  692. #else
  693. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  694. #endif
  695. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  696. #endif`,O3e=`#ifdef USE_FOG
  697. uniform vec3 fogColor;
  698. varying float vFogDepth;
  699. #ifdef FOG_EXP2
  700. uniform float fogDensity;
  701. #else
  702. uniform float fogNear;
  703. uniform float fogFar;
  704. #endif
  705. #endif`,L3e=`#ifdef USE_GRADIENTMAP
  706. uniform sampler2D gradientMap;
  707. #endif
  708. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  709. float dotNL = dot( normal, lightDirection );
  710. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  711. #ifdef USE_GRADIENTMAP
  712. return vec3( texture2D( gradientMap, coord ).r );
  713. #else
  714. vec2 fw = fwidth( coord ) * 0.5;
  715. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  716. #endif
  717. }`,F3e=`#ifdef USE_LIGHTMAP
  718. uniform sampler2D lightMap;
  719. uniform float lightMapIntensity;
  720. #endif`,I3e=`LambertMaterial material;
  721. material.diffuseColor = diffuseColor.rgb;
  722. material.specularStrength = specularStrength;`,U3e=`varying vec3 vViewPosition;
  723. struct LambertMaterial {
  724. vec3 diffuseColor;
  725. float specularStrength;
  726. };
  727. 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 ) {
  728. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  729. vec3 irradiance = dotNL * directLight.color;
  730. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  731. }
  732. 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 ) {
  733. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  734. }
  735. #define RE_Direct RE_Direct_Lambert
  736. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,z3e=`uniform bool receiveShadow;
  737. uniform vec3 ambientLightColor;
  738. #if defined( USE_LIGHT_PROBES )
  739. uniform vec3 lightProbe[ 9 ];
  740. #endif
  741. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  742. float x = normal.x, y = normal.y, z = normal.z;
  743. vec3 result = shCoefficients[ 0 ] * 0.886227;
  744. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  745. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  746. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  747. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  748. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  749. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  750. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  751. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  752. return result;
  753. }
  754. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  755. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  756. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  757. return irradiance;
  758. }
  759. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  760. vec3 irradiance = ambientLightColor;
  761. return irradiance;
  762. }
  763. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  764. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  765. if ( cutoffDistance > 0.0 ) {
  766. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  767. }
  768. return distanceFalloff;
  769. }
  770. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  771. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  772. }
  773. #if NUM_DIR_LIGHTS > 0
  774. struct DirectionalLight {
  775. vec3 direction;
  776. vec3 color;
  777. };
  778. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  779. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  780. light.color = directionalLight.color;
  781. light.direction = directionalLight.direction;
  782. light.visible = true;
  783. }
  784. #endif
  785. #if NUM_POINT_LIGHTS > 0
  786. struct PointLight {
  787. vec3 position;
  788. vec3 color;
  789. float distance;
  790. float decay;
  791. };
  792. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  793. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  794. vec3 lVector = pointLight.position - geometryPosition;
  795. light.direction = normalize( lVector );
  796. float lightDistance = length( lVector );
  797. light.color = pointLight.color;
  798. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  799. light.visible = ( light.color != vec3( 0.0 ) );
  800. }
  801. #endif
  802. #if NUM_SPOT_LIGHTS > 0
  803. struct SpotLight {
  804. vec3 position;
  805. vec3 direction;
  806. vec3 color;
  807. float distance;
  808. float decay;
  809. float coneCos;
  810. float penumbraCos;
  811. };
  812. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  813. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  814. vec3 lVector = spotLight.position - geometryPosition;
  815. light.direction = normalize( lVector );
  816. float angleCos = dot( light.direction, spotLight.direction );
  817. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  818. if ( spotAttenuation > 0.0 ) {
  819. float lightDistance = length( lVector );
  820. light.color = spotLight.color * spotAttenuation;
  821. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  822. light.visible = ( light.color != vec3( 0.0 ) );
  823. } else {
  824. light.color = vec3( 0.0 );
  825. light.visible = false;
  826. }
  827. }
  828. #endif
  829. #if NUM_RECT_AREA_LIGHTS > 0
  830. struct RectAreaLight {
  831. vec3 color;
  832. vec3 position;
  833. vec3 halfWidth;
  834. vec3 halfHeight;
  835. };
  836. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  837. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  838. #endif
  839. #if NUM_HEMI_LIGHTS > 0
  840. struct HemisphereLight {
  841. vec3 direction;
  842. vec3 skyColor;
  843. vec3 groundColor;
  844. };
  845. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  846. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  847. float dotNL = dot( normal, hemiLight.direction );
  848. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  849. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  850. return irradiance;
  851. }
  852. #endif`,B3e=`#ifdef USE_ENVMAP
  853. vec3 getIBLIrradiance( const in vec3 normal ) {
  854. #ifdef ENVMAP_TYPE_CUBE_UV
  855. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  856. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
  857. return PI * envMapColor.rgb * envMapIntensity;
  858. #else
  859. return vec3( 0.0 );
  860. #endif
  861. }
  862. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  863. #ifdef ENVMAP_TYPE_CUBE_UV
  864. vec3 reflectVec = reflect( - viewDir, normal );
  865. reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
  866. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  867. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
  868. return envMapColor.rgb * envMapIntensity;
  869. #else
  870. return vec3( 0.0 );
  871. #endif
  872. }
  873. #ifdef USE_ANISOTROPY
  874. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  875. #ifdef ENVMAP_TYPE_CUBE_UV
  876. vec3 bentNormal = cross( bitangent, viewDir );
  877. bentNormal = normalize( cross( bentNormal, bitangent ) );
  878. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  879. return getIBLRadiance( viewDir, bentNormal, roughness );
  880. #else
  881. return vec3( 0.0 );
  882. #endif
  883. }
  884. #endif
  885. #endif`,$3e=`ToonMaterial material;
  886. material.diffuseColor = diffuseColor.rgb;`,H3e=`varying vec3 vViewPosition;
  887. struct ToonMaterial {
  888. vec3 diffuseColor;
  889. };
  890. 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 ) {
  891. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  892. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  893. }
  894. 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 ) {
  895. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  896. }
  897. #define RE_Direct RE_Direct_Toon
  898. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,V3e=`BlinnPhongMaterial material;
  899. material.diffuseColor = diffuseColor.rgb;
  900. material.specularColor = specular;
  901. material.specularShininess = shininess;
  902. material.specularStrength = specularStrength;`,G3e=`varying vec3 vViewPosition;
  903. struct BlinnPhongMaterial {
  904. vec3 diffuseColor;
  905. vec3 specularColor;
  906. float specularShininess;
  907. float specularStrength;
  908. };
  909. 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 ) {
  910. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  911. vec3 irradiance = dotNL * directLight.color;
  912. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  913. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  914. }
  915. 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 ) {
  916. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  917. }
  918. #define RE_Direct RE_Direct_BlinnPhong
  919. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,q3e=`PhysicalMaterial material;
  920. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  921. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  922. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  923. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  924. material.roughness = min( material.roughness, 1.0 );
  925. #ifdef IOR
  926. material.ior = ior;
  927. #ifdef USE_SPECULAR
  928. float specularIntensityFactor = specularIntensity;
  929. vec3 specularColorFactor = specularColor;
  930. #ifdef USE_SPECULAR_COLORMAP
  931. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  932. #endif
  933. #ifdef USE_SPECULAR_INTENSITYMAP
  934. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  935. #endif
  936. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  937. #else
  938. float specularIntensityFactor = 1.0;
  939. vec3 specularColorFactor = vec3( 1.0 );
  940. material.specularF90 = 1.0;
  941. #endif
  942. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  943. #else
  944. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  945. material.specularF90 = 1.0;
  946. #endif
  947. #ifdef USE_CLEARCOAT
  948. material.clearcoat = clearcoat;
  949. material.clearcoatRoughness = clearcoatRoughness;
  950. material.clearcoatF0 = vec3( 0.04 );
  951. material.clearcoatF90 = 1.0;
  952. #ifdef USE_CLEARCOATMAP
  953. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  954. #endif
  955. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  956. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  957. #endif
  958. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  959. material.clearcoatRoughness += geometryRoughness;
  960. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  961. #endif
  962. #ifdef USE_DISPERSION
  963. material.dispersion = dispersion;
  964. #endif
  965. #ifdef USE_IRIDESCENCE
  966. material.iridescence = iridescence;
  967. material.iridescenceIOR = iridescenceIOR;
  968. #ifdef USE_IRIDESCENCEMAP
  969. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  970. #endif
  971. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  972. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  973. #else
  974. material.iridescenceThickness = iridescenceThicknessMaximum;
  975. #endif
  976. #endif
  977. #ifdef USE_SHEEN
  978. material.sheenColor = sheenColor;
  979. #ifdef USE_SHEEN_COLORMAP
  980. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  981. #endif
  982. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  983. #ifdef USE_SHEEN_ROUGHNESSMAP
  984. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  985. #endif
  986. #endif
  987. #ifdef USE_ANISOTROPY
  988. #ifdef USE_ANISOTROPYMAP
  989. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  990. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  991. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  992. #else
  993. vec2 anisotropyV = anisotropyVector;
  994. #endif
  995. material.anisotropy = length( anisotropyV );
  996. if( material.anisotropy == 0.0 ) {
  997. anisotropyV = vec2( 1.0, 0.0 );
  998. } else {
  999. anisotropyV /= material.anisotropy;
  1000. material.anisotropy = saturate( material.anisotropy );
  1001. }
  1002. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  1003. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  1004. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  1005. #endif`,W3e=`uniform sampler2D dfgLUT;
  1006. struct PhysicalMaterial {
  1007. vec3 diffuseColor;
  1008. float roughness;
  1009. vec3 specularColor;
  1010. float specularF90;
  1011. float dispersion;
  1012. #ifdef USE_CLEARCOAT
  1013. float clearcoat;
  1014. float clearcoatRoughness;
  1015. vec3 clearcoatF0;
  1016. float clearcoatF90;
  1017. #endif
  1018. #ifdef USE_IRIDESCENCE
  1019. float iridescence;
  1020. float iridescenceIOR;
  1021. float iridescenceThickness;
  1022. vec3 iridescenceFresnel;
  1023. vec3 iridescenceF0;
  1024. #endif
  1025. #ifdef USE_SHEEN
  1026. vec3 sheenColor;
  1027. float sheenRoughness;
  1028. #endif
  1029. #ifdef IOR
  1030. float ior;
  1031. #endif
  1032. #ifdef USE_TRANSMISSION
  1033. float transmission;
  1034. float transmissionAlpha;
  1035. float thickness;
  1036. float attenuationDistance;
  1037. vec3 attenuationColor;
  1038. #endif
  1039. #ifdef USE_ANISOTROPY
  1040. float anisotropy;
  1041. float alphaT;
  1042. vec3 anisotropyT;
  1043. vec3 anisotropyB;
  1044. #endif
  1045. };
  1046. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  1047. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  1048. vec3 sheenSpecularDirect = vec3( 0.0 );
  1049. vec3 sheenSpecularIndirect = vec3(0.0 );
  1050. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  1051. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  1052. float x2 = x * x;
  1053. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  1054. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  1055. }
  1056. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  1057. float a2 = pow2( alpha );
  1058. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  1059. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  1060. return 0.5 / max( gv + gl, EPSILON );
  1061. }
  1062. float D_GGX( const in float alpha, const in float dotNH ) {
  1063. float a2 = pow2( alpha );
  1064. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  1065. return RECIPROCAL_PI * a2 / pow2( denom );
  1066. }
  1067. #ifdef USE_ANISOTROPY
  1068. 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 ) {
  1069. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  1070. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  1071. float v = 0.5 / ( gv + gl );
  1072. return saturate(v);
  1073. }
  1074. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  1075. float a2 = alphaT * alphaB;
  1076. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  1077. highp float v2 = dot( v, v );
  1078. float w2 = a2 / v2;
  1079. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  1080. }
  1081. #endif
  1082. #ifdef USE_CLEARCOAT
  1083. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  1084. vec3 f0 = material.clearcoatF0;
  1085. float f90 = material.clearcoatF90;
  1086. float roughness = material.clearcoatRoughness;
  1087. float alpha = pow2( roughness );
  1088. vec3 halfDir = normalize( lightDir + viewDir );
  1089. float dotNL = saturate( dot( normal, lightDir ) );
  1090. float dotNV = saturate( dot( normal, viewDir ) );
  1091. float dotNH = saturate( dot( normal, halfDir ) );
  1092. float dotVH = saturate( dot( viewDir, halfDir ) );
  1093. vec3 F = F_Schlick( f0, f90, dotVH );
  1094. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1095. float D = D_GGX( alpha, dotNH );
  1096. return F * ( V * D );
  1097. }
  1098. #endif
  1099. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1100. vec3 f0 = material.specularColor;
  1101. float f90 = material.specularF90;
  1102. float roughness = material.roughness;
  1103. float alpha = pow2( roughness );
  1104. vec3 halfDir = normalize( lightDir + viewDir );
  1105. float dotNL = saturate( dot( normal, lightDir ) );
  1106. float dotNV = saturate( dot( normal, viewDir ) );
  1107. float dotNH = saturate( dot( normal, halfDir ) );
  1108. float dotVH = saturate( dot( viewDir, halfDir ) );
  1109. vec3 F = F_Schlick( f0, f90, dotVH );
  1110. #ifdef USE_IRIDESCENCE
  1111. F = mix( F, material.iridescenceFresnel, material.iridescence );
  1112. #endif
  1113. #ifdef USE_ANISOTROPY
  1114. float dotTL = dot( material.anisotropyT, lightDir );
  1115. float dotTV = dot( material.anisotropyT, viewDir );
  1116. float dotTH = dot( material.anisotropyT, halfDir );
  1117. float dotBL = dot( material.anisotropyB, lightDir );
  1118. float dotBV = dot( material.anisotropyB, viewDir );
  1119. float dotBH = dot( material.anisotropyB, halfDir );
  1120. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  1121. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  1122. #else
  1123. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1124. float D = D_GGX( alpha, dotNH );
  1125. #endif
  1126. return F * ( V * D );
  1127. }
  1128. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  1129. const float LUT_SIZE = 64.0;
  1130. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  1131. const float LUT_BIAS = 0.5 / LUT_SIZE;
  1132. float dotNV = saturate( dot( N, V ) );
  1133. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  1134. uv = uv * LUT_SCALE + LUT_BIAS;
  1135. return uv;
  1136. }
  1137. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  1138. float l = length( f );
  1139. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  1140. }
  1141. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  1142. float x = dot( v1, v2 );
  1143. float y = abs( x );
  1144. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  1145. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  1146. float v = a / b;
  1147. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  1148. return cross( v1, v2 ) * theta_sintheta;
  1149. }
  1150. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  1151. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  1152. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  1153. vec3 lightNormal = cross( v1, v2 );
  1154. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  1155. vec3 T1, T2;
  1156. T1 = normalize( V - N * dot( V, N ) );
  1157. T2 = - cross( N, T1 );
  1158. mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
  1159. vec3 coords[ 4 ];
  1160. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  1161. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  1162. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  1163. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  1164. coords[ 0 ] = normalize( coords[ 0 ] );
  1165. coords[ 1 ] = normalize( coords[ 1 ] );
  1166. coords[ 2 ] = normalize( coords[ 2 ] );
  1167. coords[ 3 ] = normalize( coords[ 3 ] );
  1168. vec3 vectorFormFactor = vec3( 0.0 );
  1169. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  1170. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  1171. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  1172. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  1173. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  1174. return vec3( result );
  1175. }
  1176. #if defined( USE_SHEEN )
  1177. float D_Charlie( float roughness, float dotNH ) {
  1178. float alpha = pow2( roughness );
  1179. float invAlpha = 1.0 / alpha;
  1180. float cos2h = dotNH * dotNH;
  1181. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  1182. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  1183. }
  1184. float V_Neubelt( float dotNV, float dotNL ) {
  1185. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  1186. }
  1187. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  1188. vec3 halfDir = normalize( lightDir + viewDir );
  1189. float dotNL = saturate( dot( normal, lightDir ) );
  1190. float dotNV = saturate( dot( normal, viewDir ) );
  1191. float dotNH = saturate( dot( normal, halfDir ) );
  1192. float D = D_Charlie( sheenRoughness, dotNH );
  1193. float V = V_Neubelt( dotNV, dotNL );
  1194. return sheenColor * ( D * V );
  1195. }
  1196. #endif
  1197. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1198. float dotNV = saturate( dot( normal, viewDir ) );
  1199. float r2 = roughness * roughness;
  1200. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  1201. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  1202. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  1203. return saturate( DG * RECIPROCAL_PI );
  1204. }
  1205. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1206. float dotNV = saturate( dot( normal, viewDir ) );
  1207. vec2 uv = vec2( roughness, dotNV );
  1208. return texture2D( dfgLUT, uv ).rg;
  1209. }
  1210. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  1211. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1212. return specularColor * fab.x + specularF90 * fab.y;
  1213. }
  1214. #ifdef USE_IRIDESCENCE
  1215. 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 ) {
  1216. #else
  1217. 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 ) {
  1218. #endif
  1219. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1220. #ifdef USE_IRIDESCENCE
  1221. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  1222. #else
  1223. vec3 Fr = specularColor;
  1224. #endif
  1225. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  1226. float Ess = fab.x + fab.y;
  1227. float Ems = 1.0 - Ess;
  1228. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  1229. singleScatter += FssEss;
  1230. multiScatter += Fms * Ems;
  1231. }
  1232. vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1233. vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
  1234. float dotNL = saturate( dot( normal, lightDir ) );
  1235. float dotNV = saturate( dot( normal, viewDir ) );
  1236. vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
  1237. vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
  1238. vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
  1239. vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
  1240. float Ess_V = dfgV.x + dfgV.y;
  1241. float Ess_L = dfgL.x + dfgL.y;
  1242. float Ems_V = 1.0 - Ess_V;
  1243. float Ems_L = 1.0 - Ess_L;
  1244. vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
  1245. vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
  1246. float compensationFactor = Ems_V * Ems_L;
  1247. vec3 multiScatter = Fms * compensationFactor;
  1248. return singleScatter + multiScatter;
  1249. }
  1250. #if NUM_RECT_AREA_LIGHTS > 0
  1251. 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 ) {
  1252. vec3 normal = geometryNormal;
  1253. vec3 viewDir = geometryViewDir;
  1254. vec3 position = geometryPosition;
  1255. vec3 lightPos = rectAreaLight.position;
  1256. vec3 halfWidth = rectAreaLight.halfWidth;
  1257. vec3 halfHeight = rectAreaLight.halfHeight;
  1258. vec3 lightColor = rectAreaLight.color;
  1259. float roughness = material.roughness;
  1260. vec3 rectCoords[ 4 ];
  1261. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  1262. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  1263. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  1264. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  1265. vec4 t1 = texture2D( ltc_1, uv );
  1266. vec4 t2 = texture2D( ltc_2, uv );
  1267. mat3 mInv = mat3(
  1268. vec3( t1.x, 0, t1.y ),
  1269. vec3( 0, 1, 0 ),
  1270. vec3( t1.z, 0, t1.w )
  1271. );
  1272. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  1273. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  1274. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  1275. }
  1276. #endif
  1277. 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 ) {
  1278. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  1279. vec3 irradiance = dotNL * directLight.color;
  1280. #ifdef USE_CLEARCOAT
  1281. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  1282. vec3 ccIrradiance = dotNLcc * directLight.color;
  1283. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  1284. #endif
  1285. #ifdef USE_SHEEN
  1286. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  1287. #endif
  1288. reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
  1289. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1290. }
  1291. 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 ) {
  1292. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1293. }
  1294. 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) {
  1295. #ifdef USE_CLEARCOAT
  1296. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  1297. #endif
  1298. #ifdef USE_SHEEN
  1299. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  1300. #endif
  1301. vec3 singleScattering = vec3( 0.0 );
  1302. vec3 multiScattering = vec3( 0.0 );
  1303. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  1304. #ifdef USE_IRIDESCENCE
  1305. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  1306. #else
  1307. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  1308. #endif
  1309. vec3 totalScattering = singleScattering + multiScattering;
  1310. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  1311. reflectedLight.indirectSpecular += radiance * singleScattering;
  1312. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  1313. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  1314. }
  1315. #define RE_Direct RE_Direct_Physical
  1316. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  1317. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  1318. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  1319. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  1320. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  1321. }`,K3e=`
  1322. vec3 geometryPosition = - vViewPosition;
  1323. vec3 geometryNormal = normal;
  1324. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  1325. vec3 geometryClearcoatNormal = vec3( 0.0 );
  1326. #ifdef USE_CLEARCOAT
  1327. geometryClearcoatNormal = clearcoatNormal;
  1328. #endif
  1329. #ifdef USE_IRIDESCENCE
  1330. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  1331. if ( material.iridescenceThickness == 0.0 ) {
  1332. material.iridescence = 0.0;
  1333. } else {
  1334. material.iridescence = saturate( material.iridescence );
  1335. }
  1336. if ( material.iridescence > 0.0 ) {
  1337. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  1338. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  1339. }
  1340. #endif
  1341. IncidentLight directLight;
  1342. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  1343. PointLight pointLight;
  1344. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  1345. PointLightShadow pointLightShadow;
  1346. #endif
  1347. #pragma unroll_loop_start
  1348. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  1349. pointLight = pointLights[ i ];
  1350. getPointLightInfo( pointLight, geometryPosition, directLight );
  1351. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  1352. pointLightShadow = pointLightShadows[ i ];
  1353. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  1354. #endif
  1355. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1356. }
  1357. #pragma unroll_loop_end
  1358. #endif
  1359. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  1360. SpotLight spotLight;
  1361. vec4 spotColor;
  1362. vec3 spotLightCoord;
  1363. bool inSpotLightMap;
  1364. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  1365. SpotLightShadow spotLightShadow;
  1366. #endif
  1367. #pragma unroll_loop_start
  1368. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  1369. spotLight = spotLights[ i ];
  1370. getSpotLightInfo( spotLight, geometryPosition, directLight );
  1371. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1372. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  1373. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1374. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  1375. #else
  1376. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1377. #endif
  1378. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  1379. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  1380. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  1381. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  1382. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  1383. #endif
  1384. #undef SPOT_LIGHT_MAP_INDEX
  1385. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1386. spotLightShadow = spotLightShadows[ i ];
  1387. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1388. #endif
  1389. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1390. }
  1391. #pragma unroll_loop_end
  1392. #endif
  1393. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  1394. DirectionalLight directionalLight;
  1395. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  1396. DirectionalLightShadow directionalLightShadow;
  1397. #endif
  1398. #pragma unroll_loop_start
  1399. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  1400. directionalLight = directionalLights[ i ];
  1401. getDirectionalLightInfo( directionalLight, directLight );
  1402. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  1403. directionalLightShadow = directionalLightShadows[ i ];
  1404. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1405. #endif
  1406. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1407. }
  1408. #pragma unroll_loop_end
  1409. #endif
  1410. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  1411. RectAreaLight rectAreaLight;
  1412. #pragma unroll_loop_start
  1413. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  1414. rectAreaLight = rectAreaLights[ i ];
  1415. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1416. }
  1417. #pragma unroll_loop_end
  1418. #endif
  1419. #if defined( RE_IndirectDiffuse )
  1420. vec3 iblIrradiance = vec3( 0.0 );
  1421. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  1422. #if defined( USE_LIGHT_PROBES )
  1423. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  1424. #endif
  1425. #if ( NUM_HEMI_LIGHTS > 0 )
  1426. #pragma unroll_loop_start
  1427. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  1428. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  1429. }
  1430. #pragma unroll_loop_end
  1431. #endif
  1432. #endif
  1433. #if defined( RE_IndirectSpecular )
  1434. vec3 radiance = vec3( 0.0 );
  1435. vec3 clearcoatRadiance = vec3( 0.0 );
  1436. #endif`,X3e=`#if defined( RE_IndirectDiffuse )
  1437. #ifdef USE_LIGHTMAP
  1438. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  1439. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  1440. irradiance += lightMapIrradiance;
  1441. #endif
  1442. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  1443. iblIrradiance += getIBLIrradiance( geometryNormal );
  1444. #endif
  1445. #endif
  1446. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  1447. #ifdef USE_ANISOTROPY
  1448. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  1449. #else
  1450. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  1451. #endif
  1452. #ifdef USE_CLEARCOAT
  1453. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  1454. #endif
  1455. #endif`,Y3e=`#if defined( RE_IndirectDiffuse )
  1456. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1457. #endif
  1458. #if defined( RE_IndirectSpecular )
  1459. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1460. #endif`,Q3e=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1461. gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  1462. #endif`,Z3e=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1463. uniform float logDepthBufFC;
  1464. varying float vFragDepth;
  1465. varying float vIsPerspective;
  1466. #endif`,J3e=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1467. varying float vFragDepth;
  1468. varying float vIsPerspective;
  1469. #endif`,eDe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1470. vFragDepth = 1.0 + gl_Position.w;
  1471. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  1472. #endif`,tDe=`#ifdef USE_MAP
  1473. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  1474. #ifdef DECODE_VIDEO_TEXTURE
  1475. sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
  1476. #endif
  1477. diffuseColor *= sampledDiffuseColor;
  1478. #endif`,nDe=`#ifdef USE_MAP
  1479. uniform sampler2D map;
  1480. #endif`,rDe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1481. #if defined( USE_POINTS_UV )
  1482. vec2 uv = vUv;
  1483. #else
  1484. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  1485. #endif
  1486. #endif
  1487. #ifdef USE_MAP
  1488. diffuseColor *= texture2D( map, uv );
  1489. #endif
  1490. #ifdef USE_ALPHAMAP
  1491. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  1492. #endif`,iDe=`#if defined( USE_POINTS_UV )
  1493. varying vec2 vUv;
  1494. #else
  1495. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1496. uniform mat3 uvTransform;
  1497. #endif
  1498. #endif
  1499. #ifdef USE_MAP
  1500. uniform sampler2D map;
  1501. #endif
  1502. #ifdef USE_ALPHAMAP
  1503. uniform sampler2D alphaMap;
  1504. #endif`,aDe=`float metalnessFactor = metalness;
  1505. #ifdef USE_METALNESSMAP
  1506. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  1507. metalnessFactor *= texelMetalness.b;
  1508. #endif`,sDe=`#ifdef USE_METALNESSMAP
  1509. uniform sampler2D metalnessMap;
  1510. #endif`,oDe=`#ifdef USE_INSTANCING_MORPH
  1511. float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1512. float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
  1513. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1514. morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
  1515. }
  1516. #endif`,lDe=`#if defined( USE_MORPHCOLORS )
  1517. vColor *= morphTargetBaseInfluence;
  1518. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1519. #if defined( USE_COLOR_ALPHA )
  1520. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  1521. #elif defined( USE_COLOR )
  1522. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  1523. #endif
  1524. }
  1525. #endif`,cDe=`#ifdef USE_MORPHNORMALS
  1526. objectNormal *= morphTargetBaseInfluence;
  1527. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1528. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  1529. }
  1530. #endif`,uDe=`#ifdef USE_MORPHTARGETS
  1531. #ifndef USE_INSTANCING_MORPH
  1532. uniform float morphTargetBaseInfluence;
  1533. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1534. #endif
  1535. uniform sampler2DArray morphTargetsTexture;
  1536. uniform ivec2 morphTargetsTextureSize;
  1537. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  1538. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  1539. int y = texelIndex / morphTargetsTextureSize.x;
  1540. int x = texelIndex - y * morphTargetsTextureSize.x;
  1541. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  1542. return texelFetch( morphTargetsTexture, morphUV, 0 );
  1543. }
  1544. #endif`,dDe=`#ifdef USE_MORPHTARGETS
  1545. transformed *= morphTargetBaseInfluence;
  1546. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1547. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  1548. }
  1549. #endif`,hDe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  1550. #ifdef FLAT_SHADED
  1551. vec3 fdx = dFdx( vViewPosition );
  1552. vec3 fdy = dFdy( vViewPosition );
  1553. vec3 normal = normalize( cross( fdx, fdy ) );
  1554. #else
  1555. vec3 normal = normalize( vNormal );
  1556. #ifdef DOUBLE_SIDED
  1557. normal *= faceDirection;
  1558. #endif
  1559. #endif
  1560. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  1561. #ifdef USE_TANGENT
  1562. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1563. #else
  1564. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  1565. #if defined( USE_NORMALMAP )
  1566. vNormalMapUv
  1567. #elif defined( USE_CLEARCOAT_NORMALMAP )
  1568. vClearcoatNormalMapUv
  1569. #else
  1570. vUv
  1571. #endif
  1572. );
  1573. #endif
  1574. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1575. tbn[0] *= faceDirection;
  1576. tbn[1] *= faceDirection;
  1577. #endif
  1578. #endif
  1579. #ifdef USE_CLEARCOAT_NORMALMAP
  1580. #ifdef USE_TANGENT
  1581. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1582. #else
  1583. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  1584. #endif
  1585. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1586. tbn2[0] *= faceDirection;
  1587. tbn2[1] *= faceDirection;
  1588. #endif
  1589. #endif
  1590. vec3 nonPerturbedNormal = normal;`,fDe=`#ifdef USE_NORMALMAP_OBJECTSPACE
  1591. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1592. #ifdef FLIP_SIDED
  1593. normal = - normal;
  1594. #endif
  1595. #ifdef DOUBLE_SIDED
  1596. normal = normal * faceDirection;
  1597. #endif
  1598. normal = normalize( normalMatrix * normal );
  1599. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  1600. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1601. mapN.xy *= normalScale;
  1602. normal = normalize( tbn * mapN );
  1603. #elif defined( USE_BUMPMAP )
  1604. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  1605. #endif`,mDe=`#ifndef FLAT_SHADED
  1606. varying vec3 vNormal;
  1607. #ifdef USE_TANGENT
  1608. varying vec3 vTangent;
  1609. varying vec3 vBitangent;
  1610. #endif
  1611. #endif`,pDe=`#ifndef FLAT_SHADED
  1612. varying vec3 vNormal;
  1613. #ifdef USE_TANGENT
  1614. varying vec3 vTangent;
  1615. varying vec3 vBitangent;
  1616. #endif
  1617. #endif`,gDe=`#ifndef FLAT_SHADED
  1618. vNormal = normalize( transformedNormal );
  1619. #ifdef USE_TANGENT
  1620. vTangent = normalize( transformedTangent );
  1621. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  1622. #endif
  1623. #endif`,xDe=`#ifdef USE_NORMALMAP
  1624. uniform sampler2D normalMap;
  1625. uniform vec2 normalScale;
  1626. #endif
  1627. #ifdef USE_NORMALMAP_OBJECTSPACE
  1628. uniform mat3 normalMatrix;
  1629. #endif
  1630. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  1631. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  1632. vec3 q0 = dFdx( eye_pos.xyz );
  1633. vec3 q1 = dFdy( eye_pos.xyz );
  1634. vec2 st0 = dFdx( uv.st );
  1635. vec2 st1 = dFdy( uv.st );
  1636. vec3 N = surf_norm;
  1637. vec3 q1perp = cross( q1, N );
  1638. vec3 q0perp = cross( N, q0 );
  1639. vec3 T = q1perp * st0.x + q0perp * st1.x;
  1640. vec3 B = q1perp * st0.y + q0perp * st1.y;
  1641. float det = max( dot( T, T ), dot( B, B ) );
  1642. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  1643. return mat3( T * scale, B * scale, N );
  1644. }
  1645. #endif`,bDe=`#ifdef USE_CLEARCOAT
  1646. vec3 clearcoatNormal = nonPerturbedNormal;
  1647. #endif`,yDe=`#ifdef USE_CLEARCOAT_NORMALMAP
  1648. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  1649. clearcoatMapN.xy *= clearcoatNormalScale;
  1650. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  1651. #endif`,vDe=`#ifdef USE_CLEARCOATMAP
  1652. uniform sampler2D clearcoatMap;
  1653. #endif
  1654. #ifdef USE_CLEARCOAT_NORMALMAP
  1655. uniform sampler2D clearcoatNormalMap;
  1656. uniform vec2 clearcoatNormalScale;
  1657. #endif
  1658. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  1659. uniform sampler2D clearcoatRoughnessMap;
  1660. #endif`,wDe=`#ifdef USE_IRIDESCENCEMAP
  1661. uniform sampler2D iridescenceMap;
  1662. #endif
  1663. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  1664. uniform sampler2D iridescenceThicknessMap;
  1665. #endif`,_De=`#ifdef OPAQUE
  1666. diffuseColor.a = 1.0;
  1667. #endif
  1668. #ifdef USE_TRANSMISSION
  1669. diffuseColor.a *= material.transmissionAlpha;
  1670. #endif
  1671. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,SDe=`vec3 packNormalToRGB( const in vec3 normal ) {
  1672. return normalize( normal ) * 0.5 + 0.5;
  1673. }
  1674. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  1675. return 2.0 * rgb.xyz - 1.0;
  1676. }
  1677. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
  1678. const float Inv255 = 1. / 255.;
  1679. const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
  1680. const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
  1681. const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
  1682. const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
  1683. vec4 packDepthToRGBA( const in float v ) {
  1684. if( v <= 0.0 )
  1685. return vec4( 0., 0., 0., 0. );
  1686. if( v >= 1.0 )
  1687. return vec4( 1., 1., 1., 1. );
  1688. float vuf;
  1689. float af = modf( v * PackFactors.a, vuf );
  1690. float bf = modf( vuf * ShiftRight8, vuf );
  1691. float gf = modf( vuf * ShiftRight8, vuf );
  1692. return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
  1693. }
  1694. vec3 packDepthToRGB( const in float v ) {
  1695. if( v <= 0.0 )
  1696. return vec3( 0., 0., 0. );
  1697. if( v >= 1.0 )
  1698. return vec3( 1., 1., 1. );
  1699. float vuf;
  1700. float bf = modf( v * PackFactors.b, vuf );
  1701. float gf = modf( vuf * ShiftRight8, vuf );
  1702. return vec3( vuf * Inv255, gf * PackUpscale, bf );
  1703. }
  1704. vec2 packDepthToRG( const in float v ) {
  1705. if( v <= 0.0 )
  1706. return vec2( 0., 0. );
  1707. if( v >= 1.0 )
  1708. return vec2( 1., 1. );
  1709. float vuf;
  1710. float gf = modf( v * 256., vuf );
  1711. return vec2( vuf * Inv255, gf );
  1712. }
  1713. float unpackRGBAToDepth( const in vec4 v ) {
  1714. return dot( v, UnpackFactors4 );
  1715. }
  1716. float unpackRGBToDepth( const in vec3 v ) {
  1717. return dot( v, UnpackFactors3 );
  1718. }
  1719. float unpackRGToDepth( const in vec2 v ) {
  1720. return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
  1721. }
  1722. vec4 pack2HalfToRGBA( const in vec2 v ) {
  1723. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  1724. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  1725. }
  1726. vec2 unpackRGBATo2Half( const in vec4 v ) {
  1727. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  1728. }
  1729. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  1730. return ( viewZ + near ) / ( near - far );
  1731. }
  1732. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1733. return depth * ( near - far ) - near;
  1734. }
  1735. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  1736. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  1737. }
  1738. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1739. return ( near * far ) / ( ( far - near ) * depth - far );
  1740. }`,NDe=`#ifdef PREMULTIPLIED_ALPHA
  1741. gl_FragColor.rgb *= gl_FragColor.a;
  1742. #endif`,MDe=`vec4 mvPosition = vec4( transformed, 1.0 );
  1743. #ifdef USE_BATCHING
  1744. mvPosition = batchingMatrix * mvPosition;
  1745. #endif
  1746. #ifdef USE_INSTANCING
  1747. mvPosition = instanceMatrix * mvPosition;
  1748. #endif
  1749. mvPosition = modelViewMatrix * mvPosition;
  1750. gl_Position = projectionMatrix * mvPosition;`,EDe=`#ifdef DITHERING
  1751. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  1752. #endif`,kDe=`#ifdef DITHERING
  1753. vec3 dithering( vec3 color ) {
  1754. float grid_position = rand( gl_FragCoord.xy );
  1755. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  1756. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  1757. return color + dither_shift_RGB;
  1758. }
  1759. #endif`,TDe=`float roughnessFactor = roughness;
  1760. #ifdef USE_ROUGHNESSMAP
  1761. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  1762. roughnessFactor *= texelRoughness.g;
  1763. #endif`,ADe=`#ifdef USE_ROUGHNESSMAP
  1764. uniform sampler2D roughnessMap;
  1765. #endif`,CDe=`#if NUM_SPOT_LIGHT_COORDS > 0
  1766. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1767. #endif
  1768. #if NUM_SPOT_LIGHT_MAPS > 0
  1769. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  1770. #endif
  1771. #ifdef USE_SHADOWMAP
  1772. #if NUM_DIR_LIGHT_SHADOWS > 0
  1773. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  1774. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1775. struct DirectionalLightShadow {
  1776. float shadowIntensity;
  1777. float shadowBias;
  1778. float shadowNormalBias;
  1779. float shadowRadius;
  1780. vec2 shadowMapSize;
  1781. };
  1782. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1783. #endif
  1784. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1785. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  1786. struct SpotLightShadow {
  1787. float shadowIntensity;
  1788. float shadowBias;
  1789. float shadowNormalBias;
  1790. float shadowRadius;
  1791. vec2 shadowMapSize;
  1792. };
  1793. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1794. #endif
  1795. #if NUM_POINT_LIGHT_SHADOWS > 0
  1796. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  1797. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1798. struct PointLightShadow {
  1799. float shadowIntensity;
  1800. float shadowBias;
  1801. float shadowNormalBias;
  1802. float shadowRadius;
  1803. vec2 shadowMapSize;
  1804. float shadowCameraNear;
  1805. float shadowCameraFar;
  1806. };
  1807. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1808. #endif
  1809. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  1810. float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
  1811. #ifdef USE_REVERSED_DEPTH_BUFFER
  1812. return step( depth, compare );
  1813. #else
  1814. return step( compare, depth );
  1815. #endif
  1816. }
  1817. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  1818. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  1819. }
  1820. float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
  1821. float occlusion = 1.0;
  1822. vec2 distribution = texture2DDistribution( shadow, uv );
  1823. #ifdef USE_REVERSED_DEPTH_BUFFER
  1824. float hard_shadow = step( distribution.x, compare );
  1825. #else
  1826. float hard_shadow = step( compare, distribution.x );
  1827. #endif
  1828. if ( hard_shadow != 1.0 ) {
  1829. float distance = compare - distribution.x;
  1830. float variance = max( 0.00000, distribution.y * distribution.y );
  1831. 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 );
  1832. }
  1833. return occlusion;
  1834. }
  1835. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1836. float shadow = 1.0;
  1837. shadowCoord.xyz /= shadowCoord.w;
  1838. shadowCoord.z += shadowBias;
  1839. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  1840. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  1841. if ( frustumTest ) {
  1842. #if defined( SHADOWMAP_TYPE_PCF )
  1843. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1844. float dx0 = - texelSize.x * shadowRadius;
  1845. float dy0 = - texelSize.y * shadowRadius;
  1846. float dx1 = + texelSize.x * shadowRadius;
  1847. float dy1 = + texelSize.y * shadowRadius;
  1848. float dx2 = dx0 / 2.0;
  1849. float dy2 = dy0 / 2.0;
  1850. float dx3 = dx1 / 2.0;
  1851. float dy3 = dy1 / 2.0;
  1852. shadow = (
  1853. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  1854. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  1855. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  1856. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  1857. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  1858. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  1859. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  1860. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  1861. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  1862. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  1863. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  1864. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  1865. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  1866. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  1867. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  1868. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  1869. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  1870. ) * ( 1.0 / 17.0 );
  1871. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  1872. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1873. float dx = texelSize.x;
  1874. float dy = texelSize.y;
  1875. vec2 uv = shadowCoord.xy;
  1876. vec2 f = fract( uv * shadowMapSize + 0.5 );
  1877. uv -= f * texelSize;
  1878. shadow = (
  1879. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  1880. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  1881. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  1882. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  1883. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  1884. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  1885. f.x ) +
  1886. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  1887. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  1888. f.x ) +
  1889. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  1890. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  1891. f.y ) +
  1892. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  1893. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  1894. f.y ) +
  1895. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  1896. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  1897. f.x ),
  1898. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  1899. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  1900. f.x ),
  1901. f.y )
  1902. ) * ( 1.0 / 9.0 );
  1903. #elif defined( SHADOWMAP_TYPE_VSM )
  1904. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  1905. #else
  1906. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  1907. #endif
  1908. }
  1909. return mix( 1.0, shadow, shadowIntensity );
  1910. }
  1911. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  1912. vec3 absV = abs( v );
  1913. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  1914. absV *= scaleToCube;
  1915. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  1916. vec2 planar = v.xy;
  1917. float almostATexel = 1.5 * texelSizeY;
  1918. float almostOne = 1.0 - almostATexel;
  1919. if ( absV.z >= almostOne ) {
  1920. if ( v.z > 0.0 )
  1921. planar.x = 4.0 - v.x;
  1922. } else if ( absV.x >= almostOne ) {
  1923. float signX = sign( v.x );
  1924. planar.x = v.z * signX + 2.0 * signX;
  1925. } else if ( absV.y >= almostOne ) {
  1926. float signY = sign( v.y );
  1927. planar.x = v.x + 2.0 * signY + 2.0;
  1928. planar.y = v.z * signY - 2.0;
  1929. }
  1930. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  1931. }
  1932. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  1933. float shadow = 1.0;
  1934. vec3 lightToPosition = shadowCoord.xyz;
  1935. float lightToPositionLength = length( lightToPosition );
  1936. if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
  1937. float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  1938. vec3 bd3D = normalize( lightToPosition );
  1939. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  1940. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  1941. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  1942. shadow = (
  1943. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  1944. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  1945. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  1946. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  1947. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  1948. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  1949. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  1950. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  1951. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  1952. ) * ( 1.0 / 9.0 );
  1953. #else
  1954. shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  1955. #endif
  1956. }
  1957. return mix( 1.0, shadow, shadowIntensity );
  1958. }
  1959. #endif`,jDe=`#if NUM_SPOT_LIGHT_COORDS > 0
  1960. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  1961. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1962. #endif
  1963. #ifdef USE_SHADOWMAP
  1964. #if NUM_DIR_LIGHT_SHADOWS > 0
  1965. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  1966. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1967. struct DirectionalLightShadow {
  1968. float shadowIntensity;
  1969. float shadowBias;
  1970. float shadowNormalBias;
  1971. float shadowRadius;
  1972. vec2 shadowMapSize;
  1973. };
  1974. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1975. #endif
  1976. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1977. struct SpotLightShadow {
  1978. float shadowIntensity;
  1979. float shadowBias;
  1980. float shadowNormalBias;
  1981. float shadowRadius;
  1982. vec2 shadowMapSize;
  1983. };
  1984. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1985. #endif
  1986. #if NUM_POINT_LIGHT_SHADOWS > 0
  1987. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  1988. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1989. struct PointLightShadow {
  1990. float shadowIntensity;
  1991. float shadowBias;
  1992. float shadowNormalBias;
  1993. float shadowRadius;
  1994. vec2 shadowMapSize;
  1995. float shadowCameraNear;
  1996. float shadowCameraFar;
  1997. };
  1998. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1999. #endif
  2000. #endif`,PDe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  2001. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  2002. vec4 shadowWorldPosition;
  2003. #endif
  2004. #if defined( USE_SHADOWMAP )
  2005. #if NUM_DIR_LIGHT_SHADOWS > 0
  2006. #pragma unroll_loop_start
  2007. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  2008. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  2009. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  2010. }
  2011. #pragma unroll_loop_end
  2012. #endif
  2013. #if NUM_POINT_LIGHT_SHADOWS > 0
  2014. #pragma unroll_loop_start
  2015. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  2016. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  2017. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  2018. }
  2019. #pragma unroll_loop_end
  2020. #endif
  2021. #endif
  2022. #if NUM_SPOT_LIGHT_COORDS > 0
  2023. #pragma unroll_loop_start
  2024. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  2025. shadowWorldPosition = worldPosition;
  2026. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  2027. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  2028. #endif
  2029. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  2030. }
  2031. #pragma unroll_loop_end
  2032. #endif`,DDe=`float getShadowMask() {
  2033. float shadow = 1.0;
  2034. #ifdef USE_SHADOWMAP
  2035. #if NUM_DIR_LIGHT_SHADOWS > 0
  2036. DirectionalLightShadow directionalLight;
  2037. #pragma unroll_loop_start
  2038. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  2039. directionalLight = directionalLightShadows[ i ];
  2040. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  2041. }
  2042. #pragma unroll_loop_end
  2043. #endif
  2044. #if NUM_SPOT_LIGHT_SHADOWS > 0
  2045. SpotLightShadow spotLight;
  2046. #pragma unroll_loop_start
  2047. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  2048. spotLight = spotLightShadows[ i ];
  2049. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  2050. }
  2051. #pragma unroll_loop_end
  2052. #endif
  2053. #if NUM_POINT_LIGHT_SHADOWS > 0
  2054. PointLightShadow pointLight;
  2055. #pragma unroll_loop_start
  2056. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  2057. pointLight = pointLightShadows[ i ];
  2058. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  2059. }
  2060. #pragma unroll_loop_end
  2061. #endif
  2062. #endif
  2063. return shadow;
  2064. }`,RDe=`#ifdef USE_SKINNING
  2065. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  2066. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  2067. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  2068. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  2069. #endif`,ODe=`#ifdef USE_SKINNING
  2070. uniform mat4 bindMatrix;
  2071. uniform mat4 bindMatrixInverse;
  2072. uniform highp sampler2D boneTexture;
  2073. mat4 getBoneMatrix( const in float i ) {
  2074. int size = textureSize( boneTexture, 0 ).x;
  2075. int j = int( i ) * 4;
  2076. int x = j % size;
  2077. int y = j / size;
  2078. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  2079. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  2080. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  2081. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  2082. return mat4( v1, v2, v3, v4 );
  2083. }
  2084. #endif`,LDe=`#ifdef USE_SKINNING
  2085. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  2086. vec4 skinned = vec4( 0.0 );
  2087. skinned += boneMatX * skinVertex * skinWeight.x;
  2088. skinned += boneMatY * skinVertex * skinWeight.y;
  2089. skinned += boneMatZ * skinVertex * skinWeight.z;
  2090. skinned += boneMatW * skinVertex * skinWeight.w;
  2091. transformed = ( bindMatrixInverse * skinned ).xyz;
  2092. #endif`,FDe=`#ifdef USE_SKINNING
  2093. mat4 skinMatrix = mat4( 0.0 );
  2094. skinMatrix += skinWeight.x * boneMatX;
  2095. skinMatrix += skinWeight.y * boneMatY;
  2096. skinMatrix += skinWeight.z * boneMatZ;
  2097. skinMatrix += skinWeight.w * boneMatW;
  2098. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  2099. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  2100. #ifdef USE_TANGENT
  2101. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  2102. #endif
  2103. #endif`,IDe=`float specularStrength;
  2104. #ifdef USE_SPECULARMAP
  2105. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  2106. specularStrength = texelSpecular.r;
  2107. #else
  2108. specularStrength = 1.0;
  2109. #endif`,UDe=`#ifdef USE_SPECULARMAP
  2110. uniform sampler2D specularMap;
  2111. #endif`,zDe=`#if defined( TONE_MAPPING )
  2112. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  2113. #endif`,BDe=`#ifndef saturate
  2114. #define saturate( a ) clamp( a, 0.0, 1.0 )
  2115. #endif
  2116. uniform float toneMappingExposure;
  2117. vec3 LinearToneMapping( vec3 color ) {
  2118. return saturate( toneMappingExposure * color );
  2119. }
  2120. vec3 ReinhardToneMapping( vec3 color ) {
  2121. color *= toneMappingExposure;
  2122. return saturate( color / ( vec3( 1.0 ) + color ) );
  2123. }
  2124. vec3 CineonToneMapping( vec3 color ) {
  2125. color *= toneMappingExposure;
  2126. color = max( vec3( 0.0 ), color - 0.004 );
  2127. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  2128. }
  2129. vec3 RRTAndODTFit( vec3 v ) {
  2130. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  2131. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  2132. return a / b;
  2133. }
  2134. vec3 ACESFilmicToneMapping( vec3 color ) {
  2135. const mat3 ACESInputMat = mat3(
  2136. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  2137. vec3( 0.04823, 0.01566, 0.83777 )
  2138. );
  2139. const mat3 ACESOutputMat = mat3(
  2140. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  2141. vec3( -0.07367, -0.00605, 1.07602 )
  2142. );
  2143. color *= toneMappingExposure / 0.6;
  2144. color = ACESInputMat * color;
  2145. color = RRTAndODTFit( color );
  2146. color = ACESOutputMat * color;
  2147. return saturate( color );
  2148. }
  2149. const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
  2150. vec3( 1.6605, - 0.1246, - 0.0182 ),
  2151. vec3( - 0.5876, 1.1329, - 0.1006 ),
  2152. vec3( - 0.0728, - 0.0083, 1.1187 )
  2153. );
  2154. const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
  2155. vec3( 0.6274, 0.0691, 0.0164 ),
  2156. vec3( 0.3293, 0.9195, 0.0880 ),
  2157. vec3( 0.0433, 0.0113, 0.8956 )
  2158. );
  2159. vec3 agxDefaultContrastApprox( vec3 x ) {
  2160. vec3 x2 = x * x;
  2161. vec3 x4 = x2 * x2;
  2162. return + 15.5 * x4 * x2
  2163. - 40.14 * x4 * x
  2164. + 31.96 * x4
  2165. - 6.868 * x2 * x
  2166. + 0.4298 * x2
  2167. + 0.1191 * x
  2168. - 0.00232;
  2169. }
  2170. vec3 AgXToneMapping( vec3 color ) {
  2171. const mat3 AgXInsetMatrix = mat3(
  2172. vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
  2173. vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
  2174. vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
  2175. );
  2176. const mat3 AgXOutsetMatrix = mat3(
  2177. vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
  2178. vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
  2179. vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
  2180. );
  2181. const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
  2182. color *= toneMappingExposure;
  2183. color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
  2184. color = AgXInsetMatrix * color;
  2185. color = max( color, 1e-10 ); color = log2( color );
  2186. color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
  2187. color = clamp( color, 0.0, 1.0 );
  2188. color = agxDefaultContrastApprox( color );
  2189. color = AgXOutsetMatrix * color;
  2190. color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
  2191. color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
  2192. color = clamp( color, 0.0, 1.0 );
  2193. return color;
  2194. }
  2195. vec3 NeutralToneMapping( vec3 color ) {
  2196. const float StartCompression = 0.8 - 0.04;
  2197. const float Desaturation = 0.15;
  2198. color *= toneMappingExposure;
  2199. float x = min( color.r, min( color.g, color.b ) );
  2200. float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
  2201. color -= offset;
  2202. float peak = max( color.r, max( color.g, color.b ) );
  2203. if ( peak < StartCompression ) return color;
  2204. float d = 1. - StartCompression;
  2205. float newPeak = 1. - d * d / ( peak + d - StartCompression );
  2206. color *= newPeak / peak;
  2207. float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
  2208. return mix( color, vec3( newPeak ), g );
  2209. }
  2210. vec3 CustomToneMapping( vec3 color ) { return color; }`,$De=`#ifdef USE_TRANSMISSION
  2211. material.transmission = transmission;
  2212. material.transmissionAlpha = 1.0;
  2213. material.thickness = thickness;
  2214. material.attenuationDistance = attenuationDistance;
  2215. material.attenuationColor = attenuationColor;
  2216. #ifdef USE_TRANSMISSIONMAP
  2217. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  2218. #endif
  2219. #ifdef USE_THICKNESSMAP
  2220. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  2221. #endif
  2222. vec3 pos = vWorldPosition;
  2223. vec3 v = normalize( cameraPosition - pos );
  2224. vec3 n = inverseTransformDirection( normal, viewMatrix );
  2225. vec4 transmitted = getIBLVolumeRefraction(
  2226. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  2227. pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
  2228. material.attenuationColor, material.attenuationDistance );
  2229. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  2230. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  2231. #endif`,HDe=`#ifdef USE_TRANSMISSION
  2232. uniform float transmission;
  2233. uniform float thickness;
  2234. uniform float attenuationDistance;
  2235. uniform vec3 attenuationColor;
  2236. #ifdef USE_TRANSMISSIONMAP
  2237. uniform sampler2D transmissionMap;
  2238. #endif
  2239. #ifdef USE_THICKNESSMAP
  2240. uniform sampler2D thicknessMap;
  2241. #endif
  2242. uniform vec2 transmissionSamplerSize;
  2243. uniform sampler2D transmissionSamplerMap;
  2244. uniform mat4 modelMatrix;
  2245. uniform mat4 projectionMatrix;
  2246. varying vec3 vWorldPosition;
  2247. float w0( float a ) {
  2248. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  2249. }
  2250. float w1( float a ) {
  2251. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  2252. }
  2253. float w2( float a ){
  2254. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  2255. }
  2256. float w3( float a ) {
  2257. return ( 1.0 / 6.0 ) * ( a * a * a );
  2258. }
  2259. float g0( float a ) {
  2260. return w0( a ) + w1( a );
  2261. }
  2262. float g1( float a ) {
  2263. return w2( a ) + w3( a );
  2264. }
  2265. float h0( float a ) {
  2266. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  2267. }
  2268. float h1( float a ) {
  2269. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  2270. }
  2271. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  2272. uv = uv * texelSize.zw + 0.5;
  2273. vec2 iuv = floor( uv );
  2274. vec2 fuv = fract( uv );
  2275. float g0x = g0( fuv.x );
  2276. float g1x = g1( fuv.x );
  2277. float h0x = h0( fuv.x );
  2278. float h1x = h1( fuv.x );
  2279. float h0y = h0( fuv.y );
  2280. float h1y = h1( fuv.y );
  2281. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2282. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2283. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2284. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2285. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  2286. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  2287. }
  2288. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  2289. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  2290. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  2291. vec2 fLodSizeInv = 1.0 / fLodSize;
  2292. vec2 cLodSizeInv = 1.0 / cLodSize;
  2293. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  2294. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  2295. return mix( fSample, cSample, fract( lod ) );
  2296. }
  2297. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  2298. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  2299. vec3 modelScale;
  2300. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  2301. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  2302. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  2303. return normalize( refractionVector ) * thickness * modelScale;
  2304. }
  2305. float applyIorToRoughness( const in float roughness, const in float ior ) {
  2306. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  2307. }
  2308. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  2309. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  2310. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  2311. }
  2312. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  2313. if ( isinf( attenuationDistance ) ) {
  2314. return vec3( 1.0 );
  2315. } else {
  2316. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  2317. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  2318. }
  2319. }
  2320. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  2321. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  2322. const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
  2323. const in vec3 attenuationColor, const in float attenuationDistance ) {
  2324. vec4 transmittedLight;
  2325. vec3 transmittance;
  2326. #ifdef USE_DISPERSION
  2327. float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
  2328. vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
  2329. for ( int i = 0; i < 3; i ++ ) {
  2330. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
  2331. vec3 refractedRayExit = position + transmissionRay;
  2332. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2333. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2334. refractionCoords += 1.0;
  2335. refractionCoords /= 2.0;
  2336. vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
  2337. transmittedLight[ i ] = transmissionSample[ i ];
  2338. transmittedLight.a += transmissionSample.a;
  2339. transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
  2340. }
  2341. transmittedLight.a /= 3.0;
  2342. #else
  2343. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  2344. vec3 refractedRayExit = position + transmissionRay;
  2345. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2346. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2347. refractionCoords += 1.0;
  2348. refractionCoords /= 2.0;
  2349. transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  2350. transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  2351. #endif
  2352. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  2353. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  2354. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  2355. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  2356. }
  2357. #endif`,VDe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2358. varying vec2 vUv;
  2359. #endif
  2360. #ifdef USE_MAP
  2361. varying vec2 vMapUv;
  2362. #endif
  2363. #ifdef USE_ALPHAMAP
  2364. varying vec2 vAlphaMapUv;
  2365. #endif
  2366. #ifdef USE_LIGHTMAP
  2367. varying vec2 vLightMapUv;
  2368. #endif
  2369. #ifdef USE_AOMAP
  2370. varying vec2 vAoMapUv;
  2371. #endif
  2372. #ifdef USE_BUMPMAP
  2373. varying vec2 vBumpMapUv;
  2374. #endif
  2375. #ifdef USE_NORMALMAP
  2376. varying vec2 vNormalMapUv;
  2377. #endif
  2378. #ifdef USE_EMISSIVEMAP
  2379. varying vec2 vEmissiveMapUv;
  2380. #endif
  2381. #ifdef USE_METALNESSMAP
  2382. varying vec2 vMetalnessMapUv;
  2383. #endif
  2384. #ifdef USE_ROUGHNESSMAP
  2385. varying vec2 vRoughnessMapUv;
  2386. #endif
  2387. #ifdef USE_ANISOTROPYMAP
  2388. varying vec2 vAnisotropyMapUv;
  2389. #endif
  2390. #ifdef USE_CLEARCOATMAP
  2391. varying vec2 vClearcoatMapUv;
  2392. #endif
  2393. #ifdef USE_CLEARCOAT_NORMALMAP
  2394. varying vec2 vClearcoatNormalMapUv;
  2395. #endif
  2396. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2397. varying vec2 vClearcoatRoughnessMapUv;
  2398. #endif
  2399. #ifdef USE_IRIDESCENCEMAP
  2400. varying vec2 vIridescenceMapUv;
  2401. #endif
  2402. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2403. varying vec2 vIridescenceThicknessMapUv;
  2404. #endif
  2405. #ifdef USE_SHEEN_COLORMAP
  2406. varying vec2 vSheenColorMapUv;
  2407. #endif
  2408. #ifdef USE_SHEEN_ROUGHNESSMAP
  2409. varying vec2 vSheenRoughnessMapUv;
  2410. #endif
  2411. #ifdef USE_SPECULARMAP
  2412. varying vec2 vSpecularMapUv;
  2413. #endif
  2414. #ifdef USE_SPECULAR_COLORMAP
  2415. varying vec2 vSpecularColorMapUv;
  2416. #endif
  2417. #ifdef USE_SPECULAR_INTENSITYMAP
  2418. varying vec2 vSpecularIntensityMapUv;
  2419. #endif
  2420. #ifdef USE_TRANSMISSIONMAP
  2421. uniform mat3 transmissionMapTransform;
  2422. varying vec2 vTransmissionMapUv;
  2423. #endif
  2424. #ifdef USE_THICKNESSMAP
  2425. uniform mat3 thicknessMapTransform;
  2426. varying vec2 vThicknessMapUv;
  2427. #endif`,GDe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2428. varying vec2 vUv;
  2429. #endif
  2430. #ifdef USE_MAP
  2431. uniform mat3 mapTransform;
  2432. varying vec2 vMapUv;
  2433. #endif
  2434. #ifdef USE_ALPHAMAP
  2435. uniform mat3 alphaMapTransform;
  2436. varying vec2 vAlphaMapUv;
  2437. #endif
  2438. #ifdef USE_LIGHTMAP
  2439. uniform mat3 lightMapTransform;
  2440. varying vec2 vLightMapUv;
  2441. #endif
  2442. #ifdef USE_AOMAP
  2443. uniform mat3 aoMapTransform;
  2444. varying vec2 vAoMapUv;
  2445. #endif
  2446. #ifdef USE_BUMPMAP
  2447. uniform mat3 bumpMapTransform;
  2448. varying vec2 vBumpMapUv;
  2449. #endif
  2450. #ifdef USE_NORMALMAP
  2451. uniform mat3 normalMapTransform;
  2452. varying vec2 vNormalMapUv;
  2453. #endif
  2454. #ifdef USE_DISPLACEMENTMAP
  2455. uniform mat3 displacementMapTransform;
  2456. varying vec2 vDisplacementMapUv;
  2457. #endif
  2458. #ifdef USE_EMISSIVEMAP
  2459. uniform mat3 emissiveMapTransform;
  2460. varying vec2 vEmissiveMapUv;
  2461. #endif
  2462. #ifdef USE_METALNESSMAP
  2463. uniform mat3 metalnessMapTransform;
  2464. varying vec2 vMetalnessMapUv;
  2465. #endif
  2466. #ifdef USE_ROUGHNESSMAP
  2467. uniform mat3 roughnessMapTransform;
  2468. varying vec2 vRoughnessMapUv;
  2469. #endif
  2470. #ifdef USE_ANISOTROPYMAP
  2471. uniform mat3 anisotropyMapTransform;
  2472. varying vec2 vAnisotropyMapUv;
  2473. #endif
  2474. #ifdef USE_CLEARCOATMAP
  2475. uniform mat3 clearcoatMapTransform;
  2476. varying vec2 vClearcoatMapUv;
  2477. #endif
  2478. #ifdef USE_CLEARCOAT_NORMALMAP
  2479. uniform mat3 clearcoatNormalMapTransform;
  2480. varying vec2 vClearcoatNormalMapUv;
  2481. #endif
  2482. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2483. uniform mat3 clearcoatRoughnessMapTransform;
  2484. varying vec2 vClearcoatRoughnessMapUv;
  2485. #endif
  2486. #ifdef USE_SHEEN_COLORMAP
  2487. uniform mat3 sheenColorMapTransform;
  2488. varying vec2 vSheenColorMapUv;
  2489. #endif
  2490. #ifdef USE_SHEEN_ROUGHNESSMAP
  2491. uniform mat3 sheenRoughnessMapTransform;
  2492. varying vec2 vSheenRoughnessMapUv;
  2493. #endif
  2494. #ifdef USE_IRIDESCENCEMAP
  2495. uniform mat3 iridescenceMapTransform;
  2496. varying vec2 vIridescenceMapUv;
  2497. #endif
  2498. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2499. uniform mat3 iridescenceThicknessMapTransform;
  2500. varying vec2 vIridescenceThicknessMapUv;
  2501. #endif
  2502. #ifdef USE_SPECULARMAP
  2503. uniform mat3 specularMapTransform;
  2504. varying vec2 vSpecularMapUv;
  2505. #endif
  2506. #ifdef USE_SPECULAR_COLORMAP
  2507. uniform mat3 specularColorMapTransform;
  2508. varying vec2 vSpecularColorMapUv;
  2509. #endif
  2510. #ifdef USE_SPECULAR_INTENSITYMAP
  2511. uniform mat3 specularIntensityMapTransform;
  2512. varying vec2 vSpecularIntensityMapUv;
  2513. #endif
  2514. #ifdef USE_TRANSMISSIONMAP
  2515. uniform mat3 transmissionMapTransform;
  2516. varying vec2 vTransmissionMapUv;
  2517. #endif
  2518. #ifdef USE_THICKNESSMAP
  2519. uniform mat3 thicknessMapTransform;
  2520. varying vec2 vThicknessMapUv;
  2521. #endif`,qDe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2522. vUv = vec3( uv, 1 ).xy;
  2523. #endif
  2524. #ifdef USE_MAP
  2525. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  2526. #endif
  2527. #ifdef USE_ALPHAMAP
  2528. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  2529. #endif
  2530. #ifdef USE_LIGHTMAP
  2531. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  2532. #endif
  2533. #ifdef USE_AOMAP
  2534. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  2535. #endif
  2536. #ifdef USE_BUMPMAP
  2537. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  2538. #endif
  2539. #ifdef USE_NORMALMAP
  2540. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  2541. #endif
  2542. #ifdef USE_DISPLACEMENTMAP
  2543. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  2544. #endif
  2545. #ifdef USE_EMISSIVEMAP
  2546. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  2547. #endif
  2548. #ifdef USE_METALNESSMAP
  2549. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  2550. #endif
  2551. #ifdef USE_ROUGHNESSMAP
  2552. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  2553. #endif
  2554. #ifdef USE_ANISOTROPYMAP
  2555. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  2556. #endif
  2557. #ifdef USE_CLEARCOATMAP
  2558. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  2559. #endif
  2560. #ifdef USE_CLEARCOAT_NORMALMAP
  2561. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  2562. #endif
  2563. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2564. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  2565. #endif
  2566. #ifdef USE_IRIDESCENCEMAP
  2567. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  2568. #endif
  2569. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2570. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  2571. #endif
  2572. #ifdef USE_SHEEN_COLORMAP
  2573. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  2574. #endif
  2575. #ifdef USE_SHEEN_ROUGHNESSMAP
  2576. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  2577. #endif
  2578. #ifdef USE_SPECULARMAP
  2579. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  2580. #endif
  2581. #ifdef USE_SPECULAR_COLORMAP
  2582. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  2583. #endif
  2584. #ifdef USE_SPECULAR_INTENSITYMAP
  2585. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  2586. #endif
  2587. #ifdef USE_TRANSMISSIONMAP
  2588. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  2589. #endif
  2590. #ifdef USE_THICKNESSMAP
  2591. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  2592. #endif`,WDe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  2593. vec4 worldPosition = vec4( transformed, 1.0 );
  2594. #ifdef USE_BATCHING
  2595. worldPosition = batchingMatrix * worldPosition;
  2596. #endif
  2597. #ifdef USE_INSTANCING
  2598. worldPosition = instanceMatrix * worldPosition;
  2599. #endif
  2600. worldPosition = modelMatrix * worldPosition;
  2601. #endif`;const KDe=`varying vec2 vUv;
  2602. uniform mat3 uvTransform;
  2603. void main() {
  2604. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  2605. gl_Position = vec4( position.xy, 1.0, 1.0 );
  2606. }`,XDe=`uniform sampler2D t2D;
  2607. uniform float backgroundIntensity;
  2608. varying vec2 vUv;
  2609. void main() {
  2610. vec4 texColor = texture2D( t2D, vUv );
  2611. #ifdef DECODE_VIDEO_TEXTURE
  2612. 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 );
  2613. #endif
  2614. texColor.rgb *= backgroundIntensity;
  2615. gl_FragColor = texColor;
  2616. #include <tonemapping_fragment>
  2617. #include <colorspace_fragment>
  2618. }`,YDe=`varying vec3 vWorldDirection;
  2619. #include <common>
  2620. void main() {
  2621. vWorldDirection = transformDirection( position, modelMatrix );
  2622. #include <begin_vertex>
  2623. #include <project_vertex>
  2624. gl_Position.z = gl_Position.w;
  2625. }`,QDe=`#ifdef ENVMAP_TYPE_CUBE
  2626. uniform samplerCube envMap;
  2627. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2628. uniform sampler2D envMap;
  2629. #endif
  2630. uniform float flipEnvMap;
  2631. uniform float backgroundBlurriness;
  2632. uniform float backgroundIntensity;
  2633. uniform mat3 backgroundRotation;
  2634. varying vec3 vWorldDirection;
  2635. #include <cube_uv_reflection_fragment>
  2636. void main() {
  2637. #ifdef ENVMAP_TYPE_CUBE
  2638. vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  2639. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2640. vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
  2641. #else
  2642. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  2643. #endif
  2644. texColor.rgb *= backgroundIntensity;
  2645. gl_FragColor = texColor;
  2646. #include <tonemapping_fragment>
  2647. #include <colorspace_fragment>
  2648. }`,ZDe=`varying vec3 vWorldDirection;
  2649. #include <common>
  2650. void main() {
  2651. vWorldDirection = transformDirection( position, modelMatrix );
  2652. #include <begin_vertex>
  2653. #include <project_vertex>
  2654. gl_Position.z = gl_Position.w;
  2655. }`,JDe=`uniform samplerCube tCube;
  2656. uniform float tFlip;
  2657. uniform float opacity;
  2658. varying vec3 vWorldDirection;
  2659. void main() {
  2660. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  2661. gl_FragColor = texColor;
  2662. gl_FragColor.a *= opacity;
  2663. #include <tonemapping_fragment>
  2664. #include <colorspace_fragment>
  2665. }`,eRe=`#include <common>
  2666. #include <batching_pars_vertex>
  2667. #include <uv_pars_vertex>
  2668. #include <displacementmap_pars_vertex>
  2669. #include <morphtarget_pars_vertex>
  2670. #include <skinning_pars_vertex>
  2671. #include <logdepthbuf_pars_vertex>
  2672. #include <clipping_planes_pars_vertex>
  2673. varying vec2 vHighPrecisionZW;
  2674. void main() {
  2675. #include <uv_vertex>
  2676. #include <batching_vertex>
  2677. #include <skinbase_vertex>
  2678. #include <morphinstance_vertex>
  2679. #ifdef USE_DISPLACEMENTMAP
  2680. #include <beginnormal_vertex>
  2681. #include <morphnormal_vertex>
  2682. #include <skinnormal_vertex>
  2683. #endif
  2684. #include <begin_vertex>
  2685. #include <morphtarget_vertex>
  2686. #include <skinning_vertex>
  2687. #include <displacementmap_vertex>
  2688. #include <project_vertex>
  2689. #include <logdepthbuf_vertex>
  2690. #include <clipping_planes_vertex>
  2691. vHighPrecisionZW = gl_Position.zw;
  2692. }`,tRe=`#if DEPTH_PACKING == 3200
  2693. uniform float opacity;
  2694. #endif
  2695. #include <common>
  2696. #include <packing>
  2697. #include <uv_pars_fragment>
  2698. #include <map_pars_fragment>
  2699. #include <alphamap_pars_fragment>
  2700. #include <alphatest_pars_fragment>
  2701. #include <alphahash_pars_fragment>
  2702. #include <logdepthbuf_pars_fragment>
  2703. #include <clipping_planes_pars_fragment>
  2704. varying vec2 vHighPrecisionZW;
  2705. void main() {
  2706. vec4 diffuseColor = vec4( 1.0 );
  2707. #include <clipping_planes_fragment>
  2708. #if DEPTH_PACKING == 3200
  2709. diffuseColor.a = opacity;
  2710. #endif
  2711. #include <map_fragment>
  2712. #include <alphamap_fragment>
  2713. #include <alphatest_fragment>
  2714. #include <alphahash_fragment>
  2715. #include <logdepthbuf_fragment>
  2716. #ifdef USE_REVERSED_DEPTH_BUFFER
  2717. float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
  2718. #else
  2719. float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
  2720. #endif
  2721. #if DEPTH_PACKING == 3200
  2722. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  2723. #elif DEPTH_PACKING == 3201
  2724. gl_FragColor = packDepthToRGBA( fragCoordZ );
  2725. #elif DEPTH_PACKING == 3202
  2726. gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
  2727. #elif DEPTH_PACKING == 3203
  2728. gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
  2729. #endif
  2730. }`,nRe=`#define DISTANCE
  2731. varying vec3 vWorldPosition;
  2732. #include <common>
  2733. #include <batching_pars_vertex>
  2734. #include <uv_pars_vertex>
  2735. #include <displacementmap_pars_vertex>
  2736. #include <morphtarget_pars_vertex>
  2737. #include <skinning_pars_vertex>
  2738. #include <clipping_planes_pars_vertex>
  2739. void main() {
  2740. #include <uv_vertex>
  2741. #include <batching_vertex>
  2742. #include <skinbase_vertex>
  2743. #include <morphinstance_vertex>
  2744. #ifdef USE_DISPLACEMENTMAP
  2745. #include <beginnormal_vertex>
  2746. #include <morphnormal_vertex>
  2747. #include <skinnormal_vertex>
  2748. #endif
  2749. #include <begin_vertex>
  2750. #include <morphtarget_vertex>
  2751. #include <skinning_vertex>
  2752. #include <displacementmap_vertex>
  2753. #include <project_vertex>
  2754. #include <worldpos_vertex>
  2755. #include <clipping_planes_vertex>
  2756. vWorldPosition = worldPosition.xyz;
  2757. }`,rRe=`#define DISTANCE
  2758. uniform vec3 referencePosition;
  2759. uniform float nearDistance;
  2760. uniform float farDistance;
  2761. varying vec3 vWorldPosition;
  2762. #include <common>
  2763. #include <packing>
  2764. #include <uv_pars_fragment>
  2765. #include <map_pars_fragment>
  2766. #include <alphamap_pars_fragment>
  2767. #include <alphatest_pars_fragment>
  2768. #include <alphahash_pars_fragment>
  2769. #include <clipping_planes_pars_fragment>
  2770. void main () {
  2771. vec4 diffuseColor = vec4( 1.0 );
  2772. #include <clipping_planes_fragment>
  2773. #include <map_fragment>
  2774. #include <alphamap_fragment>
  2775. #include <alphatest_fragment>
  2776. #include <alphahash_fragment>
  2777. float dist = length( vWorldPosition - referencePosition );
  2778. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  2779. dist = saturate( dist );
  2780. gl_FragColor = packDepthToRGBA( dist );
  2781. }`,iRe=`varying vec3 vWorldDirection;
  2782. #include <common>
  2783. void main() {
  2784. vWorldDirection = transformDirection( position, modelMatrix );
  2785. #include <begin_vertex>
  2786. #include <project_vertex>
  2787. }`,aRe=`uniform sampler2D tEquirect;
  2788. varying vec3 vWorldDirection;
  2789. #include <common>
  2790. void main() {
  2791. vec3 direction = normalize( vWorldDirection );
  2792. vec2 sampleUV = equirectUv( direction );
  2793. gl_FragColor = texture2D( tEquirect, sampleUV );
  2794. #include <tonemapping_fragment>
  2795. #include <colorspace_fragment>
  2796. }`,sRe=`uniform float scale;
  2797. attribute float lineDistance;
  2798. varying float vLineDistance;
  2799. #include <common>
  2800. #include <uv_pars_vertex>
  2801. #include <color_pars_vertex>
  2802. #include <fog_pars_vertex>
  2803. #include <morphtarget_pars_vertex>
  2804. #include <logdepthbuf_pars_vertex>
  2805. #include <clipping_planes_pars_vertex>
  2806. void main() {
  2807. vLineDistance = scale * lineDistance;
  2808. #include <uv_vertex>
  2809. #include <color_vertex>
  2810. #include <morphinstance_vertex>
  2811. #include <morphcolor_vertex>
  2812. #include <begin_vertex>
  2813. #include <morphtarget_vertex>
  2814. #include <project_vertex>
  2815. #include <logdepthbuf_vertex>
  2816. #include <clipping_planes_vertex>
  2817. #include <fog_vertex>
  2818. }`,oRe=`uniform vec3 diffuse;
  2819. uniform float opacity;
  2820. uniform float dashSize;
  2821. uniform float totalSize;
  2822. varying float vLineDistance;
  2823. #include <common>
  2824. #include <color_pars_fragment>
  2825. #include <uv_pars_fragment>
  2826. #include <map_pars_fragment>
  2827. #include <fog_pars_fragment>
  2828. #include <logdepthbuf_pars_fragment>
  2829. #include <clipping_planes_pars_fragment>
  2830. void main() {
  2831. vec4 diffuseColor = vec4( diffuse, opacity );
  2832. #include <clipping_planes_fragment>
  2833. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  2834. discard;
  2835. }
  2836. vec3 outgoingLight = vec3( 0.0 );
  2837. #include <logdepthbuf_fragment>
  2838. #include <map_fragment>
  2839. #include <color_fragment>
  2840. outgoingLight = diffuseColor.rgb;
  2841. #include <opaque_fragment>
  2842. #include <tonemapping_fragment>
  2843. #include <colorspace_fragment>
  2844. #include <fog_fragment>
  2845. #include <premultiplied_alpha_fragment>
  2846. }`,lRe=`#include <common>
  2847. #include <batching_pars_vertex>
  2848. #include <uv_pars_vertex>
  2849. #include <envmap_pars_vertex>
  2850. #include <color_pars_vertex>
  2851. #include <fog_pars_vertex>
  2852. #include <morphtarget_pars_vertex>
  2853. #include <skinning_pars_vertex>
  2854. #include <logdepthbuf_pars_vertex>
  2855. #include <clipping_planes_pars_vertex>
  2856. void main() {
  2857. #include <uv_vertex>
  2858. #include <color_vertex>
  2859. #include <morphinstance_vertex>
  2860. #include <morphcolor_vertex>
  2861. #include <batching_vertex>
  2862. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  2863. #include <beginnormal_vertex>
  2864. #include <morphnormal_vertex>
  2865. #include <skinbase_vertex>
  2866. #include <skinnormal_vertex>
  2867. #include <defaultnormal_vertex>
  2868. #endif
  2869. #include <begin_vertex>
  2870. #include <morphtarget_vertex>
  2871. #include <skinning_vertex>
  2872. #include <project_vertex>
  2873. #include <logdepthbuf_vertex>
  2874. #include <clipping_planes_vertex>
  2875. #include <worldpos_vertex>
  2876. #include <envmap_vertex>
  2877. #include <fog_vertex>
  2878. }`,cRe=`uniform vec3 diffuse;
  2879. uniform float opacity;
  2880. #ifndef FLAT_SHADED
  2881. varying vec3 vNormal;
  2882. #endif
  2883. #include <common>
  2884. #include <dithering_pars_fragment>
  2885. #include <color_pars_fragment>
  2886. #include <uv_pars_fragment>
  2887. #include <map_pars_fragment>
  2888. #include <alphamap_pars_fragment>
  2889. #include <alphatest_pars_fragment>
  2890. #include <alphahash_pars_fragment>
  2891. #include <aomap_pars_fragment>
  2892. #include <lightmap_pars_fragment>
  2893. #include <envmap_common_pars_fragment>
  2894. #include <envmap_pars_fragment>
  2895. #include <fog_pars_fragment>
  2896. #include <specularmap_pars_fragment>
  2897. #include <logdepthbuf_pars_fragment>
  2898. #include <clipping_planes_pars_fragment>
  2899. void main() {
  2900. vec4 diffuseColor = vec4( diffuse, opacity );
  2901. #include <clipping_planes_fragment>
  2902. #include <logdepthbuf_fragment>
  2903. #include <map_fragment>
  2904. #include <color_fragment>
  2905. #include <alphamap_fragment>
  2906. #include <alphatest_fragment>
  2907. #include <alphahash_fragment>
  2908. #include <specularmap_fragment>
  2909. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2910. #ifdef USE_LIGHTMAP
  2911. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  2912. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  2913. #else
  2914. reflectedLight.indirectDiffuse += vec3( 1.0 );
  2915. #endif
  2916. #include <aomap_fragment>
  2917. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  2918. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  2919. #include <envmap_fragment>
  2920. #include <opaque_fragment>
  2921. #include <tonemapping_fragment>
  2922. #include <colorspace_fragment>
  2923. #include <fog_fragment>
  2924. #include <premultiplied_alpha_fragment>
  2925. #include <dithering_fragment>
  2926. }`,uRe=`#define LAMBERT
  2927. varying vec3 vViewPosition;
  2928. #include <common>
  2929. #include <batching_pars_vertex>
  2930. #include <uv_pars_vertex>
  2931. #include <displacementmap_pars_vertex>
  2932. #include <envmap_pars_vertex>
  2933. #include <color_pars_vertex>
  2934. #include <fog_pars_vertex>
  2935. #include <normal_pars_vertex>
  2936. #include <morphtarget_pars_vertex>
  2937. #include <skinning_pars_vertex>
  2938. #include <shadowmap_pars_vertex>
  2939. #include <logdepthbuf_pars_vertex>
  2940. #include <clipping_planes_pars_vertex>
  2941. void main() {
  2942. #include <uv_vertex>
  2943. #include <color_vertex>
  2944. #include <morphinstance_vertex>
  2945. #include <morphcolor_vertex>
  2946. #include <batching_vertex>
  2947. #include <beginnormal_vertex>
  2948. #include <morphnormal_vertex>
  2949. #include <skinbase_vertex>
  2950. #include <skinnormal_vertex>
  2951. #include <defaultnormal_vertex>
  2952. #include <normal_vertex>
  2953. #include <begin_vertex>
  2954. #include <morphtarget_vertex>
  2955. #include <skinning_vertex>
  2956. #include <displacementmap_vertex>
  2957. #include <project_vertex>
  2958. #include <logdepthbuf_vertex>
  2959. #include <clipping_planes_vertex>
  2960. vViewPosition = - mvPosition.xyz;
  2961. #include <worldpos_vertex>
  2962. #include <envmap_vertex>
  2963. #include <shadowmap_vertex>
  2964. #include <fog_vertex>
  2965. }`,dRe=`#define LAMBERT
  2966. uniform vec3 diffuse;
  2967. uniform vec3 emissive;
  2968. uniform float opacity;
  2969. #include <common>
  2970. #include <packing>
  2971. #include <dithering_pars_fragment>
  2972. #include <color_pars_fragment>
  2973. #include <uv_pars_fragment>
  2974. #include <map_pars_fragment>
  2975. #include <alphamap_pars_fragment>
  2976. #include <alphatest_pars_fragment>
  2977. #include <alphahash_pars_fragment>
  2978. #include <aomap_pars_fragment>
  2979. #include <lightmap_pars_fragment>
  2980. #include <emissivemap_pars_fragment>
  2981. #include <envmap_common_pars_fragment>
  2982. #include <envmap_pars_fragment>
  2983. #include <fog_pars_fragment>
  2984. #include <bsdfs>
  2985. #include <lights_pars_begin>
  2986. #include <normal_pars_fragment>
  2987. #include <lights_lambert_pars_fragment>
  2988. #include <shadowmap_pars_fragment>
  2989. #include <bumpmap_pars_fragment>
  2990. #include <normalmap_pars_fragment>
  2991. #include <specularmap_pars_fragment>
  2992. #include <logdepthbuf_pars_fragment>
  2993. #include <clipping_planes_pars_fragment>
  2994. void main() {
  2995. vec4 diffuseColor = vec4( diffuse, opacity );
  2996. #include <clipping_planes_fragment>
  2997. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2998. vec3 totalEmissiveRadiance = emissive;
  2999. #include <logdepthbuf_fragment>
  3000. #include <map_fragment>
  3001. #include <color_fragment>
  3002. #include <alphamap_fragment>
  3003. #include <alphatest_fragment>
  3004. #include <alphahash_fragment>
  3005. #include <specularmap_fragment>
  3006. #include <normal_fragment_begin>
  3007. #include <normal_fragment_maps>
  3008. #include <emissivemap_fragment>
  3009. #include <lights_lambert_fragment>
  3010. #include <lights_fragment_begin>
  3011. #include <lights_fragment_maps>
  3012. #include <lights_fragment_end>
  3013. #include <aomap_fragment>
  3014. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  3015. #include <envmap_fragment>
  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. }`,hRe=`#define MATCAP
  3023. varying vec3 vViewPosition;
  3024. #include <common>
  3025. #include <batching_pars_vertex>
  3026. #include <uv_pars_vertex>
  3027. #include <color_pars_vertex>
  3028. #include <displacementmap_pars_vertex>
  3029. #include <fog_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 <color_vertex>
  3038. #include <morphinstance_vertex>
  3039. #include <morphcolor_vertex>
  3040. #include <batching_vertex>
  3041. #include <beginnormal_vertex>
  3042. #include <morphnormal_vertex>
  3043. #include <skinbase_vertex>
  3044. #include <skinnormal_vertex>
  3045. #include <defaultnormal_vertex>
  3046. #include <normal_vertex>
  3047. #include <begin_vertex>
  3048. #include <morphtarget_vertex>
  3049. #include <skinning_vertex>
  3050. #include <displacementmap_vertex>
  3051. #include <project_vertex>
  3052. #include <logdepthbuf_vertex>
  3053. #include <clipping_planes_vertex>
  3054. #include <fog_vertex>
  3055. vViewPosition = - mvPosition.xyz;
  3056. }`,fRe=`#define MATCAP
  3057. uniform vec3 diffuse;
  3058. uniform float opacity;
  3059. uniform sampler2D matcap;
  3060. varying vec3 vViewPosition;
  3061. #include <common>
  3062. #include <dithering_pars_fragment>
  3063. #include <color_pars_fragment>
  3064. #include <uv_pars_fragment>
  3065. #include <map_pars_fragment>
  3066. #include <alphamap_pars_fragment>
  3067. #include <alphatest_pars_fragment>
  3068. #include <alphahash_pars_fragment>
  3069. #include <fog_pars_fragment>
  3070. #include <normal_pars_fragment>
  3071. #include <bumpmap_pars_fragment>
  3072. #include <normalmap_pars_fragment>
  3073. #include <logdepthbuf_pars_fragment>
  3074. #include <clipping_planes_pars_fragment>
  3075. void main() {
  3076. vec4 diffuseColor = vec4( diffuse, opacity );
  3077. #include <clipping_planes_fragment>
  3078. #include <logdepthbuf_fragment>
  3079. #include <map_fragment>
  3080. #include <color_fragment>
  3081. #include <alphamap_fragment>
  3082. #include <alphatest_fragment>
  3083. #include <alphahash_fragment>
  3084. #include <normal_fragment_begin>
  3085. #include <normal_fragment_maps>
  3086. vec3 viewDir = normalize( vViewPosition );
  3087. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  3088. vec3 y = cross( viewDir, x );
  3089. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  3090. #ifdef USE_MATCAP
  3091. vec4 matcapColor = texture2D( matcap, uv );
  3092. #else
  3093. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  3094. #endif
  3095. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  3096. #include <opaque_fragment>
  3097. #include <tonemapping_fragment>
  3098. #include <colorspace_fragment>
  3099. #include <fog_fragment>
  3100. #include <premultiplied_alpha_fragment>
  3101. #include <dithering_fragment>
  3102. }`,mRe=`#define NORMAL
  3103. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3104. varying vec3 vViewPosition;
  3105. #endif
  3106. #include <common>
  3107. #include <batching_pars_vertex>
  3108. #include <uv_pars_vertex>
  3109. #include <displacementmap_pars_vertex>
  3110. #include <normal_pars_vertex>
  3111. #include <morphtarget_pars_vertex>
  3112. #include <skinning_pars_vertex>
  3113. #include <logdepthbuf_pars_vertex>
  3114. #include <clipping_planes_pars_vertex>
  3115. void main() {
  3116. #include <uv_vertex>
  3117. #include <batching_vertex>
  3118. #include <beginnormal_vertex>
  3119. #include <morphinstance_vertex>
  3120. #include <morphnormal_vertex>
  3121. #include <skinbase_vertex>
  3122. #include <skinnormal_vertex>
  3123. #include <defaultnormal_vertex>
  3124. #include <normal_vertex>
  3125. #include <begin_vertex>
  3126. #include <morphtarget_vertex>
  3127. #include <skinning_vertex>
  3128. #include <displacementmap_vertex>
  3129. #include <project_vertex>
  3130. #include <logdepthbuf_vertex>
  3131. #include <clipping_planes_vertex>
  3132. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3133. vViewPosition = - mvPosition.xyz;
  3134. #endif
  3135. }`,pRe=`#define NORMAL
  3136. uniform float opacity;
  3137. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3138. varying vec3 vViewPosition;
  3139. #endif
  3140. #include <packing>
  3141. #include <uv_pars_fragment>
  3142. #include <normal_pars_fragment>
  3143. #include <bumpmap_pars_fragment>
  3144. #include <normalmap_pars_fragment>
  3145. #include <logdepthbuf_pars_fragment>
  3146. #include <clipping_planes_pars_fragment>
  3147. void main() {
  3148. vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
  3149. #include <clipping_planes_fragment>
  3150. #include <logdepthbuf_fragment>
  3151. #include <normal_fragment_begin>
  3152. #include <normal_fragment_maps>
  3153. gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
  3154. #ifdef OPAQUE
  3155. gl_FragColor.a = 1.0;
  3156. #endif
  3157. }`,gRe=`#define PHONG
  3158. varying vec3 vViewPosition;
  3159. #include <common>
  3160. #include <batching_pars_vertex>
  3161. #include <uv_pars_vertex>
  3162. #include <displacementmap_pars_vertex>
  3163. #include <envmap_pars_vertex>
  3164. #include <color_pars_vertex>
  3165. #include <fog_pars_vertex>
  3166. #include <normal_pars_vertex>
  3167. #include <morphtarget_pars_vertex>
  3168. #include <skinning_pars_vertex>
  3169. #include <shadowmap_pars_vertex>
  3170. #include <logdepthbuf_pars_vertex>
  3171. #include <clipping_planes_pars_vertex>
  3172. void main() {
  3173. #include <uv_vertex>
  3174. #include <color_vertex>
  3175. #include <morphcolor_vertex>
  3176. #include <batching_vertex>
  3177. #include <beginnormal_vertex>
  3178. #include <morphinstance_vertex>
  3179. #include <morphnormal_vertex>
  3180. #include <skinbase_vertex>
  3181. #include <skinnormal_vertex>
  3182. #include <defaultnormal_vertex>
  3183. #include <normal_vertex>
  3184. #include <begin_vertex>
  3185. #include <morphtarget_vertex>
  3186. #include <skinning_vertex>
  3187. #include <displacementmap_vertex>
  3188. #include <project_vertex>
  3189. #include <logdepthbuf_vertex>
  3190. #include <clipping_planes_vertex>
  3191. vViewPosition = - mvPosition.xyz;
  3192. #include <worldpos_vertex>
  3193. #include <envmap_vertex>
  3194. #include <shadowmap_vertex>
  3195. #include <fog_vertex>
  3196. }`,xRe=`#define PHONG
  3197. uniform vec3 diffuse;
  3198. uniform vec3 emissive;
  3199. uniform vec3 specular;
  3200. uniform float shininess;
  3201. uniform float opacity;
  3202. #include <common>
  3203. #include <packing>
  3204. #include <dithering_pars_fragment>
  3205. #include <color_pars_fragment>
  3206. #include <uv_pars_fragment>
  3207. #include <map_pars_fragment>
  3208. #include <alphamap_pars_fragment>
  3209. #include <alphatest_pars_fragment>
  3210. #include <alphahash_pars_fragment>
  3211. #include <aomap_pars_fragment>
  3212. #include <lightmap_pars_fragment>
  3213. #include <emissivemap_pars_fragment>
  3214. #include <envmap_common_pars_fragment>
  3215. #include <envmap_pars_fragment>
  3216. #include <fog_pars_fragment>
  3217. #include <bsdfs>
  3218. #include <lights_pars_begin>
  3219. #include <normal_pars_fragment>
  3220. #include <lights_phong_pars_fragment>
  3221. #include <shadowmap_pars_fragment>
  3222. #include <bumpmap_pars_fragment>
  3223. #include <normalmap_pars_fragment>
  3224. #include <specularmap_pars_fragment>
  3225. #include <logdepthbuf_pars_fragment>
  3226. #include <clipping_planes_pars_fragment>
  3227. void main() {
  3228. vec4 diffuseColor = vec4( diffuse, opacity );
  3229. #include <clipping_planes_fragment>
  3230. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3231. vec3 totalEmissiveRadiance = emissive;
  3232. #include <logdepthbuf_fragment>
  3233. #include <map_fragment>
  3234. #include <color_fragment>
  3235. #include <alphamap_fragment>
  3236. #include <alphatest_fragment>
  3237. #include <alphahash_fragment>
  3238. #include <specularmap_fragment>
  3239. #include <normal_fragment_begin>
  3240. #include <normal_fragment_maps>
  3241. #include <emissivemap_fragment>
  3242. #include <lights_phong_fragment>
  3243. #include <lights_fragment_begin>
  3244. #include <lights_fragment_maps>
  3245. #include <lights_fragment_end>
  3246. #include <aomap_fragment>
  3247. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  3248. #include <envmap_fragment>
  3249. #include <opaque_fragment>
  3250. #include <tonemapping_fragment>
  3251. #include <colorspace_fragment>
  3252. #include <fog_fragment>
  3253. #include <premultiplied_alpha_fragment>
  3254. #include <dithering_fragment>
  3255. }`,bRe=`#define STANDARD
  3256. varying vec3 vViewPosition;
  3257. #ifdef USE_TRANSMISSION
  3258. varying vec3 vWorldPosition;
  3259. #endif
  3260. #include <common>
  3261. #include <batching_pars_vertex>
  3262. #include <uv_pars_vertex>
  3263. #include <displacementmap_pars_vertex>
  3264. #include <color_pars_vertex>
  3265. #include <fog_pars_vertex>
  3266. #include <normal_pars_vertex>
  3267. #include <morphtarget_pars_vertex>
  3268. #include <skinning_pars_vertex>
  3269. #include <shadowmap_pars_vertex>
  3270. #include <logdepthbuf_pars_vertex>
  3271. #include <clipping_planes_pars_vertex>
  3272. void main() {
  3273. #include <uv_vertex>
  3274. #include <color_vertex>
  3275. #include <morphinstance_vertex>
  3276. #include <morphcolor_vertex>
  3277. #include <batching_vertex>
  3278. #include <beginnormal_vertex>
  3279. #include <morphnormal_vertex>
  3280. #include <skinbase_vertex>
  3281. #include <skinnormal_vertex>
  3282. #include <defaultnormal_vertex>
  3283. #include <normal_vertex>
  3284. #include <begin_vertex>
  3285. #include <morphtarget_vertex>
  3286. #include <skinning_vertex>
  3287. #include <displacementmap_vertex>
  3288. #include <project_vertex>
  3289. #include <logdepthbuf_vertex>
  3290. #include <clipping_planes_vertex>
  3291. vViewPosition = - mvPosition.xyz;
  3292. #include <worldpos_vertex>
  3293. #include <shadowmap_vertex>
  3294. #include <fog_vertex>
  3295. #ifdef USE_TRANSMISSION
  3296. vWorldPosition = worldPosition.xyz;
  3297. #endif
  3298. }`,yRe=`#define STANDARD
  3299. #ifdef PHYSICAL
  3300. #define IOR
  3301. #define USE_SPECULAR
  3302. #endif
  3303. uniform vec3 diffuse;
  3304. uniform vec3 emissive;
  3305. uniform float roughness;
  3306. uniform float metalness;
  3307. uniform float opacity;
  3308. #ifdef IOR
  3309. uniform float ior;
  3310. #endif
  3311. #ifdef USE_SPECULAR
  3312. uniform float specularIntensity;
  3313. uniform vec3 specularColor;
  3314. #ifdef USE_SPECULAR_COLORMAP
  3315. uniform sampler2D specularColorMap;
  3316. #endif
  3317. #ifdef USE_SPECULAR_INTENSITYMAP
  3318. uniform sampler2D specularIntensityMap;
  3319. #endif
  3320. #endif
  3321. #ifdef USE_CLEARCOAT
  3322. uniform float clearcoat;
  3323. uniform float clearcoatRoughness;
  3324. #endif
  3325. #ifdef USE_DISPERSION
  3326. uniform float dispersion;
  3327. #endif
  3328. #ifdef USE_IRIDESCENCE
  3329. uniform float iridescence;
  3330. uniform float iridescenceIOR;
  3331. uniform float iridescenceThicknessMinimum;
  3332. uniform float iridescenceThicknessMaximum;
  3333. #endif
  3334. #ifdef USE_SHEEN
  3335. uniform vec3 sheenColor;
  3336. uniform float sheenRoughness;
  3337. #ifdef USE_SHEEN_COLORMAP
  3338. uniform sampler2D sheenColorMap;
  3339. #endif
  3340. #ifdef USE_SHEEN_ROUGHNESSMAP
  3341. uniform sampler2D sheenRoughnessMap;
  3342. #endif
  3343. #endif
  3344. #ifdef USE_ANISOTROPY
  3345. uniform vec2 anisotropyVector;
  3346. #ifdef USE_ANISOTROPYMAP
  3347. uniform sampler2D anisotropyMap;
  3348. #endif
  3349. #endif
  3350. varying vec3 vViewPosition;
  3351. #include <common>
  3352. #include <packing>
  3353. #include <dithering_pars_fragment>
  3354. #include <color_pars_fragment>
  3355. #include <uv_pars_fragment>
  3356. #include <map_pars_fragment>
  3357. #include <alphamap_pars_fragment>
  3358. #include <alphatest_pars_fragment>
  3359. #include <alphahash_pars_fragment>
  3360. #include <aomap_pars_fragment>
  3361. #include <lightmap_pars_fragment>
  3362. #include <emissivemap_pars_fragment>
  3363. #include <iridescence_fragment>
  3364. #include <cube_uv_reflection_fragment>
  3365. #include <envmap_common_pars_fragment>
  3366. #include <envmap_physical_pars_fragment>
  3367. #include <fog_pars_fragment>
  3368. #include <lights_pars_begin>
  3369. #include <normal_pars_fragment>
  3370. #include <lights_physical_pars_fragment>
  3371. #include <transmission_pars_fragment>
  3372. #include <shadowmap_pars_fragment>
  3373. #include <bumpmap_pars_fragment>
  3374. #include <normalmap_pars_fragment>
  3375. #include <clearcoat_pars_fragment>
  3376. #include <iridescence_pars_fragment>
  3377. #include <roughnessmap_pars_fragment>
  3378. #include <metalnessmap_pars_fragment>
  3379. #include <logdepthbuf_pars_fragment>
  3380. #include <clipping_planes_pars_fragment>
  3381. void main() {
  3382. vec4 diffuseColor = vec4( diffuse, opacity );
  3383. #include <clipping_planes_fragment>
  3384. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3385. vec3 totalEmissiveRadiance = emissive;
  3386. #include <logdepthbuf_fragment>
  3387. #include <map_fragment>
  3388. #include <color_fragment>
  3389. #include <alphamap_fragment>
  3390. #include <alphatest_fragment>
  3391. #include <alphahash_fragment>
  3392. #include <roughnessmap_fragment>
  3393. #include <metalnessmap_fragment>
  3394. #include <normal_fragment_begin>
  3395. #include <normal_fragment_maps>
  3396. #include <clearcoat_normal_fragment_begin>
  3397. #include <clearcoat_normal_fragment_maps>
  3398. #include <emissivemap_fragment>
  3399. #include <lights_physical_fragment>
  3400. #include <lights_fragment_begin>
  3401. #include <lights_fragment_maps>
  3402. #include <lights_fragment_end>
  3403. #include <aomap_fragment>
  3404. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  3405. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  3406. #include <transmission_fragment>
  3407. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  3408. #ifdef USE_SHEEN
  3409. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  3410. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  3411. #endif
  3412. #ifdef USE_CLEARCOAT
  3413. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  3414. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  3415. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  3416. #endif
  3417. #include <opaque_fragment>
  3418. #include <tonemapping_fragment>
  3419. #include <colorspace_fragment>
  3420. #include <fog_fragment>
  3421. #include <premultiplied_alpha_fragment>
  3422. #include <dithering_fragment>
  3423. }`,vRe=`#define TOON
  3424. varying vec3 vViewPosition;
  3425. #include <common>
  3426. #include <batching_pars_vertex>
  3427. #include <uv_pars_vertex>
  3428. #include <displacementmap_pars_vertex>
  3429. #include <color_pars_vertex>
  3430. #include <fog_pars_vertex>
  3431. #include <normal_pars_vertex>
  3432. #include <morphtarget_pars_vertex>
  3433. #include <skinning_pars_vertex>
  3434. #include <shadowmap_pars_vertex>
  3435. #include <logdepthbuf_pars_vertex>
  3436. #include <clipping_planes_pars_vertex>
  3437. void main() {
  3438. #include <uv_vertex>
  3439. #include <color_vertex>
  3440. #include <morphinstance_vertex>
  3441. #include <morphcolor_vertex>
  3442. #include <batching_vertex>
  3443. #include <beginnormal_vertex>
  3444. #include <morphnormal_vertex>
  3445. #include <skinbase_vertex>
  3446. #include <skinnormal_vertex>
  3447. #include <defaultnormal_vertex>
  3448. #include <normal_vertex>
  3449. #include <begin_vertex>
  3450. #include <morphtarget_vertex>
  3451. #include <skinning_vertex>
  3452. #include <displacementmap_vertex>
  3453. #include <project_vertex>
  3454. #include <logdepthbuf_vertex>
  3455. #include <clipping_planes_vertex>
  3456. vViewPosition = - mvPosition.xyz;
  3457. #include <worldpos_vertex>
  3458. #include <shadowmap_vertex>
  3459. #include <fog_vertex>
  3460. }`,wRe=`#define TOON
  3461. uniform vec3 diffuse;
  3462. uniform vec3 emissive;
  3463. uniform float opacity;
  3464. #include <common>
  3465. #include <packing>
  3466. #include <dithering_pars_fragment>
  3467. #include <color_pars_fragment>
  3468. #include <uv_pars_fragment>
  3469. #include <map_pars_fragment>
  3470. #include <alphamap_pars_fragment>
  3471. #include <alphatest_pars_fragment>
  3472. #include <alphahash_pars_fragment>
  3473. #include <aomap_pars_fragment>
  3474. #include <lightmap_pars_fragment>
  3475. #include <emissivemap_pars_fragment>
  3476. #include <gradientmap_pars_fragment>
  3477. #include <fog_pars_fragment>
  3478. #include <bsdfs>
  3479. #include <lights_pars_begin>
  3480. #include <normal_pars_fragment>
  3481. #include <lights_toon_pars_fragment>
  3482. #include <shadowmap_pars_fragment>
  3483. #include <bumpmap_pars_fragment>
  3484. #include <normalmap_pars_fragment>
  3485. #include <logdepthbuf_pars_fragment>
  3486. #include <clipping_planes_pars_fragment>
  3487. void main() {
  3488. vec4 diffuseColor = vec4( diffuse, opacity );
  3489. #include <clipping_planes_fragment>
  3490. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3491. vec3 totalEmissiveRadiance = emissive;
  3492. #include <logdepthbuf_fragment>
  3493. #include <map_fragment>
  3494. #include <color_fragment>
  3495. #include <alphamap_fragment>
  3496. #include <alphatest_fragment>
  3497. #include <alphahash_fragment>
  3498. #include <normal_fragment_begin>
  3499. #include <normal_fragment_maps>
  3500. #include <emissivemap_fragment>
  3501. #include <lights_toon_fragment>
  3502. #include <lights_fragment_begin>
  3503. #include <lights_fragment_maps>
  3504. #include <lights_fragment_end>
  3505. #include <aomap_fragment>
  3506. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  3507. #include <opaque_fragment>
  3508. #include <tonemapping_fragment>
  3509. #include <colorspace_fragment>
  3510. #include <fog_fragment>
  3511. #include <premultiplied_alpha_fragment>
  3512. #include <dithering_fragment>
  3513. }`,_Re=`uniform float size;
  3514. uniform float scale;
  3515. #include <common>
  3516. #include <color_pars_vertex>
  3517. #include <fog_pars_vertex>
  3518. #include <morphtarget_pars_vertex>
  3519. #include <logdepthbuf_pars_vertex>
  3520. #include <clipping_planes_pars_vertex>
  3521. #ifdef USE_POINTS_UV
  3522. varying vec2 vUv;
  3523. uniform mat3 uvTransform;
  3524. #endif
  3525. void main() {
  3526. #ifdef USE_POINTS_UV
  3527. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  3528. #endif
  3529. #include <color_vertex>
  3530. #include <morphinstance_vertex>
  3531. #include <morphcolor_vertex>
  3532. #include <begin_vertex>
  3533. #include <morphtarget_vertex>
  3534. #include <project_vertex>
  3535. gl_PointSize = size;
  3536. #ifdef USE_SIZEATTENUATION
  3537. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3538. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  3539. #endif
  3540. #include <logdepthbuf_vertex>
  3541. #include <clipping_planes_vertex>
  3542. #include <worldpos_vertex>
  3543. #include <fog_vertex>
  3544. }`,SRe=`uniform vec3 diffuse;
  3545. uniform float opacity;
  3546. #include <common>
  3547. #include <color_pars_fragment>
  3548. #include <map_particle_pars_fragment>
  3549. #include <alphatest_pars_fragment>
  3550. #include <alphahash_pars_fragment>
  3551. #include <fog_pars_fragment>
  3552. #include <logdepthbuf_pars_fragment>
  3553. #include <clipping_planes_pars_fragment>
  3554. void main() {
  3555. vec4 diffuseColor = vec4( diffuse, opacity );
  3556. #include <clipping_planes_fragment>
  3557. vec3 outgoingLight = vec3( 0.0 );
  3558. #include <logdepthbuf_fragment>
  3559. #include <map_particle_fragment>
  3560. #include <color_fragment>
  3561. #include <alphatest_fragment>
  3562. #include <alphahash_fragment>
  3563. outgoingLight = diffuseColor.rgb;
  3564. #include <opaque_fragment>
  3565. #include <tonemapping_fragment>
  3566. #include <colorspace_fragment>
  3567. #include <fog_fragment>
  3568. #include <premultiplied_alpha_fragment>
  3569. }`,NRe=`#include <common>
  3570. #include <batching_pars_vertex>
  3571. #include <fog_pars_vertex>
  3572. #include <morphtarget_pars_vertex>
  3573. #include <skinning_pars_vertex>
  3574. #include <logdepthbuf_pars_vertex>
  3575. #include <shadowmap_pars_vertex>
  3576. void main() {
  3577. #include <batching_vertex>
  3578. #include <beginnormal_vertex>
  3579. #include <morphinstance_vertex>
  3580. #include <morphnormal_vertex>
  3581. #include <skinbase_vertex>
  3582. #include <skinnormal_vertex>
  3583. #include <defaultnormal_vertex>
  3584. #include <begin_vertex>
  3585. #include <morphtarget_vertex>
  3586. #include <skinning_vertex>
  3587. #include <project_vertex>
  3588. #include <logdepthbuf_vertex>
  3589. #include <worldpos_vertex>
  3590. #include <shadowmap_vertex>
  3591. #include <fog_vertex>
  3592. }`,MRe=`uniform vec3 color;
  3593. uniform float opacity;
  3594. #include <common>
  3595. #include <packing>
  3596. #include <fog_pars_fragment>
  3597. #include <bsdfs>
  3598. #include <lights_pars_begin>
  3599. #include <logdepthbuf_pars_fragment>
  3600. #include <shadowmap_pars_fragment>
  3601. #include <shadowmask_pars_fragment>
  3602. void main() {
  3603. #include <logdepthbuf_fragment>
  3604. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  3605. #include <tonemapping_fragment>
  3606. #include <colorspace_fragment>
  3607. #include <fog_fragment>
  3608. }`,ERe=`uniform float rotation;
  3609. uniform vec2 center;
  3610. #include <common>
  3611. #include <uv_pars_vertex>
  3612. #include <fog_pars_vertex>
  3613. #include <logdepthbuf_pars_vertex>
  3614. #include <clipping_planes_pars_vertex>
  3615. void main() {
  3616. #include <uv_vertex>
  3617. vec4 mvPosition = modelViewMatrix[ 3 ];
  3618. vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
  3619. #ifndef USE_SIZEATTENUATION
  3620. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3621. if ( isPerspective ) scale *= - mvPosition.z;
  3622. #endif
  3623. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  3624. vec2 rotatedPosition;
  3625. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  3626. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  3627. mvPosition.xy += rotatedPosition;
  3628. gl_Position = projectionMatrix * mvPosition;
  3629. #include <logdepthbuf_vertex>
  3630. #include <clipping_planes_vertex>
  3631. #include <fog_vertex>
  3632. }`,kRe=`uniform vec3 diffuse;
  3633. uniform float opacity;
  3634. #include <common>
  3635. #include <uv_pars_fragment>
  3636. #include <map_pars_fragment>
  3637. #include <alphamap_pars_fragment>
  3638. #include <alphatest_pars_fragment>
  3639. #include <alphahash_pars_fragment>
  3640. #include <fog_pars_fragment>
  3641. #include <logdepthbuf_pars_fragment>
  3642. #include <clipping_planes_pars_fragment>
  3643. void main() {
  3644. vec4 diffuseColor = vec4( diffuse, opacity );
  3645. #include <clipping_planes_fragment>
  3646. vec3 outgoingLight = vec3( 0.0 );
  3647. #include <logdepthbuf_fragment>
  3648. #include <map_fragment>
  3649. #include <alphamap_fragment>
  3650. #include <alphatest_fragment>
  3651. #include <alphahash_fragment>
  3652. outgoingLight = diffuseColor.rgb;
  3653. #include <opaque_fragment>
  3654. #include <tonemapping_fragment>
  3655. #include <colorspace_fragment>
  3656. #include <fog_fragment>
  3657. }`,En={alphahash_fragment:XPe,alphahash_pars_fragment:YPe,alphamap_fragment:QPe,alphamap_pars_fragment:ZPe,alphatest_fragment:JPe,alphatest_pars_fragment:e3e,aomap_fragment:t3e,aomap_pars_fragment:n3e,batching_pars_vertex:r3e,batching_vertex:i3e,begin_vertex:a3e,beginnormal_vertex:s3e,bsdfs:o3e,iridescence_fragment:l3e,bumpmap_pars_fragment:c3e,clipping_planes_fragment:u3e,clipping_planes_pars_fragment:d3e,clipping_planes_pars_vertex:h3e,clipping_planes_vertex:f3e,color_fragment:m3e,color_pars_fragment:p3e,color_pars_vertex:g3e,color_vertex:x3e,common:b3e,cube_uv_reflection_fragment:y3e,defaultnormal_vertex:v3e,displacementmap_pars_vertex:w3e,displacementmap_vertex:_3e,emissivemap_fragment:S3e,emissivemap_pars_fragment:N3e,colorspace_fragment:M3e,colorspace_pars_fragment:E3e,envmap_fragment:k3e,envmap_common_pars_fragment:T3e,envmap_pars_fragment:A3e,envmap_pars_vertex:C3e,envmap_physical_pars_fragment:B3e,envmap_vertex:j3e,fog_vertex:P3e,fog_pars_vertex:D3e,fog_fragment:R3e,fog_pars_fragment:O3e,gradientmap_pars_fragment:L3e,lightmap_pars_fragment:F3e,lights_lambert_fragment:I3e,lights_lambert_pars_fragment:U3e,lights_pars_begin:z3e,lights_toon_fragment:$3e,lights_toon_pars_fragment:H3e,lights_phong_fragment:V3e,lights_phong_pars_fragment:G3e,lights_physical_fragment:q3e,lights_physical_pars_fragment:W3e,lights_fragment_begin:K3e,lights_fragment_maps:X3e,lights_fragment_end:Y3e,logdepthbuf_fragment:Q3e,logdepthbuf_pars_fragment:Z3e,logdepthbuf_pars_vertex:J3e,logdepthbuf_vertex:eDe,map_fragment:tDe,map_pars_fragment:nDe,map_particle_fragment:rDe,map_particle_pars_fragment:iDe,metalnessmap_fragment:aDe,metalnessmap_pars_fragment:sDe,morphinstance_vertex:oDe,morphcolor_vertex:lDe,morphnormal_vertex:cDe,morphtarget_pars_vertex:uDe,morphtarget_vertex:dDe,normal_fragment_begin:hDe,normal_fragment_maps:fDe,normal_pars_fragment:mDe,normal_pars_vertex:pDe,normal_vertex:gDe,normalmap_pars_fragment:xDe,clearcoat_normal_fragment_begin:bDe,clearcoat_normal_fragment_maps:yDe,clearcoat_pars_fragment:vDe,iridescence_pars_fragment:wDe,opaque_fragment:_De,packing:SDe,premultiplied_alpha_fragment:NDe,project_vertex:MDe,dithering_fragment:EDe,dithering_pars_fragment:kDe,roughnessmap_fragment:TDe,roughnessmap_pars_fragment:ADe,shadowmap_pars_fragment:CDe,shadowmap_pars_vertex:jDe,shadowmap_vertex:PDe,shadowmask_pars_fragment:DDe,skinbase_vertex:RDe,skinning_pars_vertex:ODe,skinning_vertex:LDe,skinnormal_vertex:FDe,specularmap_fragment:IDe,specularmap_pars_fragment:UDe,tonemapping_fragment:zDe,tonemapping_pars_fragment:BDe,transmission_fragment:$De,transmission_pars_fragment:HDe,uv_pars_fragment:VDe,uv_pars_vertex:GDe,uv_vertex:qDe,worldpos_vertex:WDe,background_vert:KDe,background_frag:XDe,backgroundCube_vert:YDe,backgroundCube_frag:QDe,cube_vert:ZDe,cube_frag:JDe,depth_vert:eRe,depth_frag:tRe,distanceRGBA_vert:nRe,distanceRGBA_frag:rRe,equirect_vert:iRe,equirect_frag:aRe,linedashed_vert:sRe,linedashed_frag:oRe,meshbasic_vert:lRe,meshbasic_frag:cRe,meshlambert_vert:uRe,meshlambert_frag:dRe,meshmatcap_vert:hRe,meshmatcap_frag:fRe,meshnormal_vert:mRe,meshnormal_frag:pRe,meshphong_vert:gRe,meshphong_frag:xRe,meshphysical_vert:bRe,meshphysical_frag:yRe,meshtoon_vert:vRe,meshtoon_frag:wRe,points_vert:_Re,points_frag:SRe,shadow_vert:NRe,shadow_frag:MRe,sprite_vert:ERe,sprite_frag:kRe},Ot={common:{diffuse:{value:new Bn(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 Tn(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 Bn(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 Bn(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 Bn(16777215)},opacity:{value:1},center:{value:new Tn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Pn},alphaMap:{value:null},alphaMapTransform:{value:new Pn},alphaTest:{value:0}}},rc={basic:{uniforms:cs([Ot.common,Ot.specularmap,Ot.envmap,Ot.aomap,Ot.lightmap,Ot.fog]),vertexShader:En.meshbasic_vert,fragmentShader:En.meshbasic_frag},lambert:{uniforms:cs([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 Bn(0)}}]),vertexShader:En.meshlambert_vert,fragmentShader:En.meshlambert_frag},phong:{uniforms:cs([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 Bn(0)},specular:{value:new Bn(1118481)},shininess:{value:30}}]),vertexShader:En.meshphong_vert,fragmentShader:En.meshphong_frag},standard:{uniforms:cs([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 Bn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:En.meshphysical_vert,fragmentShader:En.meshphysical_frag},toon:{uniforms:cs([Ot.common,Ot.aomap,Ot.lightmap,Ot.emissivemap,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.gradientmap,Ot.fog,Ot.lights,{emissive:{value:new Bn(0)}}]),vertexShader:En.meshtoon_vert,fragmentShader:En.meshtoon_frag},matcap:{uniforms:cs([Ot.common,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.fog,{matcap:{value:null}}]),vertexShader:En.meshmatcap_vert,fragmentShader:En.meshmatcap_frag},points:{uniforms:cs([Ot.points,Ot.fog]),vertexShader:En.points_vert,fragmentShader:En.points_frag},dashed:{uniforms:cs([Ot.common,Ot.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:En.linedashed_vert,fragmentShader:En.linedashed_frag},depth:{uniforms:cs([Ot.common,Ot.displacementmap]),vertexShader:En.depth_vert,fragmentShader:En.depth_frag},normal:{uniforms:cs([Ot.common,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,{opacity:{value:1}}]),vertexShader:En.meshnormal_vert,fragmentShader:En.meshnormal_frag},sprite:{uniforms:cs([Ot.sprite,Ot.fog]),vertexShader:En.sprite_vert,fragmentShader:En.sprite_frag},background:{uniforms:{uvTransform:{value:new Pn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:En.background_vert,fragmentShader:En.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Pn}},vertexShader:En.backgroundCube_vert,fragmentShader:En.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:En.cube_vert,fragmentShader:En.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:En.equirect_vert,fragmentShader:En.equirect_frag},distanceRGBA:{uniforms:cs([Ot.common,Ot.displacementmap,{referencePosition:{value:new dt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:En.distanceRGBA_vert,fragmentShader:En.distanceRGBA_frag},shadow:{uniforms:cs([Ot.lights,Ot.fog,{color:{value:new Bn(0)},opacity:{value:1}}]),vertexShader:En.shadow_vert,fragmentShader:En.shadow_frag}};rc.physical={uniforms:cs([rc.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Pn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Pn},clearcoatNormalScale:{value:new Tn(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 Bn(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 Tn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Pn},attenuationDistance:{value:0},attenuationColor:{value:new Bn(0)},specularColor:{value:new Bn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Pn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Pn},anisotropyVector:{value:new Tn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Pn}}]),vertexShader:En.meshphysical_vert,fragmentShader:En.meshphysical_frag};const b_={r:0,b:0,g:0},df=new kh,TRe=new Vi;function ARe(t,e,n,r,i,a,o){const l=new Bn(0);let c=a===!0?0:1,u,d,f=null,p=0,m=null;function x(M){let T=M.isScene===!0?M.background:null;return T&&T.isTexture&&(T=(M.backgroundBlurriness>0?n:e).get(T)),T}function b(M){let T=!1;const E=x(M);E===null?v(l,c):E&&E.isColor&&(v(E,1),T=!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||T)&&(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(M,T){const E=x(T);E&&(E.isCubeTexture||E.mapping===fM)?(d===void 0&&(d=new vc(new J4(1,1,1),new Hu({name:"BackgroundCubeMaterial",uniforms:tx(rc.backgroundCube.uniforms),vertexShader:rc.backgroundCube.vertexShader,fragmentShader:rc.backgroundCube.fragmentShader,side:Us,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(C,k,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),df.copy(T.backgroundRotation),df.x*=-1,df.y*=-1,df.z*=-1,E.isCubeTexture&&E.isRenderTargetTexture===!1&&(df.y*=-1,df.z*=-1),d.material.uniforms.envMap.value=E,d.material.uniforms.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(TRe.makeRotationFromEuler(df)),d.material.toneMapped=sr.getTransfer(E.colorSpace)!==Mr,(f!==E||p!==E.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,f=E,p=E.version,m=t.toneMapping),d.layers.enableAll(),M.unshift(d,d.geometry,d.material,0,0,null)):E&&E.isTexture&&(u===void 0&&(u=new vc(new tL(2,2),new Hu({name:"BackgroundMaterial",uniforms:tx(rc.background.uniforms),vertexShader:rc.background.vertexShader,fragmentShader:rc.background.fragmentShader,side:Eh,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=E,u.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,u.material.toneMapped=sr.getTransfer(E.colorSpace)!==Mr,E.matrixAutoUpdate===!0&&E.updateMatrix(),u.material.uniforms.uvTransform.value.copy(E.matrix),(f!==E||p!==E.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,f=E,p=E.version,m=t.toneMapping),u.layers.enableAll(),M.unshift(u,u.geometry,u.material,0,0,null))}function v(M,T){M.getRGB(b_,yJ(t)),r.buffers.color.setClear(b_.r,b_.g,b_.b,T,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(M,T=1){l.set(M),c=T,v(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(M){c=M,v(l,c)},render:b,addToRenderList:y,dispose:S}}function CRe(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=p(null);let a=i,o=!1;function l(D,U,F,H,j){let $=!1;const K=f(H,F,U);a!==K&&(a=K,u(a.object)),$=m(D,H,F,j),$&&x(D,H,F,j),j!==null&&e.update(j,t.ELEMENT_ARRAY_BUFFER),($||o)&&(o=!1,T(D,U,F,H),j!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(j).buffer))}function c(){return t.createVertexArray()}function u(D){return t.bindVertexArray(D)}function d(D){return t.deleteVertexArray(D)}function f(D,U,F){const H=F.wireframe===!0;let j=r[D.id];j===void 0&&(j={},r[D.id]=j);let $=j[U.id];$===void 0&&($={},j[U.id]=$);let K=$[H];return K===void 0&&(K=p(c()),$[H]=K),K}function p(D){const U=[],F=[],H=[];for(let j=0;j<n;j++)U[j]=0,F[j]=0,H[j]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:U,enabledAttributes:F,attributeDivisors:H,object:D,attributes:{},index:null}}function m(D,U,F,H){const j=a.attributes,$=U.attributes;let K=0;const V=F.getAttributes();for(const Q in V)if(V[Q].location>=0){const ae=j[Q];let B=$[Q];if(B===void 0&&(Q==="instanceMatrix"&&D.instanceMatrix&&(B=D.instanceMatrix),Q==="instanceColor"&&D.instanceColor&&(B=D.instanceColor)),ae===void 0||ae.attribute!==B||B&&ae.data!==B.data)return!0;K++}return a.attributesNum!==K||a.index!==H}function x(D,U,F,H){const j={},$=U.attributes;let K=0;const V=F.getAttributes();for(const Q in V)if(V[Q].location>=0){let ae=$[Q];ae===void 0&&(Q==="instanceMatrix"&&D.instanceMatrix&&(ae=D.instanceMatrix),Q==="instanceColor"&&D.instanceColor&&(ae=D.instanceColor));const B={};B.attribute=ae,ae&&ae.data&&(B.data=ae.data),j[Q]=B,K++}a.attributes=j,a.attributesNum=K,a.index=H}function b(){const D=a.newAttributes;for(let U=0,F=D.length;U<F;U++)D[U]=0}function y(D){v(D,0)}function v(D,U){const F=a.newAttributes,H=a.enabledAttributes,j=a.attributeDivisors;F[D]=1,H[D]===0&&(t.enableVertexAttribArray(D),H[D]=1),j[D]!==U&&(t.vertexAttribDivisor(D,U),j[D]=U)}function S(){const D=a.newAttributes,U=a.enabledAttributes;for(let F=0,H=U.length;F<H;F++)U[F]!==D[F]&&(t.disableVertexAttribArray(F),U[F]=0)}function M(D,U,F,H,j,$,K){K===!0?t.vertexAttribIPointer(D,U,F,j,$):t.vertexAttribPointer(D,U,F,H,j,$)}function T(D,U,F,H){b();const j=H.attributes,$=F.getAttributes(),K=U.defaultAttributeValues;for(const V in $){const Q=$[V];if(Q.location>=0){let Z=j[V];if(Z===void 0&&(V==="instanceMatrix"&&D.instanceMatrix&&(Z=D.instanceMatrix),V==="instanceColor"&&D.instanceColor&&(Z=D.instanceColor)),Z!==void 0){const ae=Z.normalized,B=Z.itemSize,X=e.get(Z);if(X===void 0)continue;const ne=X.buffer,se=X.type,be=X.bytesPerElement,xe=se===t.INT||se===t.UNSIGNED_INT||Z.gpuType===H4;if(Z.isInterleavedBufferAttribute){const de=Z.data,Pe=de.stride,ie=Z.offset;if(de.isInstancedInterleavedBuffer){for(let Me=0;Me<Q.locationSize;Me++)v(Q.location+Me,de.meshPerAttribute);D.isInstancedMesh!==!0&&H._maxInstanceCount===void 0&&(H._maxInstanceCount=de.meshPerAttribute*de.count)}else for(let Me=0;Me<Q.locationSize;Me++)y(Q.location+Me);t.bindBuffer(t.ARRAY_BUFFER,ne);for(let Me=0;Me<Q.locationSize;Me++)M(Q.location+Me,B/Q.locationSize,se,ae,Pe*be,(ie+B/Q.locationSize*Me)*be,xe)}else{if(Z.isInstancedBufferAttribute){for(let de=0;de<Q.locationSize;de++)v(Q.location+de,Z.meshPerAttribute);D.isInstancedMesh!==!0&&H._maxInstanceCount===void 0&&(H._maxInstanceCount=Z.meshPerAttribute*Z.count)}else for(let de=0;de<Q.locationSize;de++)y(Q.location+de);t.bindBuffer(t.ARRAY_BUFFER,ne);for(let de=0;de<Q.locationSize;de++)M(Q.location+de,B/Q.locationSize,se,ae,B*be,B/Q.locationSize*de*be,xe)}}else if(K!==void 0){const ae=K[V];if(ae!==void 0)switch(ae.length){case 2:t.vertexAttrib2fv(Q.location,ae);break;case 3:t.vertexAttrib3fv(Q.location,ae);break;case 4:t.vertexAttrib4fv(Q.location,ae);break;default:t.vertexAttrib1fv(Q.location,ae)}}}}S()}function E(){R();for(const D in r){const U=r[D];for(const F in U){const H=U[F];for(const j in H)d(H[j].object),delete H[j];delete U[F]}delete r[D]}}function C(D){if(r[D.id]===void 0)return;const U=r[D.id];for(const F in U){const H=U[F];for(const j in H)d(H[j].object),delete H[j];delete U[F]}delete r[D.id]}function k(D){for(const U in r){const F=r[U];if(F[D.id]===void 0)continue;const H=F[D.id];for(const j in H)d(H[j].object),delete H[j];delete F[D.id]}}function R(){A(),o=!0,a!==i&&(a=i,u(a.object))}function A(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:l,reset:R,resetDefaultState:A,dispose:E,releaseStatesOfGeometry:C,releaseStatesOfProgram:k,initAttributes:b,enableAttribute:y,disableUnusedAttributes:S}}function jRe(t,e,n){let r;function i(u){r=u}function a(u,d){t.drawArrays(r,u,d),n.update(d,r,1)}function 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 m=0;for(let x=0;x<f;x++)m+=d[x];n.update(m,r,1)}function c(u,d,f,p){if(f===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let x=0;x<u.length;x++)o(u[x],d[x],p[x]);else{m.multiDrawArraysInstancedWEBGL(r,u,0,d,0,p,0,f);let x=0;for(let b=0;b<f;b++)x+=d[b]*p[b];n.update(x,r,1)}}this.setMode=i,this.render=a,this.renderInstances=o,this.renderMultiDraw=l,this.renderMultiDrawInstances=c}function PRe(t,e,n,r){let i;function a(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const k=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(k.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(k){return!(k!==Pl&&r.convert(k)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function l(k){const R=k===Cx&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(k!==yc&&r.convert(k)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&k!==wu&&!R)}function c(k){if(k==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";k="mediump"}return k==="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&&(gn("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const f=n.logarithmicDepthBuffer===!0,p=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),m=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),x=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),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),M=t.getParameter(t.MAX_VARYING_VECTORS),T=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),E=x>0,C=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:l,precision:u,logarithmicDepthBuffer:f,reversedDepthBuffer:p,maxTextures:m,maxVertexTextures:x,maxTextureSize:b,maxCubemapSize:y,maxAttributes:v,maxVertexUniforms:S,maxVaryings:M,maxFragmentUniforms:T,vertexTextures:E,maxSamples:C}}function DRe(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new Bd,l=new Pn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,p){const m=f.length!==0||p||r!==0||i;return i=p,r=f.length,m},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,p){n=d(f,p,0)},this.setState=function(f,p,m){const x=f.clippingPlanes,b=f.clipIntersection,y=f.clipShadows,v=t.get(f);if(!i||x===null||x.length===0||a&&!y)a?d(null):u();else{const S=a?0:r,M=S*4;let T=v.clippingState||null;c.value=T,T=d(x,p,M,m);for(let E=0;E!==M;++E)T[E]=n[E];v.clippingState=T,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,p,m,x){const b=f!==null?f.length:0;let y=null;if(b!==0){if(y=c.value,x!==!0||y===null){const v=m+b*4,S=p.matrixWorldInverse;l.getNormalMatrix(S),(y===null||y.length<v)&&(y=new Float32Array(v));for(let M=0,T=m;M!==b;++M,T+=4)o.copy(f[M]).applyMatrix4(S,l),o.normal.toArray(y,T),y[T+3]=o.constant}c.value=y,c.needsUpdate=!0}return e.numPlanes=b,e.numIntersection=0,y}}function RRe(t){let e=new WeakMap;function n(o,l){return l===P3?o.mapping=Zg:l===D3&&(o.mapping=Jg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===P3||l===D3)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 APe(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 a(){e=new WeakMap}return{get:r,dispose:a}}const Qd=4,sV=[.125,.215,.35,.446,.526,.582],Mf=20,ORe=256,qb=new kJ,oV=new Bn;let xC=null,bC=0,yC=0,vC=!1;const LRe=new dt;let lV=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,n=0,r=.1,i=100,a={}){const{size:o=256,position:l=LRe}=a;xC=this._renderer.getRenderTarget(),bC=this._renderer.getActiveCubeFace(),yC=this._renderer.getActiveMipmapLevel(),vC=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=dV(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=uV(),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(xC,bC,yC),this._renderer.xr.enabled=vC,e.scissorTest=!1,Dp(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Zg||e.mapping===Jg?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),xC=this._renderer.getRenderTarget(),bC=this._renderer.getActiveCubeFace(),yC=this._renderer.getActiveMipmapLevel(),vC=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:el,minFilter:el,generateMipmaps:!1,type:Cx,format:Pl,colorSpace:ex,depthBuffer:!1},i=cV(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=cV(e,n,r);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=FRe(a)),this._blurMaterial=URe(a,e,n),this._ggxMaterial=IRe(a,e,n)}return i}_compileMaterial(e){const n=new vc(new Ac,e);this._renderer.compile(n,qb)}_sceneToCubeUV(e,n,r,i,a){const c=new Wo(90,1,n,r),u=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,p=f.autoClear,m=f.toneMapping;f.getClearColor(oV),f.toneMapping=lh,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new vc(new J4,new Z4({name:"PMREM.Background",side:Us,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(oV),v=!0);for(let M=0;M<6;M++){const T=M%3;T===0?(c.up.set(0,u[M],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x+d[M],a.y,a.z)):T===1?(c.up.set(0,0,u[M]),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y+d[M],a.z)):(c.up.set(0,u[M],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y,a.z+d[M]));const E=this._cubeSize;Dp(i,T*E,M>2?E:0,E,E),f.setRenderTarget(i),v&&f.render(b,c),f.render(e,c)}f.toneMapping=m,f.autoClear=p,e.background=S}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Zg||e.mapping===Jg;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=dV()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=uV());const a=i?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=a;const l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;Dp(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,qb)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;const i=this._lodMeshes.length;for(let a=1;a<i;a++)this._applyGGXFilter(e,a-1,a);n.autoClear=r}_applyGGXFilter(e,n,r){const i=this._renderer,a=this._pingPongRenderTarget,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),p=.05+u*.95,m=f*p,{_lodMax:x}=this,b=this._sizeLods[r],y=3*b*(r>x-Qd?r-x+Qd:0),v=4*(this._cubeSize-b);c.envMap.value=e.texture,c.roughness.value=m,c.mipInt.value=x-n,Dp(a,y,v,3*b,2*b),i.setRenderTarget(a),i.render(l,qb),c.envMap.value=a.texture,c.roughness.value=0,c.mipInt.value=x-r,Dp(e,y,v,3*b,2*b),i.setRenderTarget(e),i.render(l,qb)}_blur(e,n,r,i,a){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",a),this._halfBlur(o,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,o,l){const c=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&ki("blur direction must be either latitudinal or longitudinal!");const d=3,f=this._lodMeshes[i];f.material=u;const p=u.uniforms,m=this._sizeLods[r]-1,x=isFinite(a)?Math.PI/(2*m):2*Math.PI/(2*Mf-1),b=a/x,y=isFinite(a)?1+Math.floor(d*b):Mf;y>Mf&&gn(`sigmaRadians, ${a}, 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 k=0;k<Mf;++k){const R=k/b,A=Math.exp(-R*R/2);v.push(A),k===0?S+=A:k<y&&(S+=2*A)}for(let k=0;k<v.length;k++)v[k]=v[k]/S;p.envMap.value=e.texture,p.samples.value=y,p.weights.value=v,p.latitudinal.value=o==="latitudinal",l&&(p.poleAxis.value=l);const{_lodMax:M}=this;p.dTheta.value=x,p.mipInt.value=M-r;const T=this._sizeLods[i],E=3*T*(i>M-Qd?i-M+Qd:0),C=4*(this._cubeSize-T);Dp(n,E,C,3*T,2*T),c.setRenderTarget(n),c.render(f,qb)}};function FRe(t){const e=[],n=[],r=[];let i=t;const a=t-Qd+1+sV.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);e.push(l);let c=1/l;o>t-Qd?c=sV[o-t+Qd-1]:o===0&&(c=0),n.push(c);const u=1/(l-2),d=-u,f=1+u,p=[d,d,f,d,f,f,d,d,f,f,d,f],m=6,x=6,b=3,y=2,v=1,S=new Float32Array(b*x*m),M=new Float32Array(y*x*m),T=new Float32Array(v*x*m);for(let C=0;C<m;C++){const k=C%3*2/3-1,R=C>2?0:-1,A=[k,R,0,k+2/3,R,0,k+2/3,R+1,0,k,R,0,k+2/3,R+1,0,k,R+1,0];S.set(A,b*x*C),M.set(p,y*x*C);const D=[C,C,C,C,C,C];T.set(D,v*x*C)}const E=new Ac;E.setAttribute("position",new nl(S,b)),E.setAttribute("uv",new nl(M,y)),E.setAttribute("faceIndex",new nl(T,v)),r.push(new vc(E,null)),i>Qd&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function cV(t,e,n){const r=new xm(t,e,n);return r.texture.mapping=fM,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Dp(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function IRe(t,e,n){return new Hu({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:ORe,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:pM(),fragmentShader:`
  3658. precision highp float;
  3659. precision highp int;
  3660. varying vec3 vOutputDirection;
  3661. uniform sampler2D envMap;
  3662. uniform float roughness;
  3663. uniform float mipInt;
  3664. #define ENVMAP_TYPE_CUBE_UV
  3665. #include <cube_uv_reflection_fragment>
  3666. #define PI 3.14159265359
  3667. // Van der Corput radical inverse
  3668. float radicalInverse_VdC(uint bits) {
  3669. bits = (bits << 16u) | (bits >> 16u);
  3670. bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
  3671. bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
  3672. bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
  3673. bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
  3674. return float(bits) * 2.3283064365386963e-10; // / 0x100000000
  3675. }
  3676. // Hammersley sequence
  3677. vec2 hammersley(uint i, uint N) {
  3678. return vec2(float(i) / float(N), radicalInverse_VdC(i));
  3679. }
  3680. // GGX VNDF importance sampling (Eric Heitz 2018)
  3681. // "Sampling the GGX Distribution of Visible Normals"
  3682. // https://jcgt.org/published/0007/04/01/
  3683. vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
  3684. float alpha = roughness * roughness;
  3685. // Section 3.2: Transform view direction to hemisphere configuration
  3686. vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
  3687. // Section 4.1: Orthonormal basis
  3688. float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
  3689. vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
  3690. vec3 T2 = cross(Vh, T1);
  3691. // Section 4.2: Parameterization of projected area
  3692. float r = sqrt(Xi.x);
  3693. float phi = 2.0 * PI * Xi.y;
  3694. float t1 = r * cos(phi);
  3695. float t2 = r * sin(phi);
  3696. float s = 0.5 * (1.0 + Vh.z);
  3697. t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
  3698. // Section 4.3: Reprojection onto hemisphere
  3699. vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
  3700. // Section 3.4: Transform back to ellipsoid configuration
  3701. return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
  3702. }
  3703. void main() {
  3704. vec3 N = normalize(vOutputDirection);
  3705. vec3 V = N; // Assume view direction equals normal for pre-filtering
  3706. vec3 prefilteredColor = vec3(0.0);
  3707. float totalWeight = 0.0;
  3708. // For very low roughness, just sample the environment directly
  3709. if (roughness < 0.001) {
  3710. gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
  3711. return;
  3712. }
  3713. // Tangent space basis for VNDF sampling
  3714. vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
  3715. vec3 tangent = normalize(cross(up, N));
  3716. vec3 bitangent = cross(N, tangent);
  3717. for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
  3718. vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
  3719. // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
  3720. vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
  3721. // Transform H back to world space
  3722. vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
  3723. vec3 L = normalize(2.0 * dot(V, H) * H - V);
  3724. float NdotL = max(dot(N, L), 0.0);
  3725. if(NdotL > 0.0) {
  3726. // Sample environment at fixed mip level
  3727. // VNDF importance sampling handles the distribution filtering
  3728. vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
  3729. // Weight by NdotL for the split-sum approximation
  3730. // VNDF PDF naturally accounts for the visible microfacet distribution
  3731. prefilteredColor += sampleColor * NdotL;
  3732. totalWeight += NdotL;
  3733. }
  3734. }
  3735. if (totalWeight > 0.0) {
  3736. prefilteredColor = prefilteredColor / totalWeight;
  3737. }
  3738. gl_FragColor = vec4(prefilteredColor, 1.0);
  3739. }
  3740. `,blending:Tu,depthTest:!1,depthWrite:!1})}function URe(t,e,n){const r=new Float32Array(Mf),i=new dt(0,1,0);return new Hu({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:pM(),fragmentShader:`
  3741. precision mediump float;
  3742. precision mediump int;
  3743. varying vec3 vOutputDirection;
  3744. uniform sampler2D envMap;
  3745. uniform int samples;
  3746. uniform float weights[ n ];
  3747. uniform bool latitudinal;
  3748. uniform float dTheta;
  3749. uniform float mipInt;
  3750. uniform vec3 poleAxis;
  3751. #define ENVMAP_TYPE_CUBE_UV
  3752. #include <cube_uv_reflection_fragment>
  3753. vec3 getSample( float theta, vec3 axis ) {
  3754. float cosTheta = cos( theta );
  3755. // Rodrigues' axis-angle rotation
  3756. vec3 sampleDirection = vOutputDirection * cosTheta
  3757. + cross( axis, vOutputDirection ) * sin( theta )
  3758. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  3759. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  3760. }
  3761. void main() {
  3762. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  3763. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  3764. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  3765. }
  3766. axis = normalize( axis );
  3767. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  3768. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  3769. for ( int i = 1; i < n; i++ ) {
  3770. if ( i >= samples ) {
  3771. break;
  3772. }
  3773. float theta = dTheta * float( i );
  3774. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  3775. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  3776. }
  3777. }
  3778. `,blending:Tu,depthTest:!1,depthWrite:!1})}function uV(){return new Hu({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:pM(),fragmentShader:`
  3779. precision mediump float;
  3780. precision mediump int;
  3781. varying vec3 vOutputDirection;
  3782. uniform sampler2D envMap;
  3783. #include <common>
  3784. void main() {
  3785. vec3 outputDirection = normalize( vOutputDirection );
  3786. vec2 uv = equirectUv( outputDirection );
  3787. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  3788. }
  3789. `,blending:Tu,depthTest:!1,depthWrite:!1})}function dV(){return new Hu({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:pM(),fragmentShader:`
  3790. precision mediump float;
  3791. precision mediump int;
  3792. uniform float flipEnvMap;
  3793. varying vec3 vOutputDirection;
  3794. uniform samplerCube envMap;
  3795. void main() {
  3796. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  3797. }
  3798. `,blending:Tu,depthTest:!1,depthWrite:!1})}function pM(){return`
  3799. precision mediump float;
  3800. precision mediump int;
  3801. attribute float faceIndex;
  3802. varying vec3 vOutputDirection;
  3803. // RH coordinate system; PMREM face-indexing convention
  3804. vec3 getDirection( vec2 uv, float face ) {
  3805. uv = 2.0 * uv - 1.0;
  3806. vec3 direction = vec3( uv, 1.0 );
  3807. if ( face == 0.0 ) {
  3808. direction = direction.zyx; // ( 1, v, u ) pos x
  3809. } else if ( face == 1.0 ) {
  3810. direction = direction.xzy;
  3811. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  3812. } else if ( face == 2.0 ) {
  3813. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  3814. } else if ( face == 3.0 ) {
  3815. direction = direction.zyx;
  3816. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  3817. } else if ( face == 4.0 ) {
  3818. direction = direction.xzy;
  3819. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  3820. } else if ( face == 5.0 ) {
  3821. direction.z *= -1.0; // ( u, v, -1 ) neg z
  3822. }
  3823. return direction;
  3824. }
  3825. void main() {
  3826. vOutputDirection = getDirection( uv, faceIndex );
  3827. gl_Position = vec4( position, 1.0 );
  3828. }
  3829. `}function zRe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===P3||c===D3,d=c===Zg||c===Jg;if(u||d){let f=e.get(l);const p=f!==void 0?f.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==p)return n===null&&(n=new lV(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 m=l.image;return u&&m&&m.height>0||d&&m&&i(m)?(n===null&&(n=new lV(t)),f=u?n.fromEquirectangular(l):n.fromCubemap(l),f.texture.pmremVersion=l.pmremVersion,e.set(l,f),l.addEventListener("dispose",a),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 a(l){const c=l.target;c.removeEventListener("dispose",a);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 BRe(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&&py("WebGLRenderer: "+r+" extension not supported."),i}}}function $Re(t,e,n,r){const i={},a=new WeakMap;function o(f){const p=f.target;p.index!==null&&e.remove(p.index);for(const x in p.attributes)e.remove(p.attributes[x]);p.removeEventListener("dispose",o),delete i[p.id];const m=a.get(p);m&&(e.remove(m),a.delete(p)),r.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,n.memory.geometries--}function l(f,p){return i[p.id]===!0||(p.addEventListener("dispose",o),i[p.id]=!0,n.memory.geometries++),p}function c(f){const p=f.attributes;for(const m in p)e.update(p[m],t.ARRAY_BUFFER)}function u(f){const p=[],m=f.index,x=f.attributes.position;let b=0;if(m!==null){const S=m.array;b=m.version;for(let M=0,T=S.length;M<T;M+=3){const E=S[M+0],C=S[M+1],k=S[M+2];p.push(E,C,C,k,k,E)}}else if(x!==void 0){const S=x.array;b=x.version;for(let M=0,T=S.length/3-1;M<T;M+=3){const E=M+0,C=M+1,k=M+2;p.push(E,C,C,k,k,E)}}else return;const y=new(sJ(p)?gJ:pJ)(p,1);y.version=b;const v=a.get(f);v&&e.remove(v),a.set(f,y)}function d(f){const p=a.get(f);if(p){const m=f.index;m!==null&&p.version<m.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function HRe(t,e,n){let r;function i(p){r=p}let a,o;function l(p){a=p.type,o=p.bytesPerElement}function c(p,m){t.drawElements(r,m,a,p*o),n.update(m,r,1)}function u(p,m,x){x!==0&&(t.drawElementsInstanced(r,m,a,p*o,x),n.update(m,r,x))}function d(p,m,x){if(x===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,m,0,a,p,0,x);let y=0;for(let v=0;v<x;v++)y+=m[v];n.update(y,r,1)}function f(p,m,x,b){if(x===0)return;const y=e.get("WEBGL_multi_draw");if(y===null)for(let v=0;v<p.length;v++)u(p[v]/o,m[v],b[v]);else{y.multiDrawElementsInstancedWEBGL(r,m,0,a,p,0,b,0,x);let v=0;for(let S=0;S<x;S++)v+=m[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 VRe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,o,l){switch(n.calls++,o){case t.TRIANGLES:n.triangles+=l*(a/3);break;case t.LINES:n.lines+=l*(a/2);break;case t.LINE_STRIP:n.lines+=l*(a-1);break;case t.LINE_LOOP:n.lines+=l*a;break;case t.POINTS:n.points+=l*a;break;default:ki("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 GRe(t,e,n){const r=new WeakMap,i=new Ui;function a(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 p=r.get(l);if(p===void 0||p.count!==f){let D=function(){R.dispose(),r.delete(l),l.removeEventListener("dispose",D)};var m=D;p!==void 0&&p.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||[],M=l.morphAttributes.color||[];let T=0;x===!0&&(T=1),b===!0&&(T=2),y===!0&&(T=3);let E=l.attributes.position.count*T,C=1;E>e.maxTextureSize&&(C=Math.ceil(E/e.maxTextureSize),E=e.maxTextureSize);const k=new Float32Array(E*C*4*f),R=new dJ(k,E,C,f);R.type=wu,R.needsUpdate=!0;const A=T*4;for(let U=0;U<f;U++){const F=v[U],H=S[U],j=M[U],$=E*C*4*U;for(let K=0;K<F.count;K++){const V=K*A;x===!0&&(i.fromBufferAttribute(F,K),k[$+V+0]=i.x,k[$+V+1]=i.y,k[$+V+2]=i.z,k[$+V+3]=0),b===!0&&(i.fromBufferAttribute(H,K),k[$+V+4]=i.x,k[$+V+5]=i.y,k[$+V+6]=i.z,k[$+V+7]=0),y===!0&&(i.fromBufferAttribute(j,K),k[$+V+8]=i.x,k[$+V+9]=i.y,k[$+V+10]=i.z,k[$+V+11]=j.itemSize===4?i.w:1)}}p={count:f,texture:R,size:new Tn(E,C)},r.set(l,p),l.addEventListener("dispose",D)}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",p.texture,n),c.getUniforms().setValue(t,"morphTargetsTextureSize",p.size)}return{update:a}}function qRe(t,e,n,r){let i=new WeakMap;function a(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",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 p=c.skeleton;i.get(p)!==u&&(p.update(),i.set(p,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:a,dispose:o}}const AJ=new $l,hV=new SJ(1,1),CJ=new dJ,jJ=new hPe,PJ=new wJ,fV=[],mV=[],pV=new Float32Array(16),gV=new Float32Array(9),xV=new Float32Array(4);function Px(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=fV[i];if(a===void 0&&(a=new Float32Array(i),fV[i]=a),e!==0){r.toArray(a,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(a,l)}return a}function Zi(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 Ji(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function gM(t,e){let n=mV[e];n===void 0&&(n=new Int32Array(e),mV[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function WRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function KRe(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(Zi(n,e))return;t.uniform2fv(this.addr,e),Ji(n,e)}}function XRe(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(Zi(n,e))return;t.uniform3fv(this.addr,e),Ji(n,e)}}function YRe(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(Zi(n,e))return;t.uniform4fv(this.addr,e),Ji(n,e)}}function QRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Zi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Ji(n,e)}else{if(Zi(n,r))return;xV.set(r),t.uniformMatrix2fv(this.addr,!1,xV),Ji(n,r)}}function ZRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Zi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Ji(n,e)}else{if(Zi(n,r))return;gV.set(r),t.uniformMatrix3fv(this.addr,!1,gV),Ji(n,r)}}function JRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Zi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Ji(n,e)}else{if(Zi(n,r))return;pV.set(r),t.uniformMatrix4fv(this.addr,!1,pV),Ji(n,r)}}function eOe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function tOe(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(Zi(n,e))return;t.uniform2iv(this.addr,e),Ji(n,e)}}function nOe(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(Zi(n,e))return;t.uniform3iv(this.addr,e),Ji(n,e)}}function rOe(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(Zi(n,e))return;t.uniform4iv(this.addr,e),Ji(n,e)}}function iOe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function aOe(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(Zi(n,e))return;t.uniform2uiv(this.addr,e),Ji(n,e)}}function sOe(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(Zi(n,e))return;t.uniform3uiv(this.addr,e),Ji(n,e)}}function oOe(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(Zi(n,e))return;t.uniform4uiv(this.addr,e),Ji(n,e)}}function lOe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);let a;this.type===t.SAMPLER_2D_SHADOW?(hV.compareFunction=aJ,a=hV):a=AJ,n.setTexture2D(e||a,i)}function cOe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||jJ,i)}function uOe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||PJ,i)}function dOe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||CJ,i)}function hOe(t){switch(t){case 5126:return WRe;case 35664:return KRe;case 35665:return XRe;case 35666:return YRe;case 35674:return QRe;case 35675:return ZRe;case 35676:return JRe;case 5124:case 35670:return eOe;case 35667:case 35671:return tOe;case 35668:case 35672:return nOe;case 35669:case 35673:return rOe;case 5125:return iOe;case 36294:return aOe;case 36295:return sOe;case 36296:return oOe;case 35678:case 36198:case 36298:case 36306:case 35682:return lOe;case 35679:case 36299:case 36307:return cOe;case 35680:case 36300:case 36308:case 36293:return uOe;case 36289:case 36303:case 36311:case 36292:return dOe}}function fOe(t,e){t.uniform1fv(this.addr,e)}function mOe(t,e){const n=Px(e,this.size,2);t.uniform2fv(this.addr,n)}function pOe(t,e){const n=Px(e,this.size,3);t.uniform3fv(this.addr,n)}function gOe(t,e){const n=Px(e,this.size,4);t.uniform4fv(this.addr,n)}function xOe(t,e){const n=Px(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function bOe(t,e){const n=Px(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function yOe(t,e){const n=Px(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function vOe(t,e){t.uniform1iv(this.addr,e)}function wOe(t,e){t.uniform2iv(this.addr,e)}function _Oe(t,e){t.uniform3iv(this.addr,e)}function SOe(t,e){t.uniform4iv(this.addr,e)}function NOe(t,e){t.uniform1uiv(this.addr,e)}function MOe(t,e){t.uniform2uiv(this.addr,e)}function EOe(t,e){t.uniform3uiv(this.addr,e)}function kOe(t,e){t.uniform4uiv(this.addr,e)}function TOe(t,e,n){const r=this.cache,i=e.length,a=gM(n,i);Zi(r,a)||(t.uniform1iv(this.addr,a),Ji(r,a));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||AJ,a[o])}function AOe(t,e,n){const r=this.cache,i=e.length,a=gM(n,i);Zi(r,a)||(t.uniform1iv(this.addr,a),Ji(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||jJ,a[o])}function COe(t,e,n){const r=this.cache,i=e.length,a=gM(n,i);Zi(r,a)||(t.uniform1iv(this.addr,a),Ji(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||PJ,a[o])}function jOe(t,e,n){const r=this.cache,i=e.length,a=gM(n,i);Zi(r,a)||(t.uniform1iv(this.addr,a),Ji(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||CJ,a[o])}function POe(t){switch(t){case 5126:return fOe;case 35664:return mOe;case 35665:return pOe;case 35666:return gOe;case 35674:return xOe;case 35675:return bOe;case 35676:return yOe;case 5124:case 35670:return vOe;case 35667:case 35671:return wOe;case 35668:case 35672:return _Oe;case 35669:case 35673:return SOe;case 5125:return NOe;case 36294:return MOe;case 36295:return EOe;case 36296:return kOe;case 35678:case 36198:case 36298:case 36306:case 35682:return TOe;case 35679:case 36299:case 36307:return AOe;case 35680:case 36300:case 36308:case 36293:return COe;case 36289:case 36303:case 36311:case 36292:return jOe}}let DOe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=hOe(n.type)}},ROe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=POe(n.type)}},OOe=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,o=i.length;a!==o;++a){const l=i[a];l.setValue(e,n[l.id],r)}}};const wC=/(\w+)(\])?(\[|\.)?/g;function bV(t,e){t.seq.push(e),t.map[e.id]=e}function LOe(t,e,n){const r=t.name,i=r.length;for(wC.lastIndex=0;;){const a=wC.exec(r),o=wC.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){bV(n,u===void 0?new DOe(l,t,e):new ROe(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new OOe(l),bV(n,f)),n=f}}}let j1=class{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const a=e.getActiveUniform(n,i),o=e.getUniformLocation(n,a.name);LOe(a,o,this)}}setValue(e,n,r,i){const a=this.map[n];a!==void 0&&a.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let a=0,o=n.length;a!==o;++a){const l=n[a],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const o=e[i];o.id in n&&r.push(o)}return r}};function yV(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const FOe=37297;let IOe=0;function UOe(t,e){const n=t.split(`
  3830. `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let o=i;o<a;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
  3831. `)}const vV=new Pn;function zOe(t){sr._getMatrix(vV,sr.workingColorSpace,t);const e=`mat3( ${vV.elements.map(n=>n.toFixed(4))} )`;switch(sr.getTransfer(t)){case WS:return[e,"LinearTransferOETF"];case Mr:return[e,"sRGBTransferOETF"];default:return gn("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function wV(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),a=(t.getShaderInfoLog(e)||"").trim();if(r&&a==="")return"";const o=/ERROR: 0:(\d+)/.exec(a);if(o){const l=parseInt(o[1]);return n.toUpperCase()+`
  3832. `+a+`
  3833. `+UOe(t.getShaderSource(e),l)}else return a}function BOe(t,e){const n=zOe(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
  3834. `)}function $Oe(t,e){let n;switch(e){case Uje:n="Linear";break;case zje:n="Reinhard";break;case Bje:n="Cineon";break;case $je:n="ACESFilmic";break;case Vje:n="AgX";break;case Gje:n="Neutral";break;case Hje:n="Custom";break;default:gn("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const y_=new dt;function HOe(){sr.getLuminanceCoefficients(y_);const t=y_.x.toFixed(4),e=y_.y.toFixed(4),n=y_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
  3835. `)}function VOe(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(l0).join(`
  3836. `)}function GOe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  3837. `)}function qOe(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),o=a.name;let l=1;a.type===t.FLOAT_MAT2&&(l=2),a.type===t.FLOAT_MAT3&&(l=3),a.type===t.FLOAT_MAT4&&(l=4),n[o]={type:a.type,location:t.getAttribLocation(e,o),locationSize:l}}return n}function l0(t){return t!==""}function _V(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 SV(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const WOe=/^[ \t]*#include +<([\w\d./]+)>/gm;function hD(t){return t.replace(WOe,XOe)}const KOe=new Map;function XOe(t,e){let n=En[e];if(n===void 0){const r=KOe.get(e);if(r!==void 0)n=En[r],gn('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return hD(n)}const YOe=/#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 NV(t){return t.replace(YOe,QOe)}function QOe(t,e,n,r){let i="";for(let a=parseInt(e);a<parseInt(n);a++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return i}function MV(t){let e=`precision ${t.precision} float;
  3838. precision ${t.precision} int;
  3839. precision ${t.precision} sampler2D;
  3840. precision ${t.precision} samplerCube;
  3841. precision ${t.precision} sampler3D;
  3842. precision ${t.precision} sampler2DArray;
  3843. precision ${t.precision} sampler2DShadow;
  3844. precision ${t.precision} samplerCubeShadow;
  3845. precision ${t.precision} sampler2DArrayShadow;
  3846. precision ${t.precision} isampler2D;
  3847. precision ${t.precision} isampler3D;
  3848. precision ${t.precision} isamplerCube;
  3849. precision ${t.precision} isampler2DArray;
  3850. precision ${t.precision} usampler2D;
  3851. precision ${t.precision} usampler3D;
  3852. precision ${t.precision} usamplerCube;
  3853. precision ${t.precision} usampler2DArray;
  3854. `;return t.precision==="highp"?e+=`
  3855. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  3856. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  3857. #define LOW_PRECISION`),e}function ZOe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===XZ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===bje?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===ou&&(e="SHADOWMAP_TYPE_VSM"),e}function JOe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Zg:case Jg:e="ENVMAP_TYPE_CUBE";break;case fM:e="ENVMAP_TYPE_CUBE_UV";break}return e}function e4e(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Jg:e="ENVMAP_MODE_REFRACTION";break}return e}function t4e(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case $4:e="ENVMAP_BLENDING_MULTIPLY";break;case Fje:e="ENVMAP_BLENDING_MIX";break;case Ije:e="ENVMAP_BLENDING_ADD";break}return e}function n4e(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 r4e(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=ZOe(n),u=JOe(n),d=e4e(n),f=t4e(n),p=n4e(n),m=VOe(n),x=GOe(a),b=i.createProgram();let y,v,S=n.glslVersion?"#version "+n.glslVersion+`
  3858. `:"";n.isRawShaderMaterial?(y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(l0).join(`
  3859. `),y.length>0&&(y+=`
  3860. `),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(l0).join(`
  3861. `),v.length>0&&(v+=`
  3862. `)):(y=[MV(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",`
  3863. `].filter(l0).join(`
  3864. `),v=[MV(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:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.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!==lh?"#define TONE_MAPPING":"",n.toneMapping!==lh?En.tonemapping_pars_fragment:"",n.toneMapping!==lh?$Oe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",En.colorspace_pars_fragment,BOe("linearToOutputTexel",n.outputColorSpace),HOe(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  3865. `].filter(l0).join(`
  3866. `)),o=hD(o),o=_V(o,n),o=SV(o,n),l=hD(l),l=_V(l,n),l=SV(l,n),o=NV(o),l=NV(l),n.isRawShaderMaterial!==!0&&(S=`#version 300 es
  3867. `,y=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
  3868. `)+`
  3869. `+y,v=["#define varying in",n.glslVersion===PH?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===PH?"":"#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(`
  3870. `)+`
  3871. `+v);const M=S+y+o,T=S+v+l,E=yV(i,i.VERTEX_SHADER,M),C=yV(i,i.FRAGMENT_SHADER,T);i.attachShader(b,E),i.attachShader(b,C),n.index0AttributeName!==void 0?i.bindAttribLocation(b,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(b,0,"position"),i.linkProgram(b);function k(U){if(t.debug.checkShaderErrors){const F=i.getProgramInfoLog(b)||"",H=i.getShaderInfoLog(E)||"",j=i.getShaderInfoLog(C)||"",$=F.trim(),K=H.trim(),V=j.trim();let Q=!0,Z=!0;if(i.getProgramParameter(b,i.LINK_STATUS)===!1)if(Q=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,b,E,C);else{const ae=wV(i,E,"vertex"),B=wV(i,C,"fragment");ki("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(b,i.VALIDATE_STATUS)+`
  3872. Material Name: `+U.name+`
  3873. Material Type: `+U.type+`
  3874. Program Info Log: `+$+`
  3875. `+ae+`
  3876. `+B)}else $!==""?gn("WebGLProgram: Program Info Log:",$):(K===""||V==="")&&(Z=!1);Z&&(U.diagnostics={runnable:Q,programLog:$,vertexShader:{log:K,prefix:y},fragmentShader:{log:V,prefix:v}})}i.deleteShader(E),i.deleteShader(C),R=new j1(i,b),A=qOe(i,b)}let R;this.getUniforms=function(){return R===void 0&&k(this),R};let A;this.getAttributes=function(){return A===void 0&&k(this),A};let D=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=i.getProgramParameter(b,FOe)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(b),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=IOe++,this.cacheKey=e,this.usedTimes=1,this.program=b,this.vertexShader=E,this.fragmentShader=C,this}let i4e=0,a4e=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),a=this._getShaderStage(r),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(a)===!1&&(o.add(a),a.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new s4e(e),n.set(e,r)),r}},s4e=class{constructor(e){this.id=i4e++,this.code=e,this.usedTimes=0}};function o4e(t,e,n,r,i,a,o){const l=new fJ,c=new a4e,u=new Set,d=[],f=i.logarithmicDepthBuffer,p=i.vertexTextures;let m=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function b(A){return u.add(A),A===0?"uv":`uv${A}`}function y(A,D,U,F,H){const j=F.fog,$=H.geometry,K=A.isMeshStandardMaterial?F.environment:null,V=(A.isMeshStandardMaterial?n:e).get(A.envMap||K),Q=V&&V.mapping===fM?V.image.height:null,Z=x[A.type];A.precision!==null&&(m=i.getMaxPrecision(A.precision),m!==A.precision&&gn("WebGLProgram.getParameters:",A.precision,"not supported, using",m,"instead."));const ae=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,B=ae!==void 0?ae.length:0;let X=0;$.morphAttributes.position!==void 0&&(X=1),$.morphAttributes.normal!==void 0&&(X=2),$.morphAttributes.color!==void 0&&(X=3);let ne,se,be,xe;if(Z){const ft=rc[Z];ne=ft.vertexShader,se=ft.fragmentShader}else ne=A.vertexShader,se=A.fragmentShader,c.update(A),be=c.getVertexShaderID(A),xe=c.getFragmentShaderID(A);const de=t.getRenderTarget(),Pe=t.state.buffers.depth.getReversed(),ie=H.isInstancedMesh===!0,Me=H.isBatchedMesh===!0,Oe=!!A.map,ge=!!A.matcap,Ke=!!V,G=!!A.aoMap,Y=!!A.lightMap,ce=!!A.bumpMap,q=!!A.normalMap,te=!!A.displacementMap,I=!!A.emissiveMap,fe=!!A.metalnessMap,me=!!A.roughnessMap,ke=A.anisotropy>0,z=A.clearcoat>0,O=A.dispersion>0,ee=A.iridescence>0,le=A.sheen>0,_e=A.transmission>0,we=ke&&!!A.anisotropyMap,re=z&&!!A.clearcoatMap,Fe=z&&!!A.clearcoatNormalMap,$e=z&&!!A.clearcoatRoughnessMap,Ve=ee&&!!A.iridescenceMap,He=ee&&!!A.iridescenceThicknessMap,ye=le&&!!A.sheenColorMap,je=le&&!!A.sheenRoughnessMap,Be=!!A.specularMap,Se=!!A.specularColorMap,Xe=!!A.specularIntensityMap,Ne=_e&&!!A.transmissionMap,tt=_e&&!!A.thicknessMap,Ee=!!A.gradientMap,We=!!A.alphaMap,ze=A.alphaTest>0,W=!!A.alphaHash,De=!!A.extensions;let Ye=lh;A.toneMapped&&(de===null||de.isXRRenderTarget===!0)&&(Ye=t.toneMapping);const xt={shaderID:Z,shaderType:A.type,shaderName:A.name,vertexShader:ne,fragmentShader:se,defines:A.defines,customVertexShaderID:be,customFragmentShaderID:xe,isRawShaderMaterial:A.isRawShaderMaterial===!0,glslVersion:A.glslVersion,precision:m,batching:Me,batchingColor:Me&&H._colorsTexture!==null,instancing:ie,instancingColor:ie&&H.instanceColor!==null,instancingMorph:ie&&H.morphTexture!==null,supportsVertexTextures:p,outputColorSpace:de===null?t.outputColorSpace:de.isXRRenderTarget===!0?de.texture.colorSpace:ex,alphaToCoverage:!!A.alphaToCoverage,map:Oe,matcap:ge,envMap:Ke,envMapMode:Ke&&V.mapping,envMapCubeUVHeight:Q,aoMap:G,lightMap:Y,bumpMap:ce,normalMap:q,displacementMap:p&&te,emissiveMap:I,normalMapObjectSpace:q&&A.normalMapType===Xje,normalMapTangentSpace:q&&A.normalMapType===iJ,metalnessMap:fe,roughnessMap:me,anisotropy:ke,anisotropyMap:we,clearcoat:z,clearcoatMap:re,clearcoatNormalMap:Fe,clearcoatRoughnessMap:$e,dispersion:O,iridescence:ee,iridescenceMap:Ve,iridescenceThicknessMap:He,sheen:le,sheenColorMap:ye,sheenRoughnessMap:je,specularMap:Be,specularColorMap:Se,specularIntensityMap:Xe,transmission:_e,transmissionMap:Ne,thicknessMap:tt,gradientMap:Ee,opaque:A.transparent===!1&&A.blending===Ag&&A.alphaToCoverage===!1,alphaMap:We,alphaTest:ze,alphaHash:W,combine:A.combine,mapUv:Oe&&b(A.map.channel),aoMapUv:G&&b(A.aoMap.channel),lightMapUv:Y&&b(A.lightMap.channel),bumpMapUv:ce&&b(A.bumpMap.channel),normalMapUv:q&&b(A.normalMap.channel),displacementMapUv:te&&b(A.displacementMap.channel),emissiveMapUv:I&&b(A.emissiveMap.channel),metalnessMapUv:fe&&b(A.metalnessMap.channel),roughnessMapUv:me&&b(A.roughnessMap.channel),anisotropyMapUv:we&&b(A.anisotropyMap.channel),clearcoatMapUv:re&&b(A.clearcoatMap.channel),clearcoatNormalMapUv:Fe&&b(A.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:$e&&b(A.clearcoatRoughnessMap.channel),iridescenceMapUv:Ve&&b(A.iridescenceMap.channel),iridescenceThicknessMapUv:He&&b(A.iridescenceThicknessMap.channel),sheenColorMapUv:ye&&b(A.sheenColorMap.channel),sheenRoughnessMapUv:je&&b(A.sheenRoughnessMap.channel),specularMapUv:Be&&b(A.specularMap.channel),specularColorMapUv:Se&&b(A.specularColorMap.channel),specularIntensityMapUv:Xe&&b(A.specularIntensityMap.channel),transmissionMapUv:Ne&&b(A.transmissionMap.channel),thicknessMapUv:tt&&b(A.thicknessMap.channel),alphaMapUv:We&&b(A.alphaMap.channel),vertexTangents:!!$.attributes.tangent&&(q||ke),vertexColors:A.vertexColors,vertexAlphas:A.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,pointsUvs:H.isPoints===!0&&!!$.attributes.uv&&(Oe||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:Pe,skinning:H.isSkinnedMesh===!0,morphTargets:$.morphAttributes.position!==void 0,morphNormals:$.morphAttributes.normal!==void 0,morphColors:$.morphAttributes.color!==void 0,morphTargetsCount:B,morphTextureStride:X,numDirLights:D.directional.length,numPointLights:D.point.length,numSpotLights:D.spot.length,numSpotLightMaps:D.spotLightMap.length,numRectAreaLights:D.rectArea.length,numHemiLights:D.hemi.length,numDirLightShadows:D.directionalShadowMap.length,numPointLightShadows:D.pointShadowMap.length,numSpotLightShadows:D.spotShadowMap.length,numSpotLightShadowsWithMaps:D.numSpotLightShadowsWithMaps,numLightProbes:D.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:A.dithering,shadowMapEnabled:t.shadowMap.enabled&&U.length>0,shadowMapType:t.shadowMap.type,toneMapping:Ye,decodeVideoTexture:Oe&&A.map.isVideoTexture===!0&&sr.getTransfer(A.map.colorSpace)===Mr,decodeVideoTextureEmissive:I&&A.emissiveMap.isVideoTexture===!0&&sr.getTransfer(A.emissiveMap.colorSpace)===Mr,premultipliedAlpha:A.premultipliedAlpha,doubleSided:A.side===ic,flipSided:A.side===Us,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||Me)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:A.customProgramCacheKey()};return xt.vertexUv1s=u.has(1),xt.vertexUv2s=u.has(2),xt.vertexUv3s=u.has(3),u.clear(),xt}function v(A){const D=[];if(A.shaderID?D.push(A.shaderID):(D.push(A.customVertexShaderID),D.push(A.customFragmentShaderID)),A.defines!==void 0)for(const U in A.defines)D.push(U),D.push(A.defines[U]);return A.isRawShaderMaterial===!1&&(S(D,A),M(D,A),D.push(t.outputColorSpace)),D.push(A.customProgramCacheKey),D.join()}function S(A,D){A.push(D.precision),A.push(D.outputColorSpace),A.push(D.envMapMode),A.push(D.envMapCubeUVHeight),A.push(D.mapUv),A.push(D.alphaMapUv),A.push(D.lightMapUv),A.push(D.aoMapUv),A.push(D.bumpMapUv),A.push(D.normalMapUv),A.push(D.displacementMapUv),A.push(D.emissiveMapUv),A.push(D.metalnessMapUv),A.push(D.roughnessMapUv),A.push(D.anisotropyMapUv),A.push(D.clearcoatMapUv),A.push(D.clearcoatNormalMapUv),A.push(D.clearcoatRoughnessMapUv),A.push(D.iridescenceMapUv),A.push(D.iridescenceThicknessMapUv),A.push(D.sheenColorMapUv),A.push(D.sheenRoughnessMapUv),A.push(D.specularMapUv),A.push(D.specularColorMapUv),A.push(D.specularIntensityMapUv),A.push(D.transmissionMapUv),A.push(D.thicknessMapUv),A.push(D.combine),A.push(D.fogExp2),A.push(D.sizeAttenuation),A.push(D.morphTargetsCount),A.push(D.morphAttributeCount),A.push(D.numDirLights),A.push(D.numPointLights),A.push(D.numSpotLights),A.push(D.numSpotLightMaps),A.push(D.numHemiLights),A.push(D.numRectAreaLights),A.push(D.numDirLightShadows),A.push(D.numPointLightShadows),A.push(D.numSpotLightShadows),A.push(D.numSpotLightShadowsWithMaps),A.push(D.numLightProbes),A.push(D.shadowMapType),A.push(D.toneMapping),A.push(D.numClippingPlanes),A.push(D.numClipIntersection),A.push(D.depthPacking)}function M(A,D){l.disableAll(),D.supportsVertexTextures&&l.enable(0),D.instancing&&l.enable(1),D.instancingColor&&l.enable(2),D.instancingMorph&&l.enable(3),D.matcap&&l.enable(4),D.envMap&&l.enable(5),D.normalMapObjectSpace&&l.enable(6),D.normalMapTangentSpace&&l.enable(7),D.clearcoat&&l.enable(8),D.iridescence&&l.enable(9),D.alphaTest&&l.enable(10),D.vertexColors&&l.enable(11),D.vertexAlphas&&l.enable(12),D.vertexUv1s&&l.enable(13),D.vertexUv2s&&l.enable(14),D.vertexUv3s&&l.enable(15),D.vertexTangents&&l.enable(16),D.anisotropy&&l.enable(17),D.alphaHash&&l.enable(18),D.batching&&l.enable(19),D.dispersion&&l.enable(20),D.batchingColor&&l.enable(21),D.gradientMap&&l.enable(22),A.push(l.mask),l.disableAll(),D.fog&&l.enable(0),D.useFog&&l.enable(1),D.flatShading&&l.enable(2),D.logarithmicDepthBuffer&&l.enable(3),D.reversedDepthBuffer&&l.enable(4),D.skinning&&l.enable(5),D.morphTargets&&l.enable(6),D.morphNormals&&l.enable(7),D.morphColors&&l.enable(8),D.premultipliedAlpha&&l.enable(9),D.shadowMapEnabled&&l.enable(10),D.doubleSided&&l.enable(11),D.flipSided&&l.enable(12),D.useDepthPacking&&l.enable(13),D.dithering&&l.enable(14),D.transmission&&l.enable(15),D.sheen&&l.enable(16),D.opaque&&l.enable(17),D.pointsUvs&&l.enable(18),D.decodeVideoTexture&&l.enable(19),D.decodeVideoTextureEmissive&&l.enable(20),D.alphaToCoverage&&l.enable(21),A.push(l.mask)}function T(A){const D=x[A.type];let U;if(D){const F=rc[D];U=MPe.clone(F.uniforms)}else U=A.uniforms;return U}function E(A,D){let U;for(let F=0,H=d.length;F<H;F++){const j=d[F];if(j.cacheKey===D){U=j,++U.usedTimes;break}}return U===void 0&&(U=new r4e(t,D,A,a),d.push(U)),U}function C(A){if(--A.usedTimes===0){const D=d.indexOf(A);d[D]=d[d.length-1],d.pop(),A.destroy()}}function k(A){c.remove(A)}function R(){c.dispose()}return{getParameters:y,getProgramCacheKey:v,getUniforms:T,acquireProgram:E,releaseProgram:C,releaseShaderCache:k,programs:d,dispose:R}}function l4e(){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 a(){t=new WeakMap}return{has:e,get:n,remove:r,update:i,dispose:a}}function c4e(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function EV(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function kV(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function o(f,p,m,x,b,y){let v=t[e];return v===void 0?(v={id:f.id,object:f,geometry:p,material:m,groupOrder:x,renderOrder:f.renderOrder,z:b,group:y},t[e]=v):(v.id=f.id,v.object=f,v.geometry=p,v.material=m,v.groupOrder=x,v.renderOrder=f.renderOrder,v.z=b,v.group=y),e++,v}function l(f,p,m,x,b,y){const v=o(f,p,m,x,b,y);m.transmission>0?r.push(v):m.transparent===!0?i.push(v):n.push(v)}function c(f,p,m,x,b,y){const v=o(f,p,m,x,b,y);m.transmission>0?r.unshift(v):m.transparent===!0?i.unshift(v):n.unshift(v)}function u(f,p){n.length>1&&n.sort(f||c4e),r.length>1&&r.sort(p||EV),i.length>1&&i.sort(p||EV)}function d(){for(let f=e,p=t.length;f<p;f++){const m=t[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function u4e(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new kV,t.set(r,[o])):i>=a.length?(o=new kV,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function d4e(){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 dt,color:new Bn};break;case"SpotLight":n={position:new dt,direction:new dt,color:new Bn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new dt,color:new Bn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new dt,skyColor:new Bn,groundColor:new Bn};break;case"RectAreaLight":n={color:new Bn,position:new dt,halfWidth:new dt,halfHeight:new dt};break}return t[e.id]=n,n}}}function h4e(){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 Tn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Tn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Tn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let f4e=0;function m4e(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function p4e(t){const e=new d4e,n=h4e(),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 dt);const i=new dt,a=new Vi,o=new Vi;function l(u){let d=0,f=0,p=0;for(let A=0;A<9;A++)r.probe[A].set(0,0,0);let m=0,x=0,b=0,y=0,v=0,S=0,M=0,T=0,E=0,C=0,k=0;u.sort(m4e);for(let A=0,D=u.length;A<D;A++){const U=u[A],F=U.color,H=U.intensity,j=U.distance,$=U.shadow&&U.shadow.map?U.shadow.map.texture:null;if(U.isAmbientLight)d+=F.r*H,f+=F.g*H,p+=F.b*H;else if(U.isLightProbe){for(let K=0;K<9;K++)r.probe[K].addScaledVector(U.sh.coefficients[K],H);k++}else if(U.isDirectionalLight){const K=e.get(U);if(K.color.copy(U.color).multiplyScalar(U.intensity),U.castShadow){const V=U.shadow,Q=n.get(U);Q.shadowIntensity=V.intensity,Q.shadowBias=V.bias,Q.shadowNormalBias=V.normalBias,Q.shadowRadius=V.radius,Q.shadowMapSize=V.mapSize,r.directionalShadow[m]=Q,r.directionalShadowMap[m]=$,r.directionalShadowMatrix[m]=U.shadow.matrix,S++}r.directional[m]=K,m++}else if(U.isSpotLight){const K=e.get(U);K.position.setFromMatrixPosition(U.matrixWorld),K.color.copy(F).multiplyScalar(H),K.distance=j,K.coneCos=Math.cos(U.angle),K.penumbraCos=Math.cos(U.angle*(1-U.penumbra)),K.decay=U.decay,r.spot[b]=K;const V=U.shadow;if(U.map&&(r.spotLightMap[E]=U.map,E++,V.updateMatrices(U),U.castShadow&&C++),r.spotLightMatrix[b]=V.matrix,U.castShadow){const Q=n.get(U);Q.shadowIntensity=V.intensity,Q.shadowBias=V.bias,Q.shadowNormalBias=V.normalBias,Q.shadowRadius=V.radius,Q.shadowMapSize=V.mapSize,r.spotShadow[b]=Q,r.spotShadowMap[b]=$,T++}b++}else if(U.isRectAreaLight){const K=e.get(U);K.color.copy(F).multiplyScalar(H),K.halfWidth.set(U.width*.5,0,0),K.halfHeight.set(0,U.height*.5,0),r.rectArea[y]=K,y++}else if(U.isPointLight){const K=e.get(U);if(K.color.copy(U.color).multiplyScalar(U.intensity),K.distance=U.distance,K.decay=U.decay,U.castShadow){const V=U.shadow,Q=n.get(U);Q.shadowIntensity=V.intensity,Q.shadowBias=V.bias,Q.shadowNormalBias=V.normalBias,Q.shadowRadius=V.radius,Q.shadowMapSize=V.mapSize,Q.shadowCameraNear=V.camera.near,Q.shadowCameraFar=V.camera.far,r.pointShadow[x]=Q,r.pointShadowMap[x]=$,r.pointShadowMatrix[x]=U.shadow.matrix,M++}r.point[x]=K,x++}else if(U.isHemisphereLight){const K=e.get(U);K.skyColor.copy(U.color).multiplyScalar(H),K.groundColor.copy(U.groundColor).multiplyScalar(H),r.hemi[v]=K,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]=p;const R=r.hash;(R.directionalLength!==m||R.pointLength!==x||R.spotLength!==b||R.rectAreaLength!==y||R.hemiLength!==v||R.numDirectionalShadows!==S||R.numPointShadows!==M||R.numSpotShadows!==T||R.numSpotMaps!==E||R.numLightProbes!==k)&&(r.directional.length=m,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=M,r.pointShadowMap.length=M,r.spotShadow.length=T,r.spotShadowMap.length=T,r.directionalShadowMatrix.length=S,r.pointShadowMatrix.length=M,r.spotLightMatrix.length=T+E-C,r.spotLightMap.length=E,r.numSpotLightShadowsWithMaps=C,r.numLightProbes=k,R.directionalLength=m,R.pointLength=x,R.spotLength=b,R.rectAreaLength=y,R.hemiLength=v,R.numDirectionalShadows=S,R.numPointShadows=M,R.numSpotShadows=T,R.numSpotMaps=E,R.numLightProbes=k,r.version=f4e++)}function c(u,d){let f=0,p=0,m=0,x=0,b=0;const y=d.matrixWorldInverse;for(let v=0,S=u.length;v<S;v++){const M=u[v];if(M.isDirectionalLight){const T=r.directional[f];T.direction.setFromMatrixPosition(M.matrixWorld),i.setFromMatrixPosition(M.target.matrixWorld),T.direction.sub(i),T.direction.transformDirection(y),f++}else if(M.isSpotLight){const T=r.spot[m];T.position.setFromMatrixPosition(M.matrixWorld),T.position.applyMatrix4(y),T.direction.setFromMatrixPosition(M.matrixWorld),i.setFromMatrixPosition(M.target.matrixWorld),T.direction.sub(i),T.direction.transformDirection(y),m++}else if(M.isRectAreaLight){const T=r.rectArea[x];T.position.setFromMatrixPosition(M.matrixWorld),T.position.applyMatrix4(y),o.identity(),a.copy(M.matrixWorld),a.premultiply(y),o.extractRotation(a),T.halfWidth.set(M.width*.5,0,0),T.halfHeight.set(0,M.height*.5,0),T.halfWidth.applyMatrix4(o),T.halfHeight.applyMatrix4(o),x++}else if(M.isPointLight){const T=r.point[p];T.position.setFromMatrixPosition(M.matrixWorld),T.position.applyMatrix4(y),p++}else if(M.isHemisphereLight){const T=r.hemi[b];T.direction.setFromMatrixPosition(M.matrixWorld),T.direction.transformDirection(y),b++}}}return{setup:l,setupView:c,state:r}}function TV(t){const e=new p4e(t),n=[],r=[];function i(d){u.camera=d,n.length=0,r.length=0}function a(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:a,pushShadow:o}}function g4e(t){let e=new WeakMap;function n(i,a=0){const o=e.get(i);let l;return o===void 0?(l=new TV(t),e.set(i,[l])):a>=o.length?(l=new TV(t),o.push(l)):l=o[a],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const x4e=`void main() {
  3877. gl_Position = vec4( position, 1.0 );
  3878. }`,b4e=`uniform sampler2D shadow_pass;
  3879. uniform vec2 resolution;
  3880. uniform float radius;
  3881. #include <packing>
  3882. void main() {
  3883. const float samples = float( VSM_SAMPLES );
  3884. float mean = 0.0;
  3885. float squared_mean = 0.0;
  3886. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  3887. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  3888. for ( float i = 0.0; i < samples; i ++ ) {
  3889. float uvOffset = uvStart + i * uvStride;
  3890. #ifdef HORIZONTAL_PASS
  3891. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  3892. mean += distribution.x;
  3893. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  3894. #else
  3895. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  3896. mean += depth;
  3897. squared_mean += depth * depth;
  3898. #endif
  3899. }
  3900. mean = mean / samples;
  3901. squared_mean = squared_mean / samples;
  3902. float std_dev = sqrt( squared_mean - mean * mean );
  3903. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  3904. }`;function y4e(t,e,n){let r=new eL;const i=new Tn,a=new Tn,o=new Ui,l=new UPe({depthPacking:Kje}),c=new zPe,u={},d=n.maxTextureSize,f={[Eh]:Us,[Us]:Eh,[ic]:ic},p=new Hu({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Tn},radius:{value:4}},vertexShader:x4e,fragmentShader:b4e}),m=p.clone();m.defines.HORIZONTAL_PASS=1;const x=new Ac;x.setAttribute("position",new nl(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const b=new vc(x,p),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=XZ;let v=this.type;this.render=function(C,k,R){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||C.length===0)return;const A=t.getRenderTarget(),D=t.getActiveCubeFace(),U=t.getActiveMipmapLevel(),F=t.state;F.setBlending(Tu),F.buffers.depth.getReversed()===!0?F.buffers.color.setClear(0,0,0,0):F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const H=v!==ou&&this.type===ou,j=v===ou&&this.type!==ou;for(let $=0,K=C.length;$<K;$++){const V=C[$],Q=V.shadow;if(Q===void 0){gn("WebGLShadowMap:",V,"has no shadow.");continue}if(Q.autoUpdate===!1&&Q.needsUpdate===!1)continue;i.copy(Q.mapSize);const Z=Q.getFrameExtents();if(i.multiply(Z),a.copy(Q.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/Z.x),i.x=a.x*Z.x,Q.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/Z.y),i.y=a.y*Z.y,Q.mapSize.y=a.y)),Q.map===null||H===!0||j===!0){const B=this.type!==ou?{minFilter:po,magFilter:po}:{};Q.map!==null&&Q.map.dispose(),Q.map=new xm(i.x,i.y,B),Q.map.texture.name=V.name+".shadowMap",Q.camera.updateProjectionMatrix()}t.setRenderTarget(Q.map),t.clear();const ae=Q.getViewportCount();for(let B=0;B<ae;B++){const X=Q.getViewport(B);o.set(a.x*X.x,a.y*X.y,a.x*X.z,a.y*X.w),F.viewport(o),Q.updateMatrices(V,B),r=Q.getFrustum(),T(k,R,Q.camera,V,this.type)}Q.isPointLightShadow!==!0&&this.type===ou&&S(Q,R),Q.needsUpdate=!1}v=this.type,y.needsUpdate=!1,t.setRenderTarget(A,D,U)};function S(C,k){const R=e.update(b);p.defines.VSM_SAMPLES!==C.blurSamples&&(p.defines.VSM_SAMPLES=C.blurSamples,m.defines.VSM_SAMPLES=C.blurSamples,p.needsUpdate=!0,m.needsUpdate=!0),C.mapPass===null&&(C.mapPass=new xm(i.x,i.y)),p.uniforms.shadow_pass.value=C.map.texture,p.uniforms.resolution.value=C.mapSize,p.uniforms.radius.value=C.radius,t.setRenderTarget(C.mapPass),t.clear(),t.renderBufferDirect(k,null,R,p,b,null),m.uniforms.shadow_pass.value=C.mapPass.texture,m.uniforms.resolution.value=C.mapSize,m.uniforms.radius.value=C.radius,t.setRenderTarget(C.map),t.clear(),t.renderBufferDirect(k,null,R,m,b,null)}function M(C,k,R,A){let D=null;const U=R.isPointLight===!0?C.customDistanceMaterial:C.customDepthMaterial;if(U!==void 0)D=U;else if(D=R.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||k.alphaToCoverage===!0){const F=D.uuid,H=k.uuid;let j=u[F];j===void 0&&(j={},u[F]=j);let $=j[H];$===void 0&&($=D.clone(),j[H]=$,k.addEventListener("dispose",E)),D=$}if(D.visible=k.visible,D.wireframe=k.wireframe,A===ou?D.side=k.shadowSide!==null?k.shadowSide:k.side:D.side=k.shadowSide!==null?k.shadowSide:f[k.side],D.alphaMap=k.alphaMap,D.alphaTest=k.alphaToCoverage===!0?.5:k.alphaTest,D.map=k.map,D.clipShadows=k.clipShadows,D.clippingPlanes=k.clippingPlanes,D.clipIntersection=k.clipIntersection,D.displacementMap=k.displacementMap,D.displacementScale=k.displacementScale,D.displacementBias=k.displacementBias,D.wireframeLinewidth=k.wireframeLinewidth,D.linewidth=k.linewidth,R.isPointLight===!0&&D.isMeshDistanceMaterial===!0){const F=t.properties.get(D);F.light=R}return D}function T(C,k,R,A,D){if(C.visible===!1)return;if(C.layers.test(k.layers)&&(C.isMesh||C.isLine||C.isPoints)&&(C.castShadow||C.receiveShadow&&D===ou)&&(!C.frustumCulled||r.intersectsObject(C))){C.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse,C.matrixWorld);const H=e.update(C),j=C.material;if(Array.isArray(j)){const $=H.groups;for(let K=0,V=$.length;K<V;K++){const Q=$[K],Z=j[Q.materialIndex];if(Z&&Z.visible){const ae=M(C,Z,A,D);C.onBeforeShadow(t,C,k,R,H,ae,Q),t.renderBufferDirect(R,null,H,ae,C,Q),C.onAfterShadow(t,C,k,R,H,ae,Q)}}}else if(j.visible){const $=M(C,j,A,D);C.onBeforeShadow(t,C,k,R,H,$,null),t.renderBufferDirect(R,null,H,$,C,null),C.onAfterShadow(t,C,k,R,H,$,null)}}const F=C.children;for(let H=0,j=F.length;H<j;H++)T(F[H],k,R,A,D)}function E(C){C.target.removeEventListener("dispose",E);for(const R in u){const A=u[R],D=C.target.uuid;D in A&&(A[D].dispose(),delete A[D])}}}const v4e={[M3]:E3,[k3]:C3,[T3]:j3,[Qg]:A3,[E3]:M3,[C3]:k3,[j3]:T3,[A3]:Qg};function w4e(t,e){function n(){let Ne=!1;const tt=new Ui;let Ee=null;const We=new Ui(0,0,0,0);return{setMask:function(ze){Ee!==ze&&!Ne&&(t.colorMask(ze,ze,ze,ze),Ee=ze)},setLocked:function(ze){Ne=ze},setClear:function(ze,W,De,Ye,xt){xt===!0&&(ze*=Ye,W*=Ye,De*=Ye),tt.set(ze,W,De,Ye),We.equals(tt)===!1&&(t.clearColor(ze,W,De,Ye),We.copy(tt))},reset:function(){Ne=!1,Ee=null,We.set(-1,0,0,0)}}}function r(){let Ne=!1,tt=!1,Ee=null,We=null,ze=null;return{setReversed:function(W){if(tt!==W){const De=e.get("EXT_clip_control");W?De.clipControlEXT(De.LOWER_LEFT_EXT,De.ZERO_TO_ONE_EXT):De.clipControlEXT(De.LOWER_LEFT_EXT,De.NEGATIVE_ONE_TO_ONE_EXT),tt=W;const Ye=ze;ze=null,this.setClear(Ye)}},getReversed:function(){return tt},setTest:function(W){W?de(t.DEPTH_TEST):Pe(t.DEPTH_TEST)},setMask:function(W){Ee!==W&&!Ne&&(t.depthMask(W),Ee=W)},setFunc:function(W){if(tt&&(W=v4e[W]),We!==W){switch(W){case M3:t.depthFunc(t.NEVER);break;case E3:t.depthFunc(t.ALWAYS);break;case k3:t.depthFunc(t.LESS);break;case Qg:t.depthFunc(t.LEQUAL);break;case T3:t.depthFunc(t.EQUAL);break;case A3:t.depthFunc(t.GEQUAL);break;case C3:t.depthFunc(t.GREATER);break;case j3:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}We=W}},setLocked:function(W){Ne=W},setClear:function(W){ze!==W&&(tt&&(W=1-W),t.clearDepth(W),ze=W)},reset:function(){Ne=!1,Ee=null,We=null,ze=null,tt=!1}}}function i(){let Ne=!1,tt=null,Ee=null,We=null,ze=null,W=null,De=null,Ye=null,xt=null;return{setTest:function(ft){Ne||(ft?de(t.STENCIL_TEST):Pe(t.STENCIL_TEST))},setMask:function(ft){tt!==ft&&!Ne&&(t.stencilMask(ft),tt=ft)},setFunc:function(ft,Bt,Lt){(Ee!==ft||We!==Bt||ze!==Lt)&&(t.stencilFunc(ft,Bt,Lt),Ee=ft,We=Bt,ze=Lt)},setOp:function(ft,Bt,Lt){(W!==ft||De!==Bt||Ye!==Lt)&&(t.stencilOp(ft,Bt,Lt),W=ft,De=Bt,Ye=Lt)},setLocked:function(ft){Ne=ft},setClear:function(ft){xt!==ft&&(t.clearStencil(ft),xt=ft)},reset:function(){Ne=!1,tt=null,Ee=null,We=null,ze=null,W=null,De=null,Ye=null,xt=null}}}const a=new n,o=new r,l=new i,c=new WeakMap,u=new WeakMap;let d={},f={},p=new WeakMap,m=[],x=null,b=!1,y=null,v=null,S=null,M=null,T=null,E=null,C=null,k=new Bn(0,0,0),R=0,A=!1,D=null,U=null,F=null,H=null,j=null;const $=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,V=0;const Q=t.getParameter(t.VERSION);Q.indexOf("WebGL")!==-1?(V=parseFloat(/^WebGL (\d)/.exec(Q)[1]),K=V>=1):Q.indexOf("OpenGL ES")!==-1&&(V=parseFloat(/^OpenGL ES (\d)/.exec(Q)[1]),K=V>=2);let Z=null,ae={};const B=t.getParameter(t.SCISSOR_BOX),X=t.getParameter(t.VIEWPORT),ne=new Ui().fromArray(B),se=new Ui().fromArray(X);function be(Ne,tt,Ee,We){const ze=new Uint8Array(4),W=t.createTexture();t.bindTexture(Ne,W),t.texParameteri(Ne,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(Ne,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let De=0;De<Ee;De++)Ne===t.TEXTURE_3D||Ne===t.TEXTURE_2D_ARRAY?t.texImage3D(tt,0,t.RGBA,1,1,We,0,t.RGBA,t.UNSIGNED_BYTE,ze):t.texImage2D(tt+De,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,ze);return W}const xe={};xe[t.TEXTURE_2D]=be(t.TEXTURE_2D,t.TEXTURE_2D,1),xe[t.TEXTURE_CUBE_MAP]=be(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),xe[t.TEXTURE_2D_ARRAY]=be(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),xe[t.TEXTURE_3D]=be(t.TEXTURE_3D,t.TEXTURE_3D,1,1),a.setClear(0,0,0,1),o.setClear(1),l.setClear(0),de(t.DEPTH_TEST),o.setFunc(Qg),ce(!1),q(EH),de(t.CULL_FACE),G(Tu);function de(Ne){d[Ne]!==!0&&(t.enable(Ne),d[Ne]=!0)}function Pe(Ne){d[Ne]!==!1&&(t.disable(Ne),d[Ne]=!1)}function ie(Ne,tt){return f[Ne]!==tt?(t.bindFramebuffer(Ne,tt),f[Ne]=tt,Ne===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=tt),Ne===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=tt),!0):!1}function Me(Ne,tt){let Ee=m,We=!1;if(Ne){Ee=p.get(tt),Ee===void 0&&(Ee=[],p.set(tt,Ee));const ze=Ne.textures;if(Ee.length!==ze.length||Ee[0]!==t.COLOR_ATTACHMENT0){for(let W=0,De=ze.length;W<De;W++)Ee[W]=t.COLOR_ATTACHMENT0+W;Ee.length=ze.length,We=!0}}else Ee[0]!==t.BACK&&(Ee[0]=t.BACK,We=!0);We&&t.drawBuffers(Ee)}function Oe(Ne){return x!==Ne?(t.useProgram(Ne),x=Ne,!0):!1}const ge={[Nf]:t.FUNC_ADD,[vje]:t.FUNC_SUBTRACT,[wje]:t.FUNC_REVERSE_SUBTRACT};ge[_je]=t.MIN,ge[Sje]=t.MAX;const Ke={[Nje]:t.ZERO,[Mje]:t.ONE,[Eje]:t.SRC_COLOR,[S3]:t.SRC_ALPHA,[Pje]:t.SRC_ALPHA_SATURATE,[Cje]:t.DST_COLOR,[Tje]:t.DST_ALPHA,[kje]:t.ONE_MINUS_SRC_COLOR,[N3]:t.ONE_MINUS_SRC_ALPHA,[jje]:t.ONE_MINUS_DST_COLOR,[Aje]:t.ONE_MINUS_DST_ALPHA,[Dje]:t.CONSTANT_COLOR,[Rje]:t.ONE_MINUS_CONSTANT_COLOR,[Oje]:t.CONSTANT_ALPHA,[Lje]:t.ONE_MINUS_CONSTANT_ALPHA};function G(Ne,tt,Ee,We,ze,W,De,Ye,xt,ft){if(Ne===Tu){b===!0&&(Pe(t.BLEND),b=!1);return}if(b===!1&&(de(t.BLEND),b=!0),Ne!==yje){if(Ne!==y||ft!==A){if((v!==Nf||T!==Nf)&&(t.blendEquation(t.FUNC_ADD),v=Nf,T=Nf),ft)switch(Ne){case Ag:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case kH:t.blendFunc(t.ONE,t.ONE);break;case TH:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case AH:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:ki("WebGLState: Invalid blending: ",Ne);break}else switch(Ne){case Ag:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case kH:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case TH:ki("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case AH:ki("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ki("WebGLState: Invalid blending: ",Ne);break}S=null,M=null,E=null,C=null,k.set(0,0,0),R=0,y=Ne,A=ft}return}ze=ze||tt,W=W||Ee,De=De||We,(tt!==v||ze!==T)&&(t.blendEquationSeparate(ge[tt],ge[ze]),v=tt,T=ze),(Ee!==S||We!==M||W!==E||De!==C)&&(t.blendFuncSeparate(Ke[Ee],Ke[We],Ke[W],Ke[De]),S=Ee,M=We,E=W,C=De),(Ye.equals(k)===!1||xt!==R)&&(t.blendColor(Ye.r,Ye.g,Ye.b,xt),k.copy(Ye),R=xt),y=Ne,A=!1}function Y(Ne,tt){Ne.side===ic?Pe(t.CULL_FACE):de(t.CULL_FACE);let Ee=Ne.side===Us;tt&&(Ee=!Ee),ce(Ee),Ne.blending===Ag&&Ne.transparent===!1?G(Tu):G(Ne.blending,Ne.blendEquation,Ne.blendSrc,Ne.blendDst,Ne.blendEquationAlpha,Ne.blendSrcAlpha,Ne.blendDstAlpha,Ne.blendColor,Ne.blendAlpha,Ne.premultipliedAlpha),o.setFunc(Ne.depthFunc),o.setTest(Ne.depthTest),o.setMask(Ne.depthWrite),a.setMask(Ne.colorWrite);const We=Ne.stencilWrite;l.setTest(We),We&&(l.setMask(Ne.stencilWriteMask),l.setFunc(Ne.stencilFunc,Ne.stencilRef,Ne.stencilFuncMask),l.setOp(Ne.stencilFail,Ne.stencilZFail,Ne.stencilZPass)),I(Ne.polygonOffset,Ne.polygonOffsetFactor,Ne.polygonOffsetUnits),Ne.alphaToCoverage===!0?de(t.SAMPLE_ALPHA_TO_COVERAGE):Pe(t.SAMPLE_ALPHA_TO_COVERAGE)}function ce(Ne){D!==Ne&&(Ne?t.frontFace(t.CW):t.frontFace(t.CCW),D=Ne)}function q(Ne){Ne!==gje?(de(t.CULL_FACE),Ne!==U&&(Ne===EH?t.cullFace(t.BACK):Ne===xje?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Pe(t.CULL_FACE),U=Ne}function te(Ne){Ne!==F&&(K&&t.lineWidth(Ne),F=Ne)}function I(Ne,tt,Ee){Ne?(de(t.POLYGON_OFFSET_FILL),(H!==tt||j!==Ee)&&(t.polygonOffset(tt,Ee),H=tt,j=Ee)):Pe(t.POLYGON_OFFSET_FILL)}function fe(Ne){Ne?de(t.SCISSOR_TEST):Pe(t.SCISSOR_TEST)}function me(Ne){Ne===void 0&&(Ne=t.TEXTURE0+$-1),Z!==Ne&&(t.activeTexture(Ne),Z=Ne)}function ke(Ne,tt,Ee){Ee===void 0&&(Z===null?Ee=t.TEXTURE0+$-1:Ee=Z);let We=ae[Ee];We===void 0&&(We={type:void 0,texture:void 0},ae[Ee]=We),(We.type!==Ne||We.texture!==tt)&&(Z!==Ee&&(t.activeTexture(Ee),Z=Ee),t.bindTexture(Ne,tt||xe[Ne]),We.type=Ne,We.texture=tt)}function z(){const Ne=ae[Z];Ne!==void 0&&Ne.type!==void 0&&(t.bindTexture(Ne.type,null),Ne.type=void 0,Ne.texture=void 0)}function O(){try{t.compressedTexImage2D(...arguments)}catch(Ne){Ne("WebGLState:",Ne)}}function ee(){try{t.compressedTexImage3D(...arguments)}catch(Ne){Ne("WebGLState:",Ne)}}function le(){try{t.texSubImage2D(...arguments)}catch(Ne){Ne("WebGLState:",Ne)}}function _e(){try{t.texSubImage3D(...arguments)}catch(Ne){Ne("WebGLState:",Ne)}}function we(){try{t.compressedTexSubImage2D(...arguments)}catch(Ne){Ne("WebGLState:",Ne)}}function re(){try{t.compressedTexSubImage3D(...arguments)}catch(Ne){Ne("WebGLState:",Ne)}}function Fe(){try{t.texStorage2D(...arguments)}catch(Ne){Ne("WebGLState:",Ne)}}function $e(){try{t.texStorage3D(...arguments)}catch(Ne){Ne("WebGLState:",Ne)}}function Ve(){try{t.texImage2D(...arguments)}catch(Ne){Ne("WebGLState:",Ne)}}function He(){try{t.texImage3D(...arguments)}catch(Ne){Ne("WebGLState:",Ne)}}function ye(Ne){ne.equals(Ne)===!1&&(t.scissor(Ne.x,Ne.y,Ne.z,Ne.w),ne.copy(Ne))}function je(Ne){se.equals(Ne)===!1&&(t.viewport(Ne.x,Ne.y,Ne.z,Ne.w),se.copy(Ne))}function Be(Ne,tt){let Ee=u.get(tt);Ee===void 0&&(Ee=new WeakMap,u.set(tt,Ee));let We=Ee.get(Ne);We===void 0&&(We=t.getUniformBlockIndex(tt,Ne.name),Ee.set(Ne,We))}function Se(Ne,tt){const We=u.get(tt).get(Ne);c.get(tt)!==We&&(t.uniformBlockBinding(tt,We,Ne.__bindingPointIndex),c.set(tt,We))}function Xe(){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,ae={},f={},p=new WeakMap,m=[],x=null,b=!1,y=null,v=null,S=null,M=null,T=null,E=null,C=null,k=new Bn(0,0,0),R=0,A=!1,D=null,U=null,F=null,H=null,j=null,ne.set(0,0,t.canvas.width,t.canvas.height),se.set(0,0,t.canvas.width,t.canvas.height),a.reset(),o.reset(),l.reset()}return{buffers:{color:a,depth:o,stencil:l},enable:de,disable:Pe,bindFramebuffer:ie,drawBuffers:Me,useProgram:Oe,setBlending:G,setMaterial:Y,setFlipSided:ce,setCullFace:q,setLineWidth:te,setPolygonOffset:I,setScissorTest:fe,activeTexture:me,bindTexture:ke,unbindTexture:z,compressedTexImage2D:O,compressedTexImage3D:ee,texImage2D:Ve,texImage3D:He,updateUBOMapping:Be,uniformBlockBinding:Se,texStorage2D:Fe,texStorage3D:$e,texSubImage2D:le,texSubImage3D:_e,compressedTexSubImage2D:we,compressedTexSubImage3D:re,scissor:ye,viewport:je,reset:Xe}}function _4e(t,e,n,r,i,a,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 Tn,d=new WeakMap;let f;const p=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(z,O){return m?new OffscreenCanvas(z,O):XS("canvas")}function b(z,O,ee){let le=1;const _e=ke(z);if((_e.width>ee||_e.height>ee)&&(le=ee/Math.max(_e.width,_e.height)),le<1)if(typeof HTMLImageElement<"u"&&z instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&z instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&z instanceof ImageBitmap||typeof VideoFrame<"u"&&z instanceof VideoFrame){const we=Math.floor(le*_e.width),re=Math.floor(le*_e.height);f===void 0&&(f=x(we,re));const Fe=O?x(we,re):f;return Fe.width=we,Fe.height=re,Fe.getContext("2d").drawImage(z,0,0,we,re),gn("WebGLRenderer: Texture has been resized from ("+_e.width+"x"+_e.height+") to ("+we+"x"+re+")."),Fe}else return"data"in z&&gn("WebGLRenderer: Image in DataTexture is too big ("+_e.width+"x"+_e.height+")."),z;return z}function y(z){return z.generateMipmaps}function v(z){t.generateMipmap(z)}function S(z){return z.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:z.isWebGL3DRenderTarget?t.TEXTURE_3D:z.isWebGLArrayRenderTarget||z.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function M(z,O,ee,le,_e=!1){if(z!==null){if(t[z]!==void 0)return t[z];gn("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+z+"'")}let we=O;if(O===t.RED&&(ee===t.FLOAT&&(we=t.R32F),ee===t.HALF_FLOAT&&(we=t.R16F),ee===t.UNSIGNED_BYTE&&(we=t.R8)),O===t.RED_INTEGER&&(ee===t.UNSIGNED_BYTE&&(we=t.R8UI),ee===t.UNSIGNED_SHORT&&(we=t.R16UI),ee===t.UNSIGNED_INT&&(we=t.R32UI),ee===t.BYTE&&(we=t.R8I),ee===t.SHORT&&(we=t.R16I),ee===t.INT&&(we=t.R32I)),O===t.RG&&(ee===t.FLOAT&&(we=t.RG32F),ee===t.HALF_FLOAT&&(we=t.RG16F),ee===t.UNSIGNED_BYTE&&(we=t.RG8)),O===t.RG_INTEGER&&(ee===t.UNSIGNED_BYTE&&(we=t.RG8UI),ee===t.UNSIGNED_SHORT&&(we=t.RG16UI),ee===t.UNSIGNED_INT&&(we=t.RG32UI),ee===t.BYTE&&(we=t.RG8I),ee===t.SHORT&&(we=t.RG16I),ee===t.INT&&(we=t.RG32I)),O===t.RGB_INTEGER&&(ee===t.UNSIGNED_BYTE&&(we=t.RGB8UI),ee===t.UNSIGNED_SHORT&&(we=t.RGB16UI),ee===t.UNSIGNED_INT&&(we=t.RGB32UI),ee===t.BYTE&&(we=t.RGB8I),ee===t.SHORT&&(we=t.RGB16I),ee===t.INT&&(we=t.RGB32I)),O===t.RGBA_INTEGER&&(ee===t.UNSIGNED_BYTE&&(we=t.RGBA8UI),ee===t.UNSIGNED_SHORT&&(we=t.RGBA16UI),ee===t.UNSIGNED_INT&&(we=t.RGBA32UI),ee===t.BYTE&&(we=t.RGBA8I),ee===t.SHORT&&(we=t.RGBA16I),ee===t.INT&&(we=t.RGBA32I)),O===t.RGB&&(ee===t.UNSIGNED_INT_5_9_9_9_REV&&(we=t.RGB9_E5),ee===t.UNSIGNED_INT_10F_11F_11F_REV&&(we=t.R11F_G11F_B10F)),O===t.RGBA){const re=_e?WS:sr.getTransfer(le);ee===t.FLOAT&&(we=t.RGBA32F),ee===t.HALF_FLOAT&&(we=t.RGBA16F),ee===t.UNSIGNED_BYTE&&(we=re===Mr?t.SRGB8_ALPHA8:t.RGBA8),ee===t.UNSIGNED_SHORT_4_4_4_4&&(we=t.RGBA4),ee===t.UNSIGNED_SHORT_5_5_5_1&&(we=t.RGB5_A1)}return(we===t.R16F||we===t.R32F||we===t.RG16F||we===t.RG32F||we===t.RGBA16F||we===t.RGBA32F)&&e.get("EXT_color_buffer_float"),we}function T(z,O){let ee;return z?O===null||O===pm||O===hy?ee=t.DEPTH24_STENCIL8:O===wu?ee=t.DEPTH32F_STENCIL8:O===dy&&(ee=t.DEPTH24_STENCIL8,gn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):O===null||O===pm||O===hy?ee=t.DEPTH_COMPONENT24:O===wu?ee=t.DEPTH_COMPONENT32F:O===dy&&(ee=t.DEPTH_COMPONENT16),ee}function E(z,O){return y(z)===!0||z.isFramebufferTexture&&z.minFilter!==po&&z.minFilter!==el?Math.log2(Math.max(O.width,O.height))+1:z.mipmaps!==void 0&&z.mipmaps.length>0?z.mipmaps.length:z.isCompressedTexture&&Array.isArray(z.image)?O.mipmaps.length:1}function C(z){const O=z.target;O.removeEventListener("dispose",C),R(O),O.isVideoTexture&&d.delete(O)}function k(z){const O=z.target;O.removeEventListener("dispose",k),D(O)}function R(z){const O=r.get(z);if(O.__webglInit===void 0)return;const ee=z.source,le=p.get(ee);if(le){const _e=le[O.__cacheKey];_e.usedTimes--,_e.usedTimes===0&&A(z),Object.keys(le).length===0&&p.delete(ee)}r.remove(z)}function A(z){const O=r.get(z);t.deleteTexture(O.__webglTexture);const ee=z.source,le=p.get(ee);delete le[O.__cacheKey],o.memory.textures--}function D(z){const O=r.get(z);if(z.depthTexture&&(z.depthTexture.dispose(),r.remove(z.depthTexture)),z.isWebGLCubeRenderTarget)for(let le=0;le<6;le++){if(Array.isArray(O.__webglFramebuffer[le]))for(let _e=0;_e<O.__webglFramebuffer[le].length;_e++)t.deleteFramebuffer(O.__webglFramebuffer[le][_e]);else t.deleteFramebuffer(O.__webglFramebuffer[le]);O.__webglDepthbuffer&&t.deleteRenderbuffer(O.__webglDepthbuffer[le])}else{if(Array.isArray(O.__webglFramebuffer))for(let le=0;le<O.__webglFramebuffer.length;le++)t.deleteFramebuffer(O.__webglFramebuffer[le]);else t.deleteFramebuffer(O.__webglFramebuffer);if(O.__webglDepthbuffer&&t.deleteRenderbuffer(O.__webglDepthbuffer),O.__webglMultisampledFramebuffer&&t.deleteFramebuffer(O.__webglMultisampledFramebuffer),O.__webglColorRenderbuffer)for(let le=0;le<O.__webglColorRenderbuffer.length;le++)O.__webglColorRenderbuffer[le]&&t.deleteRenderbuffer(O.__webglColorRenderbuffer[le]);O.__webglDepthRenderbuffer&&t.deleteRenderbuffer(O.__webglDepthRenderbuffer)}const ee=z.textures;for(let le=0,_e=ee.length;le<_e;le++){const we=r.get(ee[le]);we.__webglTexture&&(t.deleteTexture(we.__webglTexture),o.memory.textures--),r.remove(ee[le])}r.remove(z)}let U=0;function F(){U=0}function H(){const z=U;return z>=i.maxTextures&&gn("WebGLTextures: Trying to use "+z+" texture units while this GPU supports only "+i.maxTextures),U+=1,z}function j(z){const O=[];return O.push(z.wrapS),O.push(z.wrapT),O.push(z.wrapR||0),O.push(z.magFilter),O.push(z.minFilter),O.push(z.anisotropy),O.push(z.internalFormat),O.push(z.format),O.push(z.type),O.push(z.generateMipmaps),O.push(z.premultiplyAlpha),O.push(z.flipY),O.push(z.unpackAlignment),O.push(z.colorSpace),O.join()}function $(z,O){const ee=r.get(z);if(z.isVideoTexture&&fe(z),z.isRenderTargetTexture===!1&&z.isExternalTexture!==!0&&z.version>0&&ee.__version!==z.version){const le=z.image;if(le===null)gn("WebGLRenderer: Texture marked for update but no image data found.");else if(le.complete===!1)gn("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(ee,z,O);return}}else z.isExternalTexture&&(ee.__webglTexture=z.sourceTexture?z.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,ee.__webglTexture,t.TEXTURE0+O)}function K(z,O){const ee=r.get(z);if(z.isRenderTargetTexture===!1&&z.version>0&&ee.__version!==z.version){xe(ee,z,O);return}else z.isExternalTexture&&(ee.__webglTexture=z.sourceTexture?z.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,ee.__webglTexture,t.TEXTURE0+O)}function V(z,O){const ee=r.get(z);if(z.isRenderTargetTexture===!1&&z.version>0&&ee.__version!==z.version){xe(ee,z,O);return}n.bindTexture(t.TEXTURE_3D,ee.__webglTexture,t.TEXTURE0+O)}function Q(z,O){const ee=r.get(z);if(z.version>0&&ee.__version!==z.version){de(ee,z,O);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ee.__webglTexture,t.TEXTURE0+O)}const Z={[R3]:t.REPEAT,[vu]:t.CLAMP_TO_EDGE,[O3]:t.MIRRORED_REPEAT},ae={[po]:t.NEAREST,[qje]:t.NEAREST_MIPMAP_NEAREST,[Zw]:t.NEAREST_MIPMAP_LINEAR,[el]:t.LINEAR,[GA]:t.LINEAR_MIPMAP_NEAREST,[Of]:t.LINEAR_MIPMAP_LINEAR},B={[Yje]:t.NEVER,[nPe]:t.ALWAYS,[Qje]:t.LESS,[aJ]:t.LEQUAL,[Zje]:t.EQUAL,[tPe]:t.GEQUAL,[Jje]:t.GREATER,[ePe]:t.NOTEQUAL};function X(z,O){if(O.type===wu&&e.has("OES_texture_float_linear")===!1&&(O.magFilter===el||O.magFilter===GA||O.magFilter===Zw||O.magFilter===Of||O.minFilter===el||O.minFilter===GA||O.minFilter===Zw||O.minFilter===Of)&&gn("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(z,t.TEXTURE_WRAP_S,Z[O.wrapS]),t.texParameteri(z,t.TEXTURE_WRAP_T,Z[O.wrapT]),(z===t.TEXTURE_3D||z===t.TEXTURE_2D_ARRAY)&&t.texParameteri(z,t.TEXTURE_WRAP_R,Z[O.wrapR]),t.texParameteri(z,t.TEXTURE_MAG_FILTER,ae[O.magFilter]),t.texParameteri(z,t.TEXTURE_MIN_FILTER,ae[O.minFilter]),O.compareFunction&&(t.texParameteri(z,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(z,t.TEXTURE_COMPARE_FUNC,B[O.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(O.magFilter===po||O.minFilter!==Zw&&O.minFilter!==Of||O.type===wu&&e.has("OES_texture_float_linear")===!1)return;if(O.anisotropy>1||r.get(O).__currentAnisotropy){const ee=e.get("EXT_texture_filter_anisotropic");t.texParameterf(z,ee.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,i.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy}}}function ne(z,O){let ee=!1;z.__webglInit===void 0&&(z.__webglInit=!0,O.addEventListener("dispose",C));const le=O.source;let _e=p.get(le);_e===void 0&&(_e={},p.set(le,_e));const we=j(O);if(we!==z.__cacheKey){_e[we]===void 0&&(_e[we]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,ee=!0),_e[we].usedTimes++;const re=_e[z.__cacheKey];re!==void 0&&(_e[z.__cacheKey].usedTimes--,re.usedTimes===0&&A(O)),z.__cacheKey=we,z.__webglTexture=_e[we].texture}return ee}function se(z,O,ee){return Math.floor(Math.floor(z/ee)/O)}function be(z,O,ee,le){const we=z.updateRanges;if(we.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,O.width,O.height,ee,le,O.data);else{we.sort((He,ye)=>He.start-ye.start);let re=0;for(let He=1;He<we.length;He++){const ye=we[re],je=we[He],Be=ye.start+ye.count,Se=se(je.start,O.width,4),Xe=se(ye.start,O.width,4);je.start<=Be+1&&Se===Xe&&se(je.start+je.count-1,O.width,4)===Se?ye.count=Math.max(ye.count,je.start+je.count-ye.start):(++re,we[re]=je)}we.length=re+1;const Fe=t.getParameter(t.UNPACK_ROW_LENGTH),$e=t.getParameter(t.UNPACK_SKIP_PIXELS),Ve=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,O.width);for(let He=0,ye=we.length;He<ye;He++){const je=we[He],Be=Math.floor(je.start/4),Se=Math.ceil(je.count/4),Xe=Be%O.width,Ne=Math.floor(Be/O.width),tt=Se,Ee=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,Xe),t.pixelStorei(t.UNPACK_SKIP_ROWS,Ne),n.texSubImage2D(t.TEXTURE_2D,0,Xe,Ne,tt,Ee,ee,le,O.data)}z.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Fe),t.pixelStorei(t.UNPACK_SKIP_PIXELS,$e),t.pixelStorei(t.UNPACK_SKIP_ROWS,Ve)}}function xe(z,O,ee){let le=t.TEXTURE_2D;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(le=t.TEXTURE_2D_ARRAY),O.isData3DTexture&&(le=t.TEXTURE_3D);const _e=ne(z,O),we=O.source;n.bindTexture(le,z.__webglTexture,t.TEXTURE0+ee);const re=r.get(we);if(we.version!==re.__version||_e===!0){n.activeTexture(t.TEXTURE0+ee);const Fe=sr.getPrimaries(sr.workingColorSpace),$e=O.colorSpace===Kd?null:sr.getPrimaries(O.colorSpace),Ve=O.colorSpace===Kd||Fe===$e?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ve);let He=b(O.image,!1,i.maxTextureSize);He=me(O,He);const ye=a.convert(O.format,O.colorSpace),je=a.convert(O.type);let Be=M(O.internalFormat,ye,je,O.colorSpace,O.isVideoTexture);X(le,O);let Se;const Xe=O.mipmaps,Ne=O.isVideoTexture!==!0,tt=re.__version===void 0||_e===!0,Ee=we.dataReady,We=E(O,He);if(O.isDepthTexture)Be=T(O.format===my,O.type),tt&&(Ne?n.texStorage2D(t.TEXTURE_2D,1,Be,He.width,He.height):n.texImage2D(t.TEXTURE_2D,0,Be,He.width,He.height,0,ye,je,null));else if(O.isDataTexture)if(Xe.length>0){Ne&&tt&&n.texStorage2D(t.TEXTURE_2D,We,Be,Xe[0].width,Xe[0].height);for(let ze=0,W=Xe.length;ze<W;ze++)Se=Xe[ze],Ne?Ee&&n.texSubImage2D(t.TEXTURE_2D,ze,0,0,Se.width,Se.height,ye,je,Se.data):n.texImage2D(t.TEXTURE_2D,ze,Be,Se.width,Se.height,0,ye,je,Se.data);O.generateMipmaps=!1}else Ne?(tt&&n.texStorage2D(t.TEXTURE_2D,We,Be,He.width,He.height),Ee&&be(O,He,ye,je)):n.texImage2D(t.TEXTURE_2D,0,Be,He.width,He.height,0,ye,je,He.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){Ne&&tt&&n.texStorage3D(t.TEXTURE_2D_ARRAY,We,Be,Xe[0].width,Xe[0].height,He.depth);for(let ze=0,W=Xe.length;ze<W;ze++)if(Se=Xe[ze],O.format!==Pl)if(ye!==null)if(Ne){if(Ee)if(O.layerUpdates.size>0){const De=aV(Se.width,Se.height,O.format,O.type);for(const Ye of O.layerUpdates){const xt=Se.data.subarray(Ye*De/Se.data.BYTES_PER_ELEMENT,(Ye+1)*De/Se.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,ze,0,0,Ye,Se.width,Se.height,1,ye,xt)}O.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,ze,0,0,0,Se.width,Se.height,He.depth,ye,Se.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,ze,Be,Se.width,Se.height,He.depth,0,Se.data,0,0);else gn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ne?Ee&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,ze,0,0,0,Se.width,Se.height,He.depth,ye,je,Se.data):n.texImage3D(t.TEXTURE_2D_ARRAY,ze,Be,Se.width,Se.height,He.depth,0,ye,je,Se.data)}else{Ne&&tt&&n.texStorage2D(t.TEXTURE_2D,We,Be,Xe[0].width,Xe[0].height);for(let ze=0,W=Xe.length;ze<W;ze++)Se=Xe[ze],O.format!==Pl?ye!==null?Ne?Ee&&n.compressedTexSubImage2D(t.TEXTURE_2D,ze,0,0,Se.width,Se.height,ye,Se.data):n.compressedTexImage2D(t.TEXTURE_2D,ze,Be,Se.width,Se.height,0,Se.data):gn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ne?Ee&&n.texSubImage2D(t.TEXTURE_2D,ze,0,0,Se.width,Se.height,ye,je,Se.data):n.texImage2D(t.TEXTURE_2D,ze,Be,Se.width,Se.height,0,ye,je,Se.data)}else if(O.isDataArrayTexture)if(Ne){if(tt&&n.texStorage3D(t.TEXTURE_2D_ARRAY,We,Be,He.width,He.height,He.depth),Ee)if(O.layerUpdates.size>0){const ze=aV(He.width,He.height,O.format,O.type);for(const W of O.layerUpdates){const De=He.data.subarray(W*ze/He.data.BYTES_PER_ELEMENT,(W+1)*ze/He.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,W,He.width,He.height,1,ye,je,De)}O.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,He.width,He.height,He.depth,ye,je,He.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,Be,He.width,He.height,He.depth,0,ye,je,He.data);else if(O.isData3DTexture)Ne?(tt&&n.texStorage3D(t.TEXTURE_3D,We,Be,He.width,He.height,He.depth),Ee&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,He.width,He.height,He.depth,ye,je,He.data)):n.texImage3D(t.TEXTURE_3D,0,Be,He.width,He.height,He.depth,0,ye,je,He.data);else if(O.isFramebufferTexture){if(tt)if(Ne)n.texStorage2D(t.TEXTURE_2D,We,Be,He.width,He.height);else{let ze=He.width,W=He.height;for(let De=0;De<We;De++)n.texImage2D(t.TEXTURE_2D,De,Be,ze,W,0,ye,je,null),ze>>=1,W>>=1}}else if(Xe.length>0){if(Ne&&tt){const ze=ke(Xe[0]);n.texStorage2D(t.TEXTURE_2D,We,Be,ze.width,ze.height)}for(let ze=0,W=Xe.length;ze<W;ze++)Se=Xe[ze],Ne?Ee&&n.texSubImage2D(t.TEXTURE_2D,ze,0,0,ye,je,Se):n.texImage2D(t.TEXTURE_2D,ze,Be,ye,je,Se);O.generateMipmaps=!1}else if(Ne){if(tt){const ze=ke(He);n.texStorage2D(t.TEXTURE_2D,We,Be,ze.width,ze.height)}Ee&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,ye,je,He)}else n.texImage2D(t.TEXTURE_2D,0,Be,ye,je,He);y(O)&&v(le),re.__version=we.version,O.onUpdate&&O.onUpdate(O)}z.__version=O.version}function de(z,O,ee){if(O.image.length!==6)return;const le=ne(z,O),_e=O.source;n.bindTexture(t.TEXTURE_CUBE_MAP,z.__webglTexture,t.TEXTURE0+ee);const we=r.get(_e);if(_e.version!==we.__version||le===!0){n.activeTexture(t.TEXTURE0+ee);const re=sr.getPrimaries(sr.workingColorSpace),Fe=O.colorSpace===Kd?null:sr.getPrimaries(O.colorSpace),$e=O.colorSpace===Kd||re===Fe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,$e);const Ve=O.isCompressedTexture||O.image[0].isCompressedTexture,He=O.image[0]&&O.image[0].isDataTexture,ye=[];for(let W=0;W<6;W++)!Ve&&!He?ye[W]=b(O.image[W],!0,i.maxCubemapSize):ye[W]=He?O.image[W].image:O.image[W],ye[W]=me(O,ye[W]);const je=ye[0],Be=a.convert(O.format,O.colorSpace),Se=a.convert(O.type),Xe=M(O.internalFormat,Be,Se,O.colorSpace),Ne=O.isVideoTexture!==!0,tt=we.__version===void 0||le===!0,Ee=_e.dataReady;let We=E(O,je);X(t.TEXTURE_CUBE_MAP,O);let ze;if(Ve){Ne&&tt&&n.texStorage2D(t.TEXTURE_CUBE_MAP,We,Xe,je.width,je.height);for(let W=0;W<6;W++){ze=ye[W].mipmaps;for(let De=0;De<ze.length;De++){const Ye=ze[De];O.format!==Pl?Be!==null?Ne?Ee&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De,0,0,Ye.width,Ye.height,Be,Ye.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De,Xe,Ye.width,Ye.height,0,Ye.data):gn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Ne?Ee&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De,0,0,Ye.width,Ye.height,Be,Se,Ye.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De,Xe,Ye.width,Ye.height,0,Be,Se,Ye.data)}}}else{if(ze=O.mipmaps,Ne&&tt){ze.length>0&&We++;const W=ke(ye[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,We,Xe,W.width,W.height)}for(let W=0;W<6;W++)if(He){Ne?Ee&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,0,0,ye[W].width,ye[W].height,Be,Se,ye[W].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,Xe,ye[W].width,ye[W].height,0,Be,Se,ye[W].data);for(let De=0;De<ze.length;De++){const xt=ze[De].image[W].image;Ne?Ee&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De+1,0,0,xt.width,xt.height,Be,Se,xt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De+1,Xe,xt.width,xt.height,0,Be,Se,xt.data)}}else{Ne?Ee&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,0,0,Be,Se,ye[W]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,Xe,Be,Se,ye[W]);for(let De=0;De<ze.length;De++){const Ye=ze[De];Ne?Ee&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De+1,0,0,Be,Se,Ye.image[W]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De+1,Xe,Be,Se,Ye.image[W])}}}y(O)&&v(t.TEXTURE_CUBE_MAP),we.__version=_e.version,O.onUpdate&&O.onUpdate(O)}z.__version=O.version}function Pe(z,O,ee,le,_e,we){const re=a.convert(ee.format,ee.colorSpace),Fe=a.convert(ee.type),$e=M(ee.internalFormat,re,Fe,ee.colorSpace),Ve=r.get(O),He=r.get(ee);if(He.__renderTarget=O,!Ve.__hasExternalTextures){const ye=Math.max(1,O.width>>we),je=Math.max(1,O.height>>we);_e===t.TEXTURE_3D||_e===t.TEXTURE_2D_ARRAY?n.texImage3D(_e,we,$e,ye,je,O.depth,0,re,Fe,null):n.texImage2D(_e,we,$e,ye,je,0,re,Fe,null)}n.bindFramebuffer(t.FRAMEBUFFER,z),I(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,le,_e,He.__webglTexture,0,te(O)):(_e===t.TEXTURE_2D||_e>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&_e<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,le,_e,He.__webglTexture,we),n.bindFramebuffer(t.FRAMEBUFFER,null)}function ie(z,O,ee){if(t.bindRenderbuffer(t.RENDERBUFFER,z),O.depthBuffer){const le=O.depthTexture,_e=le&&le.isDepthTexture?le.type:null,we=T(O.stencilBuffer,_e),re=O.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Fe=te(O);I(O)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Fe,we,O.width,O.height):ee?t.renderbufferStorageMultisample(t.RENDERBUFFER,Fe,we,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,we,O.width,O.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,re,t.RENDERBUFFER,z)}else{const le=O.textures;for(let _e=0;_e<le.length;_e++){const we=le[_e],re=a.convert(we.format,we.colorSpace),Fe=a.convert(we.type),$e=M(we.internalFormat,re,Fe,we.colorSpace),Ve=te(O);ee&&I(O)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ve,$e,O.width,O.height):I(O)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ve,$e,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,$e,O.width,O.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Me(z,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,z),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const le=r.get(O.depthTexture);le.__renderTarget=O,(!le.__webglTexture||O.depthTexture.image.width!==O.width||O.depthTexture.image.height!==O.height)&&(O.depthTexture.image.width=O.width,O.depthTexture.image.height=O.height,O.depthTexture.needsUpdate=!0),$(O.depthTexture,0);const _e=le.__webglTexture,we=te(O);if(O.depthTexture.format===fy)I(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,_e,0,we):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,_e,0);else if(O.depthTexture.format===my)I(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,_e,0,we):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,_e,0);else throw new Error("Unknown depthTexture format")}function Oe(z){const O=r.get(z),ee=z.isWebGLCubeRenderTarget===!0;if(O.__boundDepthTexture!==z.depthTexture){const le=z.depthTexture;if(O.__depthDisposeCallback&&O.__depthDisposeCallback(),le){const _e=()=>{delete O.__boundDepthTexture,delete O.__depthDisposeCallback,le.removeEventListener("dispose",_e)};le.addEventListener("dispose",_e),O.__depthDisposeCallback=_e}O.__boundDepthTexture=le}if(z.depthTexture&&!O.__autoAllocateDepthBuffer){if(ee)throw new Error("target.depthTexture not supported in Cube render targets");const le=z.texture.mipmaps;le&&le.length>0?Me(O.__webglFramebuffer[0],z):Me(O.__webglFramebuffer,z)}else if(ee){O.__webglDepthbuffer=[];for(let le=0;le<6;le++)if(n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer[le]),O.__webglDepthbuffer[le]===void 0)O.__webglDepthbuffer[le]=t.createRenderbuffer(),ie(O.__webglDepthbuffer[le],z,!1);else{const _e=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,we=O.__webglDepthbuffer[le];t.bindRenderbuffer(t.RENDERBUFFER,we),t.framebufferRenderbuffer(t.FRAMEBUFFER,_e,t.RENDERBUFFER,we)}}else{const le=z.texture.mipmaps;if(le&&le.length>0?n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer),O.__webglDepthbuffer===void 0)O.__webglDepthbuffer=t.createRenderbuffer(),ie(O.__webglDepthbuffer,z,!1);else{const _e=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,we=O.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,we),t.framebufferRenderbuffer(t.FRAMEBUFFER,_e,t.RENDERBUFFER,we)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function ge(z,O,ee){const le=r.get(z);O!==void 0&&Pe(le.__webglFramebuffer,z,z.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ee!==void 0&&Oe(z)}function Ke(z){const O=z.texture,ee=r.get(z),le=r.get(O);z.addEventListener("dispose",k);const _e=z.textures,we=z.isWebGLCubeRenderTarget===!0,re=_e.length>1;if(re||(le.__webglTexture===void 0&&(le.__webglTexture=t.createTexture()),le.__version=O.version,o.memory.textures++),we){ee.__webglFramebuffer=[];for(let Fe=0;Fe<6;Fe++)if(O.mipmaps&&O.mipmaps.length>0){ee.__webglFramebuffer[Fe]=[];for(let $e=0;$e<O.mipmaps.length;$e++)ee.__webglFramebuffer[Fe][$e]=t.createFramebuffer()}else ee.__webglFramebuffer[Fe]=t.createFramebuffer()}else{if(O.mipmaps&&O.mipmaps.length>0){ee.__webglFramebuffer=[];for(let Fe=0;Fe<O.mipmaps.length;Fe++)ee.__webglFramebuffer[Fe]=t.createFramebuffer()}else ee.__webglFramebuffer=t.createFramebuffer();if(re)for(let Fe=0,$e=_e.length;Fe<$e;Fe++){const Ve=r.get(_e[Fe]);Ve.__webglTexture===void 0&&(Ve.__webglTexture=t.createTexture(),o.memory.textures++)}if(z.samples>0&&I(z)===!1){ee.__webglMultisampledFramebuffer=t.createFramebuffer(),ee.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ee.__webglMultisampledFramebuffer);for(let Fe=0;Fe<_e.length;Fe++){const $e=_e[Fe];ee.__webglColorRenderbuffer[Fe]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ee.__webglColorRenderbuffer[Fe]);const Ve=a.convert($e.format,$e.colorSpace),He=a.convert($e.type),ye=M($e.internalFormat,Ve,He,$e.colorSpace,z.isXRRenderTarget===!0),je=te(z);t.renderbufferStorageMultisample(t.RENDERBUFFER,je,ye,z.width,z.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Fe,t.RENDERBUFFER,ee.__webglColorRenderbuffer[Fe])}t.bindRenderbuffer(t.RENDERBUFFER,null),z.depthBuffer&&(ee.__webglDepthRenderbuffer=t.createRenderbuffer(),ie(ee.__webglDepthRenderbuffer,z,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(we){n.bindTexture(t.TEXTURE_CUBE_MAP,le.__webglTexture),X(t.TEXTURE_CUBE_MAP,O);for(let Fe=0;Fe<6;Fe++)if(O.mipmaps&&O.mipmaps.length>0)for(let $e=0;$e<O.mipmaps.length;$e++)Pe(ee.__webglFramebuffer[Fe][$e],z,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Fe,$e);else Pe(ee.__webglFramebuffer[Fe],z,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Fe,0);y(O)&&v(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(re){for(let Fe=0,$e=_e.length;Fe<$e;Fe++){const Ve=_e[Fe],He=r.get(Ve);let ye=t.TEXTURE_2D;(z.isWebGL3DRenderTarget||z.isWebGLArrayRenderTarget)&&(ye=z.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(ye,He.__webglTexture),X(ye,Ve),Pe(ee.__webglFramebuffer,z,Ve,t.COLOR_ATTACHMENT0+Fe,ye,0),y(Ve)&&v(ye)}n.unbindTexture()}else{let Fe=t.TEXTURE_2D;if((z.isWebGL3DRenderTarget||z.isWebGLArrayRenderTarget)&&(Fe=z.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Fe,le.__webglTexture),X(Fe,O),O.mipmaps&&O.mipmaps.length>0)for(let $e=0;$e<O.mipmaps.length;$e++)Pe(ee.__webglFramebuffer[$e],z,O,t.COLOR_ATTACHMENT0,Fe,$e);else Pe(ee.__webglFramebuffer,z,O,t.COLOR_ATTACHMENT0,Fe,0);y(O)&&v(Fe),n.unbindTexture()}z.depthBuffer&&Oe(z)}function G(z){const O=z.textures;for(let ee=0,le=O.length;ee<le;ee++){const _e=O[ee];if(y(_e)){const we=S(z),re=r.get(_e).__webglTexture;n.bindTexture(we,re),v(we),n.unbindTexture()}}}const Y=[],ce=[];function q(z){if(z.samples>0){if(I(z)===!1){const O=z.textures,ee=z.width,le=z.height;let _e=t.COLOR_BUFFER_BIT;const we=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,re=r.get(z),Fe=O.length>1;if(Fe)for(let Ve=0;Ve<O.length;Ve++)n.bindFramebuffer(t.FRAMEBUFFER,re.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,re.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,re.__webglMultisampledFramebuffer);const $e=z.texture.mipmaps;$e&&$e.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,re.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,re.__webglFramebuffer);for(let Ve=0;Ve<O.length;Ve++){if(z.resolveDepthBuffer&&(z.depthBuffer&&(_e|=t.DEPTH_BUFFER_BIT),z.stencilBuffer&&z.resolveStencilBuffer&&(_e|=t.STENCIL_BUFFER_BIT)),Fe){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,re.__webglColorRenderbuffer[Ve]);const He=r.get(O[Ve]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,He,0)}t.blitFramebuffer(0,0,ee,le,0,0,ee,le,_e,t.NEAREST),c===!0&&(Y.length=0,ce.length=0,Y.push(t.COLOR_ATTACHMENT0+Ve),z.depthBuffer&&z.resolveDepthBuffer===!1&&(Y.push(we),ce.push(we),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,ce)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,Y))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Fe)for(let Ve=0;Ve<O.length;Ve++){n.bindFramebuffer(t.FRAMEBUFFER,re.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,re.__webglColorRenderbuffer[Ve]);const He=r.get(O[Ve]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,re.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,He,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,re.__webglMultisampledFramebuffer)}else if(z.depthBuffer&&z.resolveDepthBuffer===!1&&c){const O=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[O])}}}function te(z){return Math.min(i.maxSamples,z.samples)}function I(z){const O=r.get(z);return z.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function fe(z){const O=o.render.frame;d.get(z)!==O&&(d.set(z,O),z.update())}function me(z,O){const ee=z.colorSpace,le=z.format,_e=z.type;return z.isCompressedTexture===!0||z.isVideoTexture===!0||ee!==ex&&ee!==Kd&&(sr.getTransfer(ee)===Mr?(le!==Pl||_e!==yc)&&gn("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):ki("WebGLTextures: Unsupported texture color space:",ee)),O}function ke(z){return typeof HTMLImageElement<"u"&&z instanceof HTMLImageElement?(u.width=z.naturalWidth||z.width,u.height=z.naturalHeight||z.height):typeof VideoFrame<"u"&&z instanceof VideoFrame?(u.width=z.displayWidth,u.height=z.displayHeight):(u.width=z.width,u.height=z.height),u}this.allocateTextureUnit=H,this.resetTextureUnits=F,this.setTexture2D=$,this.setTexture2DArray=K,this.setTexture3D=V,this.setTextureCube=Q,this.rebindTextures=ge,this.setupRenderTarget=Ke,this.updateRenderTargetMipmap=G,this.updateMultisampleRenderTarget=q,this.setupDepthRenderbuffer=Oe,this.setupFrameBufferTexture=Pe,this.useMultisampledRTT=I}function S4e(t,e){function n(r,i=Kd){let a;const o=sr.getTransfer(i);if(r===yc)return t.UNSIGNED_BYTE;if(r===V4)return t.UNSIGNED_SHORT_4_4_4_4;if(r===G4)return t.UNSIGNED_SHORT_5_5_5_1;if(r===JZ)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===eJ)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===QZ)return t.BYTE;if(r===ZZ)return t.SHORT;if(r===dy)return t.UNSIGNED_SHORT;if(r===H4)return t.INT;if(r===pm)return t.UNSIGNED_INT;if(r===wu)return t.FLOAT;if(r===Cx)return t.HALF_FLOAT;if(r===tJ)return t.ALPHA;if(r===nJ)return t.RGB;if(r===Pl)return t.RGBA;if(r===fy)return t.DEPTH_COMPONENT;if(r===my)return t.DEPTH_STENCIL;if(r===rJ)return t.RED;if(r===q4)return t.RED_INTEGER;if(r===W4)return t.RG;if(r===K4)return t.RG_INTEGER;if(r===X4)return t.RGBA_INTEGER;if(r===N1||r===M1||r===E1||r===k1)if(o===Mr)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===N1)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===M1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===E1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===k1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===N1)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===M1)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===E1)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===k1)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===L3||r===F3||r===I3||r===U3)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===L3)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===F3)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===I3)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===U3)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===z3||r===B3||r===$3)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===z3||r===B3)return o===Mr?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===$3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===H3||r===V3||r===G3||r===q3||r===W3||r===K3||r===X3||r===Y3||r===Q3||r===Z3||r===J3||r===eD||r===tD||r===nD)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===H3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===V3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===G3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===q3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===W3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===K3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===X3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===Y3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===Q3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===Z3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===J3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===eD)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===tD)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===nD)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===rD||r===iD||r===aD)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===rD)return o===Mr?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===iD)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===aD)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===sD||r===oD||r===lD||r===cD)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===sD)return a.COMPRESSED_RED_RGTC1_EXT;if(r===oD)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===lD)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===cD)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===hy?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const N4e=`
  3905. void main() {
  3906. gl_Position = vec4( position, 1.0 );
  3907. }`,M4e=`
  3908. uniform sampler2DArray depthColor;
  3909. uniform float depthWidth;
  3910. uniform float depthHeight;
  3911. void main() {
  3912. vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
  3913. if ( coord.x >= 1.0 ) {
  3914. gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
  3915. } else {
  3916. gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
  3917. }
  3918. }`;class E4e{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new NJ(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 Hu({vertexShader:N4e,fragmentShader:M4e,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new vc(new tL(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let k4e=class extends Cm{constructor(e,n){super();const r=this;let i=null,a=1,o=null,l="local-floor",c=1,u=null,d=null,f=null,p=null,m=null,x=null;const b=typeof XRWebGLBinding<"u",y=new E4e,v={},S=n.getContextAttributes();let M=null,T=null;const E=[],C=[],k=new Tn;let R=null;const A=new Wo;A.viewport=new Ui;const D=new Wo;D.viewport=new Ui;const U=[A,D],F=new VPe;let H=null,j=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(xe){let de=E[xe];return de===void 0&&(de=new fC,E[xe]=de),de.getTargetRaySpace()},this.getControllerGrip=function(xe){let de=E[xe];return de===void 0&&(de=new fC,E[xe]=de),de.getGripSpace()},this.getHand=function(xe){let de=E[xe];return de===void 0&&(de=new fC,E[xe]=de),de.getHandSpace()};function $(xe){const de=C.indexOf(xe.inputSource);if(de===-1)return;const Pe=E[de];Pe!==void 0&&(Pe.update(xe.inputSource,xe.frame,u||o),Pe.dispatchEvent({type:xe.type,data:xe.inputSource}))}function K(){i.removeEventListener("select",$),i.removeEventListener("selectstart",$),i.removeEventListener("selectend",$),i.removeEventListener("squeeze",$),i.removeEventListener("squeezestart",$),i.removeEventListener("squeezeend",$),i.removeEventListener("end",K),i.removeEventListener("inputsourceschange",V);for(let xe=0;xe<E.length;xe++){const de=C[xe];de!==null&&(C[xe]=null,E[xe].disconnect(de))}H=null,j=null,y.reset();for(const xe in v)delete v[xe];e.setRenderTarget(M),m=null,p=null,f=null,i=null,T=null,be.stop(),r.isPresenting=!1,e.setPixelRatio(R),e.setSize(k.width,k.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(xe){a=xe,r.isPresenting===!0&&gn("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(xe){l=xe,r.isPresenting===!0&&gn("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(xe){u=xe},this.getBaseLayer=function(){return p!==null?p:m},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(xe){if(i=xe,i!==null){if(M=e.getRenderTarget(),i.addEventListener("select",$),i.addEventListener("selectstart",$),i.addEventListener("selectend",$),i.addEventListener("squeeze",$),i.addEventListener("squeezestart",$),i.addEventListener("squeezeend",$),i.addEventListener("end",K),i.addEventListener("inputsourceschange",V),S.xrCompatible!==!0&&await n.makeXRCompatible(),R=e.getPixelRatio(),e.getSize(k),b&&"createProjectionLayer"in XRWebGLBinding.prototype){let Pe=null,ie=null,Me=null;S.depth&&(Me=S.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Pe=S.stencil?my:fy,ie=S.stencil?hy:pm);const Oe={colorFormat:n.RGBA8,depthFormat:Me,scaleFactor:a};f=this.getBinding(),p=f.createProjectionLayer(Oe),i.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),T=new xm(p.textureWidth,p.textureHeight,{format:Pl,type:yc,depthTexture:new SJ(p.textureWidth,p.textureHeight,ie,void 0,void 0,void 0,void 0,void 0,void 0,Pe),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}else{const Pe={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:a};m=new XRWebGLLayer(i,n,Pe),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),T=new xm(m.framebufferWidth,m.framebufferHeight,{format:Pl,type:yc,colorSpace:e.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}T.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),be.setContext(i),be.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return y.getDepthTexture()};function V(xe){for(let de=0;de<xe.removed.length;de++){const Pe=xe.removed[de],ie=C.indexOf(Pe);ie>=0&&(C[ie]=null,E[ie].disconnect(Pe))}for(let de=0;de<xe.added.length;de++){const Pe=xe.added[de];let ie=C.indexOf(Pe);if(ie===-1){for(let Oe=0;Oe<E.length;Oe++)if(Oe>=C.length){C.push(Pe),ie=Oe;break}else if(C[Oe]===null){C[Oe]=Pe,ie=Oe;break}if(ie===-1)break}const Me=E[ie];Me&&Me.connect(Pe)}}const Q=new dt,Z=new dt;function ae(xe,de,Pe){Q.setFromMatrixPosition(de.matrixWorld),Z.setFromMatrixPosition(Pe.matrixWorld);const ie=Q.distanceTo(Z),Me=de.projectionMatrix.elements,Oe=Pe.projectionMatrix.elements,ge=Me[14]/(Me[10]-1),Ke=Me[14]/(Me[10]+1),G=(Me[9]+1)/Me[5],Y=(Me[9]-1)/Me[5],ce=(Me[8]-1)/Me[0],q=(Oe[8]+1)/Oe[0],te=ge*ce,I=ge*q,fe=ie/(-ce+q),me=fe*-ce;if(de.matrixWorld.decompose(xe.position,xe.quaternion,xe.scale),xe.translateX(me),xe.translateZ(fe),xe.matrixWorld.compose(xe.position,xe.quaternion,xe.scale),xe.matrixWorldInverse.copy(xe.matrixWorld).invert(),Me[10]===-1)xe.projectionMatrix.copy(de.projectionMatrix),xe.projectionMatrixInverse.copy(de.projectionMatrixInverse);else{const ke=ge+fe,z=Ke+fe,O=te-me,ee=I+(ie-me),le=G*Ke/z*ke,_e=Y*Ke/z*ke;xe.projectionMatrix.makePerspective(O,ee,le,_e,ke,z),xe.projectionMatrixInverse.copy(xe.projectionMatrix).invert()}}function B(xe,de){de===null?xe.matrixWorld.copy(xe.matrix):xe.matrixWorld.multiplyMatrices(de.matrixWorld,xe.matrix),xe.matrixWorldInverse.copy(xe.matrixWorld).invert()}this.updateCamera=function(xe){if(i===null)return;let de=xe.near,Pe=xe.far;y.texture!==null&&(y.depthNear>0&&(de=y.depthNear),y.depthFar>0&&(Pe=y.depthFar)),F.near=D.near=A.near=de,F.far=D.far=A.far=Pe,(H!==F.near||j!==F.far)&&(i.updateRenderState({depthNear:F.near,depthFar:F.far}),H=F.near,j=F.far),F.layers.mask=xe.layers.mask|6,A.layers.mask=F.layers.mask&3,D.layers.mask=F.layers.mask&5;const ie=xe.parent,Me=F.cameras;B(F,ie);for(let Oe=0;Oe<Me.length;Oe++)B(Me[Oe],ie);Me.length===2?ae(F,A,D):F.projectionMatrix.copy(A.projectionMatrix),X(xe,F,ie)};function X(xe,de,Pe){Pe===null?xe.matrix.copy(de.matrixWorld):(xe.matrix.copy(Pe.matrixWorld),xe.matrix.invert(),xe.matrix.multiply(de.matrixWorld)),xe.matrix.decompose(xe.position,xe.quaternion,xe.scale),xe.updateMatrixWorld(!0),xe.projectionMatrix.copy(de.projectionMatrix),xe.projectionMatrixInverse.copy(de.projectionMatrixInverse),xe.isPerspectiveCamera&&(xe.fov=uD*2*Math.atan(1/xe.projectionMatrix.elements[5]),xe.zoom=1)}this.getCamera=function(){return F},this.getFoveation=function(){if(!(p===null&&m===null))return c},this.setFoveation=function(xe){c=xe,p!==null&&(p.fixedFoveation=xe),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=xe)},this.hasDepthSensing=function(){return y.texture!==null},this.getDepthSensingMesh=function(){return y.getMesh(F)},this.getCameraTexture=function(xe){return v[xe]};let ne=null;function se(xe,de){if(d=de.getViewerPose(u||o),x=de,d!==null){const Pe=d.views;m!==null&&(e.setRenderTargetFramebuffer(T,m.framebuffer),e.setRenderTarget(T));let ie=!1;Pe.length!==F.cameras.length&&(F.cameras.length=0,ie=!0);for(let Ke=0;Ke<Pe.length;Ke++){const G=Pe[Ke];let Y=null;if(m!==null)Y=m.getViewport(G);else{const q=f.getViewSubImage(p,G);Y=q.viewport,Ke===0&&(e.setRenderTargetTextures(T,q.colorTexture,q.depthStencilTexture),e.setRenderTarget(T))}let ce=U[Ke];ce===void 0&&(ce=new Wo,ce.layers.enable(Ke),ce.viewport=new Ui,U[Ke]=ce),ce.matrix.fromArray(G.transform.matrix),ce.matrix.decompose(ce.position,ce.quaternion,ce.scale),ce.projectionMatrix.fromArray(G.projectionMatrix),ce.projectionMatrixInverse.copy(ce.projectionMatrix).invert(),ce.viewport.set(Y.x,Y.y,Y.width,Y.height),Ke===0&&(F.matrix.copy(ce.matrix),F.matrix.decompose(F.position,F.quaternion,F.scale)),ie===!0&&F.cameras.push(ce)}const Me=i.enabledFeatures;if(Me&&Me.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&b){f=r.getBinding();const Ke=f.getDepthInformation(Pe[0]);Ke&&Ke.isValid&&Ke.texture&&y.init(Ke,i.renderState)}if(Me&&Me.includes("camera-access")&&b){e.state.unbindTexture(),f=r.getBinding();for(let Ke=0;Ke<Pe.length;Ke++){const G=Pe[Ke].camera;if(G){let Y=v[G];Y||(Y=new NJ,v[G]=Y);const ce=f.getCameraImage(G);Y.sourceTexture=ce}}}}for(let Pe=0;Pe<E.length;Pe++){const ie=C[Pe],Me=E[Pe];ie!==null&&Me!==void 0&&Me.update(ie,de,u||o)}ne&&ne(xe,de),de.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:de}),x=null}const be=new TJ;be.setAnimationLoop(se),this.setAnimationLoop=function(xe){ne=xe},this.dispose=function(){}}};const hf=new kh,T4e=new Vi;function A4e(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,yJ(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,M,T){v.isMeshBasicMaterial||v.isMeshLambertMaterial?a(y,v):v.isMeshToonMaterial?(a(y,v),f(y,v)):v.isMeshPhongMaterial?(a(y,v),d(y,v)):v.isMeshStandardMaterial?(a(y,v),p(y,v),v.isMeshPhysicalMaterial&&m(y,v,T)):v.isMeshMatcapMaterial?(a(y,v),x(y,v)):v.isMeshDepthMaterial?a(y,v):v.isMeshDistanceMaterial?(a(y,v),b(y,v)):v.isMeshNormalMaterial?a(y,v):v.isLineBasicMaterial?(o(y,v),v.isLineDashedMaterial&&l(y,v)):v.isPointsMaterial?c(y,v,S,M):v.isSpriteMaterial?u(y,v):v.isShadowMaterial?(y.color.value.copy(v.color),y.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function a(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===Us&&(y.bumpScale.value*=-1)),v.normalMap&&(y.normalMap.value=v.normalMap,n(v.normalMap,y.normalMapTransform),y.normalScale.value.copy(v.normalScale),v.side===Us&&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),M=S.envMap,T=S.envMapRotation;M&&(y.envMap.value=M,hf.copy(T),hf.x*=-1,hf.y*=-1,hf.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(hf.y*=-1,hf.z*=-1),y.envMapRotation.value.setFromMatrix4(T4e.makeRotationFromEuler(hf)),y.flipEnvMap.value=M.isCubeTexture&&M.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,M){y.diffuse.value.copy(v.color),y.opacity.value=v.opacity,y.size.value=v.size*S,y.scale.value=M*.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 p(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 m(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===Us&&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 C4e(t,e,n,r){let i={},a={},o=[];const l=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(S,M){const T=M.program;r.uniformBlockBinding(S,T)}function u(S,M){let T=i[S.id];T===void 0&&(x(S),T=d(S),i[S.id]=T,S.addEventListener("dispose",y));const E=M.program;r.updateUBOMapping(S,E);const C=e.render.frame;a[S.id]!==C&&(p(S),a[S.id]=C)}function d(S){const M=f();S.__bindingPointIndex=M;const T=t.createBuffer(),E=S.__size,C=S.usage;return t.bindBuffer(t.UNIFORM_BUFFER,T),t.bufferData(t.UNIFORM_BUFFER,E,C),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,M,T),T}function f(){for(let S=0;S<l;S++)if(o.indexOf(S)===-1)return o.push(S),S;return ki("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function p(S){const M=i[S.id],T=S.uniforms,E=S.__cache;t.bindBuffer(t.UNIFORM_BUFFER,M);for(let C=0,k=T.length;C<k;C++){const R=Array.isArray(T[C])?T[C]:[T[C]];for(let A=0,D=R.length;A<D;A++){const U=R[A];if(m(U,C,A,E)===!0){const F=U.__offset,H=Array.isArray(U.value)?U.value:[U.value];let j=0;for(let $=0;$<H.length;$++){const K=H[$],V=b(K);typeof K=="number"||typeof K=="boolean"?(U.__data[0]=K,t.bufferSubData(t.UNIFORM_BUFFER,F+j,U.__data)):K.isMatrix3?(U.__data[0]=K.elements[0],U.__data[1]=K.elements[1],U.__data[2]=K.elements[2],U.__data[3]=0,U.__data[4]=K.elements[3],U.__data[5]=K.elements[4],U.__data[6]=K.elements[5],U.__data[7]=0,U.__data[8]=K.elements[6],U.__data[9]=K.elements[7],U.__data[10]=K.elements[8],U.__data[11]=0):(K.toArray(U.__data,j),j+=V.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,F,U.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(S,M,T,E){const C=S.value,k=M+"_"+T;if(E[k]===void 0)return typeof C=="number"||typeof C=="boolean"?E[k]=C:E[k]=C.clone(),!0;{const R=E[k];if(typeof C=="number"||typeof C=="boolean"){if(R!==C)return E[k]=C,!0}else if(R.equals(C)===!1)return R.copy(C),!0}return!1}function x(S){const M=S.uniforms;let T=0;const E=16;for(let k=0,R=M.length;k<R;k++){const A=Array.isArray(M[k])?M[k]:[M[k]];for(let D=0,U=A.length;D<U;D++){const F=A[D],H=Array.isArray(F.value)?F.value:[F.value];for(let j=0,$=H.length;j<$;j++){const K=H[j],V=b(K),Q=T%E,Z=Q%V.boundary,ae=Q+Z;T+=Z,ae!==0&&E-ae<V.storage&&(T+=E-ae),F.__data=new Float32Array(V.storage/Float32Array.BYTES_PER_ELEMENT),F.__offset=T,T+=V.storage}}}const C=T%E;return C>0&&(T+=E-C),S.__size=T,S.__cache={},this}function b(S){const M={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(M.boundary=4,M.storage=4):S.isVector2?(M.boundary=8,M.storage=8):S.isVector3||S.isColor?(M.boundary=16,M.storage=12):S.isVector4?(M.boundary=16,M.storage=16):S.isMatrix3?(M.boundary=48,M.storage=48):S.isMatrix4?(M.boundary=64,M.storage=64):S.isTexture?gn("WebGLRenderer: Texture samplers can not be part of an uniforms group."):gn("WebGLRenderer: Unsupported uniform value type.",S),M}function y(S){const M=S.target;M.removeEventListener("dispose",y);const T=o.indexOf(M.__bindingPointIndex);o.splice(T,1),t.deleteBuffer(i[M.id]),delete i[M.id],delete a[M.id]}function v(){for(const S in i)t.deleteBuffer(i[S]);o=[],i={},a={}}return{bind:c,update:u,dispose:v}}const j4e=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 P4e(){return Qc===null&&(Qc=new PPe(j4e,32,32,W4,Cx),Qc.minFilter=el,Qc.magFilter=el,Qc.wrapS=vu,Qc.wrapT=vu,Qc.generateMipmaps=!1,Qc.needsUpdate=!0),Qc}let D4e=class{constructor(e={}){const{canvas:n=rPe(),context:r=null,depth:i=!0,stencil:a=!1,alpha:o=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:p=!1}=e;this.isWebGLRenderer=!0;let m;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=r.getContextAttributes().alpha}else m=o;const x=new Set([X4,K4,q4]),b=new Set([yc,pm,dy,hy,V4,G4]),y=new Uint32Array(4),v=new Int32Array(4);let S=null,M=null;const T=[],E=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=lh,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let k=!1;this._outputColorSpace=Vo;let R=0,A=0,D=null,U=-1,F=null;const H=new Ui,j=new Ui;let $=null;const K=new Bn(0);let V=0,Q=n.width,Z=n.height,ae=1,B=null,X=null;const ne=new Ui(0,0,Q,Z),se=new Ui(0,0,Q,Z);let be=!1;const xe=new eL;let de=!1,Pe=!1;const ie=new Vi,Me=new dt,Oe=new Ui,ge={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ke=!1;function G(){return D===null?ae:1}let Y=r;function ce(he,pe){return n.getContext(he,pe)}try{const he={alpha:!0,depth:i,stencil:a,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${B4}`),n.addEventListener("webglcontextlost",ze,!1),n.addEventListener("webglcontextrestored",W,!1),n.addEventListener("webglcontextcreationerror",De,!1),Y===null){const pe="webgl2";if(Y=ce(pe,he),Y===null)throw ce(pe)?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,te,I,fe,me,ke,z,O,ee,le,_e,we,re,Fe,$e,Ve,He,ye,je,Be,Se,Xe,Ne,tt;function Ee(){q=new BRe(Y),q.init(),Xe=new S4e(Y,q),te=new PRe(Y,q,e,Xe),I=new w4e(Y,q),te.reversedDepthBuffer&&p&&I.buffers.depth.setReversed(!0),fe=new VRe(Y),me=new l4e,ke=new _4e(Y,q,I,me,te,Xe,fe),z=new RRe(C),O=new zRe(C),ee=new KPe(Y),Ne=new CRe(Y,ee),le=new $Re(Y,ee,fe,Ne),_e=new qRe(Y,le,ee,fe),je=new GRe(Y,te,ke),Ve=new DRe(me),we=new o4e(C,z,O,q,te,Ne,Ve),re=new A4e(C,me),Fe=new u4e,$e=new g4e(q),ye=new ARe(C,z,O,I,_e,m,c),He=new y4e(C,_e,te),tt=new C4e(Y,fe,te,I),Be=new jRe(Y,q,fe),Se=new HRe(Y,q,fe),fe.programs=we.programs,C.capabilities=te,C.extensions=q,C.properties=me,C.renderLists=Fe,C.shadowMap=He,C.state=I,C.info=fe}Ee();const We=new k4e(C,Y);this.xr=We,this.getContext=function(){return Y},this.getContextAttributes=function(){return Y.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 ae},this.setPixelRatio=function(he){he!==void 0&&(ae=he,this.setSize(Q,Z,!1))},this.getSize=function(he){return he.set(Q,Z)},this.setSize=function(he,pe,Ie=!0){if(We.isPresenting){gn("WebGLRenderer: Can't change size while VR device is presenting.");return}Q=he,Z=pe,n.width=Math.floor(he*ae),n.height=Math.floor(pe*ae),Ie===!0&&(n.style.width=he+"px",n.style.height=pe+"px"),this.setViewport(0,0,he,pe)},this.getDrawingBufferSize=function(he){return he.set(Q*ae,Z*ae).floor()},this.setDrawingBufferSize=function(he,pe,Ie){Q=he,Z=pe,ae=Ie,n.width=Math.floor(he*Ie),n.height=Math.floor(pe*Ie),this.setViewport(0,0,he,pe)},this.getCurrentViewport=function(he){return he.copy(H)},this.getViewport=function(he){return he.copy(ne)},this.setViewport=function(he,pe,Ie,Le){he.isVector4?ne.set(he.x,he.y,he.z,he.w):ne.set(he,pe,Ie,Le),I.viewport(H.copy(ne).multiplyScalar(ae).round())},this.getScissor=function(he){return he.copy(se)},this.setScissor=function(he,pe,Ie,Le){he.isVector4?se.set(he.x,he.y,he.z,he.w):se.set(he,pe,Ie,Le),I.scissor(j.copy(se).multiplyScalar(ae).round())},this.getScissorTest=function(){return be},this.setScissorTest=function(he){I.setScissorTest(be=he)},this.setOpaqueSort=function(he){B=he},this.setTransparentSort=function(he){X=he},this.getClearColor=function(he){return he.copy(ye.getClearColor())},this.setClearColor=function(){ye.setClearColor(...arguments)},this.getClearAlpha=function(){return ye.getClearAlpha()},this.setClearAlpha=function(){ye.setClearAlpha(...arguments)},this.clear=function(he=!0,pe=!0,Ie=!0){let Le=0;if(he){let Ce=!1;if(D!==null){const ut=D.texture.format;Ce=x.has(ut)}if(Ce){const ut=D.texture.type,St=b.has(ut),At=ye.getClearColor(),Tt=ye.getClearAlpha(),Ft=At.r,Pt=At.g,Mt=At.b;St?(y[0]=Ft,y[1]=Pt,y[2]=Mt,y[3]=Tt,Y.clearBufferuiv(Y.COLOR,0,y)):(v[0]=Ft,v[1]=Pt,v[2]=Mt,v[3]=Tt,Y.clearBufferiv(Y.COLOR,0,v))}else Le|=Y.COLOR_BUFFER_BIT}pe&&(Le|=Y.DEPTH_BUFFER_BIT),Ie&&(Le|=Y.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Y.clear(Le)},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",ze,!1),n.removeEventListener("webglcontextrestored",W,!1),n.removeEventListener("webglcontextcreationerror",De,!1),ye.dispose(),Fe.dispose(),$e.dispose(),me.dispose(),z.dispose(),O.dispose(),_e.dispose(),Ne.dispose(),tt.dispose(),we.dispose(),We.dispose(),We.removeEventListener("sessionstart",Jt),We.removeEventListener("sessionend",rr),hr.stop()};function ze(he){he.preventDefault(),RH("WebGLRenderer: Context Lost."),k=!0}function W(){RH("WebGLRenderer: Context Restored."),k=!1;const he=fe.autoReset,pe=He.enabled,Ie=He.autoUpdate,Le=He.needsUpdate,Ce=He.type;Ee(),fe.autoReset=he,He.enabled=pe,He.autoUpdate=Ie,He.needsUpdate=Le,He.type=Ce}function De(he){ki("WebGLRenderer: A WebGL context could not be created. Reason: ",he.statusMessage)}function Ye(he){const pe=he.target;pe.removeEventListener("dispose",Ye),xt(pe)}function xt(he){ft(he),me.remove(he)}function ft(he){const pe=me.get(he).programs;pe!==void 0&&(pe.forEach(function(Ie){we.releaseProgram(Ie)}),he.isShaderMaterial&&we.releaseShaderCache(he))}this.renderBufferDirect=function(he,pe,Ie,Le,Ce,ut){pe===null&&(pe=ge);const St=Ce.isMesh&&Ce.matrixWorld.determinant()<0,At=Ae(he,pe,Ie,Le,Ce);I.setMaterial(Le,St);let Tt=Ie.index,Ft=1;if(Le.wireframe===!0){if(Tt=le.getWireframeAttribute(Ie),Tt===void 0)return;Ft=2}const Pt=Ie.drawRange,Mt=Ie.attributes.position;let en=Pt.start*Ft,$t=(Pt.start+Pt.count)*Ft;ut!==null&&(en=Math.max(en,ut.start*Ft),$t=Math.min($t,(ut.start+ut.count)*Ft)),Tt!==null?(en=Math.max(en,0),$t=Math.min($t,Tt.count)):Mt!=null&&(en=Math.max(en,0),$t=Math.min($t,Mt.count));const dn=$t-en;if(dn<0||dn===1/0)return;Ne.setup(Ce,Le,At,Ie,Tt);let cn,Sn=Be;if(Tt!==null&&(cn=ee.get(Tt),Sn=Se,Sn.setIndex(cn)),Ce.isMesh)Le.wireframe===!0?(I.setLineWidth(Le.wireframeLinewidth*G()),Sn.setMode(Y.LINES)):Sn.setMode(Y.TRIANGLES);else if(Ce.isLine){let Gt=Le.linewidth;Gt===void 0&&(Gt=1),I.setLineWidth(Gt*G()),Ce.isLineSegments?Sn.setMode(Y.LINES):Ce.isLineLoop?Sn.setMode(Y.LINE_LOOP):Sn.setMode(Y.LINE_STRIP)}else Ce.isPoints?Sn.setMode(Y.POINTS):Ce.isSprite&&Sn.setMode(Y.TRIANGLES);if(Ce.isBatchedMesh)if(Ce._multiDrawInstances!==null)py("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Sn.renderMultiDrawInstances(Ce._multiDrawStarts,Ce._multiDrawCounts,Ce._multiDrawCount,Ce._multiDrawInstances);else if(q.get("WEBGL_multi_draw"))Sn.renderMultiDraw(Ce._multiDrawStarts,Ce._multiDrawCounts,Ce._multiDrawCount);else{const Gt=Ce._multiDrawStarts,sn=Ce._multiDrawCounts,un=Ce._multiDrawCount,Yt=Tt?ee.get(Tt).bytesPerElement:1,tr=me.get(Le).currentProgram.getUniforms();for(let jn=0;jn<un;jn++)tr.setValue(Y,"_gl_DrawID",jn),Sn.render(Gt[jn]/Yt,sn[jn])}else if(Ce.isInstancedMesh)Sn.renderInstances(en,dn,Ce.count);else if(Ie.isInstancedBufferGeometry){const Gt=Ie._maxInstanceCount!==void 0?Ie._maxInstanceCount:1/0,sn=Math.min(Ie.instanceCount,Gt);Sn.renderInstances(en,dn,sn)}else Sn.render(en,dn)};function Bt(he,pe,Ie){he.transparent===!0&&he.side===ic&&he.forceSinglePass===!1?(he.side=Us,he.needsUpdate=!0,bn(he,pe,Ie),he.side=Eh,he.needsUpdate=!0,bn(he,pe,Ie),he.side=ic):bn(he,pe,Ie)}this.compile=function(he,pe,Ie=null){Ie===null&&(Ie=he),M=$e.get(Ie),M.init(pe),E.push(M),Ie.traverseVisible(function(Ce){Ce.isLight&&Ce.layers.test(pe.layers)&&(M.pushLight(Ce),Ce.castShadow&&M.pushShadow(Ce))}),he!==Ie&&he.traverseVisible(function(Ce){Ce.isLight&&Ce.layers.test(pe.layers)&&(M.pushLight(Ce),Ce.castShadow&&M.pushShadow(Ce))}),M.setupLights();const Le=new Set;return he.traverse(function(Ce){if(!(Ce.isMesh||Ce.isPoints||Ce.isLine||Ce.isSprite))return;const ut=Ce.material;if(ut)if(Array.isArray(ut))for(let St=0;St<ut.length;St++){const At=ut[St];Bt(At,Ie,Ce),Le.add(At)}else Bt(ut,Ie,Ce),Le.add(ut)}),M=E.pop(),Le},this.compileAsync=function(he,pe,Ie=null){const Le=this.compile(he,pe,Ie);return new Promise(Ce=>{function ut(){if(Le.forEach(function(St){me.get(St).currentProgram.isReady()&&Le.delete(St)}),Le.size===0){Ce(he);return}setTimeout(ut,10)}q.get("KHR_parallel_shader_compile")!==null?ut():setTimeout(ut,10)})};let Lt=null;function vn(he){Lt&&Lt(he)}function Jt(){hr.stop()}function rr(){hr.start()}const hr=new TJ;hr.setAnimationLoop(vn),typeof self<"u"&&hr.setContext(self),this.setAnimationLoop=function(he){Lt=he,We.setAnimationLoop(he),he===null?hr.stop():hr.start()},We.addEventListener("sessionstart",Jt),We.addEventListener("sessionend",rr),this.render=function(he,pe){if(pe!==void 0&&pe.isCamera!==!0){ki("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(k===!0)return;if(he.matrixWorldAutoUpdate===!0&&he.updateMatrixWorld(),pe.parent===null&&pe.matrixWorldAutoUpdate===!0&&pe.updateMatrixWorld(),We.enabled===!0&&We.isPresenting===!0&&(We.cameraAutoUpdate===!0&&We.updateCamera(pe),pe=We.getCamera()),he.isScene===!0&&he.onBeforeRender(C,he,pe,D),M=$e.get(he,E.length),M.init(pe),E.push(M),ie.multiplyMatrices(pe.projectionMatrix,pe.matrixWorldInverse),xe.setFromProjectionMatrix(ie,lc,pe.reversedDepth),Pe=this.localClippingEnabled,de=Ve.init(this.clippingPlanes,Pe),S=Fe.get(he,T.length),S.init(),T.push(S),We.enabled===!0&&We.isPresenting===!0){const ut=C.xr.getDepthSensingMesh();ut!==null&&Dn(ut,pe,-1/0,C.sortObjects)}Dn(he,pe,0,C.sortObjects),S.finish(),C.sortObjects===!0&&S.sort(B,X),Ke=We.enabled===!1||We.isPresenting===!1||We.hasDepthSensing()===!1,Ke&&ye.addToRenderList(S,he),this.info.render.frame++,de===!0&&Ve.beginShadows();const Ie=M.state.shadowsArray;He.render(Ie,he,pe),de===!0&&Ve.endShadows(),this.info.autoReset===!0&&this.info.reset();const Le=S.opaque,Ce=S.transmissive;if(M.setupLights(),pe.isArrayCamera){const ut=pe.cameras;if(Ce.length>0)for(let St=0,At=ut.length;St<At;St++){const Tt=ut[St];fr(Le,Ce,he,Tt)}Ke&&ye.render(he);for(let St=0,At=ut.length;St<At;St++){const Tt=ut[St];ln(S,he,Tt,Tt.viewport)}}else Ce.length>0&&fr(Le,Ce,he,pe),Ke&&ye.render(he),ln(S,he,pe);D!==null&&A===0&&(ke.updateMultisampleRenderTarget(D),ke.updateRenderTargetMipmap(D)),he.isScene===!0&&he.onAfterRender(C,he,pe),Ne.resetDefaultState(),U=-1,F=null,E.pop(),E.length>0?(M=E[E.length-1],de===!0&&Ve.setGlobalState(C.clippingPlanes,M.state.camera)):M=null,T.pop(),T.length>0?S=T[T.length-1]:S=null};function Dn(he,pe,Ie,Le){if(he.visible===!1)return;if(he.layers.test(pe.layers)){if(he.isGroup)Ie=he.renderOrder;else if(he.isLOD)he.autoUpdate===!0&&he.update(pe);else if(he.isLight)M.pushLight(he),he.castShadow&&M.pushShadow(he);else if(he.isSprite){if(!he.frustumCulled||xe.intersectsSprite(he)){Le&&Oe.setFromMatrixPosition(he.matrixWorld).applyMatrix4(ie);const St=_e.update(he),At=he.material;At.visible&&S.push(he,St,At,Ie,Oe.z,null)}}else if((he.isMesh||he.isLine||he.isPoints)&&(!he.frustumCulled||xe.intersectsObject(he))){const St=_e.update(he),At=he.material;if(Le&&(he.boundingSphere!==void 0?(he.boundingSphere===null&&he.computeBoundingSphere(),Oe.copy(he.boundingSphere.center)):(St.boundingSphere===null&&St.computeBoundingSphere(),Oe.copy(St.boundingSphere.center)),Oe.applyMatrix4(he.matrixWorld).applyMatrix4(ie)),Array.isArray(At)){const Tt=St.groups;for(let Ft=0,Pt=Tt.length;Ft<Pt;Ft++){const Mt=Tt[Ft],en=At[Mt.materialIndex];en&&en.visible&&S.push(he,St,en,Ie,Oe.z,Mt)}}else At.visible&&S.push(he,St,At,Ie,Oe.z,null)}}const ut=he.children;for(let St=0,At=ut.length;St<At;St++)Dn(ut[St],pe,Ie,Le)}function ln(he,pe,Ie,Le){const{opaque:Ce,transmissive:ut,transparent:St}=he;M.setupLightsView(Ie),de===!0&&Ve.setGlobalState(C.clippingPlanes,Ie),Le&&I.viewport(H.copy(Le)),Ce.length>0&&Fn(Ce,pe,Ie),ut.length>0&&Fn(ut,pe,Ie),St.length>0&&Fn(St,pe,Ie),I.buffers.depth.setTest(!0),I.buffers.depth.setMask(!0),I.buffers.color.setMask(!0),I.setPolygonOffset(!1)}function fr(he,pe,Ie,Le){if((Ie.isScene===!0?Ie.overrideMaterial:null)!==null)return;M.state.transmissionRenderTarget[Le.id]===void 0&&(M.state.transmissionRenderTarget[Le.id]=new xm(1,1,{generateMipmaps:!0,type:q.has("EXT_color_buffer_half_float")||q.has("EXT_color_buffer_float")?Cx:yc,minFilter:Of,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:sr.workingColorSpace}));const ut=M.state.transmissionRenderTarget[Le.id],St=Le.viewport||H;ut.setSize(St.z*C.transmissionResolutionScale,St.w*C.transmissionResolutionScale);const At=C.getRenderTarget(),Tt=C.getActiveCubeFace(),Ft=C.getActiveMipmapLevel();C.setRenderTarget(ut),C.getClearColor(K),V=C.getClearAlpha(),V<1&&C.setClearColor(16777215,.5),C.clear(),Ke&&ye.render(Ie);const Pt=C.toneMapping;C.toneMapping=lh;const Mt=Le.viewport;if(Le.viewport!==void 0&&(Le.viewport=void 0),M.setupLightsView(Le),de===!0&&Ve.setGlobalState(C.clippingPlanes,Le),Fn(he,Ie,Le),ke.updateMultisampleRenderTarget(ut),ke.updateRenderTargetMipmap(ut),q.has("WEBGL_multisampled_render_to_texture")===!1){let en=!1;for(let $t=0,dn=pe.length;$t<dn;$t++){const cn=pe[$t],{object:Sn,geometry:Gt,material:sn,group:un}=cn;if(sn.side===ic&&Sn.layers.test(Le.layers)){const Yt=sn.side;sn.side=Us,sn.needsUpdate=!0,Kn(Sn,Ie,Le,Gt,sn,un),sn.side=Yt,sn.needsUpdate=!0,en=!0}}en===!0&&(ke.updateMultisampleRenderTarget(ut),ke.updateRenderTargetMipmap(ut))}C.setRenderTarget(At,Tt,Ft),C.setClearColor(K,V),Mt!==void 0&&(Le.viewport=Mt),C.toneMapping=Pt}function Fn(he,pe,Ie){const Le=pe.isScene===!0?pe.overrideMaterial:null;for(let Ce=0,ut=he.length;Ce<ut;Ce++){const St=he[Ce],{object:At,geometry:Tt,group:Ft}=St;let Pt=St.material;Pt.allowOverride===!0&&Le!==null&&(Pt=Le),At.layers.test(Ie.layers)&&Kn(At,pe,Ie,Tt,Pt,Ft)}}function Kn(he,pe,Ie,Le,Ce,ut){he.onBeforeRender(C,pe,Ie,Le,Ce,ut),he.modelViewMatrix.multiplyMatrices(Ie.matrixWorldInverse,he.matrixWorld),he.normalMatrix.getNormalMatrix(he.modelViewMatrix),Ce.onBeforeRender(C,pe,Ie,Le,he,ut),Ce.transparent===!0&&Ce.side===ic&&Ce.forceSinglePass===!1?(Ce.side=Us,Ce.needsUpdate=!0,C.renderBufferDirect(Ie,pe,Le,Ce,he,ut),Ce.side=Eh,Ce.needsUpdate=!0,C.renderBufferDirect(Ie,pe,Le,Ce,he,ut),Ce.side=ic):C.renderBufferDirect(Ie,pe,Le,Ce,he,ut),he.onAfterRender(C,pe,Ie,Le,Ce,ut)}function bn(he,pe,Ie){pe.isScene!==!0&&(pe=ge);const Le=me.get(he),Ce=M.state.lights,ut=M.state.shadowsArray,St=Ce.state.version,At=we.getParameters(he,Ce.state,ut,pe,Ie),Tt=we.getProgramCacheKey(At);let Ft=Le.programs;Le.environment=he.isMeshStandardMaterial?pe.environment:null,Le.fog=pe.fog,Le.envMap=(he.isMeshStandardMaterial?O:z).get(he.envMap||Le.environment),Le.envMapRotation=Le.environment!==null&&he.envMap===null?pe.environmentRotation:he.envMapRotation,Ft===void 0&&(he.addEventListener("dispose",Ye),Ft=new Map,Le.programs=Ft);let Pt=Ft.get(Tt);if(Pt!==void 0){if(Le.currentProgram===Pt&&Le.lightsStateVersion===St)return Ba(he,At),Pt}else At.uniforms=we.getUniforms(he),he.onBeforeCompile(At,C),Pt=we.acquireProgram(At,Tt),Ft.set(Tt,Pt),Le.uniforms=At.uniforms;const Mt=Le.uniforms;return(!he.isShaderMaterial&&!he.isRawShaderMaterial||he.clipping===!0)&&(Mt.clippingPlanes=Ve.uniform),Ba(he,At),Le.needsLights=st(he),Le.lightsStateVersion=St,Le.needsLights&&(Mt.ambientLightColor.value=Ce.state.ambient,Mt.lightProbe.value=Ce.state.probe,Mt.directionalLights.value=Ce.state.directional,Mt.directionalLightShadows.value=Ce.state.directionalShadow,Mt.spotLights.value=Ce.state.spot,Mt.spotLightShadows.value=Ce.state.spotShadow,Mt.rectAreaLights.value=Ce.state.rectArea,Mt.ltc_1.value=Ce.state.rectAreaLTC1,Mt.ltc_2.value=Ce.state.rectAreaLTC2,Mt.pointLights.value=Ce.state.point,Mt.pointLightShadows.value=Ce.state.pointShadow,Mt.hemisphereLights.value=Ce.state.hemi,Mt.directionalShadowMap.value=Ce.state.directionalShadowMap,Mt.directionalShadowMatrix.value=Ce.state.directionalShadowMatrix,Mt.spotShadowMap.value=Ce.state.spotShadowMap,Mt.spotLightMatrix.value=Ce.state.spotLightMatrix,Mt.spotLightMap.value=Ce.state.spotLightMap,Mt.pointShadowMap.value=Ce.state.pointShadowMap,Mt.pointShadowMatrix.value=Ce.state.pointShadowMatrix),Le.currentProgram=Pt,Le.uniformsList=null,Pt}function wi(he){if(he.uniformsList===null){const pe=he.currentProgram.getUniforms();he.uniformsList=j1.seqWithValue(pe.seq,he.uniforms)}return he.uniformsList}function Ba(he,pe){const Ie=me.get(he);Ie.outputColorSpace=pe.outputColorSpace,Ie.batching=pe.batching,Ie.batchingColor=pe.batchingColor,Ie.instancing=pe.instancing,Ie.instancingColor=pe.instancingColor,Ie.instancingMorph=pe.instancingMorph,Ie.skinning=pe.skinning,Ie.morphTargets=pe.morphTargets,Ie.morphNormals=pe.morphNormals,Ie.morphColors=pe.morphColors,Ie.morphTargetsCount=pe.morphTargetsCount,Ie.numClippingPlanes=pe.numClippingPlanes,Ie.numIntersection=pe.numClipIntersection,Ie.vertexAlphas=pe.vertexAlphas,Ie.vertexTangents=pe.vertexTangents,Ie.toneMapping=pe.toneMapping}function Ae(he,pe,Ie,Le,Ce){pe.isScene!==!0&&(pe=ge),ke.resetTextureUnits();const ut=pe.fog,St=Le.isMeshStandardMaterial?pe.environment:null,At=D===null?C.outputColorSpace:D.isXRRenderTarget===!0?D.texture.colorSpace:ex,Tt=(Le.isMeshStandardMaterial?O:z).get(Le.envMap||St),Ft=Le.vertexColors===!0&&!!Ie.attributes.color&&Ie.attributes.color.itemSize===4,Pt=!!Ie.attributes.tangent&&(!!Le.normalMap||Le.anisotropy>0),Mt=!!Ie.morphAttributes.position,en=!!Ie.morphAttributes.normal,$t=!!Ie.morphAttributes.color;let dn=lh;Le.toneMapped&&(D===null||D.isXRRenderTarget===!0)&&(dn=C.toneMapping);const cn=Ie.morphAttributes.position||Ie.morphAttributes.normal||Ie.morphAttributes.color,Sn=cn!==void 0?cn.length:0,Gt=me.get(Le),sn=M.state.lights;if(de===!0&&(Pe===!0||he!==F)){const jt=he===F&&Le.id===U;Ve.setState(Le,he,jt)}let un=!1;Le.version===Gt.__version?(Gt.needsLights&&Gt.lightsStateVersion!==sn.state.version||Gt.outputColorSpace!==At||Ce.isBatchedMesh&&Gt.batching===!1||!Ce.isBatchedMesh&&Gt.batching===!0||Ce.isBatchedMesh&&Gt.batchingColor===!0&&Ce.colorTexture===null||Ce.isBatchedMesh&&Gt.batchingColor===!1&&Ce.colorTexture!==null||Ce.isInstancedMesh&&Gt.instancing===!1||!Ce.isInstancedMesh&&Gt.instancing===!0||Ce.isSkinnedMesh&&Gt.skinning===!1||!Ce.isSkinnedMesh&&Gt.skinning===!0||Ce.isInstancedMesh&&Gt.instancingColor===!0&&Ce.instanceColor===null||Ce.isInstancedMesh&&Gt.instancingColor===!1&&Ce.instanceColor!==null||Ce.isInstancedMesh&&Gt.instancingMorph===!0&&Ce.morphTexture===null||Ce.isInstancedMesh&&Gt.instancingMorph===!1&&Ce.morphTexture!==null||Gt.envMap!==Tt||Le.fog===!0&&Gt.fog!==ut||Gt.numClippingPlanes!==void 0&&(Gt.numClippingPlanes!==Ve.numPlanes||Gt.numIntersection!==Ve.numIntersection)||Gt.vertexAlphas!==Ft||Gt.vertexTangents!==Pt||Gt.morphTargets!==Mt||Gt.morphNormals!==en||Gt.morphColors!==$t||Gt.toneMapping!==dn||Gt.morphTargetsCount!==Sn)&&(un=!0):(un=!0,Gt.__version=Le.version);let Yt=Gt.currentProgram;un===!0&&(Yt=bn(Le,pe,Ce));let tr=!1,jn=!1,ii=!1;const nr=Yt.getUniforms(),lr=Gt.uniforms;if(I.useProgram(Yt.program)&&(tr=!0,jn=!0,ii=!0),Le.id!==U&&(U=Le.id,jn=!0),tr||F!==he){I.buffers.depth.getReversed()&&he.reversedDepth!==!0&&(he._reversedDepth=!0,he.updateProjectionMatrix()),nr.setValue(Y,"projectionMatrix",he.projectionMatrix),nr.setValue(Y,"viewMatrix",he.matrixWorldInverse);const qt=nr.map.cameraPosition;qt!==void 0&&qt.setValue(Y,Me.setFromMatrixPosition(he.matrixWorld)),te.logarithmicDepthBuffer&&nr.setValue(Y,"logDepthBufFC",2/(Math.log(he.far+1)/Math.LN2)),(Le.isMeshPhongMaterial||Le.isMeshToonMaterial||Le.isMeshLambertMaterial||Le.isMeshBasicMaterial||Le.isMeshStandardMaterial||Le.isShaderMaterial)&&nr.setValue(Y,"isOrthographic",he.isOrthographicCamera===!0),F!==he&&(F=he,jn=!0,ii=!0)}if(Ce.isSkinnedMesh){nr.setOptional(Y,Ce,"bindMatrix"),nr.setOptional(Y,Ce,"bindMatrixInverse");const jt=Ce.skeleton;jt&&(jt.boneTexture===null&&jt.computeBoneTexture(),nr.setValue(Y,"boneTexture",jt.boneTexture,ke))}Ce.isBatchedMesh&&(nr.setOptional(Y,Ce,"batchingTexture"),nr.setValue(Y,"batchingTexture",Ce._matricesTexture,ke),nr.setOptional(Y,Ce,"batchingIdTexture"),nr.setValue(Y,"batchingIdTexture",Ce._indirectTexture,ke),nr.setOptional(Y,Ce,"batchingColorTexture"),Ce._colorsTexture!==null&&nr.setValue(Y,"batchingColorTexture",Ce._colorsTexture,ke));const et=Ie.morphAttributes;if((et.position!==void 0||et.normal!==void 0||et.color!==void 0)&&je.update(Ce,Ie,Yt),(jn||Gt.receiveShadow!==Ce.receiveShadow)&&(Gt.receiveShadow=Ce.receiveShadow,nr.setValue(Y,"receiveShadow",Ce.receiveShadow)),Le.isMeshGouraudMaterial&&Le.envMap!==null&&(lr.envMap.value=Tt,lr.flipEnvMap.value=Tt.isCubeTexture&&Tt.isRenderTargetTexture===!1?-1:1),Le.isMeshStandardMaterial&&Le.envMap===null&&pe.environment!==null&&(lr.envMapIntensity.value=pe.environmentIntensity),lr.dfgLUT!==void 0&&(lr.dfgLUT.value=P4e()),jn&&(nr.setValue(Y,"toneMappingExposure",C.toneMappingExposure),Gt.needsLights&&Ze(lr,ii),ut&&Le.fog===!0&&re.refreshFogUniforms(lr,ut),re.refreshMaterialUniforms(lr,Le,ae,Z,M.state.transmissionRenderTarget[he.id]),j1.upload(Y,wi(Gt),lr,ke)),Le.isShaderMaterial&&Le.uniformsNeedUpdate===!0&&(j1.upload(Y,wi(Gt),lr,ke),Le.uniformsNeedUpdate=!1),Le.isSpriteMaterial&&nr.setValue(Y,"center",Ce.center),nr.setValue(Y,"modelViewMatrix",Ce.modelViewMatrix),nr.setValue(Y,"normalMatrix",Ce.normalMatrix),nr.setValue(Y,"modelMatrix",Ce.matrixWorld),Le.isShaderMaterial||Le.isRawShaderMaterial){const jt=Le.uniformsGroups;for(let qt=0,yt=jt.length;qt<yt;qt++){const wn=jt[qt];tt.update(wn,Yt),tt.bind(wn,Yt)}}return Yt}function Ze(he,pe){he.ambientLightColor.needsUpdate=pe,he.lightProbe.needsUpdate=pe,he.directionalLights.needsUpdate=pe,he.directionalLightShadows.needsUpdate=pe,he.pointLights.needsUpdate=pe,he.pointLightShadows.needsUpdate=pe,he.spotLights.needsUpdate=pe,he.spotLightShadows.needsUpdate=pe,he.rectAreaLights.needsUpdate=pe,he.hemisphereLights.needsUpdate=pe}function st(he){return he.isMeshLambertMaterial||he.isMeshToonMaterial||he.isMeshPhongMaterial||he.isMeshStandardMaterial||he.isShadowMaterial||he.isShaderMaterial&&he.lights===!0}this.getActiveCubeFace=function(){return R},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return D},this.setRenderTargetTextures=function(he,pe,Ie){const Le=me.get(he);Le.__autoAllocateDepthBuffer=he.resolveDepthBuffer===!1,Le.__autoAllocateDepthBuffer===!1&&(Le.__useRenderToTexture=!1),me.get(he.texture).__webglTexture=pe,me.get(he.depthTexture).__webglTexture=Le.__autoAllocateDepthBuffer?void 0:Ie,Le.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(he,pe){const Ie=me.get(he);Ie.__webglFramebuffer=pe,Ie.__useDefaultFramebuffer=pe===void 0};const lt=Y.createFramebuffer();this.setRenderTarget=function(he,pe=0,Ie=0){D=he,R=pe,A=Ie;let Le=!0,Ce=null,ut=!1,St=!1;if(he){const Tt=me.get(he);if(Tt.__useDefaultFramebuffer!==void 0)I.bindFramebuffer(Y.FRAMEBUFFER,null),Le=!1;else if(Tt.__webglFramebuffer===void 0)ke.setupRenderTarget(he);else if(Tt.__hasExternalTextures)ke.rebindTextures(he,me.get(he.texture).__webglTexture,me.get(he.depthTexture).__webglTexture);else if(he.depthBuffer){const Mt=he.depthTexture;if(Tt.__boundDepthTexture!==Mt){if(Mt!==null&&me.has(Mt)&&(he.width!==Mt.image.width||he.height!==Mt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");ke.setupDepthRenderbuffer(he)}}const Ft=he.texture;(Ft.isData3DTexture||Ft.isDataArrayTexture||Ft.isCompressedArrayTexture)&&(St=!0);const Pt=me.get(he).__webglFramebuffer;he.isWebGLCubeRenderTarget?(Array.isArray(Pt[pe])?Ce=Pt[pe][Ie]:Ce=Pt[pe],ut=!0):he.samples>0&&ke.useMultisampledRTT(he)===!1?Ce=me.get(he).__webglMultisampledFramebuffer:Array.isArray(Pt)?Ce=Pt[Ie]:Ce=Pt,H.copy(he.viewport),j.copy(he.scissor),$=he.scissorTest}else H.copy(ne).multiplyScalar(ae).floor(),j.copy(se).multiplyScalar(ae).floor(),$=be;if(Ie!==0&&(Ce=lt),I.bindFramebuffer(Y.FRAMEBUFFER,Ce)&&Le&&I.drawBuffers(he,Ce),I.viewport(H),I.scissor(j),I.setScissorTest($),ut){const Tt=me.get(he.texture);Y.framebufferTexture2D(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_CUBE_MAP_POSITIVE_X+pe,Tt.__webglTexture,Ie)}else if(St){const Tt=pe;for(let Ft=0;Ft<he.textures.length;Ft++){const Pt=me.get(he.textures[Ft]);Y.framebufferTextureLayer(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0+Ft,Pt.__webglTexture,Ie,Tt)}}else if(he!==null&&Ie!==0){const Tt=me.get(he.texture);Y.framebufferTexture2D(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_2D,Tt.__webglTexture,Ie)}U=-1},this.readRenderTargetPixels=function(he,pe,Ie,Le,Ce,ut,St,At=0){if(!(he&&he.isWebGLRenderTarget)){ki("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Tt=me.get(he).__webglFramebuffer;if(he.isWebGLCubeRenderTarget&&St!==void 0&&(Tt=Tt[St]),Tt){I.bindFramebuffer(Y.FRAMEBUFFER,Tt);try{const Ft=he.textures[At],Pt=Ft.format,Mt=Ft.type;if(!te.textureFormatReadable(Pt)){ki("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!te.textureTypeReadable(Mt)){ki("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}pe>=0&&pe<=he.width-Le&&Ie>=0&&Ie<=he.height-Ce&&(he.textures.length>1&&Y.readBuffer(Y.COLOR_ATTACHMENT0+At),Y.readPixels(pe,Ie,Le,Ce,Xe.convert(Pt),Xe.convert(Mt),ut))}finally{const Ft=D!==null?me.get(D).__webglFramebuffer:null;I.bindFramebuffer(Y.FRAMEBUFFER,Ft)}}},this.readRenderTargetPixelsAsync=async function(he,pe,Ie,Le,Ce,ut,St,At=0){if(!(he&&he.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Tt=me.get(he).__webglFramebuffer;if(he.isWebGLCubeRenderTarget&&St!==void 0&&(Tt=Tt[St]),Tt)if(pe>=0&&pe<=he.width-Le&&Ie>=0&&Ie<=he.height-Ce){I.bindFramebuffer(Y.FRAMEBUFFER,Tt);const Ft=he.textures[At],Pt=Ft.format,Mt=Ft.type;if(!te.textureFormatReadable(Pt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!te.textureTypeReadable(Mt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const en=Y.createBuffer();Y.bindBuffer(Y.PIXEL_PACK_BUFFER,en),Y.bufferData(Y.PIXEL_PACK_BUFFER,ut.byteLength,Y.STREAM_READ),he.textures.length>1&&Y.readBuffer(Y.COLOR_ATTACHMENT0+At),Y.readPixels(pe,Ie,Le,Ce,Xe.convert(Pt),Xe.convert(Mt),0);const $t=D!==null?me.get(D).__webglFramebuffer:null;I.bindFramebuffer(Y.FRAMEBUFFER,$t);const dn=Y.fenceSync(Y.SYNC_GPU_COMMANDS_COMPLETE,0);return Y.flush(),await iPe(Y,dn,4),Y.bindBuffer(Y.PIXEL_PACK_BUFFER,en),Y.getBufferSubData(Y.PIXEL_PACK_BUFFER,0,ut),Y.deleteBuffer(en),Y.deleteSync(dn),ut}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(he,pe=null,Ie=0){const Le=Math.pow(2,-Ie),Ce=Math.floor(he.image.width*Le),ut=Math.floor(he.image.height*Le),St=pe!==null?pe.x:0,At=pe!==null?pe.y:0;ke.setTexture2D(he,0),Y.copyTexSubImage2D(Y.TEXTURE_2D,Ie,0,0,St,At,Ce,ut),I.unbindTexture()};const ot=Y.createFramebuffer(),kt=Y.createFramebuffer();this.copyTextureToTexture=function(he,pe,Ie=null,Le=null,Ce=0,ut=null){ut===null&&(Ce!==0?(py("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ut=Ce,Ce=0):ut=0);let St,At,Tt,Ft,Pt,Mt,en,$t,dn;const cn=he.isCompressedTexture?he.mipmaps[ut]:he.image;if(Ie!==null)St=Ie.max.x-Ie.min.x,At=Ie.max.y-Ie.min.y,Tt=Ie.isBox3?Ie.max.z-Ie.min.z:1,Ft=Ie.min.x,Pt=Ie.min.y,Mt=Ie.isBox3?Ie.min.z:0;else{const et=Math.pow(2,-Ce);St=Math.floor(cn.width*et),At=Math.floor(cn.height*et),he.isDataArrayTexture?Tt=cn.depth:he.isData3DTexture?Tt=Math.floor(cn.depth*et):Tt=1,Ft=0,Pt=0,Mt=0}Le!==null?(en=Le.x,$t=Le.y,dn=Le.z):(en=0,$t=0,dn=0);const Sn=Xe.convert(pe.format),Gt=Xe.convert(pe.type);let sn;pe.isData3DTexture?(ke.setTexture3D(pe,0),sn=Y.TEXTURE_3D):pe.isDataArrayTexture||pe.isCompressedArrayTexture?(ke.setTexture2DArray(pe,0),sn=Y.TEXTURE_2D_ARRAY):(ke.setTexture2D(pe,0),sn=Y.TEXTURE_2D),Y.pixelStorei(Y.UNPACK_FLIP_Y_WEBGL,pe.flipY),Y.pixelStorei(Y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,pe.premultiplyAlpha),Y.pixelStorei(Y.UNPACK_ALIGNMENT,pe.unpackAlignment);const un=Y.getParameter(Y.UNPACK_ROW_LENGTH),Yt=Y.getParameter(Y.UNPACK_IMAGE_HEIGHT),tr=Y.getParameter(Y.UNPACK_SKIP_PIXELS),jn=Y.getParameter(Y.UNPACK_SKIP_ROWS),ii=Y.getParameter(Y.UNPACK_SKIP_IMAGES);Y.pixelStorei(Y.UNPACK_ROW_LENGTH,cn.width),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,cn.height),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,Ft),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,Pt),Y.pixelStorei(Y.UNPACK_SKIP_IMAGES,Mt);const nr=he.isDataArrayTexture||he.isData3DTexture,lr=pe.isDataArrayTexture||pe.isData3DTexture;if(he.isDepthTexture){const et=me.get(he),jt=me.get(pe),qt=me.get(et.__renderTarget),yt=me.get(jt.__renderTarget);I.bindFramebuffer(Y.READ_FRAMEBUFFER,qt.__webglFramebuffer),I.bindFramebuffer(Y.DRAW_FRAMEBUFFER,yt.__webglFramebuffer);for(let wn=0;wn<Tt;wn++)nr&&(Y.framebufferTextureLayer(Y.READ_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,me.get(he).__webglTexture,Ce,Mt+wn),Y.framebufferTextureLayer(Y.DRAW_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,me.get(pe).__webglTexture,ut,dn+wn)),Y.blitFramebuffer(Ft,Pt,St,At,en,$t,St,At,Y.DEPTH_BUFFER_BIT,Y.NEAREST);I.bindFramebuffer(Y.READ_FRAMEBUFFER,null),I.bindFramebuffer(Y.DRAW_FRAMEBUFFER,null)}else if(Ce!==0||he.isRenderTargetTexture||me.has(he)){const et=me.get(he),jt=me.get(pe);I.bindFramebuffer(Y.READ_FRAMEBUFFER,ot),I.bindFramebuffer(Y.DRAW_FRAMEBUFFER,kt);for(let qt=0;qt<Tt;qt++)nr?Y.framebufferTextureLayer(Y.READ_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,et.__webglTexture,Ce,Mt+qt):Y.framebufferTexture2D(Y.READ_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_2D,et.__webglTexture,Ce),lr?Y.framebufferTextureLayer(Y.DRAW_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,jt.__webglTexture,ut,dn+qt):Y.framebufferTexture2D(Y.DRAW_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_2D,jt.__webglTexture,ut),Ce!==0?Y.blitFramebuffer(Ft,Pt,St,At,en,$t,St,At,Y.COLOR_BUFFER_BIT,Y.NEAREST):lr?Y.copyTexSubImage3D(sn,ut,en,$t,dn+qt,Ft,Pt,St,At):Y.copyTexSubImage2D(sn,ut,en,$t,Ft,Pt,St,At);I.bindFramebuffer(Y.READ_FRAMEBUFFER,null),I.bindFramebuffer(Y.DRAW_FRAMEBUFFER,null)}else lr?he.isDataTexture||he.isData3DTexture?Y.texSubImage3D(sn,ut,en,$t,dn,St,At,Tt,Sn,Gt,cn.data):pe.isCompressedArrayTexture?Y.compressedTexSubImage3D(sn,ut,en,$t,dn,St,At,Tt,Sn,cn.data):Y.texSubImage3D(sn,ut,en,$t,dn,St,At,Tt,Sn,Gt,cn):he.isDataTexture?Y.texSubImage2D(Y.TEXTURE_2D,ut,en,$t,St,At,Sn,Gt,cn.data):he.isCompressedTexture?Y.compressedTexSubImage2D(Y.TEXTURE_2D,ut,en,$t,cn.width,cn.height,Sn,cn.data):Y.texSubImage2D(Y.TEXTURE_2D,ut,en,$t,St,At,Sn,Gt,cn);Y.pixelStorei(Y.UNPACK_ROW_LENGTH,un),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,Yt),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,tr),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,jn),Y.pixelStorei(Y.UNPACK_SKIP_IMAGES,ii),ut===0&&pe.generateMipmaps&&Y.generateMipmap(sn),I.unbindTexture()},this.initRenderTarget=function(he){me.get(he).__webglFramebuffer===void 0&&ke.setupRenderTarget(he)},this.initTexture=function(he){he.isCubeTexture?ke.setTextureCube(he,0):he.isData3DTexture?ke.setTexture3D(he,0):he.isDataArrayTexture||he.isCompressedArrayTexture?ke.setTexture2DArray(he,0):ke.setTexture2D(he,0),I.unbindTexture()},this.resetState=function(){R=0,A=0,D=null,I.reset(),Ne.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=sr._getDrawingBufferColorSpace(e),n.unpackColorSpace=sr._getUnpackColorSpace()}};const AV={type:"change"},nL={type:"start"},DJ={type:"end"},v_=new Q4,CV=new Bd,R4e=Math.cos(70*sPe.DEG2RAD),Wi=new dt,js=2*Math.PI,Tr={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},_C=1e-6;class O4e extends qPe{constructor(e,n=null){super(e,n),this.state=Tr.NONE,this.target=new dt,this.cursor=new dt,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:Tg.ROTATE,MIDDLE:Tg.DOLLY,RIGHT:Tg.PAN},this.touches={ONE:bg.ROTATE,TWO:bg.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new dt,this._lastQuaternion=new gm,this._lastTargetPosition=new dt,this._quat=new gm().setFromUnitVectors(e.up,new dt(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new iV,this._sphericalDelta=new iV,this._scale=1,this._panOffset=new dt,this._rotateStart=new Tn,this._rotateEnd=new Tn,this._rotateDelta=new Tn,this._panStart=new Tn,this._panEnd=new Tn,this._panDelta=new Tn,this._dollyStart=new Tn,this._dollyEnd=new Tn,this._dollyDelta=new Tn,this._dollyDirection=new dt,this._mouse=new Tn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=F4e.bind(this),this._onPointerDown=L4e.bind(this),this._onPointerUp=I4e.bind(this),this._onContextMenu=G4e.bind(this),this._onMouseWheel=B4e.bind(this),this._onKeyDown=$4e.bind(this),this._onTouchStart=H4e.bind(this),this._onTouchMove=V4e.bind(this),this._onMouseDown=U4e.bind(this),this._onMouseMove=z4e.bind(this),this._interceptControlDown=q4e.bind(this),this._interceptControlUp=W4e.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(AV),this.update(),this.state=Tr.NONE}update(e=null){const n=this.object.position;Wi.copy(n).sub(this.target),Wi.applyQuaternion(this._quat),this._spherical.setFromVector3(Wi),this.autoRotate&&this.state===Tr.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+=js:r>Math.PI&&(r-=js),i<-Math.PI?i+=js:i>Math.PI&&(i-=js),r<=i?this._spherical.theta=Math.max(r,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+i)/2?Math.max(r,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=o!=this._spherical.radius}if(Wi.setFromSpherical(this._spherical),Wi.applyQuaternion(this._quatInverse),n.copy(this.target).add(Wi),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=Wi.length();o=this._clampDistance(l*this._scale);const c=l-o;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),a=!!c}else if(this.object.isOrthographicCamera){const l=new dt(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(),a=c!==this.object.zoom;const u=new dt(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),o=Wi.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):(v_.origin.copy(this.object.position),v_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(v_.direction))<R4e?this.object.lookAt(this.target):(CV.setFromNormalAndCoplanarPoint(this.object.up,this.target),v_.intersectPlane(CV,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(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>_C||8*(1-this._lastQuaternion.dot(this.object.quaternion))>_C||this._lastTargetPosition.distanceToSquared(this.target)>_C?(this.dispatchEvent(AV),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?js/60*this.autoRotateSpeed*e:js/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){Wi.setFromMatrixColumn(n,0),Wi.multiplyScalar(-e),this._panOffset.add(Wi)}_panUp(e,n){this.screenSpacePanning===!0?Wi.setFromMatrixColumn(n,1):(Wi.setFromMatrixColumn(n,0),Wi.crossVectors(this.object.up,Wi)),Wi.multiplyScalar(e),this._panOffset.add(Wi)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Wi.copy(i).sub(this.target);let a=Wi.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*a/r.clientHeight,this.object.matrix),this._panUp(2*n*a/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/r.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const r=this.domElement.getBoundingClientRect(),i=e-r.left,a=n-r.top,o=r.width,l=r.height;this._mouse.x=i/o*2-1,this._mouse.y=-(a/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(js*this._rotateDelta.x/n.clientHeight),this._rotateUp(js*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(js*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(-js*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(js*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(-js*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),n=!0;break}n&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._rotateStart.set(r,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panStart.set(r,i)}}_handleTouchStartDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,a=Math.sqrt(r*r+i*i);this._dollyStart.set(0,a)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const r=this._getSecondPointerPosition(e),i=.5*(e.pageX+r.x),a=.5*(e.pageY+r.y);this._rotateEnd.set(i,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(js*this._rotateDelta.x/n.clientHeight),this._rotateUp(js*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panEnd.set(r,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,a=Math.sqrt(r*r+i*i);this._dollyEnd.set(0,a),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const 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 Tn,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 L4e(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 F4e(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function I4e(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(DJ),this.state=Tr.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 U4e(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 Tg.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=Tr.DOLLY;break;case Tg.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Tr.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Tr.ROTATE}break;case Tg.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Tr.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Tr.PAN}break;default:this.state=Tr.NONE}this.state!==Tr.NONE&&this.dispatchEvent(nL)}function z4e(t){switch(this.state){case Tr.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case Tr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case Tr.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function B4e(t){this.enabled===!1||this.enableZoom===!1||this.state!==Tr.NONE||(t.preventDefault(),this.dispatchEvent(nL),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(DJ))}function $4e(t){this.enabled!==!1&&this._handleKeyDown(t)}function H4e(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case bg.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=Tr.TOUCH_ROTATE;break;case bg.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=Tr.TOUCH_PAN;break;default:this.state=Tr.NONE}break;case 2:switch(this.touches.TWO){case bg.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=Tr.TOUCH_DOLLY_PAN;break;case bg.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=Tr.TOUCH_DOLLY_ROTATE;break;default:this.state=Tr.NONE}break;default:this.state=Tr.NONE}this.state!==Tr.NONE&&this.dispatchEvent(nL)}function V4e(t){switch(this._trackPointer(t),this.state){case Tr.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case Tr.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case Tr.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case Tr.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=Tr.NONE}}function G4e(t){this.enabled!==!1&&t.preventDefault()}function q4e(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function W4e(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function K4e(t,e=!1){const n=t[0].index!==null,r=new Set(Object.keys(t[0].attributes)),i=new Set(Object.keys(t[0].morphAttributes)),a={},o={},l=t[0].morphTargetsRelative,c=new Ac;let u=0;for(let d=0;d<t.length;++d){const f=t[d];let p=0;if(n!==(f.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const m in f.attributes){if(!r.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.'),null;a[m]===void 0&&(a[m]=[]),a[m].push(f.attributes[m]),p++}if(p!==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 m in f.morphAttributes){if(!i.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;o[m]===void 0&&(o[m]=[]),o[m].push(f.morphAttributes[m])}if(e){let m;if(n)m=f.index.count;else if(f.attributes.position!==void 0)m=f.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;c.addGroup(u,m,d),u+=m}}if(n){let d=0;const f=[];for(let p=0;p<t.length;++p){const m=t[p].index;for(let x=0;x<m.count;++x)f.push(m.getX(x)+d);d+=t[p].attributes.position.count}c.setIndex(f)}for(const d in a){const f=jV(a[d]);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" attribute."),null;c.setAttribute(d,f)}for(const d in o){const f=o[d][0].length;if(f===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[d]=[];for(let p=0;p<f;++p){const m=[];for(let b=0;b<o[d].length;++b)m.push(o[d][b][p]);const x=jV(m);if(!x)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;c.morphAttributes[d].push(x)}}return c}function jV(t){let e,n,r,i=-1,a=0;for(let u=0;u<t.length;++u){const d=t[u];if(e===void 0&&(e=d.array.constructor),e!==d.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(n===void 0&&(n=d.itemSize),n!==d.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=d.normalized),r!==d.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=d.gpuType),i!==d.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;a+=d.count*n}const o=new e(a),l=new nl(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 p=0,m=d.count;p<m;p++)for(let x=0;x<n;x++){const b=d.getComponent(p,x);l.setComponent(p+f,x,b)}}else o.set(d.array,c);c+=d.count*n}return i!==void 0&&(l.gpuType=i),l}function w_(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 SC={exports:{}};var PV;function X4e(){return PV||(PV=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(r,i,a){function o(u,d){if(!i[u]){if(!r[u]){var f=typeof w_=="function"&&w_;if(!d&&f)return f(u,!0);if(l)return l(u,!0);var p=new Error("Cannot find module '"+u+"'");throw p.code="MODULE_NOT_FOUND",p}var m=i[u]={exports:{}};r[u][0].call(m.exports,function(x){var b=r[u][1][x];return o(b||x)},m,m.exports,n,r,i,a)}return i[u].exports}for(var l=typeof w_=="function"&&w_,c=0;c<a.length;c++)o(a[c]);return o})({1:[function(n,r,i){var a=n("./utils"),o=n("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(c){for(var u,d,f,p,m,x,b,y=[],v=0,S=c.length,M=S,T=a.getTypeOf(c)!=="string";v<c.length;)M=S-v,f=T?(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),p=u>>2,m=(3&u)<<4|d>>4,x=1<M?(15&d)<<2|f>>6:64,b=2<M?63&f:64,y.push(l.charAt(p)+l.charAt(m)+l.charAt(x)+l.charAt(b));return y.join("")},i.decode=function(c){var u,d,f,p,m,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,M=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===l.charAt(64)&&M--,c.charAt(c.length-2)===l.charAt(64)&&M--,M%1!=0)throw new Error("Invalid base64 input, bad content length.");for(S=o.uint8array?new Uint8Array(0|M):new Array(0|M);b<c.length;)u=l.indexOf(c.charAt(b++))<<2|(p=l.indexOf(c.charAt(b++)))>>4,d=(15&p)<<4|(m=l.indexOf(c.charAt(b++)))>>2,f=(3&m)<<6|(x=l.indexOf(c.charAt(b++))),S[y++]=u,m!==64&&(S[y++]=d),x!==64&&(S[y++]=f);return S}},{"./support":30,"./utils":32}],2:[function(n,r,i){var a=n("./external"),o=n("./stream/DataWorker"),l=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(d,f,p,m,x){this.compressedSize=d,this.uncompressedSize=f,this.crc32=p,this.compression=m,this.compressedContent=x}u.prototype={getContentWorker:function(){var d=new o(a.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),f=this;return d.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new o(a.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,f,p){return d.pipe(new l).pipe(new c("uncompressedSize")).pipe(f.compressWorker(p)).pipe(new c("compressedSize")).withStreamInfo("compression",f)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){var a=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new a("STORE compression")},uncompressWorker:function(){return new a("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){var a=n("./utils"),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?a.getTypeOf(l)!=="string"?(function(u,d,f,p){var m=o,x=p+f;u^=-1;for(var b=p;b<x;b++)u=u>>>8^m[255&(u^d[b])];return-1^u})(0|c,l,l.length,0):(function(u,d,f,p){var m=o,x=p+f;u^=-1;for(var b=p;b<x;b++)u=u>>>8^m[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 a=null;a=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:a}},{lie:37}],7:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=n("pako"),l=n("./utils"),c=n("./stream/GenericWorker"),u=a?"uint8array":"array";function d(f,p){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=p,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(p){f.push({data:p,meta:f.meta})}},i.compressWorker=function(f){return new d("Deflate",f)},i.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function a(m,x){var b,y="";for(b=0;b<x;b++)y+=String.fromCharCode(255&m),m>>>=8;return y}function o(m,x,b,y,v,S){var M,T,E=m.file,C=m.compression,k=S!==u.utf8encode,R=l.transformTo("string",S(E.name)),A=l.transformTo("string",u.utf8encode(E.name)),D=E.comment,U=l.transformTo("string",S(D)),F=l.transformTo("string",u.utf8encode(D)),H=A.length!==E.name.length,j=F.length!==D.length,$="",K="",V="",Q=E.dir,Z=E.date,ae={crc32:0,compressedSize:0,uncompressedSize:0};x&&!b||(ae.crc32=m.crc32,ae.compressedSize=m.compressedSize,ae.uncompressedSize=m.uncompressedSize);var B=0;x&&(B|=8),k||!H&&!j||(B|=2048);var X=0,ne=0;Q&&(X|=16),v==="UNIX"?(ne=798,X|=(function(be,xe){var de=be;return be||(de=xe?16893:33204),(65535&de)<<16})(E.unixPermissions,Q)):(ne=20,X|=(function(be){return 63&(be||0)})(E.dosPermissions)),M=Z.getUTCHours(),M<<=6,M|=Z.getUTCMinutes(),M<<=5,M|=Z.getUTCSeconds()/2,T=Z.getUTCFullYear()-1980,T<<=4,T|=Z.getUTCMonth()+1,T<<=5,T|=Z.getUTCDate(),H&&(K=a(1,1)+a(d(R),4)+A,$+="up"+a(K.length,2)+K),j&&(V=a(1,1)+a(d(U),4)+F,$+="uc"+a(V.length,2)+V);var se="";return se+=`
  3919. \0`,se+=a(B,2),se+=C.magic,se+=a(M,2),se+=a(T,2),se+=a(ae.crc32,4),se+=a(ae.compressedSize,4),se+=a(ae.uncompressedSize,4),se+=a(R.length,2),se+=a($.length,2),{fileRecord:f.LOCAL_FILE_HEADER+se+R+$,dirRecord:f.CENTRAL_FILE_HEADER+a(ne,2)+se+a(U.length,2)+"\0\0\0\0"+a(X,4)+a(y,4)+R+$+U}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function p(m,x,b,y){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=b,this.encodeFileName=y,this.streamFiles=m,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(p,c),p.prototype.push=function(m){var x=m.meta.percent||0,b=this.entriesCount,y=this._sources.length;this.accumulate?this.contentBuffer.push(m):(this.bytesWritten+=m.data.length,c.prototype.push.call(this,{data:m.data,meta:{currentFile:this.currentFile,percent:b?(x+100*(b-y-1))/b:100}}))},p.prototype.openedSource=function(m){this.currentSourceOffset=this.bytesWritten,this.currentFile=m.file.name;var x=this.streamFiles&&!m.file.dir;if(x){var b=o(m,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:b.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(m){this.accumulate=!1;var x=this.streamFiles&&!m.file.dir,b=o(m,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(b.dirRecord),x)this.push({data:(function(y){return f.DATA_DESCRIPTOR+a(y.crc32,4)+a(y.compressedSize,4)+a(y.uncompressedSize,4)})(m),meta:{percent:100}});else for(this.push({data:b.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var m=this.bytesWritten,x=0;x<this.dirRecords.length;x++)this.push({data:this.dirRecords[x],meta:{percent:100}});var b=this.bytesWritten-m,y=(function(v,S,M,T,E){var C=l.transformTo("string",E(T));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(v,2)+a(v,2)+a(S,4)+a(M,4)+a(C.length,2)+C})(this.dirRecords.length,b,m,this.zipComment,this.encodeFileName);this.push({data:y,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(m){this._sources.push(m);var x=this;return m.on("data",function(b){x.processChunk(b)}),m.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),m.on("error",function(b){x.error(b)}),this},p.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))},p.prototype.error=function(m){var x=this._sources;if(!c.prototype.error.call(this,m))return!1;for(var b=0;b<x.length;b++)try{x[b].error(m)}catch{}return!0},p.prototype.lock=function(){c.prototype.lock.call(this);for(var m=this._sources,x=0;x<m.length;x++)m[x].lock()},r.exports=p},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){var a=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(p,m){f++;var x=(function(S,M){var T=S||M,E=a[T];if(!E)throw new Error(T+" is not a valid compression method !");return E})(m.options.compression,c.compression),b=m.options.compressionOptions||c.compressionOptions||{},y=m.dir,v=m.date;m._compressWorker(x,b).withStreamInfo("file",{name:p,dir:y,date:v,comment:m.comment||"",unixPermissions:m.unixPermissions,dosPermissions:m.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(p){d.error(p)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){function a(){if(!(this instanceof a))return new a;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var o=new a;for(var l in this)typeof this[l]!="function"&&(o[l]=this[l]);return o}}(a.prototype=n("./object")).loadAsync=n("./load"),a.support=n("./support"),a.defaults=n("./defaults"),a.version="3.10.1",a.loadAsync=function(o,l){return new a().loadAsync(o,l)},a.external=n("./external"),r.exports=a},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){var a=n("./utils"),o=n("./external"),l=n("./utf8"),c=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function f(p){return new o.Promise(function(m,x){var b=p.decompressed.getContentWorker().pipe(new u);b.on("error",function(y){x(y)}).on("end",function(){b.streamInfo.crc32!==p.decompressed.crc32?x(new Error("Corrupted zip : CRC32 mismatch")):m()}).resume()})}r.exports=function(p,m){var x=this;return m=a.extend(m||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:l.utf8decode}),d.isNode&&d.isStream(p)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):a.prepareContent("the loaded zip file",p,!0,m.optimizedBinaryString,m.base64).then(function(b){var y=new c(m);return y.load(b),y}).then(function(b){var y=[o.Promise.resolve(b)],v=b.files;if(m.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 M=v[S],T=M.fileNameStr,E=a.resolve(M.fileNameStr);x.file(E,M.decompressed,{binary:!0,optimizedBinaryString:!0,date:M.date,dir:M.dir,comment:M.fileCommentStr.length?M.fileCommentStr:null,unixPermissions:M.unixPermissions,dosPermissions:M.dosPermissions,createFolders:m.createFolders}),M.dir||(x.file(E).unsafeOriginalName=T)}return y.zipComment.length&&(x.comment=y.zipComment),x})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){var a=n("../utils"),o=n("../stream/GenericWorker");function l(c,u){o.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}a.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 a=n("readable-stream").Readable;function o(l,c,u){a.call(this,c),this._helper=l;var d=this;l.on("data",function(f,p){d.push(f)||d._helper.pause(),u&&u(p)}).on("error",function(f){d.emit("error",f)}).on("end",function(){d.push(null)})}n("../utils").inherits(o,a),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(a,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(a,o);if(typeof a=="number")throw new Error('The "data" argument must not be a number');return new Buffer(a,o)},allocBuffer:function(a){if(Buffer.alloc)return Buffer.alloc(a);var o=new Buffer(a);return o.fill(0),o},isBuffer:function(a){return Buffer.isBuffer(a)},isStream:function(a){return a&&typeof a.on=="function"&&typeof a.pause=="function"&&typeof a.resume=="function"}}},{}],15:[function(n,r,i){function a(E,C,k){var R,A=l.getTypeOf(C),D=l.extend(k||{},d);D.date=D.date||new Date,D.compression!==null&&(D.compression=D.compression.toUpperCase()),typeof D.unixPermissions=="string"&&(D.unixPermissions=parseInt(D.unixPermissions,8)),D.unixPermissions&&16384&D.unixPermissions&&(D.dir=!0),D.dosPermissions&&16&D.dosPermissions&&(D.dir=!0),D.dir&&(E=v(E)),D.createFolders&&(R=y(E))&&S.call(this,R,!0);var U=A==="string"&&D.binary===!1&&D.base64===!1;k&&k.binary!==void 0||(D.binary=!U),(C instanceof f&&C.uncompressedSize===0||D.dir||!C||C.length===0)&&(D.base64=!1,D.binary=!0,C="",D.compression="STORE",A="string");var F=null;F=C instanceof f||C instanceof c?C:x.isNode&&x.isStream(C)?new b(E,C):l.prepareContent(E,C,D.binary,D.optimizedBinaryString,D.base64);var H=new p(E,F,D);this.files[E]=H}var o=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),p=n("./zipObject"),m=n("./generate"),x=n("./nodejsUtils"),b=n("./nodejs/NodejsStreamInputAdapter"),y=function(E){E.slice(-1)==="/"&&(E=E.substring(0,E.length-1));var C=E.lastIndexOf("/");return 0<C?E.substring(0,C):""},v=function(E){return E.slice(-1)!=="/"&&(E+="/"),E},S=function(E,C){return C=C!==void 0?C:d.createFolders,E=v(E),this.files[E]||a.call(this,E,null,{dir:!0,createFolders:C}),this.files[E]};function M(E){return Object.prototype.toString.call(E)==="[object RegExp]"}var T={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(E){var C,k,R;for(C in this.files)R=this.files[C],(k=C.slice(this.root.length,C.length))&&C.slice(0,this.root.length)===this.root&&E(k,R)},filter:function(E){var C=[];return this.forEach(function(k,R){E(k,R)&&C.push(R)}),C},file:function(E,C,k){if(arguments.length!==1)return E=this.root+E,a.call(this,E,C,k),this;if(M(E)){var R=E;return this.filter(function(D,U){return!U.dir&&R.test(D)})}var A=this.files[this.root+E];return A&&!A.dir?A:null},folder:function(E){if(!E)return this;if(M(E))return this.filter(function(A,D){return D.dir&&E.test(A)});var C=this.root+E,k=S.call(this,C),R=this.clone();return R.root=k.name,R},remove:function(E){E=this.root+E;var C=this.files[E];if(C||(E.slice(-1)!=="/"&&(E+="/"),C=this.files[E]),C&&!C.dir)delete this.files[E];else for(var k=this.filter(function(A,D){return D.name.slice(0,E.length)===E}),R=0;R<k.length;R++)delete this.files[k[R].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(E){var C,k={};try{if((k=l.extend(E||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=k.type.toLowerCase(),k.compression=k.compression.toUpperCase(),k.type==="binarystring"&&(k.type="string"),!k.type)throw new Error("No output type specified.");l.checkSupport(k.type),k.platform!=="darwin"&&k.platform!=="freebsd"&&k.platform!=="linux"&&k.platform!=="sunos"||(k.platform="UNIX"),k.platform==="win32"&&(k.platform="DOS");var R=k.comment||this.comment||"";C=m.generateWorker(this,k,R)}catch(A){(C=new c("error")).error(A)}return new u(C,k.type||"string",k.mimeType)},generateAsync:function(E,C){return this.generateInternalStream(E).accumulate(C)},generateNodeStream:function(E,C){return(E=E||{}).type||(E.type="nodebuffer"),this.generateInternalStream(E).toNodejsStream(C)}};r.exports=T},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){var a=n("./DataReader");function o(l){a.call(this,l);for(var c=0;c<this.data.length;c++)l[c]=255&l[c]}n("../utils").inherits(o,a),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),p=this.length-4;0<=p;--p)if(this.data[p]===c&&this.data[p+1]===u&&this.data[p+2]===d&&this.data[p+3]===f)return p-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),p=this.readData(4);return c===p[0]&&u===p[1]&&d===p[2]&&f===p[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 a=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 a.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 a=n("./Uint8ArrayReader");function o(l){a.call(this,l)}n("../utils").inherits(o,a),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 a=n("./DataReader");function o(l){a.call(this,l)}n("../utils").inherits(o,a),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 a=n("./ArrayReader");function o(l){a.call(this,l)}n("../utils").inherits(o,a),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 a=n("../utils"),o=n("../support"),l=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(f){var p=a.getTypeOf(f);return a.checkSupport(p),p!=="string"||o.uint8array?p==="nodebuffer"?new u(f):o.uint8array?new d(a.transformTo("uint8array",f)):new l(a.transformTo("array",f)):new c(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){var a=n("./GenericWorker"),o=n("../utils");function l(c){a.call(this,"ConvertWorker to "+c),this.destType=c}o.inherits(l,a),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 a=n("./GenericWorker"),o=n("../crc32");function l(){a.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(l,a),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 a=n("../utils"),o=n("./GenericWorker");function l(c){o.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}a.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 a=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=a.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}a.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,a.delay(this._tickAndRepeat,[],this)),!0)},l.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(a.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 a(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}a.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=a},{}],29:[function(n,r,i){var a=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 p(x,b){return new d.Promise(function(y,v){var S=[],M=x._internalType,T=x._outputType,E=x._mimeType;x.on("data",function(C,k){S.push(C),b&&b(k)}).on("error",function(C){S=[],v(C)}).on("end",function(){try{var C=(function(k,R,A){switch(k){case"blob":return a.newBlob(a.transformTo("arraybuffer",R),A);case"base64":return c.encode(R);default:return a.transformTo(k,R)}})(T,(function(k,R){var A,D=0,U=null,F=0;for(A=0;A<R.length;A++)F+=R[A].length;switch(k){case"string":return R.join("");case"array":return Array.prototype.concat.apply([],R);case"uint8array":for(U=new Uint8Array(F),A=0;A<R.length;A++)U.set(R[A],D),D+=R[A].length;return U;case"nodebuffer":return Buffer.concat(R);default:throw new Error("concat : unsupported type '"+k+"'")}})(M,S),E);y(C)}catch(k){v(k)}S=[]}).resume()})}function m(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,a.checkSupport(v),this._worker=x.pipe(new o(v)),x.lock()}catch(S){this._worker=new l("error"),this._worker.error(S)}}m.prototype={accumulate:function(x){return p(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(){a.delay(b,arguments,y)}),this},resume:function(){return a.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(x){if(a.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},x)}},r.exports=m},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var a=new ArrayBuffer(0);try{i.blob=new Blob([a],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(a),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 a=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 p(){c.call(this,"utf-8 encode")}i.utf8encode=function(m){return o.nodebuffer?l.newBufferFrom(m,"utf-8"):(function(x){var b,y,v,S,M,T=x.length,E=0;for(S=0;S<T;S++)(64512&(y=x.charCodeAt(S)))==55296&&S+1<T&&(64512&(v=x.charCodeAt(S+1)))==56320&&(y=65536+(y-55296<<10)+(v-56320),S++),E+=y<128?1:y<2048?2:y<65536?3:4;for(b=o.uint8array?new Uint8Array(E):new Array(E),S=M=0;M<E;S++)(64512&(y=x.charCodeAt(S)))==55296&&S+1<T&&(64512&(v=x.charCodeAt(S+1)))==56320&&(y=65536+(y-55296<<10)+(v-56320),S++),y<128?b[M++]=y:(y<2048?b[M++]=192|y>>>6:(y<65536?b[M++]=224|y>>>12:(b[M++]=240|y>>>18,b[M++]=128|y>>>12&63),b[M++]=128|y>>>6&63),b[M++]=128|63&y);return b})(m)},i.utf8decode=function(m){return o.nodebuffer?a.transformTo("nodebuffer",m).toString("utf-8"):(function(x){var b,y,v,S,M=x.length,T=new Array(2*M);for(b=y=0;b<M;)if((v=x[b++])<128)T[y++]=v;else if(4<(S=u[v]))T[y++]=65533,b+=S-1;else{for(v&=S===2?31:S===3?15:7;1<S&&b<M;)v=v<<6|63&x[b++],S--;1<S?T[y++]=65533:v<65536?T[y++]=v:(v-=65536,T[y++]=55296|v>>10&1023,T[y++]=56320|1023&v)}return T.length!==y&&(T.subarray?T=T.subarray(0,y):T.length=y),a.applyFromCharCode(T)})(m=a.transformTo(o.uint8array?"uint8array":"array",m))},a.inherits(f,c),f.prototype.processChunk=function(m){var x=a.transformTo(o.uint8array?"uint8array":"array",m.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,M){var T;for((M=M||S.length)>S.length&&(M=S.length),T=M-1;0<=T&&(192&S[T])==128;)T--;return T<0||T===0?M:T+u[S[T]]>M?T:M})(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:m.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=f,a.inherits(p,c),p.prototype.processChunk=function(m){this.push({data:i.utf8encode(m.data),meta:m.meta})},i.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,i){var a=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=[],M=0,T=b.length;if(T<=v)return String.fromCharCode.apply(null,b);for(;M<T;)y==="array"||y==="nodebuffer"?S.push(String.fromCharCode.apply(null,b.slice(M,Math.min(M+v,T)))):S.push(String.fromCharCode.apply(null,b.subarray(M,Math.min(M+v,T)))),M+=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 a.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return a.nodebuffer&&String.fromCharCode.apply(null,l.allocBuffer(1)).length===1}catch{return!1}})()}};function p(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 m(b,y){for(var v=0;v<b.length;v++)y[v]=b[v];return y}i.applyFromCharCode=p;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:p,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 p(new Uint8Array(b))},array:function(b){return m(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:p,array:function(b){return m(b,new Array(b.length))},arraybuffer:function(b){return b.buffer},uint8array:u,nodebuffer:function(b){return l.newBufferFrom(b)}},x.nodebuffer={string:p,array:function(b){return m(b,new Array(b.length))},arraybuffer:function(b){return x.nodebuffer.uint8array(b).buffer},uint8array:function(b){return m(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 M=y[S];M==="."||M===""&&S!==0&&S!==y.length-1||(M===".."?v.pop():v.push(M))}return v.join("/")},i.getTypeOf=function(b){return typeof b=="string"?"string":Object.prototype.toString.call(b)==="[object Array]"?"array":a.nodebuffer&&l.isBuffer(b)?"nodebuffer":a.uint8array&&b instanceof Uint8Array?"uint8array":a.arraybuffer&&b instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(b){if(!a[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,M){return c.Promise.resolve(y).then(function(T){return a.blob&&(T instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(T))!==-1)&&typeof FileReader<"u"?new c.Promise(function(E,C){var k=new FileReader;k.onload=function(R){E(R.target.result)},k.onerror=function(R){C(R.target.error)},k.readAsArrayBuffer(T)}):T}).then(function(T){var E=i.getTypeOf(T);return E?(E==="arraybuffer"?T=i.transformTo("uint8array",T):E==="string"&&(M?T=o.decode(T):v&&S!==!0&&(T=(function(C){return d(C,a.uint8array?new Uint8Array(C.length):new Array(C.length))})(T))),T):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 a=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 p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(p)+", expected "+o.pretty(f)+")")}},isSignature:function(f,p){var m=this.reader.index;this.reader.setIndex(f);var x=this.reader.readString(4)===p;return this.reader.setIndex(m),x},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),p=u.uint8array?"uint8array":"array",m=o.transformTo(p,f);this.zipComment=this.loadOptions.decodeFileName(m)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,p,m,x=this.zip64EndOfCentralSize-44;0<x;)f=this.reader.readInt(2),p=this.reader.readInt(4),m=this.reader.readData(p),this.zip64ExtensibleData[f]={id:f,length:p,value:m}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,p;for(f=0;f<this.files.length;f++)p=this.files[f],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.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 p=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 m=this.centralDirOffset+this.centralDirSize;this.zip64&&(m+=20,m+=12+this.zip64EndOfCentralSize);var x=p-m;if(0<x)this.isSignature(p,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=a(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){var a=n("./reader/readerFor"),o=n("./utils"),l=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),d=n("./compressions"),f=n("./support");function p(m,x){this.options=m,this.loadOptions=x}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(m){var x,b;if(m.skip(22),this.fileNameLength=m.readInt(2),b=m.readInt(2),this.fileName=m.readData(this.fileNameLength),m.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,m.readData(this.compressedSize))},readCentralPart:function(m){this.versionMadeBy=m.readInt(2),m.skip(2),this.bitFlag=m.readInt(2),this.compressionMethod=m.readString(2),this.date=m.readDate(),this.crc32=m.readInt(4),this.compressedSize=m.readInt(4),this.uncompressedSize=m.readInt(4);var x=m.readInt(2);if(this.extraFieldsLength=m.readInt(2),this.fileCommentLength=m.readInt(2),this.diskNumberStart=m.readInt(2),this.internalFileAttributes=m.readInt(2),this.externalFileAttributes=m.readInt(4),this.localHeaderOffset=m.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");m.skip(x),this.readExtraFields(m),this.parseZIP64ExtraField(m),this.fileComment=m.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var m=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),m==0&&(this.dosPermissions=63&this.externalFileAttributes),m==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var m=a(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=m.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=m.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=m.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=m.readInt(4))}},readExtraFields:function(m){var x,b,y,v=m.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});m.index+4<v;)x=m.readInt(2),b=m.readInt(2),y=m.readData(b),this.extraFields[x]={id:x,length:b,value:y};m.setIndex(v)},handleUTF8:function(){var m=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var x=this.findExtraFieldUnicodePath();if(x!==null)this.fileNameStr=x;else{var b=o.transformTo(m,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(b)}var y=this.findExtraFieldUnicodeComment();if(y!==null)this.fileCommentStr=y;else{var v=o.transformTo(m,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(v)}}},findExtraFieldUnicodePath:function(){var m=this.extraFields[28789];if(m){var x=a(m.value);return x.readInt(1)!==1||c(this.fileName)!==x.readInt(4)?null:u.utf8decode(x.readData(m.length-5))}return null},findExtraFieldUnicodeComment:function(){var m=this.extraFields[25461];if(m){var x=a(m.value);return x.readInt(1)!==1||c(this.fileComment)!==x.readInt(4)?null:u.utf8decode(x.readData(m.length-5))}return null}},r.exports=p},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function a(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");a.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(M){(b=new d("error")).error(M)}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"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},m=0;m<f.length;m++)a.prototype[f[m]]=p;r.exports=a},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(a){var o,l,c=a.MutationObserver||a.WebKitMutationObserver;if(c){var u=0,d=new c(x),f=a.document.createTextNode("");d.observe(f,{characterData:!0}),o=function(){f.data=u=++u%2}}else if(a.setImmediate||a.MessageChannel===void 0)o="document"in a&&"onreadystatechange"in a.document.createElement("script")?function(){var b=a.document.createElement("script");b.onreadystatechange=function(){x(),b.onreadystatechange=null,b.parentNode.removeChild(b),b=null},a.document.documentElement.appendChild(b)}:function(){setTimeout(x,0)};else{var p=new a.MessageChannel;p.port1.onmessage=x,o=function(){p.port2.postMessage(0)}}var m=[];function x(){var b,y;l=!0;for(var v=m.length;v;){for(y=m,m=[],b=-1;++b<v;)y[b]();v=m.length}l=!1}r.exports=function(b){m.push(b)!==1||l||o()}}).call(this,typeof Aw<"u"?Aw:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var a=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 p(v,S,M){this.promise=v,typeof S=="function"&&(this.onFulfilled=S,this.callFulfilled=this.otherCallFulfilled),typeof M=="function"&&(this.onRejected=M,this.callRejected=this.otherCallRejected)}function m(v,S,M){a(function(){var T;try{T=S(M)}catch(E){return l.reject(v,E)}T===v?l.reject(v,new TypeError("Cannot resolve promise with itself")):l.resolve(v,T)})}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 M=!1;function T(k){M||(M=!0,l.reject(v,k))}function E(k){M||(M=!0,l.resolve(v,k))}var C=y(function(){S(E,T)});C.status==="error"&&T(C.value)}function y(v,S){var M={};try{M.value=v(S),M.status="success"}catch(T){M.status="error",M.value=T}return M}(r.exports=f).prototype.finally=function(v){if(typeof v!="function")return this;var S=this.constructor;return this.then(function(M){return S.resolve(v()).then(function(){return M})},function(M){return S.resolve(v()).then(function(){throw M})})},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 M=new this.constructor(o);return this.state!==d?m(M,this.state===u?v:S,this.outcome):this.queue.push(new p(M,v,S)),M},p.prototype.callFulfilled=function(v){l.resolve(this.promise,v)},p.prototype.otherCallFulfilled=function(v){m(this.promise,this.onFulfilled,v)},p.prototype.callRejected=function(v){l.reject(this.promise,v)},p.prototype.otherCallRejected=function(v){m(this.promise,this.onRejected,v)},l.resolve=function(v,S){var M=y(x,S);if(M.status==="error")return l.reject(v,M.value);var T=M.value;if(T)b(v,T);else{v.state=u,v.outcome=S;for(var E=-1,C=v.queue.length;++E<C;)v.queue[E].callFulfilled(S)}return v},l.reject=function(v,S){v.state=c,v.outcome=S;for(var M=-1,T=v.queue.length;++M<T;)v.queue[M].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 M=v.length,T=!1;if(!M)return this.resolve([]);for(var E=new Array(M),C=0,k=-1,R=new this(o);++k<M;)A(v[k],k);return R;function A(D,U){S.resolve(D).then(function(F){E[U]=F,++C!==M||T||(T=!0,l.resolve(R,E))},function(F){T||(T=!0,l.reject(R,F))})}},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 M=v.length,T=!1;if(!M)return this.resolve([]);for(var E=-1,C=new this(o);++E<M;)k=v[E],S.resolve(k).then(function(R){T||(T=!0,l.resolve(C,R))},function(R){T||(T=!0,l.reject(C,R))});var k;return C}},{immediate:36}],38:[function(n,r,i){var a={};(0,n("./lib/utils/common").assign)(a,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=a},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){var a=n("./zlib/deflate"),o=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,f=0,p=-1,m=0,x=8;function b(v){if(!(this instanceof b))return new b(v);this.options=o.assign({level:p,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:m,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 M=a.deflateInit2(this.strm,S.level,S.method,S.windowBits,S.memLevel,S.strategy);if(M!==f)throw new Error(c[M]);if(S.header&&a.deflateSetHeader(this.strm,S.header),S.dictionary){var T;if(T=typeof S.dictionary=="string"?l.string2buf(S.dictionary):d.call(S.dictionary)==="[object ArrayBuffer]"?new Uint8Array(S.dictionary):S.dictionary,(M=a.deflateSetDictionary(this.strm,T))!==f)throw new Error(c[M]);this._dict_set=!0}}function y(v,S){var M=new b(S);if(M.push(v,!0),M.err)throw M.msg||c[M.err];return M.result}b.prototype.push=function(v,S){var M,T,E=this.strm,C=this.options.chunkSize;if(this.ended)return!1;T=S===~~S?S:S===!0?4:0,typeof v=="string"?E.input=l.string2buf(v):d.call(v)==="[object ArrayBuffer]"?E.input=new Uint8Array(v):E.input=v,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new o.Buf8(C),E.next_out=0,E.avail_out=C),(M=a.deflate(E,T))!==1&&M!==f)return this.onEnd(M),!(this.ended=!0);E.avail_out!==0&&(E.avail_in!==0||T!==4&&T!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(o.shrinkBuf(E.output,E.next_out))):this.onData(o.shrinkBuf(E.output,E.next_out)))}while((0<E.avail_in||E.avail_out===0)&&M!==1);return T===4?(M=a.deflateEnd(this.strm),this.onEnd(M),this.ended=!0,M===f):T!==2||(this.onEnd(f),!(E.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 a=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"),p=Object.prototype.toString;function m(b){if(!(this instanceof m))return new m(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=a.inflateInit2(this.strm,y.windowBits);if(v!==c.Z_OK)throw new Error(u[v]);this.header=new f,a.inflateGetHeader(this.strm,this.header)}function x(b,y){var v=new m(y);if(v.push(b,!0),v.err)throw v.msg||u[v.err];return v.result}m.prototype.push=function(b,y){var v,S,M,T,E,C,k=this.strm,R=this.options.chunkSize,A=this.options.dictionary,D=!1;if(this.ended)return!1;S=y===~~y?y:y===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof b=="string"?k.input=l.binstring2buf(b):p.call(b)==="[object ArrayBuffer]"?k.input=new Uint8Array(b):k.input=b,k.next_in=0,k.avail_in=k.input.length;do{if(k.avail_out===0&&(k.output=new o.Buf8(R),k.next_out=0,k.avail_out=R),(v=a.inflate(k,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&A&&(C=typeof A=="string"?l.string2buf(A):p.call(A)==="[object ArrayBuffer]"?new Uint8Array(A):A,v=a.inflateSetDictionary(this.strm,C)),v===c.Z_BUF_ERROR&&D===!0&&(v=c.Z_OK,D=!1),v!==c.Z_STREAM_END&&v!==c.Z_OK)return this.onEnd(v),!(this.ended=!0);k.next_out&&(k.avail_out!==0&&v!==c.Z_STREAM_END&&(k.avail_in!==0||S!==c.Z_FINISH&&S!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(M=l.utf8border(k.output,k.next_out),T=k.next_out-M,E=l.buf2string(k.output,M),k.next_out=T,k.avail_out=R-T,T&&o.arraySet(k.output,k.output,M,T,0),this.onData(E)):this.onData(o.shrinkBuf(k.output,k.next_out)))),k.avail_in===0&&k.avail_out===0&&(D=!0)}while((0<k.avail_in||k.avail_out===0)&&v!==c.Z_STREAM_END);return v===c.Z_STREAM_END&&(S=c.Z_FINISH),S===c.Z_FINISH?(v=a.inflateEnd(this.strm),this.onEnd(v),this.ended=!0,v===c.Z_OK):S!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(k.avail_out=0))},m.prototype.onData=function(b){this.chunks.push(b)},m.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=m,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 a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(c[f]=d[f])}}return c},i.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var o={arraySet:function(c,u,d,f,p){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+f),p);else for(var m=0;m<f;m++)c[p+m]=u[d+m]},flattenChunks:function(c){var u,d,f,p,m,x;for(u=f=0,d=c.length;u<d;u++)f+=c[u].length;for(x=new Uint8Array(f),u=p=0,d=c.length;u<d;u++)m=c[u],x.set(m,p),p+=m.length;return x}},l={arraySet:function(c,u,d,f,p){for(var m=0;m<f;m++)c[p+m]=u[d+m]},flattenChunks:function(c){return[].concat.apply([],c)}};i.setTyped=function(c){c?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,o)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,l))},i.setTyped(a)},{}],42:[function(n,r,i){var a=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 a.Buf8(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(f,p){if(p<65537&&(f.subarray&&l||!f.subarray&&o))return String.fromCharCode.apply(null,a.shrinkBuf(f,p));for(var m="",x=0;x<p;x++)m+=String.fromCharCode(f[x]);return m}c[254]=c[254]=1,i.string2buf=function(f){var p,m,x,b,y,v=f.length,S=0;for(b=0;b<v;b++)(64512&(m=f.charCodeAt(b)))==55296&&b+1<v&&(64512&(x=f.charCodeAt(b+1)))==56320&&(m=65536+(m-55296<<10)+(x-56320),b++),S+=m<128?1:m<2048?2:m<65536?3:4;for(p=new a.Buf8(S),b=y=0;y<S;b++)(64512&(m=f.charCodeAt(b)))==55296&&b+1<v&&(64512&(x=f.charCodeAt(b+1)))==56320&&(m=65536+(m-55296<<10)+(x-56320),b++),m<128?p[y++]=m:(m<2048?p[y++]=192|m>>>6:(m<65536?p[y++]=224|m>>>12:(p[y++]=240|m>>>18,p[y++]=128|m>>>12&63),p[y++]=128|m>>>6&63),p[y++]=128|63&m);return p},i.buf2binstring=function(f){return d(f,f.length)},i.binstring2buf=function(f){for(var p=new a.Buf8(f.length),m=0,x=p.length;m<x;m++)p[m]=f.charCodeAt(m);return p},i.buf2string=function(f,p){var m,x,b,y,v=p||f.length,S=new Array(2*v);for(m=x=0;m<v;)if((b=f[m++])<128)S[x++]=b;else if(4<(y=c[b]))S[x++]=65533,m+=y-1;else{for(b&=y===2?31:y===3?15:7;1<y&&m<v;)b=b<<6|63&f[m++],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,p){var m;for((p=p||f.length)>f.length&&(p=f.length),m=p-1;0<=m&&(192&f[m])==128;)m--;return m<0||m===0?p:m+c[f[m]]>p?m:p}},{"./common":41}],43:[function(n,r,i){r.exports=function(a,o,l,c){for(var u=65535&a|0,d=a>>>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 a=(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=a,f=u+c;o^=-1;for(var p=u;p<f;p++)o=o>>>8^d[255&(o^l[p])];return-1^o}},{}],46:[function(n,r,i){var a,o=n("../utils/common"),l=n("./trees"),c=n("./adler32"),u=n("./crc32"),d=n("./messages"),f=0,p=4,m=0,x=-2,b=-1,y=4,v=2,S=8,M=9,T=286,E=30,C=19,k=2*T+1,R=15,A=3,D=258,U=D+A+1,F=42,H=113,j=1,$=2,K=3,V=4;function Q(G,Y){return G.msg=d[Y],Y}function Z(G){return(G<<1)-(4<G?9:0)}function ae(G){for(var Y=G.length;0<=--Y;)G[Y]=0}function B(G){var Y=G.state,ce=Y.pending;ce>G.avail_out&&(ce=G.avail_out),ce!==0&&(o.arraySet(G.output,Y.pending_buf,Y.pending_out,ce,G.next_out),G.next_out+=ce,Y.pending_out+=ce,G.total_out+=ce,G.avail_out-=ce,Y.pending-=ce,Y.pending===0&&(Y.pending_out=0))}function X(G,Y){l._tr_flush_block(G,0<=G.block_start?G.block_start:-1,G.strstart-G.block_start,Y),G.block_start=G.strstart,B(G.strm)}function ne(G,Y){G.pending_buf[G.pending++]=Y}function se(G,Y){G.pending_buf[G.pending++]=Y>>>8&255,G.pending_buf[G.pending++]=255&Y}function be(G,Y){var ce,q,te=G.max_chain_length,I=G.strstart,fe=G.prev_length,me=G.nice_match,ke=G.strstart>G.w_size-U?G.strstart-(G.w_size-U):0,z=G.window,O=G.w_mask,ee=G.prev,le=G.strstart+D,_e=z[I+fe-1],we=z[I+fe];G.prev_length>=G.good_match&&(te>>=2),me>G.lookahead&&(me=G.lookahead);do if(z[(ce=Y)+fe]===we&&z[ce+fe-1]===_e&&z[ce]===z[I]&&z[++ce]===z[I+1]){I+=2,ce++;do;while(z[++I]===z[++ce]&&z[++I]===z[++ce]&&z[++I]===z[++ce]&&z[++I]===z[++ce]&&z[++I]===z[++ce]&&z[++I]===z[++ce]&&z[++I]===z[++ce]&&z[++I]===z[++ce]&&I<le);if(q=D-(le-I),I=le-D,fe<q){if(G.match_start=Y,me<=(fe=q))break;_e=z[I+fe-1],we=z[I+fe]}}while((Y=ee[Y&O])>ke&&--te!=0);return fe<=G.lookahead?fe:G.lookahead}function xe(G){var Y,ce,q,te,I,fe,me,ke,z,O,ee=G.w_size;do{if(te=G.window_size-G.lookahead-G.strstart,G.strstart>=ee+(ee-U)){for(o.arraySet(G.window,G.window,ee,ee,0),G.match_start-=ee,G.strstart-=ee,G.block_start-=ee,Y=ce=G.hash_size;q=G.head[--Y],G.head[Y]=ee<=q?q-ee:0,--ce;);for(Y=ce=ee;q=G.prev[--Y],G.prev[Y]=ee<=q?q-ee:0,--ce;);te+=ee}if(G.strm.avail_in===0)break;if(fe=G.strm,me=G.window,ke=G.strstart+G.lookahead,z=te,O=void 0,O=fe.avail_in,z<O&&(O=z),ce=O===0?0:(fe.avail_in-=O,o.arraySet(me,fe.input,fe.next_in,O,ke),fe.state.wrap===1?fe.adler=c(fe.adler,me,O,ke):fe.state.wrap===2&&(fe.adler=u(fe.adler,me,O,ke)),fe.next_in+=O,fe.total_in+=O,O),G.lookahead+=ce,G.lookahead+G.insert>=A)for(I=G.strstart-G.insert,G.ins_h=G.window[I],G.ins_h=(G.ins_h<<G.hash_shift^G.window[I+1])&G.hash_mask;G.insert&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[I+A-1])&G.hash_mask,G.prev[I&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=I,I++,G.insert--,!(G.lookahead+G.insert<A)););}while(G.lookahead<U&&G.strm.avail_in!==0)}function de(G,Y){for(var ce,q;;){if(G.lookahead<U){if(xe(G),G.lookahead<U&&Y===f)return j;if(G.lookahead===0)break}if(ce=0,G.lookahead>=A&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+A-1])&G.hash_mask,ce=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart),ce!==0&&G.strstart-ce<=G.w_size-U&&(G.match_length=be(G,ce)),G.match_length>=A)if(q=l._tr_tally(G,G.strstart-G.match_start,G.match_length-A),G.lookahead-=G.match_length,G.match_length<=G.max_lazy_match&&G.lookahead>=A){for(G.match_length--;G.strstart++,G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+A-1])&G.hash_mask,ce=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart,--G.match_length!=0;);G.strstart++}else G.strstart+=G.match_length,G.match_length=0,G.ins_h=G.window[G.strstart],G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+1])&G.hash_mask;else q=l._tr_tally(G,0,G.window[G.strstart]),G.lookahead--,G.strstart++;if(q&&(X(G,!1),G.strm.avail_out===0))return j}return G.insert=G.strstart<A-1?G.strstart:A-1,Y===p?(X(G,!0),G.strm.avail_out===0?K:V):G.last_lit&&(X(G,!1),G.strm.avail_out===0)?j:$}function Pe(G,Y){for(var ce,q,te;;){if(G.lookahead<U){if(xe(G),G.lookahead<U&&Y===f)return j;if(G.lookahead===0)break}if(ce=0,G.lookahead>=A&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+A-1])&G.hash_mask,ce=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart),G.prev_length=G.match_length,G.prev_match=G.match_start,G.match_length=A-1,ce!==0&&G.prev_length<G.max_lazy_match&&G.strstart-ce<=G.w_size-U&&(G.match_length=be(G,ce),G.match_length<=5&&(G.strategy===1||G.match_length===A&&4096<G.strstart-G.match_start)&&(G.match_length=A-1)),G.prev_length>=A&&G.match_length<=G.prev_length){for(te=G.strstart+G.lookahead-A,q=l._tr_tally(G,G.strstart-1-G.prev_match,G.prev_length-A),G.lookahead-=G.prev_length-1,G.prev_length-=2;++G.strstart<=te&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+A-1])&G.hash_mask,ce=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart),--G.prev_length!=0;);if(G.match_available=0,G.match_length=A-1,G.strstart++,q&&(X(G,!1),G.strm.avail_out===0))return j}else if(G.match_available){if((q=l._tr_tally(G,0,G.window[G.strstart-1]))&&X(G,!1),G.strstart++,G.lookahead--,G.strm.avail_out===0)return j}else G.match_available=1,G.strstart++,G.lookahead--}return G.match_available&&(q=l._tr_tally(G,0,G.window[G.strstart-1]),G.match_available=0),G.insert=G.strstart<A-1?G.strstart:A-1,Y===p?(X(G,!0),G.strm.avail_out===0?K:V):G.last_lit&&(X(G,!1),G.strm.avail_out===0)?j:$}function ie(G,Y,ce,q,te){this.good_length=G,this.max_lazy=Y,this.nice_length=ce,this.max_chain=q,this.func=te}function Me(){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*k),this.dyn_dtree=new o.Buf16(2*(2*E+1)),this.bl_tree=new o.Buf16(2*(2*C+1)),ae(this.dyn_ltree),ae(this.dyn_dtree),ae(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(R+1),this.heap=new o.Buf16(2*T+1),ae(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*T+1),ae(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Oe(G){var Y;return G&&G.state?(G.total_in=G.total_out=0,G.data_type=v,(Y=G.state).pending=0,Y.pending_out=0,Y.wrap<0&&(Y.wrap=-Y.wrap),Y.status=Y.wrap?F:H,G.adler=Y.wrap===2?0:1,Y.last_flush=f,l._tr_init(Y),m):Q(G,x)}function ge(G){var Y=Oe(G);return Y===m&&(function(ce){ce.window_size=2*ce.w_size,ae(ce.head),ce.max_lazy_match=a[ce.level].max_lazy,ce.good_match=a[ce.level].good_length,ce.nice_match=a[ce.level].nice_length,ce.max_chain_length=a[ce.level].max_chain,ce.strstart=0,ce.block_start=0,ce.lookahead=0,ce.insert=0,ce.match_length=ce.prev_length=A-1,ce.match_available=0,ce.ins_h=0})(G.state),Y}function Ke(G,Y,ce,q,te,I){if(!G)return x;var fe=1;if(Y===b&&(Y=6),q<0?(fe=0,q=-q):15<q&&(fe=2,q-=16),te<1||M<te||ce!==S||q<8||15<q||Y<0||9<Y||I<0||y<I)return Q(G,x);q===8&&(q=9);var me=new Me;return(G.state=me).strm=G,me.wrap=fe,me.gzhead=null,me.w_bits=q,me.w_size=1<<me.w_bits,me.w_mask=me.w_size-1,me.hash_bits=te+7,me.hash_size=1<<me.hash_bits,me.hash_mask=me.hash_size-1,me.hash_shift=~~((me.hash_bits+A-1)/A),me.window=new o.Buf8(2*me.w_size),me.head=new o.Buf16(me.hash_size),me.prev=new o.Buf16(me.w_size),me.lit_bufsize=1<<te+6,me.pending_buf_size=4*me.lit_bufsize,me.pending_buf=new o.Buf8(me.pending_buf_size),me.d_buf=1*me.lit_bufsize,me.l_buf=3*me.lit_bufsize,me.level=Y,me.strategy=I,me.method=ce,ge(G)}a=[new ie(0,0,0,0,function(G,Y){var ce=65535;for(ce>G.pending_buf_size-5&&(ce=G.pending_buf_size-5);;){if(G.lookahead<=1){if(xe(G),G.lookahead===0&&Y===f)return j;if(G.lookahead===0)break}G.strstart+=G.lookahead,G.lookahead=0;var q=G.block_start+ce;if((G.strstart===0||G.strstart>=q)&&(G.lookahead=G.strstart-q,G.strstart=q,X(G,!1),G.strm.avail_out===0)||G.strstart-G.block_start>=G.w_size-U&&(X(G,!1),G.strm.avail_out===0))return j}return G.insert=0,Y===p?(X(G,!0),G.strm.avail_out===0?K:V):(G.strstart>G.block_start&&(X(G,!1),G.strm.avail_out),j)}),new ie(4,4,8,4,de),new ie(4,5,16,8,de),new ie(4,6,32,32,de),new ie(4,4,16,16,Pe),new ie(8,16,32,32,Pe),new ie(8,16,128,128,Pe),new ie(8,32,128,256,Pe),new ie(32,128,258,1024,Pe),new ie(32,258,258,4096,Pe)],i.deflateInit=function(G,Y){return Ke(G,Y,S,15,8,0)},i.deflateInit2=Ke,i.deflateReset=ge,i.deflateResetKeep=Oe,i.deflateSetHeader=function(G,Y){return G&&G.state?G.state.wrap!==2?x:(G.state.gzhead=Y,m):x},i.deflate=function(G,Y){var ce,q,te,I;if(!G||!G.state||5<Y||Y<0)return G?Q(G,x):x;if(q=G.state,!G.output||!G.input&&G.avail_in!==0||q.status===666&&Y!==p)return Q(G,G.avail_out===0?-5:x);if(q.strm=G,ce=q.last_flush,q.last_flush=Y,q.status===F)if(q.wrap===2)G.adler=0,ne(q,31),ne(q,139),ne(q,8),q.gzhead?(ne(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)),ne(q,255&q.gzhead.time),ne(q,q.gzhead.time>>8&255),ne(q,q.gzhead.time>>16&255),ne(q,q.gzhead.time>>24&255),ne(q,q.level===9?2:2<=q.strategy||q.level<2?4:0),ne(q,255&q.gzhead.os),q.gzhead.extra&&q.gzhead.extra.length&&(ne(q,255&q.gzhead.extra.length),ne(q,q.gzhead.extra.length>>8&255)),q.gzhead.hcrc&&(G.adler=u(G.adler,q.pending_buf,q.pending,0)),q.gzindex=0,q.status=69):(ne(q,0),ne(q,0),ne(q,0),ne(q,0),ne(q,0),ne(q,q.level===9?2:2<=q.strategy||q.level<2?4:0),ne(q,3),q.status=H);else{var fe=S+(q.w_bits-8<<4)<<8;fe|=(2<=q.strategy||q.level<2?0:q.level<6?1:q.level===6?2:3)<<6,q.strstart!==0&&(fe|=32),fe+=31-fe%31,q.status=H,se(q,fe),q.strstart!==0&&(se(q,G.adler>>>16),se(q,65535&G.adler)),G.adler=1}if(q.status===69)if(q.gzhead.extra){for(te=q.pending;q.gzindex<(65535&q.gzhead.extra.length)&&(q.pending!==q.pending_buf_size||(q.gzhead.hcrc&&q.pending>te&&(G.adler=u(G.adler,q.pending_buf,q.pending-te,te)),B(G),te=q.pending,q.pending!==q.pending_buf_size));)ne(q,255&q.gzhead.extra[q.gzindex]),q.gzindex++;q.gzhead.hcrc&&q.pending>te&&(G.adler=u(G.adler,q.pending_buf,q.pending-te,te)),q.gzindex===q.gzhead.extra.length&&(q.gzindex=0,q.status=73)}else q.status=73;if(q.status===73)if(q.gzhead.name){te=q.pending;do{if(q.pending===q.pending_buf_size&&(q.gzhead.hcrc&&q.pending>te&&(G.adler=u(G.adler,q.pending_buf,q.pending-te,te)),B(G),te=q.pending,q.pending===q.pending_buf_size)){I=1;break}I=q.gzindex<q.gzhead.name.length?255&q.gzhead.name.charCodeAt(q.gzindex++):0,ne(q,I)}while(I!==0);q.gzhead.hcrc&&q.pending>te&&(G.adler=u(G.adler,q.pending_buf,q.pending-te,te)),I===0&&(q.gzindex=0,q.status=91)}else q.status=91;if(q.status===91)if(q.gzhead.comment){te=q.pending;do{if(q.pending===q.pending_buf_size&&(q.gzhead.hcrc&&q.pending>te&&(G.adler=u(G.adler,q.pending_buf,q.pending-te,te)),B(G),te=q.pending,q.pending===q.pending_buf_size)){I=1;break}I=q.gzindex<q.gzhead.comment.length?255&q.gzhead.comment.charCodeAt(q.gzindex++):0,ne(q,I)}while(I!==0);q.gzhead.hcrc&&q.pending>te&&(G.adler=u(G.adler,q.pending_buf,q.pending-te,te)),I===0&&(q.status=103)}else q.status=103;if(q.status===103&&(q.gzhead.hcrc?(q.pending+2>q.pending_buf_size&&B(G),q.pending+2<=q.pending_buf_size&&(ne(q,255&G.adler),ne(q,G.adler>>8&255),G.adler=0,q.status=H)):q.status=H),q.pending!==0){if(B(G),G.avail_out===0)return q.last_flush=-1,m}else if(G.avail_in===0&&Z(Y)<=Z(ce)&&Y!==p)return Q(G,-5);if(q.status===666&&G.avail_in!==0)return Q(G,-5);if(G.avail_in!==0||q.lookahead!==0||Y!==f&&q.status!==666){var me=q.strategy===2?(function(ke,z){for(var O;;){if(ke.lookahead===0&&(xe(ke),ke.lookahead===0)){if(z===f)return j;break}if(ke.match_length=0,O=l._tr_tally(ke,0,ke.window[ke.strstart]),ke.lookahead--,ke.strstart++,O&&(X(ke,!1),ke.strm.avail_out===0))return j}return ke.insert=0,z===p?(X(ke,!0),ke.strm.avail_out===0?K:V):ke.last_lit&&(X(ke,!1),ke.strm.avail_out===0)?j:$})(q,Y):q.strategy===3?(function(ke,z){for(var O,ee,le,_e,we=ke.window;;){if(ke.lookahead<=D){if(xe(ke),ke.lookahead<=D&&z===f)return j;if(ke.lookahead===0)break}if(ke.match_length=0,ke.lookahead>=A&&0<ke.strstart&&(ee=we[le=ke.strstart-1])===we[++le]&&ee===we[++le]&&ee===we[++le]){_e=ke.strstart+D;do;while(ee===we[++le]&&ee===we[++le]&&ee===we[++le]&&ee===we[++le]&&ee===we[++le]&&ee===we[++le]&&ee===we[++le]&&ee===we[++le]&&le<_e);ke.match_length=D-(_e-le),ke.match_length>ke.lookahead&&(ke.match_length=ke.lookahead)}if(ke.match_length>=A?(O=l._tr_tally(ke,1,ke.match_length-A),ke.lookahead-=ke.match_length,ke.strstart+=ke.match_length,ke.match_length=0):(O=l._tr_tally(ke,0,ke.window[ke.strstart]),ke.lookahead--,ke.strstart++),O&&(X(ke,!1),ke.strm.avail_out===0))return j}return ke.insert=0,z===p?(X(ke,!0),ke.strm.avail_out===0?K:V):ke.last_lit&&(X(ke,!1),ke.strm.avail_out===0)?j:$})(q,Y):a[q.level].func(q,Y);if(me!==K&&me!==V||(q.status=666),me===j||me===K)return G.avail_out===0&&(q.last_flush=-1),m;if(me===$&&(Y===1?l._tr_align(q):Y!==5&&(l._tr_stored_block(q,0,0,!1),Y===3&&(ae(q.head),q.lookahead===0&&(q.strstart=0,q.block_start=0,q.insert=0))),B(G),G.avail_out===0))return q.last_flush=-1,m}return Y!==p?m:q.wrap<=0?1:(q.wrap===2?(ne(q,255&G.adler),ne(q,G.adler>>8&255),ne(q,G.adler>>16&255),ne(q,G.adler>>24&255),ne(q,255&G.total_in),ne(q,G.total_in>>8&255),ne(q,G.total_in>>16&255),ne(q,G.total_in>>24&255)):(se(q,G.adler>>>16),se(q,65535&G.adler)),B(G),0<q.wrap&&(q.wrap=-q.wrap),q.pending!==0?m:1)},i.deflateEnd=function(G){var Y;return G&&G.state?(Y=G.state.status)!==F&&Y!==69&&Y!==73&&Y!==91&&Y!==103&&Y!==H&&Y!==666?Q(G,x):(G.state=null,Y===H?Q(G,-3):m):x},i.deflateSetDictionary=function(G,Y){var ce,q,te,I,fe,me,ke,z,O=Y.length;if(!G||!G.state||(I=(ce=G.state).wrap)===2||I===1&&ce.status!==F||ce.lookahead)return x;for(I===1&&(G.adler=c(G.adler,Y,O,0)),ce.wrap=0,O>=ce.w_size&&(I===0&&(ae(ce.head),ce.strstart=0,ce.block_start=0,ce.insert=0),z=new o.Buf8(ce.w_size),o.arraySet(z,Y,O-ce.w_size,ce.w_size,0),Y=z,O=ce.w_size),fe=G.avail_in,me=G.next_in,ke=G.input,G.avail_in=O,G.next_in=0,G.input=Y,xe(ce);ce.lookahead>=A;){for(q=ce.strstart,te=ce.lookahead-(A-1);ce.ins_h=(ce.ins_h<<ce.hash_shift^ce.window[q+A-1])&ce.hash_mask,ce.prev[q&ce.w_mask]=ce.head[ce.ins_h],ce.head[ce.ins_h]=q,q++,--te;);ce.strstart=q,ce.lookahead=A-1,xe(ce)}return ce.strstart+=ce.lookahead,ce.block_start=ce.strstart,ce.insert=ce.lookahead,ce.lookahead=0,ce.match_length=ce.prev_length=A-1,ce.match_available=0,G.next_in=me,G.input=ke,G.avail_in=fe,ce.wrap=I,m},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){r.exports=function(a,o){var l,c,u,d,f,p,m,x,b,y,v,S,M,T,E,C,k,R,A,D,U,F,H,j,$;l=a.state,c=a.next_in,j=a.input,u=c+(a.avail_in-5),d=a.next_out,$=a.output,f=d-(o-a.avail_out),p=d+(a.avail_out-257),m=l.dmax,x=l.wsize,b=l.whave,y=l.wnext,v=l.window,S=l.hold,M=l.bits,T=l.lencode,E=l.distcode,C=(1<<l.lenbits)-1,k=(1<<l.distbits)-1;e:do{M<15&&(S+=j[c++]<<M,M+=8,S+=j[c++]<<M,M+=8),R=T[S&C];t:for(;;){if(S>>>=A=R>>>24,M-=A,(A=R>>>16&255)===0)$[d++]=65535&R;else{if(!(16&A)){if((64&A)==0){R=T[(65535&R)+(S&(1<<A)-1)];continue t}if(32&A){l.mode=12;break e}a.msg="invalid literal/length code",l.mode=30;break e}D=65535&R,(A&=15)&&(M<A&&(S+=j[c++]<<M,M+=8),D+=S&(1<<A)-1,S>>>=A,M-=A),M<15&&(S+=j[c++]<<M,M+=8,S+=j[c++]<<M,M+=8),R=E[S&k];n:for(;;){if(S>>>=A=R>>>24,M-=A,!(16&(A=R>>>16&255))){if((64&A)==0){R=E[(65535&R)+(S&(1<<A)-1)];continue n}a.msg="invalid distance code",l.mode=30;break e}if(U=65535&R,M<(A&=15)&&(S+=j[c++]<<M,(M+=8)<A&&(S+=j[c++]<<M,M+=8)),m<(U+=S&(1<<A)-1)){a.msg="invalid distance too far back",l.mode=30;break e}if(S>>>=A,M-=A,(A=d-f)<U){if(b<(A=U-A)&&l.sane){a.msg="invalid distance too far back",l.mode=30;break e}if(H=v,(F=0)===y){if(F+=x-A,A<D){for(D-=A;$[d++]=v[F++],--A;);F=d-U,H=$}}else if(y<A){if(F+=x+y-A,(A-=y)<D){for(D-=A;$[d++]=v[F++],--A;);if(F=0,y<D){for(D-=A=y;$[d++]=v[F++],--A;);F=d-U,H=$}}}else if(F+=y-A,A<D){for(D-=A;$[d++]=v[F++],--A;);F=d-U,H=$}for(;2<D;)$[d++]=H[F++],$[d++]=H[F++],$[d++]=H[F++],D-=3;D&&($[d++]=H[F++],1<D&&($[d++]=H[F++]))}else{for(F=d-U;$[d++]=$[F++],$[d++]=$[F++],$[d++]=$[F++],2<(D-=3););D&&($[d++]=$[F++],1<D&&($[d++]=$[F++]))}break}}break}}while(c<u&&d<p);c-=D=M>>3,S&=(1<<(M-=D<<3))-1,a.next_in=c,a.next_out=d,a.avail_in=c<u?u-c+5:5-(c-u),a.avail_out=d<p?p-d+257:257-(d-p),l.hold=S,l.bits=M}},{}],49:[function(n,r,i){var a=n("../utils/common"),o=n("./adler32"),l=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),d=1,f=2,p=0,m=-2,x=1,b=852,y=592;function v(F){return(F>>>24&255)+(F>>>8&65280)+((65280&F)<<8)+((255&F)<<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 a.Buf16(320),this.work=new a.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function M(F){var H;return F&&F.state?(H=F.state,F.total_in=F.total_out=H.total=0,F.msg="",H.wrap&&(F.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 a.Buf32(b),H.distcode=H.distdyn=new a.Buf32(y),H.sane=1,H.back=-1,p):m}function T(F){var H;return F&&F.state?((H=F.state).wsize=0,H.whave=0,H.wnext=0,M(F)):m}function E(F,H){var j,$;return F&&F.state?($=F.state,H<0?(j=0,H=-H):(j=1+(H>>4),H<48&&(H&=15)),H&&(H<8||15<H)?m:($.window!==null&&$.wbits!==H&&($.window=null),$.wrap=j,$.wbits=H,T(F))):m}function C(F,H){var j,$;return F?($=new S,(F.state=$).window=null,(j=E(F,H))!==p&&(F.state=null),j):m}var k,R,A=!0;function D(F){if(A){var H;for(k=new a.Buf32(512),R=new a.Buf32(32),H=0;H<144;)F.lens[H++]=8;for(;H<256;)F.lens[H++]=9;for(;H<280;)F.lens[H++]=7;for(;H<288;)F.lens[H++]=8;for(u(d,F.lens,0,288,k,0,F.work,{bits:9}),H=0;H<32;)F.lens[H++]=5;u(f,F.lens,0,32,R,0,F.work,{bits:5}),A=!1}F.lencode=k,F.lenbits=9,F.distcode=R,F.distbits=5}function U(F,H,j,$){var K,V=F.state;return V.window===null&&(V.wsize=1<<V.wbits,V.wnext=0,V.whave=0,V.window=new a.Buf8(V.wsize)),$>=V.wsize?(a.arraySet(V.window,H,j-V.wsize,V.wsize,0),V.wnext=0,V.whave=V.wsize):($<(K=V.wsize-V.wnext)&&(K=$),a.arraySet(V.window,H,j-$,K,V.wnext),($-=K)?(a.arraySet(V.window,H,j-$,$,0),V.wnext=$,V.whave=V.wsize):(V.wnext+=K,V.wnext===V.wsize&&(V.wnext=0),V.whave<V.wsize&&(V.whave+=K))),0}i.inflateReset=T,i.inflateReset2=E,i.inflateResetKeep=M,i.inflateInit=function(F){return C(F,15)},i.inflateInit2=C,i.inflate=function(F,H){var j,$,K,V,Q,Z,ae,B,X,ne,se,be,xe,de,Pe,ie,Me,Oe,ge,Ke,G,Y,ce,q,te=0,I=new a.Buf8(4),fe=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!F||!F.state||!F.output||!F.input&&F.avail_in!==0)return m;(j=F.state).mode===12&&(j.mode=13),Q=F.next_out,K=F.output,ae=F.avail_out,V=F.next_in,$=F.input,Z=F.avail_in,B=j.hold,X=j.bits,ne=Z,se=ae,Y=p;e:for(;;)switch(j.mode){case x:if(j.wrap===0){j.mode=13;break}for(;X<16;){if(Z===0)break e;Z--,B+=$[V++]<<X,X+=8}if(2&j.wrap&&B===35615){I[j.check=0]=255&B,I[1]=B>>>8&255,j.check=l(j.check,I,2,0),X=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){F.msg="incorrect header check",j.mode=30;break}if((15&B)!=8){F.msg="unknown compression method",j.mode=30;break}if(X-=4,G=8+(15&(B>>>=4)),j.wbits===0)j.wbits=G;else if(G>j.wbits){F.msg="invalid window size",j.mode=30;break}j.dmax=1<<G,F.adler=j.check=1,j.mode=512&B?10:12,X=B=0;break;case 2:for(;X<16;){if(Z===0)break e;Z--,B+=$[V++]<<X,X+=8}if(j.flags=B,(255&j.flags)!=8){F.msg="unknown compression method",j.mode=30;break}if(57344&j.flags){F.msg="unknown header flags set",j.mode=30;break}j.head&&(j.head.text=B>>8&1),512&j.flags&&(I[0]=255&B,I[1]=B>>>8&255,j.check=l(j.check,I,2,0)),X=B=0,j.mode=3;case 3:for(;X<32;){if(Z===0)break e;Z--,B+=$[V++]<<X,X+=8}j.head&&(j.head.time=B),512&j.flags&&(I[0]=255&B,I[1]=B>>>8&255,I[2]=B>>>16&255,I[3]=B>>>24&255,j.check=l(j.check,I,4,0)),X=B=0,j.mode=4;case 4:for(;X<16;){if(Z===0)break e;Z--,B+=$[V++]<<X,X+=8}j.head&&(j.head.xflags=255&B,j.head.os=B>>8),512&j.flags&&(I[0]=255&B,I[1]=B>>>8&255,j.check=l(j.check,I,2,0)),X=B=0,j.mode=5;case 5:if(1024&j.flags){for(;X<16;){if(Z===0)break e;Z--,B+=$[V++]<<X,X+=8}j.length=B,j.head&&(j.head.extra_len=B),512&j.flags&&(I[0]=255&B,I[1]=B>>>8&255,j.check=l(j.check,I,2,0)),X=B=0}else j.head&&(j.head.extra=null);j.mode=6;case 6:if(1024&j.flags&&(Z<(be=j.length)&&(be=Z),be&&(j.head&&(G=j.head.extra_len-j.length,j.head.extra||(j.head.extra=new Array(j.head.extra_len)),a.arraySet(j.head.extra,$,V,be,G)),512&j.flags&&(j.check=l(j.check,$,be,V)),Z-=be,V+=be,j.length-=be),j.length))break e;j.length=0,j.mode=7;case 7:if(2048&j.flags){if(Z===0)break e;for(be=0;G=$[V+be++],j.head&&G&&j.length<65536&&(j.head.name+=String.fromCharCode(G)),G&&be<Z;);if(512&j.flags&&(j.check=l(j.check,$,be,V)),Z-=be,V+=be,G)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(be=0;G=$[V+be++],j.head&&G&&j.length<65536&&(j.head.comment+=String.fromCharCode(G)),G&&be<Z;);if(512&j.flags&&(j.check=l(j.check,$,be,V)),Z-=be,V+=be,G)break e}else j.head&&(j.head.comment=null);j.mode=9;case 9:if(512&j.flags){for(;X<16;){if(Z===0)break e;Z--,B+=$[V++]<<X,X+=8}if(B!==(65535&j.check)){F.msg="header crc mismatch",j.mode=30;break}X=B=0}j.head&&(j.head.hcrc=j.flags>>9&1,j.head.done=!0),F.adler=j.check=0,j.mode=12;break;case 10:for(;X<32;){if(Z===0)break e;Z--,B+=$[V++]<<X,X+=8}F.adler=j.check=v(B),X=B=0,j.mode=11;case 11:if(j.havedict===0)return F.next_out=Q,F.avail_out=ae,F.next_in=V,F.avail_in=Z,j.hold=B,j.bits=X,2;F.adler=j.check=1,j.mode=12;case 12:if(H===5||H===6)break e;case 13:if(j.last){B>>>=7&X,X-=7&X,j.mode=27;break}for(;X<3;){if(Z===0)break e;Z--,B+=$[V++]<<X,X+=8}switch(j.last=1&B,X-=1,3&(B>>>=1)){case 0:j.mode=14;break;case 1:if(D(j),j.mode=20,H!==6)break;B>>>=2,X-=2;break e;case 2:j.mode=17;break;case 3:F.msg="invalid block type",j.mode=30}B>>>=2,X-=2;break;case 14:for(B>>>=7&X,X-=7&X;X<32;){if(Z===0)break e;Z--,B+=$[V++]<<X,X+=8}if((65535&B)!=(B>>>16^65535)){F.msg="invalid stored block lengths",j.mode=30;break}if(j.length=65535&B,X=B=0,j.mode=15,H===6)break e;case 15:j.mode=16;case 16:if(be=j.length){if(Z<be&&(be=Z),ae<be&&(be=ae),be===0)break e;a.arraySet(K,$,V,be,Q),Z-=be,V+=be,ae-=be,Q+=be,j.length-=be;break}j.mode=12;break;case 17:for(;X<14;){if(Z===0)break e;Z--,B+=$[V++]<<X,X+=8}if(j.nlen=257+(31&B),B>>>=5,X-=5,j.ndist=1+(31&B),B>>>=5,X-=5,j.ncode=4+(15&B),B>>>=4,X-=4,286<j.nlen||30<j.ndist){F.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(;X<3;){if(Z===0)break e;Z--,B+=$[V++]<<X,X+=8}j.lens[fe[j.have++]]=7&B,B>>>=3,X-=3}for(;j.have<19;)j.lens[fe[j.have++]]=0;if(j.lencode=j.lendyn,j.lenbits=7,ce={bits:j.lenbits},Y=u(0,j.lens,0,19,j.lencode,0,j.work,ce),j.lenbits=ce.bits,Y){F.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(;ie=(te=j.lencode[B&(1<<j.lenbits)-1])>>>16&255,Me=65535&te,!((Pe=te>>>24)<=X);){if(Z===0)break e;Z--,B+=$[V++]<<X,X+=8}if(Me<16)B>>>=Pe,X-=Pe,j.lens[j.have++]=Me;else{if(Me===16){for(q=Pe+2;X<q;){if(Z===0)break e;Z--,B+=$[V++]<<X,X+=8}if(B>>>=Pe,X-=Pe,j.have===0){F.msg="invalid bit length repeat",j.mode=30;break}G=j.lens[j.have-1],be=3+(3&B),B>>>=2,X-=2}else if(Me===17){for(q=Pe+3;X<q;){if(Z===0)break e;Z--,B+=$[V++]<<X,X+=8}X-=Pe,G=0,be=3+(7&(B>>>=Pe)),B>>>=3,X-=3}else{for(q=Pe+7;X<q;){if(Z===0)break e;Z--,B+=$[V++]<<X,X+=8}X-=Pe,G=0,be=11+(127&(B>>>=Pe)),B>>>=7,X-=7}if(j.have+be>j.nlen+j.ndist){F.msg="invalid bit length repeat",j.mode=30;break}for(;be--;)j.lens[j.have++]=G}}if(j.mode===30)break;if(j.lens[256]===0){F.msg="invalid code -- missing end-of-block",j.mode=30;break}if(j.lenbits=9,ce={bits:j.lenbits},Y=u(d,j.lens,0,j.nlen,j.lencode,0,j.work,ce),j.lenbits=ce.bits,Y){F.msg="invalid literal/lengths set",j.mode=30;break}if(j.distbits=6,j.distcode=j.distdyn,ce={bits:j.distbits},Y=u(f,j.lens,j.nlen,j.ndist,j.distcode,0,j.work,ce),j.distbits=ce.bits,Y){F.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<=ae){F.next_out=Q,F.avail_out=ae,F.next_in=V,F.avail_in=Z,j.hold=B,j.bits=X,c(F,se),Q=F.next_out,K=F.output,ae=F.avail_out,V=F.next_in,$=F.input,Z=F.avail_in,B=j.hold,X=j.bits,j.mode===12&&(j.back=-1);break}for(j.back=0;ie=(te=j.lencode[B&(1<<j.lenbits)-1])>>>16&255,Me=65535&te,!((Pe=te>>>24)<=X);){if(Z===0)break e;Z--,B+=$[V++]<<X,X+=8}if(ie&&(240&ie)==0){for(Oe=Pe,ge=ie,Ke=Me;ie=(te=j.lencode[Ke+((B&(1<<Oe+ge)-1)>>Oe)])>>>16&255,Me=65535&te,!(Oe+(Pe=te>>>24)<=X);){if(Z===0)break e;Z--,B+=$[V++]<<X,X+=8}B>>>=Oe,X-=Oe,j.back+=Oe}if(B>>>=Pe,X-=Pe,j.back+=Pe,j.length=Me,ie===0){j.mode=26;break}if(32&ie){j.back=-1,j.mode=12;break}if(64&ie){F.msg="invalid literal/length code",j.mode=30;break}j.extra=15&ie,j.mode=22;case 22:if(j.extra){for(q=j.extra;X<q;){if(Z===0)break e;Z--,B+=$[V++]<<X,X+=8}j.length+=B&(1<<j.extra)-1,B>>>=j.extra,X-=j.extra,j.back+=j.extra}j.was=j.length,j.mode=23;case 23:for(;ie=(te=j.distcode[B&(1<<j.distbits)-1])>>>16&255,Me=65535&te,!((Pe=te>>>24)<=X);){if(Z===0)break e;Z--,B+=$[V++]<<X,X+=8}if((240&ie)==0){for(Oe=Pe,ge=ie,Ke=Me;ie=(te=j.distcode[Ke+((B&(1<<Oe+ge)-1)>>Oe)])>>>16&255,Me=65535&te,!(Oe+(Pe=te>>>24)<=X);){if(Z===0)break e;Z--,B+=$[V++]<<X,X+=8}B>>>=Oe,X-=Oe,j.back+=Oe}if(B>>>=Pe,X-=Pe,j.back+=Pe,64&ie){F.msg="invalid distance code",j.mode=30;break}j.offset=Me,j.extra=15&ie,j.mode=24;case 24:if(j.extra){for(q=j.extra;X<q;){if(Z===0)break e;Z--,B+=$[V++]<<X,X+=8}j.offset+=B&(1<<j.extra)-1,B>>>=j.extra,X-=j.extra,j.back+=j.extra}if(j.offset>j.dmax){F.msg="invalid distance too far back",j.mode=30;break}j.mode=25;case 25:if(ae===0)break e;if(be=se-ae,j.offset>be){if((be=j.offset-be)>j.whave&&j.sane){F.msg="invalid distance too far back",j.mode=30;break}xe=be>j.wnext?(be-=j.wnext,j.wsize-be):j.wnext-be,be>j.length&&(be=j.length),de=j.window}else de=K,xe=Q-j.offset,be=j.length;for(ae<be&&(be=ae),ae-=be,j.length-=be;K[Q++]=de[xe++],--be;);j.length===0&&(j.mode=21);break;case 26:if(ae===0)break e;K[Q++]=j.length,ae--,j.mode=21;break;case 27:if(j.wrap){for(;X<32;){if(Z===0)break e;Z--,B|=$[V++]<<X,X+=8}if(se-=ae,F.total_out+=se,j.total+=se,se&&(F.adler=j.check=j.flags?l(j.check,K,se,Q-se):o(j.check,K,se,Q-se)),se=ae,(j.flags?B:v(B))!==j.check){F.msg="incorrect data check",j.mode=30;break}X=B=0}j.mode=28;case 28:if(j.wrap&&j.flags){for(;X<32;){if(Z===0)break e;Z--,B+=$[V++]<<X,X+=8}if(B!==(4294967295&j.total)){F.msg="incorrect length check",j.mode=30;break}X=B=0}j.mode=29;case 29:Y=1;break e;case 30:Y=-3;break e;case 31:return-4;case 32:default:return m}return F.next_out=Q,F.avail_out=ae,F.next_in=V,F.avail_in=Z,j.hold=B,j.bits=X,(j.wsize||se!==F.avail_out&&j.mode<30&&(j.mode<27||H!==4))&&U(F,F.output,F.next_out,se-F.avail_out)?(j.mode=31,-4):(ne-=F.avail_in,se-=F.avail_out,F.total_in+=ne,F.total_out+=se,j.total+=se,j.wrap&&se&&(F.adler=j.check=j.flags?l(j.check,K,se,F.next_out-se):o(j.check,K,se,F.next_out-se)),F.data_type=j.bits+(j.last?64:0)+(j.mode===12?128:0)+(j.mode===20||j.mode===15?256:0),(ne==0&&se===0||H===4)&&Y===p&&(Y=-5),Y)},i.inflateEnd=function(F){if(!F||!F.state)return m;var H=F.state;return H.window&&(H.window=null),F.state=null,p},i.inflateGetHeader=function(F,H){var j;return F&&F.state?(2&(j=F.state).wrap)==0?m:((j.head=H).done=!1,p):m},i.inflateSetDictionary=function(F,H){var j,$=H.length;return F&&F.state?(j=F.state).wrap!==0&&j.mode!==11?m:j.mode===11&&o(1,H,$,0)!==j.check?-3:U(F,H,$,$)?(j.mode=31,-4):(j.havedict=1,p):m},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){var a=n("../utils/common"),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,p,m,x,b,y,v){var S,M,T,E,C,k,R,A,D,U=v.bits,F=0,H=0,j=0,$=0,K=0,V=0,Q=0,Z=0,ae=0,B=0,X=null,ne=0,se=new a.Buf16(16),be=new a.Buf16(16),xe=null,de=0;for(F=0;F<=15;F++)se[F]=0;for(H=0;H<m;H++)se[f[p+H]]++;for(K=U,$=15;1<=$&&se[$]===0;$--);if($<K&&(K=$),$===0)return x[b++]=20971520,x[b++]=20971520,v.bits=1,0;for(j=1;j<$&&se[j]===0;j++);for(K<j&&(K=j),F=Z=1;F<=15;F++)if(Z<<=1,(Z-=se[F])<0)return-1;if(0<Z&&(d===0||$!==1))return-1;for(be[1]=0,F=1;F<15;F++)be[F+1]=be[F]+se[F];for(H=0;H<m;H++)f[p+H]!==0&&(y[be[f[p+H]]++]=H);if(k=d===0?(X=xe=y,19):d===1?(X=o,ne-=257,xe=l,de-=257,256):(X=c,xe=u,-1),F=j,C=b,Q=H=B=0,T=-1,E=(ae=1<<(V=K))-1,d===1&&852<ae||d===2&&592<ae)return 1;for(;;){for(R=F-Q,D=y[H]<k?(A=0,y[H]):y[H]>k?(A=xe[de+y[H]],X[ne+y[H]]):(A=96,0),S=1<<F-Q,j=M=1<<V;x[C+(B>>Q)+(M-=S)]=R<<24|A<<16|D|0,M!==0;);for(S=1<<F-1;B&S;)S>>=1;if(S!==0?(B&=S-1,B+=S):B=0,H++,--se[F]==0){if(F===$)break;F=f[p+y[H]]}if(K<F&&(B&E)!==T){for(Q===0&&(Q=K),C+=j,Z=1<<(V=F-Q);V+Q<$&&!((Z-=se[V+Q])<=0);)V++,Z<<=1;if(ae+=1<<V,d===1&&852<ae||d===2&&592<ae)return 1;x[T=B&E]=K<<24|V<<16|C-b|0}}return B!==0&&(x[C+B]=F-Q<<24|64<<16|0),v.bits=K,0}},{"../utils/common":41}],51:[function(n,r,i){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){var a=n("../utils/common"),o=0,l=1;function c(te){for(var I=te.length;0<=--I;)te[I]=0}var u=0,d=29,f=256,p=f+1+d,m=30,x=19,b=2*p+1,y=15,v=16,S=7,M=256,T=16,E=17,C=18,k=[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],R=[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],D=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],U=new Array(2*(p+2));c(U);var F=new Array(2*m);c(F);var H=new Array(512);c(H);var j=new Array(256);c(j);var $=new Array(d);c($);var K,V,Q,Z=new Array(m);function ae(te,I,fe,me,ke){this.static_tree=te,this.extra_bits=I,this.extra_base=fe,this.elems=me,this.max_length=ke,this.has_stree=te&&te.length}function B(te,I){this.dyn_tree=te,this.max_code=0,this.stat_desc=I}function X(te){return te<256?H[te]:H[256+(te>>>7)]}function ne(te,I){te.pending_buf[te.pending++]=255&I,te.pending_buf[te.pending++]=I>>>8&255}function se(te,I,fe){te.bi_valid>v-fe?(te.bi_buf|=I<<te.bi_valid&65535,ne(te,te.bi_buf),te.bi_buf=I>>v-te.bi_valid,te.bi_valid+=fe-v):(te.bi_buf|=I<<te.bi_valid&65535,te.bi_valid+=fe)}function be(te,I,fe){se(te,fe[2*I],fe[2*I+1])}function xe(te,I){for(var fe=0;fe|=1&te,te>>>=1,fe<<=1,0<--I;);return fe>>>1}function de(te,I,fe){var me,ke,z=new Array(y+1),O=0;for(me=1;me<=y;me++)z[me]=O=O+fe[me-1]<<1;for(ke=0;ke<=I;ke++){var ee=te[2*ke+1];ee!==0&&(te[2*ke]=xe(z[ee]++,ee))}}function Pe(te){var I;for(I=0;I<p;I++)te.dyn_ltree[2*I]=0;for(I=0;I<m;I++)te.dyn_dtree[2*I]=0;for(I=0;I<x;I++)te.bl_tree[2*I]=0;te.dyn_ltree[2*M]=1,te.opt_len=te.static_len=0,te.last_lit=te.matches=0}function ie(te){8<te.bi_valid?ne(te,te.bi_buf):0<te.bi_valid&&(te.pending_buf[te.pending++]=te.bi_buf),te.bi_buf=0,te.bi_valid=0}function Me(te,I,fe,me){var ke=2*I,z=2*fe;return te[ke]<te[z]||te[ke]===te[z]&&me[I]<=me[fe]}function Oe(te,I,fe){for(var me=te.heap[fe],ke=fe<<1;ke<=te.heap_len&&(ke<te.heap_len&&Me(I,te.heap[ke+1],te.heap[ke],te.depth)&&ke++,!Me(I,me,te.heap[ke],te.depth));)te.heap[fe]=te.heap[ke],fe=ke,ke<<=1;te.heap[fe]=me}function ge(te,I,fe){var me,ke,z,O,ee=0;if(te.last_lit!==0)for(;me=te.pending_buf[te.d_buf+2*ee]<<8|te.pending_buf[te.d_buf+2*ee+1],ke=te.pending_buf[te.l_buf+ee],ee++,me===0?be(te,ke,I):(be(te,(z=j[ke])+f+1,I),(O=k[z])!==0&&se(te,ke-=$[z],O),be(te,z=X(--me),fe),(O=R[z])!==0&&se(te,me-=Z[z],O)),ee<te.last_lit;);be(te,M,I)}function Ke(te,I){var fe,me,ke,z=I.dyn_tree,O=I.stat_desc.static_tree,ee=I.stat_desc.has_stree,le=I.stat_desc.elems,_e=-1;for(te.heap_len=0,te.heap_max=b,fe=0;fe<le;fe++)z[2*fe]!==0?(te.heap[++te.heap_len]=_e=fe,te.depth[fe]=0):z[2*fe+1]=0;for(;te.heap_len<2;)z[2*(ke=te.heap[++te.heap_len]=_e<2?++_e:0)]=1,te.depth[ke]=0,te.opt_len--,ee&&(te.static_len-=O[2*ke+1]);for(I.max_code=_e,fe=te.heap_len>>1;1<=fe;fe--)Oe(te,z,fe);for(ke=le;fe=te.heap[1],te.heap[1]=te.heap[te.heap_len--],Oe(te,z,1),me=te.heap[1],te.heap[--te.heap_max]=fe,te.heap[--te.heap_max]=me,z[2*ke]=z[2*fe]+z[2*me],te.depth[ke]=(te.depth[fe]>=te.depth[me]?te.depth[fe]:te.depth[me])+1,z[2*fe+1]=z[2*me+1]=ke,te.heap[1]=ke++,Oe(te,z,1),2<=te.heap_len;);te.heap[--te.heap_max]=te.heap[1],(function(we,re){var Fe,$e,Ve,He,ye,je,Be=re.dyn_tree,Se=re.max_code,Xe=re.stat_desc.static_tree,Ne=re.stat_desc.has_stree,tt=re.stat_desc.extra_bits,Ee=re.stat_desc.extra_base,We=re.stat_desc.max_length,ze=0;for(He=0;He<=y;He++)we.bl_count[He]=0;for(Be[2*we.heap[we.heap_max]+1]=0,Fe=we.heap_max+1;Fe<b;Fe++)We<(He=Be[2*Be[2*($e=we.heap[Fe])+1]+1]+1)&&(He=We,ze++),Be[2*$e+1]=He,Se<$e||(we.bl_count[He]++,ye=0,Ee<=$e&&(ye=tt[$e-Ee]),je=Be[2*$e],we.opt_len+=je*(He+ye),Ne&&(we.static_len+=je*(Xe[2*$e+1]+ye)));if(ze!==0){do{for(He=We-1;we.bl_count[He]===0;)He--;we.bl_count[He]--,we.bl_count[He+1]+=2,we.bl_count[We]--,ze-=2}while(0<ze);for(He=We;He!==0;He--)for($e=we.bl_count[He];$e!==0;)Se<(Ve=we.heap[--Fe])||(Be[2*Ve+1]!==He&&(we.opt_len+=(He-Be[2*Ve+1])*Be[2*Ve],Be[2*Ve+1]=He),$e--)}})(te,I),de(z,_e,te.bl_count)}function G(te,I,fe){var me,ke,z=-1,O=I[1],ee=0,le=7,_e=4;for(O===0&&(le=138,_e=3),I[2*(fe+1)+1]=65535,me=0;me<=fe;me++)ke=O,O=I[2*(me+1)+1],++ee<le&&ke===O||(ee<_e?te.bl_tree[2*ke]+=ee:ke!==0?(ke!==z&&te.bl_tree[2*ke]++,te.bl_tree[2*T]++):ee<=10?te.bl_tree[2*E]++:te.bl_tree[2*C]++,z=ke,_e=(ee=0)===O?(le=138,3):ke===O?(le=6,3):(le=7,4))}function Y(te,I,fe){var me,ke,z=-1,O=I[1],ee=0,le=7,_e=4;for(O===0&&(le=138,_e=3),me=0;me<=fe;me++)if(ke=O,O=I[2*(me+1)+1],!(++ee<le&&ke===O)){if(ee<_e)for(;be(te,ke,te.bl_tree),--ee!=0;);else ke!==0?(ke!==z&&(be(te,ke,te.bl_tree),ee--),be(te,T,te.bl_tree),se(te,ee-3,2)):ee<=10?(be(te,E,te.bl_tree),se(te,ee-3,3)):(be(te,C,te.bl_tree),se(te,ee-11,7));z=ke,_e=(ee=0)===O?(le=138,3):ke===O?(le=6,3):(le=7,4)}}c(Z);var ce=!1;function q(te,I,fe,me){se(te,(u<<1)+(me?1:0),3),(function(ke,z,O,ee){ie(ke),ne(ke,O),ne(ke,~O),a.arraySet(ke.pending_buf,ke.window,z,O,ke.pending),ke.pending+=O})(te,I,fe)}i._tr_init=function(te){ce||((function(){var I,fe,me,ke,z,O=new Array(y+1);for(ke=me=0;ke<d-1;ke++)for($[ke]=me,I=0;I<1<<k[ke];I++)j[me++]=ke;for(j[me-1]=ke,ke=z=0;ke<16;ke++)for(Z[ke]=z,I=0;I<1<<R[ke];I++)H[z++]=ke;for(z>>=7;ke<m;ke++)for(Z[ke]=z<<7,I=0;I<1<<R[ke]-7;I++)H[256+z++]=ke;for(fe=0;fe<=y;fe++)O[fe]=0;for(I=0;I<=143;)U[2*I+1]=8,I++,O[8]++;for(;I<=255;)U[2*I+1]=9,I++,O[9]++;for(;I<=279;)U[2*I+1]=7,I++,O[7]++;for(;I<=287;)U[2*I+1]=8,I++,O[8]++;for(de(U,p+1,O),I=0;I<m;I++)F[2*I+1]=5,F[2*I]=xe(I,5);K=new ae(U,k,f+1,p,y),V=new ae(F,R,0,m,y),Q=new ae(new Array(0),A,0,x,S)})(),ce=!0),te.l_desc=new B(te.dyn_ltree,K),te.d_desc=new B(te.dyn_dtree,V),te.bl_desc=new B(te.bl_tree,Q),te.bi_buf=0,te.bi_valid=0,Pe(te)},i._tr_stored_block=q,i._tr_flush_block=function(te,I,fe,me){var ke,z,O=0;0<te.level?(te.strm.data_type===2&&(te.strm.data_type=(function(ee){var le,_e=4093624447;for(le=0;le<=31;le++,_e>>>=1)if(1&_e&&ee.dyn_ltree[2*le]!==0)return o;if(ee.dyn_ltree[18]!==0||ee.dyn_ltree[20]!==0||ee.dyn_ltree[26]!==0)return l;for(le=32;le<f;le++)if(ee.dyn_ltree[2*le]!==0)return l;return o})(te)),Ke(te,te.l_desc),Ke(te,te.d_desc),O=(function(ee){var le;for(G(ee,ee.dyn_ltree,ee.l_desc.max_code),G(ee,ee.dyn_dtree,ee.d_desc.max_code),Ke(ee,ee.bl_desc),le=x-1;3<=le&&ee.bl_tree[2*D[le]+1]===0;le--);return ee.opt_len+=3*(le+1)+5+5+4,le})(te),ke=te.opt_len+3+7>>>3,(z=te.static_len+3+7>>>3)<=ke&&(ke=z)):ke=z=fe+5,fe+4<=ke&&I!==-1?q(te,I,fe,me):te.strategy===4||z===ke?(se(te,2+(me?1:0),3),ge(te,U,F)):(se(te,4+(me?1:0),3),(function(ee,le,_e,we){var re;for(se(ee,le-257,5),se(ee,_e-1,5),se(ee,we-4,4),re=0;re<we;re++)se(ee,ee.bl_tree[2*D[re]+1],3);Y(ee,ee.dyn_ltree,le-1),Y(ee,ee.dyn_dtree,_e-1)})(te,te.l_desc.max_code+1,te.d_desc.max_code+1,O+1),ge(te,te.dyn_ltree,te.dyn_dtree)),Pe(te),me&&ie(te)},i._tr_tally=function(te,I,fe){return te.pending_buf[te.d_buf+2*te.last_lit]=I>>>8&255,te.pending_buf[te.d_buf+2*te.last_lit+1]=255&I,te.pending_buf[te.l_buf+te.last_lit]=255&fe,te.last_lit++,I===0?te.dyn_ltree[2*fe]++:(te.matches++,I--,te.dyn_ltree[2*(j[fe]+f+1)]++,te.dyn_dtree[2*X(I)]++),te.last_lit===te.lit_bufsize-1},i._tr_align=function(te){se(te,2,3),be(te,M,U),(function(I){I.bi_valid===16?(ne(I,I.bi_buf),I.bi_buf=0,I.bi_valid=0):8<=I.bi_valid&&(I.pending_buf[I.pending++]=255&I.bi_buf,I.bi_buf>>=8,I.bi_valid-=8)})(te)}},{"../utils/common":41}],53:[function(n,r,i){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,i){(function(a){(function(o,l){if(!o.setImmediate){var c,u,d,f,p=1,m={},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(T){process.nextTick(function(){S(T)})}:(function(){if(o.postMessage&&!o.importScripts){var T=!0,E=o.onmessage;return o.onmessage=function(){T=!1},o.postMessage("","*"),o.onmessage=E,T}})()?(f="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",M,!1):o.attachEvent("onmessage",M),function(T){o.postMessage(f+T,"*")}):o.MessageChannel?((d=new MessageChannel).port1.onmessage=function(T){S(T.data)},function(T){d.port2.postMessage(T)}):b&&"onreadystatechange"in b.createElement("script")?(u=b.documentElement,function(T){var E=b.createElement("script");E.onreadystatechange=function(){S(T),E.onreadystatechange=null,u.removeChild(E),E=null},u.appendChild(E)}):function(T){setTimeout(S,0,T)},y.setImmediate=function(T){typeof T!="function"&&(T=new Function(""+T));for(var E=new Array(arguments.length-1),C=0;C<E.length;C++)E[C]=arguments[C+1];var k={callback:T,args:E};return m[p]=k,c(p),p++},y.clearImmediate=v}function v(T){delete m[T]}function S(T){if(x)setTimeout(S,0,T);else{var E=m[T];if(E){x=!0;try{(function(C){var k=C.callback,R=C.args;switch(R.length){case 0:k();break;case 1:k(R[0]);break;case 2:k(R[0],R[1]);break;case 3:k(R[0],R[1],R[2]);break;default:k.apply(l,R)}})(E)}finally{v(T),x=!1}}}}function M(T){T.source===o&&typeof T.data=="string"&&T.data.indexOf(f)===0&&S(+T.data.slice(f.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof Aw<"u"?Aw:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(SC)),SC.exports}var Y4e=X4e();const Q4e=hl(Y4e);function Z4e(t){const e=new Vi;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 DV=Z4e;async function RV(t,e=0){const n=[],r=t.getElementsByTagName("mesh");for(let i=0;i<r.length;i++){const a=r[i],o=[],l=[],c=a.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=a.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}async function J4e(t){const e=await Q4e.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function a(m){const x=m.startsWith("/")?m.slice(1):m,b=e.files[x];if(!b)return null;const y=await b.async("string");return i.parseFromString(y,"application/xml")}const o=new Map,l=new Map,c=e.files["Metadata/model_settings.config"];if(c)try{const m=await c.async("string"),b=i.parseFromString(m,"application/xml").getElementsByTagName("object");for(let y=0;y<b.length;y++){const v=b[y],S=v.getAttribute("id");if(!S)continue;const M=Array.from(v.children).filter(E=>E.tagName==="metadata"&&E.getAttribute("key")==="extruder");if(M.length>0){const E=M[0].getAttribute("value");E&&o.set(S,Math.max(0,parseInt(E,10)-1))}const T=v.getElementsByTagName("part");for(let E=0;E<T.length;E++){const C=T[E],k=C.getAttribute("id");if(!k)continue;const R=Array.from(C.children).filter(A=>A.tagName==="metadata"&&A.getAttribute("key")==="extruder");if(R.length>0){const A=R[0].getAttribute("value");A&&l.set(`${S}:${k}`,Math.max(0,parseInt(A,10)-1))}}}}catch{}const u=Object.keys(e.files).find(m=>m==="3D/3dmodel.model"||m.endsWith("/3dmodel.model"));if(!u){const m=Object.keys(e.files).find(x=>x.endsWith(".model"));if(m){const x=await a(m);if(x){const b=await RV(x,0);b.length>0&&n.set("1",{id:"1",meshes:b,defaultExtruder:0})}}return{objects:n,buildItems:r}}const d=await a(u);if(!d)return{objects:n,buildItems:r};const f=d.getElementsByTagName("object");for(let m=0;m<f.length;m++){const x=f[m],b=x.getAttribute("id");if(!b)continue;let y=o.get(b)??-1;if(y<0){const T=x.getAttribute("p:extruder")||x.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","extruder")||"1";y=Math.max(0,parseInt(T,10)-1)}const v=[],S=x.getElementsByTagName("mesh");for(let T=0;T<S.length;T++){const E=S[T],C=[],k=[],R=E.getElementsByTagName("vertex");for(let D=0;D<R.length;D++){const U=R[D];C.push(parseFloat(U.getAttribute("x")||"0"),parseFloat(U.getAttribute("y")||"0"),parseFloat(U.getAttribute("z")||"0"))}const A=E.getElementsByTagName("triangle");for(let D=0;D<A.length;D++){const U=A[D];k.push(parseInt(U.getAttribute("v1")||"0"),parseInt(U.getAttribute("v2")||"0"),parseInt(U.getAttribute("v3")||"0"))}C.length>0&&k.length>0&&v.push({vertices:C,triangles:k,extruder:y})}const M=x.getElementsByTagName("component");for(let T=0;T<M.length;T++){const E=M[T],C=E.getAttribute("p:path")||E.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path"),k=E.getAttribute("objectid");if(C){const R=await a(C);if(R){const A=k?`${b}:${k}`:null,D=A?l.get(A)??y:y,U=await RV(R,D),F=E.getAttribute("transform"),H=DV(F);for(const j of U)if(F){const $=[];for(let K=0;K<j.vertices.length;K+=3){const V=new dt(j.vertices[K],j.vertices[K+1],j.vertices[K+2]);V.applyMatrix4(H),$.push(V.x,V.y,V.z)}v.push({vertices:$,triangles:j.triangles,extruder:j.extruder})}else v.push(j)}}}v.length>0&&n.set(b,{id:b,meshes:v,defaultExtruder:y})}const p=d.getElementsByTagName("build");if(p.length>0){const m=p[0].getElementsByTagName("item");for(let x=0;x<m.length;x++){const b=m[x],y=b.getAttribute("objectid");if(!y)continue;const v=DV(b.getAttribute("transform"));r.push({objectId:y,transform:v})}}return{objects:n,buildItems:r}}function OV(t){const e=new Ac,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 nl(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function eLe({url:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=_.useRef(null),a=_.useRef(null),o=_.useRef(null),l=_.useRef(null),c=_.useRef(null),[u,d]=_.useState(!0),[f,p]=_.useState(null);_.useEffect(()=>{if(!i.current)return;const b=i.current,y=b.clientWidth,v=b.clientHeight,S=new jPe;S.background=new Bn(1710618),o.current=S;const M=new Wo(45,y/v,.1,1e4);M.position.set(150,150,150),l.current=M;const T=new D4e({antialias:!0});T.setSize(y,v),T.setPixelRatio(window.devicePixelRatio),b.appendChild(T.domElement),a.current=T;const E=new O4e(M,T.domElement);E.enableDamping=!0,E.dampingFactor=.05,c.current=E;const C=new HPe(16777215,.6);S.add(C);const k=new rV(16777215,.8);k.position.set(100,100,100),S.add(k);const R=new rV(16777215,.4);R.position.set(-100,50,-100),S.add(R);const A=Math.max(e.x,e.y),D=Math.ceil(A/16),U=new GPe(A,D,4473924,3355443);S.add(U);const F=new tL(e.x,e.y),H=new Z4({color:44610,transparent:!0,opacity:.15,side:ic}),j=new vc(F,H);j.rotation.x=-Math.PI/2,j.position.y=-.5,S.add(j);let $;const K=()=>{$=requestAnimationFrame(K),E.update(),T.render(S,M)};K(),fetch(t).then(Q=>{if(!Q.ok)throw new Error("Failed to load file");return Q.arrayBuffer()}).then(J4e).then(({objects:Q,buildItems:Z})=>{if(Q.size===0)throw new Error("No meshes found in 3MF file");const ae=Me=>{const ge=n?.[Me]||"#00ae42",Ke=new Bn(ge);return new IPe({color:Ke,shininess:30,flatShading:!1})},B=new o0,X=new Map;if(Z.length>0)for(const Me of Z){const Oe=Q.get(Me.objectId);if(Oe)for(const ge of Oe.meshes){const Ke=Me.extruder??ge.extruder,G=[];for(let ce=0;ce<ge.vertices.length;ce+=3){const q=new dt(ge.vertices[ce],ge.vertices[ce+1],ge.vertices[ce+2]);q.applyMatrix4(Me.transform),G.push(q.x,q.y,q.z)}const Y=OV({vertices:G,triangles:ge.triangles});X.has(Ke)||X.set(Ke,[]),X.get(Ke).push(Y)}}else for(const Me of Q.values())for(const Oe of Me.meshes){const ge=Oe.extruder,Ke=OV(Oe);X.has(ge)||X.set(ge,[]),X.get(ge).push(Ke)}for(const[Me,Oe]of X){if(Oe.length===0)continue;const ge=Oe.length===1?Oe[0]:K4e(Oe,!1);if(ge){const Ke=ae(Me),G=new vc(ge,Ke);B.add(G)}if(Oe.length>1)for(const Ke of Oe)Ke.dispose()}const ne=new bm().setFromObject(B),se=ne.getCenter(new dt);B.position.y=-ne.min.y,Z.length===0&&(B.position.x=-se.x,B.position.z=-se.z),S.add(B);const be=new bm().setFromObject(B),xe=be.getCenter(new dt),de=be.getSize(new dt),ie=Math.max(de.x,de.y,de.z)*1.8;M.position.set(xe.x+ie*.7,xe.y+ie*.5,xe.z+ie*.7),E.target.copy(xe),E.update(),d(!1)}).catch(Q=>{p(Q.message),d(!1)});const V=()=>{if(!b)return;const Q=b.clientWidth,Z=b.clientHeight;M.aspect=Q/Z,M.updateProjectionMatrix(),T.setSize(Q,Z)};return window.addEventListener("resize",V),()=>{window.removeEventListener("resize",V),cancelAnimationFrame($),E.dispose(),T.dispose(),b.removeChild(T.domElement)}},[t,e,n]);const m=()=>{l.current&&c.current&&(l.current.position.set(150,150,150),c.current.target.set(0,50,0),c.current.update())},x=b=>{l.current&&l.current.position.multiplyScalar(b)};return s.jsxs("div",{className:`relative ${r}`,children:[s.jsx("div",{ref:i,className:"w-full h-full min-h-[400px]"}),u&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}),f&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsx("p",{className:"text-red-400",children:f})}),!u&&!f&&s.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>x(.8),children:s.jsx(LR,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>x(1.25),children:s.jsx(FR,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:m,children:s.jsx(Rh,{className:"w-4 h-4"})})]})]})}const xM="159",Rp={ROTATE:0,DOLLY:1,PAN:2},Op={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},tLe=0,LV=1,nLe=2,RJ=1,rLe=2,lu=3,Th=0,zs=1,pu=2,ch=0,jg=1,FV=2,IV=3,UV=4,iLe=5,Ef=100,aLe=101,sLe=102,zV=103,BV=104,oLe=200,lLe=201,cLe=202,uLe=203,fD=204,mD=205,dLe=206,hLe=207,fLe=208,mLe=209,pLe=210,gLe=211,xLe=212,bLe=213,yLe=214,vLe=0,wLe=1,_Le=2,ZS=3,SLe=4,NLe=5,MLe=6,ELe=7,rL=0,kLe=1,TLe=2,uh=0,ALe=1,CLe=2,jLe=3,PLe=4,DLe=5,OJ=300,nx=301,rx=302,pD=303,gD=304,bM=306,xD=1e3,Cl=1001,bD=1002,Da=1003,$V=1004,NC=1005,Ko=1006,RLe=1007,gy=1008,dh=1009,OLe=1010,LLe=1011,iL=1012,LJ=1013,Zd=1014,_u=1015,xy=1016,FJ=1017,IJ=1018,qf=1020,FLe=1021,Xo=1023,ILe=1024,ULe=1025,Wf=1026,ix=1027,zLe=1028,UJ=1029,BLe=1030,zJ=1031,BJ=1033,MC=33776,EC=33777,kC=33778,TC=33779,HV=35840,VV=35841,GV=35842,qV=35843,$J=36196,WV=37492,KV=37496,XV=37808,YV=37809,QV=37810,ZV=37811,JV=37812,eG=37813,tG=37814,nG=37815,rG=37816,iG=37817,aG=37818,sG=37819,oG=37820,lG=37821,AC=36492,cG=36494,uG=36495,$Le=36283,dG=36284,hG=36285,fG=36286,HJ=3e3,Kf=3001,HLe=3200,VLe=3201,VJ=0,GLe=1,Yo="",Ra="srgb",Vu="srgb-linear",aL="display-p3",yM="display-p3-linear",JS="linear",Gr="srgb",eN="rec709",tN="p3",Lp=7680,mG=519,qLe=512,WLe=513,KLe=514,GJ=515,XLe=516,YLe=517,QLe=518,ZLe=519,yD=35044,pG="300 es",vD=1035,cc=2e3,by=2001;class jm{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){if(this._listeners===void 0)return!1;const r=this._listeners;return r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const r=this._listeners[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let a=0,o=i.length;a<o;a++)i[a].call(this,e);e.target=null}}}const Ga=["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 gG=1234567;const w0=Math.PI/180,yy=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(Ga[t&255]+Ga[t>>8&255]+Ga[t>>16&255]+Ga[t>>24&255]+"-"+Ga[e&255]+Ga[e>>8&255]+"-"+Ga[e>>16&15|64]+Ga[e>>24&255]+"-"+Ga[n&63|128]+Ga[n>>8&255]+"-"+Ga[n>>16&255]+Ga[n>>24&255]+Ga[r&255]+Ga[r>>8&255]+Ga[r>>16&255]+Ga[r>>24&255]).toLowerCase()}function Oa(t,e,n){return Math.max(e,Math.min(n,t))}function sL(t,e){return(t%e+e)%e}function JLe(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function eFe(t,e,n){return t!==e?(n-t)/(e-t):0}function _0(t,e,n){return(1-n)*t+n*e}function tFe(t,e,n,r){return _0(t,e,1-Math.exp(-n*r))}function nFe(t,e=1){return e-Math.abs(sL(t,e*2)-e)}function rFe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function iFe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function aFe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function sFe(t,e){return t+Math.random()*(e-t)}function oFe(t){return t*(.5-Math.random())}function lFe(t){t!==void 0&&(gG=t);let e=gG+=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 cFe(t){return t*w0}function uFe(t){return t*yy}function wD(t){return(t&t-1)===0&&t!==0}function dFe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function nN(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function hFe(t,e,n,r,i){const a=Math.cos,o=Math.sin,l=a(n/2),c=o(n/2),u=a((e+r)/2),d=o((e+r)/2),f=a((e-r)/2),p=o((e-r)/2),m=a((r-e)/2),x=o((r-e)/2);switch(i){case"XYX":t.set(l*d,c*f,c*p,l*u);break;case"YZY":t.set(c*p,l*d,c*f,l*u);break;case"ZXZ":t.set(c*f,c*p,l*d,l*u);break;case"XZX":t.set(l*d,c*x,c*m,l*u);break;case"YXY":t.set(c*m,l*d,c*x,l*u);break;case"ZYZ":t.set(c*x,c*m,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 Er(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 qJ={DEG2RAD:w0,RAD2DEG:yy,generateUUID:Cu,clamp:Oa,euclideanModulo:sL,mapLinear:JLe,inverseLerp:eFe,lerp:_0,damp:tFe,pingpong:nFe,smoothstep:rFe,smootherstep:iFe,randInt:aFe,randFloat:sFe,randFloatSpread:oFe,seededRandom:lFe,degToRad:cFe,radToDeg:uFe,isPowerOfTwo:wD,ceilPowerOfTwo:dFe,floorPowerOfTwo:nN,setQuaternionFromProperEuler:hFe,normalize:Er,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(Oa(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),a=this.x-e.x,o=this.y-e.y;return this.x=a*r-o*i+e.x,this.y=a*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,a,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,a,o,l,c,u)}set(e,n,r,i,a,o,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=a,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,a=this.elements,o=r[0],l=r[3],c=r[6],u=r[1],d=r[4],f=r[7],p=r[2],m=r[5],x=r[8],b=i[0],y=i[3],v=i[6],S=i[1],M=i[4],T=i[7],E=i[2],C=i[5],k=i[8];return a[0]=o*b+l*S+c*E,a[3]=o*y+l*M+c*C,a[6]=o*v+l*T+c*k,a[1]=u*b+d*S+f*E,a[4]=u*y+d*M+f*C,a[7]=u*v+d*T+f*k,a[2]=p*b+m*S+x*E,a[5]=p*y+m*M+x*C,a[8]=p*v+m*T+x*k,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8];return n*o*d-n*l*u-r*a*d+r*l*c+i*a*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=d*o-l*u,p=l*c-d*a,m=u*a-o*c,x=n*f+r*p+i*m;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]=p*b,e[4]=(d*n-i*c)*b,e[5]=(i*a-l*n)*b,e[6]=m*b,e[7]=(r*c-u*n)*b,e[8]=(o*n-r*a)*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,a,o,l){const c=Math.cos(a),u=Math.sin(a);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(CC.makeScale(e,n)),this}rotate(e){return this.premultiply(CC.makeRotation(-e)),this}translate(e,n){return this.premultiply(CC.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 CC=new Ln;function WJ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function rN(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function fFe(){const t=rN("canvas");return t.style.display="block",t}const xG={};function S0(t){t in xG||(xG[t]=!0,console.warn(t))}const bG=new Ln().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),yG=new Ln().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),__={[Vu]:{transfer:JS,primaries:eN,toReference:t=>t,fromReference:t=>t},[Ra]:{transfer:Gr,primaries:eN,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[yM]:{transfer:JS,primaries:tN,toReference:t=>t.applyMatrix3(yG),fromReference:t=>t.applyMatrix3(bG)},[aL]:{transfer:Gr,primaries:tN,toReference:t=>t.convertSRGBToLinear().applyMatrix3(yG),fromReference:t=>t.applyMatrix3(bG).convertLinearToSRGB()}},mFe=new Set([Vu,yM]),kr={enabled:!0,_workingColorSpace:Vu,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(!mFe.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=__[e].toReference,i=__[n].fromReference;return i(r(t))},fromWorkingColorSpace:function(t,e){return this.convert(t,this._workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this._workingColorSpace)},getPrimaries:function(t){return __[t].primaries},getTransfer:function(t){return t===Yo?JS:__[t].transfer}};function Pg(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function jC(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Fp;class KJ{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Fp===void 0&&(Fp=rN("canvas")),Fp.width=e.width,Fp.height=e.height;const r=Fp.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Fp}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=rN("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),a=i.data;for(let o=0;o<a.length;o++)a[o]=Pg(a[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(Pg(n[r]/255)*255):n[r]=Pg(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 pFe=0;class XJ{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:pFe++}),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 a;if(Array.isArray(i)){a=[];for(let o=0,l=i.length;o<l;o++)i[o].isDataTexture?a.push(PC(i[o].image)):a.push(PC(i[o]))}else a=PC(i);r.url=a}return n||(e.images[this.uuid]=r),r}}function PC(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?KJ.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 gFe=0;class Bs extends jm{constructor(e=Bs.DEFAULT_IMAGE,n=Bs.DEFAULT_MAPPING,r=Cl,i=Cl,a=Ko,o=gy,l=Xo,c=dh,u=Bs.DEFAULT_ANISOTROPY,d=Yo){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:gFe++}),this.uuid=Cu(),this.name="",this.source=new XJ(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,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:(S0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===Kf?Ra:Yo),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!==OJ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case xD:e.x=e.x-Math.floor(e.x);break;case Cl:e.x=e.x<0?0:1;break;case bD: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 xD:e.y=e.y-Math.floor(e.y);break;case Cl:e.y=e.y<0?0:1;break;case bD: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 S0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Ra?Kf:HJ}set encoding(e){S0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Kf?Ra:Yo}}Bs.DEFAULT_IMAGE=null;Bs.DEFAULT_MAPPING=OJ;Bs.DEFAULT_ANISOTROPY=1;class Cr{constructor(e=0,n=0,r=0,i=1){Cr.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=this.w,o=e.elements;return this.x=o[0]*n+o[4]*r+o[8]*i+o[12]*a,this.y=o[1]*n+o[5]*r+o[9]*i+o[13]*a,this.z=o[2]*n+o[6]*r+o[10]*i+o[14]*a,this.w=o[3]*n+o[7]*r+o[11]*i+o[15]*a,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const c=e.elements,u=c[0],d=c[4],f=c[8],p=c[1],m=c[5],x=c[9],b=c[2],y=c[6],v=c[10];if(Math.abs(d-p)<.01&&Math.abs(f-b)<.01&&Math.abs(x-y)<.01){if(Math.abs(d+p)<.1&&Math.abs(f+b)<.1&&Math.abs(x+y)<.1&&Math.abs(u+m+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const M=(u+1)/2,T=(m+1)/2,E=(v+1)/2,C=(d+p)/4,k=(f+b)/4,R=(x+y)/4;return M>T&&M>E?M<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(M),i=C/r,a=k/r):T>E?T<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(T),r=C/i,a=R/i):E<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(E),r=k/a,i=R/a),this.set(r,i,a,n),this}let S=Math.sqrt((y-x)*(y-x)+(f-b)*(f-b)+(p-d)*(p-d));return Math.abs(S)<.001&&(S=1),this.x=(y-x)/S,this.y=(f-b)/S,this.z=(p-d)/S,this.w=Math.acos((u+m+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 xFe extends jm{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new Cr(0,0,e,n),this.scissorTest=!1,this.viewport=new Cr(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(S0("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===Kf?Ra:Yo),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ko,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new Bs(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 XJ(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 ym extends xFe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class YJ extends Bs{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=Da,this.minFilter=Da,this.wrapR=Cl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class bFe extends Bs{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=Da,this.minFilter=Da,this.wrapR=Cl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class vm{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,a,o,l){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3];const p=a[o+0],m=a[o+1],x=a[o+2],b=a[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]=p,e[n+1]=m,e[n+2]=x,e[n+3]=b;return}if(f!==b||c!==p||u!==m||d!==x){let y=1-l;const v=c*p+u*m+d*x+f*b,S=v>=0?1:-1,M=1-v*v;if(M>Number.EPSILON){const E=Math.sqrt(M),C=Math.atan2(E,v*S);y=Math.sin(y*C)/E,l=Math.sin(l*C)/E}const T=l*S;if(c=c*y+p*T,u=u*y+m*T,d=d*y+x*T,f=f*y+b*T,y===1-l){const E=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=E,u*=E,d*=E,f*=E}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[o],p=a[o+1],m=a[o+2],x=a[o+3];return e[n]=l*x+d*f+c*m-u*p,e[n+1]=c*x+d*p+u*f-l*m,e[n+2]=u*x+d*m+l*p-c*f,e[n+3]=d*x-l*f-c*p-u*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n){const r=e._x,i=e._y,a=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(a/2),p=c(r/2),m=c(i/2),x=c(a/2);switch(o){case"XYZ":this._x=p*d*f+u*m*x,this._y=u*m*f-p*d*x,this._z=u*d*x+p*m*f,this._w=u*d*f-p*m*x;break;case"YXZ":this._x=p*d*f+u*m*x,this._y=u*m*f-p*d*x,this._z=u*d*x-p*m*f,this._w=u*d*f+p*m*x;break;case"ZXY":this._x=p*d*f-u*m*x,this._y=u*m*f+p*d*x,this._z=u*d*x+p*m*f,this._w=u*d*f-p*m*x;break;case"ZYX":this._x=p*d*f-u*m*x,this._y=u*m*f+p*d*x,this._z=u*d*x-p*m*f,this._w=u*d*f+p*m*x;break;case"YZX":this._x=p*d*f+u*m*x,this._y=u*m*f+p*d*x,this._z=u*d*x-p*m*f,this._w=u*d*f-p*m*x;break;case"XZY":this._x=p*d*f-u*m*x,this._y=u*m*f-p*d*x,this._z=u*d*x+p*m*f,this._w=u*d*f+p*m*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],a=n[8],o=n[1],l=n[5],c=n[9],u=n[2],d=n[6],f=n[10],p=r+l+f;if(p>0){const m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(d-c)*m,this._y=(a-u)*m,this._z=(o-i)*m}else if(r>l&&r>f){const m=2*Math.sqrt(1+r-l-f);this._w=(d-c)/m,this._x=.25*m,this._y=(i+o)/m,this._z=(a+u)/m}else if(l>f){const m=2*Math.sqrt(1+l-r-f);this._w=(a-u)/m,this._x=(i+o)/m,this._y=.25*m,this._z=(c+d)/m}else{const m=2*Math.sqrt(1+f-r-l);this._w=(o-i)/m,this._x=(a+u)/m,this._y=(c+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Oa(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,a=e._z,o=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+o*l+i*u-a*c,this._y=i*d+o*c+a*l-r*u,this._z=a*d+o*u+r*c-i*l,this._w=o*d-r*l-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);const r=this._x,i=this._y,a=this._z,o=this._w;let l=o*e._w+r*e._x+i*e._y+a*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=a,this;const c=1-l*l;if(c<=Number.EPSILON){const m=1-n;return this._w=m*o+n*this._w,this._x=m*r+n*this._x,this._y=m*i+n*this._y,this._z=m*a+n*this._z,this.normalize(),this._onChangeCallback(),this}const u=Math.sqrt(c),d=Math.atan2(u,l),f=Math.sin((1-n)*d)/u,p=Math.sin(n*d)/u;return this._w=o*f+this._w*p,this._x=r*f+this._x*p,this._y=i*f+this._y*p,this._z=a*f+this._z*p,this._onChangeCallback(),this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=Math.random(),n=Math.sqrt(1-e),r=Math.sqrt(e),i=2*Math.PI*Math.random(),a=2*Math.PI*Math.random();return this.set(n*Math.cos(i),r*Math.sin(a),r*Math.cos(a),n*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class 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(vG.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(vG.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,o=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*o,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*o,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-a*i),f=2*(a*r-o*n);return this.x=n+c*u+o*f-l*d,this.y=r+c*d+l*u-a*f,this.z=i+c*f+a*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,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,o=n.x,l=n.y,c=n.z;return this.x=i*c-a*l,this.y=a*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 DC.copy(this).projectOnVector(e),this.sub(DC)}reflect(e){return this.sub(DC.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(Oa(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 DC=new qe,vG=new vm;class rl{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 a=r.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let o=0,l=a.count;o<l;o++)e.isMesh===!0?e.getVertexPosition(o,Sl):Sl.fromBufferAttribute(a,o),Sl.applyMatrix4(e.matrixWorld),this.expandByPoint(Sl);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),S_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),S_.copy(r.boundingBox)),S_.applyMatrix4(e.matrixWorld),this.union(S_)}const i=e.children;for(let a=0,o=i.length;a<o;a++)this.expandByObject(i[a],n);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,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(Wb),N_.subVectors(this.max,Wb),Ip.subVectors(e.a,Wb),Up.subVectors(e.b,Wb),zp.subVectors(e.c,Wb),Ad.subVectors(Up,Ip),Cd.subVectors(zp,Up),ff.subVectors(Ip,zp);let n=[0,-Ad.z,Ad.y,0,-Cd.z,Cd.y,0,-ff.z,ff.y,Ad.z,0,-Ad.x,Cd.z,0,-Cd.x,ff.z,0,-ff.x,-Ad.y,Ad.x,0,-Cd.y,Cd.x,0,-ff.y,ff.x,0];return!RC(n,Ip,Up,zp,N_)||(n=[1,0,0,0,1,0,0,0,1],!RC(n,Ip,Up,zp,N_))?!1:(M_.crossVectors(Ad,Cd),n=[M_.x,M_.y,M_.z],RC(n,Ip,Up,zp,N_))}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,S_=new rl,Ip=new qe,Up=new qe,zp=new qe,Ad=new qe,Cd=new qe,ff=new qe,Wb=new qe,N_=new qe,M_=new qe,mf=new qe;function RC(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){mf.fromArray(t,a);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 yFe=new rl,Kb=new qe,OC=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):yFe.setFromPoints(e).getCenter(r);let i=0;for(let a=0,o=e.length;a<o;a++)i=Math.max(i,r.distanceToSquared(e[a]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Kb.subVectors(e,this.center);const n=Kb.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Kb,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):(OC.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Kb.copy(e.center).add(OC)),this.expandByPoint(Kb.copy(e.center).sub(OC))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Jc=new qe,LC=new qe,E_=new qe,jd=new qe,FC=new qe,k_=new qe,IC=new qe;class oL{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){LC.copy(e).add(n).multiplyScalar(.5),E_.copy(n).sub(e).normalize(),jd.copy(this.origin).sub(LC);const a=e.distanceTo(n)*.5,o=-this.direction.dot(E_),l=jd.dot(this.direction),c=-jd.dot(E_),u=jd.lengthSq(),d=Math.abs(1-o*o);let f,p,m,x;if(d>0)if(f=o*c-l,p=o*l-c,x=a*d,f>=0)if(p>=-x)if(p<=x){const b=1/d;f*=b,p*=b,m=f*(f+o*p+2*l)+p*(o*f+p+2*c)+u}else p=a,f=Math.max(0,-(o*p+l)),m=-f*f+p*(p+2*c)+u;else p=-a,f=Math.max(0,-(o*p+l)),m=-f*f+p*(p+2*c)+u;else p<=-x?(f=Math.max(0,-(-o*a+l)),p=f>0?-a:Math.min(Math.max(-a,-c),a),m=-f*f+p*(p+2*c)+u):p<=x?(f=0,p=Math.min(Math.max(-a,-c),a),m=p*(p+2*c)+u):(f=Math.max(0,-(o*a+l)),p=f>0?a:Math.min(Math.max(-a,-c),a),m=-f*f+p*(p+2*c)+u);else p=o>0?-a:a,f=Math.max(0,-(o*p+l)),m=-f*f+p*(p+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(LC).addScaledVector(E_,p),m}intersectSphere(e,n){Jc.subVectors(e.center,this.origin);const r=Jc.dot(this.direction),i=Jc.dot(Jc)-r*r,a=e.radius*e.radius;if(i>a)return null;const o=Math.sqrt(a-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,a,o,l,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,p=this.origin;return u>=0?(r=(e.min.x-p.x)*u,i=(e.max.x-p.x)*u):(r=(e.max.x-p.x)*u,i=(e.min.x-p.x)*u),d>=0?(a=(e.min.y-p.y)*d,o=(e.max.y-p.y)*d):(a=(e.max.y-p.y)*d,o=(e.min.y-p.y)*d),r>o||a>i||((a>r||isNaN(r))&&(r=a),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-p.z)*f,c=(e.max.z-p.z)*f):(l=(e.max.z-p.z)*f,c=(e.min.z-p.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,a){FC.subVectors(n,e),k_.subVectors(r,e),IC.crossVectors(FC,k_);let o=this.direction.dot(IC),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;jd.subVectors(this.origin,e);const c=l*this.direction.dot(k_.crossVectors(jd,k_));if(c<0)return null;const u=l*this.direction.dot(FC.cross(jd));if(u<0||c+u>o)return null;const d=-l*jd.dot(IC);return d<0?null:this.at(d/o,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class zr{constructor(e,n,r,i,a,o,l,c,u,d,f,p,m,x,b,y){zr.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,o,l,c,u,d,f,p,m,x,b,y)}set(e,n,r,i,a,o,l,c,u,d,f,p,m,x,b,y){const v=this.elements;return v[0]=e,v[4]=n,v[8]=r,v[12]=i,v[1]=a,v[5]=o,v[9]=l,v[13]=c,v[2]=u,v[6]=d,v[10]=f,v[14]=p,v[3]=m,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 zr().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/Bp.setFromMatrixColumn(e,0).length(),a=1/Bp.setFromMatrixColumn(e,1).length(),o=1/Bp.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*a,n[5]=r[5]*a,n[6]=r[6]*a,n[7]=0,n[8]=r[8]*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,a=e.z,o=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const p=o*d,m=o*f,x=l*d,b=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=m+x*u,n[5]=p-b*u,n[9]=-l*c,n[2]=b-p*u,n[6]=x+m*u,n[10]=o*c}else if(e.order==="YXZ"){const p=c*d,m=c*f,x=u*d,b=u*f;n[0]=p+b*l,n[4]=x*l-m,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=m*l-x,n[6]=b+p*l,n[10]=o*c}else if(e.order==="ZXY"){const p=c*d,m=c*f,x=u*d,b=u*f;n[0]=p-b*l,n[4]=-o*f,n[8]=x+m*l,n[1]=m+x*l,n[5]=o*d,n[9]=b-p*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const p=o*d,m=o*f,x=l*d,b=l*f;n[0]=c*d,n[4]=x*u-m,n[8]=p*u+b,n[1]=c*f,n[5]=b*u+p,n[9]=m*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const p=o*c,m=o*u,x=l*c,b=l*u;n[0]=c*d,n[4]=b-p*f,n[8]=x*f+m,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=m*f+x,n[10]=p-b*f}else if(e.order==="XZY"){const p=o*c,m=o*u,x=l*c,b=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=p*f+b,n[5]=o*d,n[9]=m*f-x,n[2]=x*f-m,n[6]=l*d,n[10]=b*f+p}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(vFe,e,wFe)}lookAt(e,n,r){const i=this.elements;return io.subVectors(e,n),io.lengthSq()===0&&(io.z=1),io.normalize(),Pd.crossVectors(r,io),Pd.lengthSq()===0&&(Math.abs(r.z)===1?io.x+=1e-4:io.z+=1e-4,io.normalize(),Pd.crossVectors(r,io)),Pd.normalize(),T_.crossVectors(io,Pd),i[0]=Pd.x,i[4]=T_.x,i[8]=io.x,i[1]=Pd.y,i[5]=T_.y,i[9]=io.y,i[2]=Pd.z,i[6]=T_.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,a=this.elements,o=r[0],l=r[4],c=r[8],u=r[12],d=r[1],f=r[5],p=r[9],m=r[13],x=r[2],b=r[6],y=r[10],v=r[14],S=r[3],M=r[7],T=r[11],E=r[15],C=i[0],k=i[4],R=i[8],A=i[12],D=i[1],U=i[5],F=i[9],H=i[13],j=i[2],$=i[6],K=i[10],V=i[14],Q=i[3],Z=i[7],ae=i[11],B=i[15];return a[0]=o*C+l*D+c*j+u*Q,a[4]=o*k+l*U+c*$+u*Z,a[8]=o*R+l*F+c*K+u*ae,a[12]=o*A+l*H+c*V+u*B,a[1]=d*C+f*D+p*j+m*Q,a[5]=d*k+f*U+p*$+m*Z,a[9]=d*R+f*F+p*K+m*ae,a[13]=d*A+f*H+p*V+m*B,a[2]=x*C+b*D+y*j+v*Q,a[6]=x*k+b*U+y*$+v*Z,a[10]=x*R+b*F+y*K+v*ae,a[14]=x*A+b*H+y*V+v*B,a[3]=S*C+M*D+T*j+E*Q,a[7]=S*k+M*U+T*$+E*Z,a[11]=S*R+M*F+T*K+E*ae,a[15]=S*A+M*H+T*V+E*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],a=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],p=e[10],m=e[14],x=e[3],b=e[7],y=e[11],v=e[15];return x*(+a*c*f-i*u*f-a*l*p+r*u*p+i*l*m-r*c*m)+b*(+n*c*m-n*u*p+a*o*p-i*o*m+i*u*d-a*c*d)+y*(+n*u*f-n*l*m-a*o*f+r*o*m+a*l*d-r*u*d)+v*(-i*l*d-n*c*f+n*l*p+i*o*f-r*o*p+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9],p=e[10],m=e[11],x=e[12],b=e[13],y=e[14],v=e[15],S=f*y*u-b*p*u+b*c*m-l*y*m-f*c*v+l*p*v,M=x*p*u-d*y*u-x*c*m+o*y*m+d*c*v-o*p*v,T=d*b*u-x*f*u+x*l*m-o*b*m-d*l*v+o*f*v,E=x*f*c-d*b*c-x*l*p+o*b*p+d*l*y-o*f*y,C=n*S+r*M+i*T+a*E;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const k=1/C;return e[0]=S*k,e[1]=(b*p*a-f*y*a-b*i*m+r*y*m+f*i*v-r*p*v)*k,e[2]=(l*y*a-b*c*a+b*i*u-r*y*u-l*i*v+r*c*v)*k,e[3]=(f*c*a-l*p*a-f*i*u+r*p*u+l*i*m-r*c*m)*k,e[4]=M*k,e[5]=(d*y*a-x*p*a+x*i*m-n*y*m-d*i*v+n*p*v)*k,e[6]=(x*c*a-o*y*a-x*i*u+n*y*u+o*i*v-n*c*v)*k,e[7]=(o*p*a-d*c*a+d*i*u-n*p*u-o*i*m+n*c*m)*k,e[8]=T*k,e[9]=(x*f*a-d*b*a-x*r*m+n*b*m+d*r*v-n*f*v)*k,e[10]=(o*b*a-x*l*a+x*r*u-n*b*u-o*r*v+n*l*v)*k,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*m-n*l*m)*k,e[12]=E*k,e[13]=(d*b*i-x*f*i+x*r*p-n*b*p-d*r*y+n*f*y)*k,e[14]=(x*l*i-o*b*i-x*r*c+n*b*c+o*r*y-n*l*y)*k,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*p+n*l*p)*k,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,o=e.x,l=e.y,c=e.z,u=a*o,d=a*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,a*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,o){return this.set(1,r,a,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,o=n._y,l=n._z,c=n._w,u=a+a,d=o+o,f=l+l,p=a*u,m=a*d,x=a*f,b=o*d,y=o*f,v=l*f,S=c*u,M=c*d,T=c*f,E=r.x,C=r.y,k=r.z;return i[0]=(1-(b+v))*E,i[1]=(m+T)*E,i[2]=(x-M)*E,i[3]=0,i[4]=(m-T)*C,i[5]=(1-(p+v))*C,i[6]=(y+S)*C,i[7]=0,i[8]=(x+M)*k,i[9]=(y-S)*k,i[10]=(1-(p+b))*k,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let a=Bp.set(i[0],i[1],i[2]).length();const o=Bp.set(i[4],i[5],i[6]).length(),l=Bp.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),e.x=i[12],e.y=i[13],e.z=i[14],Nl.copy(this);const u=1/a,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=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=cc){const c=this.elements,u=2*a/(n-e),d=2*a/(r-i),f=(n+e)/(n-e),p=(r+i)/(r-i);let m,x;if(l===cc)m=-(o+a)/(o-a),x=-2*o*a/(o-a);else if(l===by)m=-o/(o-a),x=-o*a/(o-a);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]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,a,o,l=cc){const c=this.elements,u=1/(n-e),d=1/(r-i),f=1/(o-a),p=(n+e)*u,m=(r+i)*d;let x,b;if(l===cc)x=(o+a)*f,b=-2*f;else if(l===by)x=a*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]=-p,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-m,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 Bp=new qe,Nl=new zr,vFe=new qe(0,0,0),wFe=new qe(1,1,1),Pd=new qe,T_=new qe,io=new qe,wG=new zr,_G=new vm;class fv{constructor(e=0,n=0,r=0,i=fv.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,a=i[0],o=i[4],l=i[8],c=i[1],u=i[5],d=i[9],f=i[2],p=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(Oa(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(p,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Oa(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,m),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(Oa(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-Oa(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(Oa(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(l,m));break;case"XZY":this._z=Math.asin(-Oa(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return wG.makeRotationFromQuaternion(e),this.setFromRotationMatrix(wG,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return _G.setFromEuler(this),this.setFromQuaternion(_G,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}}fv.DEFAULT_ORDER="XYZ";class QJ{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 _Fe=0;const SG=new qe,$p=new vm,eu=new zr,A_=new qe,Xb=new qe,SFe=new qe,NFe=new vm,NG=new qe(1,0,0),MG=new qe(0,1,0),EG=new qe(0,0,1),MFe={type:"added"},EFe={type:"removed"};class ps extends jm{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:_Fe++}),this.uuid=Cu(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ps.DEFAULT_UP.clone();const e=new qe,n=new fv,r=new vm,i=new qe(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),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 zr},normalMatrix:{value:new Ln}}),this.matrix=new zr,this.matrixWorld=new zr,this.matrixAutoUpdate=ps.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ps.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new QJ,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 $p.setFromAxisAngle(e,n),this.quaternion.multiply($p),this}rotateOnWorldAxis(e,n){return $p.setFromAxisAngle(e,n),this.quaternion.premultiply($p),this}rotateX(e){return this.rotateOnAxis(NG,e)}rotateY(e){return this.rotateOnAxis(MG,e)}rotateZ(e){return this.rotateOnAxis(EG,e)}translateOnAxis(e,n){return SG.copy(e).applyQuaternion(this.quaternion),this.position.add(SG.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(NG,e)}translateY(e){return this.translateOnAxis(MG,e)}translateZ(e){return this.translateOnAxis(EG,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?A_.copy(e):A_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Xb.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?eu.lookAt(Xb,A_,this.up):eu.lookAt(A_,Xb,this.up),this.quaternion.setFromRotationMatrix(eu),i&&(eu.extractRotation(i.matrixWorld),$p.setFromRotationMatrix(eu),this.quaternion.premultiply($p.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(MFe)):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(EFe)),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 a=0,o=i.length;a<o;a++)i[a].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Xb,e,SFe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Xb,NFe,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++){const a=n[r];(a.matrixWorldAutoUpdate===!0||e===!0)&&a.updateMatrixWorld(e)}}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.matrixWorldAutoUpdate===!0&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),n===!0){const i=this.children;for(let a=0,o=i.length;a<o;a++){const l=i[a];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 a(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=a(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];a(e.shapes,f)}else a(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let c=0,u=this.material.length;c<u;c++)l.push(a(e.materials,this.material[c]));i.material=l}else i.material=a(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(a(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),p=o(e.skeletons),m=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),p.length>0&&(r.skeletons=p),m.length>0&&(r.animations=m),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}}ps.DEFAULT_UP=new qe(0,1,0);ps.DEFAULT_MATRIX_AUTO_UPDATE=!0;ps.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Ml=new qe,tu=new qe,UC=new qe,nu=new qe,Hp=new qe,Vp=new qe,kG=new qe,zC=new qe,BC=new qe,$C=new qe;let C_=!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 a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}static getBarycoord(e,n,r,i,a){Ml.subVectors(i,n),tu.subVectors(r,n),UC.subVectors(e,n);const o=Ml.dot(Ml),l=Ml.dot(tu),c=Ml.dot(UC),u=tu.dot(tu),d=tu.dot(UC),f=o*u-l*l;if(f===0)return a.set(-2,-1,-1);const p=1/f,m=(u*c-l*d)*p,x=(o*d-l*c)*p;return a.set(1-m-x,x,m)}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,a,o,l,c){return C_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),C_=!0),this.getInterpolation(e,n,r,i,a,o,l,c)}static getInterpolation(e,n,r,i,a,o,l,c){return this.getBarycoord(e,n,r,i,nu),c.setScalar(0),c.addScaledVector(a,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,a){return C_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),C_=!0),El.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}getInterpolation(e,n,r,i,a){return El.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}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,a=this.c;let o,l;Hp.subVectors(i,r),Vp.subVectors(a,r),zC.subVectors(e,r);const c=Hp.dot(zC),u=Vp.dot(zC);if(c<=0&&u<=0)return n.copy(r);BC.subVectors(e,i);const d=Hp.dot(BC),f=Vp.dot(BC);if(d>=0&&f<=d)return n.copy(i);const p=c*f-d*u;if(p<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(Hp,o);$C.subVectors(e,a);const m=Hp.dot($C),x=Vp.dot($C);if(x>=0&&m<=x)return n.copy(a);const b=m*u-c*x;if(b<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(Vp,l);const y=d*x-m*f;if(y<=0&&f-d>=0&&m-x>=0)return kG.subVectors(a,i),l=(f-d)/(f-d+(m-x)),n.copy(i).addScaledVector(kG,l);const v=1/(y+b+p);return o=b*v,l=p*v,n.copy(r).addScaledVector(Hp,o).addScaledVector(Vp,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const ZJ={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},Dd={h:0,s:0,l:0},j_={h:0,s:0,l:0};function HC(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 Zt=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=Ra){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,kr.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=kr.workingColorSpace){return this.r=e,this.g=n,this.b=r,kr.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=kr.workingColorSpace){if(e=sL(e,1),n=Oa(n,0,1),r=Oa(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,o=2*r-a;this.r=HC(o,a,e+1/3),this.g=HC(o,a,e),this.b=HC(o,a,e-1/3)}return kr.toWorkingColorSpace(this,i),this}setStyle(e,n=Ra){function r(a){a!==void 0&&parseFloat(a)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const o=i[1],l=i[2];switch(o){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],o=a.length;if(o===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(o===6)return this.setHex(parseInt(a,16),n);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=Ra){const r=ZJ[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=Pg(e.r),this.g=Pg(e.g),this.b=Pg(e.b),this}copyLinearToSRGB(e){return this.r=jC(e.r),this.g=jC(e.g),this.b=jC(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ra){return kr.fromWorkingColorSpace(qa.copy(this),e),Math.round(Oa(qa.r*255,0,255))*65536+Math.round(Oa(qa.g*255,0,255))*256+Math.round(Oa(qa.b*255,0,255))}getHexString(e=Ra){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=kr.workingColorSpace){kr.fromWorkingColorSpace(qa.copy(this),n);const r=qa.r,i=qa.g,a=qa.b,o=Math.max(r,i,a),l=Math.min(r,i,a);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-a)/f+(i<a?6:0);break;case i:c=(a-r)/f+2;break;case a:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=kr.workingColorSpace){return kr.fromWorkingColorSpace(qa.copy(this),n),e.r=qa.r,e.g=qa.g,e.b=qa.b,e}getStyle(e=Ra){kr.fromWorkingColorSpace(qa.copy(this),e);const n=qa.r,r=qa.g,i=qa.b;return e!==Ra?`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(Dd),this.setHSL(Dd.h+e,Dd.s+n,Dd.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(Dd),e.getHSL(j_);const r=_0(Dd.h,j_.h,n),i=_0(Dd.s,j_.s,n),a=_0(Dd.l,j_.l,n);return this.setHSL(r,i,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,a=e.elements;return this.r=a[0]*n+a[3]*r+a[6]*i,this.g=a[1]*n+a[4]*r+a[7]*i,this.b=a[2]*n+a[5]*r+a[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const qa=new Zt;Zt.NAMES=ZJ;let kFe=0;class Dx extends jm{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:kFe++}),this.uuid=Cu(),this.name="",this.type="Material",this.blending=jg,this.side=Th,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=fD,this.blendDst=mD,this.blendEquation=Ef,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Zt(0,0,0),this.blendAlpha=0,this.depthFunc=ZS,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=mG,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Lp,this.stencilZFail=Lp,this.stencilZPass=Lp,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!==jg&&(r.blending=this.blending),this.side!==Th&&(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!==fD&&(r.blendSrc=this.blendSrc),this.blendDst!==mD&&(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!==ZS&&(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!==mG&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Lp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Lp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Lp&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(a){const o=[];for(const l in a){const c=a[l];delete c.metadata,o.push(c)}return o}if(n){const a=i(e.textures),o=i(e.images);a.length>0&&(r.textures=a),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 a=0;a!==i;++a)r[a]=n[a].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class JJ extends Dx{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Zt(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=rL,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 Oi=new qe,P_=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=yD,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=_u,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.BufferAttribute: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)P_.fromBufferAttribute(this,n),P_.applyMatrix3(e),this.setXY(n,P_.x,P_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Oi.fromBufferAttribute(this,n),Oi.applyMatrix3(e),this.setXYZ(n,Oi.x,Oi.y,Oi.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Oi.fromBufferAttribute(this,n),Oi.applyMatrix4(e),this.setXYZ(n,Oi.x,Oi.y,Oi.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Oi.fromBufferAttribute(this,n),Oi.applyNormalMatrix(e),this.setXYZ(n,Oi.x,Oi.y,Oi.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Oi.fromBufferAttribute(this,n),Oi.transformDirection(e),this.setXYZ(n,Oi.x,Oi.y,Oi.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=Er(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=Er(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=Er(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=Er(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=Er(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Er(n,this.array),r=Er(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=Er(n,this.array),r=Er(r,this.array),i=Er(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e*=this.itemSize,this.normalized&&(n=Er(n,this.array),r=Er(r,this.array),i=Er(i,this.array),a=Er(a,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==yD&&(e.usage=this.usage),e}}class eee extends go{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class tee extends go{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class Ti extends go{constructor(e,n,r){super(new Float32Array(e),n,r)}}let TFe=0;const Fo=new zr,VC=new ps,Gp=new qe,ao=new rl,Yb=new rl,ha=new qe;class ns extends jm{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:TFe++}),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(WJ(e)?tee:eee)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const a=new Ln().getNormalMatrix(e);r.applyNormalMatrix(a),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Fo.makeRotationFromQuaternion(e),this.applyMatrix4(Fo),this}rotateX(e){return Fo.makeRotationX(e),this.applyMatrix4(Fo),this}rotateY(e){return Fo.makeRotationY(e),this.applyMatrix4(Fo),this}rotateZ(e){return Fo.makeRotationZ(e),this.applyMatrix4(Fo),this}translate(e,n,r){return Fo.makeTranslation(e,n,r),this.applyMatrix4(Fo),this}scale(e,n,r){return Fo.makeScale(e,n,r),this.applyMatrix4(Fo),this}lookAt(e){return VC.lookAt(e),VC.updateMatrix(),this.applyMatrix4(VC.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Gp).negate(),this.translate(Gp.x,Gp.y,Gp.z),this}setFromPoints(e){const n=[];for(let r=0,i=e.length;r<i;r++){const a=e[r];n.push(a.x,a.y,a.z||0)}return this.setAttribute("position",new Ti(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new rl);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 a=n[r];ao.setFromBufferAttribute(a),this.morphTargetsRelative?(ha.addVectors(this.boundingBox.min,ao.min),this.boundingBox.expandByPoint(ha),ha.addVectors(this.boundingBox.max,ao.max),this.boundingBox.expandByPoint(ha)):(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 a=0,o=n.length;a<o;a++){const l=n[a];Yb.setFromBufferAttribute(l),this.morphTargetsRelative?(ha.addVectors(ao.min,Yb.min),ao.expandByPoint(ha),ha.addVectors(ao.max,Yb.max),ao.expandByPoint(ha)):(ao.expandByPoint(Yb.min),ao.expandByPoint(Yb.max))}ao.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)ha.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(ha));if(n)for(let a=0,o=n.length;a<o;a++){const l=n[a],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)ha.fromBufferAttribute(l,u),c&&(Gp.fromBufferAttribute(e,u),ha.add(Gp)),i=Math.max(i,r.distanceToSquared(ha))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=e.array,i=n.position.array,a=n.normal.array,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 D=0;D<l;D++)u[D]=new qe,d[D]=new qe;const f=new qe,p=new qe,m=new qe,x=new xn,b=new xn,y=new xn,v=new qe,S=new qe;function M(D,U,F){f.fromArray(i,D*3),p.fromArray(i,U*3),m.fromArray(i,F*3),x.fromArray(o,D*2),b.fromArray(o,U*2),y.fromArray(o,F*2),p.sub(f),m.sub(f),b.sub(x),y.sub(x);const H=1/(b.x*y.y-y.x*b.y);isFinite(H)&&(v.copy(p).multiplyScalar(y.y).addScaledVector(m,-b.y).multiplyScalar(H),S.copy(m).multiplyScalar(b.x).addScaledVector(p,-y.x).multiplyScalar(H),u[D].add(v),u[U].add(v),u[F].add(v),d[D].add(S),d[U].add(S),d[F].add(S))}let T=this.groups;T.length===0&&(T=[{start:0,count:r.length}]);for(let D=0,U=T.length;D<U;++D){const F=T[D],H=F.start,j=F.count;for(let $=H,K=H+j;$<K;$+=3)M(r[$+0],r[$+1],r[$+2])}const E=new qe,C=new qe,k=new qe,R=new qe;function A(D){k.fromArray(a,D*3),R.copy(k);const U=u[D];E.copy(U),E.sub(k.multiplyScalar(k.dot(U))).normalize(),C.crossVectors(R,U);const H=C.dot(d[D])<0?-1:1;c[D*4]=E.x,c[D*4+1]=E.y,c[D*4+2]=E.z,c[D*4+3]=H}for(let D=0,U=T.length;D<U;++D){const F=T[D],H=F.start,j=F.count;for(let $=H,K=H+j;$<K;$+=3)A(r[$+0]),A(r[$+1]),A(r[$+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 p=0,m=r.count;p<m;p++)r.setXYZ(p,0,0,0);const i=new qe,a=new qe,o=new qe,l=new qe,c=new qe,u=new qe,d=new qe,f=new qe;if(e)for(let p=0,m=e.count;p<m;p+=3){const x=e.getX(p+0),b=e.getX(p+1),y=e.getX(p+2);i.fromBufferAttribute(n,x),a.fromBufferAttribute(n,b),o.fromBufferAttribute(n,y),d.subVectors(o,a),f.subVectors(i,a),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 p=0,m=n.count;p<m;p+=3)i.fromBufferAttribute(n,p+0),a.fromBufferAttribute(n,p+1),o.fromBufferAttribute(n,p+2),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),r.setXYZ(p+0,d.x,d.y,d.z),r.setXYZ(p+1,d.x,d.y,d.z),r.setXYZ(p+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++)ha.fromBufferAttribute(e,n),ha.normalize(),e.setXYZ(n,ha.x,ha.y,ha.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,p=new u.constructor(c.length*d);let m=0,x=0;for(let b=0,y=c.length;b<y;b++){l.isInterleavedBufferAttribute?m=c[b]*l.data.stride+l.offset:m=c[b]*d;for(let v=0;v<d;v++)p[x++]=u[m++]}return new go(p,d,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new ns,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 a=this.morphAttributes;for(const l in a){const c=[],u=a[l];for(let d=0,f=u.length;d<f;d++){const p=u[d],m=e(p,r);c.push(m)}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 a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,p=u.length;f<p;f++){const m=u[f];d.push(m.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const 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 a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let p=0,m=f.length;p<m;p++)d.push(f[p].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 TG=new zr,pf=new oL,D_=new hc,AG=new qe,qp=new qe,Wp=new qe,Kp=new qe,GC=new qe,R_=new qe,O_=new xn,L_=new xn,F_=new xn,CG=new qe,jG=new qe,PG=new qe,I_=new qe,U_=new qe;class Dl extends ps{constructor(e=new ns,n=new JJ){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,o=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(a&&l){R_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(GC.fromBufferAttribute(f,e),o?R_.addScaledVector(GC,d):R_.addScaledVector(GC.sub(n),d))}n.add(R_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),D_.copy(r.boundingSphere),D_.applyMatrix4(a),pf.copy(e.ray).recast(e.near),!(D_.containsPoint(pf.origin)===!1&&(pf.intersectSphere(D_,AG)===null||pf.origin.distanceToSquared(AG)>(e.far-e.near)**2))&&(TG.copy(a).invert(),pf.copy(e.ray).applyMatrix4(TG),!(r.boundingBox!==null&&pf.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,pf)))}_computeIntersections(e,n,r){let i;const a=this.geometry,o=this.material,l=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,p=a.groups,m=a.drawRange;if(l!==null)if(Array.isArray(o))for(let x=0,b=p.length;x<b;x++){const y=p[x],v=o[y.materialIndex],S=Math.max(y.start,m.start),M=Math.min(l.count,Math.min(y.start+y.count,m.start+m.count));for(let T=S,E=M;T<E;T+=3){const C=l.getX(T),k=l.getX(T+1),R=l.getX(T+2);i=z_(this,v,e,r,u,d,f,C,k,R),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),b=Math.min(l.count,m.start+m.count);for(let y=x,v=b;y<v;y+=3){const S=l.getX(y),M=l.getX(y+1),T=l.getX(y+2);i=z_(this,o,e,r,u,d,f,S,M,T),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,b=p.length;x<b;x++){const y=p[x],v=o[y.materialIndex],S=Math.max(y.start,m.start),M=Math.min(c.count,Math.min(y.start+y.count,m.start+m.count));for(let T=S,E=M;T<E;T+=3){const C=T,k=T+1,R=T+2;i=z_(this,v,e,r,u,d,f,C,k,R),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),b=Math.min(c.count,m.start+m.count);for(let y=x,v=b;y<v;y+=3){const S=y,M=y+1,T=y+2;i=z_(this,o,e,r,u,d,f,S,M,T),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}}}function AFe(t,e,n,r,i,a,o,l){let c;if(e.side===zs?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===Th,l),c===null)return null;U_.copy(l),U_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(U_);return u<n.near||u>n.far?null:{distance:u,point:U_.clone(),object:t}}function z_(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,qp),t.getVertexPosition(c,Wp),t.getVertexPosition(u,Kp);const d=AFe(t,e,n,r,qp,Wp,Kp,I_);if(d){i&&(O_.fromBufferAttribute(i,l),L_.fromBufferAttribute(i,c),F_.fromBufferAttribute(i,u),d.uv=El.getInterpolation(I_,qp,Wp,Kp,O_,L_,F_,new xn)),a&&(O_.fromBufferAttribute(a,l),L_.fromBufferAttribute(a,c),F_.fromBufferAttribute(a,u),d.uv1=El.getInterpolation(I_,qp,Wp,Kp,O_,L_,F_,new xn),d.uv2=d.uv1),o&&(CG.fromBufferAttribute(o,l),jG.fromBufferAttribute(o,c),PG.fromBufferAttribute(o,u),d.normal=El.getInterpolation(I_,qp,Wp,Kp,CG,jG,PG,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(qp,Wp,Kp,f.normal),d.face=f}return d}class mv extends ns{constructor(e=1,n=1,r=1,i=1,a=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:o};const l=this;i=Math.floor(i),a=Math.floor(a),o=Math.floor(o);const c=[],u=[],d=[],f=[];let p=0,m=0;x("z","y","x",-1,-1,r,n,e,o,a,0),x("z","y","x",1,-1,r,n,-e,o,a,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,a,4),x("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new Ti(u,3)),this.setAttribute("normal",new Ti(d,3)),this.setAttribute("uv",new Ti(f,2));function x(b,y,v,S,M,T,E,C,k,R,A){const D=T/k,U=E/R,F=T/2,H=E/2,j=C/2,$=k+1,K=R+1;let V=0,Q=0;const Z=new qe;for(let ae=0;ae<K;ae++){const B=ae*U-H;for(let X=0;X<$;X++){const ne=X*D-F;Z[b]=ne*S,Z[y]=B*M,Z[v]=j,u.push(Z.x,Z.y,Z.z),Z[b]=0,Z[y]=0,Z[v]=C>0?1:-1,d.push(Z.x,Z.y,Z.z),f.push(X/k),f.push(1-ae/R),V+=1}}for(let ae=0;ae<R;ae++)for(let B=0;B<k;B++){const X=p+B+$*ae,ne=p+B+$*(ae+1),se=p+(B+1)+$*(ae+1),be=p+(B+1)+$*ae;c.push(X,ne,be),c.push(ne,se,be),Q+=6}l.addGroup(m,Q,A),m+=Q,p+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mv(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function ax(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 us(t){const e={};for(let n=0;n<t.length;n++){const r=ax(t[n]);for(const i in r)e[i]=r[i]}return e}function CFe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function nee(t){return t.getRenderTarget()===null?t.outputColorSpace:kr.workingColorSpace}const lL={clone:ax,merge:us};var jFe=`void main() {
  3920. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  3921. }`,PFe=`void main() {
  3922. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  3923. }`;class Ah extends Dx{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=jFe,this.fragmentShader=PFe,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=ax(e.uniforms),this.uniformsGroups=CFe(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 ree extends ps{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new zr,this.projectionMatrix=new zr,this.projectionMatrixInverse=new zr,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 oo extends ree{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=yy*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(w0*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return yy*2*Math.atan(Math.tan(w0*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,n,r,i,a,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=a,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(w0*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,a=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,u=o.fullHeight;a+=o.offsetX*i/c,n-=o.offsetY*r/u,i*=o.width/c,r*=o.height/u}const l=this.filmOffset;l!==0&&(a+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,n,n-r,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}}const Xp=-90,Yp=1;class DFe extends ps{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new oo(Xp,Yp,e,n);i.layers=this.layers,this.add(i);const a=new oo(Xp,Yp,e,n);a.layers=this.layers,this.add(a);const o=new oo(Xp,Yp,e,n);o.layers=this.layers,this.add(o);const l=new oo(Xp,Yp,e,n);l.layers=this.layers,this.add(l);const c=new oo(Xp,Yp,e,n);c.layers=this.layers,this.add(c);const u=new oo(Xp,Yp,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,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),a.up.set(0,0,-1),a.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===by)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),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[a,o,l,c,u,d]=this.children,f=e.getRenderTarget(),p=e.getActiveCubeFace(),m=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,a),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,p,m),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}}class iee extends Bs{constructor(e,n,r,i,a,o,l,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:nx,super(e,n,r,i,a,o,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class RFe extends ym{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&&(S0("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Kf?Ra:Yo),this.texture=new iee(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:Ko}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:`
  3924. varying vec3 vWorldDirection;
  3925. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  3926. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  3927. }
  3928. void main() {
  3929. vWorldDirection = transformDirection( position, modelMatrix );
  3930. #include <begin_vertex>
  3931. #include <project_vertex>
  3932. }
  3933. `,fragmentShader:`
  3934. uniform sampler2D tEquirect;
  3935. varying vec3 vWorldDirection;
  3936. #include <common>
  3937. void main() {
  3938. vec3 direction = normalize( vWorldDirection );
  3939. vec2 sampleUV = equirectUv( direction );
  3940. gl_FragColor = texture2D( tEquirect, sampleUV );
  3941. }
  3942. `},i=new mv(5,5,5),a=new Ah({name:"CubemapFromEquirect",uniforms:ax(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:zs,blending:ch});a.uniforms.tEquirect.value=n;const o=new Dl(i,a),l=n.minFilter;return n.minFilter===gy&&(n.minFilter=Ko),new DFe(1,10,this).update(e,o),n.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,n,r,i){const a=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(n,r,i);e.setRenderTarget(a)}}const qC=new qe,OFe=new qe,LFe=new Ln;class $d{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=qC.subVectors(r,n).cross(OFe.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(qC),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/i;return a<0||a>1?null:n.copy(e.start).addScaledVector(r,a)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||LFe.getNormalMatrix(e),i=this.coplanarPoint(qC).applyMatrix4(e),a=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const gf=new hc,B_=new qe;class vM{constructor(e=new $d,n=new $d,r=new $d,i=new $d,a=new $d,o=new $d){this.planes=[e,n,r,i,a,o]}set(e,n,r,i,a,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(a),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,a=i[0],o=i[1],l=i[2],c=i[3],u=i[4],d=i[5],f=i[6],p=i[7],m=i[8],x=i[9],b=i[10],y=i[11],v=i[12],S=i[13],M=i[14],T=i[15];if(r[0].setComponents(c-a,p-u,y-m,T-v).normalize(),r[1].setComponents(c+a,p+u,y+m,T+v).normalize(),r[2].setComponents(c+o,p+d,y+x,T+S).normalize(),r[3].setComponents(c-o,p-d,y-x,T-S).normalize(),r[4].setComponents(c-l,p-f,y-b,T-M).normalize(),n===cc)r[5].setComponents(c+l,p+f,y+b,T+M).normalize();else if(n===by)r[5].setComponents(l,f,b,M).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 a=0;a<6;a++)if(n[a].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(B_.x=i.normal.x>0?e.max.x:e.min.x,B_.y=i.normal.y>0?e.max.y:e.min.y,B_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(B_)<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 aee(){let t=null,e=!1,n=null,r=null;function i(a,o){n(a,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(a){n=a},setContext:function(a){t=a}}}function FFe(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const f=u.array,p=u.usage,m=f.byteLength,x=t.createBuffer();t.bindBuffer(d,x),t.bufferData(d,f,p),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:m}}function a(u,d,f){const p=d.array,m=d._updateRange,x=d.updateRanges;if(t.bindBuffer(f,u),m.count===-1&&x.length===0&&t.bufferSubData(f,0,p),x.length!==0){for(let b=0,y=x.length;b<y;b++){const v=x[b];n?t.bufferSubData(f,v.start*p.BYTES_PER_ELEMENT,p,v.start,v.count):t.bufferSubData(f,v.start*p.BYTES_PER_ELEMENT,p.subarray(v.start,v.start+v.count))}d.clearUpdateRanges()}m.count!==-1&&(n?t.bufferSubData(f,m.offset*p.BYTES_PER_ELEMENT,p,m.offset,m.count):t.bufferSubData(f,m.offset*p.BYTES_PER_ELEMENT,p.subarray(m.offset,m.offset+m.count)),m.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 p=r.get(u);(!p||p.version<u.version)&&r.set(u,{buffer:u.buffer,type:u.type,bytesPerElement:u.elementSize,version:u.version});return}u.isInterleavedBufferAttribute&&(u=u.data);const f=r.get(u);if(f===void 0)r.set(u,i(u,d));else if(f.version<u.version){if(f.size!==u.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");a(f.buffer,u,d),f.version=u.version}}return{get:o,remove:l,update:c}}class cL extends ns{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const a=e/2,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,p=n/c,m=[],x=[],b=[],y=[];for(let v=0;v<d;v++){const S=v*p-o;for(let M=0;M<u;M++){const T=M*f-a;x.push(T,-S,0),b.push(0,0,1),y.push(M/l),y.push(1-v/c)}}for(let v=0;v<c;v++)for(let S=0;S<l;S++){const M=S+u*v,T=S+u*(v+1),E=S+1+u*(v+1),C=S+1+u*v;m.push(M,T,C),m.push(T,E,C)}this.setIndex(m),this.setAttribute("position",new Ti(x,3)),this.setAttribute("normal",new Ti(b,3)),this.setAttribute("uv",new Ti(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new cL(e.width,e.height,e.widthSegments,e.heightSegments)}}var IFe=`#ifdef USE_ALPHAHASH
  3943. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  3944. #endif`,UFe=`#ifdef USE_ALPHAHASH
  3945. const float ALPHA_HASH_SCALE = 0.05;
  3946. float hash2D( vec2 value ) {
  3947. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  3948. }
  3949. float hash3D( vec3 value ) {
  3950. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  3951. }
  3952. float getAlphaHashThreshold( vec3 position ) {
  3953. float maxDeriv = max(
  3954. length( dFdx( position.xyz ) ),
  3955. length( dFdy( position.xyz ) )
  3956. );
  3957. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  3958. vec2 pixScales = vec2(
  3959. exp2( floor( log2( pixScale ) ) ),
  3960. exp2( ceil( log2( pixScale ) ) )
  3961. );
  3962. vec2 alpha = vec2(
  3963. hash3D( floor( pixScales.x * position.xyz ) ),
  3964. hash3D( floor( pixScales.y * position.xyz ) )
  3965. );
  3966. float lerpFactor = fract( log2( pixScale ) );
  3967. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  3968. float a = min( lerpFactor, 1.0 - lerpFactor );
  3969. vec3 cases = vec3(
  3970. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  3971. ( x - 0.5 * a ) / ( 1.0 - a ),
  3972. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  3973. );
  3974. float threshold = ( x < ( 1.0 - a ) )
  3975. ? ( ( x < a ) ? cases.x : cases.y )
  3976. : cases.z;
  3977. return clamp( threshold , 1.0e-6, 1.0 );
  3978. }
  3979. #endif`,zFe=`#ifdef USE_ALPHAMAP
  3980. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  3981. #endif`,BFe=`#ifdef USE_ALPHAMAP
  3982. uniform sampler2D alphaMap;
  3983. #endif`,$Fe=`#ifdef USE_ALPHATEST
  3984. if ( diffuseColor.a < alphaTest ) discard;
  3985. #endif`,HFe=`#ifdef USE_ALPHATEST
  3986. uniform float alphaTest;
  3987. #endif`,VFe=`#ifdef USE_AOMAP
  3988. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  3989. reflectedLight.indirectDiffuse *= ambientOcclusion;
  3990. #if defined( USE_CLEARCOAT )
  3991. clearcoatSpecularIndirect *= ambientOcclusion;
  3992. #endif
  3993. #if defined( USE_SHEEN )
  3994. sheenSpecularIndirect *= ambientOcclusion;
  3995. #endif
  3996. #if defined( USE_ENVMAP ) && defined( STANDARD )
  3997. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  3998. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  3999. #endif
  4000. #endif`,GFe=`#ifdef USE_AOMAP
  4001. uniform sampler2D aoMap;
  4002. uniform float aoMapIntensity;
  4003. #endif`,qFe=`#ifdef USE_BATCHING
  4004. attribute float batchId;
  4005. uniform highp sampler2D batchingTexture;
  4006. mat4 getBatchingMatrix( const in float i ) {
  4007. int size = textureSize( batchingTexture, 0 ).x;
  4008. int j = int( i ) * 4;
  4009. int x = j % size;
  4010. int y = j / size;
  4011. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  4012. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  4013. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  4014. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  4015. return mat4( v1, v2, v3, v4 );
  4016. }
  4017. #endif`,WFe=`#ifdef USE_BATCHING
  4018. mat4 batchingMatrix = getBatchingMatrix( batchId );
  4019. #endif`,KFe=`vec3 transformed = vec3( position );
  4020. #ifdef USE_ALPHAHASH
  4021. vPosition = vec3( position );
  4022. #endif`,XFe=`vec3 objectNormal = vec3( normal );
  4023. #ifdef USE_TANGENT
  4024. vec3 objectTangent = vec3( tangent.xyz );
  4025. #endif`,YFe=`float G_BlinnPhong_Implicit( ) {
  4026. return 0.25;
  4027. }
  4028. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  4029. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  4030. }
  4031. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  4032. vec3 halfDir = normalize( lightDir + viewDir );
  4033. float dotNH = saturate( dot( normal, halfDir ) );
  4034. float dotVH = saturate( dot( viewDir, halfDir ) );
  4035. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  4036. float G = G_BlinnPhong_Implicit( );
  4037. float D = D_BlinnPhong( shininess, dotNH );
  4038. return F * ( G * D );
  4039. } // validated`,QFe=`#ifdef USE_IRIDESCENCE
  4040. const mat3 XYZ_TO_REC709 = mat3(
  4041. 3.2404542, -0.9692660, 0.0556434,
  4042. -1.5371385, 1.8760108, -0.2040259,
  4043. -0.4985314, 0.0415560, 1.0572252
  4044. );
  4045. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  4046. vec3 sqrtF0 = sqrt( fresnel0 );
  4047. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  4048. }
  4049. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  4050. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  4051. }
  4052. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  4053. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  4054. }
  4055. vec3 evalSensitivity( float OPD, vec3 shift ) {
  4056. float phase = 2.0 * PI * OPD * 1.0e-9;
  4057. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  4058. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  4059. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  4060. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  4061. 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 ) );
  4062. xyz /= 1.0685e-7;
  4063. vec3 rgb = XYZ_TO_REC709 * xyz;
  4064. return rgb;
  4065. }
  4066. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  4067. vec3 I;
  4068. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  4069. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  4070. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  4071. if ( cosTheta2Sq < 0.0 ) {
  4072. return vec3( 1.0 );
  4073. }
  4074. float cosTheta2 = sqrt( cosTheta2Sq );
  4075. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  4076. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  4077. float T121 = 1.0 - R12;
  4078. float phi12 = 0.0;
  4079. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  4080. float phi21 = PI - phi12;
  4081. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  4082. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  4083. vec3 phi23 = vec3( 0.0 );
  4084. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  4085. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  4086. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  4087. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  4088. vec3 phi = vec3( phi21 ) + phi23;
  4089. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  4090. vec3 r123 = sqrt( R123 );
  4091. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  4092. vec3 C0 = R12 + Rs;
  4093. I = C0;
  4094. vec3 Cm = Rs - T121;
  4095. for ( int m = 1; m <= 2; ++ m ) {
  4096. Cm *= r123;
  4097. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  4098. I += Cm * Sm;
  4099. }
  4100. return max( I, vec3( 0.0 ) );
  4101. }
  4102. #endif`,ZFe=`#ifdef USE_BUMPMAP
  4103. uniform sampler2D bumpMap;
  4104. uniform float bumpScale;
  4105. vec2 dHdxy_fwd() {
  4106. vec2 dSTdx = dFdx( vBumpMapUv );
  4107. vec2 dSTdy = dFdy( vBumpMapUv );
  4108. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  4109. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  4110. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  4111. return vec2( dBx, dBy );
  4112. }
  4113. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  4114. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  4115. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  4116. vec3 vN = surf_norm;
  4117. vec3 R1 = cross( vSigmaY, vN );
  4118. vec3 R2 = cross( vN, vSigmaX );
  4119. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  4120. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  4121. return normalize( abs( fDet ) * surf_norm - vGrad );
  4122. }
  4123. #endif`,JFe=`#if NUM_CLIPPING_PLANES > 0
  4124. vec4 plane;
  4125. #pragma unroll_loop_start
  4126. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  4127. plane = clippingPlanes[ i ];
  4128. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  4129. }
  4130. #pragma unroll_loop_end
  4131. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  4132. bool clipped = true;
  4133. #pragma unroll_loop_start
  4134. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  4135. plane = clippingPlanes[ i ];
  4136. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  4137. }
  4138. #pragma unroll_loop_end
  4139. if ( clipped ) discard;
  4140. #endif
  4141. #endif`,eIe=`#if NUM_CLIPPING_PLANES > 0
  4142. varying vec3 vClipPosition;
  4143. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  4144. #endif`,tIe=`#if NUM_CLIPPING_PLANES > 0
  4145. varying vec3 vClipPosition;
  4146. #endif`,nIe=`#if NUM_CLIPPING_PLANES > 0
  4147. vClipPosition = - mvPosition.xyz;
  4148. #endif`,rIe=`#if defined( USE_COLOR_ALPHA )
  4149. diffuseColor *= vColor;
  4150. #elif defined( USE_COLOR )
  4151. diffuseColor.rgb *= vColor;
  4152. #endif`,iIe=`#if defined( USE_COLOR_ALPHA )
  4153. varying vec4 vColor;
  4154. #elif defined( USE_COLOR )
  4155. varying vec3 vColor;
  4156. #endif`,aIe=`#if defined( USE_COLOR_ALPHA )
  4157. varying vec4 vColor;
  4158. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4159. varying vec3 vColor;
  4160. #endif`,sIe=`#if defined( USE_COLOR_ALPHA )
  4161. vColor = vec4( 1.0 );
  4162. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4163. vColor = vec3( 1.0 );
  4164. #endif
  4165. #ifdef USE_COLOR
  4166. vColor *= color;
  4167. #endif
  4168. #ifdef USE_INSTANCING_COLOR
  4169. vColor.xyz *= instanceColor.xyz;
  4170. #endif`,oIe=`#define PI 3.141592653589793
  4171. #define PI2 6.283185307179586
  4172. #define PI_HALF 1.5707963267948966
  4173. #define RECIPROCAL_PI 0.3183098861837907
  4174. #define RECIPROCAL_PI2 0.15915494309189535
  4175. #define EPSILON 1e-6
  4176. #ifndef saturate
  4177. #define saturate( a ) clamp( a, 0.0, 1.0 )
  4178. #endif
  4179. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  4180. float pow2( const in float x ) { return x*x; }
  4181. vec3 pow2( const in vec3 x ) { return x*x; }
  4182. float pow3( const in float x ) { return x*x*x; }
  4183. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  4184. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  4185. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  4186. highp float rand( const in vec2 uv ) {
  4187. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  4188. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  4189. return fract( sin( sn ) * c );
  4190. }
  4191. #ifdef HIGH_PRECISION
  4192. float precisionSafeLength( vec3 v ) { return length( v ); }
  4193. #else
  4194. float precisionSafeLength( vec3 v ) {
  4195. float maxComponent = max3( abs( v ) );
  4196. return length( v / maxComponent ) * maxComponent;
  4197. }
  4198. #endif
  4199. struct IncidentLight {
  4200. vec3 color;
  4201. vec3 direction;
  4202. bool visible;
  4203. };
  4204. struct ReflectedLight {
  4205. vec3 directDiffuse;
  4206. vec3 directSpecular;
  4207. vec3 indirectDiffuse;
  4208. vec3 indirectSpecular;
  4209. };
  4210. #ifdef USE_ALPHAHASH
  4211. varying vec3 vPosition;
  4212. #endif
  4213. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  4214. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  4215. }
  4216. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  4217. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  4218. }
  4219. mat3 transposeMat3( const in mat3 m ) {
  4220. mat3 tmp;
  4221. tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
  4222. tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
  4223. tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
  4224. return tmp;
  4225. }
  4226. float luminance( const in vec3 rgb ) {
  4227. const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
  4228. return dot( weights, rgb );
  4229. }
  4230. bool isPerspectiveMatrix( mat4 m ) {
  4231. return m[ 2 ][ 3 ] == - 1.0;
  4232. }
  4233. vec2 equirectUv( in vec3 dir ) {
  4234. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  4235. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  4236. return vec2( u, v );
  4237. }
  4238. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  4239. return RECIPROCAL_PI * diffuseColor;
  4240. }
  4241. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  4242. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4243. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4244. }
  4245. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  4246. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4247. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4248. } // validated`,lIe=`#ifdef ENVMAP_TYPE_CUBE_UV
  4249. #define cubeUV_minMipLevel 4.0
  4250. #define cubeUV_minTileSize 16.0
  4251. float getFace( vec3 direction ) {
  4252. vec3 absDirection = abs( direction );
  4253. float face = - 1.0;
  4254. if ( absDirection.x > absDirection.z ) {
  4255. if ( absDirection.x > absDirection.y )
  4256. face = direction.x > 0.0 ? 0.0 : 3.0;
  4257. else
  4258. face = direction.y > 0.0 ? 1.0 : 4.0;
  4259. } else {
  4260. if ( absDirection.z > absDirection.y )
  4261. face = direction.z > 0.0 ? 2.0 : 5.0;
  4262. else
  4263. face = direction.y > 0.0 ? 1.0 : 4.0;
  4264. }
  4265. return face;
  4266. }
  4267. vec2 getUV( vec3 direction, float face ) {
  4268. vec2 uv;
  4269. if ( face == 0.0 ) {
  4270. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  4271. } else if ( face == 1.0 ) {
  4272. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  4273. } else if ( face == 2.0 ) {
  4274. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  4275. } else if ( face == 3.0 ) {
  4276. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  4277. } else if ( face == 4.0 ) {
  4278. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  4279. } else {
  4280. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  4281. }
  4282. return 0.5 * ( uv + 1.0 );
  4283. }
  4284. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  4285. float face = getFace( direction );
  4286. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  4287. mipInt = max( mipInt, cubeUV_minMipLevel );
  4288. float faceSize = exp2( mipInt );
  4289. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  4290. if ( face > 2.0 ) {
  4291. uv.y += faceSize;
  4292. face -= 3.0;
  4293. }
  4294. uv.x += face * faceSize;
  4295. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  4296. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  4297. uv.x *= CUBEUV_TEXEL_WIDTH;
  4298. uv.y *= CUBEUV_TEXEL_HEIGHT;
  4299. #ifdef texture2DGradEXT
  4300. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  4301. #else
  4302. return texture2D( envMap, uv ).rgb;
  4303. #endif
  4304. }
  4305. #define cubeUV_r0 1.0
  4306. #define cubeUV_v0 0.339
  4307. #define cubeUV_m0 - 2.0
  4308. #define cubeUV_r1 0.8
  4309. #define cubeUV_v1 0.276
  4310. #define cubeUV_m1 - 1.0
  4311. #define cubeUV_r4 0.4
  4312. #define cubeUV_v4 0.046
  4313. #define cubeUV_m4 2.0
  4314. #define cubeUV_r5 0.305
  4315. #define cubeUV_v5 0.016
  4316. #define cubeUV_m5 3.0
  4317. #define cubeUV_r6 0.21
  4318. #define cubeUV_v6 0.0038
  4319. #define cubeUV_m6 4.0
  4320. float roughnessToMip( float roughness ) {
  4321. float mip = 0.0;
  4322. if ( roughness >= cubeUV_r1 ) {
  4323. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  4324. } else if ( roughness >= cubeUV_r4 ) {
  4325. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  4326. } else if ( roughness >= cubeUV_r5 ) {
  4327. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  4328. } else if ( roughness >= cubeUV_r6 ) {
  4329. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  4330. } else {
  4331. mip = - 2.0 * log2( 1.16 * roughness ); }
  4332. return mip;
  4333. }
  4334. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  4335. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  4336. float mipF = fract( mip );
  4337. float mipInt = floor( mip );
  4338. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  4339. if ( mipF == 0.0 ) {
  4340. return vec4( color0, 1.0 );
  4341. } else {
  4342. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  4343. return vec4( mix( color0, color1, mipF ), 1.0 );
  4344. }
  4345. }
  4346. #endif`,cIe=`vec3 transformedNormal = objectNormal;
  4347. #ifdef USE_TANGENT
  4348. vec3 transformedTangent = objectTangent;
  4349. #endif
  4350. #ifdef USE_BATCHING
  4351. mat3 bm = mat3( batchingMatrix );
  4352. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  4353. transformedNormal = bm * transformedNormal;
  4354. #ifdef USE_TANGENT
  4355. transformedTangent = bm * transformedTangent;
  4356. #endif
  4357. #endif
  4358. #ifdef USE_INSTANCING
  4359. mat3 im = mat3( instanceMatrix );
  4360. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  4361. transformedNormal = im * transformedNormal;
  4362. #ifdef USE_TANGENT
  4363. transformedTangent = im * transformedTangent;
  4364. #endif
  4365. #endif
  4366. transformedNormal = normalMatrix * transformedNormal;
  4367. #ifdef FLIP_SIDED
  4368. transformedNormal = - transformedNormal;
  4369. #endif
  4370. #ifdef USE_TANGENT
  4371. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  4372. #ifdef FLIP_SIDED
  4373. transformedTangent = - transformedTangent;
  4374. #endif
  4375. #endif`,uIe=`#ifdef USE_DISPLACEMENTMAP
  4376. uniform sampler2D displacementMap;
  4377. uniform float displacementScale;
  4378. uniform float displacementBias;
  4379. #endif`,dIe=`#ifdef USE_DISPLACEMENTMAP
  4380. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  4381. #endif`,hIe=`#ifdef USE_EMISSIVEMAP
  4382. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  4383. totalEmissiveRadiance *= emissiveColor.rgb;
  4384. #endif`,fIe=`#ifdef USE_EMISSIVEMAP
  4385. uniform sampler2D emissiveMap;
  4386. #endif`,mIe="gl_FragColor = linearToOutputTexel( gl_FragColor );",pIe=`
  4387. const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
  4388. vec3( 0.8224621, 0.177538, 0.0 ),
  4389. vec3( 0.0331941, 0.9668058, 0.0 ),
  4390. vec3( 0.0170827, 0.0723974, 0.9105199 )
  4391. );
  4392. const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
  4393. vec3( 1.2249401, - 0.2249404, 0.0 ),
  4394. vec3( - 0.0420569, 1.0420571, 0.0 ),
  4395. vec3( - 0.0196376, - 0.0786361, 1.0982735 )
  4396. );
  4397. vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
  4398. return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
  4399. }
  4400. vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
  4401. return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
  4402. }
  4403. vec4 LinearTransferOETF( in vec4 value ) {
  4404. return value;
  4405. }
  4406. vec4 sRGBTransferOETF( in vec4 value ) {
  4407. 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 );
  4408. }
  4409. vec4 LinearToLinear( in vec4 value ) {
  4410. return value;
  4411. }
  4412. vec4 LinearTosRGB( in vec4 value ) {
  4413. return sRGBTransferOETF( value );
  4414. }`,gIe=`#ifdef USE_ENVMAP
  4415. #ifdef ENV_WORLDPOS
  4416. vec3 cameraToFrag;
  4417. if ( isOrthographic ) {
  4418. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4419. } else {
  4420. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  4421. }
  4422. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4423. #ifdef ENVMAP_MODE_REFLECTION
  4424. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  4425. #else
  4426. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  4427. #endif
  4428. #else
  4429. vec3 reflectVec = vReflect;
  4430. #endif
  4431. #ifdef ENVMAP_TYPE_CUBE
  4432. vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  4433. #else
  4434. vec4 envColor = vec4( 0.0 );
  4435. #endif
  4436. #ifdef ENVMAP_BLENDING_MULTIPLY
  4437. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  4438. #elif defined( ENVMAP_BLENDING_MIX )
  4439. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  4440. #elif defined( ENVMAP_BLENDING_ADD )
  4441. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  4442. #endif
  4443. #endif`,xIe=`#ifdef USE_ENVMAP
  4444. uniform float envMapIntensity;
  4445. uniform float flipEnvMap;
  4446. #ifdef ENVMAP_TYPE_CUBE
  4447. uniform samplerCube envMap;
  4448. #else
  4449. uniform sampler2D envMap;
  4450. #endif
  4451. #endif`,bIe=`#ifdef USE_ENVMAP
  4452. uniform float reflectivity;
  4453. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4454. #define ENV_WORLDPOS
  4455. #endif
  4456. #ifdef ENV_WORLDPOS
  4457. varying vec3 vWorldPosition;
  4458. uniform float refractionRatio;
  4459. #else
  4460. varying vec3 vReflect;
  4461. #endif
  4462. #endif`,yIe=`#ifdef USE_ENVMAP
  4463. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4464. #define ENV_WORLDPOS
  4465. #endif
  4466. #ifdef ENV_WORLDPOS
  4467. varying vec3 vWorldPosition;
  4468. #else
  4469. varying vec3 vReflect;
  4470. uniform float refractionRatio;
  4471. #endif
  4472. #endif`,vIe=`#ifdef USE_ENVMAP
  4473. #ifdef ENV_WORLDPOS
  4474. vWorldPosition = worldPosition.xyz;
  4475. #else
  4476. vec3 cameraToVertex;
  4477. if ( isOrthographic ) {
  4478. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4479. } else {
  4480. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  4481. }
  4482. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  4483. #ifdef ENVMAP_MODE_REFLECTION
  4484. vReflect = reflect( cameraToVertex, worldNormal );
  4485. #else
  4486. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  4487. #endif
  4488. #endif
  4489. #endif`,wIe=`#ifdef USE_FOG
  4490. vFogDepth = - mvPosition.z;
  4491. #endif`,_Ie=`#ifdef USE_FOG
  4492. varying float vFogDepth;
  4493. #endif`,SIe=`#ifdef USE_FOG
  4494. #ifdef FOG_EXP2
  4495. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  4496. #else
  4497. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  4498. #endif
  4499. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  4500. #endif`,NIe=`#ifdef USE_FOG
  4501. uniform vec3 fogColor;
  4502. varying float vFogDepth;
  4503. #ifdef FOG_EXP2
  4504. uniform float fogDensity;
  4505. #else
  4506. uniform float fogNear;
  4507. uniform float fogFar;
  4508. #endif
  4509. #endif`,MIe=`#ifdef USE_GRADIENTMAP
  4510. uniform sampler2D gradientMap;
  4511. #endif
  4512. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  4513. float dotNL = dot( normal, lightDirection );
  4514. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  4515. #ifdef USE_GRADIENTMAP
  4516. return vec3( texture2D( gradientMap, coord ).r );
  4517. #else
  4518. vec2 fw = fwidth( coord ) * 0.5;
  4519. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  4520. #endif
  4521. }`,EIe=`#ifdef USE_LIGHTMAP
  4522. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  4523. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  4524. reflectedLight.indirectDiffuse += lightMapIrradiance;
  4525. #endif`,kIe=`#ifdef USE_LIGHTMAP
  4526. uniform sampler2D lightMap;
  4527. uniform float lightMapIntensity;
  4528. #endif`,TIe=`LambertMaterial material;
  4529. material.diffuseColor = diffuseColor.rgb;
  4530. material.specularStrength = specularStrength;`,AIe=`varying vec3 vViewPosition;
  4531. struct LambertMaterial {
  4532. vec3 diffuseColor;
  4533. float specularStrength;
  4534. };
  4535. 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 ) {
  4536. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4537. vec3 irradiance = dotNL * directLight.color;
  4538. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4539. }
  4540. 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 ) {
  4541. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4542. }
  4543. #define RE_Direct RE_Direct_Lambert
  4544. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,CIe=`uniform bool receiveShadow;
  4545. uniform vec3 ambientLightColor;
  4546. #if defined( USE_LIGHT_PROBES )
  4547. uniform vec3 lightProbe[ 9 ];
  4548. #endif
  4549. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  4550. float x = normal.x, y = normal.y, z = normal.z;
  4551. vec3 result = shCoefficients[ 0 ] * 0.886227;
  4552. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  4553. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  4554. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  4555. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  4556. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  4557. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  4558. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  4559. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  4560. return result;
  4561. }
  4562. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  4563. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4564. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  4565. return irradiance;
  4566. }
  4567. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  4568. vec3 irradiance = ambientLightColor;
  4569. return irradiance;
  4570. }
  4571. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  4572. #if defined ( LEGACY_LIGHTS )
  4573. if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
  4574. return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
  4575. }
  4576. return 1.0;
  4577. #else
  4578. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  4579. if ( cutoffDistance > 0.0 ) {
  4580. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  4581. }
  4582. return distanceFalloff;
  4583. #endif
  4584. }
  4585. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  4586. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  4587. }
  4588. #if NUM_DIR_LIGHTS > 0
  4589. struct DirectionalLight {
  4590. vec3 direction;
  4591. vec3 color;
  4592. };
  4593. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  4594. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  4595. light.color = directionalLight.color;
  4596. light.direction = directionalLight.direction;
  4597. light.visible = true;
  4598. }
  4599. #endif
  4600. #if NUM_POINT_LIGHTS > 0
  4601. struct PointLight {
  4602. vec3 position;
  4603. vec3 color;
  4604. float distance;
  4605. float decay;
  4606. };
  4607. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  4608. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4609. vec3 lVector = pointLight.position - geometryPosition;
  4610. light.direction = normalize( lVector );
  4611. float lightDistance = length( lVector );
  4612. light.color = pointLight.color;
  4613. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  4614. light.visible = ( light.color != vec3( 0.0 ) );
  4615. }
  4616. #endif
  4617. #if NUM_SPOT_LIGHTS > 0
  4618. struct SpotLight {
  4619. vec3 position;
  4620. vec3 direction;
  4621. vec3 color;
  4622. float distance;
  4623. float decay;
  4624. float coneCos;
  4625. float penumbraCos;
  4626. };
  4627. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  4628. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4629. vec3 lVector = spotLight.position - geometryPosition;
  4630. light.direction = normalize( lVector );
  4631. float angleCos = dot( light.direction, spotLight.direction );
  4632. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  4633. if ( spotAttenuation > 0.0 ) {
  4634. float lightDistance = length( lVector );
  4635. light.color = spotLight.color * spotAttenuation;
  4636. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  4637. light.visible = ( light.color != vec3( 0.0 ) );
  4638. } else {
  4639. light.color = vec3( 0.0 );
  4640. light.visible = false;
  4641. }
  4642. }
  4643. #endif
  4644. #if NUM_RECT_AREA_LIGHTS > 0
  4645. struct RectAreaLight {
  4646. vec3 color;
  4647. vec3 position;
  4648. vec3 halfWidth;
  4649. vec3 halfHeight;
  4650. };
  4651. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  4652. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  4653. #endif
  4654. #if NUM_HEMI_LIGHTS > 0
  4655. struct HemisphereLight {
  4656. vec3 direction;
  4657. vec3 skyColor;
  4658. vec3 groundColor;
  4659. };
  4660. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  4661. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  4662. float dotNL = dot( normal, hemiLight.direction );
  4663. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  4664. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  4665. return irradiance;
  4666. }
  4667. #endif`,jIe=`#ifdef USE_ENVMAP
  4668. vec3 getIBLIrradiance( const in vec3 normal ) {
  4669. #ifdef ENVMAP_TYPE_CUBE_UV
  4670. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4671. vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
  4672. return PI * envMapColor.rgb * envMapIntensity;
  4673. #else
  4674. return vec3( 0.0 );
  4675. #endif
  4676. }
  4677. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  4678. #ifdef ENVMAP_TYPE_CUBE_UV
  4679. vec3 reflectVec = reflect( - viewDir, normal );
  4680. reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
  4681. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  4682. vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
  4683. return envMapColor.rgb * envMapIntensity;
  4684. #else
  4685. return vec3( 0.0 );
  4686. #endif
  4687. }
  4688. #ifdef USE_ANISOTROPY
  4689. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  4690. #ifdef ENVMAP_TYPE_CUBE_UV
  4691. vec3 bentNormal = cross( bitangent, viewDir );
  4692. bentNormal = normalize( cross( bentNormal, bitangent ) );
  4693. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  4694. return getIBLRadiance( viewDir, bentNormal, roughness );
  4695. #else
  4696. return vec3( 0.0 );
  4697. #endif
  4698. }
  4699. #endif
  4700. #endif`,PIe=`ToonMaterial material;
  4701. material.diffuseColor = diffuseColor.rgb;`,DIe=`varying vec3 vViewPosition;
  4702. struct ToonMaterial {
  4703. vec3 diffuseColor;
  4704. };
  4705. 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 ) {
  4706. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  4707. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4708. }
  4709. 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 ) {
  4710. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4711. }
  4712. #define RE_Direct RE_Direct_Toon
  4713. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,RIe=`BlinnPhongMaterial material;
  4714. material.diffuseColor = diffuseColor.rgb;
  4715. material.specularColor = specular;
  4716. material.specularShininess = shininess;
  4717. material.specularStrength = specularStrength;`,OIe=`varying vec3 vViewPosition;
  4718. struct BlinnPhongMaterial {
  4719. vec3 diffuseColor;
  4720. vec3 specularColor;
  4721. float specularShininess;
  4722. float specularStrength;
  4723. };
  4724. 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 ) {
  4725. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4726. vec3 irradiance = dotNL * directLight.color;
  4727. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4728. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  4729. }
  4730. 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 ) {
  4731. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4732. }
  4733. #define RE_Direct RE_Direct_BlinnPhong
  4734. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,LIe=`PhysicalMaterial material;
  4735. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  4736. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  4737. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  4738. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  4739. material.roughness = min( material.roughness, 1.0 );
  4740. #ifdef IOR
  4741. material.ior = ior;
  4742. #ifdef USE_SPECULAR
  4743. float specularIntensityFactor = specularIntensity;
  4744. vec3 specularColorFactor = specularColor;
  4745. #ifdef USE_SPECULAR_COLORMAP
  4746. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  4747. #endif
  4748. #ifdef USE_SPECULAR_INTENSITYMAP
  4749. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  4750. #endif
  4751. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  4752. #else
  4753. float specularIntensityFactor = 1.0;
  4754. vec3 specularColorFactor = vec3( 1.0 );
  4755. material.specularF90 = 1.0;
  4756. #endif
  4757. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  4758. #else
  4759. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  4760. material.specularF90 = 1.0;
  4761. #endif
  4762. #ifdef USE_CLEARCOAT
  4763. material.clearcoat = clearcoat;
  4764. material.clearcoatRoughness = clearcoatRoughness;
  4765. material.clearcoatF0 = vec3( 0.04 );
  4766. material.clearcoatF90 = 1.0;
  4767. #ifdef USE_CLEARCOATMAP
  4768. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  4769. #endif
  4770. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  4771. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  4772. #endif
  4773. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  4774. material.clearcoatRoughness += geometryRoughness;
  4775. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  4776. #endif
  4777. #ifdef USE_IRIDESCENCE
  4778. material.iridescence = iridescence;
  4779. material.iridescenceIOR = iridescenceIOR;
  4780. #ifdef USE_IRIDESCENCEMAP
  4781. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  4782. #endif
  4783. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  4784. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  4785. #else
  4786. material.iridescenceThickness = iridescenceThicknessMaximum;
  4787. #endif
  4788. #endif
  4789. #ifdef USE_SHEEN
  4790. material.sheenColor = sheenColor;
  4791. #ifdef USE_SHEEN_COLORMAP
  4792. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  4793. #endif
  4794. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  4795. #ifdef USE_SHEEN_ROUGHNESSMAP
  4796. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  4797. #endif
  4798. #endif
  4799. #ifdef USE_ANISOTROPY
  4800. #ifdef USE_ANISOTROPYMAP
  4801. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  4802. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  4803. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  4804. #else
  4805. vec2 anisotropyV = anisotropyVector;
  4806. #endif
  4807. material.anisotropy = length( anisotropyV );
  4808. if( material.anisotropy == 0.0 ) {
  4809. anisotropyV = vec2( 1.0, 0.0 );
  4810. } else {
  4811. anisotropyV /= material.anisotropy;
  4812. material.anisotropy = saturate( material.anisotropy );
  4813. }
  4814. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  4815. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  4816. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  4817. #endif`,FIe=`struct PhysicalMaterial {
  4818. vec3 diffuseColor;
  4819. float roughness;
  4820. vec3 specularColor;
  4821. float specularF90;
  4822. #ifdef USE_CLEARCOAT
  4823. float clearcoat;
  4824. float clearcoatRoughness;
  4825. vec3 clearcoatF0;
  4826. float clearcoatF90;
  4827. #endif
  4828. #ifdef USE_IRIDESCENCE
  4829. float iridescence;
  4830. float iridescenceIOR;
  4831. float iridescenceThickness;
  4832. vec3 iridescenceFresnel;
  4833. vec3 iridescenceF0;
  4834. #endif
  4835. #ifdef USE_SHEEN
  4836. vec3 sheenColor;
  4837. float sheenRoughness;
  4838. #endif
  4839. #ifdef IOR
  4840. float ior;
  4841. #endif
  4842. #ifdef USE_TRANSMISSION
  4843. float transmission;
  4844. float transmissionAlpha;
  4845. float thickness;
  4846. float attenuationDistance;
  4847. vec3 attenuationColor;
  4848. #endif
  4849. #ifdef USE_ANISOTROPY
  4850. float anisotropy;
  4851. float alphaT;
  4852. vec3 anisotropyT;
  4853. vec3 anisotropyB;
  4854. #endif
  4855. };
  4856. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  4857. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  4858. vec3 sheenSpecularDirect = vec3( 0.0 );
  4859. vec3 sheenSpecularIndirect = vec3(0.0 );
  4860. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  4861. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  4862. float x2 = x * x;
  4863. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  4864. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  4865. }
  4866. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  4867. float a2 = pow2( alpha );
  4868. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  4869. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  4870. return 0.5 / max( gv + gl, EPSILON );
  4871. }
  4872. float D_GGX( const in float alpha, const in float dotNH ) {
  4873. float a2 = pow2( alpha );
  4874. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  4875. return RECIPROCAL_PI * a2 / pow2( denom );
  4876. }
  4877. #ifdef USE_ANISOTROPY
  4878. 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 ) {
  4879. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  4880. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  4881. float v = 0.5 / ( gv + gl );
  4882. return saturate(v);
  4883. }
  4884. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  4885. float a2 = alphaT * alphaB;
  4886. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  4887. highp float v2 = dot( v, v );
  4888. float w2 = a2 / v2;
  4889. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  4890. }
  4891. #endif
  4892. #ifdef USE_CLEARCOAT
  4893. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  4894. vec3 f0 = material.clearcoatF0;
  4895. float f90 = material.clearcoatF90;
  4896. float roughness = material.clearcoatRoughness;
  4897. float alpha = pow2( roughness );
  4898. vec3 halfDir = normalize( lightDir + viewDir );
  4899. float dotNL = saturate( dot( normal, lightDir ) );
  4900. float dotNV = saturate( dot( normal, viewDir ) );
  4901. float dotNH = saturate( dot( normal, halfDir ) );
  4902. float dotVH = saturate( dot( viewDir, halfDir ) );
  4903. vec3 F = F_Schlick( f0, f90, dotVH );
  4904. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4905. float D = D_GGX( alpha, dotNH );
  4906. return F * ( V * D );
  4907. }
  4908. #endif
  4909. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  4910. vec3 f0 = material.specularColor;
  4911. float f90 = material.specularF90;
  4912. float roughness = material.roughness;
  4913. float alpha = pow2( roughness );
  4914. vec3 halfDir = normalize( lightDir + viewDir );
  4915. float dotNL = saturate( dot( normal, lightDir ) );
  4916. float dotNV = saturate( dot( normal, viewDir ) );
  4917. float dotNH = saturate( dot( normal, halfDir ) );
  4918. float dotVH = saturate( dot( viewDir, halfDir ) );
  4919. vec3 F = F_Schlick( f0, f90, dotVH );
  4920. #ifdef USE_IRIDESCENCE
  4921. F = mix( F, material.iridescenceFresnel, material.iridescence );
  4922. #endif
  4923. #ifdef USE_ANISOTROPY
  4924. float dotTL = dot( material.anisotropyT, lightDir );
  4925. float dotTV = dot( material.anisotropyT, viewDir );
  4926. float dotTH = dot( material.anisotropyT, halfDir );
  4927. float dotBL = dot( material.anisotropyB, lightDir );
  4928. float dotBV = dot( material.anisotropyB, viewDir );
  4929. float dotBH = dot( material.anisotropyB, halfDir );
  4930. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  4931. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  4932. #else
  4933. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4934. float D = D_GGX( alpha, dotNH );
  4935. #endif
  4936. return F * ( V * D );
  4937. }
  4938. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  4939. const float LUT_SIZE = 64.0;
  4940. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  4941. const float LUT_BIAS = 0.5 / LUT_SIZE;
  4942. float dotNV = saturate( dot( N, V ) );
  4943. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  4944. uv = uv * LUT_SCALE + LUT_BIAS;
  4945. return uv;
  4946. }
  4947. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  4948. float l = length( f );
  4949. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  4950. }
  4951. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  4952. float x = dot( v1, v2 );
  4953. float y = abs( x );
  4954. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  4955. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  4956. float v = a / b;
  4957. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  4958. return cross( v1, v2 ) * theta_sintheta;
  4959. }
  4960. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  4961. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  4962. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  4963. vec3 lightNormal = cross( v1, v2 );
  4964. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  4965. vec3 T1, T2;
  4966. T1 = normalize( V - N * dot( V, N ) );
  4967. T2 = - cross( N, T1 );
  4968. mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
  4969. vec3 coords[ 4 ];
  4970. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  4971. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  4972. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  4973. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  4974. coords[ 0 ] = normalize( coords[ 0 ] );
  4975. coords[ 1 ] = normalize( coords[ 1 ] );
  4976. coords[ 2 ] = normalize( coords[ 2 ] );
  4977. coords[ 3 ] = normalize( coords[ 3 ] );
  4978. vec3 vectorFormFactor = vec3( 0.0 );
  4979. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  4980. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  4981. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  4982. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  4983. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  4984. return vec3( result );
  4985. }
  4986. #if defined( USE_SHEEN )
  4987. float D_Charlie( float roughness, float dotNH ) {
  4988. float alpha = pow2( roughness );
  4989. float invAlpha = 1.0 / alpha;
  4990. float cos2h = dotNH * dotNH;
  4991. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  4992. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  4993. }
  4994. float V_Neubelt( float dotNV, float dotNL ) {
  4995. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  4996. }
  4997. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  4998. vec3 halfDir = normalize( lightDir + viewDir );
  4999. float dotNL = saturate( dot( normal, lightDir ) );
  5000. float dotNV = saturate( dot( normal, viewDir ) );
  5001. float dotNH = saturate( dot( normal, halfDir ) );
  5002. float D = D_Charlie( sheenRoughness, dotNH );
  5003. float V = V_Neubelt( dotNV, dotNL );
  5004. return sheenColor * ( D * V );
  5005. }
  5006. #endif
  5007. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  5008. float dotNV = saturate( dot( normal, viewDir ) );
  5009. float r2 = roughness * roughness;
  5010. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  5011. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  5012. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  5013. return saturate( DG * RECIPROCAL_PI );
  5014. }
  5015. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  5016. float dotNV = saturate( dot( normal, viewDir ) );
  5017. const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
  5018. const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
  5019. vec4 r = roughness * c0 + c1;
  5020. float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
  5021. vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
  5022. return fab;
  5023. }
  5024. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  5025. vec2 fab = DFGApprox( normal, viewDir, roughness );
  5026. return specularColor * fab.x + specularF90 * fab.y;
  5027. }
  5028. #ifdef USE_IRIDESCENCE
  5029. 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 ) {
  5030. #else
  5031. 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 ) {
  5032. #endif
  5033. vec2 fab = DFGApprox( normal, viewDir, roughness );
  5034. #ifdef USE_IRIDESCENCE
  5035. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  5036. #else
  5037. vec3 Fr = specularColor;
  5038. #endif
  5039. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  5040. float Ess = fab.x + fab.y;
  5041. float Ems = 1.0 - Ess;
  5042. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  5043. singleScatter += FssEss;
  5044. multiScatter += Fms * Ems;
  5045. }
  5046. #if NUM_RECT_AREA_LIGHTS > 0
  5047. 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 ) {
  5048. vec3 normal = geometryNormal;
  5049. vec3 viewDir = geometryViewDir;
  5050. vec3 position = geometryPosition;
  5051. vec3 lightPos = rectAreaLight.position;
  5052. vec3 halfWidth = rectAreaLight.halfWidth;
  5053. vec3 halfHeight = rectAreaLight.halfHeight;
  5054. vec3 lightColor = rectAreaLight.color;
  5055. float roughness = material.roughness;
  5056. vec3 rectCoords[ 4 ];
  5057. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  5058. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  5059. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  5060. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  5061. vec4 t1 = texture2D( ltc_1, uv );
  5062. vec4 t2 = texture2D( ltc_2, uv );
  5063. mat3 mInv = mat3(
  5064. vec3( t1.x, 0, t1.y ),
  5065. vec3( 0, 1, 0 ),
  5066. vec3( t1.z, 0, t1.w )
  5067. );
  5068. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  5069. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  5070. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  5071. }
  5072. #endif
  5073. 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 ) {
  5074. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  5075. vec3 irradiance = dotNL * directLight.color;
  5076. #ifdef USE_CLEARCOAT
  5077. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  5078. vec3 ccIrradiance = dotNLcc * directLight.color;
  5079. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  5080. #endif
  5081. #ifdef USE_SHEEN
  5082. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  5083. #endif
  5084. reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
  5085. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5086. }
  5087. 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 ) {
  5088. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5089. }
  5090. 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) {
  5091. #ifdef USE_CLEARCOAT
  5092. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  5093. #endif
  5094. #ifdef USE_SHEEN
  5095. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  5096. #endif
  5097. vec3 singleScattering = vec3( 0.0 );
  5098. vec3 multiScattering = vec3( 0.0 );
  5099. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  5100. #ifdef USE_IRIDESCENCE
  5101. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  5102. #else
  5103. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  5104. #endif
  5105. vec3 totalScattering = singleScattering + multiScattering;
  5106. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  5107. reflectedLight.indirectSpecular += radiance * singleScattering;
  5108. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  5109. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  5110. }
  5111. #define RE_Direct RE_Direct_Physical
  5112. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  5113. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  5114. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  5115. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  5116. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  5117. }`,IIe=`
  5118. vec3 geometryPosition = - vViewPosition;
  5119. vec3 geometryNormal = normal;
  5120. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  5121. vec3 geometryClearcoatNormal = vec3( 0.0 );
  5122. #ifdef USE_CLEARCOAT
  5123. geometryClearcoatNormal = clearcoatNormal;
  5124. #endif
  5125. #ifdef USE_IRIDESCENCE
  5126. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  5127. if ( material.iridescenceThickness == 0.0 ) {
  5128. material.iridescence = 0.0;
  5129. } else {
  5130. material.iridescence = saturate( material.iridescence );
  5131. }
  5132. if ( material.iridescence > 0.0 ) {
  5133. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  5134. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  5135. }
  5136. #endif
  5137. IncidentLight directLight;
  5138. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  5139. PointLight pointLight;
  5140. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  5141. PointLightShadow pointLightShadow;
  5142. #endif
  5143. #pragma unroll_loop_start
  5144. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  5145. pointLight = pointLights[ i ];
  5146. getPointLightInfo( pointLight, geometryPosition, directLight );
  5147. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  5148. pointLightShadow = pointLightShadows[ i ];
  5149. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  5150. #endif
  5151. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5152. }
  5153. #pragma unroll_loop_end
  5154. #endif
  5155. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  5156. SpotLight spotLight;
  5157. vec4 spotColor;
  5158. vec3 spotLightCoord;
  5159. bool inSpotLightMap;
  5160. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  5161. SpotLightShadow spotLightShadow;
  5162. #endif
  5163. #pragma unroll_loop_start
  5164. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  5165. spotLight = spotLights[ i ];
  5166. getSpotLightInfo( spotLight, geometryPosition, directLight );
  5167. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5168. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  5169. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5170. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  5171. #else
  5172. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5173. #endif
  5174. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  5175. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  5176. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  5177. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  5178. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  5179. #endif
  5180. #undef SPOT_LIGHT_MAP_INDEX
  5181. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5182. spotLightShadow = spotLightShadows[ i ];
  5183. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5184. #endif
  5185. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5186. }
  5187. #pragma unroll_loop_end
  5188. #endif
  5189. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  5190. DirectionalLight directionalLight;
  5191. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  5192. DirectionalLightShadow directionalLightShadow;
  5193. #endif
  5194. #pragma unroll_loop_start
  5195. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  5196. directionalLight = directionalLights[ i ];
  5197. getDirectionalLightInfo( directionalLight, directLight );
  5198. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  5199. directionalLightShadow = directionalLightShadows[ i ];
  5200. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5201. #endif
  5202. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5203. }
  5204. #pragma unroll_loop_end
  5205. #endif
  5206. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  5207. RectAreaLight rectAreaLight;
  5208. #pragma unroll_loop_start
  5209. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  5210. rectAreaLight = rectAreaLights[ i ];
  5211. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5212. }
  5213. #pragma unroll_loop_end
  5214. #endif
  5215. #if defined( RE_IndirectDiffuse )
  5216. vec3 iblIrradiance = vec3( 0.0 );
  5217. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  5218. #if defined( USE_LIGHT_PROBES )
  5219. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  5220. #endif
  5221. #if ( NUM_HEMI_LIGHTS > 0 )
  5222. #pragma unroll_loop_start
  5223. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  5224. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  5225. }
  5226. #pragma unroll_loop_end
  5227. #endif
  5228. #endif
  5229. #if defined( RE_IndirectSpecular )
  5230. vec3 radiance = vec3( 0.0 );
  5231. vec3 clearcoatRadiance = vec3( 0.0 );
  5232. #endif`,UIe=`#if defined( RE_IndirectDiffuse )
  5233. #ifdef USE_LIGHTMAP
  5234. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  5235. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  5236. irradiance += lightMapIrradiance;
  5237. #endif
  5238. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  5239. iblIrradiance += getIBLIrradiance( geometryNormal );
  5240. #endif
  5241. #endif
  5242. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  5243. #ifdef USE_ANISOTROPY
  5244. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  5245. #else
  5246. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  5247. #endif
  5248. #ifdef USE_CLEARCOAT
  5249. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  5250. #endif
  5251. #endif`,zIe=`#if defined( RE_IndirectDiffuse )
  5252. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5253. #endif
  5254. #if defined( RE_IndirectSpecular )
  5255. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5256. #endif`,BIe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5257. gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  5258. #endif`,$Ie=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5259. uniform float logDepthBufFC;
  5260. varying float vFragDepth;
  5261. varying float vIsPerspective;
  5262. #endif`,HIe=`#ifdef USE_LOGDEPTHBUF
  5263. #ifdef USE_LOGDEPTHBUF_EXT
  5264. varying float vFragDepth;
  5265. varying float vIsPerspective;
  5266. #else
  5267. uniform float logDepthBufFC;
  5268. #endif
  5269. #endif`,VIe=`#ifdef USE_LOGDEPTHBUF
  5270. #ifdef USE_LOGDEPTHBUF_EXT
  5271. vFragDepth = 1.0 + gl_Position.w;
  5272. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  5273. #else
  5274. if ( isPerspectiveMatrix( projectionMatrix ) ) {
  5275. gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
  5276. gl_Position.z *= gl_Position.w;
  5277. }
  5278. #endif
  5279. #endif`,GIe=`#ifdef USE_MAP
  5280. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  5281. #ifdef DECODE_VIDEO_TEXTURE
  5282. 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 );
  5283. #endif
  5284. diffuseColor *= sampledDiffuseColor;
  5285. #endif`,qIe=`#ifdef USE_MAP
  5286. uniform sampler2D map;
  5287. #endif`,WIe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5288. #if defined( USE_POINTS_UV )
  5289. vec2 uv = vUv;
  5290. #else
  5291. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  5292. #endif
  5293. #endif
  5294. #ifdef USE_MAP
  5295. diffuseColor *= texture2D( map, uv );
  5296. #endif
  5297. #ifdef USE_ALPHAMAP
  5298. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  5299. #endif`,KIe=`#if defined( USE_POINTS_UV )
  5300. varying vec2 vUv;
  5301. #else
  5302. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5303. uniform mat3 uvTransform;
  5304. #endif
  5305. #endif
  5306. #ifdef USE_MAP
  5307. uniform sampler2D map;
  5308. #endif
  5309. #ifdef USE_ALPHAMAP
  5310. uniform sampler2D alphaMap;
  5311. #endif`,XIe=`float metalnessFactor = metalness;
  5312. #ifdef USE_METALNESSMAP
  5313. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  5314. metalnessFactor *= texelMetalness.b;
  5315. #endif`,YIe=`#ifdef USE_METALNESSMAP
  5316. uniform sampler2D metalnessMap;
  5317. #endif`,QIe=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
  5318. vColor *= morphTargetBaseInfluence;
  5319. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5320. #if defined( USE_COLOR_ALPHA )
  5321. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  5322. #elif defined( USE_COLOR )
  5323. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  5324. #endif
  5325. }
  5326. #endif`,ZIe=`#ifdef USE_MORPHNORMALS
  5327. objectNormal *= morphTargetBaseInfluence;
  5328. #ifdef MORPHTARGETS_TEXTURE
  5329. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5330. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  5331. }
  5332. #else
  5333. objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
  5334. objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
  5335. objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
  5336. objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
  5337. #endif
  5338. #endif`,JIe=`#ifdef USE_MORPHTARGETS
  5339. uniform float morphTargetBaseInfluence;
  5340. #ifdef MORPHTARGETS_TEXTURE
  5341. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  5342. uniform sampler2DArray morphTargetsTexture;
  5343. uniform ivec2 morphTargetsTextureSize;
  5344. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  5345. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  5346. int y = texelIndex / morphTargetsTextureSize.x;
  5347. int x = texelIndex - y * morphTargetsTextureSize.x;
  5348. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  5349. return texelFetch( morphTargetsTexture, morphUV, 0 );
  5350. }
  5351. #else
  5352. #ifndef USE_MORPHNORMALS
  5353. uniform float morphTargetInfluences[ 8 ];
  5354. #else
  5355. uniform float morphTargetInfluences[ 4 ];
  5356. #endif
  5357. #endif
  5358. #endif`,e5e=`#ifdef USE_MORPHTARGETS
  5359. transformed *= morphTargetBaseInfluence;
  5360. #ifdef MORPHTARGETS_TEXTURE
  5361. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5362. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  5363. }
  5364. #else
  5365. transformed += morphTarget0 * morphTargetInfluences[ 0 ];
  5366. transformed += morphTarget1 * morphTargetInfluences[ 1 ];
  5367. transformed += morphTarget2 * morphTargetInfluences[ 2 ];
  5368. transformed += morphTarget3 * morphTargetInfluences[ 3 ];
  5369. #ifndef USE_MORPHNORMALS
  5370. transformed += morphTarget4 * morphTargetInfluences[ 4 ];
  5371. transformed += morphTarget5 * morphTargetInfluences[ 5 ];
  5372. transformed += morphTarget6 * morphTargetInfluences[ 6 ];
  5373. transformed += morphTarget7 * morphTargetInfluences[ 7 ];
  5374. #endif
  5375. #endif
  5376. #endif`,t5e=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  5377. #ifdef FLAT_SHADED
  5378. vec3 fdx = dFdx( vViewPosition );
  5379. vec3 fdy = dFdy( vViewPosition );
  5380. vec3 normal = normalize( cross( fdx, fdy ) );
  5381. #else
  5382. vec3 normal = normalize( vNormal );
  5383. #ifdef DOUBLE_SIDED
  5384. normal *= faceDirection;
  5385. #endif
  5386. #endif
  5387. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  5388. #ifdef USE_TANGENT
  5389. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5390. #else
  5391. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  5392. #if defined( USE_NORMALMAP )
  5393. vNormalMapUv
  5394. #elif defined( USE_CLEARCOAT_NORMALMAP )
  5395. vClearcoatNormalMapUv
  5396. #else
  5397. vUv
  5398. #endif
  5399. );
  5400. #endif
  5401. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5402. tbn[0] *= faceDirection;
  5403. tbn[1] *= faceDirection;
  5404. #endif
  5405. #endif
  5406. #ifdef USE_CLEARCOAT_NORMALMAP
  5407. #ifdef USE_TANGENT
  5408. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5409. #else
  5410. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  5411. #endif
  5412. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5413. tbn2[0] *= faceDirection;
  5414. tbn2[1] *= faceDirection;
  5415. #endif
  5416. #endif
  5417. vec3 nonPerturbedNormal = normal;`,n5e=`#ifdef USE_NORMALMAP_OBJECTSPACE
  5418. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5419. #ifdef FLIP_SIDED
  5420. normal = - normal;
  5421. #endif
  5422. #ifdef DOUBLE_SIDED
  5423. normal = normal * faceDirection;
  5424. #endif
  5425. normal = normalize( normalMatrix * normal );
  5426. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  5427. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5428. mapN.xy *= normalScale;
  5429. normal = normalize( tbn * mapN );
  5430. #elif defined( USE_BUMPMAP )
  5431. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  5432. #endif`,r5e=`#ifndef FLAT_SHADED
  5433. varying vec3 vNormal;
  5434. #ifdef USE_TANGENT
  5435. varying vec3 vTangent;
  5436. varying vec3 vBitangent;
  5437. #endif
  5438. #endif`,i5e=`#ifndef FLAT_SHADED
  5439. varying vec3 vNormal;
  5440. #ifdef USE_TANGENT
  5441. varying vec3 vTangent;
  5442. varying vec3 vBitangent;
  5443. #endif
  5444. #endif`,a5e=`#ifndef FLAT_SHADED
  5445. vNormal = normalize( transformedNormal );
  5446. #ifdef USE_TANGENT
  5447. vTangent = normalize( transformedTangent );
  5448. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  5449. #endif
  5450. #endif`,s5e=`#ifdef USE_NORMALMAP
  5451. uniform sampler2D normalMap;
  5452. uniform vec2 normalScale;
  5453. #endif
  5454. #ifdef USE_NORMALMAP_OBJECTSPACE
  5455. uniform mat3 normalMatrix;
  5456. #endif
  5457. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  5458. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  5459. vec3 q0 = dFdx( eye_pos.xyz );
  5460. vec3 q1 = dFdy( eye_pos.xyz );
  5461. vec2 st0 = dFdx( uv.st );
  5462. vec2 st1 = dFdy( uv.st );
  5463. vec3 N = surf_norm;
  5464. vec3 q1perp = cross( q1, N );
  5465. vec3 q0perp = cross( N, q0 );
  5466. vec3 T = q1perp * st0.x + q0perp * st1.x;
  5467. vec3 B = q1perp * st0.y + q0perp * st1.y;
  5468. float det = max( dot( T, T ), dot( B, B ) );
  5469. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  5470. return mat3( T * scale, B * scale, N );
  5471. }
  5472. #endif`,o5e=`#ifdef USE_CLEARCOAT
  5473. vec3 clearcoatNormal = nonPerturbedNormal;
  5474. #endif`,l5e=`#ifdef USE_CLEARCOAT_NORMALMAP
  5475. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  5476. clearcoatMapN.xy *= clearcoatNormalScale;
  5477. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  5478. #endif`,c5e=`#ifdef USE_CLEARCOATMAP
  5479. uniform sampler2D clearcoatMap;
  5480. #endif
  5481. #ifdef USE_CLEARCOAT_NORMALMAP
  5482. uniform sampler2D clearcoatNormalMap;
  5483. uniform vec2 clearcoatNormalScale;
  5484. #endif
  5485. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  5486. uniform sampler2D clearcoatRoughnessMap;
  5487. #endif`,u5e=`#ifdef USE_IRIDESCENCEMAP
  5488. uniform sampler2D iridescenceMap;
  5489. #endif
  5490. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  5491. uniform sampler2D iridescenceThicknessMap;
  5492. #endif`,d5e=`#ifdef OPAQUE
  5493. diffuseColor.a = 1.0;
  5494. #endif
  5495. #ifdef USE_TRANSMISSION
  5496. diffuseColor.a *= material.transmissionAlpha;
  5497. #endif
  5498. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,h5e=`vec3 packNormalToRGB( const in vec3 normal ) {
  5499. return normalize( normal ) * 0.5 + 0.5;
  5500. }
  5501. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  5502. return 2.0 * rgb.xyz - 1.0;
  5503. }
  5504. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
  5505. const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
  5506. const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
  5507. const float ShiftRight8 = 1. / 256.;
  5508. vec4 packDepthToRGBA( const in float v ) {
  5509. vec4 r = vec4( fract( v * PackFactors ), v );
  5510. r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
  5511. }
  5512. float unpackRGBAToDepth( const in vec4 v ) {
  5513. return dot( v, UnpackFactors );
  5514. }
  5515. vec2 packDepthToRG( in highp float v ) {
  5516. return packDepthToRGBA( v ).yx;
  5517. }
  5518. float unpackRGToDepth( const in highp vec2 v ) {
  5519. return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
  5520. }
  5521. vec4 pack2HalfToRGBA( vec2 v ) {
  5522. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  5523. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  5524. }
  5525. vec2 unpackRGBATo2Half( vec4 v ) {
  5526. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  5527. }
  5528. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  5529. return ( viewZ + near ) / ( near - far );
  5530. }
  5531. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5532. return depth * ( near - far ) - near;
  5533. }
  5534. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  5535. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  5536. }
  5537. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5538. return ( near * far ) / ( ( far - near ) * depth - far );
  5539. }`,f5e=`#ifdef PREMULTIPLIED_ALPHA
  5540. gl_FragColor.rgb *= gl_FragColor.a;
  5541. #endif`,m5e=`vec4 mvPosition = vec4( transformed, 1.0 );
  5542. #ifdef USE_BATCHING
  5543. mvPosition = batchingMatrix * mvPosition;
  5544. #endif
  5545. #ifdef USE_INSTANCING
  5546. mvPosition = instanceMatrix * mvPosition;
  5547. #endif
  5548. mvPosition = modelViewMatrix * mvPosition;
  5549. gl_Position = projectionMatrix * mvPosition;`,p5e=`#ifdef DITHERING
  5550. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  5551. #endif`,g5e=`#ifdef DITHERING
  5552. vec3 dithering( vec3 color ) {
  5553. float grid_position = rand( gl_FragCoord.xy );
  5554. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  5555. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  5556. return color + dither_shift_RGB;
  5557. }
  5558. #endif`,x5e=`float roughnessFactor = roughness;
  5559. #ifdef USE_ROUGHNESSMAP
  5560. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  5561. roughnessFactor *= texelRoughness.g;
  5562. #endif`,b5e=`#ifdef USE_ROUGHNESSMAP
  5563. uniform sampler2D roughnessMap;
  5564. #endif`,y5e=`#if NUM_SPOT_LIGHT_COORDS > 0
  5565. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5566. #endif
  5567. #if NUM_SPOT_LIGHT_MAPS > 0
  5568. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  5569. #endif
  5570. #ifdef USE_SHADOWMAP
  5571. #if NUM_DIR_LIGHT_SHADOWS > 0
  5572. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  5573. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5574. struct DirectionalLightShadow {
  5575. float shadowBias;
  5576. float shadowNormalBias;
  5577. float shadowRadius;
  5578. vec2 shadowMapSize;
  5579. };
  5580. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5581. #endif
  5582. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5583. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  5584. struct SpotLightShadow {
  5585. float shadowBias;
  5586. float shadowNormalBias;
  5587. float shadowRadius;
  5588. vec2 shadowMapSize;
  5589. };
  5590. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5591. #endif
  5592. #if NUM_POINT_LIGHT_SHADOWS > 0
  5593. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  5594. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5595. struct PointLightShadow {
  5596. float shadowBias;
  5597. float shadowNormalBias;
  5598. float shadowRadius;
  5599. vec2 shadowMapSize;
  5600. float shadowCameraNear;
  5601. float shadowCameraFar;
  5602. };
  5603. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5604. #endif
  5605. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  5606. return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
  5607. }
  5608. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  5609. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  5610. }
  5611. float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
  5612. float occlusion = 1.0;
  5613. vec2 distribution = texture2DDistribution( shadow, uv );
  5614. float hard_shadow = step( compare , distribution.x );
  5615. if (hard_shadow != 1.0 ) {
  5616. float distance = compare - distribution.x ;
  5617. float variance = max( 0.00000, distribution.y * distribution.y );
  5618. 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 );
  5619. }
  5620. return occlusion;
  5621. }
  5622. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  5623. float shadow = 1.0;
  5624. shadowCoord.xyz /= shadowCoord.w;
  5625. shadowCoord.z += shadowBias;
  5626. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  5627. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  5628. if ( frustumTest ) {
  5629. #if defined( SHADOWMAP_TYPE_PCF )
  5630. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5631. float dx0 = - texelSize.x * shadowRadius;
  5632. float dy0 = - texelSize.y * shadowRadius;
  5633. float dx1 = + texelSize.x * shadowRadius;
  5634. float dy1 = + texelSize.y * shadowRadius;
  5635. float dx2 = dx0 / 2.0;
  5636. float dy2 = dy0 / 2.0;
  5637. float dx3 = dx1 / 2.0;
  5638. float dy3 = dy1 / 2.0;
  5639. shadow = (
  5640. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  5641. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  5642. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  5643. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  5644. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  5645. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  5646. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  5647. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  5648. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  5649. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  5650. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  5651. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  5652. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  5653. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  5654. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  5655. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  5656. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  5657. ) * ( 1.0 / 17.0 );
  5658. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  5659. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5660. float dx = texelSize.x;
  5661. float dy = texelSize.y;
  5662. vec2 uv = shadowCoord.xy;
  5663. vec2 f = fract( uv * shadowMapSize + 0.5 );
  5664. uv -= f * texelSize;
  5665. shadow = (
  5666. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  5667. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  5668. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  5669. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  5670. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  5671. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  5672. f.x ) +
  5673. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  5674. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  5675. f.x ) +
  5676. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  5677. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  5678. f.y ) +
  5679. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  5680. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  5681. f.y ) +
  5682. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  5683. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  5684. f.x ),
  5685. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  5686. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  5687. f.x ),
  5688. f.y )
  5689. ) * ( 1.0 / 9.0 );
  5690. #elif defined( SHADOWMAP_TYPE_VSM )
  5691. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  5692. #else
  5693. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  5694. #endif
  5695. }
  5696. return shadow;
  5697. }
  5698. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  5699. vec3 absV = abs( v );
  5700. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  5701. absV *= scaleToCube;
  5702. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  5703. vec2 planar = v.xy;
  5704. float almostATexel = 1.5 * texelSizeY;
  5705. float almostOne = 1.0 - almostATexel;
  5706. if ( absV.z >= almostOne ) {
  5707. if ( v.z > 0.0 )
  5708. planar.x = 4.0 - v.x;
  5709. } else if ( absV.x >= almostOne ) {
  5710. float signX = sign( v.x );
  5711. planar.x = v.z * signX + 2.0 * signX;
  5712. } else if ( absV.y >= almostOne ) {
  5713. float signY = sign( v.y );
  5714. planar.x = v.x + 2.0 * signY + 2.0;
  5715. planar.y = v.z * signY - 2.0;
  5716. }
  5717. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  5718. }
  5719. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  5720. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  5721. vec3 lightToPosition = shadowCoord.xyz;
  5722. float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  5723. vec3 bd3D = normalize( lightToPosition );
  5724. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  5725. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  5726. return (
  5727. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  5728. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  5729. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  5730. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  5731. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  5732. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  5733. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  5734. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  5735. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  5736. ) * ( 1.0 / 9.0 );
  5737. #else
  5738. return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  5739. #endif
  5740. }
  5741. #endif`,v5e=`#if NUM_SPOT_LIGHT_COORDS > 0
  5742. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  5743. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5744. #endif
  5745. #ifdef USE_SHADOWMAP
  5746. #if NUM_DIR_LIGHT_SHADOWS > 0
  5747. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  5748. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5749. struct DirectionalLightShadow {
  5750. float shadowBias;
  5751. float shadowNormalBias;
  5752. float shadowRadius;
  5753. vec2 shadowMapSize;
  5754. };
  5755. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5756. #endif
  5757. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5758. struct SpotLightShadow {
  5759. float shadowBias;
  5760. float shadowNormalBias;
  5761. float shadowRadius;
  5762. vec2 shadowMapSize;
  5763. };
  5764. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5765. #endif
  5766. #if NUM_POINT_LIGHT_SHADOWS > 0
  5767. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  5768. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5769. struct PointLightShadow {
  5770. float shadowBias;
  5771. float shadowNormalBias;
  5772. float shadowRadius;
  5773. vec2 shadowMapSize;
  5774. float shadowCameraNear;
  5775. float shadowCameraFar;
  5776. };
  5777. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5778. #endif
  5779. #endif`,w5e=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  5780. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  5781. vec4 shadowWorldPosition;
  5782. #endif
  5783. #if defined( USE_SHADOWMAP )
  5784. #if NUM_DIR_LIGHT_SHADOWS > 0
  5785. #pragma unroll_loop_start
  5786. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5787. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  5788. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  5789. }
  5790. #pragma unroll_loop_end
  5791. #endif
  5792. #if NUM_POINT_LIGHT_SHADOWS > 0
  5793. #pragma unroll_loop_start
  5794. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5795. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  5796. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  5797. }
  5798. #pragma unroll_loop_end
  5799. #endif
  5800. #endif
  5801. #if NUM_SPOT_LIGHT_COORDS > 0
  5802. #pragma unroll_loop_start
  5803. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  5804. shadowWorldPosition = worldPosition;
  5805. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5806. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  5807. #endif
  5808. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  5809. }
  5810. #pragma unroll_loop_end
  5811. #endif`,_5e=`float getShadowMask() {
  5812. float shadow = 1.0;
  5813. #ifdef USE_SHADOWMAP
  5814. #if NUM_DIR_LIGHT_SHADOWS > 0
  5815. DirectionalLightShadow directionalLight;
  5816. #pragma unroll_loop_start
  5817. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5818. directionalLight = directionalLightShadows[ i ];
  5819. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5820. }
  5821. #pragma unroll_loop_end
  5822. #endif
  5823. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5824. SpotLightShadow spotLight;
  5825. #pragma unroll_loop_start
  5826. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  5827. spotLight = spotLightShadows[ i ];
  5828. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5829. }
  5830. #pragma unroll_loop_end
  5831. #endif
  5832. #if NUM_POINT_LIGHT_SHADOWS > 0
  5833. PointLightShadow pointLight;
  5834. #pragma unroll_loop_start
  5835. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5836. pointLight = pointLightShadows[ i ];
  5837. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  5838. }
  5839. #pragma unroll_loop_end
  5840. #endif
  5841. #endif
  5842. return shadow;
  5843. }`,S5e=`#ifdef USE_SKINNING
  5844. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  5845. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  5846. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  5847. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  5848. #endif`,N5e=`#ifdef USE_SKINNING
  5849. uniform mat4 bindMatrix;
  5850. uniform mat4 bindMatrixInverse;
  5851. uniform highp sampler2D boneTexture;
  5852. mat4 getBoneMatrix( const in float i ) {
  5853. int size = textureSize( boneTexture, 0 ).x;
  5854. int j = int( i ) * 4;
  5855. int x = j % size;
  5856. int y = j / size;
  5857. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  5858. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  5859. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  5860. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  5861. return mat4( v1, v2, v3, v4 );
  5862. }
  5863. #endif`,M5e=`#ifdef USE_SKINNING
  5864. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  5865. vec4 skinned = vec4( 0.0 );
  5866. skinned += boneMatX * skinVertex * skinWeight.x;
  5867. skinned += boneMatY * skinVertex * skinWeight.y;
  5868. skinned += boneMatZ * skinVertex * skinWeight.z;
  5869. skinned += boneMatW * skinVertex * skinWeight.w;
  5870. transformed = ( bindMatrixInverse * skinned ).xyz;
  5871. #endif`,E5e=`#ifdef USE_SKINNING
  5872. mat4 skinMatrix = mat4( 0.0 );
  5873. skinMatrix += skinWeight.x * boneMatX;
  5874. skinMatrix += skinWeight.y * boneMatY;
  5875. skinMatrix += skinWeight.z * boneMatZ;
  5876. skinMatrix += skinWeight.w * boneMatW;
  5877. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  5878. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  5879. #ifdef USE_TANGENT
  5880. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  5881. #endif
  5882. #endif`,k5e=`float specularStrength;
  5883. #ifdef USE_SPECULARMAP
  5884. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  5885. specularStrength = texelSpecular.r;
  5886. #else
  5887. specularStrength = 1.0;
  5888. #endif`,T5e=`#ifdef USE_SPECULARMAP
  5889. uniform sampler2D specularMap;
  5890. #endif`,A5e=`#if defined( TONE_MAPPING )
  5891. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  5892. #endif`,C5e=`#ifndef saturate
  5893. #define saturate( a ) clamp( a, 0.0, 1.0 )
  5894. #endif
  5895. uniform float toneMappingExposure;
  5896. vec3 LinearToneMapping( vec3 color ) {
  5897. return saturate( toneMappingExposure * color );
  5898. }
  5899. vec3 ReinhardToneMapping( vec3 color ) {
  5900. color *= toneMappingExposure;
  5901. return saturate( color / ( vec3( 1.0 ) + color ) );
  5902. }
  5903. vec3 OptimizedCineonToneMapping( vec3 color ) {
  5904. color *= toneMappingExposure;
  5905. color = max( vec3( 0.0 ), color - 0.004 );
  5906. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  5907. }
  5908. vec3 RRTAndODTFit( vec3 v ) {
  5909. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  5910. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  5911. return a / b;
  5912. }
  5913. vec3 ACESFilmicToneMapping( vec3 color ) {
  5914. const mat3 ACESInputMat = mat3(
  5915. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  5916. vec3( 0.04823, 0.01566, 0.83777 )
  5917. );
  5918. const mat3 ACESOutputMat = mat3(
  5919. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  5920. vec3( -0.07367, -0.00605, 1.07602 )
  5921. );
  5922. color *= toneMappingExposure / 0.6;
  5923. color = ACESInputMat * color;
  5924. color = RRTAndODTFit( color );
  5925. color = ACESOutputMat * color;
  5926. return saturate( color );
  5927. }
  5928. vec3 CustomToneMapping( vec3 color ) { return color; }`,j5e=`#ifdef USE_TRANSMISSION
  5929. material.transmission = transmission;
  5930. material.transmissionAlpha = 1.0;
  5931. material.thickness = thickness;
  5932. material.attenuationDistance = attenuationDistance;
  5933. material.attenuationColor = attenuationColor;
  5934. #ifdef USE_TRANSMISSIONMAP
  5935. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  5936. #endif
  5937. #ifdef USE_THICKNESSMAP
  5938. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  5939. #endif
  5940. vec3 pos = vWorldPosition;
  5941. vec3 v = normalize( cameraPosition - pos );
  5942. vec3 n = inverseTransformDirection( normal, viewMatrix );
  5943. vec4 transmitted = getIBLVolumeRefraction(
  5944. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  5945. pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
  5946. material.attenuationColor, material.attenuationDistance );
  5947. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  5948. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  5949. #endif`,P5e=`#ifdef USE_TRANSMISSION
  5950. uniform float transmission;
  5951. uniform float thickness;
  5952. uniform float attenuationDistance;
  5953. uniform vec3 attenuationColor;
  5954. #ifdef USE_TRANSMISSIONMAP
  5955. uniform sampler2D transmissionMap;
  5956. #endif
  5957. #ifdef USE_THICKNESSMAP
  5958. uniform sampler2D thicknessMap;
  5959. #endif
  5960. uniform vec2 transmissionSamplerSize;
  5961. uniform sampler2D transmissionSamplerMap;
  5962. uniform mat4 modelMatrix;
  5963. uniform mat4 projectionMatrix;
  5964. varying vec3 vWorldPosition;
  5965. float w0( float a ) {
  5966. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  5967. }
  5968. float w1( float a ) {
  5969. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  5970. }
  5971. float w2( float a ){
  5972. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  5973. }
  5974. float w3( float a ) {
  5975. return ( 1.0 / 6.0 ) * ( a * a * a );
  5976. }
  5977. float g0( float a ) {
  5978. return w0( a ) + w1( a );
  5979. }
  5980. float g1( float a ) {
  5981. return w2( a ) + w3( a );
  5982. }
  5983. float h0( float a ) {
  5984. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  5985. }
  5986. float h1( float a ) {
  5987. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  5988. }
  5989. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  5990. uv = uv * texelSize.zw + 0.5;
  5991. vec2 iuv = floor( uv );
  5992. vec2 fuv = fract( uv );
  5993. float g0x = g0( fuv.x );
  5994. float g1x = g1( fuv.x );
  5995. float h0x = h0( fuv.x );
  5996. float h1x = h1( fuv.x );
  5997. float h0y = h0( fuv.y );
  5998. float h1y = h1( fuv.y );
  5999. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  6000. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  6001. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  6002. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  6003. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  6004. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  6005. }
  6006. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  6007. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  6008. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  6009. vec2 fLodSizeInv = 1.0 / fLodSize;
  6010. vec2 cLodSizeInv = 1.0 / cLodSize;
  6011. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  6012. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  6013. return mix( fSample, cSample, fract( lod ) );
  6014. }
  6015. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  6016. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  6017. vec3 modelScale;
  6018. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  6019. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  6020. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  6021. return normalize( refractionVector ) * thickness * modelScale;
  6022. }
  6023. float applyIorToRoughness( const in float roughness, const in float ior ) {
  6024. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  6025. }
  6026. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  6027. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  6028. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  6029. }
  6030. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  6031. if ( isinf( attenuationDistance ) ) {
  6032. return vec3( 1.0 );
  6033. } else {
  6034. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  6035. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  6036. }
  6037. }
  6038. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  6039. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  6040. const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
  6041. const in vec3 attenuationColor, const in float attenuationDistance ) {
  6042. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  6043. vec3 refractedRayExit = position + transmissionRay;
  6044. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  6045. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  6046. refractionCoords += 1.0;
  6047. refractionCoords /= 2.0;
  6048. vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  6049. vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  6050. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  6051. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  6052. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  6053. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  6054. }
  6055. #endif`,D5e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6056. varying vec2 vUv;
  6057. #endif
  6058. #ifdef USE_MAP
  6059. varying vec2 vMapUv;
  6060. #endif
  6061. #ifdef USE_ALPHAMAP
  6062. varying vec2 vAlphaMapUv;
  6063. #endif
  6064. #ifdef USE_LIGHTMAP
  6065. varying vec2 vLightMapUv;
  6066. #endif
  6067. #ifdef USE_AOMAP
  6068. varying vec2 vAoMapUv;
  6069. #endif
  6070. #ifdef USE_BUMPMAP
  6071. varying vec2 vBumpMapUv;
  6072. #endif
  6073. #ifdef USE_NORMALMAP
  6074. varying vec2 vNormalMapUv;
  6075. #endif
  6076. #ifdef USE_EMISSIVEMAP
  6077. varying vec2 vEmissiveMapUv;
  6078. #endif
  6079. #ifdef USE_METALNESSMAP
  6080. varying vec2 vMetalnessMapUv;
  6081. #endif
  6082. #ifdef USE_ROUGHNESSMAP
  6083. varying vec2 vRoughnessMapUv;
  6084. #endif
  6085. #ifdef USE_ANISOTROPYMAP
  6086. varying vec2 vAnisotropyMapUv;
  6087. #endif
  6088. #ifdef USE_CLEARCOATMAP
  6089. varying vec2 vClearcoatMapUv;
  6090. #endif
  6091. #ifdef USE_CLEARCOAT_NORMALMAP
  6092. varying vec2 vClearcoatNormalMapUv;
  6093. #endif
  6094. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6095. varying vec2 vClearcoatRoughnessMapUv;
  6096. #endif
  6097. #ifdef USE_IRIDESCENCEMAP
  6098. varying vec2 vIridescenceMapUv;
  6099. #endif
  6100. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6101. varying vec2 vIridescenceThicknessMapUv;
  6102. #endif
  6103. #ifdef USE_SHEEN_COLORMAP
  6104. varying vec2 vSheenColorMapUv;
  6105. #endif
  6106. #ifdef USE_SHEEN_ROUGHNESSMAP
  6107. varying vec2 vSheenRoughnessMapUv;
  6108. #endif
  6109. #ifdef USE_SPECULARMAP
  6110. varying vec2 vSpecularMapUv;
  6111. #endif
  6112. #ifdef USE_SPECULAR_COLORMAP
  6113. varying vec2 vSpecularColorMapUv;
  6114. #endif
  6115. #ifdef USE_SPECULAR_INTENSITYMAP
  6116. varying vec2 vSpecularIntensityMapUv;
  6117. #endif
  6118. #ifdef USE_TRANSMISSIONMAP
  6119. uniform mat3 transmissionMapTransform;
  6120. varying vec2 vTransmissionMapUv;
  6121. #endif
  6122. #ifdef USE_THICKNESSMAP
  6123. uniform mat3 thicknessMapTransform;
  6124. varying vec2 vThicknessMapUv;
  6125. #endif`,R5e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6126. varying vec2 vUv;
  6127. #endif
  6128. #ifdef USE_MAP
  6129. uniform mat3 mapTransform;
  6130. varying vec2 vMapUv;
  6131. #endif
  6132. #ifdef USE_ALPHAMAP
  6133. uniform mat3 alphaMapTransform;
  6134. varying vec2 vAlphaMapUv;
  6135. #endif
  6136. #ifdef USE_LIGHTMAP
  6137. uniform mat3 lightMapTransform;
  6138. varying vec2 vLightMapUv;
  6139. #endif
  6140. #ifdef USE_AOMAP
  6141. uniform mat3 aoMapTransform;
  6142. varying vec2 vAoMapUv;
  6143. #endif
  6144. #ifdef USE_BUMPMAP
  6145. uniform mat3 bumpMapTransform;
  6146. varying vec2 vBumpMapUv;
  6147. #endif
  6148. #ifdef USE_NORMALMAP
  6149. uniform mat3 normalMapTransform;
  6150. varying vec2 vNormalMapUv;
  6151. #endif
  6152. #ifdef USE_DISPLACEMENTMAP
  6153. uniform mat3 displacementMapTransform;
  6154. varying vec2 vDisplacementMapUv;
  6155. #endif
  6156. #ifdef USE_EMISSIVEMAP
  6157. uniform mat3 emissiveMapTransform;
  6158. varying vec2 vEmissiveMapUv;
  6159. #endif
  6160. #ifdef USE_METALNESSMAP
  6161. uniform mat3 metalnessMapTransform;
  6162. varying vec2 vMetalnessMapUv;
  6163. #endif
  6164. #ifdef USE_ROUGHNESSMAP
  6165. uniform mat3 roughnessMapTransform;
  6166. varying vec2 vRoughnessMapUv;
  6167. #endif
  6168. #ifdef USE_ANISOTROPYMAP
  6169. uniform mat3 anisotropyMapTransform;
  6170. varying vec2 vAnisotropyMapUv;
  6171. #endif
  6172. #ifdef USE_CLEARCOATMAP
  6173. uniform mat3 clearcoatMapTransform;
  6174. varying vec2 vClearcoatMapUv;
  6175. #endif
  6176. #ifdef USE_CLEARCOAT_NORMALMAP
  6177. uniform mat3 clearcoatNormalMapTransform;
  6178. varying vec2 vClearcoatNormalMapUv;
  6179. #endif
  6180. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6181. uniform mat3 clearcoatRoughnessMapTransform;
  6182. varying vec2 vClearcoatRoughnessMapUv;
  6183. #endif
  6184. #ifdef USE_SHEEN_COLORMAP
  6185. uniform mat3 sheenColorMapTransform;
  6186. varying vec2 vSheenColorMapUv;
  6187. #endif
  6188. #ifdef USE_SHEEN_ROUGHNESSMAP
  6189. uniform mat3 sheenRoughnessMapTransform;
  6190. varying vec2 vSheenRoughnessMapUv;
  6191. #endif
  6192. #ifdef USE_IRIDESCENCEMAP
  6193. uniform mat3 iridescenceMapTransform;
  6194. varying vec2 vIridescenceMapUv;
  6195. #endif
  6196. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6197. uniform mat3 iridescenceThicknessMapTransform;
  6198. varying vec2 vIridescenceThicknessMapUv;
  6199. #endif
  6200. #ifdef USE_SPECULARMAP
  6201. uniform mat3 specularMapTransform;
  6202. varying vec2 vSpecularMapUv;
  6203. #endif
  6204. #ifdef USE_SPECULAR_COLORMAP
  6205. uniform mat3 specularColorMapTransform;
  6206. varying vec2 vSpecularColorMapUv;
  6207. #endif
  6208. #ifdef USE_SPECULAR_INTENSITYMAP
  6209. uniform mat3 specularIntensityMapTransform;
  6210. varying vec2 vSpecularIntensityMapUv;
  6211. #endif
  6212. #ifdef USE_TRANSMISSIONMAP
  6213. uniform mat3 transmissionMapTransform;
  6214. varying vec2 vTransmissionMapUv;
  6215. #endif
  6216. #ifdef USE_THICKNESSMAP
  6217. uniform mat3 thicknessMapTransform;
  6218. varying vec2 vThicknessMapUv;
  6219. #endif`,O5e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6220. vUv = vec3( uv, 1 ).xy;
  6221. #endif
  6222. #ifdef USE_MAP
  6223. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  6224. #endif
  6225. #ifdef USE_ALPHAMAP
  6226. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  6227. #endif
  6228. #ifdef USE_LIGHTMAP
  6229. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  6230. #endif
  6231. #ifdef USE_AOMAP
  6232. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  6233. #endif
  6234. #ifdef USE_BUMPMAP
  6235. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  6236. #endif
  6237. #ifdef USE_NORMALMAP
  6238. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  6239. #endif
  6240. #ifdef USE_DISPLACEMENTMAP
  6241. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  6242. #endif
  6243. #ifdef USE_EMISSIVEMAP
  6244. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  6245. #endif
  6246. #ifdef USE_METALNESSMAP
  6247. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  6248. #endif
  6249. #ifdef USE_ROUGHNESSMAP
  6250. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  6251. #endif
  6252. #ifdef USE_ANISOTROPYMAP
  6253. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  6254. #endif
  6255. #ifdef USE_CLEARCOATMAP
  6256. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  6257. #endif
  6258. #ifdef USE_CLEARCOAT_NORMALMAP
  6259. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  6260. #endif
  6261. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6262. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  6263. #endif
  6264. #ifdef USE_IRIDESCENCEMAP
  6265. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  6266. #endif
  6267. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6268. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  6269. #endif
  6270. #ifdef USE_SHEEN_COLORMAP
  6271. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  6272. #endif
  6273. #ifdef USE_SHEEN_ROUGHNESSMAP
  6274. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  6275. #endif
  6276. #ifdef USE_SPECULARMAP
  6277. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  6278. #endif
  6279. #ifdef USE_SPECULAR_COLORMAP
  6280. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  6281. #endif
  6282. #ifdef USE_SPECULAR_INTENSITYMAP
  6283. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  6284. #endif
  6285. #ifdef USE_TRANSMISSIONMAP
  6286. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  6287. #endif
  6288. #ifdef USE_THICKNESSMAP
  6289. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  6290. #endif`,L5e=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  6291. vec4 worldPosition = vec4( transformed, 1.0 );
  6292. #ifdef USE_BATCHING
  6293. worldPosition = batchingMatrix * worldPosition;
  6294. #endif
  6295. #ifdef USE_INSTANCING
  6296. worldPosition = instanceMatrix * worldPosition;
  6297. #endif
  6298. worldPosition = modelMatrix * worldPosition;
  6299. #endif`;const F5e=`varying vec2 vUv;
  6300. uniform mat3 uvTransform;
  6301. void main() {
  6302. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  6303. gl_Position = vec4( position.xy, 1.0, 1.0 );
  6304. }`,I5e=`uniform sampler2D t2D;
  6305. uniform float backgroundIntensity;
  6306. varying vec2 vUv;
  6307. void main() {
  6308. vec4 texColor = texture2D( t2D, vUv );
  6309. #ifdef DECODE_VIDEO_TEXTURE
  6310. 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 );
  6311. #endif
  6312. texColor.rgb *= backgroundIntensity;
  6313. gl_FragColor = texColor;
  6314. #include <tonemapping_fragment>
  6315. #include <colorspace_fragment>
  6316. }`,U5e=`varying vec3 vWorldDirection;
  6317. #include <common>
  6318. void main() {
  6319. vWorldDirection = transformDirection( position, modelMatrix );
  6320. #include <begin_vertex>
  6321. #include <project_vertex>
  6322. gl_Position.z = gl_Position.w;
  6323. }`,z5e=`#ifdef ENVMAP_TYPE_CUBE
  6324. uniform samplerCube envMap;
  6325. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6326. uniform sampler2D envMap;
  6327. #endif
  6328. uniform float flipEnvMap;
  6329. uniform float backgroundBlurriness;
  6330. uniform float backgroundIntensity;
  6331. varying vec3 vWorldDirection;
  6332. #include <cube_uv_reflection_fragment>
  6333. void main() {
  6334. #ifdef ENVMAP_TYPE_CUBE
  6335. vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  6336. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6337. vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
  6338. #else
  6339. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  6340. #endif
  6341. texColor.rgb *= backgroundIntensity;
  6342. gl_FragColor = texColor;
  6343. #include <tonemapping_fragment>
  6344. #include <colorspace_fragment>
  6345. }`,B5e=`varying vec3 vWorldDirection;
  6346. #include <common>
  6347. void main() {
  6348. vWorldDirection = transformDirection( position, modelMatrix );
  6349. #include <begin_vertex>
  6350. #include <project_vertex>
  6351. gl_Position.z = gl_Position.w;
  6352. }`,$5e=`uniform samplerCube tCube;
  6353. uniform float tFlip;
  6354. uniform float opacity;
  6355. varying vec3 vWorldDirection;
  6356. void main() {
  6357. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  6358. gl_FragColor = texColor;
  6359. gl_FragColor.a *= opacity;
  6360. #include <tonemapping_fragment>
  6361. #include <colorspace_fragment>
  6362. }`,H5e=`#include <common>
  6363. #include <batching_pars_vertex>
  6364. #include <uv_pars_vertex>
  6365. #include <displacementmap_pars_vertex>
  6366. #include <morphtarget_pars_vertex>
  6367. #include <skinning_pars_vertex>
  6368. #include <logdepthbuf_pars_vertex>
  6369. #include <clipping_planes_pars_vertex>
  6370. varying vec2 vHighPrecisionZW;
  6371. void main() {
  6372. #include <uv_vertex>
  6373. #include <batching_vertex>
  6374. #include <skinbase_vertex>
  6375. #ifdef USE_DISPLACEMENTMAP
  6376. #include <beginnormal_vertex>
  6377. #include <morphnormal_vertex>
  6378. #include <skinnormal_vertex>
  6379. #endif
  6380. #include <begin_vertex>
  6381. #include <morphtarget_vertex>
  6382. #include <skinning_vertex>
  6383. #include <displacementmap_vertex>
  6384. #include <project_vertex>
  6385. #include <logdepthbuf_vertex>
  6386. #include <clipping_planes_vertex>
  6387. vHighPrecisionZW = gl_Position.zw;
  6388. }`,V5e=`#if DEPTH_PACKING == 3200
  6389. uniform float opacity;
  6390. #endif
  6391. #include <common>
  6392. #include <packing>
  6393. #include <uv_pars_fragment>
  6394. #include <map_pars_fragment>
  6395. #include <alphamap_pars_fragment>
  6396. #include <alphatest_pars_fragment>
  6397. #include <alphahash_pars_fragment>
  6398. #include <logdepthbuf_pars_fragment>
  6399. #include <clipping_planes_pars_fragment>
  6400. varying vec2 vHighPrecisionZW;
  6401. void main() {
  6402. #include <clipping_planes_fragment>
  6403. vec4 diffuseColor = vec4( 1.0 );
  6404. #if DEPTH_PACKING == 3200
  6405. diffuseColor.a = opacity;
  6406. #endif
  6407. #include <map_fragment>
  6408. #include <alphamap_fragment>
  6409. #include <alphatest_fragment>
  6410. #include <alphahash_fragment>
  6411. #include <logdepthbuf_fragment>
  6412. float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
  6413. #if DEPTH_PACKING == 3200
  6414. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  6415. #elif DEPTH_PACKING == 3201
  6416. gl_FragColor = packDepthToRGBA( fragCoordZ );
  6417. #endif
  6418. }`,G5e=`#define DISTANCE
  6419. varying vec3 vWorldPosition;
  6420. #include <common>
  6421. #include <batching_pars_vertex>
  6422. #include <uv_pars_vertex>
  6423. #include <displacementmap_pars_vertex>
  6424. #include <morphtarget_pars_vertex>
  6425. #include <skinning_pars_vertex>
  6426. #include <clipping_planes_pars_vertex>
  6427. void main() {
  6428. #include <uv_vertex>
  6429. #include <batching_vertex>
  6430. #include <skinbase_vertex>
  6431. #ifdef USE_DISPLACEMENTMAP
  6432. #include <beginnormal_vertex>
  6433. #include <morphnormal_vertex>
  6434. #include <skinnormal_vertex>
  6435. #endif
  6436. #include <begin_vertex>
  6437. #include <morphtarget_vertex>
  6438. #include <skinning_vertex>
  6439. #include <displacementmap_vertex>
  6440. #include <project_vertex>
  6441. #include <worldpos_vertex>
  6442. #include <clipping_planes_vertex>
  6443. vWorldPosition = worldPosition.xyz;
  6444. }`,q5e=`#define DISTANCE
  6445. uniform vec3 referencePosition;
  6446. uniform float nearDistance;
  6447. uniform float farDistance;
  6448. varying vec3 vWorldPosition;
  6449. #include <common>
  6450. #include <packing>
  6451. #include <uv_pars_fragment>
  6452. #include <map_pars_fragment>
  6453. #include <alphamap_pars_fragment>
  6454. #include <alphatest_pars_fragment>
  6455. #include <alphahash_pars_fragment>
  6456. #include <clipping_planes_pars_fragment>
  6457. void main () {
  6458. #include <clipping_planes_fragment>
  6459. vec4 diffuseColor = vec4( 1.0 );
  6460. #include <map_fragment>
  6461. #include <alphamap_fragment>
  6462. #include <alphatest_fragment>
  6463. #include <alphahash_fragment>
  6464. float dist = length( vWorldPosition - referencePosition );
  6465. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  6466. dist = saturate( dist );
  6467. gl_FragColor = packDepthToRGBA( dist );
  6468. }`,W5e=`varying vec3 vWorldDirection;
  6469. #include <common>
  6470. void main() {
  6471. vWorldDirection = transformDirection( position, modelMatrix );
  6472. #include <begin_vertex>
  6473. #include <project_vertex>
  6474. }`,K5e=`uniform sampler2D tEquirect;
  6475. varying vec3 vWorldDirection;
  6476. #include <common>
  6477. void main() {
  6478. vec3 direction = normalize( vWorldDirection );
  6479. vec2 sampleUV = equirectUv( direction );
  6480. gl_FragColor = texture2D( tEquirect, sampleUV );
  6481. #include <tonemapping_fragment>
  6482. #include <colorspace_fragment>
  6483. }`,X5e=`uniform float scale;
  6484. attribute float lineDistance;
  6485. varying float vLineDistance;
  6486. #include <common>
  6487. #include <uv_pars_vertex>
  6488. #include <color_pars_vertex>
  6489. #include <fog_pars_vertex>
  6490. #include <morphtarget_pars_vertex>
  6491. #include <logdepthbuf_pars_vertex>
  6492. #include <clipping_planes_pars_vertex>
  6493. void main() {
  6494. vLineDistance = scale * lineDistance;
  6495. #include <uv_vertex>
  6496. #include <color_vertex>
  6497. #include <morphcolor_vertex>
  6498. #include <begin_vertex>
  6499. #include <morphtarget_vertex>
  6500. #include <project_vertex>
  6501. #include <logdepthbuf_vertex>
  6502. #include <clipping_planes_vertex>
  6503. #include <fog_vertex>
  6504. }`,Y5e=`uniform vec3 diffuse;
  6505. uniform float opacity;
  6506. uniform float dashSize;
  6507. uniform float totalSize;
  6508. varying float vLineDistance;
  6509. #include <common>
  6510. #include <color_pars_fragment>
  6511. #include <uv_pars_fragment>
  6512. #include <map_pars_fragment>
  6513. #include <fog_pars_fragment>
  6514. #include <logdepthbuf_pars_fragment>
  6515. #include <clipping_planes_pars_fragment>
  6516. void main() {
  6517. #include <clipping_planes_fragment>
  6518. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  6519. discard;
  6520. }
  6521. vec3 outgoingLight = vec3( 0.0 );
  6522. vec4 diffuseColor = vec4( diffuse, opacity );
  6523. #include <logdepthbuf_fragment>
  6524. #include <map_fragment>
  6525. #include <color_fragment>
  6526. outgoingLight = diffuseColor.rgb;
  6527. #include <opaque_fragment>
  6528. #include <tonemapping_fragment>
  6529. #include <colorspace_fragment>
  6530. #include <fog_fragment>
  6531. #include <premultiplied_alpha_fragment>
  6532. }`,Q5e=`#include <common>
  6533. #include <batching_pars_vertex>
  6534. #include <uv_pars_vertex>
  6535. #include <envmap_pars_vertex>
  6536. #include <color_pars_vertex>
  6537. #include <fog_pars_vertex>
  6538. #include <morphtarget_pars_vertex>
  6539. #include <skinning_pars_vertex>
  6540. #include <logdepthbuf_pars_vertex>
  6541. #include <clipping_planes_pars_vertex>
  6542. void main() {
  6543. #include <uv_vertex>
  6544. #include <color_vertex>
  6545. #include <morphcolor_vertex>
  6546. #include <batching_vertex>
  6547. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  6548. #include <beginnormal_vertex>
  6549. #include <morphnormal_vertex>
  6550. #include <skinbase_vertex>
  6551. #include <skinnormal_vertex>
  6552. #include <defaultnormal_vertex>
  6553. #endif
  6554. #include <begin_vertex>
  6555. #include <morphtarget_vertex>
  6556. #include <skinning_vertex>
  6557. #include <project_vertex>
  6558. #include <logdepthbuf_vertex>
  6559. #include <clipping_planes_vertex>
  6560. #include <worldpos_vertex>
  6561. #include <envmap_vertex>
  6562. #include <fog_vertex>
  6563. }`,Z5e=`uniform vec3 diffuse;
  6564. uniform float opacity;
  6565. #ifndef FLAT_SHADED
  6566. varying vec3 vNormal;
  6567. #endif
  6568. #include <common>
  6569. #include <dithering_pars_fragment>
  6570. #include <color_pars_fragment>
  6571. #include <uv_pars_fragment>
  6572. #include <map_pars_fragment>
  6573. #include <alphamap_pars_fragment>
  6574. #include <alphatest_pars_fragment>
  6575. #include <alphahash_pars_fragment>
  6576. #include <aomap_pars_fragment>
  6577. #include <lightmap_pars_fragment>
  6578. #include <envmap_common_pars_fragment>
  6579. #include <envmap_pars_fragment>
  6580. #include <fog_pars_fragment>
  6581. #include <specularmap_pars_fragment>
  6582. #include <logdepthbuf_pars_fragment>
  6583. #include <clipping_planes_pars_fragment>
  6584. void main() {
  6585. #include <clipping_planes_fragment>
  6586. vec4 diffuseColor = vec4( diffuse, opacity );
  6587. #include <logdepthbuf_fragment>
  6588. #include <map_fragment>
  6589. #include <color_fragment>
  6590. #include <alphamap_fragment>
  6591. #include <alphatest_fragment>
  6592. #include <alphahash_fragment>
  6593. #include <specularmap_fragment>
  6594. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6595. #ifdef USE_LIGHTMAP
  6596. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  6597. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  6598. #else
  6599. reflectedLight.indirectDiffuse += vec3( 1.0 );
  6600. #endif
  6601. #include <aomap_fragment>
  6602. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  6603. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  6604. #include <envmap_fragment>
  6605. #include <opaque_fragment>
  6606. #include <tonemapping_fragment>
  6607. #include <colorspace_fragment>
  6608. #include <fog_fragment>
  6609. #include <premultiplied_alpha_fragment>
  6610. #include <dithering_fragment>
  6611. }`,J5e=`#define LAMBERT
  6612. varying vec3 vViewPosition;
  6613. #include <common>
  6614. #include <batching_pars_vertex>
  6615. #include <uv_pars_vertex>
  6616. #include <displacementmap_pars_vertex>
  6617. #include <envmap_pars_vertex>
  6618. #include <color_pars_vertex>
  6619. #include <fog_pars_vertex>
  6620. #include <normal_pars_vertex>
  6621. #include <morphtarget_pars_vertex>
  6622. #include <skinning_pars_vertex>
  6623. #include <shadowmap_pars_vertex>
  6624. #include <logdepthbuf_pars_vertex>
  6625. #include <clipping_planes_pars_vertex>
  6626. void main() {
  6627. #include <uv_vertex>
  6628. #include <color_vertex>
  6629. #include <morphcolor_vertex>
  6630. #include <batching_vertex>
  6631. #include <beginnormal_vertex>
  6632. #include <morphnormal_vertex>
  6633. #include <skinbase_vertex>
  6634. #include <skinnormal_vertex>
  6635. #include <defaultnormal_vertex>
  6636. #include <normal_vertex>
  6637. #include <begin_vertex>
  6638. #include <morphtarget_vertex>
  6639. #include <skinning_vertex>
  6640. #include <displacementmap_vertex>
  6641. #include <project_vertex>
  6642. #include <logdepthbuf_vertex>
  6643. #include <clipping_planes_vertex>
  6644. vViewPosition = - mvPosition.xyz;
  6645. #include <worldpos_vertex>
  6646. #include <envmap_vertex>
  6647. #include <shadowmap_vertex>
  6648. #include <fog_vertex>
  6649. }`,eUe=`#define LAMBERT
  6650. uniform vec3 diffuse;
  6651. uniform vec3 emissive;
  6652. uniform float opacity;
  6653. #include <common>
  6654. #include <packing>
  6655. #include <dithering_pars_fragment>
  6656. #include <color_pars_fragment>
  6657. #include <uv_pars_fragment>
  6658. #include <map_pars_fragment>
  6659. #include <alphamap_pars_fragment>
  6660. #include <alphatest_pars_fragment>
  6661. #include <alphahash_pars_fragment>
  6662. #include <aomap_pars_fragment>
  6663. #include <lightmap_pars_fragment>
  6664. #include <emissivemap_pars_fragment>
  6665. #include <envmap_common_pars_fragment>
  6666. #include <envmap_pars_fragment>
  6667. #include <fog_pars_fragment>
  6668. #include <bsdfs>
  6669. #include <lights_pars_begin>
  6670. #include <normal_pars_fragment>
  6671. #include <lights_lambert_pars_fragment>
  6672. #include <shadowmap_pars_fragment>
  6673. #include <bumpmap_pars_fragment>
  6674. #include <normalmap_pars_fragment>
  6675. #include <specularmap_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. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6682. vec3 totalEmissiveRadiance = emissive;
  6683. #include <logdepthbuf_fragment>
  6684. #include <map_fragment>
  6685. #include <color_fragment>
  6686. #include <alphamap_fragment>
  6687. #include <alphatest_fragment>
  6688. #include <alphahash_fragment>
  6689. #include <specularmap_fragment>
  6690. #include <normal_fragment_begin>
  6691. #include <normal_fragment_maps>
  6692. #include <emissivemap_fragment>
  6693. #include <lights_lambert_fragment>
  6694. #include <lights_fragment_begin>
  6695. #include <lights_fragment_maps>
  6696. #include <lights_fragment_end>
  6697. #include <aomap_fragment>
  6698. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  6699. #include <envmap_fragment>
  6700. #include <opaque_fragment>
  6701. #include <tonemapping_fragment>
  6702. #include <colorspace_fragment>
  6703. #include <fog_fragment>
  6704. #include <premultiplied_alpha_fragment>
  6705. #include <dithering_fragment>
  6706. }`,tUe=`#define MATCAP
  6707. varying vec3 vViewPosition;
  6708. #include <common>
  6709. #include <batching_pars_vertex>
  6710. #include <uv_pars_vertex>
  6711. #include <color_pars_vertex>
  6712. #include <displacementmap_pars_vertex>
  6713. #include <fog_pars_vertex>
  6714. #include <normal_pars_vertex>
  6715. #include <morphtarget_pars_vertex>
  6716. #include <skinning_pars_vertex>
  6717. #include <logdepthbuf_pars_vertex>
  6718. #include <clipping_planes_pars_vertex>
  6719. void main() {
  6720. #include <uv_vertex>
  6721. #include <color_vertex>
  6722. #include <morphcolor_vertex>
  6723. #include <batching_vertex>
  6724. #include <beginnormal_vertex>
  6725. #include <morphnormal_vertex>
  6726. #include <skinbase_vertex>
  6727. #include <skinnormal_vertex>
  6728. #include <defaultnormal_vertex>
  6729. #include <normal_vertex>
  6730. #include <begin_vertex>
  6731. #include <morphtarget_vertex>
  6732. #include <skinning_vertex>
  6733. #include <displacementmap_vertex>
  6734. #include <project_vertex>
  6735. #include <logdepthbuf_vertex>
  6736. #include <clipping_planes_vertex>
  6737. #include <fog_vertex>
  6738. vViewPosition = - mvPosition.xyz;
  6739. }`,nUe=`#define MATCAP
  6740. uniform vec3 diffuse;
  6741. uniform float opacity;
  6742. uniform sampler2D matcap;
  6743. varying vec3 vViewPosition;
  6744. #include <common>
  6745. #include <dithering_pars_fragment>
  6746. #include <color_pars_fragment>
  6747. #include <uv_pars_fragment>
  6748. #include <map_pars_fragment>
  6749. #include <alphamap_pars_fragment>
  6750. #include <alphatest_pars_fragment>
  6751. #include <alphahash_pars_fragment>
  6752. #include <fog_pars_fragment>
  6753. #include <normal_pars_fragment>
  6754. #include <bumpmap_pars_fragment>
  6755. #include <normalmap_pars_fragment>
  6756. #include <logdepthbuf_pars_fragment>
  6757. #include <clipping_planes_pars_fragment>
  6758. void main() {
  6759. #include <clipping_planes_fragment>
  6760. vec4 diffuseColor = vec4( diffuse, opacity );
  6761. #include <logdepthbuf_fragment>
  6762. #include <map_fragment>
  6763. #include <color_fragment>
  6764. #include <alphamap_fragment>
  6765. #include <alphatest_fragment>
  6766. #include <alphahash_fragment>
  6767. #include <normal_fragment_begin>
  6768. #include <normal_fragment_maps>
  6769. vec3 viewDir = normalize( vViewPosition );
  6770. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  6771. vec3 y = cross( viewDir, x );
  6772. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  6773. #ifdef USE_MATCAP
  6774. vec4 matcapColor = texture2D( matcap, uv );
  6775. #else
  6776. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  6777. #endif
  6778. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  6779. #include <opaque_fragment>
  6780. #include <tonemapping_fragment>
  6781. #include <colorspace_fragment>
  6782. #include <fog_fragment>
  6783. #include <premultiplied_alpha_fragment>
  6784. #include <dithering_fragment>
  6785. }`,rUe=`#define NORMAL
  6786. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6787. varying vec3 vViewPosition;
  6788. #endif
  6789. #include <common>
  6790. #include <batching_pars_vertex>
  6791. #include <uv_pars_vertex>
  6792. #include <displacementmap_pars_vertex>
  6793. #include <normal_pars_vertex>
  6794. #include <morphtarget_pars_vertex>
  6795. #include <skinning_pars_vertex>
  6796. #include <logdepthbuf_pars_vertex>
  6797. #include <clipping_planes_pars_vertex>
  6798. void main() {
  6799. #include <uv_vertex>
  6800. #include <batching_vertex>
  6801. #include <beginnormal_vertex>
  6802. #include <morphnormal_vertex>
  6803. #include <skinbase_vertex>
  6804. #include <skinnormal_vertex>
  6805. #include <defaultnormal_vertex>
  6806. #include <normal_vertex>
  6807. #include <begin_vertex>
  6808. #include <morphtarget_vertex>
  6809. #include <skinning_vertex>
  6810. #include <displacementmap_vertex>
  6811. #include <project_vertex>
  6812. #include <logdepthbuf_vertex>
  6813. #include <clipping_planes_vertex>
  6814. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6815. vViewPosition = - mvPosition.xyz;
  6816. #endif
  6817. }`,iUe=`#define NORMAL
  6818. uniform float opacity;
  6819. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6820. varying vec3 vViewPosition;
  6821. #endif
  6822. #include <packing>
  6823. #include <uv_pars_fragment>
  6824. #include <normal_pars_fragment>
  6825. #include <bumpmap_pars_fragment>
  6826. #include <normalmap_pars_fragment>
  6827. #include <logdepthbuf_pars_fragment>
  6828. #include <clipping_planes_pars_fragment>
  6829. void main() {
  6830. #include <clipping_planes_fragment>
  6831. #include <logdepthbuf_fragment>
  6832. #include <normal_fragment_begin>
  6833. #include <normal_fragment_maps>
  6834. gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
  6835. #ifdef OPAQUE
  6836. gl_FragColor.a = 1.0;
  6837. #endif
  6838. }`,aUe=`#define PHONG
  6839. varying vec3 vViewPosition;
  6840. #include <common>
  6841. #include <batching_pars_vertex>
  6842. #include <uv_pars_vertex>
  6843. #include <displacementmap_pars_vertex>
  6844. #include <envmap_pars_vertex>
  6845. #include <color_pars_vertex>
  6846. #include <fog_pars_vertex>
  6847. #include <normal_pars_vertex>
  6848. #include <morphtarget_pars_vertex>
  6849. #include <skinning_pars_vertex>
  6850. #include <shadowmap_pars_vertex>
  6851. #include <logdepthbuf_pars_vertex>
  6852. #include <clipping_planes_pars_vertex>
  6853. void main() {
  6854. #include <uv_vertex>
  6855. #include <color_vertex>
  6856. #include <morphcolor_vertex>
  6857. #include <batching_vertex>
  6858. #include <beginnormal_vertex>
  6859. #include <morphnormal_vertex>
  6860. #include <skinbase_vertex>
  6861. #include <skinnormal_vertex>
  6862. #include <defaultnormal_vertex>
  6863. #include <normal_vertex>
  6864. #include <begin_vertex>
  6865. #include <morphtarget_vertex>
  6866. #include <skinning_vertex>
  6867. #include <displacementmap_vertex>
  6868. #include <project_vertex>
  6869. #include <logdepthbuf_vertex>
  6870. #include <clipping_planes_vertex>
  6871. vViewPosition = - mvPosition.xyz;
  6872. #include <worldpos_vertex>
  6873. #include <envmap_vertex>
  6874. #include <shadowmap_vertex>
  6875. #include <fog_vertex>
  6876. }`,sUe=`#define PHONG
  6877. uniform vec3 diffuse;
  6878. uniform vec3 emissive;
  6879. uniform vec3 specular;
  6880. uniform float shininess;
  6881. uniform float opacity;
  6882. #include <common>
  6883. #include <packing>
  6884. #include <dithering_pars_fragment>
  6885. #include <color_pars_fragment>
  6886. #include <uv_pars_fragment>
  6887. #include <map_pars_fragment>
  6888. #include <alphamap_pars_fragment>
  6889. #include <alphatest_pars_fragment>
  6890. #include <alphahash_pars_fragment>
  6891. #include <aomap_pars_fragment>
  6892. #include <lightmap_pars_fragment>
  6893. #include <emissivemap_pars_fragment>
  6894. #include <envmap_common_pars_fragment>
  6895. #include <envmap_pars_fragment>
  6896. #include <fog_pars_fragment>
  6897. #include <bsdfs>
  6898. #include <lights_pars_begin>
  6899. #include <normal_pars_fragment>
  6900. #include <lights_phong_pars_fragment>
  6901. #include <shadowmap_pars_fragment>
  6902. #include <bumpmap_pars_fragment>
  6903. #include <normalmap_pars_fragment>
  6904. #include <specularmap_pars_fragment>
  6905. #include <logdepthbuf_pars_fragment>
  6906. #include <clipping_planes_pars_fragment>
  6907. void main() {
  6908. #include <clipping_planes_fragment>
  6909. vec4 diffuseColor = vec4( diffuse, opacity );
  6910. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6911. vec3 totalEmissiveRadiance = emissive;
  6912. #include <logdepthbuf_fragment>
  6913. #include <map_fragment>
  6914. #include <color_fragment>
  6915. #include <alphamap_fragment>
  6916. #include <alphatest_fragment>
  6917. #include <alphahash_fragment>
  6918. #include <specularmap_fragment>
  6919. #include <normal_fragment_begin>
  6920. #include <normal_fragment_maps>
  6921. #include <emissivemap_fragment>
  6922. #include <lights_phong_fragment>
  6923. #include <lights_fragment_begin>
  6924. #include <lights_fragment_maps>
  6925. #include <lights_fragment_end>
  6926. #include <aomap_fragment>
  6927. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  6928. #include <envmap_fragment>
  6929. #include <opaque_fragment>
  6930. #include <tonemapping_fragment>
  6931. #include <colorspace_fragment>
  6932. #include <fog_fragment>
  6933. #include <premultiplied_alpha_fragment>
  6934. #include <dithering_fragment>
  6935. }`,oUe=`#define STANDARD
  6936. varying vec3 vViewPosition;
  6937. #ifdef USE_TRANSMISSION
  6938. varying vec3 vWorldPosition;
  6939. #endif
  6940. #include <common>
  6941. #include <batching_pars_vertex>
  6942. #include <uv_pars_vertex>
  6943. #include <displacementmap_pars_vertex>
  6944. #include <color_pars_vertex>
  6945. #include <fog_pars_vertex>
  6946. #include <normal_pars_vertex>
  6947. #include <morphtarget_pars_vertex>
  6948. #include <skinning_pars_vertex>
  6949. #include <shadowmap_pars_vertex>
  6950. #include <logdepthbuf_pars_vertex>
  6951. #include <clipping_planes_pars_vertex>
  6952. void main() {
  6953. #include <uv_vertex>
  6954. #include <color_vertex>
  6955. #include <morphcolor_vertex>
  6956. #include <batching_vertex>
  6957. #include <beginnormal_vertex>
  6958. #include <morphnormal_vertex>
  6959. #include <skinbase_vertex>
  6960. #include <skinnormal_vertex>
  6961. #include <defaultnormal_vertex>
  6962. #include <normal_vertex>
  6963. #include <begin_vertex>
  6964. #include <morphtarget_vertex>
  6965. #include <skinning_vertex>
  6966. #include <displacementmap_vertex>
  6967. #include <project_vertex>
  6968. #include <logdepthbuf_vertex>
  6969. #include <clipping_planes_vertex>
  6970. vViewPosition = - mvPosition.xyz;
  6971. #include <worldpos_vertex>
  6972. #include <shadowmap_vertex>
  6973. #include <fog_vertex>
  6974. #ifdef USE_TRANSMISSION
  6975. vWorldPosition = worldPosition.xyz;
  6976. #endif
  6977. }`,lUe=`#define STANDARD
  6978. #ifdef PHYSICAL
  6979. #define IOR
  6980. #define USE_SPECULAR
  6981. #endif
  6982. uniform vec3 diffuse;
  6983. uniform vec3 emissive;
  6984. uniform float roughness;
  6985. uniform float metalness;
  6986. uniform float opacity;
  6987. #ifdef IOR
  6988. uniform float ior;
  6989. #endif
  6990. #ifdef USE_SPECULAR
  6991. uniform float specularIntensity;
  6992. uniform vec3 specularColor;
  6993. #ifdef USE_SPECULAR_COLORMAP
  6994. uniform sampler2D specularColorMap;
  6995. #endif
  6996. #ifdef USE_SPECULAR_INTENSITYMAP
  6997. uniform sampler2D specularIntensityMap;
  6998. #endif
  6999. #endif
  7000. #ifdef USE_CLEARCOAT
  7001. uniform float clearcoat;
  7002. uniform float clearcoatRoughness;
  7003. #endif
  7004. #ifdef USE_IRIDESCENCE
  7005. uniform float iridescence;
  7006. uniform float iridescenceIOR;
  7007. uniform float iridescenceThicknessMinimum;
  7008. uniform float iridescenceThicknessMaximum;
  7009. #endif
  7010. #ifdef USE_SHEEN
  7011. uniform vec3 sheenColor;
  7012. uniform float sheenRoughness;
  7013. #ifdef USE_SHEEN_COLORMAP
  7014. uniform sampler2D sheenColorMap;
  7015. #endif
  7016. #ifdef USE_SHEEN_ROUGHNESSMAP
  7017. uniform sampler2D sheenRoughnessMap;
  7018. #endif
  7019. #endif
  7020. #ifdef USE_ANISOTROPY
  7021. uniform vec2 anisotropyVector;
  7022. #ifdef USE_ANISOTROPYMAP
  7023. uniform sampler2D anisotropyMap;
  7024. #endif
  7025. #endif
  7026. varying vec3 vViewPosition;
  7027. #include <common>
  7028. #include <packing>
  7029. #include <dithering_pars_fragment>
  7030. #include <color_pars_fragment>
  7031. #include <uv_pars_fragment>
  7032. #include <map_pars_fragment>
  7033. #include <alphamap_pars_fragment>
  7034. #include <alphatest_pars_fragment>
  7035. #include <alphahash_pars_fragment>
  7036. #include <aomap_pars_fragment>
  7037. #include <lightmap_pars_fragment>
  7038. #include <emissivemap_pars_fragment>
  7039. #include <iridescence_fragment>
  7040. #include <cube_uv_reflection_fragment>
  7041. #include <envmap_common_pars_fragment>
  7042. #include <envmap_physical_pars_fragment>
  7043. #include <fog_pars_fragment>
  7044. #include <lights_pars_begin>
  7045. #include <normal_pars_fragment>
  7046. #include <lights_physical_pars_fragment>
  7047. #include <transmission_pars_fragment>
  7048. #include <shadowmap_pars_fragment>
  7049. #include <bumpmap_pars_fragment>
  7050. #include <normalmap_pars_fragment>
  7051. #include <clearcoat_pars_fragment>
  7052. #include <iridescence_pars_fragment>
  7053. #include <roughnessmap_pars_fragment>
  7054. #include <metalnessmap_pars_fragment>
  7055. #include <logdepthbuf_pars_fragment>
  7056. #include <clipping_planes_pars_fragment>
  7057. void main() {
  7058. #include <clipping_planes_fragment>
  7059. vec4 diffuseColor = vec4( diffuse, opacity );
  7060. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  7061. vec3 totalEmissiveRadiance = emissive;
  7062. #include <logdepthbuf_fragment>
  7063. #include <map_fragment>
  7064. #include <color_fragment>
  7065. #include <alphamap_fragment>
  7066. #include <alphatest_fragment>
  7067. #include <alphahash_fragment>
  7068. #include <roughnessmap_fragment>
  7069. #include <metalnessmap_fragment>
  7070. #include <normal_fragment_begin>
  7071. #include <normal_fragment_maps>
  7072. #include <clearcoat_normal_fragment_begin>
  7073. #include <clearcoat_normal_fragment_maps>
  7074. #include <emissivemap_fragment>
  7075. #include <lights_physical_fragment>
  7076. #include <lights_fragment_begin>
  7077. #include <lights_fragment_maps>
  7078. #include <lights_fragment_end>
  7079. #include <aomap_fragment>
  7080. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  7081. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  7082. #include <transmission_fragment>
  7083. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  7084. #ifdef USE_SHEEN
  7085. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  7086. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  7087. #endif
  7088. #ifdef USE_CLEARCOAT
  7089. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  7090. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  7091. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  7092. #endif
  7093. #include <opaque_fragment>
  7094. #include <tonemapping_fragment>
  7095. #include <colorspace_fragment>
  7096. #include <fog_fragment>
  7097. #include <premultiplied_alpha_fragment>
  7098. #include <dithering_fragment>
  7099. }`,cUe=`#define TOON
  7100. varying vec3 vViewPosition;
  7101. #include <common>
  7102. #include <batching_pars_vertex>
  7103. #include <uv_pars_vertex>
  7104. #include <displacementmap_pars_vertex>
  7105. #include <color_pars_vertex>
  7106. #include <fog_pars_vertex>
  7107. #include <normal_pars_vertex>
  7108. #include <morphtarget_pars_vertex>
  7109. #include <skinning_pars_vertex>
  7110. #include <shadowmap_pars_vertex>
  7111. #include <logdepthbuf_pars_vertex>
  7112. #include <clipping_planes_pars_vertex>
  7113. void main() {
  7114. #include <uv_vertex>
  7115. #include <color_vertex>
  7116. #include <morphcolor_vertex>
  7117. #include <batching_vertex>
  7118. #include <beginnormal_vertex>
  7119. #include <morphnormal_vertex>
  7120. #include <skinbase_vertex>
  7121. #include <skinnormal_vertex>
  7122. #include <defaultnormal_vertex>
  7123. #include <normal_vertex>
  7124. #include <begin_vertex>
  7125. #include <morphtarget_vertex>
  7126. #include <skinning_vertex>
  7127. #include <displacementmap_vertex>
  7128. #include <project_vertex>
  7129. #include <logdepthbuf_vertex>
  7130. #include <clipping_planes_vertex>
  7131. vViewPosition = - mvPosition.xyz;
  7132. #include <worldpos_vertex>
  7133. #include <shadowmap_vertex>
  7134. #include <fog_vertex>
  7135. }`,uUe=`#define TOON
  7136. uniform vec3 diffuse;
  7137. uniform vec3 emissive;
  7138. uniform float opacity;
  7139. #include <common>
  7140. #include <packing>
  7141. #include <dithering_pars_fragment>
  7142. #include <color_pars_fragment>
  7143. #include <uv_pars_fragment>
  7144. #include <map_pars_fragment>
  7145. #include <alphamap_pars_fragment>
  7146. #include <alphatest_pars_fragment>
  7147. #include <alphahash_pars_fragment>
  7148. #include <aomap_pars_fragment>
  7149. #include <lightmap_pars_fragment>
  7150. #include <emissivemap_pars_fragment>
  7151. #include <gradientmap_pars_fragment>
  7152. #include <fog_pars_fragment>
  7153. #include <bsdfs>
  7154. #include <lights_pars_begin>
  7155. #include <normal_pars_fragment>
  7156. #include <lights_toon_pars_fragment>
  7157. #include <shadowmap_pars_fragment>
  7158. #include <bumpmap_pars_fragment>
  7159. #include <normalmap_pars_fragment>
  7160. #include <logdepthbuf_pars_fragment>
  7161. #include <clipping_planes_pars_fragment>
  7162. void main() {
  7163. #include <clipping_planes_fragment>
  7164. vec4 diffuseColor = vec4( diffuse, opacity );
  7165. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  7166. vec3 totalEmissiveRadiance = emissive;
  7167. #include <logdepthbuf_fragment>
  7168. #include <map_fragment>
  7169. #include <color_fragment>
  7170. #include <alphamap_fragment>
  7171. #include <alphatest_fragment>
  7172. #include <alphahash_fragment>
  7173. #include <normal_fragment_begin>
  7174. #include <normal_fragment_maps>
  7175. #include <emissivemap_fragment>
  7176. #include <lights_toon_fragment>
  7177. #include <lights_fragment_begin>
  7178. #include <lights_fragment_maps>
  7179. #include <lights_fragment_end>
  7180. #include <aomap_fragment>
  7181. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  7182. #include <opaque_fragment>
  7183. #include <tonemapping_fragment>
  7184. #include <colorspace_fragment>
  7185. #include <fog_fragment>
  7186. #include <premultiplied_alpha_fragment>
  7187. #include <dithering_fragment>
  7188. }`,dUe=`uniform float size;
  7189. uniform float scale;
  7190. #include <common>
  7191. #include <color_pars_vertex>
  7192. #include <fog_pars_vertex>
  7193. #include <morphtarget_pars_vertex>
  7194. #include <logdepthbuf_pars_vertex>
  7195. #include <clipping_planes_pars_vertex>
  7196. #ifdef USE_POINTS_UV
  7197. varying vec2 vUv;
  7198. uniform mat3 uvTransform;
  7199. #endif
  7200. void main() {
  7201. #ifdef USE_POINTS_UV
  7202. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  7203. #endif
  7204. #include <color_vertex>
  7205. #include <morphcolor_vertex>
  7206. #include <begin_vertex>
  7207. #include <morphtarget_vertex>
  7208. #include <project_vertex>
  7209. gl_PointSize = size;
  7210. #ifdef USE_SIZEATTENUATION
  7211. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7212. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  7213. #endif
  7214. #include <logdepthbuf_vertex>
  7215. #include <clipping_planes_vertex>
  7216. #include <worldpos_vertex>
  7217. #include <fog_vertex>
  7218. }`,hUe=`uniform vec3 diffuse;
  7219. uniform float opacity;
  7220. #include <common>
  7221. #include <color_pars_fragment>
  7222. #include <map_particle_pars_fragment>
  7223. #include <alphatest_pars_fragment>
  7224. #include <alphahash_pars_fragment>
  7225. #include <fog_pars_fragment>
  7226. #include <logdepthbuf_pars_fragment>
  7227. #include <clipping_planes_pars_fragment>
  7228. void main() {
  7229. #include <clipping_planes_fragment>
  7230. vec3 outgoingLight = vec3( 0.0 );
  7231. vec4 diffuseColor = vec4( diffuse, opacity );
  7232. #include <logdepthbuf_fragment>
  7233. #include <map_particle_fragment>
  7234. #include <color_fragment>
  7235. #include <alphatest_fragment>
  7236. #include <alphahash_fragment>
  7237. outgoingLight = diffuseColor.rgb;
  7238. #include <opaque_fragment>
  7239. #include <tonemapping_fragment>
  7240. #include <colorspace_fragment>
  7241. #include <fog_fragment>
  7242. #include <premultiplied_alpha_fragment>
  7243. }`,fUe=`#include <common>
  7244. #include <batching_pars_vertex>
  7245. #include <fog_pars_vertex>
  7246. #include <morphtarget_pars_vertex>
  7247. #include <skinning_pars_vertex>
  7248. #include <logdepthbuf_pars_vertex>
  7249. #include <shadowmap_pars_vertex>
  7250. void main() {
  7251. #include <batching_vertex>
  7252. #include <beginnormal_vertex>
  7253. #include <morphnormal_vertex>
  7254. #include <skinbase_vertex>
  7255. #include <skinnormal_vertex>
  7256. #include <defaultnormal_vertex>
  7257. #include <begin_vertex>
  7258. #include <morphtarget_vertex>
  7259. #include <skinning_vertex>
  7260. #include <project_vertex>
  7261. #include <logdepthbuf_vertex>
  7262. #include <worldpos_vertex>
  7263. #include <shadowmap_vertex>
  7264. #include <fog_vertex>
  7265. }`,mUe=`uniform vec3 color;
  7266. uniform float opacity;
  7267. #include <common>
  7268. #include <packing>
  7269. #include <fog_pars_fragment>
  7270. #include <bsdfs>
  7271. #include <lights_pars_begin>
  7272. #include <logdepthbuf_pars_fragment>
  7273. #include <shadowmap_pars_fragment>
  7274. #include <shadowmask_pars_fragment>
  7275. void main() {
  7276. #include <logdepthbuf_fragment>
  7277. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  7278. #include <tonemapping_fragment>
  7279. #include <colorspace_fragment>
  7280. #include <fog_fragment>
  7281. }`,pUe=`uniform float rotation;
  7282. uniform vec2 center;
  7283. #include <common>
  7284. #include <uv_pars_vertex>
  7285. #include <fog_pars_vertex>
  7286. #include <logdepthbuf_pars_vertex>
  7287. #include <clipping_planes_pars_vertex>
  7288. void main() {
  7289. #include <uv_vertex>
  7290. vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
  7291. vec2 scale;
  7292. scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
  7293. scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
  7294. #ifndef USE_SIZEATTENUATION
  7295. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7296. if ( isPerspective ) scale *= - mvPosition.z;
  7297. #endif
  7298. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  7299. vec2 rotatedPosition;
  7300. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  7301. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  7302. mvPosition.xy += rotatedPosition;
  7303. gl_Position = projectionMatrix * mvPosition;
  7304. #include <logdepthbuf_vertex>
  7305. #include <clipping_planes_vertex>
  7306. #include <fog_vertex>
  7307. }`,gUe=`uniform vec3 diffuse;
  7308. uniform float opacity;
  7309. #include <common>
  7310. #include <uv_pars_fragment>
  7311. #include <map_pars_fragment>
  7312. #include <alphamap_pars_fragment>
  7313. #include <alphatest_pars_fragment>
  7314. #include <alphahash_pars_fragment>
  7315. #include <fog_pars_fragment>
  7316. #include <logdepthbuf_pars_fragment>
  7317. #include <clipping_planes_pars_fragment>
  7318. void main() {
  7319. #include <clipping_planes_fragment>
  7320. vec3 outgoingLight = vec3( 0.0 );
  7321. vec4 diffuseColor = vec4( diffuse, opacity );
  7322. #include <logdepthbuf_fragment>
  7323. #include <map_fragment>
  7324. #include <alphamap_fragment>
  7325. #include <alphatest_fragment>
  7326. #include <alphahash_fragment>
  7327. outgoingLight = diffuseColor.rgb;
  7328. #include <opaque_fragment>
  7329. #include <tonemapping_fragment>
  7330. #include <colorspace_fragment>
  7331. #include <fog_fragment>
  7332. }`,kn={alphahash_fragment:IFe,alphahash_pars_fragment:UFe,alphamap_fragment:zFe,alphamap_pars_fragment:BFe,alphatest_fragment:$Fe,alphatest_pars_fragment:HFe,aomap_fragment:VFe,aomap_pars_fragment:GFe,batching_pars_vertex:qFe,batching_vertex:WFe,begin_vertex:KFe,beginnormal_vertex:XFe,bsdfs:YFe,iridescence_fragment:QFe,bumpmap_pars_fragment:ZFe,clipping_planes_fragment:JFe,clipping_planes_pars_fragment:eIe,clipping_planes_pars_vertex:tIe,clipping_planes_vertex:nIe,color_fragment:rIe,color_pars_fragment:iIe,color_pars_vertex:aIe,color_vertex:sIe,common:oIe,cube_uv_reflection_fragment:lIe,defaultnormal_vertex:cIe,displacementmap_pars_vertex:uIe,displacementmap_vertex:dIe,emissivemap_fragment:hIe,emissivemap_pars_fragment:fIe,colorspace_fragment:mIe,colorspace_pars_fragment:pIe,envmap_fragment:gIe,envmap_common_pars_fragment:xIe,envmap_pars_fragment:bIe,envmap_pars_vertex:yIe,envmap_physical_pars_fragment:jIe,envmap_vertex:vIe,fog_vertex:wIe,fog_pars_vertex:_Ie,fog_fragment:SIe,fog_pars_fragment:NIe,gradientmap_pars_fragment:MIe,lightmap_fragment:EIe,lightmap_pars_fragment:kIe,lights_lambert_fragment:TIe,lights_lambert_pars_fragment:AIe,lights_pars_begin:CIe,lights_toon_fragment:PIe,lights_toon_pars_fragment:DIe,lights_phong_fragment:RIe,lights_phong_pars_fragment:OIe,lights_physical_fragment:LIe,lights_physical_pars_fragment:FIe,lights_fragment_begin:IIe,lights_fragment_maps:UIe,lights_fragment_end:zIe,logdepthbuf_fragment:BIe,logdepthbuf_pars_fragment:$Ie,logdepthbuf_pars_vertex:HIe,logdepthbuf_vertex:VIe,map_fragment:GIe,map_pars_fragment:qIe,map_particle_fragment:WIe,map_particle_pars_fragment:KIe,metalnessmap_fragment:XIe,metalnessmap_pars_fragment:YIe,morphcolor_vertex:QIe,morphnormal_vertex:ZIe,morphtarget_pars_vertex:JIe,morphtarget_vertex:e5e,normal_fragment_begin:t5e,normal_fragment_maps:n5e,normal_pars_fragment:r5e,normal_pars_vertex:i5e,normal_vertex:a5e,normalmap_pars_fragment:s5e,clearcoat_normal_fragment_begin:o5e,clearcoat_normal_fragment_maps:l5e,clearcoat_pars_fragment:c5e,iridescence_pars_fragment:u5e,opaque_fragment:d5e,packing:h5e,premultiplied_alpha_fragment:f5e,project_vertex:m5e,dithering_fragment:p5e,dithering_pars_fragment:g5e,roughnessmap_fragment:x5e,roughnessmap_pars_fragment:b5e,shadowmap_pars_fragment:y5e,shadowmap_pars_vertex:v5e,shadowmap_vertex:w5e,shadowmask_pars_fragment:_5e,skinbase_vertex:S5e,skinning_pars_vertex:N5e,skinning_vertex:M5e,skinnormal_vertex:E5e,specularmap_fragment:k5e,specularmap_pars_fragment:T5e,tonemapping_fragment:A5e,tonemapping_pars_fragment:C5e,transmission_fragment:j5e,transmission_pars_fragment:P5e,uv_pars_fragment:D5e,uv_pars_vertex:R5e,uv_vertex:O5e,worldpos_vertex:L5e,background_vert:F5e,background_frag:I5e,backgroundCube_vert:U5e,backgroundCube_frag:z5e,cube_vert:B5e,cube_frag:$5e,depth_vert:H5e,depth_frag:V5e,distanceRGBA_vert:G5e,distanceRGBA_frag:q5e,equirect_vert:W5e,equirect_frag:K5e,linedashed_vert:X5e,linedashed_frag:Y5e,meshbasic_vert:Q5e,meshbasic_frag:Z5e,meshlambert_vert:J5e,meshlambert_frag:eUe,meshmatcap_vert:tUe,meshmatcap_frag:nUe,meshnormal_vert:rUe,meshnormal_frag:iUe,meshphong_vert:aUe,meshphong_frag:sUe,meshphysical_vert:oUe,meshphysical_frag:lUe,meshtoon_vert:cUe,meshtoon_frag:uUe,points_vert:dUe,points_frag:hUe,shadow_vert:fUe,shadow_frag:mUe,sprite_vert:pUe,sprite_frag:gUe},Dt={common:{diffuse:{value:new Zt(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 Zt(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 Zt(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 Zt(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}}},Rs={basic:{uniforms:us([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.fog]),vertexShader:kn.meshbasic_vert,fragmentShader:kn.meshbasic_frag},lambert:{uniforms:us([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,Dt.lights,{emissive:{value:new Zt(0)}}]),vertexShader:kn.meshlambert_vert,fragmentShader:kn.meshlambert_frag},phong:{uniforms:us([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,Dt.lights,{emissive:{value:new Zt(0)},specular:{value:new Zt(1118481)},shininess:{value:30}}]),vertexShader:kn.meshphong_vert,fragmentShader:kn.meshphong_frag},standard:{uniforms:us([Dt.common,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.roughnessmap,Dt.metalnessmap,Dt.fog,Dt.lights,{emissive:{value:new Zt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:kn.meshphysical_vert,fragmentShader:kn.meshphysical_frag},toon:{uniforms:us([Dt.common,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.gradientmap,Dt.fog,Dt.lights,{emissive:{value:new Zt(0)}}]),vertexShader:kn.meshtoon_vert,fragmentShader:kn.meshtoon_frag},matcap:{uniforms:us([Dt.common,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,{matcap:{value:null}}]),vertexShader:kn.meshmatcap_vert,fragmentShader:kn.meshmatcap_frag},points:{uniforms:us([Dt.points,Dt.fog]),vertexShader:kn.points_vert,fragmentShader:kn.points_frag},dashed:{uniforms:us([Dt.common,Dt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:kn.linedashed_vert,fragmentShader:kn.linedashed_frag},depth:{uniforms:us([Dt.common,Dt.displacementmap]),vertexShader:kn.depth_vert,fragmentShader:kn.depth_frag},normal:{uniforms:us([Dt.common,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,{opacity:{value:1}}]),vertexShader:kn.meshnormal_vert,fragmentShader:kn.meshnormal_frag},sprite:{uniforms:us([Dt.sprite,Dt.fog]),vertexShader:kn.sprite_vert,fragmentShader:kn.sprite_frag},background:{uniforms:{uvTransform:{value:new Ln},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:kn.background_vert,fragmentShader:kn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:kn.backgroundCube_vert,fragmentShader:kn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:kn.cube_vert,fragmentShader:kn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:kn.equirect_vert,fragmentShader:kn.equirect_frag},distanceRGBA:{uniforms:us([Dt.common,Dt.displacementmap,{referencePosition:{value:new qe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:kn.distanceRGBA_vert,fragmentShader:kn.distanceRGBA_frag},shadow:{uniforms:us([Dt.lights,Dt.fog,{color:{value:new Zt(0)},opacity:{value:1}}]),vertexShader:kn.shadow_vert,fragmentShader:kn.shadow_frag}};Rs.physical={uniforms:us([Rs.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 Zt(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 Zt(0)},specularColor:{value:new Zt(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:kn.meshphysical_vert,fragmentShader:kn.meshphysical_frag};const $_={r:0,b:0,g:0};function xUe(t,e,n,r,i,a,o){const l=new Zt(0);let c=a===!0?0:1,u,d,f=null,p=0,m=null;function x(y,v){let S=!1,M=v.isScene===!0?v.background:null;M&&M.isTexture&&(M=(v.backgroundBlurriness>0?n:e).get(M)),M===null?b(l,c):M&&M.isColor&&(b(M,1),S=!0);const T=t.xr.getEnvironmentBlendMode();T==="additive"?r.buffers.color.setClear(0,0,0,1,o):T==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,o),(t.autoClear||S)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),M&&(M.isCubeTexture||M.mapping===bM)?(d===void 0&&(d=new Dl(new mv(1,1,1),new Ah({name:"BackgroundCubeMaterial",uniforms:ax(Rs.backgroundCube.uniforms),vertexShader:Rs.backgroundCube.vertexShader,fragmentShader:Rs.backgroundCube.fragmentShader,side:zs,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(E,C,k){this.matrixWorld.copyPosition(k.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),d.material.uniforms.envMap.value=M,d.material.uniforms.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,d.material.toneMapped=kr.getTransfer(M.colorSpace)!==Gr,(f!==M||p!==M.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,f=M,p=M.version,m=t.toneMapping),d.layers.enableAll(),y.unshift(d,d.geometry,d.material,0,0,null)):M&&M.isTexture&&(u===void 0&&(u=new Dl(new cL(2,2),new Ah({name:"BackgroundMaterial",uniforms:ax(Rs.background.uniforms),vertexShader:Rs.background.vertexShader,fragmentShader:Rs.background.fragmentShader,side:Th,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=M,u.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,u.material.toneMapped=kr.getTransfer(M.colorSpace)!==Gr,M.matrixAutoUpdate===!0&&M.updateMatrix(),u.material.uniforms.uvTransform.value.copy(M.matrix),(f!==M||p!==M.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,f=M,p=M.version,m=t.toneMapping),u.layers.enableAll(),y.unshift(u,u.geometry,u.material,0,0,null))}function b(y,v){y.getRGB($_,nee(t)),r.buffers.color.setClear($_.r,$_.g,$_.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 bUe(t,e,n,r){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),a=r.isWebGL2?null:e.get("OES_vertex_array_object"),o=r.isWebGL2||a!==null,l={},c=y(null);let u=c,d=!1;function f(j,$,K,V,Q){let Z=!1;if(o){const ae=b(V,K,$);u!==ae&&(u=ae,m(u.object)),Z=v(j,V,K,Q),Z&&S(j,V,K,Q)}else{const ae=$.wireframe===!0;(u.geometry!==V.id||u.program!==K.id||u.wireframe!==ae)&&(u.geometry=V.id,u.program=K.id,u.wireframe=ae,Z=!0)}Q!==null&&n.update(Q,t.ELEMENT_ARRAY_BUFFER),(Z||d)&&(d=!1,R(j,$,K,V),Q!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(Q).buffer))}function p(){return r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function m(j){return r.isWebGL2?t.bindVertexArray(j):a.bindVertexArrayOES(j)}function x(j){return r.isWebGL2?t.deleteVertexArray(j):a.deleteVertexArrayOES(j)}function b(j,$,K){const V=K.wireframe===!0;let Q=l[j.id];Q===void 0&&(Q={},l[j.id]=Q);let Z=Q[$.id];Z===void 0&&(Z={},Q[$.id]=Z);let ae=Z[V];return ae===void 0&&(ae=y(p()),Z[V]=ae),ae}function y(j){const $=[],K=[],V=[];for(let Q=0;Q<i;Q++)$[Q]=0,K[Q]=0,V[Q]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:$,enabledAttributes:K,attributeDivisors:V,object:j,attributes:{},index:null}}function v(j,$,K,V){const Q=u.attributes,Z=$.attributes;let ae=0;const B=K.getAttributes();for(const X in B)if(B[X].location>=0){const se=Q[X];let be=Z[X];if(be===void 0&&(X==="instanceMatrix"&&j.instanceMatrix&&(be=j.instanceMatrix),X==="instanceColor"&&j.instanceColor&&(be=j.instanceColor)),se===void 0||se.attribute!==be||be&&se.data!==be.data)return!0;ae++}return u.attributesNum!==ae||u.index!==V}function S(j,$,K,V){const Q={},Z=$.attributes;let ae=0;const B=K.getAttributes();for(const X in B)if(B[X].location>=0){let se=Z[X];se===void 0&&(X==="instanceMatrix"&&j.instanceMatrix&&(se=j.instanceMatrix),X==="instanceColor"&&j.instanceColor&&(se=j.instanceColor));const be={};be.attribute=se,se&&se.data&&(be.data=se.data),Q[X]=be,ae++}u.attributes=Q,u.attributesNum=ae,u.index=V}function M(){const j=u.newAttributes;for(let $=0,K=j.length;$<K;$++)j[$]=0}function T(j){E(j,0)}function E(j,$){const K=u.newAttributes,V=u.enabledAttributes,Q=u.attributeDivisors;K[j]=1,V[j]===0&&(t.enableVertexAttribArray(j),V[j]=1),Q[j]!==$&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](j,$),Q[j]=$)}function C(){const j=u.newAttributes,$=u.enabledAttributes;for(let K=0,V=$.length;K<V;K++)$[K]!==j[K]&&(t.disableVertexAttribArray(K),$[K]=0)}function k(j,$,K,V,Q,Z,ae){ae===!0?t.vertexAttribIPointer(j,$,K,Q,Z):t.vertexAttribPointer(j,$,K,V,Q,Z)}function R(j,$,K,V){if(r.isWebGL2===!1&&(j.isInstancedMesh||V.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;M();const Q=V.attributes,Z=K.getAttributes(),ae=$.defaultAttributeValues;for(const B in Z){const X=Z[B];if(X.location>=0){let ne=Q[B];if(ne===void 0&&(B==="instanceMatrix"&&j.instanceMatrix&&(ne=j.instanceMatrix),B==="instanceColor"&&j.instanceColor&&(ne=j.instanceColor)),ne!==void 0){const se=ne.normalized,be=ne.itemSize,xe=n.get(ne);if(xe===void 0)continue;const de=xe.buffer,Pe=xe.type,ie=xe.bytesPerElement,Me=r.isWebGL2===!0&&(Pe===t.INT||Pe===t.UNSIGNED_INT||ne.gpuType===LJ);if(ne.isInterleavedBufferAttribute){const Oe=ne.data,ge=Oe.stride,Ke=ne.offset;if(Oe.isInstancedInterleavedBuffer){for(let G=0;G<X.locationSize;G++)E(X.location+G,Oe.meshPerAttribute);j.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=Oe.meshPerAttribute*Oe.count)}else for(let G=0;G<X.locationSize;G++)T(X.location+G);t.bindBuffer(t.ARRAY_BUFFER,de);for(let G=0;G<X.locationSize;G++)k(X.location+G,be/X.locationSize,Pe,se,ge*ie,(Ke+be/X.locationSize*G)*ie,Me)}else{if(ne.isInstancedBufferAttribute){for(let Oe=0;Oe<X.locationSize;Oe++)E(X.location+Oe,ne.meshPerAttribute);j.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let Oe=0;Oe<X.locationSize;Oe++)T(X.location+Oe);t.bindBuffer(t.ARRAY_BUFFER,de);for(let Oe=0;Oe<X.locationSize;Oe++)k(X.location+Oe,be/X.locationSize,Pe,se,be*ie,be/X.locationSize*Oe*ie,Me)}}else if(ae!==void 0){const se=ae[B];if(se!==void 0)switch(se.length){case 2:t.vertexAttrib2fv(X.location,se);break;case 3:t.vertexAttrib3fv(X.location,se);break;case 4:t.vertexAttrib4fv(X.location,se);break;default:t.vertexAttrib1fv(X.location,se)}}}}C()}function A(){F();for(const j in l){const $=l[j];for(const K in $){const V=$[K];for(const Q in V)x(V[Q].object),delete V[Q];delete $[K]}delete l[j]}}function D(j){if(l[j.id]===void 0)return;const $=l[j.id];for(const K in $){const V=$[K];for(const Q in V)x(V[Q].object),delete V[Q];delete $[K]}delete l[j.id]}function U(j){for(const $ in l){const K=l[$];if(K[j.id]===void 0)continue;const V=K[j.id];for(const Q in V)x(V[Q].object),delete V[Q];delete K[j.id]}}function F(){H(),d=!0,u!==c&&(u=c,m(u.object))}function H(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:f,reset:F,resetDefaultState:H,dispose:A,releaseStatesOfGeometry:D,releaseStatesOfProgram:U,initAttributes:M,enableAttribute:T,disableUnusedAttributes:C}}function yUe(t,e,n,r){const i=r.isWebGL2;let a;function o(d){a=d}function l(d,f){t.drawArrays(a,d,f),n.update(f,a,1)}function c(d,f,p){if(p===0)return;let m,x;if(i)m=t,x="drawArraysInstanced";else if(m=e.get("ANGLE_instanced_arrays"),x="drawArraysInstancedANGLE",m===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}m[x](a,d,f,p),n.update(f,a,p)}function u(d,f,p){if(p===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let x=0;x<p;x++)this.render(d[x],f[x]);else{m.multiDrawArraysWEBGL(a,d,0,f,0,p);let x=0;for(let b=0;b<p;b++)x+=f[b];n.update(x,a,1)}}this.setMode=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function vUe(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const k=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(k.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(k){if(k==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";k="mediump"}return k==="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=a(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),p=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=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),M=p>0,T=o||e.has("OES_texture_float"),E=M&&T,C=o?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:a,precision:l,logarithmicDepthBuffer:d,maxTextures:f,maxVertexTextures:p,maxTextureSize:m,maxCubemapSize:x,maxAttributes:b,maxVertexUniforms:y,maxVaryings:v,maxFragmentUniforms:S,vertexTextures:M,floatFragmentTextures:T,floatVertexTextures:E,maxSamples:C}}function wUe(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new $d,l=new Ln,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,p){const m=f.length!==0||p||r!==0||i;return i=p,r=f.length,m},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,p){n=d(f,p,0)},this.setState=function(f,p,m){const x=f.clippingPlanes,b=f.clipIntersection,y=f.clipShadows,v=t.get(f);if(!i||x===null||x.length===0||a&&!y)a?d(null):u();else{const S=a?0:r,M=S*4;let T=v.clippingState||null;c.value=T,T=d(x,p,M,m);for(let E=0;E!==M;++E)T[E]=n[E];v.clippingState=T,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,p,m,x){const b=f!==null?f.length:0;let y=null;if(b!==0){if(y=c.value,x!==!0||y===null){const v=m+b*4,S=p.matrixWorldInverse;l.getNormalMatrix(S),(y===null||y.length<v)&&(y=new Float32Array(v));for(let M=0,T=m;M!==b;++M,T+=4)o.copy(f[M]).applyMatrix4(S,l),o.normal.toArray(y,T),y[T+3]=o.constant}c.value=y,c.needsUpdate=!0}return e.numPlanes=b,e.numIntersection=0,y}}function _Ue(t){let e=new WeakMap;function n(o,l){return l===pD?o.mapping=nx:l===gD&&(o.mapping=rx),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===pD||l===gD)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 RFe(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 a(){e=new WeakMap}return{get:r,dispose:a}}class SUe extends ree{constructor(e=-1,n=1,r=1,i=-1,a=.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=a,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,a,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=a,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 a=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;a+=u*this.view.offsetX,o=a+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(a,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 yg=4,DG=[.125,.215,.35,.446,.526,.582],kf=20,WC=new SUe,RG=new Zt;let KC=null,XC=0,YC=0;const Sf=(1+Math.sqrt(5))/2,Qp=1/Sf,OG=[new qe(1,1,1),new qe(-1,1,1),new qe(1,1,-1),new qe(-1,1,-1),new qe(0,Sf,Qp),new qe(0,Sf,-Qp),new qe(Qp,0,Sf),new qe(-Qp,0,Sf),new qe(Sf,Qp,0),new qe(-Sf,Qp,0)];class LG{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){KC=this._renderer.getRenderTarget(),XC=this._renderer.getActiveCubeFace(),YC=this._renderer.getActiveMipmapLevel(),this._setSize(256);const a=this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(e,r,i,a),n>0&&this._blur(a,0,0,n),this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=UG(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=IG(),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(KC,XC,YC),e.scissorTest=!1,H_(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===nx||e.mapping===rx?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),KC=this._renderer.getRenderTarget(),XC=this._renderer.getActiveCubeFace(),YC=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:Ko,minFilter:Ko,generateMipmaps:!1,type:xy,format:Xo,colorSpace:Vu,depthBuffer:!1},i=FG(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=FG(e,n,r);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=NUe(a)),this._blurMaterial=MUe(a,e,n)}return i}_compileMaterial(e){const n=new Dl(this._lodPlanes[0],e);this._renderer.compile(n,WC)}_sceneToCubeUV(e,n,r,i){const l=new oo(90,1,n,r),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,f=d.autoClear,p=d.toneMapping;d.getClearColor(RG),d.toneMapping=uh,d.autoClear=!1;const m=new JJ({name:"PMREM.Background",side:zs,depthWrite:!1,depthTest:!1}),x=new Dl(new mv,m);let b=!1;const y=e.background;y?y.isColor&&(m.color.copy(y),e.background=null,b=!0):(m.color.copy(RG),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 M=this._cubeSize;H_(i,S*M,v>2?M:0,M,M),d.setRenderTarget(i),b&&d.render(x,l),d.render(e,l)}x.geometry.dispose(),x.material.dispose(),d.toneMapping=p,d.autoClear=f,e.background=y}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===nx||e.mapping===rx;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=UG()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=IG());const a=i?this._cubemapMaterial:this._equirectMaterial,o=new Dl(this._lodPlanes[0],a),l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;H_(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,WC)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){const a=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),o=OG[(i-1)%OG.length];this._blur(e,i-1,i,a,o)}n.autoClear=r}_blur(e,n,r,i,a){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",a),this._halfBlur(o,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,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 Dl(this._lodPlanes[i],u),p=u.uniforms,m=this._sizeLods[r]-1,x=isFinite(a)?Math.PI/(2*m):2*Math.PI/(2*kf-1),b=a/x,y=isFinite(a)?1+Math.floor(d*b):kf;y>kf&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${kf}`);const v=[];let S=0;for(let k=0;k<kf;++k){const R=k/b,A=Math.exp(-R*R/2);v.push(A),k===0?S+=A:k<y&&(S+=2*A)}for(let k=0;k<v.length;k++)v[k]=v[k]/S;p.envMap.value=e.texture,p.samples.value=y,p.weights.value=v,p.latitudinal.value=o==="latitudinal",l&&(p.poleAxis.value=l);const{_lodMax:M}=this;p.dTheta.value=x,p.mipInt.value=M-r;const T=this._sizeLods[i],E=3*T*(i>M-yg?i-M+yg:0),C=4*(this._cubeSize-T);H_(n,E,C,3*T,2*T),c.setRenderTarget(n),c.render(f,WC)}}function NUe(t){const e=[],n=[],r=[];let i=t;const a=t-yg+1+DG.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);n.push(l);let c=1/l;o>t-yg?c=DG[o-t+yg-1]:o===0&&(c=0),r.push(c);const u=1/(l-2),d=-u,f=1+u,p=[d,d,f,d,f,f,d,d,f,f,d,f],m=6,x=6,b=3,y=2,v=1,S=new Float32Array(b*x*m),M=new Float32Array(y*x*m),T=new Float32Array(v*x*m);for(let C=0;C<m;C++){const k=C%3*2/3-1,R=C>2?0:-1,A=[k,R,0,k+2/3,R,0,k+2/3,R+1,0,k,R,0,k+2/3,R+1,0,k,R+1,0];S.set(A,b*x*C),M.set(p,y*x*C);const D=[C,C,C,C,C,C];T.set(D,v*x*C)}const E=new ns;E.setAttribute("position",new go(S,b)),E.setAttribute("uv",new go(M,y)),E.setAttribute("faceIndex",new go(T,v)),e.push(E),i>yg&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function FG(t,e,n){const r=new ym(t,e,n);return r.texture.mapping=bM,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function H_(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function MUe(t,e,n){const r=new Float32Array(kf),i=new qe(0,1,0);return new Ah({name:"SphericalGaussianBlur",defines:{n:kf,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:uL(),fragmentShader:`
  7333. precision mediump float;
  7334. precision mediump int;
  7335. varying vec3 vOutputDirection;
  7336. uniform sampler2D envMap;
  7337. uniform int samples;
  7338. uniform float weights[ n ];
  7339. uniform bool latitudinal;
  7340. uniform float dTheta;
  7341. uniform float mipInt;
  7342. uniform vec3 poleAxis;
  7343. #define ENVMAP_TYPE_CUBE_UV
  7344. #include <cube_uv_reflection_fragment>
  7345. vec3 getSample( float theta, vec3 axis ) {
  7346. float cosTheta = cos( theta );
  7347. // Rodrigues' axis-angle rotation
  7348. vec3 sampleDirection = vOutputDirection * cosTheta
  7349. + cross( axis, vOutputDirection ) * sin( theta )
  7350. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  7351. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  7352. }
  7353. void main() {
  7354. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  7355. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  7356. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  7357. }
  7358. axis = normalize( axis );
  7359. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  7360. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  7361. for ( int i = 1; i < n; i++ ) {
  7362. if ( i >= samples ) {
  7363. break;
  7364. }
  7365. float theta = dTheta * float( i );
  7366. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  7367. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  7368. }
  7369. }
  7370. `,blending:ch,depthTest:!1,depthWrite:!1})}function IG(){return new Ah({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:uL(),fragmentShader:`
  7371. precision mediump float;
  7372. precision mediump int;
  7373. varying vec3 vOutputDirection;
  7374. uniform sampler2D envMap;
  7375. #include <common>
  7376. void main() {
  7377. vec3 outputDirection = normalize( vOutputDirection );
  7378. vec2 uv = equirectUv( outputDirection );
  7379. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  7380. }
  7381. `,blending:ch,depthTest:!1,depthWrite:!1})}function UG(){return new Ah({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:uL(),fragmentShader:`
  7382. precision mediump float;
  7383. precision mediump int;
  7384. uniform float flipEnvMap;
  7385. varying vec3 vOutputDirection;
  7386. uniform samplerCube envMap;
  7387. void main() {
  7388. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  7389. }
  7390. `,blending:ch,depthTest:!1,depthWrite:!1})}function uL(){return`
  7391. precision mediump float;
  7392. precision mediump int;
  7393. attribute float faceIndex;
  7394. varying vec3 vOutputDirection;
  7395. // RH coordinate system; PMREM face-indexing convention
  7396. vec3 getDirection( vec2 uv, float face ) {
  7397. uv = 2.0 * uv - 1.0;
  7398. vec3 direction = vec3( uv, 1.0 );
  7399. if ( face == 0.0 ) {
  7400. direction = direction.zyx; // ( 1, v, u ) pos x
  7401. } else if ( face == 1.0 ) {
  7402. direction = direction.xzy;
  7403. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  7404. } else if ( face == 2.0 ) {
  7405. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  7406. } else if ( face == 3.0 ) {
  7407. direction = direction.zyx;
  7408. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  7409. } else if ( face == 4.0 ) {
  7410. direction = direction.xzy;
  7411. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  7412. } else if ( face == 5.0 ) {
  7413. direction.z *= -1.0; // ( u, v, -1 ) neg z
  7414. }
  7415. return direction;
  7416. }
  7417. void main() {
  7418. vOutputDirection = getDirection( uv, faceIndex );
  7419. gl_Position = vec4( position, 1.0 );
  7420. }
  7421. `}function EUe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===pD||c===gD,d=c===nx||c===rx;if(u||d)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let f=e.get(l);return n===null&&(n=new LG(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 LG(t));const p=u?n.fromEquirectangular(l):n.fromCubemap(l);return e.set(l,p),l.addEventListener("dispose",a),p.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 a(l){const c=l.target;c.removeEventListener("dispose",a);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 kUe(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 TUe(t,e,n,r){const i={},a=new WeakMap;function o(f){const p=f.target;p.index!==null&&e.remove(p.index);for(const x in p.attributes)e.remove(p.attributes[x]);for(const x in p.morphAttributes){const b=p.morphAttributes[x];for(let y=0,v=b.length;y<v;y++)e.remove(b[y])}p.removeEventListener("dispose",o),delete i[p.id];const m=a.get(p);m&&(e.remove(m),a.delete(p)),r.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,n.memory.geometries--}function l(f,p){return i[p.id]===!0||(p.addEventListener("dispose",o),i[p.id]=!0,n.memory.geometries++),p}function c(f){const p=f.attributes;for(const x in p)e.update(p[x],t.ARRAY_BUFFER);const m=f.morphAttributes;for(const x in m){const b=m[x];for(let y=0,v=b.length;y<v;y++)e.update(b[y],t.ARRAY_BUFFER)}}function u(f){const p=[],m=f.index,x=f.attributes.position;let b=0;if(m!==null){const S=m.array;b=m.version;for(let M=0,T=S.length;M<T;M+=3){const E=S[M+0],C=S[M+1],k=S[M+2];p.push(E,C,C,k,k,E)}}else if(x!==void 0){const S=x.array;b=x.version;for(let M=0,T=S.length/3-1;M<T;M+=3){const E=M+0,C=M+1,k=M+2;p.push(E,C,C,k,k,E)}}else return;const y=new(WJ(p)?tee:eee)(p,1);y.version=b;const v=a.get(f);v&&e.remove(v),a.set(f,y)}function d(f){const p=a.get(f);if(p){const m=f.index;m!==null&&p.version<m.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function AUe(t,e,n,r){const i=r.isWebGL2;let a;function o(m){a=m}let l,c;function u(m){l=m.type,c=m.bytesPerElement}function d(m,x){t.drawElements(a,x,l,m*c),n.update(x,a,1)}function f(m,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](a,x,l,m*c,b),n.update(x,a,b)}function p(m,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(m[v]/c,x[v]);else{y.multiDrawElementsWEBGL(a,x,0,l,m,0,b);let v=0;for(let S=0;S<b;S++)v+=x[S];n.update(v,a,1)}}this.setMode=o,this.setIndex=u,this.render=d,this.renderInstances=f,this.renderMultiDraw=p}function CUe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,o,l){switch(n.calls++,o){case t.TRIANGLES:n.triangles+=l*(a/3);break;case t.LINES:n.lines+=l*(a/2);break;case t.LINE_STRIP:n.lines+=l*(a-1);break;case t.LINE_LOOP:n.lines+=l*a;break;case t.POINTS:n.points+=l*a;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 jUe(t,e){return t[0]-e[0]}function PUe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function DUe(t,e,n){const r={},i=new Float32Array(8),a=new WeakMap,o=new Cr,l=[];for(let u=0;u<8;u++)l[u]=[u,0];function c(u,d,f){const p=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=a.get(d);if(y===void 0||y.count!==b){let $=function(){H.dispose(),a.delete(d),d.removeEventListener("dispose",$)};var m=$;y!==void 0&&y.texture.dispose();const M=d.morphAttributes.position!==void 0,T=d.morphAttributes.normal!==void 0,E=d.morphAttributes.color!==void 0,C=d.morphAttributes.position||[],k=d.morphAttributes.normal||[],R=d.morphAttributes.color||[];let A=0;M===!0&&(A=1),T===!0&&(A=2),E===!0&&(A=3);let D=d.attributes.position.count*A,U=1;D>e.maxTextureSize&&(U=Math.ceil(D/e.maxTextureSize),D=e.maxTextureSize);const F=new Float32Array(D*U*4*b),H=new YJ(F,D,U,b);H.type=_u,H.needsUpdate=!0;const j=A*4;for(let K=0;K<b;K++){const V=C[K],Q=k[K],Z=R[K],ae=D*U*4*K;for(let B=0;B<V.count;B++){const X=B*j;M===!0&&(o.fromBufferAttribute(V,B),F[ae+X+0]=o.x,F[ae+X+1]=o.y,F[ae+X+2]=o.z,F[ae+X+3]=0),T===!0&&(o.fromBufferAttribute(Q,B),F[ae+X+4]=o.x,F[ae+X+5]=o.y,F[ae+X+6]=o.z,F[ae+X+7]=0),E===!0&&(o.fromBufferAttribute(Z,B),F[ae+X+8]=o.x,F[ae+X+9]=o.y,F[ae+X+10]=o.z,F[ae+X+11]=Z.itemSize===4?o.w:1)}}y={count:b,texture:H,size:new xn(D,U)},a.set(d,y),d.addEventListener("dispose",$)}let v=0;for(let M=0;M<p.length;M++)v+=p[M];const S=d.morphTargetsRelative?1:1-v;f.getUniforms().setValue(t,"morphTargetBaseInfluence",S),f.getUniforms().setValue(t,"morphTargetInfluences",p),f.getUniforms().setValue(t,"morphTargetsTexture",y.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",y.size)}else{const x=p===void 0?0:p.length;let b=r[d.id];if(b===void 0||b.length!==x){b=[];for(let T=0;T<x;T++)b[T]=[T,0];r[d.id]=b}for(let T=0;T<x;T++){const E=b[T];E[0]=T,E[1]=p[T]}b.sort(PUe);for(let T=0;T<8;T++)T<x&&b[T][1]?(l[T][0]=b[T][0],l[T][1]=b[T][1]):(l[T][0]=Number.MAX_SAFE_INTEGER,l[T][1]=0);l.sort(jUe);const y=d.morphAttributes.position,v=d.morphAttributes.normal;let S=0;for(let T=0;T<8;T++){const E=l[T],C=E[0],k=E[1];C!==Number.MAX_SAFE_INTEGER&&k?(y&&d.getAttribute("morphTarget"+T)!==y[C]&&d.setAttribute("morphTarget"+T,y[C]),v&&d.getAttribute("morphNormal"+T)!==v[C]&&d.setAttribute("morphNormal"+T,v[C]),i[T]=k,S+=k):(y&&d.hasAttribute("morphTarget"+T)===!0&&d.deleteAttribute("morphTarget"+T),v&&d.hasAttribute("morphNormal"+T)===!0&&d.deleteAttribute("morphNormal"+T),i[T]=0)}const M=d.morphTargetsRelative?1:1-S;f.getUniforms().setValue(t,"morphTargetBaseInfluence",M),f.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function RUe(t,e,n,r){let i=new WeakMap;function a(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",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 p=c.skeleton;i.get(p)!==u&&(p.update(),i.set(p,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:a,dispose:o}}class see extends Bs{constructor(e,n,r,i,a,o,l,c,u,d){if(d=d!==void 0?d:Wf,d!==Wf&&d!==ix)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===Wf&&(r=Zd),r===void 0&&d===ix&&(r=qf),super(null,i,a,o,l,c,d,r,u),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=l!==void 0?l:Da,this.minFilter=c!==void 0?c:Da,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 oee=new Bs,lee=new see(1,1);lee.compareFunction=GJ;const cee=new YJ,uee=new bFe,dee=new iee,zG=[],BG=[],$G=new Float32Array(16),HG=new Float32Array(9),VG=new Float32Array(4);function Rx(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=zG[i];if(a===void 0&&(a=new Float32Array(i),zG[i]=a),e!==0){r.toArray(a,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(a,l)}return a}function ea(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 ta(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function wM(t,e){let n=BG[e];n===void 0&&(n=new Int32Array(e),BG[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function OUe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function LUe(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(ea(n,e))return;t.uniform2fv(this.addr,e),ta(n,e)}}function FUe(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(ea(n,e))return;t.uniform3fv(this.addr,e),ta(n,e)}}function IUe(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(ea(n,e))return;t.uniform4fv(this.addr,e),ta(n,e)}}function UUe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ea(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),ta(n,e)}else{if(ea(n,r))return;VG.set(r),t.uniformMatrix2fv(this.addr,!1,VG),ta(n,r)}}function zUe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ea(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),ta(n,e)}else{if(ea(n,r))return;HG.set(r),t.uniformMatrix3fv(this.addr,!1,HG),ta(n,r)}}function BUe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ea(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),ta(n,e)}else{if(ea(n,r))return;$G.set(r),t.uniformMatrix4fv(this.addr,!1,$G),ta(n,r)}}function $Ue(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function HUe(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(ea(n,e))return;t.uniform2iv(this.addr,e),ta(n,e)}}function VUe(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(ea(n,e))return;t.uniform3iv(this.addr,e),ta(n,e)}}function GUe(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(ea(n,e))return;t.uniform4iv(this.addr,e),ta(n,e)}}function qUe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function WUe(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(ea(n,e))return;t.uniform2uiv(this.addr,e),ta(n,e)}}function KUe(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(ea(n,e))return;t.uniform3uiv(this.addr,e),ta(n,e)}}function XUe(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(ea(n,e))return;t.uniform4uiv(this.addr,e),ta(n,e)}}function YUe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);const a=this.type===t.SAMPLER_2D_SHADOW?lee:oee;n.setTexture2D(e||a,i)}function QUe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||uee,i)}function ZUe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||dee,i)}function JUe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||cee,i)}function eze(t){switch(t){case 5126:return OUe;case 35664:return LUe;case 35665:return FUe;case 35666:return IUe;case 35674:return UUe;case 35675:return zUe;case 35676:return BUe;case 5124:case 35670:return $Ue;case 35667:case 35671:return HUe;case 35668:case 35672:return VUe;case 35669:case 35673:return GUe;case 5125:return qUe;case 36294:return WUe;case 36295:return KUe;case 36296:return XUe;case 35678:case 36198:case 36298:case 36306:case 35682:return YUe;case 35679:case 36299:case 36307:return QUe;case 35680:case 36300:case 36308:case 36293:return ZUe;case 36289:case 36303:case 36311:case 36292:return JUe}}function tze(t,e){t.uniform1fv(this.addr,e)}function nze(t,e){const n=Rx(e,this.size,2);t.uniform2fv(this.addr,n)}function rze(t,e){const n=Rx(e,this.size,3);t.uniform3fv(this.addr,n)}function ize(t,e){const n=Rx(e,this.size,4);t.uniform4fv(this.addr,n)}function aze(t,e){const n=Rx(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function sze(t,e){const n=Rx(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function oze(t,e){const n=Rx(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function lze(t,e){t.uniform1iv(this.addr,e)}function cze(t,e){t.uniform2iv(this.addr,e)}function uze(t,e){t.uniform3iv(this.addr,e)}function dze(t,e){t.uniform4iv(this.addr,e)}function hze(t,e){t.uniform1uiv(this.addr,e)}function fze(t,e){t.uniform2uiv(this.addr,e)}function mze(t,e){t.uniform3uiv(this.addr,e)}function pze(t,e){t.uniform4uiv(this.addr,e)}function gze(t,e,n){const r=this.cache,i=e.length,a=wM(n,i);ea(r,a)||(t.uniform1iv(this.addr,a),ta(r,a));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||oee,a[o])}function xze(t,e,n){const r=this.cache,i=e.length,a=wM(n,i);ea(r,a)||(t.uniform1iv(this.addr,a),ta(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||uee,a[o])}function bze(t,e,n){const r=this.cache,i=e.length,a=wM(n,i);ea(r,a)||(t.uniform1iv(this.addr,a),ta(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||dee,a[o])}function yze(t,e,n){const r=this.cache,i=e.length,a=wM(n,i);ea(r,a)||(t.uniform1iv(this.addr,a),ta(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||cee,a[o])}function vze(t){switch(t){case 5126:return tze;case 35664:return nze;case 35665:return rze;case 35666:return ize;case 35674:return aze;case 35675:return sze;case 35676:return oze;case 5124:case 35670:return lze;case 35667:case 35671:return cze;case 35668:case 35672:return uze;case 35669:case 35673:return dze;case 5125:return hze;case 36294:return fze;case 36295:return mze;case 36296:return pze;case 35678:case 36198:case 36298:case 36306:case 35682:return gze;case 35679:case 36299:case 36307:return xze;case 35680:case 36300:case 36308:case 36293:return bze;case 36289:case 36303:case 36311:case 36292:return yze}}class wze{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=eze(n.type)}}class _ze{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=vze(n.type)}}class Sze{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,o=i.length;a!==o;++a){const l=i[a];l.setValue(e,n[l.id],r)}}}const QC=/(\w+)(\])?(\[|\.)?/g;function GG(t,e){t.seq.push(e),t.map[e.id]=e}function Nze(t,e,n){const r=t.name,i=r.length;for(QC.lastIndex=0;;){const a=QC.exec(r),o=QC.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){GG(n,u===void 0?new wze(l,t,e):new _ze(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new Sze(l),GG(n,f)),n=f}}}class P1{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const a=e.getActiveUniform(n,i),o=e.getUniformLocation(n,a.name);Nze(a,o,this)}}setValue(e,n,r,i){const a=this.map[n];a!==void 0&&a.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let a=0,o=n.length;a!==o;++a){const l=n[a],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const o=e[i];o.id in n&&r.push(o)}return r}}function qG(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const Mze=37297;let Eze=0;function kze(t,e){const n=t.split(`
  7422. `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let o=i;o<a;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
  7423. `)}function Tze(t){const e=kr.getPrimaries(kr.workingColorSpace),n=kr.getPrimaries(t);let r;switch(e===n?r="":e===tN&&n===eN?r="LinearDisplayP3ToLinearSRGB":e===eN&&n===tN&&(r="LinearSRGBToLinearDisplayP3"),t){case Vu:case yM:return[r,"LinearTransferOETF"];case Ra:case aL:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function WG(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),i=t.getShaderInfoLog(e).trim();if(r&&i==="")return"";const a=/ERROR: 0:(\d+)/.exec(i);if(a){const o=parseInt(a[1]);return n.toUpperCase()+`
  7424. `+i+`
  7425. `+kze(t.getShaderSource(e),o)}else return i}function Aze(t,e){const n=Tze(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function Cze(t,e){let n;switch(e){case ALe:n="Linear";break;case CLe:n="Reinhard";break;case jLe:n="OptimizedCineon";break;case PLe:n="ACESFilmic";break;case DLe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function jze(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(c0).join(`
  7426. `)}function Pze(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  7427. `)}function Dze(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),o=a.name;let l=1;a.type===t.FLOAT_MAT2&&(l=2),a.type===t.FLOAT_MAT3&&(l=3),a.type===t.FLOAT_MAT4&&(l=4),n[o]={type:a.type,location:t.getAttribLocation(e,o),locationSize:l}}return n}function c0(t){return t!==""}function KG(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 XG(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Rze=/^[ \t]*#include +<([\w\d./]+)>/gm;function _D(t){return t.replace(Rze,Lze)}const Oze=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function Lze(t,e){let n=kn[e];if(n===void 0){const r=Oze.get(e);if(r!==void 0)n=kn[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 _D(n)}const Fze=/#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 YG(t){return t.replace(Fze,Ize)}function Ize(t,e,n,r){let i="";for(let a=parseInt(e);a<parseInt(n);a++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return i}function QG(t){let e="precision "+t.precision+` float;
  7428. precision `+t.precision+" int;";return t.precision==="highp"?e+=`
  7429. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  7430. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  7431. #define LOW_PRECISION`),e}function Uze(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===RJ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===rLe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===lu&&(e="SHADOWMAP_TYPE_VSM"),e}function zze(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case nx:case rx:e="ENVMAP_TYPE_CUBE";break;case bM:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Bze(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case rx:e="ENVMAP_MODE_REFRACTION";break}return e}function $ze(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case rL:e="ENVMAP_BLENDING_MULTIPLY";break;case kLe:e="ENVMAP_BLENDING_MIX";break;case TLe:e="ENVMAP_BLENDING_ADD";break}return e}function Hze(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 Vze(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=Uze(n),u=zze(n),d=Bze(n),f=$ze(n),p=Hze(n),m=n.isWebGL2?"":jze(n),x=Pze(a),b=i.createProgram();let y,v,S=n.glslVersion?"#version "+n.glslVersion+`
  7432. `:"";n.isRawShaderMaterial?(y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(c0).join(`
  7433. `),y.length>0&&(y+=`
  7434. `),v=[m,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(c0).join(`
  7435. `),v.length>0&&(v+=`
  7436. `)):(y=[QG(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",`
  7437. `].filter(c0).join(`
  7438. `),v=[m,QG(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:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.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!==uh?"#define TONE_MAPPING":"",n.toneMapping!==uh?kn.tonemapping_pars_fragment:"",n.toneMapping!==uh?Cze("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",kn.colorspace_pars_fragment,Aze("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  7439. `].filter(c0).join(`
  7440. `)),o=_D(o),o=KG(o,n),o=XG(o,n),l=_D(l),l=KG(l,n),l=XG(l,n),o=YG(o),l=YG(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(S=`#version 300 es
  7441. `,y=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
  7442. `)+`
  7443. `+y,v=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===pG?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===pG?"":"#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(`
  7444. `)+`
  7445. `+v);const M=S+y+o,T=S+v+l,E=qG(i,i.VERTEX_SHADER,M),C=qG(i,i.FRAGMENT_SHADER,T);i.attachShader(b,E),i.attachShader(b,C),n.index0AttributeName!==void 0?i.bindAttribLocation(b,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(b,0,"position"),i.linkProgram(b);function k(U){if(t.debug.checkShaderErrors){const F=i.getProgramInfoLog(b).trim(),H=i.getShaderInfoLog(E).trim(),j=i.getShaderInfoLog(C).trim();let $=!0,K=!0;if(i.getProgramParameter(b,i.LINK_STATUS)===!1)if($=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,b,E,C);else{const V=WG(i,E,"vertex"),Q=WG(i,C,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(b,i.VALIDATE_STATUS)+`
  7446. Program Info Log: `+F+`
  7447. `+V+`
  7448. `+Q)}else F!==""?console.warn("THREE.WebGLProgram: Program Info Log:",F):(H===""||j==="")&&(K=!1);K&&(U.diagnostics={runnable:$,programLog:F,vertexShader:{log:H,prefix:y},fragmentShader:{log:j,prefix:v}})}i.deleteShader(E),i.deleteShader(C),R=new P1(i,b),A=Dze(i,b)}let R;this.getUniforms=function(){return R===void 0&&k(this),R};let A;this.getAttributes=function(){return A===void 0&&k(this),A};let D=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=i.getProgramParameter(b,Mze)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(b),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Eze++,this.cacheKey=e,this.usedTimes=1,this.program=b,this.vertexShader=E,this.fragmentShader=C,this}let Gze=0;class qze{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),a=this._getShaderStage(r),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(a)===!1&&(o.add(a),a.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new Wze(e),n.set(e,r)),r}}class Wze{constructor(e){this.id=Gze++,this.code=e,this.usedTimes=0}}function Kze(t,e,n,r,i,a,o){const l=new QJ,c=new qze,u=[],d=i.isWebGL2,f=i.logarithmicDepthBuffer,p=i.vertexTextures;let m=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function b(A){return A===0?"uv":`uv${A}`}function y(A,D,U,F,H){const j=F.fog,$=H.geometry,K=A.isMeshStandardMaterial?F.environment:null,V=(A.isMeshStandardMaterial?n:e).get(A.envMap||K),Q=V&&V.mapping===bM?V.image.height:null,Z=x[A.type];A.precision!==null&&(m=i.getMaxPrecision(A.precision),m!==A.precision&&console.warn("THREE.WebGLProgram.getParameters:",A.precision,"not supported, using",m,"instead."));const ae=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,B=ae!==void 0?ae.length:0;let X=0;$.morphAttributes.position!==void 0&&(X=1),$.morphAttributes.normal!==void 0&&(X=2),$.morphAttributes.color!==void 0&&(X=3);let ne,se,be,xe;if(Z){const Bt=Rs[Z];ne=Bt.vertexShader,se=Bt.fragmentShader}else ne=A.vertexShader,se=A.fragmentShader,c.update(A),be=c.getVertexShaderID(A),xe=c.getFragmentShaderID(A);const de=t.getRenderTarget(),Pe=H.isInstancedMesh===!0,ie=H.isBatchedMesh===!0,Me=!!A.map,Oe=!!A.matcap,ge=!!V,Ke=!!A.aoMap,G=!!A.lightMap,Y=!!A.bumpMap,ce=!!A.normalMap,q=!!A.displacementMap,te=!!A.emissiveMap,I=!!A.metalnessMap,fe=!!A.roughnessMap,me=A.anisotropy>0,ke=A.clearcoat>0,z=A.iridescence>0,O=A.sheen>0,ee=A.transmission>0,le=me&&!!A.anisotropyMap,_e=ke&&!!A.clearcoatMap,we=ke&&!!A.clearcoatNormalMap,re=ke&&!!A.clearcoatRoughnessMap,Fe=z&&!!A.iridescenceMap,$e=z&&!!A.iridescenceThicknessMap,Ve=O&&!!A.sheenColorMap,He=O&&!!A.sheenRoughnessMap,ye=!!A.specularMap,je=!!A.specularColorMap,Be=!!A.specularIntensityMap,Se=ee&&!!A.transmissionMap,Xe=ee&&!!A.thicknessMap,Ne=!!A.gradientMap,tt=!!A.alphaMap,Ee=A.alphaTest>0,We=!!A.alphaHash,ze=!!A.extensions,W=!!$.attributes.uv1,De=!!$.attributes.uv2,Ye=!!$.attributes.uv3;let xt=uh;return A.toneMapped&&(de===null||de.isXRRenderTarget===!0)&&(xt=t.toneMapping),{isWebGL2:d,shaderID:Z,shaderType:A.type,shaderName:A.name,vertexShader:ne,fragmentShader:se,defines:A.defines,customVertexShaderID:be,customFragmentShaderID:xe,isRawShaderMaterial:A.isRawShaderMaterial===!0,glslVersion:A.glslVersion,precision:m,batching:ie,instancing:Pe,instancingColor:Pe&&H.instanceColor!==null,supportsVertexTextures:p,outputColorSpace:de===null?t.outputColorSpace:de.isXRRenderTarget===!0?de.texture.colorSpace:Vu,map:Me,matcap:Oe,envMap:ge,envMapMode:ge&&V.mapping,envMapCubeUVHeight:Q,aoMap:Ke,lightMap:G,bumpMap:Y,normalMap:ce,displacementMap:p&&q,emissiveMap:te,normalMapObjectSpace:ce&&A.normalMapType===GLe,normalMapTangentSpace:ce&&A.normalMapType===VJ,metalnessMap:I,roughnessMap:fe,anisotropy:me,anisotropyMap:le,clearcoat:ke,clearcoatMap:_e,clearcoatNormalMap:we,clearcoatRoughnessMap:re,iridescence:z,iridescenceMap:Fe,iridescenceThicknessMap:$e,sheen:O,sheenColorMap:Ve,sheenRoughnessMap:He,specularMap:ye,specularColorMap:je,specularIntensityMap:Be,transmission:ee,transmissionMap:Se,thicknessMap:Xe,gradientMap:Ne,opaque:A.transparent===!1&&A.blending===jg,alphaMap:tt,alphaTest:Ee,alphaHash:We,combine:A.combine,mapUv:Me&&b(A.map.channel),aoMapUv:Ke&&b(A.aoMap.channel),lightMapUv:G&&b(A.lightMap.channel),bumpMapUv:Y&&b(A.bumpMap.channel),normalMapUv:ce&&b(A.normalMap.channel),displacementMapUv:q&&b(A.displacementMap.channel),emissiveMapUv:te&&b(A.emissiveMap.channel),metalnessMapUv:I&&b(A.metalnessMap.channel),roughnessMapUv:fe&&b(A.roughnessMap.channel),anisotropyMapUv:le&&b(A.anisotropyMap.channel),clearcoatMapUv:_e&&b(A.clearcoatMap.channel),clearcoatNormalMapUv:we&&b(A.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:re&&b(A.clearcoatRoughnessMap.channel),iridescenceMapUv:Fe&&b(A.iridescenceMap.channel),iridescenceThicknessMapUv:$e&&b(A.iridescenceThicknessMap.channel),sheenColorMapUv:Ve&&b(A.sheenColorMap.channel),sheenRoughnessMapUv:He&&b(A.sheenRoughnessMap.channel),specularMapUv:ye&&b(A.specularMap.channel),specularColorMapUv:je&&b(A.specularColorMap.channel),specularIntensityMapUv:Be&&b(A.specularIntensityMap.channel),transmissionMapUv:Se&&b(A.transmissionMap.channel),thicknessMapUv:Xe&&b(A.thicknessMap.channel),alphaMapUv:tt&&b(A.alphaMap.channel),vertexTangents:!!$.attributes.tangent&&(ce||me),vertexColors:A.vertexColors,vertexAlphas:A.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,vertexUv1s:W,vertexUv2s:De,vertexUv3s:Ye,pointsUvs:H.isPoints===!0&&!!$.attributes.uv&&(Me||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:$.morphAttributes.position!==void 0,morphNormals:$.morphAttributes.normal!==void 0,morphColors:$.morphAttributes.color!==void 0,morphTargetsCount:B,morphTextureStride:X,numDirLights:D.directional.length,numPointLights:D.point.length,numSpotLights:D.spot.length,numSpotLightMaps:D.spotLightMap.length,numRectAreaLights:D.rectArea.length,numHemiLights:D.hemi.length,numDirLightShadows:D.directionalShadowMap.length,numPointLightShadows:D.pointShadowMap.length,numSpotLightShadows:D.spotShadowMap.length,numSpotLightShadowsWithMaps:D.numSpotLightShadowsWithMaps,numLightProbes:D.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:A.dithering,shadowMapEnabled:t.shadowMap.enabled&&U.length>0,shadowMapType:t.shadowMap.type,toneMapping:xt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:Me&&A.map.isVideoTexture===!0&&kr.getTransfer(A.map.colorSpace)===Gr,premultipliedAlpha:A.premultipliedAlpha,doubleSided:A.side===pu,flipSided:A.side===zs,useDepthPacking:A.depthPacking>=0,depthPacking:A.depthPacking||0,index0AttributeName:A.index0AttributeName,extensionDerivatives:ze&&A.extensions.derivatives===!0,extensionFragDepth:ze&&A.extensions.fragDepth===!0,extensionDrawBuffers:ze&&A.extensions.drawBuffers===!0,extensionShaderTextureLOD:ze&&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 D=[];if(A.shaderID?D.push(A.shaderID):(D.push(A.customVertexShaderID),D.push(A.customFragmentShaderID)),A.defines!==void 0)for(const U in A.defines)D.push(U),D.push(A.defines[U]);return A.isRawShaderMaterial===!1&&(S(D,A),M(D,A),D.push(t.outputColorSpace)),D.push(A.customProgramCacheKey),D.join()}function S(A,D){A.push(D.precision),A.push(D.outputColorSpace),A.push(D.envMapMode),A.push(D.envMapCubeUVHeight),A.push(D.mapUv),A.push(D.alphaMapUv),A.push(D.lightMapUv),A.push(D.aoMapUv),A.push(D.bumpMapUv),A.push(D.normalMapUv),A.push(D.displacementMapUv),A.push(D.emissiveMapUv),A.push(D.metalnessMapUv),A.push(D.roughnessMapUv),A.push(D.anisotropyMapUv),A.push(D.clearcoatMapUv),A.push(D.clearcoatNormalMapUv),A.push(D.clearcoatRoughnessMapUv),A.push(D.iridescenceMapUv),A.push(D.iridescenceThicknessMapUv),A.push(D.sheenColorMapUv),A.push(D.sheenRoughnessMapUv),A.push(D.specularMapUv),A.push(D.specularColorMapUv),A.push(D.specularIntensityMapUv),A.push(D.transmissionMapUv),A.push(D.thicknessMapUv),A.push(D.combine),A.push(D.fogExp2),A.push(D.sizeAttenuation),A.push(D.morphTargetsCount),A.push(D.morphAttributeCount),A.push(D.numDirLights),A.push(D.numPointLights),A.push(D.numSpotLights),A.push(D.numSpotLightMaps),A.push(D.numHemiLights),A.push(D.numRectAreaLights),A.push(D.numDirLightShadows),A.push(D.numPointLightShadows),A.push(D.numSpotLightShadows),A.push(D.numSpotLightShadowsWithMaps),A.push(D.numLightProbes),A.push(D.shadowMapType),A.push(D.toneMapping),A.push(D.numClippingPlanes),A.push(D.numClipIntersection),A.push(D.depthPacking)}function M(A,D){l.disableAll(),D.isWebGL2&&l.enable(0),D.supportsVertexTextures&&l.enable(1),D.instancing&&l.enable(2),D.instancingColor&&l.enable(3),D.matcap&&l.enable(4),D.envMap&&l.enable(5),D.normalMapObjectSpace&&l.enable(6),D.normalMapTangentSpace&&l.enable(7),D.clearcoat&&l.enable(8),D.iridescence&&l.enable(9),D.alphaTest&&l.enable(10),D.vertexColors&&l.enable(11),D.vertexAlphas&&l.enable(12),D.vertexUv1s&&l.enable(13),D.vertexUv2s&&l.enable(14),D.vertexUv3s&&l.enable(15),D.vertexTangents&&l.enable(16),D.anisotropy&&l.enable(17),D.alphaHash&&l.enable(18),D.batching&&l.enable(19),A.push(l.mask),l.disableAll(),D.fog&&l.enable(0),D.useFog&&l.enable(1),D.flatShading&&l.enable(2),D.logarithmicDepthBuffer&&l.enable(3),D.skinning&&l.enable(4),D.morphTargets&&l.enable(5),D.morphNormals&&l.enable(6),D.morphColors&&l.enable(7),D.premultipliedAlpha&&l.enable(8),D.shadowMapEnabled&&l.enable(9),D.useLegacyLights&&l.enable(10),D.doubleSided&&l.enable(11),D.flipSided&&l.enable(12),D.useDepthPacking&&l.enable(13),D.dithering&&l.enable(14),D.transmission&&l.enable(15),D.sheen&&l.enable(16),D.opaque&&l.enable(17),D.pointsUvs&&l.enable(18),D.decodeVideoTexture&&l.enable(19),A.push(l.mask)}function T(A){const D=x[A.type];let U;if(D){const F=Rs[D];U=lL.clone(F.uniforms)}else U=A.uniforms;return U}function E(A,D){let U;for(let F=0,H=u.length;F<H;F++){const j=u[F];if(j.cacheKey===D){U=j,++U.usedTimes;break}}return U===void 0&&(U=new Vze(t,D,A,a),u.push(U)),U}function C(A){if(--A.usedTimes===0){const D=u.indexOf(A);u[D]=u[u.length-1],u.pop(),A.destroy()}}function k(A){c.remove(A)}function R(){c.dispose()}return{getParameters:y,getProgramCacheKey:v,getUniforms:T,acquireProgram:E,releaseProgram:C,releaseShaderCache:k,programs:u,dispose:R}}function Xze(){let t=new WeakMap;function e(a){let o=t.get(a);return o===void 0&&(o={},t.set(a,o)),o}function n(a){t.delete(a)}function r(a,o,l){t.get(a)[o]=l}function i(){t=new WeakMap}return{get:e,remove:n,update:r,dispose:i}}function Yze(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 ZG(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 JG(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function o(f,p,m,x,b,y){let v=t[e];return v===void 0?(v={id:f.id,object:f,geometry:p,material:m,groupOrder:x,renderOrder:f.renderOrder,z:b,group:y},t[e]=v):(v.id=f.id,v.object=f,v.geometry=p,v.material=m,v.groupOrder=x,v.renderOrder=f.renderOrder,v.z=b,v.group=y),e++,v}function l(f,p,m,x,b,y){const v=o(f,p,m,x,b,y);m.transmission>0?r.push(v):m.transparent===!0?i.push(v):n.push(v)}function c(f,p,m,x,b,y){const v=o(f,p,m,x,b,y);m.transmission>0?r.unshift(v):m.transparent===!0?i.unshift(v):n.unshift(v)}function u(f,p){n.length>1&&n.sort(f||Yze),r.length>1&&r.sort(p||ZG),i.length>1&&i.sort(p||ZG)}function d(){for(let f=e,p=t.length;f<p;f++){const m=t[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function Qze(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new JG,t.set(r,[o])):i>=a.length?(o=new JG,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function Zze(){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 Zt};break;case"SpotLight":n={position:new qe,direction:new qe,color:new Zt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new qe,color:new Zt,distance:0,decay:0};break;case"HemisphereLight":n={direction:new qe,skyColor:new Zt,groundColor:new Zt};break;case"RectAreaLight":n={color:new Zt,position:new qe,halfWidth:new qe,halfHeight:new qe};break}return t[e.id]=n,n}}}function Jze(){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 eBe=0;function tBe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function nBe(t,e){const n=new Zze,r=Jze(),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 a=new qe,o=new zr,l=new zr;function c(d,f){let p=0,m=0,x=0;for(let F=0;F<9;F++)i.probe[F].set(0,0,0);let b=0,y=0,v=0,S=0,M=0,T=0,E=0,C=0,k=0,R=0,A=0;d.sort(tBe);const D=f===!0?Math.PI:1;for(let F=0,H=d.length;F<H;F++){const j=d[F],$=j.color,K=j.intensity,V=j.distance,Q=j.shadow&&j.shadow.map?j.shadow.map.texture:null;if(j.isAmbientLight)p+=$.r*K*D,m+=$.g*K*D,x+=$.b*K*D;else if(j.isLightProbe){for(let Z=0;Z<9;Z++)i.probe[Z].addScaledVector(j.sh.coefficients[Z],K);A++}else if(j.isDirectionalLight){const Z=n.get(j);if(Z.color.copy(j.color).multiplyScalar(j.intensity*D),j.castShadow){const ae=j.shadow,B=r.get(j);B.shadowBias=ae.bias,B.shadowNormalBias=ae.normalBias,B.shadowRadius=ae.radius,B.shadowMapSize=ae.mapSize,i.directionalShadow[b]=B,i.directionalShadowMap[b]=Q,i.directionalShadowMatrix[b]=j.shadow.matrix,T++}i.directional[b]=Z,b++}else if(j.isSpotLight){const Z=n.get(j);Z.position.setFromMatrixPosition(j.matrixWorld),Z.color.copy($).multiplyScalar(K*D),Z.distance=V,Z.coneCos=Math.cos(j.angle),Z.penumbraCos=Math.cos(j.angle*(1-j.penumbra)),Z.decay=j.decay,i.spot[v]=Z;const ae=j.shadow;if(j.map&&(i.spotLightMap[k]=j.map,k++,ae.updateMatrices(j),j.castShadow&&R++),i.spotLightMatrix[v]=ae.matrix,j.castShadow){const B=r.get(j);B.shadowBias=ae.bias,B.shadowNormalBias=ae.normalBias,B.shadowRadius=ae.radius,B.shadowMapSize=ae.mapSize,i.spotShadow[v]=B,i.spotShadowMap[v]=Q,C++}v++}else if(j.isRectAreaLight){const Z=n.get(j);Z.color.copy($).multiplyScalar(K),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*D),Z.distance=j.distance,Z.decay=j.decay,j.castShadow){const ae=j.shadow,B=r.get(j);B.shadowBias=ae.bias,B.shadowNormalBias=ae.normalBias,B.shadowRadius=ae.radius,B.shadowMapSize=ae.mapSize,B.shadowCameraNear=ae.camera.near,B.shadowCameraFar=ae.camera.far,i.pointShadow[y]=B,i.pointShadowMap[y]=Q,i.pointShadowMatrix[y]=j.shadow.matrix,E++}i.point[y]=Z,y++}else if(j.isHemisphereLight){const Z=n.get(j);Z.skyColor.copy(j.color).multiplyScalar(K*D),Z.groundColor.copy(j.groundColor).multiplyScalar(K*D),i.hemi[M]=Z,M++}}S>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Dt.LTC_FLOAT_1,i.rectAreaLTC2=Dt.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Dt.LTC_HALF_1,i.rectAreaLTC2=Dt.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=p,i.ambient[1]=m,i.ambient[2]=x;const U=i.hash;(U.directionalLength!==b||U.pointLength!==y||U.spotLength!==v||U.rectAreaLength!==S||U.hemiLength!==M||U.numDirectionalShadows!==T||U.numPointShadows!==E||U.numSpotShadows!==C||U.numSpotMaps!==k||U.numLightProbes!==A)&&(i.directional.length=b,i.spot.length=v,i.rectArea.length=S,i.point.length=y,i.hemi.length=M,i.directionalShadow.length=T,i.directionalShadowMap.length=T,i.pointShadow.length=E,i.pointShadowMap.length=E,i.spotShadow.length=C,i.spotShadowMap.length=C,i.directionalShadowMatrix.length=T,i.pointShadowMatrix.length=E,i.spotLightMatrix.length=C+k-R,i.spotLightMap.length=k,i.numSpotLightShadowsWithMaps=R,i.numLightProbes=A,U.directionalLength=b,U.pointLength=y,U.spotLength=v,U.rectAreaLength=S,U.hemiLength=M,U.numDirectionalShadows=T,U.numPointShadows=E,U.numSpotShadows=C,U.numSpotMaps=k,U.numLightProbes=A,i.version=eBe++)}function u(d,f){let p=0,m=0,x=0,b=0,y=0;const v=f.matrixWorldInverse;for(let S=0,M=d.length;S<M;S++){const T=d[S];if(T.isDirectionalLight){const E=i.directional[p];E.direction.setFromMatrixPosition(T.matrixWorld),a.setFromMatrixPosition(T.target.matrixWorld),E.direction.sub(a),E.direction.transformDirection(v),p++}else if(T.isSpotLight){const E=i.spot[x];E.position.setFromMatrixPosition(T.matrixWorld),E.position.applyMatrix4(v),E.direction.setFromMatrixPosition(T.matrixWorld),a.setFromMatrixPosition(T.target.matrixWorld),E.direction.sub(a),E.direction.transformDirection(v),x++}else if(T.isRectAreaLight){const E=i.rectArea[b];E.position.setFromMatrixPosition(T.matrixWorld),E.position.applyMatrix4(v),l.identity(),o.copy(T.matrixWorld),o.premultiply(v),l.extractRotation(o),E.halfWidth.set(T.width*.5,0,0),E.halfHeight.set(0,T.height*.5,0),E.halfWidth.applyMatrix4(l),E.halfHeight.applyMatrix4(l),b++}else if(T.isPointLight){const E=i.point[m];E.position.setFromMatrixPosition(T.matrixWorld),E.position.applyMatrix4(v),m++}else if(T.isHemisphereLight){const E=i.hemi[y];E.direction.setFromMatrixPosition(T.matrixWorld),E.direction.transformDirection(v),y++}}}return{setup:c,setupView:u,state:i}}function e7(t,e){const n=new nBe(t,e),r=[],i=[];function a(){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:a,state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:c,setupLightsView:u,pushLight:o,pushShadow:l}}function rBe(t,e){let n=new WeakMap;function r(a,o=0){const l=n.get(a);let c;return l===void 0?(c=new e7(t,e),n.set(a,[c])):o>=l.length?(c=new e7(t,e),l.push(c)):c=l[o],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class iBe extends Dx{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=HLe,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 aBe extends Dx{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 sBe=`void main() {
  7449. gl_Position = vec4( position, 1.0 );
  7450. }`,oBe=`uniform sampler2D shadow_pass;
  7451. uniform vec2 resolution;
  7452. uniform float radius;
  7453. #include <packing>
  7454. void main() {
  7455. const float samples = float( VSM_SAMPLES );
  7456. float mean = 0.0;
  7457. float squared_mean = 0.0;
  7458. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  7459. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  7460. for ( float i = 0.0; i < samples; i ++ ) {
  7461. float uvOffset = uvStart + i * uvStride;
  7462. #ifdef HORIZONTAL_PASS
  7463. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  7464. mean += distribution.x;
  7465. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  7466. #else
  7467. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  7468. mean += depth;
  7469. squared_mean += depth * depth;
  7470. #endif
  7471. }
  7472. mean = mean / samples;
  7473. squared_mean = squared_mean / samples;
  7474. float std_dev = sqrt( squared_mean - mean * mean );
  7475. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  7476. }`;function lBe(t,e,n){let r=new vM;const i=new xn,a=new xn,o=new Cr,l=new iBe({depthPacking:VLe}),c=new aBe,u={},d=n.maxTextureSize,f={[Th]:zs,[zs]:Th,[pu]:pu},p=new Ah({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new xn},radius:{value:4}},vertexShader:sBe,fragmentShader:oBe}),m=p.clone();m.defines.HORIZONTAL_PASS=1;const x=new ns;x.setAttribute("position",new go(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const b=new Dl(x,p),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=RJ;let v=this.type;this.render=function(E,C,k){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||E.length===0)return;const R=t.getRenderTarget(),A=t.getActiveCubeFace(),D=t.getActiveMipmapLevel(),U=t.state;U.setBlending(ch),U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);const F=v!==lu&&this.type===lu,H=v===lu&&this.type!==lu;for(let j=0,$=E.length;j<$;j++){const K=E[j],V=K.shadow;if(V===void 0){console.warn("THREE.WebGLShadowMap:",K,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;i.copy(V.mapSize);const Q=V.getFrameExtents();if(i.multiply(Q),a.copy(V.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/Q.x),i.x=a.x*Q.x,V.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/Q.y),i.y=a.y*Q.y,V.mapSize.y=a.y)),V.map===null||F===!0||H===!0){const ae=this.type!==lu?{minFilter:Da,magFilter:Da}:{};V.map!==null&&V.map.dispose(),V.map=new ym(i.x,i.y,ae),V.map.texture.name=K.name+".shadowMap",V.camera.updateProjectionMatrix()}t.setRenderTarget(V.map),t.clear();const Z=V.getViewportCount();for(let ae=0;ae<Z;ae++){const B=V.getViewport(ae);o.set(a.x*B.x,a.y*B.y,a.x*B.z,a.y*B.w),U.viewport(o),V.updateMatrices(K,ae),r=V.getFrustum(),T(C,k,V.camera,K,this.type)}V.isPointLightShadow!==!0&&this.type===lu&&S(V,k),V.needsUpdate=!1}v=this.type,y.needsUpdate=!1,t.setRenderTarget(R,A,D)};function S(E,C){const k=e.update(b);p.defines.VSM_SAMPLES!==E.blurSamples&&(p.defines.VSM_SAMPLES=E.blurSamples,m.defines.VSM_SAMPLES=E.blurSamples,p.needsUpdate=!0,m.needsUpdate=!0),E.mapPass===null&&(E.mapPass=new ym(i.x,i.y)),p.uniforms.shadow_pass.value=E.map.texture,p.uniforms.resolution.value=E.mapSize,p.uniforms.radius.value=E.radius,t.setRenderTarget(E.mapPass),t.clear(),t.renderBufferDirect(C,null,k,p,b,null),m.uniforms.shadow_pass.value=E.mapPass.texture,m.uniforms.resolution.value=E.mapSize,m.uniforms.radius.value=E.radius,t.setRenderTarget(E.map),t.clear(),t.renderBufferDirect(C,null,k,m,b,null)}function M(E,C,k,R){let A=null;const D=k.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(D!==void 0)A=D;else if(A=k.isPointLight===!0?c:l,t.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0){const U=A.uuid,F=C.uuid;let H=u[U];H===void 0&&(H={},u[U]=H);let j=H[F];j===void 0&&(j=A.clone(),H[F]=j),A=j}if(A.visible=C.visible,A.wireframe=C.wireframe,R===lu?A.side=C.shadowSide!==null?C.shadowSide:C.side:A.side=C.shadowSide!==null?C.shadowSide:f[C.side],A.alphaMap=C.alphaMap,A.alphaTest=C.alphaTest,A.map=C.map,A.clipShadows=C.clipShadows,A.clippingPlanes=C.clippingPlanes,A.clipIntersection=C.clipIntersection,A.displacementMap=C.displacementMap,A.displacementScale=C.displacementScale,A.displacementBias=C.displacementBias,A.wireframeLinewidth=C.wireframeLinewidth,A.linewidth=C.linewidth,k.isPointLight===!0&&A.isMeshDistanceMaterial===!0){const U=t.properties.get(A);U.light=k}return A}function T(E,C,k,R,A){if(E.visible===!1)return;if(E.layers.test(C.layers)&&(E.isMesh||E.isLine||E.isPoints)&&(E.castShadow||E.receiveShadow&&A===lu)&&(!E.frustumCulled||r.intersectsObject(E))){E.modelViewMatrix.multiplyMatrices(k.matrixWorldInverse,E.matrixWorld);const F=e.update(E),H=E.material;if(Array.isArray(H)){const j=F.groups;for(let $=0,K=j.length;$<K;$++){const V=j[$],Q=H[V.materialIndex];if(Q&&Q.visible){const Z=M(E,Q,R,A);E.onBeforeShadow(t,E,C,k,F,Z,V),t.renderBufferDirect(k,null,F,Z,E,V),E.onAfterShadow(t,E,C,k,F,Z,V)}}}else if(H.visible){const j=M(E,H,R,A);E.onBeforeShadow(t,E,C,k,F,j,null),t.renderBufferDirect(k,null,F,j,E,null),E.onAfterShadow(t,E,C,k,F,j,null)}}const U=E.children;for(let F=0,H=U.length;F<H;F++)T(U[F],C,k,R,A)}}function cBe(t,e,n){const r=n.isWebGL2;function i(){let Ee=!1;const We=new Cr;let ze=null;const W=new Cr(0,0,0,0);return{setMask:function(De){ze!==De&&!Ee&&(t.colorMask(De,De,De,De),ze=De)},setLocked:function(De){Ee=De},setClear:function(De,Ye,xt,ft,Bt){Bt===!0&&(De*=ft,Ye*=ft,xt*=ft),We.set(De,Ye,xt,ft),W.equals(We)===!1&&(t.clearColor(De,Ye,xt,ft),W.copy(We))},reset:function(){Ee=!1,ze=null,W.set(-1,0,0,0)}}}function a(){let Ee=!1,We=null,ze=null,W=null;return{setTest:function(De){De?ie(t.DEPTH_TEST):Me(t.DEPTH_TEST)},setMask:function(De){We!==De&&!Ee&&(t.depthMask(De),We=De)},setFunc:function(De){if(ze!==De){switch(De){case vLe:t.depthFunc(t.NEVER);break;case wLe:t.depthFunc(t.ALWAYS);break;case _Le:t.depthFunc(t.LESS);break;case ZS:t.depthFunc(t.LEQUAL);break;case SLe:t.depthFunc(t.EQUAL);break;case NLe:t.depthFunc(t.GEQUAL);break;case MLe:t.depthFunc(t.GREATER);break;case ELe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}ze=De}},setLocked:function(De){Ee=De},setClear:function(De){W!==De&&(t.clearDepth(De),W=De)},reset:function(){Ee=!1,We=null,ze=null,W=null}}}function o(){let Ee=!1,We=null,ze=null,W=null,De=null,Ye=null,xt=null,ft=null,Bt=null;return{setTest:function(Lt){Ee||(Lt?ie(t.STENCIL_TEST):Me(t.STENCIL_TEST))},setMask:function(Lt){We!==Lt&&!Ee&&(t.stencilMask(Lt),We=Lt)},setFunc:function(Lt,vn,Jt){(ze!==Lt||W!==vn||De!==Jt)&&(t.stencilFunc(Lt,vn,Jt),ze=Lt,W=vn,De=Jt)},setOp:function(Lt,vn,Jt){(Ye!==Lt||xt!==vn||ft!==Jt)&&(t.stencilOp(Lt,vn,Jt),Ye=Lt,xt=vn,ft=Jt)},setLocked:function(Lt){Ee=Lt},setClear:function(Lt){Bt!==Lt&&(t.clearStencil(Lt),Bt=Lt)},reset:function(){Ee=!1,We=null,ze=null,W=null,De=null,Ye=null,xt=null,ft=null,Bt=null}}}const l=new i,c=new a,u=new o,d=new WeakMap,f=new WeakMap;let p={},m={},x=new WeakMap,b=[],y=null,v=!1,S=null,M=null,T=null,E=null,C=null,k=null,R=null,A=new Zt(0,0,0),D=0,U=!1,F=null,H=null,j=null,$=null,K=null;const V=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Q=!1,Z=0;const ae=t.getParameter(t.VERSION);ae.indexOf("WebGL")!==-1?(Z=parseFloat(/^WebGL (\d)/.exec(ae)[1]),Q=Z>=1):ae.indexOf("OpenGL ES")!==-1&&(Z=parseFloat(/^OpenGL ES (\d)/.exec(ae)[1]),Q=Z>=2);let B=null,X={};const ne=t.getParameter(t.SCISSOR_BOX),se=t.getParameter(t.VIEWPORT),be=new Cr().fromArray(ne),xe=new Cr().fromArray(se);function de(Ee,We,ze,W){const De=new Uint8Array(4),Ye=t.createTexture();t.bindTexture(Ee,Ye),t.texParameteri(Ee,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(Ee,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let xt=0;xt<ze;xt++)r&&(Ee===t.TEXTURE_3D||Ee===t.TEXTURE_2D_ARRAY)?t.texImage3D(We,0,t.RGBA,1,1,W,0,t.RGBA,t.UNSIGNED_BYTE,De):t.texImage2D(We+xt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,De);return Ye}const Pe={};Pe[t.TEXTURE_2D]=de(t.TEXTURE_2D,t.TEXTURE_2D,1),Pe[t.TEXTURE_CUBE_MAP]=de(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Pe[t.TEXTURE_2D_ARRAY]=de(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Pe[t.TEXTURE_3D]=de(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),c.setClear(1),u.setClear(0),ie(t.DEPTH_TEST),c.setFunc(ZS),te(!1),I(LV),ie(t.CULL_FACE),ce(ch);function ie(Ee){p[Ee]!==!0&&(t.enable(Ee),p[Ee]=!0)}function Me(Ee){p[Ee]!==!1&&(t.disable(Ee),p[Ee]=!1)}function Oe(Ee,We){return m[Ee]!==We?(t.bindFramebuffer(Ee,We),m[Ee]=We,r&&(Ee===t.DRAW_FRAMEBUFFER&&(m[t.FRAMEBUFFER]=We),Ee===t.FRAMEBUFFER&&(m[t.DRAW_FRAMEBUFFER]=We)),!0):!1}function ge(Ee,We){let ze=b,W=!1;if(Ee)if(ze=x.get(We),ze===void 0&&(ze=[],x.set(We,ze)),Ee.isWebGLMultipleRenderTargets){const De=Ee.texture;if(ze.length!==De.length||ze[0]!==t.COLOR_ATTACHMENT0){for(let Ye=0,xt=De.length;Ye<xt;Ye++)ze[Ye]=t.COLOR_ATTACHMENT0+Ye;ze.length=De.length,W=!0}}else ze[0]!==t.COLOR_ATTACHMENT0&&(ze[0]=t.COLOR_ATTACHMENT0,W=!0);else ze[0]!==t.BACK&&(ze[0]=t.BACK,W=!0);W&&(n.isWebGL2?t.drawBuffers(ze):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(ze))}function Ke(Ee){return y!==Ee?(t.useProgram(Ee),y=Ee,!0):!1}const G={[Ef]:t.FUNC_ADD,[aLe]:t.FUNC_SUBTRACT,[sLe]:t.FUNC_REVERSE_SUBTRACT};if(r)G[zV]=t.MIN,G[BV]=t.MAX;else{const Ee=e.get("EXT_blend_minmax");Ee!==null&&(G[zV]=Ee.MIN_EXT,G[BV]=Ee.MAX_EXT)}const Y={[oLe]:t.ZERO,[lLe]:t.ONE,[cLe]:t.SRC_COLOR,[fD]:t.SRC_ALPHA,[pLe]:t.SRC_ALPHA_SATURATE,[fLe]:t.DST_COLOR,[dLe]:t.DST_ALPHA,[uLe]:t.ONE_MINUS_SRC_COLOR,[mD]:t.ONE_MINUS_SRC_ALPHA,[mLe]:t.ONE_MINUS_DST_COLOR,[hLe]:t.ONE_MINUS_DST_ALPHA,[gLe]:t.CONSTANT_COLOR,[xLe]:t.ONE_MINUS_CONSTANT_COLOR,[bLe]:t.CONSTANT_ALPHA,[yLe]:t.ONE_MINUS_CONSTANT_ALPHA};function ce(Ee,We,ze,W,De,Ye,xt,ft,Bt,Lt){if(Ee===ch){v===!0&&(Me(t.BLEND),v=!1);return}if(v===!1&&(ie(t.BLEND),v=!0),Ee!==iLe){if(Ee!==S||Lt!==U){if((M!==Ef||C!==Ef)&&(t.blendEquation(t.FUNC_ADD),M=Ef,C=Ef),Lt)switch(Ee){case jg:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case FV:t.blendFunc(t.ONE,t.ONE);break;case IV:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case UV:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",Ee);break}else switch(Ee){case jg:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case FV:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case IV:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case UV:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",Ee);break}T=null,E=null,k=null,R=null,A.set(0,0,0),D=0,S=Ee,U=Lt}return}De=De||We,Ye=Ye||ze,xt=xt||W,(We!==M||De!==C)&&(t.blendEquationSeparate(G[We],G[De]),M=We,C=De),(ze!==T||W!==E||Ye!==k||xt!==R)&&(t.blendFuncSeparate(Y[ze],Y[W],Y[Ye],Y[xt]),T=ze,E=W,k=Ye,R=xt),(ft.equals(A)===!1||Bt!==D)&&(t.blendColor(ft.r,ft.g,ft.b,Bt),A.copy(ft),D=Bt),S=Ee,U=!1}function q(Ee,We){Ee.side===pu?Me(t.CULL_FACE):ie(t.CULL_FACE);let ze=Ee.side===zs;We&&(ze=!ze),te(ze),Ee.blending===jg&&Ee.transparent===!1?ce(ch):ce(Ee.blending,Ee.blendEquation,Ee.blendSrc,Ee.blendDst,Ee.blendEquationAlpha,Ee.blendSrcAlpha,Ee.blendDstAlpha,Ee.blendColor,Ee.blendAlpha,Ee.premultipliedAlpha),c.setFunc(Ee.depthFunc),c.setTest(Ee.depthTest),c.setMask(Ee.depthWrite),l.setMask(Ee.colorWrite);const W=Ee.stencilWrite;u.setTest(W),W&&(u.setMask(Ee.stencilWriteMask),u.setFunc(Ee.stencilFunc,Ee.stencilRef,Ee.stencilFuncMask),u.setOp(Ee.stencilFail,Ee.stencilZFail,Ee.stencilZPass)),me(Ee.polygonOffset,Ee.polygonOffsetFactor,Ee.polygonOffsetUnits),Ee.alphaToCoverage===!0?ie(t.SAMPLE_ALPHA_TO_COVERAGE):Me(t.SAMPLE_ALPHA_TO_COVERAGE)}function te(Ee){F!==Ee&&(Ee?t.frontFace(t.CW):t.frontFace(t.CCW),F=Ee)}function I(Ee){Ee!==tLe?(ie(t.CULL_FACE),Ee!==H&&(Ee===LV?t.cullFace(t.BACK):Ee===nLe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Me(t.CULL_FACE),H=Ee}function fe(Ee){Ee!==j&&(Q&&t.lineWidth(Ee),j=Ee)}function me(Ee,We,ze){Ee?(ie(t.POLYGON_OFFSET_FILL),($!==We||K!==ze)&&(t.polygonOffset(We,ze),$=We,K=ze)):Me(t.POLYGON_OFFSET_FILL)}function ke(Ee){Ee?ie(t.SCISSOR_TEST):Me(t.SCISSOR_TEST)}function z(Ee){Ee===void 0&&(Ee=t.TEXTURE0+V-1),B!==Ee&&(t.activeTexture(Ee),B=Ee)}function O(Ee,We,ze){ze===void 0&&(B===null?ze=t.TEXTURE0+V-1:ze=B);let W=X[ze];W===void 0&&(W={type:void 0,texture:void 0},X[ze]=W),(W.type!==Ee||W.texture!==We)&&(B!==ze&&(t.activeTexture(ze),B=ze),t.bindTexture(Ee,We||Pe[Ee]),W.type=Ee,W.texture=We)}function ee(){const Ee=X[B];Ee!==void 0&&Ee.type!==void 0&&(t.bindTexture(Ee.type,null),Ee.type=void 0,Ee.texture=void 0)}function le(){try{t.compressedTexImage2D.apply(t,arguments)}catch(Ee){console.error("THREE.WebGLState:",Ee)}}function _e(){try{t.compressedTexImage3D.apply(t,arguments)}catch(Ee){console.error("THREE.WebGLState:",Ee)}}function we(){try{t.texSubImage2D.apply(t,arguments)}catch(Ee){console.error("THREE.WebGLState:",Ee)}}function re(){try{t.texSubImage3D.apply(t,arguments)}catch(Ee){console.error("THREE.WebGLState:",Ee)}}function Fe(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(Ee){console.error("THREE.WebGLState:",Ee)}}function $e(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(Ee){console.error("THREE.WebGLState:",Ee)}}function Ve(){try{t.texStorage2D.apply(t,arguments)}catch(Ee){console.error("THREE.WebGLState:",Ee)}}function He(){try{t.texStorage3D.apply(t,arguments)}catch(Ee){console.error("THREE.WebGLState:",Ee)}}function ye(){try{t.texImage2D.apply(t,arguments)}catch(Ee){console.error("THREE.WebGLState:",Ee)}}function je(){try{t.texImage3D.apply(t,arguments)}catch(Ee){console.error("THREE.WebGLState:",Ee)}}function Be(Ee){be.equals(Ee)===!1&&(t.scissor(Ee.x,Ee.y,Ee.z,Ee.w),be.copy(Ee))}function Se(Ee){xe.equals(Ee)===!1&&(t.viewport(Ee.x,Ee.y,Ee.z,Ee.w),xe.copy(Ee))}function Xe(Ee,We){let ze=f.get(We);ze===void 0&&(ze=new WeakMap,f.set(We,ze));let W=ze.get(Ee);W===void 0&&(W=t.getUniformBlockIndex(We,Ee.name),ze.set(Ee,W))}function Ne(Ee,We){const W=f.get(We).get(Ee);d.get(We)!==W&&(t.uniformBlockBinding(We,W,Ee.__bindingPointIndex),d.set(We,W))}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),p={},B=null,X={},m={},x=new WeakMap,b=[],y=null,v=!1,S=null,M=null,T=null,E=null,C=null,k=null,R=null,A=new Zt(0,0,0),D=0,U=!1,F=null,H=null,j=null,$=null,K=null,be.set(0,0,t.canvas.width,t.canvas.height),xe.set(0,0,t.canvas.width,t.canvas.height),l.reset(),c.reset(),u.reset()}return{buffers:{color:l,depth:c,stencil:u},enable:ie,disable:Me,bindFramebuffer:Oe,drawBuffers:ge,useProgram:Ke,setBlending:ce,setMaterial:q,setFlipSided:te,setCullFace:I,setLineWidth:fe,setPolygonOffset:me,setScissorTest:ke,activeTexture:z,bindTexture:O,unbindTexture:ee,compressedTexImage2D:le,compressedTexImage3D:_e,texImage2D:ye,texImage3D:je,updateUBOMapping:Xe,uniformBlockBinding:Ne,texStorage2D:Ve,texStorage3D:He,texSubImage2D:we,texSubImage3D:re,compressedTexSubImage2D:Fe,compressedTexSubImage3D:$e,scissor:Be,viewport:Se,reset:tt}}function uBe(t,e,n,r,i,a,o){const l=i.isWebGL2,c=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,f=i.maxSamples,p=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,m=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),x=new WeakMap;let b;const y=new WeakMap;let v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function S(z,O){return v?new OffscreenCanvas(z,O):rN("canvas")}function M(z,O,ee,le){let _e=1;if((z.width>le||z.height>le)&&(_e=le/Math.max(z.width,z.height)),_e<1||O===!0)if(typeof HTMLImageElement<"u"&&z instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&z instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&z instanceof ImageBitmap){const we=O?nN:Math.floor,re=we(_e*z.width),Fe=we(_e*z.height);b===void 0&&(b=S(re,Fe));const $e=ee?S(re,Fe):b;return $e.width=re,$e.height=Fe,$e.getContext("2d").drawImage(z,0,0,re,Fe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+z.width+"x"+z.height+") to ("+re+"x"+Fe+")."),$e}else return"data"in z&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+z.width+"x"+z.height+")."),z;return z}function T(z){return wD(z.width)&&wD(z.height)}function E(z){return l?!1:z.wrapS!==Cl||z.wrapT!==Cl||z.minFilter!==Da&&z.minFilter!==Ko}function C(z,O){return z.generateMipmaps&&O&&z.minFilter!==Da&&z.minFilter!==Ko}function k(z){t.generateMipmap(z)}function R(z,O,ee,le,_e=!1){if(l===!1)return O;if(z!==null){if(t[z]!==void 0)return t[z];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+z+"'")}let we=O;if(O===t.RED&&(ee===t.FLOAT&&(we=t.R32F),ee===t.HALF_FLOAT&&(we=t.R16F),ee===t.UNSIGNED_BYTE&&(we=t.R8)),O===t.RED_INTEGER&&(ee===t.UNSIGNED_BYTE&&(we=t.R8UI),ee===t.UNSIGNED_SHORT&&(we=t.R16UI),ee===t.UNSIGNED_INT&&(we=t.R32UI),ee===t.BYTE&&(we=t.R8I),ee===t.SHORT&&(we=t.R16I),ee===t.INT&&(we=t.R32I)),O===t.RG&&(ee===t.FLOAT&&(we=t.RG32F),ee===t.HALF_FLOAT&&(we=t.RG16F),ee===t.UNSIGNED_BYTE&&(we=t.RG8)),O===t.RGBA){const re=_e?JS:kr.getTransfer(le);ee===t.FLOAT&&(we=t.RGBA32F),ee===t.HALF_FLOAT&&(we=t.RGBA16F),ee===t.UNSIGNED_BYTE&&(we=re===Gr?t.SRGB8_ALPHA8:t.RGBA8),ee===t.UNSIGNED_SHORT_4_4_4_4&&(we=t.RGBA4),ee===t.UNSIGNED_SHORT_5_5_5_1&&(we=t.RGB5_A1)}return(we===t.R16F||we===t.R32F||we===t.RG16F||we===t.RG32F||we===t.RGBA16F||we===t.RGBA32F)&&e.get("EXT_color_buffer_float"),we}function A(z,O,ee){return C(z,ee)===!0||z.isFramebufferTexture&&z.minFilter!==Da&&z.minFilter!==Ko?Math.log2(Math.max(O.width,O.height))+1:z.mipmaps!==void 0&&z.mipmaps.length>0?z.mipmaps.length:z.isCompressedTexture&&Array.isArray(z.image)?O.mipmaps.length:1}function D(z){return z===Da||z===$V||z===NC?t.NEAREST:t.LINEAR}function U(z){const O=z.target;O.removeEventListener("dispose",U),H(O),O.isVideoTexture&&x.delete(O)}function F(z){const O=z.target;O.removeEventListener("dispose",F),$(O)}function H(z){const O=r.get(z);if(O.__webglInit===void 0)return;const ee=z.source,le=y.get(ee);if(le){const _e=le[O.__cacheKey];_e.usedTimes--,_e.usedTimes===0&&j(z),Object.keys(le).length===0&&y.delete(ee)}r.remove(z)}function j(z){const O=r.get(z);t.deleteTexture(O.__webglTexture);const ee=z.source,le=y.get(ee);delete le[O.__cacheKey],o.memory.textures--}function $(z){const O=z.texture,ee=r.get(z),le=r.get(O);if(le.__webglTexture!==void 0&&(t.deleteTexture(le.__webglTexture),o.memory.textures--),z.depthTexture&&z.depthTexture.dispose(),z.isWebGLCubeRenderTarget)for(let _e=0;_e<6;_e++){if(Array.isArray(ee.__webglFramebuffer[_e]))for(let we=0;we<ee.__webglFramebuffer[_e].length;we++)t.deleteFramebuffer(ee.__webglFramebuffer[_e][we]);else t.deleteFramebuffer(ee.__webglFramebuffer[_e]);ee.__webglDepthbuffer&&t.deleteRenderbuffer(ee.__webglDepthbuffer[_e])}else{if(Array.isArray(ee.__webglFramebuffer))for(let _e=0;_e<ee.__webglFramebuffer.length;_e++)t.deleteFramebuffer(ee.__webglFramebuffer[_e]);else t.deleteFramebuffer(ee.__webglFramebuffer);if(ee.__webglDepthbuffer&&t.deleteRenderbuffer(ee.__webglDepthbuffer),ee.__webglMultisampledFramebuffer&&t.deleteFramebuffer(ee.__webglMultisampledFramebuffer),ee.__webglColorRenderbuffer)for(let _e=0;_e<ee.__webglColorRenderbuffer.length;_e++)ee.__webglColorRenderbuffer[_e]&&t.deleteRenderbuffer(ee.__webglColorRenderbuffer[_e]);ee.__webglDepthRenderbuffer&&t.deleteRenderbuffer(ee.__webglDepthRenderbuffer)}if(z.isWebGLMultipleRenderTargets)for(let _e=0,we=O.length;_e<we;_e++){const re=r.get(O[_e]);re.__webglTexture&&(t.deleteTexture(re.__webglTexture),o.memory.textures--),r.remove(O[_e])}r.remove(O),r.remove(z)}let K=0;function V(){K=0}function Q(){const z=K;return z>=c&&console.warn("THREE.WebGLTextures: Trying to use "+z+" texture units while this GPU supports only "+c),K+=1,z}function Z(z){const O=[];return O.push(z.wrapS),O.push(z.wrapT),O.push(z.wrapR||0),O.push(z.magFilter),O.push(z.minFilter),O.push(z.anisotropy),O.push(z.internalFormat),O.push(z.format),O.push(z.type),O.push(z.generateMipmaps),O.push(z.premultiplyAlpha),O.push(z.flipY),O.push(z.unpackAlignment),O.push(z.colorSpace),O.join()}function ae(z,O){const ee=r.get(z);if(z.isVideoTexture&&me(z),z.isRenderTargetTexture===!1&&z.version>0&&ee.__version!==z.version){const le=z.image;if(le===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(le.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ie(ee,z,O);return}}n.bindTexture(t.TEXTURE_2D,ee.__webglTexture,t.TEXTURE0+O)}function B(z,O){const ee=r.get(z);if(z.version>0&&ee.__version!==z.version){ie(ee,z,O);return}n.bindTexture(t.TEXTURE_2D_ARRAY,ee.__webglTexture,t.TEXTURE0+O)}function X(z,O){const ee=r.get(z);if(z.version>0&&ee.__version!==z.version){ie(ee,z,O);return}n.bindTexture(t.TEXTURE_3D,ee.__webglTexture,t.TEXTURE0+O)}function ne(z,O){const ee=r.get(z);if(z.version>0&&ee.__version!==z.version){Me(ee,z,O);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ee.__webglTexture,t.TEXTURE0+O)}const se={[xD]:t.REPEAT,[Cl]:t.CLAMP_TO_EDGE,[bD]:t.MIRRORED_REPEAT},be={[Da]:t.NEAREST,[$V]:t.NEAREST_MIPMAP_NEAREST,[NC]:t.NEAREST_MIPMAP_LINEAR,[Ko]:t.LINEAR,[RLe]:t.LINEAR_MIPMAP_NEAREST,[gy]:t.LINEAR_MIPMAP_LINEAR},xe={[qLe]:t.NEVER,[ZLe]:t.ALWAYS,[WLe]:t.LESS,[GJ]:t.LEQUAL,[KLe]:t.EQUAL,[QLe]:t.GEQUAL,[XLe]:t.GREATER,[YLe]:t.NOTEQUAL};function de(z,O,ee){if(ee?(t.texParameteri(z,t.TEXTURE_WRAP_S,se[O.wrapS]),t.texParameteri(z,t.TEXTURE_WRAP_T,se[O.wrapT]),(z===t.TEXTURE_3D||z===t.TEXTURE_2D_ARRAY)&&t.texParameteri(z,t.TEXTURE_WRAP_R,se[O.wrapR]),t.texParameteri(z,t.TEXTURE_MAG_FILTER,be[O.magFilter]),t.texParameteri(z,t.TEXTURE_MIN_FILTER,be[O.minFilter])):(t.texParameteri(z,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(z,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(z===t.TEXTURE_3D||z===t.TEXTURE_2D_ARRAY)&&t.texParameteri(z,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(O.wrapS!==Cl||O.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(z,t.TEXTURE_MAG_FILTER,D(O.magFilter)),t.texParameteri(z,t.TEXTURE_MIN_FILTER,D(O.minFilter)),O.minFilter!==Da&&O.minFilter!==Ko&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),O.compareFunction&&(t.texParameteri(z,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(z,t.TEXTURE_COMPARE_FUNC,xe[O.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const le=e.get("EXT_texture_filter_anisotropic");if(O.magFilter===Da||O.minFilter!==NC&&O.minFilter!==gy||O.type===_u&&e.has("OES_texture_float_linear")===!1||l===!1&&O.type===xy&&e.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||r.get(O).__currentAnisotropy)&&(t.texParameterf(z,le.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,i.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy)}}function Pe(z,O){let ee=!1;z.__webglInit===void 0&&(z.__webglInit=!0,O.addEventListener("dispose",U));const le=O.source;let _e=y.get(le);_e===void 0&&(_e={},y.set(le,_e));const we=Z(O);if(we!==z.__cacheKey){_e[we]===void 0&&(_e[we]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,ee=!0),_e[we].usedTimes++;const re=_e[z.__cacheKey];re!==void 0&&(_e[z.__cacheKey].usedTimes--,re.usedTimes===0&&j(O)),z.__cacheKey=we,z.__webglTexture=_e[we].texture}return ee}function ie(z,O,ee){let le=t.TEXTURE_2D;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(le=t.TEXTURE_2D_ARRAY),O.isData3DTexture&&(le=t.TEXTURE_3D);const _e=Pe(z,O),we=O.source;n.bindTexture(le,z.__webglTexture,t.TEXTURE0+ee);const re=r.get(we);if(we.version!==re.__version||_e===!0){n.activeTexture(t.TEXTURE0+ee);const Fe=kr.getPrimaries(kr.workingColorSpace),$e=O.colorSpace===Yo?null:kr.getPrimaries(O.colorSpace),Ve=O.colorSpace===Yo||Fe===$e?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ve);const He=E(O)&&T(O.image)===!1;let ye=M(O.image,He,!1,d);ye=ke(O,ye);const je=T(ye)||l,Be=a.convert(O.format,O.colorSpace);let Se=a.convert(O.type),Xe=R(O.internalFormat,Be,Se,O.colorSpace,O.isVideoTexture);de(le,O,je);let Ne;const tt=O.mipmaps,Ee=l&&O.isVideoTexture!==!0&&Xe!==$J,We=re.__version===void 0||_e===!0,ze=A(O,ye,je);if(O.isDepthTexture)Xe=t.DEPTH_COMPONENT,l?O.type===_u?Xe=t.DEPTH_COMPONENT32F:O.type===Zd?Xe=t.DEPTH_COMPONENT24:O.type===qf?Xe=t.DEPTH24_STENCIL8:Xe=t.DEPTH_COMPONENT16:O.type===_u&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===Wf&&Xe===t.DEPTH_COMPONENT&&O.type!==iL&&O.type!==Zd&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=Zd,Se=a.convert(O.type)),O.format===ix&&Xe===t.DEPTH_COMPONENT&&(Xe=t.DEPTH_STENCIL,O.type!==qf&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=qf,Se=a.convert(O.type))),We&&(Ee?n.texStorage2D(t.TEXTURE_2D,1,Xe,ye.width,ye.height):n.texImage2D(t.TEXTURE_2D,0,Xe,ye.width,ye.height,0,Be,Se,null));else if(O.isDataTexture)if(tt.length>0&&je){Ee&&We&&n.texStorage2D(t.TEXTURE_2D,ze,Xe,tt[0].width,tt[0].height);for(let W=0,De=tt.length;W<De;W++)Ne=tt[W],Ee?n.texSubImage2D(t.TEXTURE_2D,W,0,0,Ne.width,Ne.height,Be,Se,Ne.data):n.texImage2D(t.TEXTURE_2D,W,Xe,Ne.width,Ne.height,0,Be,Se,Ne.data);O.generateMipmaps=!1}else Ee?(We&&n.texStorage2D(t.TEXTURE_2D,ze,Xe,ye.width,ye.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,ye.width,ye.height,Be,Se,ye.data)):n.texImage2D(t.TEXTURE_2D,0,Xe,ye.width,ye.height,0,Be,Se,ye.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){Ee&&We&&n.texStorage3D(t.TEXTURE_2D_ARRAY,ze,Xe,tt[0].width,tt[0].height,ye.depth);for(let W=0,De=tt.length;W<De;W++)Ne=tt[W],O.format!==Xo?Be!==null?Ee?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,W,0,0,0,Ne.width,Ne.height,ye.depth,Be,Ne.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,W,Xe,Ne.width,Ne.height,ye.depth,0,Ne.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ee?n.texSubImage3D(t.TEXTURE_2D_ARRAY,W,0,0,0,Ne.width,Ne.height,ye.depth,Be,Se,Ne.data):n.texImage3D(t.TEXTURE_2D_ARRAY,W,Xe,Ne.width,Ne.height,ye.depth,0,Be,Se,Ne.data)}else{Ee&&We&&n.texStorage2D(t.TEXTURE_2D,ze,Xe,tt[0].width,tt[0].height);for(let W=0,De=tt.length;W<De;W++)Ne=tt[W],O.format!==Xo?Be!==null?Ee?n.compressedTexSubImage2D(t.TEXTURE_2D,W,0,0,Ne.width,Ne.height,Be,Ne.data):n.compressedTexImage2D(t.TEXTURE_2D,W,Xe,Ne.width,Ne.height,0,Ne.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ee?n.texSubImage2D(t.TEXTURE_2D,W,0,0,Ne.width,Ne.height,Be,Se,Ne.data):n.texImage2D(t.TEXTURE_2D,W,Xe,Ne.width,Ne.height,0,Be,Se,Ne.data)}else if(O.isDataArrayTexture)Ee?(We&&n.texStorage3D(t.TEXTURE_2D_ARRAY,ze,Xe,ye.width,ye.height,ye.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,ye.width,ye.height,ye.depth,Be,Se,ye.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,Xe,ye.width,ye.height,ye.depth,0,Be,Se,ye.data);else if(O.isData3DTexture)Ee?(We&&n.texStorage3D(t.TEXTURE_3D,ze,Xe,ye.width,ye.height,ye.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,ye.width,ye.height,ye.depth,Be,Se,ye.data)):n.texImage3D(t.TEXTURE_3D,0,Xe,ye.width,ye.height,ye.depth,0,Be,Se,ye.data);else if(O.isFramebufferTexture){if(We)if(Ee)n.texStorage2D(t.TEXTURE_2D,ze,Xe,ye.width,ye.height);else{let W=ye.width,De=ye.height;for(let Ye=0;Ye<ze;Ye++)n.texImage2D(t.TEXTURE_2D,Ye,Xe,W,De,0,Be,Se,null),W>>=1,De>>=1}}else if(tt.length>0&&je){Ee&&We&&n.texStorage2D(t.TEXTURE_2D,ze,Xe,tt[0].width,tt[0].height);for(let W=0,De=tt.length;W<De;W++)Ne=tt[W],Ee?n.texSubImage2D(t.TEXTURE_2D,W,0,0,Be,Se,Ne):n.texImage2D(t.TEXTURE_2D,W,Xe,Be,Se,Ne);O.generateMipmaps=!1}else Ee?(We&&n.texStorage2D(t.TEXTURE_2D,ze,Xe,ye.width,ye.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,Be,Se,ye)):n.texImage2D(t.TEXTURE_2D,0,Xe,Be,Se,ye);C(O,je)&&k(le),re.__version=we.version,O.onUpdate&&O.onUpdate(O)}z.__version=O.version}function Me(z,O,ee){if(O.image.length!==6)return;const le=Pe(z,O),_e=O.source;n.bindTexture(t.TEXTURE_CUBE_MAP,z.__webglTexture,t.TEXTURE0+ee);const we=r.get(_e);if(_e.version!==we.__version||le===!0){n.activeTexture(t.TEXTURE0+ee);const re=kr.getPrimaries(kr.workingColorSpace),Fe=O.colorSpace===Yo?null:kr.getPrimaries(O.colorSpace),$e=O.colorSpace===Yo||re===Fe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,$e);const Ve=O.isCompressedTexture||O.image[0].isCompressedTexture,He=O.image[0]&&O.image[0].isDataTexture,ye=[];for(let W=0;W<6;W++)!Ve&&!He?ye[W]=M(O.image[W],!1,!0,u):ye[W]=He?O.image[W].image:O.image[W],ye[W]=ke(O,ye[W]);const je=ye[0],Be=T(je)||l,Se=a.convert(O.format,O.colorSpace),Xe=a.convert(O.type),Ne=R(O.internalFormat,Se,Xe,O.colorSpace),tt=l&&O.isVideoTexture!==!0,Ee=we.__version===void 0||le===!0;let We=A(O,je,Be);de(t.TEXTURE_CUBE_MAP,O,Be);let ze;if(Ve){tt&&Ee&&n.texStorage2D(t.TEXTURE_CUBE_MAP,We,Ne,je.width,je.height);for(let W=0;W<6;W++){ze=ye[W].mipmaps;for(let De=0;De<ze.length;De++){const Ye=ze[De];O.format!==Xo?Se!==null?tt?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De,0,0,Ye.width,Ye.height,Se,Ye.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De,Ne,Ye.width,Ye.height,0,Ye.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):tt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De,0,0,Ye.width,Ye.height,Se,Xe,Ye.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De,Ne,Ye.width,Ye.height,0,Se,Xe,Ye.data)}}}else{ze=O.mipmaps,tt&&Ee&&(ze.length>0&&We++,n.texStorage2D(t.TEXTURE_CUBE_MAP,We,Ne,ye[0].width,ye[0].height));for(let W=0;W<6;W++)if(He){tt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,0,0,ye[W].width,ye[W].height,Se,Xe,ye[W].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,Ne,ye[W].width,ye[W].height,0,Se,Xe,ye[W].data);for(let De=0;De<ze.length;De++){const xt=ze[De].image[W].image;tt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De+1,0,0,xt.width,xt.height,Se,Xe,xt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De+1,Ne,xt.width,xt.height,0,Se,Xe,xt.data)}}else{tt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,0,0,Se,Xe,ye[W]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,Ne,Se,Xe,ye[W]);for(let De=0;De<ze.length;De++){const Ye=ze[De];tt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De+1,0,0,Se,Xe,Ye.image[W]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De+1,Ne,Se,Xe,Ye.image[W])}}}C(O,Be)&&k(t.TEXTURE_CUBE_MAP),we.__version=_e.version,O.onUpdate&&O.onUpdate(O)}z.__version=O.version}function Oe(z,O,ee,le,_e,we){const re=a.convert(ee.format,ee.colorSpace),Fe=a.convert(ee.type),$e=R(ee.internalFormat,re,Fe,ee.colorSpace);if(!r.get(O).__hasExternalTextures){const He=Math.max(1,O.width>>we),ye=Math.max(1,O.height>>we);_e===t.TEXTURE_3D||_e===t.TEXTURE_2D_ARRAY?n.texImage3D(_e,we,$e,He,ye,O.depth,0,re,Fe,null):n.texImage2D(_e,we,$e,He,ye,0,re,Fe,null)}n.bindFramebuffer(t.FRAMEBUFFER,z),fe(O)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,le,_e,r.get(ee).__webglTexture,0,I(O)):(_e===t.TEXTURE_2D||_e>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&_e<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,le,_e,r.get(ee).__webglTexture,we),n.bindFramebuffer(t.FRAMEBUFFER,null)}function ge(z,O,ee){if(t.bindRenderbuffer(t.RENDERBUFFER,z),O.depthBuffer&&!O.stencilBuffer){let le=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(ee||fe(O)){const _e=O.depthTexture;_e&&_e.isDepthTexture&&(_e.type===_u?le=t.DEPTH_COMPONENT32F:_e.type===Zd&&(le=t.DEPTH_COMPONENT24));const we=I(O);fe(O)?p.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,we,le,O.width,O.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,we,le,O.width,O.height)}else t.renderbufferStorage(t.RENDERBUFFER,le,O.width,O.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,z)}else if(O.depthBuffer&&O.stencilBuffer){const le=I(O);ee&&fe(O)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,le,t.DEPTH24_STENCIL8,O.width,O.height):fe(O)?p.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,le,t.DEPTH24_STENCIL8,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,O.width,O.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,z)}else{const le=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let _e=0;_e<le.length;_e++){const we=le[_e],re=a.convert(we.format,we.colorSpace),Fe=a.convert(we.type),$e=R(we.internalFormat,re,Fe,we.colorSpace),Ve=I(O);ee&&fe(O)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ve,$e,O.width,O.height):fe(O)?p.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ve,$e,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,$e,O.width,O.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Ke(z,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,z),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(O.depthTexture).__webglTexture||O.depthTexture.image.width!==O.width||O.depthTexture.image.height!==O.height)&&(O.depthTexture.image.width=O.width,O.depthTexture.image.height=O.height,O.depthTexture.needsUpdate=!0),ae(O.depthTexture,0);const le=r.get(O.depthTexture).__webglTexture,_e=I(O);if(O.depthTexture.format===Wf)fe(O)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,le,0,_e):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,le,0);else if(O.depthTexture.format===ix)fe(O)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,le,0,_e):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,le,0);else throw new Error("Unknown depthTexture format")}function G(z){const O=r.get(z),ee=z.isWebGLCubeRenderTarget===!0;if(z.depthTexture&&!O.__autoAllocateDepthBuffer){if(ee)throw new Error("target.depthTexture not supported in Cube render targets");Ke(O.__webglFramebuffer,z)}else if(ee){O.__webglDepthbuffer=[];for(let le=0;le<6;le++)n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer[le]),O.__webglDepthbuffer[le]=t.createRenderbuffer(),ge(O.__webglDepthbuffer[le],z,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer),O.__webglDepthbuffer=t.createRenderbuffer(),ge(O.__webglDepthbuffer,z,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function Y(z,O,ee){const le=r.get(z);O!==void 0&&Oe(le.__webglFramebuffer,z,z.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ee!==void 0&&G(z)}function ce(z){const O=z.texture,ee=r.get(z),le=r.get(O);z.addEventListener("dispose",F),z.isWebGLMultipleRenderTargets!==!0&&(le.__webglTexture===void 0&&(le.__webglTexture=t.createTexture()),le.__version=O.version,o.memory.textures++);const _e=z.isWebGLCubeRenderTarget===!0,we=z.isWebGLMultipleRenderTargets===!0,re=T(z)||l;if(_e){ee.__webglFramebuffer=[];for(let Fe=0;Fe<6;Fe++)if(l&&O.mipmaps&&O.mipmaps.length>0){ee.__webglFramebuffer[Fe]=[];for(let $e=0;$e<O.mipmaps.length;$e++)ee.__webglFramebuffer[Fe][$e]=t.createFramebuffer()}else ee.__webglFramebuffer[Fe]=t.createFramebuffer()}else{if(l&&O.mipmaps&&O.mipmaps.length>0){ee.__webglFramebuffer=[];for(let Fe=0;Fe<O.mipmaps.length;Fe++)ee.__webglFramebuffer[Fe]=t.createFramebuffer()}else ee.__webglFramebuffer=t.createFramebuffer();if(we)if(i.drawBuffers){const Fe=z.texture;for(let $e=0,Ve=Fe.length;$e<Ve;$e++){const He=r.get(Fe[$e]);He.__webglTexture===void 0&&(He.__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&&z.samples>0&&fe(z)===!1){const Fe=we?O:[O];ee.__webglMultisampledFramebuffer=t.createFramebuffer(),ee.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ee.__webglMultisampledFramebuffer);for(let $e=0;$e<Fe.length;$e++){const Ve=Fe[$e];ee.__webglColorRenderbuffer[$e]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ee.__webglColorRenderbuffer[$e]);const He=a.convert(Ve.format,Ve.colorSpace),ye=a.convert(Ve.type),je=R(Ve.internalFormat,He,ye,Ve.colorSpace,z.isXRRenderTarget===!0),Be=I(z);t.renderbufferStorageMultisample(t.RENDERBUFFER,Be,je,z.width,z.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+$e,t.RENDERBUFFER,ee.__webglColorRenderbuffer[$e])}t.bindRenderbuffer(t.RENDERBUFFER,null),z.depthBuffer&&(ee.__webglDepthRenderbuffer=t.createRenderbuffer(),ge(ee.__webglDepthRenderbuffer,z,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(_e){n.bindTexture(t.TEXTURE_CUBE_MAP,le.__webglTexture),de(t.TEXTURE_CUBE_MAP,O,re);for(let Fe=0;Fe<6;Fe++)if(l&&O.mipmaps&&O.mipmaps.length>0)for(let $e=0;$e<O.mipmaps.length;$e++)Oe(ee.__webglFramebuffer[Fe][$e],z,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Fe,$e);else Oe(ee.__webglFramebuffer[Fe],z,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Fe,0);C(O,re)&&k(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(we){const Fe=z.texture;for(let $e=0,Ve=Fe.length;$e<Ve;$e++){const He=Fe[$e],ye=r.get(He);n.bindTexture(t.TEXTURE_2D,ye.__webglTexture),de(t.TEXTURE_2D,He,re),Oe(ee.__webglFramebuffer,z,He,t.COLOR_ATTACHMENT0+$e,t.TEXTURE_2D,0),C(He,re)&&k(t.TEXTURE_2D)}n.unbindTexture()}else{let Fe=t.TEXTURE_2D;if((z.isWebGL3DRenderTarget||z.isWebGLArrayRenderTarget)&&(l?Fe=z.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Fe,le.__webglTexture),de(Fe,O,re),l&&O.mipmaps&&O.mipmaps.length>0)for(let $e=0;$e<O.mipmaps.length;$e++)Oe(ee.__webglFramebuffer[$e],z,O,t.COLOR_ATTACHMENT0,Fe,$e);else Oe(ee.__webglFramebuffer,z,O,t.COLOR_ATTACHMENT0,Fe,0);C(O,re)&&k(Fe),n.unbindTexture()}z.depthBuffer&&G(z)}function q(z){const O=T(z)||l,ee=z.isWebGLMultipleRenderTargets===!0?z.texture:[z.texture];for(let le=0,_e=ee.length;le<_e;le++){const we=ee[le];if(C(we,O)){const re=z.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Fe=r.get(we).__webglTexture;n.bindTexture(re,Fe),k(re),n.unbindTexture()}}}function te(z){if(l&&z.samples>0&&fe(z)===!1){const O=z.isWebGLMultipleRenderTargets?z.texture:[z.texture],ee=z.width,le=z.height;let _e=t.COLOR_BUFFER_BIT;const we=[],re=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Fe=r.get(z),$e=z.isWebGLMultipleRenderTargets===!0;if($e)for(let Ve=0;Ve<O.length;Ve++)n.bindFramebuffer(t.FRAMEBUFFER,Fe.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Fe.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Fe.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Fe.__webglFramebuffer);for(let Ve=0;Ve<O.length;Ve++){we.push(t.COLOR_ATTACHMENT0+Ve),z.depthBuffer&&we.push(re);const He=Fe.__ignoreDepthValues!==void 0?Fe.__ignoreDepthValues:!1;if(He===!1&&(z.depthBuffer&&(_e|=t.DEPTH_BUFFER_BIT),z.stencilBuffer&&(_e|=t.STENCIL_BUFFER_BIT)),$e&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Fe.__webglColorRenderbuffer[Ve]),He===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[re]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[re])),$e){const ye=r.get(O[Ve]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,ye,0)}t.blitFramebuffer(0,0,ee,le,0,0,ee,le,_e,t.NEAREST),m&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,we)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),$e)for(let Ve=0;Ve<O.length;Ve++){n.bindFramebuffer(t.FRAMEBUFFER,Fe.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,Fe.__webglColorRenderbuffer[Ve]);const He=r.get(O[Ve]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Fe.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,He,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Fe.__webglMultisampledFramebuffer)}}function I(z){return Math.min(f,z.samples)}function fe(z){const O=r.get(z);return l&&z.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function me(z){const O=o.render.frame;x.get(z)!==O&&(x.set(z,O),z.update())}function ke(z,O){const ee=z.colorSpace,le=z.format,_e=z.type;return z.isCompressedTexture===!0||z.isVideoTexture===!0||z.format===vD||ee!==Vu&&ee!==Yo&&(kr.getTransfer(ee)===Gr?l===!1?e.has("EXT_sRGB")===!0&&le===Xo?(z.format=vD,z.minFilter=Ko,z.generateMipmaps=!1):O=KJ.sRGBToLinear(O):(le!==Xo||_e!==dh)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",ee)),O}this.allocateTextureUnit=Q,this.resetTextureUnits=V,this.setTexture2D=ae,this.setTexture2DArray=B,this.setTexture3D=X,this.setTextureCube=ne,this.rebindTextures=Y,this.setupRenderTarget=ce,this.updateRenderTargetMipmap=q,this.updateMultisampleRenderTarget=te,this.setupDepthRenderbuffer=G,this.setupFrameBufferTexture=Oe,this.useMultisampledRTT=fe}function dBe(t,e,n){const r=n.isWebGL2;function i(a,o=Yo){let l;const c=kr.getTransfer(o);if(a===dh)return t.UNSIGNED_BYTE;if(a===FJ)return t.UNSIGNED_SHORT_4_4_4_4;if(a===IJ)return t.UNSIGNED_SHORT_5_5_5_1;if(a===OLe)return t.BYTE;if(a===LLe)return t.SHORT;if(a===iL)return t.UNSIGNED_SHORT;if(a===LJ)return t.INT;if(a===Zd)return t.UNSIGNED_INT;if(a===_u)return t.FLOAT;if(a===xy)return r?t.HALF_FLOAT:(l=e.get("OES_texture_half_float"),l!==null?l.HALF_FLOAT_OES:null);if(a===FLe)return t.ALPHA;if(a===Xo)return t.RGBA;if(a===ILe)return t.LUMINANCE;if(a===ULe)return t.LUMINANCE_ALPHA;if(a===Wf)return t.DEPTH_COMPONENT;if(a===ix)return t.DEPTH_STENCIL;if(a===vD)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(a===zLe)return t.RED;if(a===UJ)return t.RED_INTEGER;if(a===BLe)return t.RG;if(a===zJ)return t.RG_INTEGER;if(a===BJ)return t.RGBA_INTEGER;if(a===MC||a===EC||a===kC||a===TC)if(c===Gr)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(a===MC)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===EC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===kC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===TC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(a===MC)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===EC)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===kC)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===TC)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===HV||a===VV||a===GV||a===qV)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(a===HV)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===VV)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===GV)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===qV)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===$J)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===WV||a===KV)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(a===WV)return c===Gr?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(a===KV)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===XV||a===YV||a===QV||a===ZV||a===JV||a===eG||a===tG||a===nG||a===rG||a===iG||a===aG||a===sG||a===oG||a===lG)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(a===XV)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===YV)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===QV)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===ZV)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===JV)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===eG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===tG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===nG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===rG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===iG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===aG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===sG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===oG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===lG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===AC||a===cG||a===uG)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(a===AC)return c===Gr?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===cG)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===uG)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===$Le||a===dG||a===hG||a===fG)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(a===AC)return l.COMPRESSED_RED_RGTC1_EXT;if(a===dG)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===hG)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===fG)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===qf?r?t.UNSIGNED_INT_24_8:(l=e.get("WEBGL_depth_texture"),l!==null?l.UNSIGNED_INT_24_8_WEBGL:null):t[a]!==void 0?t[a]:null}return{convert:i}}class hBe extends oo{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class u0 extends ps{constructor(){super(),this.isGroup=!0,this.type="Group"}}const fBe={type:"move"};class ZC{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new u0,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 u0,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 u0,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new qe,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new qe),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,a=null,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"],p=d.position.distanceTo(f.position),m=.02,x=.005;u.inputState.pinching&&p>m+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&p<=m-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),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(fBe)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=a!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new u0;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class mBe extends jm{constructor(e,n){super();const r=this;let i=null,a=1,o=null,l="local-floor",c=1,u=null,d=null,f=null,p=null,m=null,x=null;const b=n.getContextAttributes();let y=null,v=null;const S=[],M=[],T=new xn;let E=null;const C=new oo;C.layers.enable(1),C.viewport=new Cr;const k=new oo;k.layers.enable(2),k.viewport=new Cr;const R=[C,k],A=new hBe;A.layers.enable(1),A.layers.enable(2);let D=null,U=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ne){let se=S[ne];return se===void 0&&(se=new ZC,S[ne]=se),se.getTargetRaySpace()},this.getControllerGrip=function(ne){let se=S[ne];return se===void 0&&(se=new ZC,S[ne]=se),se.getGripSpace()},this.getHand=function(ne){let se=S[ne];return se===void 0&&(se=new ZC,S[ne]=se),se.getHandSpace()};function F(ne){const se=M.indexOf(ne.inputSource);if(se===-1)return;const be=S[se];be!==void 0&&(be.update(ne.inputSource,ne.frame,u||o),be.dispatchEvent({type:ne.type,data:ne.inputSource}))}function H(){i.removeEventListener("select",F),i.removeEventListener("selectstart",F),i.removeEventListener("selectend",F),i.removeEventListener("squeeze",F),i.removeEventListener("squeezestart",F),i.removeEventListener("squeezeend",F),i.removeEventListener("end",H),i.removeEventListener("inputsourceschange",j);for(let ne=0;ne<S.length;ne++){const se=M[ne];se!==null&&(M[ne]=null,S[ne].disconnect(se))}D=null,U=null,e.setRenderTarget(y),m=null,p=null,f=null,i=null,v=null,X.stop(),r.isPresenting=!1,e.setPixelRatio(E),e.setSize(T.width,T.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ne){a=ne,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ne){l=ne,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(ne){u=ne},this.getBaseLayer=function(){return p!==null?p:m},this.getBinding=function(){return f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(ne){if(i=ne,i!==null){if(y=e.getRenderTarget(),i.addEventListener("select",F),i.addEventListener("selectstart",F),i.addEventListener("selectend",F),i.addEventListener("squeeze",F),i.addEventListener("squeezestart",F),i.addEventListener("squeezeend",F),i.addEventListener("end",H),i.addEventListener("inputsourceschange",j),b.xrCompatible!==!0&&await n.makeXRCompatible(),E=e.getPixelRatio(),e.getSize(T),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const se={antialias:i.renderState.layers===void 0?b.antialias:!0,alpha:!0,depth:b.depth,stencil:b.stencil,framebufferScaleFactor:a};m=new XRWebGLLayer(i,n,se),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),v=new ym(m.framebufferWidth,m.framebufferHeight,{format:Xo,type:dh,colorSpace:e.outputColorSpace,stencilBuffer:b.stencil})}else{let se=null,be=null,xe=null;b.depth&&(xe=b.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,se=b.stencil?ix:Wf,be=b.stencil?qf:Zd);const de={colorFormat:n.RGBA8,depthFormat:xe,scaleFactor:a};f=new XRWebGLBinding(i,n),p=f.createProjectionLayer(de),i.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),v=new ym(p.textureWidth,p.textureHeight,{format:Xo,type:dh,depthTexture:new see(p.textureWidth,p.textureHeight,be,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:b.stencil,colorSpace:e.outputColorSpace,samples:b.antialias?4:0});const Pe=e.properties.get(v);Pe.__ignoreDepthValues=p.ignoreDepthValues}v.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),X.setContext(i),X.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function j(ne){for(let se=0;se<ne.removed.length;se++){const be=ne.removed[se],xe=M.indexOf(be);xe>=0&&(M[xe]=null,S[xe].disconnect(be))}for(let se=0;se<ne.added.length;se++){const be=ne.added[se];let xe=M.indexOf(be);if(xe===-1){for(let Pe=0;Pe<S.length;Pe++)if(Pe>=M.length){M.push(be),xe=Pe;break}else if(M[Pe]===null){M[Pe]=be,xe=Pe;break}if(xe===-1)break}const de=S[xe];de&&de.connect(be)}}const $=new qe,K=new qe;function V(ne,se,be){$.setFromMatrixPosition(se.matrixWorld),K.setFromMatrixPosition(be.matrixWorld);const xe=$.distanceTo(K),de=se.projectionMatrix.elements,Pe=be.projectionMatrix.elements,ie=de[14]/(de[10]-1),Me=de[14]/(de[10]+1),Oe=(de[9]+1)/de[5],ge=(de[9]-1)/de[5],Ke=(de[8]-1)/de[0],G=(Pe[8]+1)/Pe[0],Y=ie*Ke,ce=ie*G,q=xe/(-Ke+G),te=q*-Ke;se.matrixWorld.decompose(ne.position,ne.quaternion,ne.scale),ne.translateX(te),ne.translateZ(q),ne.matrixWorld.compose(ne.position,ne.quaternion,ne.scale),ne.matrixWorldInverse.copy(ne.matrixWorld).invert();const I=ie+q,fe=Me+q,me=Y-te,ke=ce+(xe-te),z=Oe*Me/fe*I,O=ge*Me/fe*I;ne.projectionMatrix.makePerspective(me,ke,z,O,I,fe),ne.projectionMatrixInverse.copy(ne.projectionMatrix).invert()}function Q(ne,se){se===null?ne.matrixWorld.copy(ne.matrix):ne.matrixWorld.multiplyMatrices(se.matrixWorld,ne.matrix),ne.matrixWorldInverse.copy(ne.matrixWorld).invert()}this.updateCamera=function(ne){if(i===null)return;A.near=k.near=C.near=ne.near,A.far=k.far=C.far=ne.far,(D!==A.near||U!==A.far)&&(i.updateRenderState({depthNear:A.near,depthFar:A.far}),D=A.near,U=A.far);const se=ne.parent,be=A.cameras;Q(A,se);for(let xe=0;xe<be.length;xe++)Q(be[xe],se);be.length===2?V(A,C,k):A.projectionMatrix.copy(C.projectionMatrix),Z(ne,A,se)};function Z(ne,se,be){be===null?ne.matrix.copy(se.matrixWorld):(ne.matrix.copy(be.matrixWorld),ne.matrix.invert(),ne.matrix.multiply(se.matrixWorld)),ne.matrix.decompose(ne.position,ne.quaternion,ne.scale),ne.updateMatrixWorld(!0),ne.projectionMatrix.copy(se.projectionMatrix),ne.projectionMatrixInverse.copy(se.projectionMatrixInverse),ne.isPerspectiveCamera&&(ne.fov=yy*2*Math.atan(1/ne.projectionMatrix.elements[5]),ne.zoom=1)}this.getCamera=function(){return A},this.getFoveation=function(){if(!(p===null&&m===null))return c},this.setFoveation=function(ne){c=ne,p!==null&&(p.fixedFoveation=ne),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=ne)};let ae=null;function B(ne,se){if(d=se.getViewerPose(u||o),x=se,d!==null){const be=d.views;m!==null&&(e.setRenderTargetFramebuffer(v,m.framebuffer),e.setRenderTarget(v));let xe=!1;be.length!==A.cameras.length&&(A.cameras.length=0,xe=!0);for(let de=0;de<be.length;de++){const Pe=be[de];let ie=null;if(m!==null)ie=m.getViewport(Pe);else{const Oe=f.getViewSubImage(p,Pe);ie=Oe.viewport,de===0&&(e.setRenderTargetTextures(v,Oe.colorTexture,p.ignoreDepthValues?void 0:Oe.depthStencilTexture),e.setRenderTarget(v))}let Me=R[de];Me===void 0&&(Me=new oo,Me.layers.enable(de),Me.viewport=new Cr,R[de]=Me),Me.matrix.fromArray(Pe.transform.matrix),Me.matrix.decompose(Me.position,Me.quaternion,Me.scale),Me.projectionMatrix.fromArray(Pe.projectionMatrix),Me.projectionMatrixInverse.copy(Me.projectionMatrix).invert(),Me.viewport.set(ie.x,ie.y,ie.width,ie.height),de===0&&(A.matrix.copy(Me.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),xe===!0&&A.cameras.push(Me)}}for(let be=0;be<S.length;be++){const xe=M[be],de=S[be];xe!==null&&de!==void 0&&de.update(xe,se,u||o)}ae&&ae(ne,se),se.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:se}),x=null}const X=new aee;X.setAnimationLoop(B),this.setAnimationLoop=function(ne){ae=ne},this.dispose=function(){}}}function pBe(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,nee(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,M,T){v.isMeshBasicMaterial||v.isMeshLambertMaterial?a(y,v):v.isMeshToonMaterial?(a(y,v),f(y,v)):v.isMeshPhongMaterial?(a(y,v),d(y,v)):v.isMeshStandardMaterial?(a(y,v),p(y,v),v.isMeshPhysicalMaterial&&m(y,v,T)):v.isMeshMatcapMaterial?(a(y,v),x(y,v)):v.isMeshDepthMaterial?a(y,v):v.isMeshDistanceMaterial?(a(y,v),b(y,v)):v.isMeshNormalMaterial?a(y,v):v.isLineBasicMaterial?(o(y,v),v.isLineDashedMaterial&&l(y,v)):v.isPointsMaterial?c(y,v,S,M):v.isSpriteMaterial?u(y,v):v.isShadowMaterial?(y.color.value.copy(v.color),y.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function a(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).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 M=t._useLegacyLights===!0?Math.PI:1;y.lightMapIntensity.value=v.lightMapIntensity*M,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,M){y.diffuse.value.copy(v.color),y.opacity.value=v.opacity,y.size.value=v.size*S,y.scale.value=M*.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 p(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 m(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.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 gBe(t,e,n,r){let i={},a={},o=[];const l=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(S,M){const T=M.program;r.uniformBlockBinding(S,T)}function u(S,M){let T=i[S.id];T===void 0&&(x(S),T=d(S),i[S.id]=T,S.addEventListener("dispose",y));const E=M.program;r.updateUBOMapping(S,E);const C=e.render.frame;a[S.id]!==C&&(p(S),a[S.id]=C)}function d(S){const M=f();S.__bindingPointIndex=M;const T=t.createBuffer(),E=S.__size,C=S.usage;return t.bindBuffer(t.UNIFORM_BUFFER,T),t.bufferData(t.UNIFORM_BUFFER,E,C),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,M,T),T}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 p(S){const M=i[S.id],T=S.uniforms,E=S.__cache;t.bindBuffer(t.UNIFORM_BUFFER,M);for(let C=0,k=T.length;C<k;C++){const R=T[C];if(m(R,C,E)===!0){const A=R.__offset,D=Array.isArray(R.value)?R.value:[R.value];let U=0;for(let F=0;F<D.length;F++){const H=D[F],j=b(H);typeof H=="number"?(R.__data[0]=H,t.bufferSubData(t.UNIFORM_BUFFER,A+U,R.__data)):H.isMatrix3?(R.__data[0]=H.elements[0],R.__data[1]=H.elements[1],R.__data[2]=H.elements[2],R.__data[3]=H.elements[0],R.__data[4]=H.elements[3],R.__data[5]=H.elements[4],R.__data[6]=H.elements[5],R.__data[7]=H.elements[0],R.__data[8]=H.elements[6],R.__data[9]=H.elements[7],R.__data[10]=H.elements[8],R.__data[11]=H.elements[0]):(H.toArray(R.__data,U),U+=j.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,A,R.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(S,M,T){const E=S.value;if(T[M]===void 0){if(typeof E=="number")T[M]=E;else{const C=Array.isArray(E)?E:[E],k=[];for(let R=0;R<C.length;R++)k.push(C[R].clone());T[M]=k}return!0}else if(typeof E=="number"){if(T[M]!==E)return T[M]=E,!0}else{const C=Array.isArray(T[M])?T[M]:[T[M]],k=Array.isArray(E)?E:[E];for(let R=0;R<C.length;R++){const A=C[R];if(A.equals(k[R])===!1)return A.copy(k[R]),!0}}return!1}function x(S){const M=S.uniforms;let T=0;const E=16;let C=0;for(let k=0,R=M.length;k<R;k++){const A=M[k],D={boundary:0,storage:0},U=Array.isArray(A.value)?A.value:[A.value];for(let F=0,H=U.length;F<H;F++){const j=U[F],$=b(j);D.boundary+=$.boundary,D.storage+=$.storage}if(A.__data=new Float32Array(D.storage/Float32Array.BYTES_PER_ELEMENT),A.__offset=T,k>0){C=T%E;const F=E-C;C!==0&&F-D.boundary<0&&(T+=E-C,A.__offset=T)}T+=D.storage}return C=T%E,C>0&&(T+=E-C),S.__size=T,S.__cache={},this}function b(S){const M={boundary:0,storage:0};return typeof S=="number"?(M.boundary=4,M.storage=4):S.isVector2?(M.boundary=8,M.storage=8):S.isVector3||S.isColor?(M.boundary=16,M.storage=12):S.isVector4?(M.boundary=16,M.storage=16):S.isMatrix3?(M.boundary=48,M.storage=48):S.isMatrix4?(M.boundary=64,M.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),M}function y(S){const M=S.target;M.removeEventListener("dispose",y);const T=o.indexOf(M.__bindingPointIndex);o.splice(T,1),t.deleteBuffer(i[M.id]),delete i[M.id],delete a[M.id]}function v(){for(const S in i)t.deleteBuffer(i[S]);o=[],i={},a={}}return{bind:c,update:u,dispose:v}}class SD{constructor(e={}){const{canvas:n=fFe(),context:r=null,depth:i=!0,stencil:a=!0,alpha:o=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let p;r!==null?p=r.getContextAttributes().alpha:p=o;const m=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=Ra,this._useLegacyLights=!1,this.toneMapping=uh,this.toneMappingExposure=1;const M=this;let T=!1,E=0,C=0,k=null,R=-1,A=null;const D=new Cr,U=new Cr;let F=null;const H=new Zt(0);let j=0,$=n.width,K=n.height,V=1,Q=null,Z=null;const ae=new Cr(0,0,$,K),B=new Cr(0,0,$,K);let X=!1;const ne=new vM;let se=!1,be=!1,xe=null;const de=new zr,Pe=new xn,ie=new qe,Me={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Oe(){return k===null?V:1}let ge=r;function Ke(Ae,Ze){for(let st=0;st<Ae.length;st++){const lt=Ae[st],ot=n.getContext(lt,Ze);if(ot!==null)return ot}return null}try{const Ae={alpha:!0,depth:i,stencil:a,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${xM}`),n.addEventListener("webglcontextlost",tt,!1),n.addEventListener("webglcontextrestored",Ee,!1),n.addEventListener("webglcontextcreationerror",We,!1),ge===null){const Ze=["webgl2","webgl","experimental-webgl"];if(M.isWebGL1Renderer===!0&&Ze.shift(),ge=Ke(Ze,Ae),ge===null)throw Ke(Ze)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&ge instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),ge.getShaderPrecisionFormat===void 0&&(ge.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(Ae){throw console.error("THREE.WebGLRenderer: "+Ae.message),Ae}let G,Y,ce,q,te,I,fe,me,ke,z,O,ee,le,_e,we,re,Fe,$e,Ve,He,ye,je,Be,Se;function Xe(){G=new kUe(ge),Y=new vUe(ge,G,e),G.init(Y),je=new dBe(ge,G,Y),ce=new cBe(ge,G,Y),q=new CUe(ge),te=new Xze,I=new uBe(ge,G,ce,te,Y,je,q),fe=new _Ue(M),me=new EUe(M),ke=new FFe(ge,Y),Be=new bUe(ge,G,ke,Y),z=new TUe(ge,ke,q,Be),O=new RUe(ge,z,ke,q),Ve=new DUe(ge,Y,I),re=new wUe(te),ee=new Kze(M,fe,me,G,Y,Be,re),le=new pBe(M,te),_e=new Qze,we=new rBe(G,Y),$e=new xUe(M,fe,me,ce,O,p,c),Fe=new lBe(M,O,Y),Se=new gBe(ge,q,Y,ce),He=new yUe(ge,G,q,Y),ye=new AUe(ge,G,q,Y),q.programs=ee.programs,M.capabilities=Y,M.extensions=G,M.properties=te,M.renderLists=_e,M.shadowMap=Fe,M.state=ce,M.info=q}Xe();const Ne=new mBe(M,ge);this.xr=Ne,this.getContext=function(){return ge},this.getContextAttributes=function(){return ge.getContextAttributes()},this.forceContextLoss=function(){const Ae=G.get("WEBGL_lose_context");Ae&&Ae.loseContext()},this.forceContextRestore=function(){const Ae=G.get("WEBGL_lose_context");Ae&&Ae.restoreContext()},this.getPixelRatio=function(){return V},this.setPixelRatio=function(Ae){Ae!==void 0&&(V=Ae,this.setSize($,K,!1))},this.getSize=function(Ae){return Ae.set($,K)},this.setSize=function(Ae,Ze,st=!0){if(Ne.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}$=Ae,K=Ze,n.width=Math.floor(Ae*V),n.height=Math.floor(Ze*V),st===!0&&(n.style.width=Ae+"px",n.style.height=Ze+"px"),this.setViewport(0,0,Ae,Ze)},this.getDrawingBufferSize=function(Ae){return Ae.set($*V,K*V).floor()},this.setDrawingBufferSize=function(Ae,Ze,st){$=Ae,K=Ze,V=st,n.width=Math.floor(Ae*st),n.height=Math.floor(Ze*st),this.setViewport(0,0,Ae,Ze)},this.getCurrentViewport=function(Ae){return Ae.copy(D)},this.getViewport=function(Ae){return Ae.copy(ae)},this.setViewport=function(Ae,Ze,st,lt){Ae.isVector4?ae.set(Ae.x,Ae.y,Ae.z,Ae.w):ae.set(Ae,Ze,st,lt),ce.viewport(D.copy(ae).multiplyScalar(V).floor())},this.getScissor=function(Ae){return Ae.copy(B)},this.setScissor=function(Ae,Ze,st,lt){Ae.isVector4?B.set(Ae.x,Ae.y,Ae.z,Ae.w):B.set(Ae,Ze,st,lt),ce.scissor(U.copy(B).multiplyScalar(V).floor())},this.getScissorTest=function(){return X},this.setScissorTest=function(Ae){ce.setScissorTest(X=Ae)},this.setOpaqueSort=function(Ae){Q=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,Ze=!0,st=!0){let lt=0;if(Ae){let ot=!1;if(k!==null){const kt=k.texture.format;ot=kt===BJ||kt===zJ||kt===UJ}if(ot){const kt=k.texture.type,he=kt===dh||kt===Zd||kt===iL||kt===qf||kt===FJ||kt===IJ,pe=$e.getClearColor(),Ie=$e.getClearAlpha(),Le=pe.r,Ce=pe.g,ut=pe.b;he?(m[0]=Le,m[1]=Ce,m[2]=ut,m[3]=Ie,ge.clearBufferuiv(ge.COLOR,0,m)):(x[0]=Le,x[1]=Ce,x[2]=ut,x[3]=Ie,ge.clearBufferiv(ge.COLOR,0,x))}else lt|=ge.COLOR_BUFFER_BIT}Ze&&(lt|=ge.DEPTH_BUFFER_BIT),st&&(lt|=ge.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ge.clear(lt)},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",Ee,!1),n.removeEventListener("webglcontextcreationerror",We,!1),_e.dispose(),we.dispose(),te.dispose(),fe.dispose(),me.dispose(),O.dispose(),Be.dispose(),Se.dispose(),ee.dispose(),Ne.dispose(),Ne.removeEventListener("sessionstart",Bt),Ne.removeEventListener("sessionend",Lt),xe&&(xe.dispose(),xe=null),vn.stop()};function tt(Ae){Ae.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),T=!0}function Ee(){console.log("THREE.WebGLRenderer: Context Restored."),T=!1;const Ae=q.autoReset,Ze=Fe.enabled,st=Fe.autoUpdate,lt=Fe.needsUpdate,ot=Fe.type;Xe(),q.autoReset=Ae,Fe.enabled=Ze,Fe.autoUpdate=st,Fe.needsUpdate=lt,Fe.type=ot}function We(Ae){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",Ae.statusMessage)}function ze(Ae){const Ze=Ae.target;Ze.removeEventListener("dispose",ze),W(Ze)}function W(Ae){De(Ae),te.remove(Ae)}function De(Ae){const Ze=te.get(Ae).programs;Ze!==void 0&&(Ze.forEach(function(st){ee.releaseProgram(st)}),Ae.isShaderMaterial&&ee.releaseShaderCache(Ae))}this.renderBufferDirect=function(Ae,Ze,st,lt,ot,kt){Ze===null&&(Ze=Me);const he=ot.isMesh&&ot.matrixWorld.determinant()<0,pe=bn(Ae,Ze,st,lt,ot);ce.setMaterial(lt,he);let Ie=st.index,Le=1;if(lt.wireframe===!0){if(Ie=z.getWireframeAttribute(st),Ie===void 0)return;Le=2}const Ce=st.drawRange,ut=st.attributes.position;let St=Ce.start*Le,At=(Ce.start+Ce.count)*Le;kt!==null&&(St=Math.max(St,kt.start*Le),At=Math.min(At,(kt.start+kt.count)*Le)),Ie!==null?(St=Math.max(St,0),At=Math.min(At,Ie.count)):ut!=null&&(St=Math.max(St,0),At=Math.min(At,ut.count));const Tt=At-St;if(Tt<0||Tt===1/0)return;Be.setup(ot,lt,pe,st,Ie);let Ft,Pt=He;if(Ie!==null&&(Ft=ke.get(Ie),Pt=ye,Pt.setIndex(Ft)),ot.isMesh)lt.wireframe===!0?(ce.setLineWidth(lt.wireframeLinewidth*Oe()),Pt.setMode(ge.LINES)):Pt.setMode(ge.TRIANGLES);else if(ot.isLine){let Mt=lt.linewidth;Mt===void 0&&(Mt=1),ce.setLineWidth(Mt*Oe()),ot.isLineSegments?Pt.setMode(ge.LINES):ot.isLineLoop?Pt.setMode(ge.LINE_LOOP):Pt.setMode(ge.LINE_STRIP)}else ot.isPoints?Pt.setMode(ge.POINTS):ot.isSprite&&Pt.setMode(ge.TRIANGLES);if(ot.isBatchedMesh)Pt.renderMultiDraw(ot._multiDrawStarts,ot._multiDrawCounts,ot._multiDrawCount);else if(ot.isInstancedMesh)Pt.renderInstances(St,Tt,ot.count);else if(st.isInstancedBufferGeometry){const Mt=st._maxInstanceCount!==void 0?st._maxInstanceCount:1/0,en=Math.min(st.instanceCount,Mt);Pt.renderInstances(St,Tt,en)}else Pt.render(St,Tt)};function Ye(Ae,Ze,st){Ae.transparent===!0&&Ae.side===pu&&Ae.forceSinglePass===!1?(Ae.side=zs,Ae.needsUpdate=!0,fr(Ae,Ze,st),Ae.side=Th,Ae.needsUpdate=!0,fr(Ae,Ze,st),Ae.side=pu):fr(Ae,Ze,st)}this.compile=function(Ae,Ze,st=null){st===null&&(st=Ae),y=we.get(st),y.init(),S.push(y),st.traverseVisible(function(ot){ot.isLight&&ot.layers.test(Ze.layers)&&(y.pushLight(ot),ot.castShadow&&y.pushShadow(ot))}),Ae!==st&&Ae.traverseVisible(function(ot){ot.isLight&&ot.layers.test(Ze.layers)&&(y.pushLight(ot),ot.castShadow&&y.pushShadow(ot))}),y.setupLights(M._useLegacyLights);const lt=new Set;return Ae.traverse(function(ot){const kt=ot.material;if(kt)if(Array.isArray(kt))for(let he=0;he<kt.length;he++){const pe=kt[he];Ye(pe,st,ot),lt.add(pe)}else Ye(kt,st,ot),lt.add(kt)}),S.pop(),y=null,lt},this.compileAsync=function(Ae,Ze,st=null){const lt=this.compile(Ae,Ze,st);return new Promise(ot=>{function kt(){if(lt.forEach(function(he){te.get(he).currentProgram.isReady()&&lt.delete(he)}),lt.size===0){ot(Ae);return}setTimeout(kt,10)}G.get("KHR_parallel_shader_compile")!==null?kt():setTimeout(kt,10)})};let xt=null;function ft(Ae){xt&&xt(Ae)}function Bt(){vn.stop()}function Lt(){vn.start()}const vn=new aee;vn.setAnimationLoop(ft),typeof self<"u"&&vn.setContext(self),this.setAnimationLoop=function(Ae){xt=Ae,Ne.setAnimationLoop(Ae),Ae===null?vn.stop():vn.start()},Ne.addEventListener("sessionstart",Bt),Ne.addEventListener("sessionend",Lt),this.render=function(Ae,Ze){if(Ze!==void 0&&Ze.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(T===!0)return;Ae.matrixWorldAutoUpdate===!0&&Ae.updateMatrixWorld(),Ze.parent===null&&Ze.matrixWorldAutoUpdate===!0&&Ze.updateMatrixWorld(),Ne.enabled===!0&&Ne.isPresenting===!0&&(Ne.cameraAutoUpdate===!0&&Ne.updateCamera(Ze),Ze=Ne.getCamera()),Ae.isScene===!0&&Ae.onBeforeRender(M,Ae,Ze,k),y=we.get(Ae,S.length),y.init(),S.push(y),de.multiplyMatrices(Ze.projectionMatrix,Ze.matrixWorldInverse),ne.setFromProjectionMatrix(de),be=this.localClippingEnabled,se=re.init(this.clippingPlanes,be),b=_e.get(Ae,v.length),b.init(),v.push(b),Jt(Ae,Ze,0,M.sortObjects),b.finish(),M.sortObjects===!0&&b.sort(Q,Z),this.info.render.frame++,se===!0&&re.beginShadows();const st=y.state.shadowsArray;if(Fe.render(st,Ae,Ze),se===!0&&re.endShadows(),this.info.autoReset===!0&&this.info.reset(),$e.render(b,Ae),y.setupLights(M._useLegacyLights),Ze.isArrayCamera){const lt=Ze.cameras;for(let ot=0,kt=lt.length;ot<kt;ot++){const he=lt[ot];rr(b,Ae,he,he.viewport)}}else rr(b,Ae,Ze);k!==null&&(I.updateMultisampleRenderTarget(k),I.updateRenderTargetMipmap(k)),Ae.isScene===!0&&Ae.onAfterRender(M,Ae,Ze),Be.resetDefaultState(),R=-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 Jt(Ae,Ze,st,lt){if(Ae.visible===!1)return;if(Ae.layers.test(Ze.layers)){if(Ae.isGroup)st=Ae.renderOrder;else if(Ae.isLOD)Ae.autoUpdate===!0&&Ae.update(Ze);else if(Ae.isLight)y.pushLight(Ae),Ae.castShadow&&y.pushShadow(Ae);else if(Ae.isSprite){if(!Ae.frustumCulled||ne.intersectsSprite(Ae)){lt&&ie.setFromMatrixPosition(Ae.matrixWorld).applyMatrix4(de);const he=O.update(Ae),pe=Ae.material;pe.visible&&b.push(Ae,he,pe,st,ie.z,null)}}else if((Ae.isMesh||Ae.isLine||Ae.isPoints)&&(!Ae.frustumCulled||ne.intersectsObject(Ae))){const he=O.update(Ae),pe=Ae.material;if(lt&&(Ae.boundingSphere!==void 0?(Ae.boundingSphere===null&&Ae.computeBoundingSphere(),ie.copy(Ae.boundingSphere.center)):(he.boundingSphere===null&&he.computeBoundingSphere(),ie.copy(he.boundingSphere.center)),ie.applyMatrix4(Ae.matrixWorld).applyMatrix4(de)),Array.isArray(pe)){const Ie=he.groups;for(let Le=0,Ce=Ie.length;Le<Ce;Le++){const ut=Ie[Le],St=pe[ut.materialIndex];St&&St.visible&&b.push(Ae,he,St,st,ie.z,ut)}}else pe.visible&&b.push(Ae,he,pe,st,ie.z,null)}}const kt=Ae.children;for(let he=0,pe=kt.length;he<pe;he++)Jt(kt[he],Ze,st,lt)}function rr(Ae,Ze,st,lt){const ot=Ae.opaque,kt=Ae.transmissive,he=Ae.transparent;y.setupLightsView(st),se===!0&&re.setGlobalState(M.clippingPlanes,st),kt.length>0&&hr(ot,kt,Ze,st),lt&&ce.viewport(D.copy(lt)),ot.length>0&&Dn(ot,Ze,st),kt.length>0&&Dn(kt,Ze,st),he.length>0&&Dn(he,Ze,st),ce.buffers.depth.setTest(!0),ce.buffers.depth.setMask(!0),ce.buffers.color.setMask(!0),ce.setPolygonOffset(!1)}function hr(Ae,Ze,st,lt){if((st.isScene===!0?st.overrideMaterial:null)!==null)return;const kt=Y.isWebGL2;xe===null&&(xe=new ym(1,1,{generateMipmaps:!0,type:G.has("EXT_color_buffer_half_float")?xy:dh,minFilter:gy,samples:kt?4:0})),M.getDrawingBufferSize(Pe),kt?xe.setSize(Pe.x,Pe.y):xe.setSize(nN(Pe.x),nN(Pe.y));const he=M.getRenderTarget();M.setRenderTarget(xe),M.getClearColor(H),j=M.getClearAlpha(),j<1&&M.setClearColor(16777215,.5),M.clear();const pe=M.toneMapping;M.toneMapping=uh,Dn(Ae,st,lt),I.updateMultisampleRenderTarget(xe),I.updateRenderTargetMipmap(xe);let Ie=!1;for(let Le=0,Ce=Ze.length;Le<Ce;Le++){const ut=Ze[Le],St=ut.object,At=ut.geometry,Tt=ut.material,Ft=ut.group;if(Tt.side===pu&&St.layers.test(lt.layers)){const Pt=Tt.side;Tt.side=zs,Tt.needsUpdate=!0,ln(St,st,lt,At,Tt,Ft),Tt.side=Pt,Tt.needsUpdate=!0,Ie=!0}}Ie===!0&&(I.updateMultisampleRenderTarget(xe),I.updateRenderTargetMipmap(xe)),M.setRenderTarget(he),M.setClearColor(H,j),M.toneMapping=pe}function Dn(Ae,Ze,st){const lt=Ze.isScene===!0?Ze.overrideMaterial:null;for(let ot=0,kt=Ae.length;ot<kt;ot++){const he=Ae[ot],pe=he.object,Ie=he.geometry,Le=lt===null?he.material:lt,Ce=he.group;pe.layers.test(st.layers)&&ln(pe,Ze,st,Ie,Le,Ce)}}function ln(Ae,Ze,st,lt,ot,kt){Ae.onBeforeRender(M,Ze,st,lt,ot,kt),Ae.modelViewMatrix.multiplyMatrices(st.matrixWorldInverse,Ae.matrixWorld),Ae.normalMatrix.getNormalMatrix(Ae.modelViewMatrix),ot.onBeforeRender(M,Ze,st,lt,Ae,kt),ot.transparent===!0&&ot.side===pu&&ot.forceSinglePass===!1?(ot.side=zs,ot.needsUpdate=!0,M.renderBufferDirect(st,Ze,lt,ot,Ae,kt),ot.side=Th,ot.needsUpdate=!0,M.renderBufferDirect(st,Ze,lt,ot,Ae,kt),ot.side=pu):M.renderBufferDirect(st,Ze,lt,ot,Ae,kt),Ae.onAfterRender(M,Ze,st,lt,ot,kt)}function fr(Ae,Ze,st){Ze.isScene!==!0&&(Ze=Me);const lt=te.get(Ae),ot=y.state.lights,kt=y.state.shadowsArray,he=ot.state.version,pe=ee.getParameters(Ae,ot.state,kt,Ze,st),Ie=ee.getProgramCacheKey(pe);let Le=lt.programs;lt.environment=Ae.isMeshStandardMaterial?Ze.environment:null,lt.fog=Ze.fog,lt.envMap=(Ae.isMeshStandardMaterial?me:fe).get(Ae.envMap||lt.environment),Le===void 0&&(Ae.addEventListener("dispose",ze),Le=new Map,lt.programs=Le);let Ce=Le.get(Ie);if(Ce!==void 0){if(lt.currentProgram===Ce&&lt.lightsStateVersion===he)return Kn(Ae,pe),Ce}else pe.uniforms=ee.getUniforms(Ae),Ae.onBuild(st,pe,M),Ae.onBeforeCompile(pe,M),Ce=ee.acquireProgram(pe,Ie),Le.set(Ie,Ce),lt.uniforms=pe.uniforms;const ut=lt.uniforms;return(!Ae.isShaderMaterial&&!Ae.isRawShaderMaterial||Ae.clipping===!0)&&(ut.clippingPlanes=re.uniform),Kn(Ae,pe),lt.needsLights=Ba(Ae),lt.lightsStateVersion=he,lt.needsLights&&(ut.ambientLightColor.value=ot.state.ambient,ut.lightProbe.value=ot.state.probe,ut.directionalLights.value=ot.state.directional,ut.directionalLightShadows.value=ot.state.directionalShadow,ut.spotLights.value=ot.state.spot,ut.spotLightShadows.value=ot.state.spotShadow,ut.rectAreaLights.value=ot.state.rectArea,ut.ltc_1.value=ot.state.rectAreaLTC1,ut.ltc_2.value=ot.state.rectAreaLTC2,ut.pointLights.value=ot.state.point,ut.pointLightShadows.value=ot.state.pointShadow,ut.hemisphereLights.value=ot.state.hemi,ut.directionalShadowMap.value=ot.state.directionalShadowMap,ut.directionalShadowMatrix.value=ot.state.directionalShadowMatrix,ut.spotShadowMap.value=ot.state.spotShadowMap,ut.spotLightMatrix.value=ot.state.spotLightMatrix,ut.spotLightMap.value=ot.state.spotLightMap,ut.pointShadowMap.value=ot.state.pointShadowMap,ut.pointShadowMatrix.value=ot.state.pointShadowMatrix),lt.currentProgram=Ce,lt.uniformsList=null,Ce}function Fn(Ae){if(Ae.uniformsList===null){const Ze=Ae.currentProgram.getUniforms();Ae.uniformsList=P1.seqWithValue(Ze.seq,Ae.uniforms)}return Ae.uniformsList}function Kn(Ae,Ze){const st=te.get(Ae);st.outputColorSpace=Ze.outputColorSpace,st.batching=Ze.batching,st.instancing=Ze.instancing,st.instancingColor=Ze.instancingColor,st.skinning=Ze.skinning,st.morphTargets=Ze.morphTargets,st.morphNormals=Ze.morphNormals,st.morphColors=Ze.morphColors,st.morphTargetsCount=Ze.morphTargetsCount,st.numClippingPlanes=Ze.numClippingPlanes,st.numIntersection=Ze.numClipIntersection,st.vertexAlphas=Ze.vertexAlphas,st.vertexTangents=Ze.vertexTangents,st.toneMapping=Ze.toneMapping}function bn(Ae,Ze,st,lt,ot){Ze.isScene!==!0&&(Ze=Me),I.resetTextureUnits();const kt=Ze.fog,he=lt.isMeshStandardMaterial?Ze.environment:null,pe=k===null?M.outputColorSpace:k.isXRRenderTarget===!0?k.texture.colorSpace:Vu,Ie=(lt.isMeshStandardMaterial?me:fe).get(lt.envMap||he),Le=lt.vertexColors===!0&&!!st.attributes.color&&st.attributes.color.itemSize===4,Ce=!!st.attributes.tangent&&(!!lt.normalMap||lt.anisotropy>0),ut=!!st.morphAttributes.position,St=!!st.morphAttributes.normal,At=!!st.morphAttributes.color;let Tt=uh;lt.toneMapped&&(k===null||k.isXRRenderTarget===!0)&&(Tt=M.toneMapping);const Ft=st.morphAttributes.position||st.morphAttributes.normal||st.morphAttributes.color,Pt=Ft!==void 0?Ft.length:0,Mt=te.get(lt),en=y.state.lights;if(se===!0&&(be===!0||Ae!==A)){const tr=Ae===A&&lt.id===R;re.setState(lt,Ae,tr)}let $t=!1;lt.version===Mt.__version?(Mt.needsLights&&Mt.lightsStateVersion!==en.state.version||Mt.outputColorSpace!==pe||ot.isBatchedMesh&&Mt.batching===!1||!ot.isBatchedMesh&&Mt.batching===!0||ot.isInstancedMesh&&Mt.instancing===!1||!ot.isInstancedMesh&&Mt.instancing===!0||ot.isSkinnedMesh&&Mt.skinning===!1||!ot.isSkinnedMesh&&Mt.skinning===!0||ot.isInstancedMesh&&Mt.instancingColor===!0&&ot.instanceColor===null||ot.isInstancedMesh&&Mt.instancingColor===!1&&ot.instanceColor!==null||Mt.envMap!==Ie||lt.fog===!0&&Mt.fog!==kt||Mt.numClippingPlanes!==void 0&&(Mt.numClippingPlanes!==re.numPlanes||Mt.numIntersection!==re.numIntersection)||Mt.vertexAlphas!==Le||Mt.vertexTangents!==Ce||Mt.morphTargets!==ut||Mt.morphNormals!==St||Mt.morphColors!==At||Mt.toneMapping!==Tt||Y.isWebGL2===!0&&Mt.morphTargetsCount!==Pt)&&($t=!0):($t=!0,Mt.__version=lt.version);let dn=Mt.currentProgram;$t===!0&&(dn=fr(lt,Ze,ot));let cn=!1,Sn=!1,Gt=!1;const sn=dn.getUniforms(),un=Mt.uniforms;if(ce.useProgram(dn.program)&&(cn=!0,Sn=!0,Gt=!0),lt.id!==R&&(R=lt.id,Sn=!0),cn||A!==Ae){sn.setValue(ge,"projectionMatrix",Ae.projectionMatrix),sn.setValue(ge,"viewMatrix",Ae.matrixWorldInverse);const tr=sn.map.cameraPosition;tr!==void 0&&tr.setValue(ge,ie.setFromMatrixPosition(Ae.matrixWorld)),Y.logarithmicDepthBuffer&&sn.setValue(ge,"logDepthBufFC",2/(Math.log(Ae.far+1)/Math.LN2)),(lt.isMeshPhongMaterial||lt.isMeshToonMaterial||lt.isMeshLambertMaterial||lt.isMeshBasicMaterial||lt.isMeshStandardMaterial||lt.isShaderMaterial)&&sn.setValue(ge,"isOrthographic",Ae.isOrthographicCamera===!0),A!==Ae&&(A=Ae,Sn=!0,Gt=!0)}if(ot.isSkinnedMesh){sn.setOptional(ge,ot,"bindMatrix"),sn.setOptional(ge,ot,"bindMatrixInverse");const tr=ot.skeleton;tr&&(Y.floatVertexTextures?(tr.boneTexture===null&&tr.computeBoneTexture(),sn.setValue(ge,"boneTexture",tr.boneTexture,I)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}ot.isBatchedMesh&&(sn.setOptional(ge,ot,"batchingTexture"),sn.setValue(ge,"batchingTexture",ot._matricesTexture,I));const Yt=st.morphAttributes;if((Yt.position!==void 0||Yt.normal!==void 0||Yt.color!==void 0&&Y.isWebGL2===!0)&&Ve.update(ot,st,dn),(Sn||Mt.receiveShadow!==ot.receiveShadow)&&(Mt.receiveShadow=ot.receiveShadow,sn.setValue(ge,"receiveShadow",ot.receiveShadow)),lt.isMeshGouraudMaterial&&lt.envMap!==null&&(un.envMap.value=Ie,un.flipEnvMap.value=Ie.isCubeTexture&&Ie.isRenderTargetTexture===!1?-1:1),Sn&&(sn.setValue(ge,"toneMappingExposure",M.toneMappingExposure),Mt.needsLights&&wi(un,Gt),kt&&lt.fog===!0&&le.refreshFogUniforms(un,kt),le.refreshMaterialUniforms(un,lt,V,K,xe),P1.upload(ge,Fn(Mt),un,I)),lt.isShaderMaterial&&lt.uniformsNeedUpdate===!0&&(P1.upload(ge,Fn(Mt),un,I),lt.uniformsNeedUpdate=!1),lt.isSpriteMaterial&&sn.setValue(ge,"center",ot.center),sn.setValue(ge,"modelViewMatrix",ot.modelViewMatrix),sn.setValue(ge,"normalMatrix",ot.normalMatrix),sn.setValue(ge,"modelMatrix",ot.matrixWorld),lt.isShaderMaterial||lt.isRawShaderMaterial){const tr=lt.uniformsGroups;for(let jn=0,ii=tr.length;jn<ii;jn++)if(Y.isWebGL2){const nr=tr[jn];Se.update(nr,dn),Se.bind(nr,dn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return dn}function wi(Ae,Ze){Ae.ambientLightColor.needsUpdate=Ze,Ae.lightProbe.needsUpdate=Ze,Ae.directionalLights.needsUpdate=Ze,Ae.directionalLightShadows.needsUpdate=Ze,Ae.pointLights.needsUpdate=Ze,Ae.pointLightShadows.needsUpdate=Ze,Ae.spotLights.needsUpdate=Ze,Ae.spotLightShadows.needsUpdate=Ze,Ae.rectAreaLights.needsUpdate=Ze,Ae.hemisphereLights.needsUpdate=Ze}function Ba(Ae){return Ae.isMeshLambertMaterial||Ae.isMeshToonMaterial||Ae.isMeshPhongMaterial||Ae.isMeshStandardMaterial||Ae.isShadowMaterial||Ae.isShaderMaterial&&Ae.lights===!0}this.getActiveCubeFace=function(){return E},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return k},this.setRenderTargetTextures=function(Ae,Ze,st){te.get(Ae.texture).__webglTexture=Ze,te.get(Ae.depthTexture).__webglTexture=st;const lt=te.get(Ae);lt.__hasExternalTextures=!0,lt.__hasExternalTextures&&(lt.__autoAllocateDepthBuffer=st===void 0,lt.__autoAllocateDepthBuffer||G.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),lt.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(Ae,Ze){const st=te.get(Ae);st.__webglFramebuffer=Ze,st.__useDefaultFramebuffer=Ze===void 0},this.setRenderTarget=function(Ae,Ze=0,st=0){k=Ae,E=Ze,C=st;let lt=!0,ot=null,kt=!1,he=!1;if(Ae){const Ie=te.get(Ae);Ie.__useDefaultFramebuffer!==void 0?(ce.bindFramebuffer(ge.FRAMEBUFFER,null),lt=!1):Ie.__webglFramebuffer===void 0?I.setupRenderTarget(Ae):Ie.__hasExternalTextures&&I.rebindTextures(Ae,te.get(Ae.texture).__webglTexture,te.get(Ae.depthTexture).__webglTexture);const Le=Ae.texture;(Le.isData3DTexture||Le.isDataArrayTexture||Le.isCompressedArrayTexture)&&(he=!0);const Ce=te.get(Ae).__webglFramebuffer;Ae.isWebGLCubeRenderTarget?(Array.isArray(Ce[Ze])?ot=Ce[Ze][st]:ot=Ce[Ze],kt=!0):Y.isWebGL2&&Ae.samples>0&&I.useMultisampledRTT(Ae)===!1?ot=te.get(Ae).__webglMultisampledFramebuffer:Array.isArray(Ce)?ot=Ce[st]:ot=Ce,D.copy(Ae.viewport),U.copy(Ae.scissor),F=Ae.scissorTest}else D.copy(ae).multiplyScalar(V).floor(),U.copy(B).multiplyScalar(V).floor(),F=X;if(ce.bindFramebuffer(ge.FRAMEBUFFER,ot)&&Y.drawBuffers&&lt&&ce.drawBuffers(Ae,ot),ce.viewport(D),ce.scissor(U),ce.setScissorTest(F),kt){const Ie=te.get(Ae.texture);ge.framebufferTexture2D(ge.FRAMEBUFFER,ge.COLOR_ATTACHMENT0,ge.TEXTURE_CUBE_MAP_POSITIVE_X+Ze,Ie.__webglTexture,st)}else if(he){const Ie=te.get(Ae.texture),Le=Ze||0;ge.framebufferTextureLayer(ge.FRAMEBUFFER,ge.COLOR_ATTACHMENT0,Ie.__webglTexture,st||0,Le)}R=-1},this.readRenderTargetPixels=function(Ae,Ze,st,lt,ot,kt,he){if(!(Ae&&Ae.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let pe=te.get(Ae).__webglFramebuffer;if(Ae.isWebGLCubeRenderTarget&&he!==void 0&&(pe=pe[he]),pe){ce.bindFramebuffer(ge.FRAMEBUFFER,pe);try{const Ie=Ae.texture,Le=Ie.format,Ce=Ie.type;if(Le!==Xo&&je.convert(Le)!==ge.getParameter(ge.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const ut=Ce===xy&&(G.has("EXT_color_buffer_half_float")||Y.isWebGL2&&G.has("EXT_color_buffer_float"));if(Ce!==dh&&je.convert(Ce)!==ge.getParameter(ge.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Ce===_u&&(Y.isWebGL2||G.has("OES_texture_float")||G.has("WEBGL_color_buffer_float")))&&!ut){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ze>=0&&Ze<=Ae.width-lt&&st>=0&&st<=Ae.height-ot&&ge.readPixels(Ze,st,lt,ot,je.convert(Le),je.convert(Ce),kt)}finally{const Ie=k!==null?te.get(k).__webglFramebuffer:null;ce.bindFramebuffer(ge.FRAMEBUFFER,Ie)}}},this.copyFramebufferToTexture=function(Ae,Ze,st=0){const lt=Math.pow(2,-st),ot=Math.floor(Ze.image.width*lt),kt=Math.floor(Ze.image.height*lt);I.setTexture2D(Ze,0),ge.copyTexSubImage2D(ge.TEXTURE_2D,st,0,0,Ae.x,Ae.y,ot,kt),ce.unbindTexture()},this.copyTextureToTexture=function(Ae,Ze,st,lt=0){const ot=Ze.image.width,kt=Ze.image.height,he=je.convert(st.format),pe=je.convert(st.type);I.setTexture2D(st,0),ge.pixelStorei(ge.UNPACK_FLIP_Y_WEBGL,st.flipY),ge.pixelStorei(ge.UNPACK_PREMULTIPLY_ALPHA_WEBGL,st.premultiplyAlpha),ge.pixelStorei(ge.UNPACK_ALIGNMENT,st.unpackAlignment),Ze.isDataTexture?ge.texSubImage2D(ge.TEXTURE_2D,lt,Ae.x,Ae.y,ot,kt,he,pe,Ze.image.data):Ze.isCompressedTexture?ge.compressedTexSubImage2D(ge.TEXTURE_2D,lt,Ae.x,Ae.y,Ze.mipmaps[0].width,Ze.mipmaps[0].height,he,Ze.mipmaps[0].data):ge.texSubImage2D(ge.TEXTURE_2D,lt,Ae.x,Ae.y,he,pe,Ze.image),lt===0&&st.generateMipmaps&&ge.generateMipmap(ge.TEXTURE_2D),ce.unbindTexture()},this.copyTextureToTexture3D=function(Ae,Ze,st,lt,ot=0){if(M.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const kt=Ae.max.x-Ae.min.x+1,he=Ae.max.y-Ae.min.y+1,pe=Ae.max.z-Ae.min.z+1,Ie=je.convert(lt.format),Le=je.convert(lt.type);let Ce;if(lt.isData3DTexture)I.setTexture3D(lt,0),Ce=ge.TEXTURE_3D;else if(lt.isDataArrayTexture)I.setTexture2DArray(lt,0),Ce=ge.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}ge.pixelStorei(ge.UNPACK_FLIP_Y_WEBGL,lt.flipY),ge.pixelStorei(ge.UNPACK_PREMULTIPLY_ALPHA_WEBGL,lt.premultiplyAlpha),ge.pixelStorei(ge.UNPACK_ALIGNMENT,lt.unpackAlignment);const ut=ge.getParameter(ge.UNPACK_ROW_LENGTH),St=ge.getParameter(ge.UNPACK_IMAGE_HEIGHT),At=ge.getParameter(ge.UNPACK_SKIP_PIXELS),Tt=ge.getParameter(ge.UNPACK_SKIP_ROWS),Ft=ge.getParameter(ge.UNPACK_SKIP_IMAGES),Pt=st.isCompressedTexture?st.mipmaps[0]:st.image;ge.pixelStorei(ge.UNPACK_ROW_LENGTH,Pt.width),ge.pixelStorei(ge.UNPACK_IMAGE_HEIGHT,Pt.height),ge.pixelStorei(ge.UNPACK_SKIP_PIXELS,Ae.min.x),ge.pixelStorei(ge.UNPACK_SKIP_ROWS,Ae.min.y),ge.pixelStorei(ge.UNPACK_SKIP_IMAGES,Ae.min.z),st.isDataTexture||st.isData3DTexture?ge.texSubImage3D(Ce,ot,Ze.x,Ze.y,Ze.z,kt,he,pe,Ie,Le,Pt.data):st.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ge.compressedTexSubImage3D(Ce,ot,Ze.x,Ze.y,Ze.z,kt,he,pe,Ie,Pt.data)):ge.texSubImage3D(Ce,ot,Ze.x,Ze.y,Ze.z,kt,he,pe,Ie,Le,Pt),ge.pixelStorei(ge.UNPACK_ROW_LENGTH,ut),ge.pixelStorei(ge.UNPACK_IMAGE_HEIGHT,St),ge.pixelStorei(ge.UNPACK_SKIP_PIXELS,At),ge.pixelStorei(ge.UNPACK_SKIP_ROWS,Tt),ge.pixelStorei(ge.UNPACK_SKIP_IMAGES,Ft),ot===0&&lt.generateMipmaps&&ge.generateMipmap(Ce),ce.unbindTexture()},this.initTexture=function(Ae){Ae.isCubeTexture?I.setTextureCube(Ae,0):Ae.isData3DTexture?I.setTexture3D(Ae,0):Ae.isDataArrayTexture||Ae.isCompressedArrayTexture?I.setTexture2DArray(Ae,0):I.setTexture2D(Ae,0),ce.unbindTexture()},this.resetState=function(){E=0,C=0,k=null,ce.reset(),Be.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===aL?"display-p3":"srgb",n.unpackColorSpace=kr.workingColorSpace===yM?"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===Ra?Kf:HJ}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Kf?Ra:Vu}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 xBe extends SD{}xBe.prototype.isWebGL1Renderer=!0;class dL{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new Zt(e),this.near=n,this.far=r}clone(){return new dL(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class bBe extends ps{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 yBe{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=yD,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,a=this.stride;i<a;i++)this.array[e+i]=n.array[r+i];return this}set(e,n=0){return this.array.set(e,n),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=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 ls=new qe;class Jd{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++)ls.fromBufferAttribute(this,n),ls.applyMatrix4(e),this.setXYZ(n,ls.x,ls.y,ls.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)ls.fromBufferAttribute(this,n),ls.applyNormalMatrix(e),this.setXYZ(n,ls.x,ls.y,ls.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)ls.fromBufferAttribute(this,n),ls.transformDirection(e),this.setXYZ(n,ls.x,ls.y,ls.z);return this}setX(e,n){return this.normalized&&(n=Er(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=Er(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=Er(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=Er(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=Er(n,this.array),r=Er(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=Er(n,this.array),r=Er(r,this.array),i=Er(i,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e=e*this.data.stride+this.offset,this.normalized&&(n=Er(n,this.array),r=Er(r,this.array),i=Er(i,this.array),a=Er(a,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this.data.array[e+3]=a,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)n.push(this.data.array[i+a])}return new 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 Jd(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)n.push(this.data.array[i+a])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:n,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class vBe extends Bs{constructor(e=null,n=1,r=1,i,a,o,l,c,u=Da,d=Da,f,p){super(null,o,l,c,u,d,i,a,f,p),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function wBe(t,e){return t.z-e.z}function _Be(t,e){return e.z-t.z}class SBe{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,n){const r=this.pool,i=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1});const a=r[this.index];i.push(a),this.index++,a.start=e.start,a.count=e.count,a.z=n}reset(){this.list.length=0,this.index=0}}const Zp="batchId",Rd=new zr,t7=new zr,NBe=new zr,n7=new zr,JC=new vM,V_=new rl,xf=new hc,Qb=new qe,ej=new SBe,Wa=new Dl,G_=[];function MBe(t,e,n=0){const r=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const i=t.count;for(let a=0;a<i;a++)for(let o=0;o<r;o++)e.setComponent(a+n,o,t.getComponent(a,o))}else e.array.set(t.array,n*r);e.needsUpdate=!0}class EBe extends Dl{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new ns,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 vBe(n,e,e,Xo,_u);this._matricesTexture=r}_initializeGeometry(e){const n=this.geometry,r=this._maxVertexCount,i=this._maxGeometryCount,a=this._maxIndexCount;if(this._geometryInitialized===!1){for(const l in e.attributes){const c=e.getAttribute(l),{array:u,itemSize:d,normalized:f}=c,p=new u.constructor(r*d),m=new c.constructor(p,d,f);m.setUsage(c.usage),n.setAttribute(l,m)}if(e.getIndex()!==null){const l=r>65536?new Uint32Array(a):new Uint16Array(a);n.setIndex(new go(l,1))}const o=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(Zp,new go(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Zp))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Zp}"`);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===Zp)continue;if(!e.hasAttribute(r))throw new Error(`BatchedMesh: Added geometry missing "${r}". All geometries must have consistent attributes.`);const i=e.getAttribute(r),a=n.getAttribute(r);if(i.itemSize!==a.itemSize||i.normalized!==a.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new rl);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,Rd),this.getBoundingBoxAt(i,V_).applyMatrix4(Rd),n.union(V_))}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,Rd),this.getBoundingSphereAt(i,xf).applyMatrix4(Rd),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 a=null;const o=this._reservedRanges,l=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(a=o[o.length-1]),n===-1?i.vertexCount=e.getAttribute("position").count:i.vertexCount=n,a===null?i.vertexStart=0:i.vertexStart=a.vertexStart+a.vertexCount;const u=e.getIndex(),d=u!==null;if(d&&(r===-1?i.indexCount=u.count:i.indexCount=r,a===null?i.indexStart=0:i.indexStart=a.indexStart+a.indexCount),i.indexStart!==-1&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const f=this._visibility,p=this._active,m=this._matricesTexture,x=this._matricesTexture.image.data;f.push(!0),p.push(!0);const b=this._geometryCount;this._geometryCount++,NBe.toArray(x,b*16),m.needsUpdate=!0,o.push(i),l.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new rl,sphereInitialized:!1,sphere:new hc});const y=this.geometry.getAttribute(Zp);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,a=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 m in r.attributes){if(m===Zp)continue;const x=n.getAttribute(m),b=r.getAttribute(m);MBe(x,b,c);const y=x.itemSize;for(let v=x.count,S=u;v<S;v++){const M=c+v;for(let T=0;T<y;T++)b.setComponent(M,T,0)}b.needsUpdate=!0}if(i){const m=l.indexStart;for(let x=0;x<o.count;x++)a.setX(m+x,c+o.getX(x));for(let x=o.count,b=l.indexCount;x<b;x++)a.setX(m+x,c);a.needsUpdate=!0}const d=this._bounds[e];n.boundingBox!==null?(d.box.copy(n.boundingBox),d.boxInitialized=!0):d.boxInitialized=!1,n.boundingSphere!==null?(d.sphere.copy(n.boundingSphere),d.sphereInitialized=!0):d.sphereInitialized=!1;const f=this._drawRanges[e],p=n.getAttribute("position");return f.count=i?o.count:p.count,this._visibilityChanged=!0,e}deleteGeometry(e){const n=this._active;return e>=n.length||n[e]===!1?this:(n[e]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],a=i.box,o=this.geometry;if(i.boxInitialized===!1){a.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 p=d;l&&(p=l.getX(p)),a.expandByPoint(Qb.fromBufferAttribute(c,p))}i.boxInitialized=!0}return n.copy(a),n}getBoundingSphereAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],a=i.sphere,o=this.geometry;if(i.sphereInitialized===!1){a.makeEmpty(),this.getBoundingBoxAt(e,V_),V_.getCenter(a.center);const l=o.index,c=o.attributes.position,u=this._drawRanges[e];let d=0;for(let f=u.start,p=u.start+u.count;f<p;f++){let m=f;l&&(m=l.getX(m)),Qb.fromBufferAttribute(c,m),d=Math.max(d,a.center.distanceToSquared(Qb))}a.radius=Math.sqrt(d),i.sphereInitialized=!0}return n.copy(a),n}setMatrixAt(e,n){const r=this._active,i=this._matricesTexture,a=this._matricesTexture.image.data,o=this._geometryCount;return e>=o||r[e]===!1?this:(n.toArray(a,e*16),i.needsUpdate=!0,this)}getMatrixAt(e,n){const r=this._active,i=this._matricesTexture.image.data,a=this._geometryCount;return e>=a||r[e]===!1?null:n.fromArray(i,e*16)}setVisibleAt(e,n){const r=this._visibility,i=this._active,a=this._geometryCount;return e>=a||i[e]===!1||r[e]===n?this:(r[e]=n,this._visibilityChanged=!0,this)}getVisibleAt(e){const n=this._visibility,r=this._active,i=this._geometryCount;return e>=i||r[e]===!1?!1:n[e]}raycast(e,n){const r=this._visibility,i=this._active,a=this._drawRanges,o=this._geometryCount,l=this.matrixWorld,c=this.geometry;Wa.material=this.material,Wa.geometry.index=c.index,Wa.geometry.attributes=c.attributes,Wa.geometry.boundingBox===null&&(Wa.geometry.boundingBox=new rl),Wa.geometry.boundingSphere===null&&(Wa.geometry.boundingSphere=new hc);for(let u=0;u<o;u++){if(!r[u]||!i[u])continue;const d=a[u];Wa.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,Wa.matrixWorld).premultiply(l),this.getBoundingBoxAt(u,Wa.geometry.boundingBox),this.getBoundingSphereAt(u,Wa.geometry.boundingSphere),Wa.raycast(e,G_);for(let f=0,p=G_.length;f<p;f++){const m=G_[f];m.object=this,m.batchId=u,n.push(m)}G_.length=0}Wa.material=null,Wa.geometry.index=null,Wa.geometry.attributes={},Wa.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(n=>({...n})),this._reservedRanges=e._reservedRanges.map(n=>({...n})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(n=>({boxInitialized:n.boxInitialized,box:n.box.clone(),sphereInitialized:n.sphereInitialized,sphere:n.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,n,r,i,a){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=i.getIndex(),l=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,f=this._drawRanges,p=this.perObjectFrustumCulled;p&&(n7.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),JC.setFromProjectionMatrix(n7,e.isWebGPURenderer?by:cc));let m=0;if(this.sortObjects){t7.copy(this.matrixWorld).invert(),Qb.setFromMatrixPosition(r.matrixWorld).applyMatrix4(t7);for(let y=0,v=c.length;y<v;y++)if(c[y]){this.getMatrixAt(y,Rd),this.getBoundingSphereAt(y,xf).applyMatrix4(Rd);let S=!1;if(p&&(S=!JC.intersectsSphere(xf)),!S){const M=Qb.distanceTo(xf.center);ej.push(f[y],M)}}const x=ej.list,b=this.customSort;b===null?x.sort(a.transparent?_Be:wBe):b.call(this,x,r);for(let y=0,v=x.length;y<v;y++){const S=x[y];u[m]=S.start*l,d[m]=S.count,m++}ej.reset()}else for(let x=0,b=c.length;x<b;x++)if(c[x]){let y=!1;if(p&&(this.getMatrixAt(x,Rd),this.getBoundingSphereAt(x,xf).applyMatrix4(Rd),y=!JC.intersectsSphere(xf)),!y){const v=f[x];u[m]=v.start*l,d[m]=v.count,m++}}this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,a,o){this.onBeforeRender(e,null,i,a,o)}}class pv extends Dx{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Zt(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 r7=new qe,i7=new qe,a7=new zr,tj=new oL,q_=new hc;class kBe extends ps{constructor(e=new ns,n=new pv){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,a=n.count;i<a;i++)r7.fromBufferAttribute(n,i-1),i7.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=r7.distanceTo(i7);e.setAttribute("lineDistance",new Ti(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,a=e.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),q_.copy(r.boundingSphere),q_.applyMatrix4(i),q_.radius+=a,e.ray.intersectsSphere(q_)===!1)return;a7.copy(i).invert(),tj.copy(e.ray).applyMatrix4(a7);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=new qe,d=new qe,f=new qe,p=new qe,m=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 M=v,T=S-1;M<T;M+=m){const E=x.getX(M),C=x.getX(M+1);if(u.fromBufferAttribute(y,E),d.fromBufferAttribute(y,C),tj.distanceSqToSegment(u,d,p,f)>c)continue;p.applyMatrix4(this.matrixWorld);const R=e.ray.origin.distanceTo(p);R<e.near||R>e.far||n.push({distance:R,point:f.clone().applyMatrix4(this.matrixWorld),index:M,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 M=v,T=S-1;M<T;M+=m){if(u.fromBufferAttribute(y,M),d.fromBufferAttribute(y,M+1),tj.distanceSqToSegment(u,d,p,f)>c)continue;p.applyMatrix4(this.matrixWorld);const C=e.ray.origin.distanceTo(p);C<e.near||C>e.far||n.push({distance:C,point:f.clone().applyMatrix4(this.matrixWorld),index:M,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}}const s7=new qe,o7=new qe;class _M extends kBe{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,a=n.count;i<a;i+=2)s7.fromBufferAttribute(n,i),o7.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+s7.distanceTo(o7);e.setAttribute("lineDistance",new Ti(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class TBe extends ns{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new qe,a=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],p=f.start,m=f.count;for(let x=p,b=p+m;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),a.fromBufferAttribute(o,S),l7(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.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),a.fromBufferAttribute(o,f),l7(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}this.setAttribute("position",new Ti(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function l7(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 ABe extends Dx{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Zt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Zt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=VJ,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=rL,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 CBe extends pv{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 hee extends ps{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Zt(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 nj=new zr,c7=new qe,u7=new qe;class jBe{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 zr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new vM,this._frameExtents=new xn(1,1),this._viewportCount=1,this._viewports=[new Cr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;c7.setFromMatrixPosition(e.matrixWorld),n.position.copy(c7),u7.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(u7),n.updateMatrixWorld(),nj.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(nj),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(nj)}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 d7=new zr,Zb=new qe,rj=new qe;class PBe extends jBe{constructor(){super(new oo(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new xn(4,2),this._viewportCount=6,this._viewports=[new Cr(2,1,1,1),new Cr(0,1,1,1),new Cr(3,1,1,1),new Cr(1,1,1,1),new Cr(3,0,1,1),new Cr(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,a=e.distance||r.far;a!==r.far&&(r.far=a,r.updateProjectionMatrix()),Zb.setFromMatrixPosition(e.matrixWorld),r.position.copy(Zb),rj.copy(r.position),rj.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(rj),r.updateMatrixWorld(),i.makeTranslation(-Zb.x,-Zb.y,-Zb.z),d7.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(d7)}}class DBe extends hee{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 PBe}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 RBe extends hee{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class OBe extends ns{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 ND extends yBe{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 h7{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(Oa(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const f7=new qe,W_=new qe;class LBe{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){f7.subVectors(e,this.start),W_.subVectors(this.end,this.start);const r=W_.dot(W_);let a=W_.dot(f7)/r;return n&&(a=Oa(a,0,1)),a}closestPointToPoint(e,n,r){const i=this.closestPointToPointParameter(e,n);return this.delta(r).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}class FBe extends _M{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 ns;i.setAttribute("position",new Ti(n,3)),i.setAttribute("color",new Ti(r,3));const a=new pv({vertexColors:!0,toneMapped:!1});super(i,a),this.type="AxesHelper"}setColors(e,n,r){const i=new Zt,a=this.geometry.attributes.color.array;return i.set(e),i.toArray(a,0),i.toArray(a,3),i.set(n),i.toArray(a,6),i.toArray(a,9),i.set(r),i.toArray(a,12),i.toArray(a,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:xM}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=xM);class fc{constructor(e,n,r,i,a="div"){this.parent=e,this.object=n,this.property=r,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement(a),this.domElement.classList.add("controller"),this.domElement.classList.add(i),this.$name=document.createElement("div"),this.$name.classList.add("name"),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 IBe 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 MD(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 UBe={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:MD,toHexString:MD},vy={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},zBe={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=vy.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 vy.toHexString(i)}},BBe={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=vy.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 vy.toHexString(i)}},$Be=[UBe,vy,zBe,BBe];function HBe(t){return $Be.find(e=>e.match(t))}class VBe 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=HBe(this.initialValue),this._rgbScale=i,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const a=MD(this.$text.value);a&&this._setValueFromHexString(a)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(e){if(this._format.isPrimitive){const n=this._format.fromHexString(e);this.setValue(n)}else this._format.fromHexString(e,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(e){return this._setValueFromHexString(e),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class ij 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 GBe extends fc{constructor(e,n,r,i,a,o){super(e,n,r,"number"),this._initInput(),this.min(i),this.max(a);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 M=parseFloat(this.$input.value);isNaN(M)||(this._snapClampSetValue(M+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))},a=S=>{this._inputFocused&&(S.preventDefault(),r(this._step*this._normalizeMouseWheel(S)))};let o=!1,l,c,u,d,f;const p=5,m=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 M=S.clientX-l,T=S.clientY-c;Math.abs(T)>p?(S.preventDefault(),this.$input.blur(),o=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(M)>p&&b()}if(!o){const M=S.clientY-u;f-=M*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",a,{passive:!1}),this.$input.addEventListener("mousedown",m),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,M,T,E)=>(v-S)/(M-S)*(E-T)+T,n=v=>{const S=this.$slider.getBoundingClientRect();let M=e(v,S.left,S.right,this._min,this._max);this._snapClampSetValue(M)},r=v=>{this._setDraggingStyle(!0),n(v.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",a)},i=v=>{n(v.clientX)},a=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",a)};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",p))},f=v=>{if(o){const S=v.touches[0].clientX-l,M=v.touches[0].clientY-c;Math.abs(S)>Math.abs(M)?u(v):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",p))}else v.preventDefault(),n(v.touches[0].clientX)},p=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",p)},m=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 M=this._normalizeMouseWheel(v)*this._step;this._snapClampSetValue(this.getValue()+M),this.$input.value=this.getValue(),clearTimeout(b),b=setTimeout(m,x)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",d,{passive:!1}),this.$slider.addEventListener("wheel",y,{passive:!1})}_setDraggingStyle(e,n="horizontal"){this.$slider&&this.$slider.classList.toggle("active",e),document.body.classList.toggle("lil-gui-dragging",e),document.body.classList.toggle(`lil-gui-${n}`,e)}_getImplicitStep(){return this._hasMin&&this._hasMax?(this._max-this._min)/1e3:.1}_onUpdateMinMax(){!this._hasSlider&&this._hasMin&&this._hasMax&&(this._stepExplicit||this.step(this._getImplicitStep(),!1),this._initSlider(),this.updateDisplay())}_normalizeMouseWheel(e){let{deltaX:n,deltaY:r}=e;return Math.floor(e.deltaY)!==e.deltaY&&e.wheelDelta&&(n=0,r=-e.wheelDelta/120,r*=this._stepExplicit?1:10),n+-r}_arrowKeyMultiplier(e){let n=this._stepExplicit?1:10;return e.shiftKey?n*=10:e.altKey&&(n/=10),n}_snap(e){const n=Math.round(e/this._step)*this._step;return parseFloat(n.toPrecision(15))}_clamp(e){return e<this._min&&(e=this._min),e>this._max&&(e=this._max),e}_snapClampSetValue(e){this.setValue(this._clamp(this._snap(e)))}get _hasScrollBar(){const e=this.parent.root.$children;return e.scrollHeight>e.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}}class qBe 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 WBe 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 KBe=`.lil-gui {
  7477. font-family: var(--font-family);
  7478. font-size: var(--font-size);
  7479. line-height: 1;
  7480. font-weight: normal;
  7481. font-style: normal;
  7482. text-align: left;
  7483. color: var(--text-color);
  7484. user-select: none;
  7485. -webkit-user-select: none;
  7486. touch-action: manipulation;
  7487. --background-color: #1f1f1f;
  7488. --text-color: #ebebeb;
  7489. --title-background-color: #111111;
  7490. --title-text-color: #ebebeb;
  7491. --widget-color: #424242;
  7492. --hover-color: #4f4f4f;
  7493. --focus-color: #595959;
  7494. --number-color: #2cc9ff;
  7495. --string-color: #a2db3c;
  7496. --font-size: 11px;
  7497. --input-font-size: 11px;
  7498. --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  7499. --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
  7500. --padding: 4px;
  7501. --spacing: 4px;
  7502. --widget-height: 20px;
  7503. --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
  7504. --name-width: 45%;
  7505. --slider-knob-width: 2px;
  7506. --slider-input-width: 27%;
  7507. --color-input-width: 27%;
  7508. --slider-input-min-width: 45px;
  7509. --color-input-min-width: 45px;
  7510. --folder-indent: 7px;
  7511. --widget-padding: 0 0 0 3px;
  7512. --widget-border-radius: 2px;
  7513. --checkbox-size: calc(0.75 * var(--widget-height));
  7514. --scrollbar-width: 5px;
  7515. }
  7516. .lil-gui, .lil-gui * {
  7517. box-sizing: border-box;
  7518. margin: 0;
  7519. padding: 0;
  7520. }
  7521. .lil-gui.root {
  7522. width: var(--width, 245px);
  7523. display: flex;
  7524. flex-direction: column;
  7525. background: var(--background-color);
  7526. }
  7527. .lil-gui.root > .title {
  7528. background: var(--title-background-color);
  7529. color: var(--title-text-color);
  7530. }
  7531. .lil-gui.root > .children {
  7532. overflow-x: hidden;
  7533. overflow-y: auto;
  7534. }
  7535. .lil-gui.root > .children::-webkit-scrollbar {
  7536. width: var(--scrollbar-width);
  7537. height: var(--scrollbar-width);
  7538. background: var(--background-color);
  7539. }
  7540. .lil-gui.root > .children::-webkit-scrollbar-thumb {
  7541. border-radius: var(--scrollbar-width);
  7542. background: var(--focus-color);
  7543. }
  7544. @media (pointer: coarse) {
  7545. .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
  7546. --widget-height: 28px;
  7547. --padding: 6px;
  7548. --spacing: 6px;
  7549. --font-size: 13px;
  7550. --input-font-size: 16px;
  7551. --folder-indent: 10px;
  7552. --scrollbar-width: 7px;
  7553. --slider-input-min-width: 50px;
  7554. --color-input-min-width: 65px;
  7555. }
  7556. }
  7557. .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
  7558. --widget-height: 28px;
  7559. --padding: 6px;
  7560. --spacing: 6px;
  7561. --font-size: 13px;
  7562. --input-font-size: 16px;
  7563. --folder-indent: 10px;
  7564. --scrollbar-width: 7px;
  7565. --slider-input-min-width: 50px;
  7566. --color-input-min-width: 65px;
  7567. }
  7568. .lil-gui.autoPlace {
  7569. max-height: 100%;
  7570. position: fixed;
  7571. top: 0;
  7572. right: 15px;
  7573. z-index: 1001;
  7574. }
  7575. .lil-gui .controller {
  7576. display: flex;
  7577. align-items: center;
  7578. padding: 0 var(--padding);
  7579. margin: var(--spacing) 0;
  7580. }
  7581. .lil-gui .controller.disabled {
  7582. opacity: 0.5;
  7583. }
  7584. .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
  7585. pointer-events: none !important;
  7586. }
  7587. .lil-gui .controller > .name {
  7588. min-width: var(--name-width);
  7589. flex-shrink: 0;
  7590. white-space: pre;
  7591. padding-right: var(--spacing);
  7592. line-height: var(--widget-height);
  7593. }
  7594. .lil-gui .controller .widget {
  7595. position: relative;
  7596. display: flex;
  7597. align-items: center;
  7598. width: 100%;
  7599. min-height: var(--widget-height);
  7600. }
  7601. .lil-gui .controller.string input {
  7602. color: var(--string-color);
  7603. }
  7604. .lil-gui .controller.boolean {
  7605. cursor: pointer;
  7606. }
  7607. .lil-gui .controller.color .display {
  7608. width: 100%;
  7609. height: var(--widget-height);
  7610. border-radius: var(--widget-border-radius);
  7611. position: relative;
  7612. }
  7613. @media (hover: hover) {
  7614. .lil-gui .controller.color .display:hover:before {
  7615. content: " ";
  7616. display: block;
  7617. position: absolute;
  7618. border-radius: var(--widget-border-radius);
  7619. border: 1px solid #fff9;
  7620. top: 0;
  7621. right: 0;
  7622. bottom: 0;
  7623. left: 0;
  7624. }
  7625. }
  7626. .lil-gui .controller.color input[type=color] {
  7627. opacity: 0;
  7628. width: 100%;
  7629. height: 100%;
  7630. cursor: pointer;
  7631. }
  7632. .lil-gui .controller.color input[type=text] {
  7633. margin-left: var(--spacing);
  7634. font-family: var(--font-family-mono);
  7635. min-width: var(--color-input-min-width);
  7636. width: var(--color-input-width);
  7637. flex-shrink: 0;
  7638. }
  7639. .lil-gui .controller.option select {
  7640. opacity: 0;
  7641. position: absolute;
  7642. width: 100%;
  7643. max-width: 100%;
  7644. }
  7645. .lil-gui .controller.option .display {
  7646. position: relative;
  7647. pointer-events: none;
  7648. border-radius: var(--widget-border-radius);
  7649. height: var(--widget-height);
  7650. line-height: var(--widget-height);
  7651. max-width: 100%;
  7652. overflow: hidden;
  7653. word-break: break-all;
  7654. padding-left: 0.55em;
  7655. padding-right: 1.75em;
  7656. background: var(--widget-color);
  7657. }
  7658. @media (hover: hover) {
  7659. .lil-gui .controller.option .display.focus {
  7660. background: var(--focus-color);
  7661. }
  7662. }
  7663. .lil-gui .controller.option .display.active {
  7664. background: var(--focus-color);
  7665. }
  7666. .lil-gui .controller.option .display:after {
  7667. font-family: "lil-gui";
  7668. content: "↕";
  7669. position: absolute;
  7670. top: 0;
  7671. right: 0;
  7672. bottom: 0;
  7673. padding-right: 0.375em;
  7674. }
  7675. .lil-gui .controller.option .widget,
  7676. .lil-gui .controller.option select {
  7677. cursor: pointer;
  7678. }
  7679. @media (hover: hover) {
  7680. .lil-gui .controller.option .widget:hover .display {
  7681. background: var(--hover-color);
  7682. }
  7683. }
  7684. .lil-gui .controller.number input {
  7685. color: var(--number-color);
  7686. }
  7687. .lil-gui .controller.number.hasSlider input {
  7688. margin-left: var(--spacing);
  7689. width: var(--slider-input-width);
  7690. min-width: var(--slider-input-min-width);
  7691. flex-shrink: 0;
  7692. }
  7693. .lil-gui .controller.number .slider {
  7694. width: 100%;
  7695. height: var(--widget-height);
  7696. background: var(--widget-color);
  7697. border-radius: var(--widget-border-radius);
  7698. padding-right: var(--slider-knob-width);
  7699. overflow: hidden;
  7700. cursor: ew-resize;
  7701. touch-action: pan-y;
  7702. }
  7703. @media (hover: hover) {
  7704. .lil-gui .controller.number .slider:hover {
  7705. background: var(--hover-color);
  7706. }
  7707. }
  7708. .lil-gui .controller.number .slider.active {
  7709. background: var(--focus-color);
  7710. }
  7711. .lil-gui .controller.number .slider.active .fill {
  7712. opacity: 0.95;
  7713. }
  7714. .lil-gui .controller.number .fill {
  7715. height: 100%;
  7716. border-right: var(--slider-knob-width) solid var(--number-color);
  7717. box-sizing: content-box;
  7718. }
  7719. .lil-gui-dragging .lil-gui {
  7720. --hover-color: var(--widget-color);
  7721. }
  7722. .lil-gui-dragging * {
  7723. cursor: ew-resize !important;
  7724. }
  7725. .lil-gui-dragging.lil-gui-vertical * {
  7726. cursor: ns-resize !important;
  7727. }
  7728. .lil-gui .title {
  7729. height: var(--title-height);
  7730. line-height: calc(var(--title-height) - 4px);
  7731. font-weight: 600;
  7732. padding: 0 var(--padding);
  7733. -webkit-tap-highlight-color: transparent;
  7734. cursor: pointer;
  7735. outline: none;
  7736. text-decoration-skip: objects;
  7737. }
  7738. .lil-gui .title:before {
  7739. font-family: "lil-gui";
  7740. content: "▾";
  7741. padding-right: 2px;
  7742. display: inline-block;
  7743. }
  7744. .lil-gui .title:active {
  7745. background: var(--title-background-color);
  7746. opacity: 0.75;
  7747. }
  7748. @media (hover: hover) {
  7749. body:not(.lil-gui-dragging) .lil-gui .title:hover {
  7750. background: var(--title-background-color);
  7751. opacity: 0.85;
  7752. }
  7753. .lil-gui .title:focus {
  7754. text-decoration: underline var(--focus-color);
  7755. }
  7756. }
  7757. .lil-gui.root > .title:focus {
  7758. text-decoration: none !important;
  7759. }
  7760. .lil-gui.closed > .title:before {
  7761. content: "▸";
  7762. }
  7763. .lil-gui.closed > .children {
  7764. transform: translateY(-7px);
  7765. opacity: 0;
  7766. }
  7767. .lil-gui.closed:not(.transition) > .children {
  7768. display: none;
  7769. }
  7770. .lil-gui.transition > .children {
  7771. transition-duration: 300ms;
  7772. transition-property: height, opacity, transform;
  7773. transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
  7774. overflow: hidden;
  7775. pointer-events: none;
  7776. }
  7777. .lil-gui .children:empty:before {
  7778. content: "Empty";
  7779. padding: 0 var(--padding);
  7780. margin: var(--spacing) 0;
  7781. display: block;
  7782. height: var(--widget-height);
  7783. font-style: italic;
  7784. line-height: var(--widget-height);
  7785. opacity: 0.5;
  7786. }
  7787. .lil-gui.root > .children > .lil-gui > .title {
  7788. border: 0 solid var(--widget-color);
  7789. border-width: 1px 0;
  7790. transition: border-color 300ms;
  7791. }
  7792. .lil-gui.root > .children > .lil-gui.closed > .title {
  7793. border-bottom-color: transparent;
  7794. }
  7795. .lil-gui + .controller {
  7796. border-top: 1px solid var(--widget-color);
  7797. margin-top: 0;
  7798. padding-top: var(--spacing);
  7799. }
  7800. .lil-gui .lil-gui .lil-gui > .title {
  7801. border: none;
  7802. }
  7803. .lil-gui .lil-gui .lil-gui > .children {
  7804. border: none;
  7805. margin-left: var(--folder-indent);
  7806. border-left: 2px solid var(--widget-color);
  7807. }
  7808. .lil-gui .lil-gui .controller {
  7809. border: none;
  7810. }
  7811. .lil-gui label, .lil-gui input, .lil-gui button {
  7812. -webkit-tap-highlight-color: transparent;
  7813. }
  7814. .lil-gui input {
  7815. border: 0;
  7816. outline: none;
  7817. font-family: var(--font-family);
  7818. font-size: var(--input-font-size);
  7819. border-radius: var(--widget-border-radius);
  7820. height: var(--widget-height);
  7821. background: var(--widget-color);
  7822. color: var(--text-color);
  7823. width: 100%;
  7824. }
  7825. @media (hover: hover) {
  7826. .lil-gui input:hover {
  7827. background: var(--hover-color);
  7828. }
  7829. .lil-gui input:active {
  7830. background: var(--focus-color);
  7831. }
  7832. }
  7833. .lil-gui input:disabled {
  7834. opacity: 1;
  7835. }
  7836. .lil-gui input[type=text],
  7837. .lil-gui input[type=number] {
  7838. padding: var(--widget-padding);
  7839. -moz-appearance: textfield;
  7840. }
  7841. .lil-gui input[type=text]:focus,
  7842. .lil-gui input[type=number]:focus {
  7843. background: var(--focus-color);
  7844. }
  7845. .lil-gui input[type=checkbox] {
  7846. appearance: none;
  7847. width: var(--checkbox-size);
  7848. height: var(--checkbox-size);
  7849. border-radius: var(--widget-border-radius);
  7850. text-align: center;
  7851. cursor: pointer;
  7852. }
  7853. .lil-gui input[type=checkbox]:checked:before {
  7854. font-family: "lil-gui";
  7855. content: "✓";
  7856. font-size: var(--checkbox-size);
  7857. line-height: var(--checkbox-size);
  7858. }
  7859. @media (hover: hover) {
  7860. .lil-gui input[type=checkbox]:focus {
  7861. box-shadow: inset 0 0 0 1px var(--focus-color);
  7862. }
  7863. }
  7864. .lil-gui button {
  7865. outline: none;
  7866. cursor: pointer;
  7867. font-family: var(--font-family);
  7868. font-size: var(--font-size);
  7869. color: var(--text-color);
  7870. width: 100%;
  7871. height: var(--widget-height);
  7872. text-transform: none;
  7873. background: var(--widget-color);
  7874. border-radius: var(--widget-border-radius);
  7875. border: none;
  7876. }
  7877. @media (hover: hover) {
  7878. .lil-gui button:hover {
  7879. background: var(--hover-color);
  7880. }
  7881. .lil-gui button:focus {
  7882. box-shadow: inset 0 0 0 1px var(--focus-color);
  7883. }
  7884. }
  7885. .lil-gui button:active {
  7886. background: var(--focus-color);
  7887. }
  7888. @font-face {
  7889. font-family: "lil-gui";
  7890. 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");
  7891. }`;function XBe(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 m7=!1;class iN{constructor({parent:e,autoPlace:n=e===void 0,container:r,width:i,title:a="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(a),this.parent){this.parent.children.push(this),this.parent.folders.push(this),this.parent.$children.appendChild(this.domElement);return}this.domElement.classList.add("root"),c&&this.domElement.classList.add("allow-touch-styles"),!m7&&l&&(XBe(KBe),m7=!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,a){if(Object(r)===r)return new qBe(this,e,n,r);const o=e[n];switch(typeof o){case"number":return new GBe(this,e,n,r,i,a);case"boolean":return new IBe(this,e,n);case"string":return new WBe(this,e,n);case"function":return new ij(this,e,n)}console.error(`gui.add failed
  7892. property:`,n,`
  7893. object:`,e,`
  7894. value:`,o)}addColor(e,n,r=1){return new VBe(this,e,n,r)}addFolder(e){const n=new iN({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof ij||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 ij)){if(r._name in n.controllers)throw new Error(`Cannot save GUI with duplicate property "${r._name}"`);n.controllers[r._name]=r.save()}}),e&&this.folders.forEach(r=>{if(r._title in n.folders)throw new Error(`Cannot save GUI with duplicate folder "${r._title}"`);n.folders[r._title]=r.save()}),n}open(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}_setClosed(e){this._closed!==e&&(this._closed=e,this._callOnOpenClose(this))}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{const n=this.$children.clientHeight;this.$children.style.height=n+"px",this.domElement.classList.add("transition");const r=a=>{a.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",r))};this.$children.addEventListener("transitionend",r);const i=e?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!e),requestAnimationFrame(()=>{this.$children.style.height=i+"px"})}),this}title(e){return this._title=e,this.$title.textContent=e,this}reset(e=!0){return(e?this.controllersRecursive():this.controllers).forEach(r=>r.reset()),this}onChange(e){return this._onChange=e,this}_callOnChange(e){this.parent&&this.parent._callOnChange(e),this._onChange!==void 0&&this._onChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(e){this.parent&&this.parent._callOnFinishChange(e),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onOpenClose(e){return this._onOpenClose=e,this}_callOnOpenClose(e){this.parent&&this.parent._callOnOpenClose(e),this._onOpenClose!==void 0&&this._onOpenClose.call(this,e)}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(e=>e.destroy())}controllersRecursive(){let e=Array.from(this.controllers);return this.folders.forEach(n=>{e=e.concat(n.controllersRecursive())}),e}foldersRecursive(){let e=Array.from(this.folders);return this.folders.forEach(n=>{e=e.concat(n.foldersRecursive())}),e}}function aj(t,e,n,r){return new(n||(n=Promise))((function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){var d;u.done?i(u.value):(d=u.value,d instanceof n?d:new n((function(f){f(d)}))).then(o,l)}c((r=r.apply(t,[])).next())}))}class hL{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 hL(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 fL{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class p7 extends fL{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class Od extends fL{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class g7{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class aN{constructor(e){this.lines=[],this.preamble=new g7(-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(`
  7895. `);this.lines=this.lines.concat(n);const r=this.lines2commands(n);this.groupIntoLayers(r);const i=this.parseMetadata(r.filter((a=>a.comment))).thumbnails;for(const[a,o]of Object.entries(i))this.metadata.thumbnails[a]=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(";"),a=i[0],o=n&&i[1]||void 0,l=a.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 p7(e,c,u,o);case"t0":return new Od(e,c,o,0);case"t1":return new Od(e,c,o,1);case"t2":return new Od(e,c,o,2);case"t3":return new Od(e,c,o,3);case"t4":return new Od(e,c,o,4);case"t5":return new Od(e,c,o,5);case"t6":return new Od(e,c,o,6);case"t7":return new Od(e,c,o,7);default:return new fL(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,a)=>{if(i%2==0)return n;let o=a[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 p7){const a=i.params;if(a.z&&(this.curZ=a.z),((n=a.e)!==null&&n!==void 0?n:0)>0&&(a.x!=null||a.y!=null)&&Math.abs(this.curZ-(this.maxZ||-1/0))>this.tolerance){const o=Math.abs(this.curZ-this.maxZ);this.maxZ=this.curZ,this.layers.push(new g7(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 a=i.comment;if(!a)continue;const o=a.indexOf("thumbnail begin"),l=a.indexOf("thumbnail end");o>-1?r=hL.parse(a.slice(o+15).trim()):r&&(l==-1?r.chars+=a.trim():(r.isValid&&(n[r.size]=r),r=void 0))}return{thumbnails:n}}}aN.prototype.parseGcode=aN.prototype.parseGCode;const x7={type:"change"},sj={type:"start"},b7={type:"end"},K_=new oL,y7=new $d,YBe=Math.cos(70*qJ.DEG2RAD);class QBe extends jm{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:Rp.ROTATE,MIDDLE:Rp.DOLLY,RIGHT:Rp.PAN},this.touches={ONE:Op.ROTATE,TWO:Op.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(Y){Y.addEventListener("keydown",Oe),this._domElementKeyEvents=Y},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Oe),this._domElementKeyEvents=null},this.saveState=function(){r.target0.copy(r.target),r.position0.copy(r.object.position),r.zoom0=r.object.zoom},this.reset=function(){r.target.copy(r.target0),r.object.position.copy(r.position0),r.object.zoom=r.zoom0,r.object.updateProjectionMatrix(),r.dispatchEvent(x7),r.update(),a=i.NONE},this.update=(function(){const Y=new qe,ce=new vm().setFromUnitVectors(e.up,new qe(0,1,0)),q=ce.clone().invert(),te=new qe,I=new vm,fe=new qe,me=2*Math.PI;return function(ke=null){const z=r.object.position;Y.copy(z).sub(r.target),Y.applyQuaternion(ce),l.setFromVector3(Y),r.autoRotate&&a===i.NONE&&D((function(_e){return _e!==null?2*Math.PI/60*r.autoRotateSpeed*_e:2*Math.PI/60/60*r.autoRotateSpeed})(ke)),r.enableDamping?(l.theta+=c.theta*r.dampingFactor,l.phi+=c.phi*r.dampingFactor):(l.theta+=c.theta,l.phi+=c.phi);let O=r.minAzimuthAngle,ee=r.maxAzimuthAngle;isFinite(O)&&isFinite(ee)&&(O<-Math.PI?O+=me:O>Math.PI&&(O-=me),ee<-Math.PI?ee+=me:ee>Math.PI&&(ee-=me),l.theta=O<=ee?Math.max(O,Math.min(ee,l.theta)):l.theta>(O+ee)/2?Math.max(O,l.theta):Math.min(ee,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&&C||r.object.isOrthographicCamera?l.radius=Q(l.radius):l.radius=Q(l.radius*u),Y.setFromSpherical(l),Y.applyQuaternion(q),z.copy(r.target).add(Y),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 le=!1;if(r.zoomToCursor&&C){let _e=null;if(r.object.isPerspectiveCamera){const we=Y.length();_e=Q(we*u);const re=we-_e;r.object.position.addScaledVector(T,re),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const we=new qe(E.x,E.y,0);we.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),le=!0;const re=new qe(E.x,E.y,0);re.unproject(r.object),r.object.position.sub(re).add(we),r.object.updateMatrixWorld(),_e=Y.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;_e!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(_e).add(r.object.position):(K_.origin.copy(r.object.position),K_.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(K_.direction))<YBe?e.lookAt(r.target):(y7.setFromNormalAndCoplanarPoint(r.object.up,r.target),K_.intersectPlane(y7,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),le=!0);return u=1,C=!1,!!(le||te.distanceToSquared(r.object.position)>o||8*(1-I.dot(r.object.quaternion))>o||fe.distanceToSquared(r.target)>0)&&(r.dispatchEvent(x7),te.copy(r.object.position),I.copy(r.object.quaternion),fe.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",ge),r.domElement.removeEventListener("pointerdown",de),r.domElement.removeEventListener("pointercancel",ie),r.domElement.removeEventListener("wheel",Me),r.domElement.removeEventListener("pointermove",Pe),r.domElement.removeEventListener("pointerup",ie),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",Oe),r._domElementKeyEvents=null)};const r=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let a=i.NONE;const o=1e-6,l=new h7,c=new h7;let u=1;const d=new qe,f=new xn,p=new xn,m=new xn,x=new xn,b=new xn,y=new xn,v=new xn,S=new xn,M=new xn,T=new qe,E=new xn;let C=!1;const k=[],R={};function A(){return Math.pow(.95,r.zoomSpeed)}function D(Y){c.theta-=Y}function U(Y){c.phi-=Y}const F=(function(){const Y=new qe;return function(ce,q){Y.setFromMatrixColumn(q,0),Y.multiplyScalar(-ce),d.add(Y)}})(),H=(function(){const Y=new qe;return function(ce,q){r.screenSpacePanning===!0?Y.setFromMatrixColumn(q,1):(Y.setFromMatrixColumn(q,0),Y.crossVectors(r.object.up,Y)),Y.multiplyScalar(ce),d.add(Y)}})(),j=(function(){const Y=new qe;return function(ce,q){const te=r.domElement;if(r.object.isPerspectiveCamera){const I=r.object.position;Y.copy(I).sub(r.target);let fe=Y.length();fe*=Math.tan(r.object.fov/2*Math.PI/180),F(2*ce*fe/te.clientHeight,r.object.matrix),H(2*q*fe/te.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(F(ce*(r.object.right-r.object.left)/r.object.zoom/te.clientWidth,r.object.matrix),H(q*(r.object.top-r.object.bottom)/r.object.zoom/te.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function $(Y){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=Y:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function K(Y){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=Y:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function V(Y){if(!r.zoomToCursor)return;C=!0;const ce=r.domElement.getBoundingClientRect(),q=Y.clientX-ce.left,te=Y.clientY-ce.top,I=ce.width,fe=ce.height;E.x=q/I*2-1,E.y=-te/fe*2+1,T.set(E.x,E.y,1).unproject(r.object).sub(r.object.position).normalize()}function Q(Y){return Math.max(r.minDistance,Math.min(r.maxDistance,Y))}function Z(Y){f.set(Y.clientX,Y.clientY)}function ae(Y){x.set(Y.clientX,Y.clientY)}function B(){if(k.length===1)f.set(k[0].pageX,k[0].pageY);else{const Y=.5*(k[0].pageX+k[1].pageX),ce=.5*(k[0].pageY+k[1].pageY);f.set(Y,ce)}}function X(){if(k.length===1)x.set(k[0].pageX,k[0].pageY);else{const Y=.5*(k[0].pageX+k[1].pageX),ce=.5*(k[0].pageY+k[1].pageY);x.set(Y,ce)}}function ne(){const Y=k[0].pageX-k[1].pageX,ce=k[0].pageY-k[1].pageY,q=Math.sqrt(Y*Y+ce*ce);v.set(0,q)}function se(Y){if(k.length==1)p.set(Y.pageX,Y.pageY);else{const q=G(Y),te=.5*(Y.pageX+q.x),I=.5*(Y.pageY+q.y);p.set(te,I)}m.subVectors(p,f).multiplyScalar(r.rotateSpeed);const ce=r.domElement;D(2*Math.PI*m.x/ce.clientHeight),U(2*Math.PI*m.y/ce.clientHeight),f.copy(p)}function be(Y){if(k.length===1)b.set(Y.pageX,Y.pageY);else{const ce=G(Y),q=.5*(Y.pageX+ce.x),te=.5*(Y.pageY+ce.y);b.set(q,te)}y.subVectors(b,x).multiplyScalar(r.panSpeed),j(y.x,y.y),x.copy(b)}function xe(Y){const ce=G(Y),q=Y.pageX-ce.x,te=Y.pageY-ce.y,I=Math.sqrt(q*q+te*te);S.set(0,I),M.set(0,Math.pow(S.y/v.y,r.zoomSpeed)),$(M.y),v.copy(S)}function de(Y){r.enabled!==!1&&(k.length===0&&(r.domElement.setPointerCapture(Y.pointerId),r.domElement.addEventListener("pointermove",Pe),r.domElement.addEventListener("pointerup",ie)),(function(ce){k.push(ce)})(Y),Y.pointerType==="touch"?(function(ce){switch(Ke(ce),k.length){case 1:switch(r.touches.ONE){case Op.ROTATE:if(r.enableRotate===!1)return;B(),a=i.TOUCH_ROTATE;break;case Op.PAN:if(r.enablePan===!1)return;X(),a=i.TOUCH_PAN;break;default:a=i.NONE}break;case 2:switch(r.touches.TWO){case Op.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&ne(),r.enablePan&&X(),a=i.TOUCH_DOLLY_PAN;break;case Op.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&ne(),r.enableRotate&&B(),a=i.TOUCH_DOLLY_ROTATE;break;default:a=i.NONE}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(sj)})(Y):(function(ce){let q;switch(ce.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 Rp.DOLLY:if(r.enableZoom===!1)return;(function(te){V(te),v.set(te.clientX,te.clientY)})(ce),a=i.DOLLY;break;case Rp.ROTATE:if(ce.ctrlKey||ce.metaKey||ce.shiftKey){if(r.enablePan===!1)return;ae(ce),a=i.PAN}else{if(r.enableRotate===!1)return;Z(ce),a=i.ROTATE}break;case Rp.PAN:if(ce.ctrlKey||ce.metaKey||ce.shiftKey){if(r.enableRotate===!1)return;Z(ce),a=i.ROTATE}else{if(r.enablePan===!1)return;ae(ce),a=i.PAN}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(sj)})(Y))}function Pe(Y){r.enabled!==!1&&(Y.pointerType==="touch"?(function(ce){switch(Ke(ce),a){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;se(ce),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;be(ce),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(q){r.enableZoom&&xe(q),r.enablePan&&be(q)})(ce),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(q){r.enableZoom&&xe(q),r.enableRotate&&se(q)})(ce),r.update();break;default:a=i.NONE}})(Y):(function(ce){switch(a){case i.ROTATE:if(r.enableRotate===!1)return;(function(q){p.set(q.clientX,q.clientY),m.subVectors(p,f).multiplyScalar(r.rotateSpeed);const te=r.domElement;D(2*Math.PI*m.x/te.clientHeight),U(2*Math.PI*m.y/te.clientHeight),f.copy(p),r.update()})(ce);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(q){S.set(q.clientX,q.clientY),M.subVectors(S,v),M.y>0?$(A()):M.y<0&&K(A()),v.copy(S),r.update()})(ce);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()})(ce)}})(Y))}function ie(Y){(function(ce){delete R[ce.pointerId];for(let q=0;q<k.length;q++)if(k[q].pointerId==ce.pointerId)return void k.splice(q,1)})(Y),k.length===0&&(r.domElement.releasePointerCapture(Y.pointerId),r.domElement.removeEventListener("pointermove",Pe),r.domElement.removeEventListener("pointerup",ie)),r.dispatchEvent(b7),a=i.NONE}function Me(Y){r.enabled!==!1&&r.enableZoom!==!1&&a===i.NONE&&(Y.preventDefault(),r.dispatchEvent(sj),(function(ce){V(ce),ce.deltaY<0?K(A()):ce.deltaY>0&&$(A()),r.update()})(Y),r.dispatchEvent(b7))}function Oe(Y){r.enabled!==!1&&r.enablePan!==!1&&(function(ce){let q=!1;switch(ce.code){case r.keys.UP:ce.ctrlKey||ce.metaKey||ce.shiftKey?U(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(0,r.keyPanSpeed),q=!0;break;case r.keys.BOTTOM:ce.ctrlKey||ce.metaKey||ce.shiftKey?U(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(0,-r.keyPanSpeed),q=!0;break;case r.keys.LEFT:ce.ctrlKey||ce.metaKey||ce.shiftKey?D(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(r.keyPanSpeed,0),q=!0;break;case r.keys.RIGHT:ce.ctrlKey||ce.metaKey||ce.shiftKey?D(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(-r.keyPanSpeed,0),q=!0}q&&(ce.preventDefault(),r.update())})(Y)}function ge(Y){r.enabled!==!1&&Y.preventDefault()}function Ke(Y){let ce=R[Y.pointerId];ce===void 0&&(ce=new xn,R[Y.pointerId]=ce),ce.set(Y.pageX,Y.pageY)}function G(Y){const ce=Y.pointerId===k[0].pointerId?k[1]:k[0];return R[ce.pointerId]}r.domElement.addEventListener("contextmenu",ge),r.domElement.addEventListener("pointerdown",de),r.domElement.addEventListener("pointercancel",ie),r.domElement.addEventListener("wheel",Me,{passive:!1}),this.update()}}Dt.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}},Rs.line={uniforms:lL.merge([Dt.common,Dt.fog,Dt.line]),vertexShader:`
  7896. #include <common>
  7897. #include <color_pars_vertex>
  7898. #include <fog_pars_vertex>
  7899. #include <logdepthbuf_pars_vertex>
  7900. #include <clipping_planes_pars_vertex>
  7901. uniform float linewidth;
  7902. uniform vec2 resolution;
  7903. attribute vec3 instanceStart;
  7904. attribute vec3 instanceEnd;
  7905. attribute vec3 instanceColorStart;
  7906. attribute vec3 instanceColorEnd;
  7907. #ifdef WORLD_UNITS
  7908. varying vec4 worldPos;
  7909. varying vec3 worldStart;
  7910. varying vec3 worldEnd;
  7911. #ifdef USE_DASH
  7912. varying vec2 vUv;
  7913. #endif
  7914. #else
  7915. varying vec2 vUv;
  7916. #endif
  7917. #ifdef USE_DASH
  7918. uniform float dashScale;
  7919. attribute float instanceDistanceStart;
  7920. attribute float instanceDistanceEnd;
  7921. varying float vLineDistance;
  7922. #endif
  7923. void trimSegment( const in vec4 start, inout vec4 end ) {
  7924. // trim end segment so it terminates between the camera plane and the near plane
  7925. // conservative estimate of the near plane
  7926. float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
  7927. float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
  7928. float nearEstimate = - 0.5 * b / a;
  7929. float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
  7930. end.xyz = mix( start.xyz, end.xyz, alpha );
  7931. }
  7932. void main() {
  7933. #ifdef USE_COLOR
  7934. vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
  7935. #endif
  7936. #ifdef USE_DASH
  7937. vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
  7938. vUv = uv;
  7939. #endif
  7940. float aspect = resolution.x / resolution.y;
  7941. // camera space
  7942. vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
  7943. vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
  7944. #ifdef WORLD_UNITS
  7945. worldStart = start.xyz;
  7946. worldEnd = end.xyz;
  7947. #else
  7948. vUv = uv;
  7949. #endif
  7950. // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
  7951. // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
  7952. // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
  7953. // perhaps there is a more elegant solution -- WestLangley
  7954. bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
  7955. if ( perspective ) {
  7956. if ( start.z < 0.0 && end.z >= 0.0 ) {
  7957. trimSegment( start, end );
  7958. } else if ( end.z < 0.0 && start.z >= 0.0 ) {
  7959. trimSegment( end, start );
  7960. }
  7961. }
  7962. // clip space
  7963. vec4 clipStart = projectionMatrix * start;
  7964. vec4 clipEnd = projectionMatrix * end;
  7965. // ndc space
  7966. vec3 ndcStart = clipStart.xyz / clipStart.w;
  7967. vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
  7968. // direction
  7969. vec2 dir = ndcEnd.xy - ndcStart.xy;
  7970. // account for clip-space aspect ratio
  7971. dir.x *= aspect;
  7972. dir = normalize( dir );
  7973. #ifdef WORLD_UNITS
  7974. // get the offset direction as perpendicular to the view vector
  7975. vec3 worldDir = normalize( end.xyz - start.xyz );
  7976. vec3 offset;
  7977. if ( position.y < 0.5 ) {
  7978. offset = normalize( cross( start.xyz, worldDir ) );
  7979. } else {
  7980. offset = normalize( cross( end.xyz, worldDir ) );
  7981. }
  7982. // sign flip
  7983. if ( position.x < 0.0 ) offset *= - 1.0;
  7984. float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
  7985. // don't extend the line if we're rendering dashes because we
  7986. // won't be rendering the endcaps
  7987. #ifndef USE_DASH
  7988. // extend the line bounds to encompass endcaps
  7989. start.xyz += - worldDir * linewidth * 0.5;
  7990. end.xyz += worldDir * linewidth * 0.5;
  7991. // shift the position of the quad so it hugs the forward edge of the line
  7992. offset.xy -= dir * forwardOffset;
  7993. offset.z += 0.5;
  7994. #endif
  7995. // endcaps
  7996. if ( position.y > 1.0 || position.y < 0.0 ) {
  7997. offset.xy += dir * 2.0 * forwardOffset;
  7998. }
  7999. // adjust for linewidth
  8000. offset *= linewidth * 0.5;
  8001. // set the world position
  8002. worldPos = ( position.y < 0.5 ) ? start : end;
  8003. worldPos.xyz += offset;
  8004. // project the worldpos
  8005. vec4 clip = projectionMatrix * worldPos;
  8006. // shift the depth of the projected points so the line
  8007. // segments overlap neatly
  8008. vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
  8009. clip.z = clipPose.z * clip.w;
  8010. #else
  8011. vec2 offset = vec2( dir.y, - dir.x );
  8012. // undo aspect ratio adjustment
  8013. dir.x /= aspect;
  8014. offset.x /= aspect;
  8015. // sign flip
  8016. if ( position.x < 0.0 ) offset *= - 1.0;
  8017. // endcaps
  8018. if ( position.y < 0.0 ) {
  8019. offset += - dir;
  8020. } else if ( position.y > 1.0 ) {
  8021. offset += dir;
  8022. }
  8023. // adjust for linewidth
  8024. offset *= linewidth;
  8025. // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
  8026. offset /= resolution.y;
  8027. // select end
  8028. vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
  8029. // back to clip space
  8030. offset *= clip.w;
  8031. clip.xy += offset;
  8032. #endif
  8033. gl_Position = clip;
  8034. vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
  8035. #include <logdepthbuf_vertex>
  8036. #include <clipping_planes_vertex>
  8037. #include <fog_vertex>
  8038. }
  8039. `,fragmentShader:`
  8040. uniform vec3 diffuse;
  8041. uniform float opacity;
  8042. uniform float linewidth;
  8043. #ifdef USE_DASH
  8044. uniform float dashOffset;
  8045. uniform float dashSize;
  8046. uniform float gapSize;
  8047. #endif
  8048. varying float vLineDistance;
  8049. #ifdef WORLD_UNITS
  8050. varying vec4 worldPos;
  8051. varying vec3 worldStart;
  8052. varying vec3 worldEnd;
  8053. #ifdef USE_DASH
  8054. varying vec2 vUv;
  8055. #endif
  8056. #else
  8057. varying vec2 vUv;
  8058. #endif
  8059. #include <common>
  8060. #include <color_pars_fragment>
  8061. #include <fog_pars_fragment>
  8062. #include <logdepthbuf_pars_fragment>
  8063. #include <clipping_planes_pars_fragment>
  8064. vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
  8065. float mua;
  8066. float mub;
  8067. vec3 p13 = p1 - p3;
  8068. vec3 p43 = p4 - p3;
  8069. vec3 p21 = p2 - p1;
  8070. float d1343 = dot( p13, p43 );
  8071. float d4321 = dot( p43, p21 );
  8072. float d1321 = dot( p13, p21 );
  8073. float d4343 = dot( p43, p43 );
  8074. float d2121 = dot( p21, p21 );
  8075. float denom = d2121 * d4343 - d4321 * d4321;
  8076. float numer = d1343 * d4321 - d1321 * d4343;
  8077. mua = numer / denom;
  8078. mua = clamp( mua, 0.0, 1.0 );
  8079. mub = ( d1343 + d4321 * ( mua ) ) / d4343;
  8080. mub = clamp( mub, 0.0, 1.0 );
  8081. return vec2( mua, mub );
  8082. }
  8083. void main() {
  8084. #include <clipping_planes_fragment>
  8085. #ifdef USE_DASH
  8086. if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
  8087. if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
  8088. #endif
  8089. float alpha = opacity;
  8090. #ifdef WORLD_UNITS
  8091. // Find the closest points on the view ray and the line segment
  8092. vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
  8093. vec3 lineDir = worldEnd - worldStart;
  8094. vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
  8095. vec3 p1 = worldStart + lineDir * params.x;
  8096. vec3 p2 = rayEnd * params.y;
  8097. vec3 delta = p1 - p2;
  8098. float len = length( delta );
  8099. float norm = len / linewidth;
  8100. #ifndef USE_DASH
  8101. #ifdef USE_ALPHA_TO_COVERAGE
  8102. float dnorm = fwidth( norm );
  8103. alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
  8104. #else
  8105. if ( norm > 0.5 ) {
  8106. discard;
  8107. }
  8108. #endif
  8109. #endif
  8110. #else
  8111. #ifdef USE_ALPHA_TO_COVERAGE
  8112. // artifacts appear on some hardware if a derivative is taken within a conditional
  8113. float a = vUv.x;
  8114. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8115. float len2 = a * a + b * b;
  8116. float dlen = fwidth( len2 );
  8117. if ( abs( vUv.y ) > 1.0 ) {
  8118. alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
  8119. }
  8120. #else
  8121. if ( abs( vUv.y ) > 1.0 ) {
  8122. float a = vUv.x;
  8123. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8124. float len2 = a * a + b * b;
  8125. if ( len2 > 1.0 ) discard;
  8126. }
  8127. #endif
  8128. #endif
  8129. vec4 diffuseColor = vec4( diffuse, alpha );
  8130. #include <logdepthbuf_fragment>
  8131. #include <color_fragment>
  8132. gl_FragColor = vec4( diffuseColor.rgb, alpha );
  8133. #include <tonemapping_fragment>
  8134. #include <colorspace_fragment>
  8135. #include <fog_fragment>
  8136. #include <premultiplied_alpha_fragment>
  8137. }
  8138. `};class fee extends Ah{constructor(e){super({type:"LineMaterial",uniforms:lL.clone(Rs.line.uniforms),vertexShader:Rs.line.vertexShader,fragmentShader:Rs.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 v7=new rl,X_=new qe;class mee extends OBe{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 Ti([-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 Ti([-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 ND(n,6,1);return this.setAttribute("instanceStart",new Jd(r,3,0)),this.setAttribute("instanceEnd",new Jd(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 ND(n,6,1);return this.setAttribute("instanceColorStart",new Jd(r,3,0)),this.setAttribute("instanceColorEnd",new Jd(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 TBe(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new rl);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),v7.setFromBufferAttribute(n),this.boundingBox.union(v7))}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 a=0,o=e.count;a<o;a++)X_.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(X_)),X_.fromBufferAttribute(n,a),i=Math.max(i,r.distanceToSquared(X_));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 w7=new qe,_7=new qe,Ta=new Cr,Aa=new Cr,Yl=new Cr,oj=new qe,lj=new zr,Ca=new LBe,S7=new qe,Y_=new rl,Q_=new hc,Ql=new Cr;let Zl,Tf;function N7(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 ZBe extends Dl{constructor(e=new mee,n=new fee({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)w7.fromBufferAttribute(n,o),_7.fromBufferAttribute(r,o),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+w7.distanceTo(_7);const a=new ND(i,2,1);return e.setAttribute("instanceDistanceStart",new Jd(a,1,0)),e.setAttribute("instanceDistanceEnd",new Jd(a,1,1)),this}raycast(e,n){const r=this.material.worldUnits,i=e.camera;i!==null||r||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const a=e.params.Line2!==void 0&&e.params.Line2.threshold||0;Zl=e.ray;const o=this.matrixWorld,l=this.geometry,c=this.material;let u,d;Tf=c.linewidth+a,l.boundingSphere===null&&l.computeBoundingSphere(),Q_.copy(l.boundingSphere).applyMatrix4(o),r?u=.5*Tf:u=N7(i,Math.max(i.near,Q_.distanceToPoint(Zl.origin)),c.resolution),Q_.radius+=u,Zl.intersectsSphere(Q_)!==!1&&(l.boundingBox===null&&l.computeBoundingBox(),Y_.copy(l.boundingBox).applyMatrix4(o),r?d=.5*Tf:d=N7(i,Math.max(i.near,Y_.distanceToPoint(Zl.origin)),c.resolution),Y_.expandByScalar(d),Zl.intersectsBox(Y_)!==!1&&(r?(function(f,p){const m=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(m);const M=new qe,T=new qe;Zl.distanceSqToSegment(Ca.start,Ca.end,T,M),T.distanceTo(M)<.5*Tf&&p.push({point:T,pointOnLine:M,distance:Zl.origin.distanceTo(T),object:f,face:null,faceIndex:v,uv:null,uv1:null})}})(this,n):(function(f,p,m){const x=p.projectionMatrix,b=f.material.resolution,y=f.matrixWorld,v=f.geometry,S=v.attributes.instanceStart,M=v.attributes.instanceEnd,T=Math.min(v.instanceCount,S.count),E=-p.near;Zl.at(1,Yl),Yl.w=1,Yl.applyMatrix4(p.matrixWorldInverse),Yl.applyMatrix4(x),Yl.multiplyScalar(1/Yl.w),Yl.x*=b.x/2,Yl.y*=b.y/2,Yl.z=0,oj.copy(Yl),lj.multiplyMatrices(p.matrixWorldInverse,y);for(let C=0,k=T;C<k;C++){if(Ta.fromBufferAttribute(S,C),Aa.fromBufferAttribute(M,C),Ta.w=1,Aa.w=1,Ta.applyMatrix4(lj),Aa.applyMatrix4(lj),Ta.z>E&&Aa.z>E)continue;if(Ta.z>E){const F=Ta.z-Aa.z,H=(Ta.z-E)/F;Ta.lerp(Aa,H)}else if(Aa.z>E){const F=Aa.z-Ta.z,H=(Aa.z-E)/F;Aa.lerp(Ta,H)}Ta.applyMatrix4(x),Aa.applyMatrix4(x),Ta.multiplyScalar(1/Ta.w),Aa.multiplyScalar(1/Aa.w),Ta.x*=b.x/2,Ta.y*=b.y/2,Aa.x*=b.x/2,Aa.y*=b.y/2,Ca.start.copy(Ta),Ca.start.z=0,Ca.end.copy(Aa),Ca.end.z=0;const R=Ca.closestPointToPointParameter(oj,!0);Ca.at(R,S7);const A=qJ.lerp(Ta.z,Aa.z,R),D=A>=-1&&A<=1,U=oj.distanceTo(S7)<.5*Tf;if(D&&U){Ca.start.fromBufferAttribute(S,C),Ca.end.fromBufferAttribute(M,C),Ca.start.applyMatrix4(y),Ca.end.applyMatrix4(y);const F=new qe,H=new qe;Zl.distanceSqToSegment(Ca.start,Ca.end,H,F),m.push({point:H,pointOnLine:F,distance:Zl.origin.distanceTo(H),object:f,face:null,faceIndex:C,uv:null,uv1:null})}}})(this,i,n)))}}class JBe extends _M{constructor(e,n,r,i,a=4473924,o=8947848){a=new Zt(a),o=new Zt(o);const l=Math.round(e/n);r=Math.round(r/i)*i/2;const c=[],u=[];let d=0;for(let p=-1*(e=l*n/2);p<=e;p+=n){c.push(p,0,-1*r,p,0,r);const m=p===0?a:o;m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3}for(let p=-1*r;p<=r;p+=i){c.push(-1*e,0,p,e,0,p);const m=p===0?a:o;m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3}const f=new ns;f.setAttribute("position",new Ti(c,3)),f.setAttribute("color",new Ti(u,3)),super(f,new pv({vertexColors:!0,toneMapped:!1}))}}function e8e(t,e,n,r){const i=(function(o,l,c){o*=.5,l*=.5,c*=.5;const u=new ns,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 Ti(d,3)),u})(t,e,n),a=new _M(i,new CBe({color:new Zt(r),dashSize:3,gapSize:1}));return a.computeLineDistances(),a}var N0=function(){var t=0,e=document.createElement("div");function n(d){return e.appendChild(d.dom),d}function r(d){for(var f=0;f<e.children.length;f++)e.children[f].style.display=f===d?"block":"none";t=d}e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",(function(d){d.preventDefault(),r(++t%e.children.length)}),!1);var i=(performance||Date).now(),a=i,o=0,l=n(new N0.Panel("FPS","#0ff","#002")),c=n(new N0.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new N0.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>=a+1e3&&(l.update(1e3*o/(d-a),100),a=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}};N0.Panel=function(t,e,n){var r=1/0,i=0,a=Math.round,o=a(window.devicePixelRatio||1),l=80*o,c=48*o,u=3*o,d=2*o,f=3*o,p=15*o,m=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,p,m,x),y.fillStyle=n,y.globalAlpha=.9,y.fillRect(f,p,m,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,p),y.fillStyle=e,y.fillText(a(v)+" "+t+" ("+a(r)+"-"+a(i)+")",u,d),y.drawImage(b,f+o,p,m-o,x,f,p,m-o,x),y.fillRect(f+m-o,p,o,x),y.fillStyle=n,y.globalAlpha=.9,y.fillRect(f+m-o,p,o,a((1-v/S)*x))}}};var t8e=N0;class M7{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new iN,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 iN,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 n8e extends ns{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 a=new qe,o=new qe,l=new xn,c=[],u=[],d=[],f=[];function p(m){const[x,b,y]=(function(v){const S=e[v],M=new qe,T=new qe,E=new qe,C=new qe;M.copy(S).sub(e[v-1]||S).normalize().add((e[v+1]||S).clone().sub(S).normalize()).normalize();let k=Number.MAX_VALUE;const R=Math.abs(M.x),A=Math.abs(M.y),D=Math.abs(M.z);return R<=k&&(k=R,T.set(1,0,0)),A<=k&&(k=A,T.set(0,1,0)),D<=k&&T.set(0,0,1),C.crossVectors(M,T).normalize(),T.crossVectors(M,C),E.crossVectors(M,T),[S,T,E]})(m);for(let v=0;v<=i;v++){const S=v/i*Math.PI*2,M=Math.sin(S),T=-Math.cos(S);o.x=T*b.x+M*y.x,o.y=T*b.y+M*y.y,o.z=T*b.z+M*y.z,o.normalize(),u.push(o.x,o.y,o.z),a.x=x.x+n*o.x*.5,a.y=x.y+n*o.y*.5,a.z=x.z+r*o.z*.5,c.push(a.x,a.y,a.z)}}(function(){for(let m=0;m<e.length;m++)p(m);p(closed===!1?e.length-1:0),(function(){for(let m=0;m<e.length;m++)for(let x=0;x<=i;x++)l.x=m/e.length,l.y=x/i,d.push(l.x,l.y)})(),(function(){for(let m=1;m<e.length;m++)for(let x=1;x<=i;x++){const b=(i+1)*(m-1)+(x-1),y=(i+1)*m+(x-1),v=(i+1)*m+x,S=(i+1)*(m-1)+x;f.push(b,y,S),f.push(y,v,S)}})()})(),this.setIndex(f),this.setAttribute("position",new Ti(c,3)),this.setAttribute("normal",new Ti(u,3)),this.setAttribute("uv",new Ti(d,2))}}class M0{static get initial(){const e=new M0;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const cj={h:0,s:0,l:0};class Dg{constructor(e){var n,r,i,a,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=M0.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=Dg.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new Zt(14737632),this._travelColor=new Zt(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 aN(this.minLayerThreshold),this.scene=new bBe,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new Zt(e.backgroundColor)),this.targetId=e.targetId,this.endLayer=e.endLayer,this.startLayer=e.startLayer,this.lineWidth=e.lineWidth,this.lineHeight=e.lineHeight,this.buildVolume=e.buildVolume,this.initialCameraPosition=(r=e.initialCameraPosition)!==null&&r!==void 0?r:this.initialCameraPosition,this.debug=(i=e.debug)!==null&&i!==void 0?i:this.debug,this.renderExtrusion=(a=e.renderExtrusion)!==null&&a!==void 0?a:this.renderExtrusion,this.renderTravel=(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 t8e:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new Zt(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new Zt(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new Zt(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[m,x]of Object.entries(e.toolColors))this._toolColors[parseInt(m)]=new Zt(x)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+xM),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 SD({canvas:this.canvas,preserveDrawingBuffer:!0});else{if(!this.targetId)throw Error("Set either opts.canvas or opts.targetId");const m=document.getElementById(this.targetId);if(!m)throw new Error("Unable to find element "+this.targetId);this.renderer=new SD({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,m.appendChild(this.canvas)}this.camera=new oo(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const f=this.camera.far,p=.8*f;this.scene.fog=new dL(this._backgroundColor,p,f),this.resize(),this.controls=new QBe(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 Zt(r)}else this._extrusionColor=new Zt(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?Dg.defaultExtrusionColor:this._extrusionColor instanceof Zt?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:Dg.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new Zt(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new Zt(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new Zt(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new Zt(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 FBe(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 RBe(13421772,.3*Math.PI),n=new DBe(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 u0;return n.name=e,n.quaternion.setFromEuler(new fv(-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=M0.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 aj(this,void 0,void 0,(function*(){return this.initScene(),this.renderLayerIndex=0,this.renderFrameLoop(e>0?e:1)}))}renderFrameLoop(e){return new Promise((n=>{const r=()=>{this.renderLayerIndex>this.layers.length-1?n():(this.renderFrame(e),requestAnimationFrame(r))};r()}))}renderFrame(e){this.group=this.createGroup("layer"+this.renderLayerIndex);for(let n=0;n<e&&this.renderLayerIndex+n<this.layers.length;n++)this.renderLayer(this.renderLayerIndex),this.renderLayerIndex++;this.batchGeometries(),this.scene.add(this.group)}renderLayer(e){var n,r,i,a,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 p of d.commands)if(p.gcode!="g20"){if(p.gcode.startsWith("t")){this.doRenderExtrusion(f,e),f.extrusion=[];const m=p;this.state.t=m.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(p.gcode)>-1){const m=p,x={x:(n=m.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=m.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=m.params.z)!==null&&i!==void 0?i:this.state.z,r:(a=m.params.r)!==null&&a!==void 0?a:this.state.r,e:(o=m.params.e)!==null&&o!==void 0?o:this.state.e,i:(l=m.params.i)!==null&&l!==void 0?l:this.state.i,j:(c=m.params.j)!==null&&c!==void 0?c:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const b=((u=m.params.e)!==null&&u!==void 0?u:0)>0||this.nonTravelmoves.indexOf(p.gcode)>-1;(x.x!=this.state.x||x.y!=this.state.y||x.z!=this.state.z)&&(b&&this.renderExtrusion||!b&&this.renderTravel)&&(p.gcode=="g2"||p.gcode=="g3"||p.gcode=="g02"||p.gcode=="g03"?this.addArcSegment(f,this.state,x,b,p.gcode=="g2"||p.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 a=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){const o=.1+.7*n/this.layers.length;a.getHSL(cj),a=new Zt().setHSL(cj.h,cj.s,o)}if(n==this.layers.length-1){const o=(r=this._topLayerColor)!==null&&r!==void 0?r:a,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,a.getHex(),e.height):this.addLine(e.extrusion,a.getHex())}this.renderTravel&&this.addLine(e.travel,this._travelColor.getHex())}setInches(){this.beyondFirstMove?console.warn("Switching units after movement is already made is discouraged and is not supported."):this.inches=!0}drawBuildVolume(){if(!this.buildVolume)return;this.scene.add(new JBe(this.buildVolume.x,10,this.buildVolume.y,10));const e=e8e(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 aN(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=M0.initial,(e=this.devGui)===null||e===void 0||e.reset(),this._geometries={}}resize(){const[e,n]=[this.canvas.offsetWidth,this.canvas.offsetHeight];this.camera.aspect=e/n,this.camera.updateProjectionMatrix(),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,n,!1)}addLineSegment(e,n,r,i){(i?e.extrusion:e.travel).push(n.x,n.y,n.z,r.x,r.y,r.z)}addArcSegment(e,n,r,i,a){const o=i?e.extrusion:e.travel,l=n.x,c=n.y,u=n.z,d=r.x,f=r.y,p=r.z;let m=r.r,x=r.i,b=r.j;if(m){const $=d-l,K=f-c,V=Math.sqrt(Math.pow($/2,2)+Math.pow(K/2,2));m=Math.max(m,V);const Q=Math.pow($,2)+Math.pow(K,2),Z=Math.pow(m,2)-Q/4;let ae=Math.sqrt(Z/Q);(a&&m<0||!a&&m>0)&&(ae=-ae),x=$/2+K*ae,b=K/2-$*ae}const y=l==d&&c==f,v=l+x,S=c+b,M=Math.sqrt(x*x+b*b),T=Math.atan2(-b,-x),E=Math.atan2(f-S,d-v);let C;y?C=2*Math.PI:(C=a?T-E:E-T,C<0&&(C+=2*Math.PI));let k=M*C/1.8;this.inches&&(k*=25),k<1&&(k=1);let R=C/k;R*=a?-1:1;const A=[];A.push({x:l,y:c,z:u});const D=(u-p)/k;let U=l,F=c,H=u,j=T;for(let $=0;$<k-1;$++)j+=R,U=v+M*Math.cos(j),F=S+M*Math.sin(j),H+=D,A.push({x:U,y:F,z:H});A.push({x:r.x,y:r.y,z:r.z});for(let $=0;$<A.length-1;$++)o.push(A[$].x,A[$].y,A[$].z,A[$+1].x,A[$+1].y,A[$+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new ns;i.setAttribute("position",new Ti(e,3)),this.disposables.push(i);const a=new pv({color:n});this.disposables.push(a);const o=new _M(i,a);(r=this.group)===null||r===void 0||r.add(o)}addTubeLine(e,n,r=.2){let i=[];const a=[];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),a.push(i),i=[])}a.forEach((o=>{var l;const c=new n8e(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 mee;this.disposables.push(i);const a=new fee({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(a),i.setPositions(e);const o=new ZBe(i,a);(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=>aj(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 ABe({color:e,wireframe:this._wireframe});this.disposables.push(i);const a=r.reduce(((l,c)=>3*c.attributes.position.count+l),0),o=new EBe(r.length,a,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 aj(this,void 0,void 0,(function*(){const i=e.getReader();let a,o="",l=0;do{console.debug("reading from stream"),a=yield i.read(),l+=(r=(n=a.value)===null||n===void 0?void 0:n.length)!==null&&r!==void 0?r:0;const u=(c=a.value,new TextDecoder("utf-8").decode(c)),d=u.lastIndexOf(`
  8139. `),f=u.slice(0,d);this.parser.parseGCode(o+f),o=u.slice(d)}while(!a.done);var c;console.debug("read from stream",l)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new M7(this):typeof this.devMode=="object"&&(this.devGui=new M7(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())}}Dg.defaultExtrusionColor=new Zt("hotpink");function r8e({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=_.useRef(null),a=_.useRef(null),o=_.useRef(null),l=_.useRef(!1),[c,u]=_.useState(!0),[d,f]=_.useState(null),[p,m]=_.useState(!1),[x,b]=_.useState(0),[y,v]=_.useState(0),S=_.useMemo(()=>JSON.stringify(n),[n]);_.useEffect(()=>{if(!i.current||l.current)return;l.current=!0;const E=i.current,C=E.parentElement?.getBoundingClientRect();C&&(E.width=C.width,E.height=C.height);const k=n&&n.length>1,R=n?.[0]||"#00ae42",A=new Dg({canvas:E,buildVolume:e,backgroundColor:1710618,extrusionColor:k?n:R,disableGradient:!0,lineHeight:.2,lineWidth:2,renderTravel:!1,renderExtrusion:!0});a.current=A,fetch(t).then(async U=>{if(!U.ok)throw U.status===404&&(await U.json().catch(()=>({}))).detail?.includes("sliced")?(m(!0),new Error("not_sliced")):new Error("Failed to load G-code");return U.text()}).then(U=>{const F=new Set,H=/^(\s*)T(\d+)(\s*;.*)?$/gim;let j;for(;(j=H.exec(U))!==null;){const ae=parseInt(j[2],10);ae<=15&&F.add(ae)}const $=new Map,K=Array.from(F).sort((ae,B)=>ae-B);K.forEach((ae,B)=>{$.set(ae,B%8)});const V=[];K.forEach((ae,B)=>{const X=n?.[ae]||"#00ae42";V[B%8]=X});const Q=U.split(`
  8140. `).map(ae=>{const B=ae.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(B){const X=parseInt(B[2],10);if(X>15)return`; FILTERED: ${ae.trim()}`;const ne=$.get(X)??0;return`${B[1]}T${ne}${B[3]||""}`}return ae}).join(`
  8141. `);V.length>0&&(A.extrusionColor=V),A.processGCode(Q);const Z=A.layers?.length||0;v(Z),b(Z),A.render(),u(!1)}).catch(U=>{U.message!=="not_sliced"&&f(U.message),u(!1)});const D=()=>{if(E.parentElement&&a.current){const U=E.parentElement.getBoundingClientRect();E.width=U.width,E.height=U.height,a.current.resize()}};return window.addEventListener("resize",D),()=>{window.removeEventListener("resize",D),o.current&&cancelAnimationFrame(o.current),a.current&&(a.current.dispose(),a.current=null),l.current=!1}},[t,S]);const M=_.useCallback(E=>{if(!a.current)return;const C=Math.max(1,Math.min(E,y));b(C),o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{a.current&&(a.current.endLayer=C,a.current.render())})},[y]),T=E=>{M(parseInt(E.target.value,10))};return s.jsxs("div",{className:`relative flex flex-col h-full ${r}`,children:[s.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsx("canvas",{ref:i,className:"w-full h-full"}),c&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsxs("div",{className:"text-center",children:[s.jsx(ht,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),s.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),p&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsxs("div",{className:"text-center max-w-sm px-4",children:[s.jsx(Eue,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),s.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),s.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&&!p&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsx("div",{className:"text-center text-red-400",children:s.jsx("p",{className:"text-sm",children:d})})})]}),!c&&!d&&!p&&y>0&&s.jsx("div",{className:"mt-4 px-2",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(sl,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("button",{onClick:()=>M(x-1),disabled:x<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:s.jsx(gh,{className:"w-4 h-4"})}),s.jsx("input",{type:"range",min:1,max:y,value:x,onChange:T,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),s.jsx("button",{onClick:()=>M(x+1),disabled:x>=y,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:s.jsx(gs,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[x," / ",y]})]})})]})}function pee({archiveId:t,title:e,onClose:n}){const[r,i]=_.useState(null),[a,o]=_.useState(null),[l,c]=_.useState(!0);_.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),_.useEffect(()=>{ue.getArchiveCapabilities(t).then(d=>{o(d),d.has_model?i("3d"):d.has_gcode&&i("gcode"),c(!1)}).catch(()=>{o({has_model:!0,has_gcode:!1,has_source:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),i("3d"),c(!1)})},[t]);const u=()=>{const d=e||"model",f=`${window.location.origin}${ue.getArchiveForSlicer(t,d)}`;mu(f)};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:n,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-4xl h-[80vh] flex flex-col",onClick:d=>d.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:e}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Te,{variant:"secondary",size:"sm",onClick:u,children:[s.jsx(Kr,{className:"w-4 h-4"}),"Open in Slicer"]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:n,children:s.jsx(Rt,{className:"w-5 h-5"})})]})]}),a&&s.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[s.jsxs("button",{onClick:()=>a.has_model&&i("3d"),disabled:!a.has_model,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="3d"?"text-bambu-green border-b-2 border-bambu-green":a.has_model?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[s.jsx(lo,{className:"w-4 h-4"}),"3D Model",!a.has_model&&s.jsx("span",{className:"text-xs",children:"(not available)"})]}),s.jsxs("button",{onClick:()=>a.has_gcode&&i("gcode"),disabled:!a.has_gcode,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="gcode"?"text-bambu-green border-b-2 border-bambu-green":a.has_gcode?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[s.jsx(eue,{className:"w-4 h-4"}),"G-code Preview",!a.has_gcode&&s.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),s.jsx("div",{className:"flex-1 overflow-hidden p-4",children:l?s.jsx("div",{className:"w-full h-full flex items-center justify-center",children:s.jsx(ht,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&a?s.jsx(eLe,{url:a.has_source?ue.getSource3mfDownloadUrl(t):ue.getArchiveDownload(t),buildVolume:a.build_volume,filamentColors:a.filament_colors,className:"w-full h-full"}):r==="gcode"&&a?s.jsx(r8e,{gcodeUrl:ue.getArchiveGcode(t),filamentColors:a.filament_colors,className:"w-full h-full"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}const E7={"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 i8e(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),a=Math.max(n,r,i)/255,o=Math.min(n,r,i)/255,l=(a+o)/2;let c=0,u=0;if(a!==o){const d=a-o;u=l>.5?d/(2-a-o):d/(a+o);const f=n/255,p=r/255,m=i/255;a===f?c=((p-m)/d+(p<m?6:0))/6:a===p?c=((m-f)/d+2)/6:c=((f-p)/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 E7[e]?E7[e]:i8e(t)}function sN(t){return t?`#${t.replace("#","").substring(0,6)}`:"#808080"}function va(t){return t?t.replace("#","").toLowerCase().substring(0,6):""}function Ch(t,e,n=40){const r=va(t),i=va(e);if(!r||!i||r.length<6||i.length<6)return!1;const a=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(a-c)<=n&&Math.abs(o-u)<=n&&Math.abs(l-d)<=n}function gee(t,e,n,r){const i=String.fromCharCode(65+(t>=128?t-128:t));return n?`HT-${i}`:`AMS-${i} Slot ${e+1}`}function xee(t,e,n){return t*4+e}function a8e(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 s8e(){const t=new Date;return t.setMinutes(t.getMinutes()+1),t.toISOString().slice(0,16)}function k7(t){if(!t)return!1;const e=Date.now()+4320*60*60*1e3;return new Date(t).getTime()>e}function mL(t){const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const a=sN(i.tray_color);e.push({type:i.tray_type,color:a,colorName:sx(a),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:gee(n.id,i.id,r),globalTrayId:xee(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=sN(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 T7(t,e){if(!t?.filaments||t.filaments.length===0)return;const n=mL(e);if(n.length===0)return;const r=new Set,i=t.filaments.map(l=>{const c=n.find(p=>!r.has(p.globalTrayId)&&p.type?.toUpperCase()===l.type?.toUpperCase()&&va(p.color)===va(l.color)),u=!c&&n.find(p=>!r.has(p.globalTrayId)&&p.type?.toUpperCase()===l.type?.toUpperCase()&&Ch(p.color,l.color)),d=!c&&!u&&n.find(p=>!r.has(p.globalTrayId)&&p.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}}),a=Math.max(...i.map(l=>l.slot_id||0));if(a<=0)return;const o=new Array(a).fill(-1);return i.forEach(l=>{l.slot_id&&l.slot_id>0&&(o[l.slot_id-1]=l.globalTrayId)}),o}function o8e(t){return _.useMemo(()=>{const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const a=sN(i.tray_color);e.push({type:i.tray_type,color:a,colorName:sx(a),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:gee(n.id,i.id,r),globalTrayId:xee(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=sN(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 bee(t,e,n){const r=o8e(e),i=_.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 M=n[d],T=r.find(E=>E.globalTrayId===M);if(T){const E=T.type?.toUpperCase()===u.type?.toUpperCase(),C=va(T.color)===va(u.color)||Ch(T.color,u.color);let k;return E&&C?k="match":E?k="type_only":k="mismatch",{...u,loaded:T,hasFilament:!0,typeMatch:E,colorMatch:C,status:k,isManual:!0}}}const f=r.find(M=>!c.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase()&&va(M.color)===va(u.color)),p=!f&&r.find(M=>!c.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase()&&Ch(M.color,u.color)),m=!f&&!p&&r.find(M=>!c.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase()),x=f||p||m||void 0;x&&c.add(x.globalTrayId);const b=!!x,y=b,v=!!f||!!p;let S;return f||p?S="match":m?S="type_only":S="mismatch",{...u,loaded:x,hasFilament:b,typeMatch:y,colorMatch:v,status:S,isManual:!1}})},[t,r,n]),a=_.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:a,hasTypeMismatch:o,hasColorMismatch:l}}function l8e(t,e,n){if(!t||t.length===0)return{exactMatches:0,typeOnlyMatches:0,missingTypes:0,totalSlots:0,status:"full"};let r=0,i=0,a=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=va(y.color)===va(u.color)||Ch(y.color,u.color);v&&S?r++:v?i++:a++;continue}}const f=e.find(b=>!o.has(b.globalTrayId)&&b.type?.toUpperCase()===u.type?.toUpperCase()&&va(b.color)===va(u.color)),p=f?void 0:e.find(b=>!o.has(b.globalTrayId)&&b.type?.toUpperCase()===u.type?.toUpperCase()&&Ch(b.color,u.color)),m=f||p?void 0:e.find(b=>!o.has(b.globalTrayId)&&b.type?.toUpperCase()===u.type?.toUpperCase()),x=f??p??m;x&&o.add(x.globalTrayId),f||p?r++:m?i++:a++}const l=t.length;let c="full";return a>0?c="missing":i>0&&(c="partial"),{exactMatches:r,typeOnlyMatches:i,missingTypes:a,totalSlots:l,status:c}}function c8e(t,e,n){if(!t?.filaments||t.filaments.length===0)return;const r=mL(e);if(r.length===0)return;const i=new Set(Object.values(n)),a=[];for(const c of t.filaments){const u=c.slot_id||0;if(u>0&&n[u]!==void 0){a.push({slot_id:u,globalTrayId:n[u]});continue}const d=r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()&&va(x.color)===va(c.color)),f=d?void 0:r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()&&Ch(x.color,c.color)),p=d||f?void 0:r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()),m=d??f??p;m&&i.add(m.globalTrayId),a.push({slot_id:u,globalTrayId:m?.globalTrayId??-1})}const o=Math.max(...a.map(c=>c.slot_id||0));if(o<=0)return;const l=new Array(o).fill(-1);return a.forEach(c=>{c.slot_id&&c.slot_id>0&&(l[c.slot_id-1]=c.globalTrayId)}),l}const A7={useDefault:!0,manualMappings:{},autoConfigured:!1};function u8e(t,e,n,r,i,a){const o=dW({queries:t.map(x=>({queryKey:["printer-status",x],queryFn:()=>ue.getPrinterStatus(x),enabled:t.length>0,staleTime:5e3}))}),l=_.useMemo(()=>t.map((x,b)=>{const y=o[b],v=y?.data,M=e?.find(D=>D.id===x)?.name||`Printer ${x}`,T=mL(v),E=i[x]||A7,C=T7(n,v),k=E.useDefault?r:E.manualMappings,R=c8e(n,v,k),A=l8e(n?.filaments,T,k);return{printerId:x,printerName:M,status:v,isLoading:y?.isLoading??!1,loadedFilaments:T,autoMapping:C,finalMapping:R,matchStatus:A.status,exactMatches:A.exactMatches,typeOnlyMatches:A.typeOnlyMatches,missingTypes:A.missingTypes,totalSlots:A.totalSlots,config:E}}),[t,o,e,n,i,r]),c=o.some(x=>x.isLoading),u=(x,b)=>{a(y=>({...y,[x]:{...y[x]||A7,...b}}))},d=x=>{const b=l.find(S=>S.printerId===x);if(!b||!b.status||!n?.filaments)return;const y=T7(n,b.status);if(!y)return;const v={};y.forEach((S,M)=>{S!==-1&&(v[M+1]=S)}),u(x,{useDefault:!1,manualMappings:v,autoConfigured:!0})},f=()=>{for(const x of t)d(x)},p=x=>l.find(y=>y.printerId===x)?.finalMapping,m=l.every(x=>x.matchStatus!=="missing");return{printerResults:l,isLoading:c,perPrinterConfigs:i,updatePrinterConfig:u,autoConfigureAll:f,autoConfigurePrinter:d,getFinalMapping:p,allPrintersReady:m}}function d8e({printerResult:t,filamentReqs:e,onUpdateConfig:n}){const r=an(),[i,a]=_.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()=>{a(!0);try{await ue.refreshPrinterStatus(t.printerId),await new Promise(u=>setTimeout(u,500)),await r.refetchQueries({queryKey:["printer-status",t.printerId]})}finally{a(!1)}},c=e.map(u=>{const d=u.slot_id||0,f=t.config.manualMappings[d];let p,m=!1;if(f!==void 0)p=t.loadedFilaments.find(b=>b.globalTrayId===f),m=!0;else{const b=new Set(Object.values(t.config.manualMappings)),y=t.loadedFilaments.find(M=>!b.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase()&&va(M.color)===va(u.color)),v=y?void 0:t.loadedFilaments.find(M=>!b.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase()&&Ch(M.color,u.color)),S=y||v?void 0:t.loadedFilaments.find(M=>!b.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase());p=y??v??S}let x="mismatch";if(p){const b=p.type?.toUpperCase()===u.type?.toUpperCase(),y=va(p.color)===va(u.color)||Ch(p.color,u.color);b&&y?x="match":b&&(x="type_only")}return{req:u,loaded:p,status:x,isManual:m}});return s.jsxs("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Custom slot mapping"}),s.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:[s.jsx(Dr,{className:`w-3 h-3 ${i?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]})]}),c.map(({req:u,loaded:d,status:f,isManual:p},m)=>s.jsxs("div",{className:"grid items-center gap-2 text-xs",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 16px"},children:[s.jsx("span",{title:`Required: ${u.type} - ${sx(u.color)}`,children:s.jsx(dP,{className:"w-3 h-3",fill:u.color,stroke:u.color})}),s.jsxs("span",{className:"text-white truncate",children:[u.type," ",s.jsxs("span",{className:"text-bambu-gray",children:["(",u.used_grams,"g)"]})]}),s.jsx("span",{className:"text-bambu-gray",children:"→"}),s.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"} ${p?"ring-1 ring-blue-400/50":""}`,title:p?"Manually selected":"Auto-matched",children:[s.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),t.loadedFilaments.map(x=>s.jsxs("option",{value:x.globalTrayId,className:"bg-bambu-dark text-white",children:[x.label,": ",x.type," (",x.colorName,")"]},x.globalTrayId))]}),f==="match"?s.jsx(Ia,{className:"w-3 h-3 text-bambu-green"}):f==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(Cn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(Cn,{className:"w-3 h-3 text-orange-400"})})]},m))]})}function h8e({printers:t,selectedPrinterIds:e,onMultiSelect:n,isLoading:r=!1,allowMultiple:i=!1,showInactive:a=!1,printerMappingResults:o,filamentReqs:l,onAutoConfigurePrinter:c,onUpdatePrinterConfig:u,assignmentMode:d="printer",onAssignmentModeChange:f,targetModel:p,onTargetModelChange:m,targetLocation:x,onTargetLocationChange:b,slicedForModel:y}){const[v,S]=_.useState(!1),M=a?t:t.filter(V=>V.is_active),T=_.useMemo(()=>{if(d!=="printer"||!y||v)return M;const V=M.filter(Q=>Q.model===y);return V.length>0?V:M},[M,d,y,v]),E=M.length-T.length,C=_.useMemo(()=>{const V=M.map(Q=>Q.model).filter(Q=>!!Q);return[...new Set(V)].sort()},[M]),k=_.useMemo(()=>{if(!p)return[];const V=M.filter(Q=>Q.model===p&&Q.location).map(Q=>Q.location).filter(Q=>!!Q);return[...new Set(V)].sort()},[M,p]),R=f&&m&&C.length>0,A=i&&e.length>1&&o&&l?.filaments&&l.filaments.length>0&&c&&u;if(r)return s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(T.length===0)return s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm mb-4",children:[s.jsx($i,{className:"w-4 h-4"}),"No ",a?"":"active ","printers available"]});const D=V=>{i?e.includes(V)?n(e.filter(Q=>Q!==V)):n([...e,V]):n([V])},U=()=>{n(T.map(V=>V.id))},F=()=>{n([])},H=(V,Q,Z)=>{Z.stopPropagation(),!(!c||!u)&&(Q?c(V):u(V,{useDefault:!0,manualMappings:{},autoConfigured:!1}))},j=V=>e.includes(V),$=e.length,K=V=>o?.find(Q=>Q.printerId===V);return s.jsxs("div",{className:"space-y-2 mb-6",children:[R&&s.jsxs("div",{className:"flex gap-2 mb-4",children:[s.jsxs("button",{type:"button",onClick:()=>{f("printer"),m(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:[s.jsx(Ur,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm",children:"Specific Printer"})]}),s.jsxs("button",{type:"button",onClick:()=>{f("model"),n([]);const V=y&&C.includes(y)?y:C[0];m(V)},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:[s.jsx(mg,{className:"w-4 h-4"}),s.jsxs("span",{className:"text-sm",children:["Any ",y||"Model"]})]})]}),d==="model"&&R&&s.jsxs("div",{className:"space-y-3 mb-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Target Model"}),s.jsxs("select",{value:p||"",onChange:V=>{m(V.target.value||null),b&&b(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 text-sm",children:[s.jsx("option",{value:"",children:"Select a model..."}),C.map(V=>s.jsx("option",{value:V,children:V},V))]})]}),p&&k.length>0&&b&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Location Filter (optional)"}),s.jsxs("select",{value:x||"",onChange:V=>b(V.target.value||null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm",children:[s.jsx("option",{value:"",children:"Any location"}),k.map(V=>s.jsx("option",{value:V,children:V},V))]})]}),p&&s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Scheduler will assign to first available idle ",p," printer",x?` in ${x}`:""]})]}),d==="printer"&&i&&T.length>1&&s.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray mb-2",children:[s.jsx("span",{children:$===0?"Select printers":`${$} printer${$!==1?"s":""} selected`}),s.jsxs("div",{className:"flex gap-2",children:[$<T.length&&s.jsx("button",{type:"button",onClick:U,className:"text-bambu-green hover:text-bambu-green/80 transition-colors",children:"Select all"}),$>0&&s.jsx("button",{type:"button",onClick:F,className:"text-bambu-gray hover:text-white transition-colors",children:"Clear"})]})]}),d==="printer"&&T.map(V=>{const Q=j(V.id),Z=K(V.id),ae=Z&&!Z.config.useDefault;return s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>D(V.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${Q?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"} ${V.is_active?"":"opacity-60"}`,children:[s.jsx("div",{className:`p-2 rounded-lg ${Q?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:s.jsx(Ur,{className:`w-5 h-5 ${Q?"text-bambu-green":"text-bambu-gray"}`})}),s.jsxs("div",{className:"text-left flex-1",children:[s.jsxs("p",{className:"text-white font-medium",children:[V.name,!V.is_active&&s.jsx("span",{className:"text-bambu-gray text-xs ml-2",children:"(inactive)"})]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[V.model||"Unknown model"," • ",V.ip_address]})]}),i&&s.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${Q?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:Q&&s.jsx(Ia,{className:"w-3 h-3 text-white"})})]}),Q&&A&&Z&&s.jsxs("div",{className:"ml-4 mt-2 mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",onClick:B=>B.stopPropagation(),children:[s.jsx("input",{type:"checkbox",checked:ae,onChange:B=>H(V.id,B.target.checked,B),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"}),s.jsx("span",{className:"text-xs text-bambu-gray",children:"Custom mapping"})]}),s.jsxs("span",{className:`text-xs ml-2 ${Z.matchStatus==="full"?"text-bambu-green":Z.matchStatus==="partial"?"text-yellow-400":"text-orange-400"}`,children:["(",Z.exactMatches,"/",Z.totalSlots," matched)"]}),Z.isLoading&&s.jsx(Dr,{className:"w-3 h-3 text-bambu-gray animate-spin"}),ae&&s.jsxs("button",{type:"button",onClick:B=>{B.stopPropagation(),c(V.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:[s.jsx(ufe,{className:"w-3 h-3"}),"Auto"]})]}),ae&&s.jsx(d8e,{printerResult:Z,filamentReqs:l.filaments,onUpdateConfig:B=>u(V.id,B)})]})]},V.id)}),d==="printer"&&E>0&&!v&&s.jsxs("button",{type:"button",onClick:()=>S(!0),className:"text-xs text-bambu-gray hover:text-white transition-colors mt-2 flex items-center gap-1",children:[s.jsx(Cn,{className:"w-3 h-3 text-yellow-400"}),E," other printer",E>1?"s":""," hidden (different model) —",s.jsx("span",{className:"underline",children:"show all"})]}),d==="printer"&&v&&y&&s.jsx("button",{type:"button",onClick:()=>S(!1),className:"text-xs text-bambu-gray hover:text-white transition-colors mt-2",children:s.jsxs("span",{className:"underline",children:["Show only ",y," printers"]})}),d==="printer"&&$===0&&s.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[s.jsx($i,{className:"w-3 h-3"}),"Select at least one printer"]}),d==="model"&&!p&&s.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[s.jsx($i,{className:"w-3 h-3"}),"Select a target printer model"]})]})}function f8e({plates:t,isMultiPlate:e,selectedPlate:n,onSelect:r}){return!e||t.length<=1?null:s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(sl,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Select Plate to Print"}),!n&&s.jsxs("span",{className:"text-xs text-orange-400 flex items-center gap-1",children:[s.jsx(Cn,{className:"w-3 h-3"}),"Selection required"]})]}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:t.map(i=>s.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?s.jsx("img",{src:i.thumbnail_url,alt:`Plate ${i.index}`,className:"w-10 h-10 rounded object-cover bg-bambu-dark-tertiary"}):s.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:s.jsx(sl,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-sm text-white font-medium truncate",children:i.name||`Plate ${i.index}`}),s.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?` • ${a8e(i.print_time_seconds)}`:""]})]}),n===i.index&&s.jsx(Ia,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},i.index))})]})}function m8e({printerId:t,filamentReqs:e,manualMappings:n,onManualMappingChange:r,defaultExpanded:i=!1}){const a=an(),[o,l]=_.useState(!1),[c,u]=_.useState(i),{data:d}=at({queryKey:["printer-status",t],queryFn:()=>ue.getPrinterStatus(t),enabled:!!t}),{loadedFilaments:f,filamentComparison:p,hasTypeMismatch:m,hasColorMismatch:x}=bee(e,d,n);if(!(e?.filaments&&e.filaments.length>0)||!d)return null;const y=m?"#f97316":x?"#facc15":"#00ae42",v=(M,T)=>{if(M>0)if(T===""){const E={...n};delete E[M],r(E)}else r({...n,[M]:parseInt(T,10)})},S=async()=>{l(!0);try{await ue.refreshPrinterStatus(t),await new Promise(M=>setTimeout(M,500)),await a.refetchQueries({queryKey:["printer-status",t]})}finally{l(!1)}};return s.jsxs("div",{className:"mb-4",children:[s.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:[s.jsx(dP,{className:"w-4 h-4",fill:y,stroke:"none"}),s.jsx("span",{children:"Filament Mapping"}),m?s.jsx("span",{className:"text-xs text-orange-400",children:"(Type not found)"}):x?s.jsx("span",{className:"text-xs text-yellow-400",children:"(Color mismatch)"}):s.jsx("span",{className:"text-xs text-bambu-green",children:"(Ready)"}),c?s.jsx(xh,{className:"w-4 h-4 ml-auto"}):s.jsx(ei,{className:"w-4 h-4 ml-auto"})]}),c&&s.jsxs("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Click to change slot assignment"}),s.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:[s.jsx(Dr,{className:`w-3 h-3 ${o?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]})]}),p.map((M,T)=>s.jsxs("div",{className:"grid items-center gap-2 text-xs",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 16px"},children:[s.jsx("span",{title:`Required: ${M.type} - ${sx(M.color)}`,children:s.jsx(dP,{className:"w-3 h-3",fill:M.color,stroke:M.color})}),s.jsxs("span",{className:"text-white truncate",children:[M.type," ",s.jsxs("span",{className:"text-bambu-gray",children:["(",M.used_grams,"g)"]})]}),s.jsx("span",{className:"text-bambu-gray",children:"→"}),s.jsxs("select",{value:M.loaded?.globalTrayId??"",onChange:E=>v(M.slot_id||0,E.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 ${M.status==="match"?"border-bambu-green/50 text-bambu-green":M.status==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${M.isManual?"ring-1 ring-blue-400/50":""}`,title:M.isManual?"Manually selected":"Auto-matched",children:[s.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),f.map(E=>s.jsxs("option",{value:E.globalTrayId,className:"bg-bambu-dark text-white",children:[E.label,": ",E.type," (",E.colorName,")"]},E.globalTrayId))]}),M.status==="match"?s.jsx(Ia,{className:"w-3 h-3 text-bambu-green"}):M.status==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(Cn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(Cn,{className:"w-3 h-3 text-orange-400"})})]},T)),m&&s.jsx("p",{className:"text-xs text-orange-400 mt-2",children:"Required filament type not found in printer."})]})]})}const p8e=[{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 g8e({options:t,onChange:e,defaultExpanded:n=!1}){const[r,i]=_.useState(n),a=o=>{e({...t,[o]:!t[o]})};return s.jsxs("div",{className:"mb-4",children:[s.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:[s.jsx(x2,{className:"w-4 h-4"}),s.jsx("span",{children:"Print Options"}),r?s.jsx(xh,{className:"w-4 h-4 ml-auto"}):s.jsx(ei,{className:"w-4 h-4 ml-auto"})]}),r&&s.jsx("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:p8e.map(({key:o,label:l,desc:c})=>s.jsxs("label",{className:"flex items-center justify-between cursor-pointer group",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-white",children:l}),s.jsx("p",{className:"text-xs text-bambu-gray",children:c})]}),s.jsx("div",{className:`relative w-10 h-5 rounded-full transition-colors ${t[o]?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,onClick:()=>a(o),children:s.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 x8e({options:t,onChange:e}){const n=r=>{e({...t,scheduleType:r})};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),s.jsxs("div",{className:"flex gap-2",children:[s.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:[s.jsx(Jn,{className:"w-4 h-4"}),"ASAP"]}),s.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:[s.jsx(si,{className:"w-4 h-4"}),"Scheduled"]}),s.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:[s.jsx(bW,{className:"w-4 h-4"}),"Queue Only"]})]})]}),t.scheduleType==="scheduled"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),s.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:s8e(),required:!0})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.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"}),s.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.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"}),s.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[s.jsx(Gu,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),s.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 Jp={bed_levelling:!0,flow_cali:!1,vibration_cali:!0,layer_inspect:!1,timelapse:!1},b8e={scheduleType:"asap",scheduledTime:"",requirePreviousSuccess:!1,autoOffAfter:!1};function jh({mode:t,archiveId:e,libraryFileId:n,archiveName:r,queueItem:i,onClose:a,onSuccess:o}){const{t:l}=$n(),c=an(),{showToast:u}=Hn(),d=!!n&&!e,[f,p]=_.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[m,x]=_.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[b,y]=_.useState(()=>t==="edit-queue-item"&&i?{bed_levelling:i.bed_levelling??Jp.bed_levelling,flow_cali:i.flow_cali??Jp.flow_cali,vibration_cali:i.vibration_cali??Jp.vibration_cali,layer_inspect:i.layer_inspect??Jp.layer_inspect,timelapse:i.timelapse??Jp.timelapse}:Jp),[v,S]=_.useState(()=>{if(t==="edit-queue-item"&&i){let Ve="asap";i.manual_start?Ve="manual":i.scheduled_time&&!k7(i.scheduled_time)&&(Ve="scheduled");let He="";return i.scheduled_time&&!k7(i.scheduled_time)&&(He=new Date(i.scheduled_time).toISOString().slice(0,16)),{scheduleType:Ve,scheduledTime:He,requirePreviousSuccess:i.require_previous_success,autoOffAfter:i.auto_off_after}}return b8e}),[M,T]=_.useState(()=>{if(t==="edit-queue-item"&&i?.ams_mapping&&Array.isArray(i.ams_mapping)){const Ve={};return i.ams_mapping.forEach((He,ye)=>{He!==-1&&(Ve[ye+1]=He)}),Ve}return{}}),[E,C]=_.useState({}),[k,R]=_.useState(()=>t==="edit-queue-item"&&i?.target_model?"model":"printer"),[A,D]=_.useState(()=>t==="edit-queue-item"&&i?.target_model?i.target_model:null),[U,F]=_.useState(()=>t==="edit-queue-item"&&i?.target_location?i.target_location:null),[H]=_.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[j]=_.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[$,K]=_.useState(!1),[V,Q]=_.useState({current:0,total:0}),[Z,ae]=_.useState(new Set),B=f.length,X=f.length>0?f[0]:null,{data:ne}=at({queryKey:["settings"],queryFn:ue.getSettings}),{data:se,isLoading:be}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:xe}=at({queryKey:["archive",e],queryFn:()=>ue.getArchive(e),enabled:!!e&&!d}),de=xe?.sliced_for_model||null,{data:Pe,isError:ie}=at({queryKey:["archive-plates",e],queryFn:()=>ue.getArchivePlates(e),enabled:!!e&&!d,retry:!1}),{data:Me}=at({queryKey:["library-file-plates",n],queryFn:()=>ue.getLibraryFilePlates(n),enabled:d&&!!n}),Oe=d?Me:Pe,{data:ge,isError:Ke}=at({queryKey:["archive-filaments",e,m],queryFn:()=>ue.getArchiveFilamentRequirements(e,m??void 0),enabled:!!e&&!d&&(m!==null||!Oe?.is_multi_plate),retry:!1}),{data:G}=at({queryKey:["library-file-filaments",n,m],queryFn:()=>ue.getLibraryFileFilamentRequirements(n,m??void 0),enabled:d&&!!n&&(m!==null||!Oe?.is_multi_plate)}),Y=!d&&(ie||Ke),ce=d?G:ge,{data:q}=at({queryKey:["printer-status",X],queryFn:()=>ue.getPrinterStatus(X),enabled:!!X}),{amsMapping:te}=bee(ce,q,M),I=u8e(f,se,ce,M,E,C);_.useEffect(()=>{Oe?.plates?.length===1&&!m&&x(Oe.plates[0].index)},[Oe,m]),_.useEffect(()=>{if(t==="edit-queue-item")return;const Ve=se?.filter(He=>He.is_active)||[];Ve.length===1&&f.length===0&&p([Ve[0].id])},[t,se,f.length]),_.useEffect(()=>{t==="edit-queue-item"?(JSON.stringify(f.sort())!==JSON.stringify(H.sort())||m!==j)&&(T({}),C({}),ae(new Set)):(T({}),C({}),ae(new Set))},[t,f,m,H,j]),_.useEffect(()=>{if(!ne?.per_printer_mapping_expanded||f.length<=1)return;const Ve=f.filter(He=>{if(Z.has(He))return!1;const ye=I.printerResults.find(je=>je.printerId===He);return ye&&ye.status&&!ye.isLoading});Ve.length>0&&(ae(He=>{const ye=new Set(He);return Ve.forEach(je=>ye.add(je)),ye}),Ve.forEach(He=>{I.autoConfigurePrinter(He)}))},[ne?.per_printer_mapping_expanded,f,Z,I]),_.useEffect(()=>{const Ve=He=>{He.key==="Escape"&&!$&&a()};return window.addEventListener("keydown",Ve),()=>window.removeEventListener("keydown",Ve)},[a,$]);const fe=Oe?.is_multi_plate??!1,me=Oe?.plates??[],ke=mt({mutationFn:Ve=>ue.addToQueue(Ve)}),z=mt({mutationFn:Ve=>ue.updateQueueItem(i.id,Ve),onSuccess:()=>{c.invalidateQueries({queryKey:["queue"]}),u("Queue item updated"),o?.(),a()},onError:Ve=>{u(Ve.message||"Failed to update queue item","error")}}),O=async Ve=>{if(Ve?.preventDefault(),k==="printer"&&f.length===0){u("Please select at least one printer","error");return}if(k==="model"&&!A){u("Please select a target printer model","error");return}K(!0);const He=k==="model"?1:f.length;Q({current:0,total:He});const ye={success:0,failed:0,errors:[]},je=Se=>{if(f.length>1){const Xe=E[Se];if(Xe&&!Xe.useDefault)return I.getFinalMapping(Se)}return te},Be=Se=>({printer_id:k==="printer"?Se:null,target_model:k==="model"?A:null,target_location:k==="model"?U:null,archive_id:d?void 0:e,library_file_id:d?n:void 0,require_previous_success:v.requirePreviousSuccess,auto_off_after:v.autoOffAfter,manual_start:v.scheduleType==="manual",ams_mapping:Se?je(Se):void 0,plate_id:m,scheduled_time:v.scheduleType==="scheduled"&&v.scheduledTime?new Date(v.scheduledTime).toISOString():void 0,...b});if(k==="model"){Q({current:1,total:1});try{if(t==="reprint"){u("Model-based assignment only works with queue mode","error"),K(!1);return}else if(t==="edit-queue-item"){const Se={printer_id:null,target_model:A,target_location:U,require_previous_success:v.requirePreviousSuccess,auto_off_after:v.autoOffAfter,manual_start:v.scheduleType==="manual",ams_mapping:void 0,plate_id:m,scheduled_time:v.scheduleType==="scheduled"&&v.scheduledTime?new Date(v.scheduledTime).toISOString():null,...b};await z.mutateAsync(Se)}else await ke.mutateAsync(Be(null));ye.success++}catch(Se){ye.failed++,ye.errors.push(Se.message)}}else for(let Se=0;Se<f.length;Se++){const Xe=f[Se];Q({current:Se+1,total:f.length});try{if(t==="reprint"){const Ne=je(Xe);d?await ue.printLibraryFile(n,Xe,{ams_mapping:Ne,...b}):await ue.reprintArchive(e,Xe,{plate_id:m??void 0,ams_mapping:Ne,...b})}else if(t==="edit-queue-item"&&Se===0){const Ne=je(Xe),tt={printer_id:Xe,target_model:null,target_location:null,require_previous_success:v.requirePreviousSuccess,auto_off_after:v.autoOffAfter,manual_start:v.scheduleType==="manual",ams_mapping:Ne,plate_id:m,scheduled_time:v.scheduleType==="scheduled"&&v.scheduledTime?new Date(v.scheduledTime).toISOString():null,...b};await z.mutateAsync(tt)}else await ke.mutateAsync(Be(Xe));ye.success++}catch(Ne){ye.failed++;const tt=se?.find(Ee=>Ee.id===Xe)?.name||`Printer ${Xe}`;ye.errors.push(`${tt}: ${Ne.message}`)}}if(K(!1),ye.failed===0){if(k==="model")u(t==="edit-queue-item"?"Queue item updated":`Queued for any ${A}`);else{const Se=t==="reprint"?"sent to":t==="edit-queue-item"?"updated/queued for":"queued for";ye.success===1?u(t==="edit-queue-item"?"Queue item updated":`Print ${Se} printer`):u(`Print ${Se} ${ye.success} printers`)}c.invalidateQueries({queryKey:["queue"]}),o?.(),a()}else ye.success===0?u(`Failed: ${ye.errors[0]}`,"error"):(u(`${ye.success} succeeded, ${ye.failed} failed`,"error"),c.invalidateQueries({queryKey:["queue"]}))},ee=$||z.isPending,le=_.useMemo(()=>!(ee||k==="printer"&&f.length===0||k==="model"&&!A||k==="model"&&t==="reprint"||!d&&fe&&!m),[f.length,k,A,t,fe,m,ee,d]),we=(()=>{const Ve=f.length;return t==="reprint"?{title:l(d?"queue.print":"queue.reprint"),icon:Ur,submitText:Ve>1?l("queue.printToPrinters",{count:Ve}):l("queue.print"),submitIcon:Ur,loadingText:V.total>1?l("queue.sendingProgress",{current:V.current,total:V.total}):l("queue.sending")}:t==="add-to-queue"?{title:l("queue.schedulePrint"),icon:si,submitText:Ve>1?l("queue.queueToPrinters",{count:Ve}):l("queue.addToQueue"),submitIcon:si,loadingText:V.total>1?l("queue.addingProgress",{current:V.current,total:V.total}):l("queue.adding")}:{title:l("queue.editQueueItem"),icon:Qi,submitText:l("common.save"),submitIcon:Qi,loadingText:V.total>1?l("queue.savingProgress",{current:V.current,total:V.total}):l("common.saving")}})(),re=we.icon,Fe=we.submitIcon,$e=X&&(d||(fe?m!==null:!0));return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:$?void 0:a,children:s.jsx(_t,{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto",onClick:Ve=>Ve.stopPropagation(),children:s.jsxs(Nt,{className:t==="reprint"?"":"p-0",children:[s.jsxs("div",{className:`flex items-center justify-between ${t==="reprint"?"mb-4":"p-4 border-b border-bambu-dark-tertiary"}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(re,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:we.title})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:a,disabled:$,children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:O,className:t==="reprint"?"":"p-4 space-y-4",children:[s.jsx("p",{className:`text-sm text-bambu-gray ${t==="reprint"?"mb-4":""}`,children:t==="reprint"?s.jsxs(s.Fragment,{children:["Send ",s.jsx("span",{className:"text-white",children:r})," to printer(s)"]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"block text-bambu-gray mb-1",children:"Print Job"}),s.jsx("span",{className:"text-white font-medium truncate block",children:r})]})}),s.jsx(f8e,{plates:me,isMultiPlate:fe,selectedPlate:m,onSelect:x}),s.jsx(h8e,{printers:se||[],selectedPrinterIds:f,onMultiSelect:p,isLoading:be,allowMultiple:!0,showInactive:t==="edit-queue-item",printerMappingResults:I.printerResults,filamentReqs:ce,onAutoConfigurePrinter:I.autoConfigurePrinter,onUpdatePrinterConfig:I.updatePrinterConfig,assignmentMode:t==="reprint"?"printer":k,onAssignmentModeChange:t!=="reprint"?R:void 0,targetModel:A,onTargetModelChange:t!=="reprint"?D:void 0,targetLocation:U,onTargetLocationChange:t!=="reprint"?F:void 0,slicedForModel:de}),de&&k==="printer"&&f.length===1&&(()=>{const Ve=se?.find(He=>He.id===f[0]);return Ve&&Ve.model&&de!==Ve.model?s.jsxs("div",{className:"p-3 mb-2 bg-yellow-500/10 border border-yellow-500/30 rounded-lg flex items-center gap-2",children:[s.jsx(Cn,{className:"w-4 h-4 text-yellow-400 flex-shrink-0"}),s.jsxs("span",{className:"text-sm text-yellow-400",children:["File was sliced for ",de,", but printing on ",Ve.model]})]}):null})(),Y&&s.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:[s.jsx($i,{className:"w-4 h-4 text-orange-400 mt-0.5 flex-shrink-0"}),s.jsx("p",{className:"text-orange-400",children:"Archive data unavailable. The source file may have been deleted. Filament mapping is disabled."})]}),$e&&!Y&&f.length===1&&s.jsx(m8e,{printerId:X,filamentReqs:ce,manualMappings:M,onManualMappingChange:T,defaultExpanded:ne?.per_printer_mapping_expanded??!1}),(t==="reprint"||B>0||k==="model"&&A)&&s.jsx(g8e,{options:b,onChange:y}),t!=="reprint"&&s.jsx(x8e,{options:v,onChange:S}),z.isError&&s.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:z.error?.message||"Failed to complete operation"}),s.jsxs("div",{className:`flex gap-3 ${t==="reprint"?"":"pt-2"}`,children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:a,className:"flex-1",disabled:$,children:"Cancel"}),s.jsx(Te,{type:"submit",disabled:!le,className:"flex-1",children:ee?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),we.loadingText]}):s.jsxs(s.Fragment,{children:[s.jsx(Fe,{className:"w-4 h-4"}),we.submitText]})})]})]})]})})})}function y8e({onClose:t,initialFiles:e}){const{t:n}=$n(),r=an(),{showToast:i}=Hn(),a=_.useRef(null),[o,l]=_.useState(()=>e?.filter(E=>E.name.endsWith(".3mf")).map(E=>({file:E,status:"pending"}))||[]),[c,u]=_.useState(!1),[d,f]=_.useState(null);_.useEffect(()=>{const E=C=>{C.key==="Escape"&&t()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[t]);const p=mt({mutationFn:E=>ue.uploadArchivesBulk(E),onSuccess:E=>{f(E),r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["archiveStats"]}),l(C=>C.map(k=>{const R=E.results.find(D=>D.filename===k.file.name),A=E.errors.find(D=>D.filename===k.file.name);return R?{...k,status:"success",archiveId:R.id}:A?{...k,status:"error",error:A.error}:k})),E.failed===0?i(`${E.uploaded} file${E.uploaded!==1?"s":""} uploaded`):E.uploaded===0?i(`Failed to upload ${E.failed} file${E.failed!==1?"s":""}`,"error"):i(`${E.uploaded} uploaded, ${E.failed} failed`,"warning")},onError:()=>{l(E=>E.map(C=>({...C,status:"error",error:"Upload failed"}))),i("Upload failed","error")}}),m=_.useCallback(E=>{E.preventDefault(),u(!0)},[]),x=_.useCallback(E=>{E.preventDefault(),u(!1)},[]),b=_.useCallback(E=>{E.preventDefault(),u(!1);const C=Array.from(E.dataTransfer.files).filter(k=>k.name.endsWith(".3mf"));C.length>0&&l(k=>[...k,...C.map(R=>({file:R,status:"pending"}))])},[]),y=_.useCallback(E=>{const C=Array.from(E.target.files||[]).filter(k=>k.name.endsWith(".3mf"));C.length>0&&l(k=>[...k,...C.map(R=>({file:R,status:"pending"}))]),a.current&&(a.current.value="")},[]),v=_.useCallback(E=>{l(C=>C.filter((k,R)=>R!==E))},[]),S=()=>{if(o.length===0)return;const E=o.filter(C=>C.status==="pending");E.length!==0&&(l(C=>C.map(k=>k.status==="pending"?{...k,status:"uploading"}:k)),p.mutate(E.map(C=>C.file)))},M=o.filter(E=>E.status==="pending").length,T=p.isPending;return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(_t,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:s.jsxs(Nt,{className:"p-0 flex flex-col h-full",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:n("uploadModal.title")}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"p-4",children:s.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${c?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:m,onDragLeave:x,onDrop:b,children:[s.jsx(Ua,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),s.jsx("p",{className:"text-white mb-2",children:n("uploadModal.dragDrop")}),s.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:n("uploadModal.or")}),s.jsx(Te,{variant:"secondary",onClick:()=>a.current?.click(),disabled:T,children:n("uploadModal.browseFiles")}),s.jsx("input",{ref:a,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:y})]})}),s.jsx("div",{className:"px-4 pb-4",children:s.jsx("p",{className:"text-xs text-bambu-gray",children:n("uploadModal.extractionInfo")})}),o.length>0&&s.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:s.jsx("div",{className:"space-y-2",children:o.map((E,C)=>s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(c2,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"flex-1 text-white text-sm truncate",children:E.file.name}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[(E.file.size/(1024*1024)).toFixed(1)," MB"]}),E.status==="pending"&&s.jsx("button",{onClick:()=>v(C),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:T,children:s.jsx(Rt,{className:"w-4 h-4"})}),E.status==="uploading"&&s.jsx(ht,{className:"w-4 h-4 text-bambu-green animate-spin"}),E.status==="success"&&s.jsx(Ar,{className:"w-4 h-4 text-bambu-green"}),E.status==="error"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-red-400",children:E.error}),s.jsx($i,{className:"w-4 h-4 text-red-400"})]})]},`${E.file.name}-${C}`))})}),d&&s.jsx("div",{className:"px-4 pb-4",children:s.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:s.jsxs("p",{className:"text-sm text-white",children:[s.jsx("span",{className:"text-bambu-green",children:d.uploaded})," ",n("uploadModal.uploaded"),d.failed>0&&s.jsxs(s.Fragment,{children:[", ",s.jsx("span",{className:"text-red-400",children:d.failed})," ",n("uploadModal.failed")]})]})})}),s.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Te,{variant:"secondary",onClick:t,className:"flex-1",children:n(d?"common.close":"common.cancel")}),!d&&s.jsx(Te,{onClick:S,disabled:M===0||T,className:"flex-1",children:T?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),n("uploadModal.uploading")]}):s.jsxs(s.Fragment,{children:[s.jsx(Ua,{className:"w-4 h-4"}),n("uploadModal.upload")," ",M>0&&`(${M})`]})})]})]})})})}const v8e=["adhesionFailure","spaghettiDetached","layerShift","cloggedNozzle","filamentRunout","warping","stringing","underExtrusion","powerFailure","userCancelled","other"],w8e=["completed","failed","aborted","printing"];function yee({archive:t,onClose:e,existingTags:n=[]}){const{t:r}=$n();_.useEffect(()=>{const ie=Me=>{Me.key==="Escape"&&e()};return window.addEventListener("keydown",ie),()=>window.removeEventListener("keydown",ie)},[e]);const i=an(),[a,o]=_.useState(t.print_name||""),[l,c]=_.useState(t.printer_id),[u,d]=_.useState(t.project_id??null),[f,p]=_.useState(t.notes||""),[m,x]=_.useState(t.tags||""),[b,y]=_.useState(t.failure_reason||""),[v,S]=_.useState(t.status),[M,T]=_.useState(t.quantity??1),[E,C]=_.useState(t.photos||[]),[k,R]=_.useState(t.external_url||""),[A,D]=_.useState(!1),[U,F]=_.useState(!1),H=_.useRef(null),j=_.useRef(null),$=_.useRef(null),{data:K}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:V}=at({queryKey:["projects"],queryFn:()=>ue.getProjects()}),{data:Q}=at({queryKey:["tags"],queryFn:ue.getTags,enabled:n.length===0}),Z=n.length>0?n:Q?.map(ie=>ie.name)||[],ae=m.split(",").map(ie=>ie.trim()).filter(Boolean),B=m.includes(",")?m.substring(m.lastIndexOf(",")+1).trim().toLowerCase():m.trim().toLowerCase(),X=Z.filter(ie=>!ae.includes(ie)&&(B===""||ie.toLowerCase().includes(B))),ne=ie=>{let Me;if(B&&!Z.includes(B)?Me=m.includes(",")?m.substring(0,m.lastIndexOf(",")).split(",").map(Oe=>Oe.trim()).filter(Boolean):[]:Me=ae,!Me.includes(ie)){const Oe=[...Me,ie].join(", ");x(Oe)}$.current!==null&&clearTimeout($.current),H.current?.focus()},se=ie=>{const Me=ae.filter(Oe=>Oe!==ie).join(", ");x(Me)},be=mt({mutationFn:ie=>ue.updateArchive(t.id,ie),onSuccess:()=>{i.invalidateQueries({queryKey:["archives"]}),i.invalidateQueries({queryKey:["projects"]}),e()}}),xe=async ie=>{const Me=ie.target.files?.[0];if(Me){D(!0);try{const Oe=await ue.uploadArchivePhoto(t.id,Me);C(Oe.photos),i.invalidateQueries({queryKey:["archives"]})}catch(Oe){console.error("Failed to upload photo:",Oe)}finally{D(!1),j.current&&(j.current.value="")}}},de=async ie=>{try{const Me=await ue.deleteArchivePhoto(t.id,ie);C(Me.photos||[]),i.invalidateQueries({queryKey:["archives"]})}catch(Me){console.error("Failed to delete photo:",Me)}},Pe=ie=>{ie.preventDefault();const Me={print_name:a||void 0,printer_id:l,project_id:u,notes:f||void 0,tags:m||void 0,quantity:M,external_url:k||null};v!==t.status&&(Me.status=v),v==="failed"||v==="aborted"?Me.failure_reason=b||void 0:(t.status==="failed"||t.status==="aborted")&&(Me.failure_reason=null),be.mutate(Me)};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:s.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:ie=>ie.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r("editArchive.title")}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:Pe,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.name")}),s.jsx("input",{type:"text",value:a,onChange:ie=>o(ie.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:r("editArchive.namePlaceholder")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.printer")}),s.jsxs("select",{value:l??"",onChange:ie=>c(ie.target.value?Number(ie.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:[s.jsx("option",{value:"",children:r("editArchive.noPrinter")}),K?.map(ie=>s.jsx("option",{value:ie.id,children:ie.name},ie.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Ja,{className:"w-4 h-4 inline mr-1"}),r("editArchive.project")]}),s.jsxs("select",{value:u??"",onChange:ie=>d(ie.target.value?Number(ie.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:[s.jsx("option",{value:"",children:r("editArchive.noProject")}),V?.map(ie=>s.jsx("option",{value:ie.id,children:ie.name},ie.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Jue,{className:"w-4 h-4 inline mr-1"}),r("editArchive.itemsPrinted")]}),s.jsx("input",{type:"number",min:1,value:M,onChange:ie=>T(Math.max(1,parseInt(ie.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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:r("editArchive.itemsPrintedHelp")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.notes")}),s.jsx("textarea",{value:f,onChange:ie=>p(ie.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:r("editArchive.notesPlaceholder")})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Fy,{className:"w-4 h-4 inline mr-1"}),r("editArchive.externalLink")]}),s.jsx("input",{type:"url",value:k,onChange:ie=>R(ie.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/..."}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:r("editArchive.externalLinkHelp")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.tags")}),ae.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:ae.map(ie=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[s.jsx(yh,{className:"w-3 h-3"}),ie,s.jsx("button",{type:"button",onClick:()=>se(ie),className:"ml-0.5 text-bambu-gray hover:text-white",children:s.jsx(Rt,{className:"w-3 h-3"})})]},ie))}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{ref:H,type:"text",value:m,onChange:ie=>x(ie.target.value),onFocus:()=>{$.current!==null&&clearTimeout($.current),F(!0)},onBlur:()=>{$.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:ae.length>0?r("editArchive.addMoreTags"):r("editArchive.tagsPlaceholder")}),U&&X.length>0&&s.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:[s.jsxs("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:[B?r("editArchive.matchingTags",{query:B}):r("editArchive.existingTags")," ",r("editArchive.clickToAdd")]}),s.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:X.map(ie=>s.jsx("button",{type:"button",onClick:()=>ne(ie),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:ie},ie))})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.status")}),s.jsx("select",{value:v,onChange:ie=>{S(ie.target.value),ie.target.value==="completed"&&y("")},className:"w-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:w8e.map(ie=>s.jsx("option",{value:ie,children:r(`editArchive.statuses.${ie}`)},ie))})]}),(v==="failed"||v==="aborted")&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.failureReason")}),s.jsxs("select",{value:b,onChange:ie=>y(ie.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:[s.jsx("option",{value:"",children:r("editArchive.selectReason")}),v8e.map(ie=>s.jsx("option",{value:r(`editArchive.failureReasons.${ie}`),children:r(`editArchive.failureReasons.${ie}`)},ie))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Ug,{className:"w-4 h-4 inline mr-1"}),r("editArchive.photos")]}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[E.map(ie=>s.jsxs("div",{className:"relative group",children:[s.jsx("img",{src:ue.getArchivePhotoUrl(t.id,ie),alt:r("editArchive.printResult"),className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),s.jsx("button",{type:"button",onClick:()=>de(ie),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:s.jsx(rn,{className:"w-3 h-3 text-white"})})]},ie)),s.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:[s.jsx("input",{ref:j,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:xe,className:"hidden",disabled:A}),A?s.jsx(ht,{className:"w-6 h-6 text-bambu-gray animate-spin"}):s.jsx(ur,{className:"w-6 h-6 text-bambu-gray"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:r("editArchive.photosHelp")})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:r("common.cancel")}),s.jsxs(Te,{type:"submit",disabled:be.isPending,className:"flex-1",children:[s.jsx(hs,{className:"w-4 h-4"}),be.isPending?r("common.saving"):r("common.save")]})]})]})]})})}function vee({x:t,y:e,items:n,onClose:r}){const i=_.useRef(null),[a,o]=_.useState(null),l=_.useRef(null),[c,u]=_.useState({x:t,y:e,visible:!1}),[d,f]=_.useState(!1),[p,m]=_.useState({});_.useEffect(()=>{const y=M=>{i.current&&!i.current.contains(M.target)&&r()},v=M=>{M.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]),_.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,M=8;let T=t,E=e;t+y.width>v-M&&(T=Math.max(M,v-y.width-M)),T<M&&(T=M),e+y.height>S-M&&(E=Math.max(M,S-y.height-M)),E<M&&(E=M);const C=180,k=v-T-y.width,R=T;f(k<C&&R>C),u({x:T,y:E,visible:!0})}},[t,e]);const x=(y,v)=>{l.current&&(clearTimeout(l.current),l.current=null);const S=v.getBoundingClientRect(),M=window.innerHeight,T=300,k=M-S.top-8<T&&S.top>T;m(R=>({...R,[y]:k?"bottom":"top"})),o(y)},b=()=>{l.current=window.setTimeout(()=>{o(null)},150)};return s.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 s.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},v);const S=y.submenu&&y.submenu.length>0;return s.jsxs("div",{className:"relative",onMouseEnter:M=>S&&x(v,M.currentTarget),onMouseLeave:()=>S&&b(),children:[s.jsxs("button",{onMouseEnter:M=>S&&x(v,M.currentTarget.parentElement),onClick:()=>{S?o(a===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&&a===v?"bg-bambu-dark-tertiary":""}`,children:[y.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:y.icon}),s.jsx("span",{className:"flex-1",children:y.label}),S&&s.jsx(gs,{className:"w-4 h-4 text-bambu-gray"})]}),S&&a===v&&s.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"} ${p[v]==="bottom"?"bottom-0":"top-0"}`,onMouseEnter:()=>{l.current&&(clearTimeout(l.current),l.current=null)},onMouseLeave:()=>b(),children:y.submenu.map((M,T)=>s.jsxs("button",{onClick:()=>{M.disabled||(M.onClick(),r())},disabled:M.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${M.disabled?"text-bambu-gray cursor-not-allowed":M.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[M.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:M.icon}),M.label]},T))})]},v)})})}function _8e({selectedIds:t,existingTags:e,onClose:n}){const r=an(),{showToast:i}=Hn(),[a,o]=_.useState(""),[l,c]=_.useState(new Set),[u,d]=_.useState("add");_.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),M=S.tags?S.tags.split(",").map(E=>E.trim()).filter(Boolean):[];let T;u==="add"?T=[...new Set([...M,...b])]:T=M.filter(E=>!l.has(E)),await ue.updateArchive(v,{tags:T.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")}}),p=b=>{c(y=>{const v=new Set(y);return v.has(b)?v.delete(b):v.add(b),v})},m=()=>{a.trim()&&!l.has(a.trim())&&(c(b=>new Set([...b,a.trim()])),o(""))},x=b=>{b.key==="Enter"&&(b.preventDefault(),m())};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(_t,{className:"w-full max-w-md",children:s.jsxs(Nt,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(yh,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:u==="add"?"Add Tags":"Remove Tags"})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("p",{className:"text-sm text-bambu-gray",children:[u==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),s.jsx(Te,{size:"sm",variant:u==="remove"?"primary":"secondary",onClick:()=>d("remove"),children:"Remove Tags"})]}),u==="add"&&s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",placeholder:"Enter new tag...",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:a,onChange:b=>o(b.target.value),onKeyDown:x}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:m,disabled:!a.trim(),children:s.jsx(ur,{className:"w-4 h-4"})})]}),e.length>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(b=>s.jsx("button",{onClick:()=>p(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&&s.jsxs("div",{children:[s.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",u==="add"?"add":"remove",":"]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(l).map(b=>s.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,s.jsx("button",{onClick:()=>p(b),className:"hover:opacity-70",children:s.jsx(Rt,{className:"w-3 h-3"})})]},b))})]})]}),s.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Te,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),s.jsx(Te,{onClick:()=>f.mutate(),disabled:l.size===0||f.isPending,className:"flex-1",children:f.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(yh,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function S8e({selectedIds:t,onClose:e}){const n=an(),{showToast:r}=Hn(),{data:i,isLoading:a}=at({queryKey:["projects"],queryFn:()=>ue.getProjects()});_.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(p=>p.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 s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(_t,{className:"w-full max-w-md max-h-[80vh] flex flex-col",children:s.jsxs(Nt,{className:"p-0 flex flex-col min-h-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ja,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Assign to Project"})]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",disabled:u,children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-3 overflow-y-auto min-h-0",children:[s.jsxs("p",{className:"text-sm text-bambu-gray",children:["Assign ",t.length," selected archive",t.length!==1?"s":""," to a project"]}),a?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 animate-spin text-bambu-gray"})}):s.jsxs("div",{className:"space-y-2",children:[s.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:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-red-500/20 flex items-center justify-center shrink-0",children:s.jsx(Yi,{className:"w-4 h-4 text-red-400"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-white font-medium",children:"Remove from project"}),s.jsx("p",{className:"text-sm text-bambu-gray truncate",children:"Clear project assignment"})]}),c.isPending&&s.jsx(ht,{className:"w-4 h-4 animate-spin text-bambu-gray shrink-0"})]}),i&&i.length>0&&s.jsxs("div",{className:"flex items-center gap-2 py-2",children:[s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary"}),s.jsx("span",{className:"text-xs text-bambu-gray",children:"or assign to"}),s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary"})]}),i?.map(d=>s.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:[s.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:s.jsx(Ja,{className:"w-4 h-4",style:{color:d.color||"rgb(var(--bambu-green))"}})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-white font-medium truncate",children:d.name}),s.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&&s.jsx(ht,{className:"w-4 h-4 animate-spin text-bambu-gray shrink-0"})]},d.id)),(!i||i.length===0)&&s.jsx("p",{className:"text-center text-bambu-gray py-4",children:"No projects yet. Create one from the Projects page."})]})]}),s.jsx("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary shrink-0",children:s.jsx(Te,{variant:"secondary",onClick:e,className:"flex-1",disabled:u,children:"Cancel"})})]})})})}function N8e(t,e){return new Date(t,e+1,0).getDate()}function M8e(t,e){return new Date(t,e,1).getDay()}const E8e=["January","February","March","April","May","June","July","August","September","October","November","December"],k8e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function T8e({archives:t,onArchiveClick:e,highlightedArchiveId:n}){const r=new Date,[i,a]=_.useState(r.getMonth()),[o,l]=_.useState(r.getFullYear()),[c,u]=_.useState(null),[d,f]=_.useState(null),p=_.useMemo(()=>{const E=new Map;return t.forEach(C=>{const k=Ii(C.completed_at||C.created_at)||new Date,R=`${k.getFullYear()}-${String(k.getMonth()+1).padStart(2,"0")}-${String(k.getDate()).padStart(2,"0")}`,A=E.get(R)||[];A.push(C),E.set(R,A)}),E},[t]),m=N8e(o,i),x=M8e(o,i),b=()=>{i===0?(a(11),l(o-1)):a(i-1)},y=()=>{i===11?(a(0),l(o+1)):a(i+1)},v=()=>{a(r.getMonth()),l(r.getFullYear())},S=[];for(let E=0;E<x;E++)S.push(null);for(let E=1;E<=m;E++)S.push(E);const M=c?p.get(c)||[]:[],T=E=>{E!==c&&f(null),u(E)};return s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("button",{onClick:b,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(gh,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white",children:[E8e[i]," ",o]}),s.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"})]}),s.jsx("button",{onClick:y,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(gs,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:k8e.map(E=>s.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:E},E))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:S.map((E,C)=>{if(E===null)return s.jsx("div",{className:"aspect-square"},`empty-${C}`);const k=`${o}-${String(i+1).padStart(2,"0")}-${String(E).padStart(2,"0")}`,R=p.get(k)||[],A=R.length>0,D=E===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),U=k===c,F=R.filter(j=>j.status==="completed").length,H=R.filter(j=>j.status==="failed").length;return s.jsxs("button",{onClick:()=>T(U?null:k),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${U?"bg-bambu-green text-white":D?"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:[s.jsx("span",{className:`text-sm font-medium ${D&&!U?"text-bambu-green":""}`,children:E}),A&&s.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[s.jsx("div",{className:`w-2 h-2 rounded-full ${H>0&&F===0?"bg-red-400":H>0?"bg-yellow-400":"bg-green-400"}`}),s.jsx("span",{className:"text-xs font-medium",children:R.length})]})]},E)})}),s.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-white",children:t.filter(E=>{const C=new Date(E.completed_at||E.created_at);return C.getMonth()===i&&C.getFullYear()===o}).length}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(E=>{const C=new Date(E.completed_at||E.created_at);return C.getMonth()===i&&C.getFullYear()===o&&E.status==="completed"}).length}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-red-400",children:t.filter(E=>{const C=new Date(E.completed_at||E.created_at);return C.getMonth()===i&&C.getFullYear()===o&&E.status==="failed"}).length}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),s.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:c?s.jsxs(s.Fragment,{children:[s.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"})}),M.length>0?s.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:M.map(E=>{const C=E.id===d||E.id===n;return s.jsxs("button",{onClick:()=>{f(E.id),e?.(E)},className:`w-full flex items-center gap-3 p-2 rounded-lg transition-colors text-left ${C?"":"hover:bg-bambu-dark-tertiary"}`,style:C?{outline:"4px solid #facc15",outlineOffset:"2px"}:void 0,children:[E.thumbnail_path?s.jsx("img",{src:ue.getArchiveThumbnail(E.id),alt:"",className:"w-12 h-12 rounded object-cover"}):s.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:s.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:E.print_name||E.filename}),s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{className:E.status==="failed"?"text-red-400":"text-green-400",children:E.status==="failed"?"Failed":"Completed"}),E.filament_color&&s.jsx("div",{className:"flex gap-0.5",children:E.filament_color.split(",").map((k,R)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:k}},R))})]})]})]},E.id)})}):s.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):s.jsx("div",{className:"text-center py-8",children:s.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function wee({archiveId:t,archiveName:e,onClose:n}){const r=ue.getArchiveQRCodeUrl(t,300);_.useEffect(()=>{const a=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[n]);const i=()=>{const a=document.createElement("a");a.href=r,a.download=`${e}_qrcode.png`,a.click()};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-6 flex flex-col items-center",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),s.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:s.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),s.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),s.jsxs(Te,{onClick:i,className:"w-full",children:[s.jsx(yi,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function _ee({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[a,o]=_.useState(0),[l,c]=_.useState(!1);if(_.useEffect(()=>{const m=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",m),()=>window.removeEventListener("keydown",m)},[r,n.length]),_.useEffect(()=>{a>=n.length&&o(Math.max(0,n.length-1))},[n.length,a]),n.length===0)return r(),null;const u=n[a],d=ue.getArchivePhotoUrl(t,u),f=()=>{const m=document.createElement("a");m.href=d,m.download=`${e}_photo_${a+1}.jpg`,m.click()},p=()=>{i&&c(!0)};return s.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[s.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:m=>m.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",a+1," of ",n.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Te,{variant:"secondary",size:"sm",onClick:f,children:[s.jsx(yi,{className:"w-4 h-4"}),"Download"]}),i&&s.jsx(Te,{variant:"secondary",size:"sm",onClick:p,className:"text-red-400 hover:text-red-300",children:s.jsx(rn,{className:"w-4 h-4"})}),s.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-6 h-6"})})]})]}),s.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[a>0&&s.jsx("button",{onClick:()=>o(m=>m-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:s.jsx(gh,{className:"w-8 h-8 text-white"})}),s.jsx("img",{src:d,alt:`Photo ${a+1}`,className:"max-w-full max-h-full object-contain rounded-lg",style:{maxHeight:"calc(100vh - 200px)"}}),a<n.length-1&&s.jsx("button",{onClick:()=>o(m=>m+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:s.jsx(gs,{className:"w-8 h-8 text-white"})})]}),n.length>1&&s.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((m,x)=>s.jsx("button",{onClick:()=>o(x),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${x===a?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:s.jsx("img",{src:ue.getArchivePhotoUrl(t,m),alt:`Thumbnail ${x+1}`,className:"w-full h-full object-cover"})},m))})]}),l&&s.jsx(Qn,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),c(!1)},onCancel:()=>c(!1)})]})}function Pa(t){this.content=t}Pa.prototype={constructor:Pa,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),a=r.content.slice();return i==-1?a.push(n||t,e):(a[i+1]=e,n&&(a[i]=n)),new Pa(a)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Pa(n)},addToStart:function(t,e){return new Pa([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Pa(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),a=r.find(t);return i.splice(a==-1?i.length:a,0,e,n),new Pa(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=Pa.from(t),t.size?new Pa(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Pa.from(t),t.size?new Pa(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Pa.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}};Pa.from=function(t){if(t instanceof Pa)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Pa(e)};function See(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),a=e.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let o=0;i.text[o]==a.text[o];o++)n++;return n}if(i.content.size||a.content.size){let o=See(i.content,a.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function Nee(t,e,n,r){for(let i=t.childCount,a=e.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=t.child(--i),l=e.child(--a),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=Nee(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,a){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,a||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 a="",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:a+=r),a+=u},0),a}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<e.content.length;a++)i.push(e.content[a]);return new 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 a=0,o=0;o<n;a++){let l=this.content[a],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(),a=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new Et(i,a)}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 See(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Nee(this,e,n,r)}findIndex(e){if(e==0)return Z_(0,e);if(e==this.size)return Z_(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),a=r+i.nodeSize;if(a>=e)return a==e?Z_(n+1,a):Z_(n,r);r=a}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return 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 a=e[i];r+=a.nodeSize,i&&a.isText&&e[i-1].sameMarkup(a)?(n||(n=e.slice(0,i)),n[n.length-1]=a.withText(n[n.length-1].text+a.text)):n&&n.push(a)}return new 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 uj={index:0,offset:0};function Z_(t,e){return uj.index=t,uj.offset=e,uj}function oN(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(!oN(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!oN(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Rr=class ED{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(this.eq(a))return e;if(this.type.excludes(a.type))n||(n=e.slice(0,i));else{if(a.type.excludes(this.type))return e;!r&&a.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(a)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&oN(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 ED.none;if(e instanceof ED)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};Rr.none=[];class lN extends Error{}class Ut{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=Eee(this.content,e+this.openStart,n);return r&&new Ut(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Ut(Mee(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 Ut.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 Ut(Et.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let a=e.firstChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.firstChild)r++;for(let a=e.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)i++;return new Ut(e,r,i)}}Ut.empty=new Ut(Et.empty,0,0);function Mee(t,e,n){let{index:r,offset:i}=t.findIndex(e),a=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(i==e||a.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,a.copy(Mee(a.content,e-i-1,n-i-1)))}function Eee(t,e,n,r){let{index:i,offset:a}=t.findIndex(e),o=t.maybeChild(i);if(a==e||o.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=Eee(o.content,e-a-1,n,o);return l&&t.replaceChild(i,o.copy(l))}function A8e(t,e,n){if(n.openStart>t.depth)throw new lN("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new lN("Inconsistent open depths");return kee(t,e,n,0)}function kee(t,e,n,r){let i=t.index(r),a=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=kee(t,e,n,r+1);return a.copy(a.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}=C8e(n,t);return Yf(a,Aee(t,o,l,e,r))}else return Yf(a,cN(t,e,r))}function Tee(t,e){if(!e.type.compatibleContent(t.type))throw new lN("Cannot join "+e.type.name+" onto "+t.type.name)}function kD(t,e,n){let r=t.node(n);return Tee(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),a=0,o=e?e.index(n):i.childCount;t&&(a=t.index(n),t.depth>n?a++:t.textOffset&&(Xf(t.nodeAfter,r),a++));for(let l=a;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 Aee(t,e,n,r,i){let a=t.depth>i&&kD(t,e,i+1),o=r.depth>i&&kD(n,r,i+1),l=[];return E0(null,t,i,l),a&&o&&e.index(i)==n.index(i)?(Tee(a,o),Xf(Yf(a,Aee(t,e,n,r,i+1)),l)):(a&&Xf(Yf(a,cN(t,e,i+1)),l),E0(e,n,i,l),o&&Xf(Yf(o,cN(n,r,i+1)),l)),E0(r,null,i,l),new Et(l)}function cN(t,e,n){let r=[];if(E0(null,t,n,r),t.depth>n){let i=kD(t,e,n+1);Xf(Yf(i,cN(t,e,n+1)),r)}return E0(e,null,n,r),new Et(r)}function C8e(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let a=n-1;a>=0;a--)i=e.node(a).copy(Et.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class wy{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let a=0;a<e;a++)i+=r.child(a).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return 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 a=r.marks;for(var o=0;o<a.length;o++)a[o].type.spec.inclusive===!1&&(!i||!a[o].isInSet(i.marks))&&(a=a[o--].removeFromSet(a));return a}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var a=0;a<r.length;a++)r[a].type.spec.inclusive===!1&&(!i||!r[a].isInSet(i.marks))&&(r=r[a--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new uN(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,a=n;for(let o=e;;){let{index:l,offset:c}=o.content.findIndex(a),u=a-c;if(r.push(o,l,i+c),!u||(o=o.child(l),o.isText))break;a=u-1,i+=c+1}return new wy(n,r,a)}static resolveCached(e,n){let r=C7.get(e);if(r)for(let a=0;a<r.elts.length;a++){let o=r.elts[a];if(o.pos==n)return o}else C7.set(e,r=new j8e);let i=r.elts[r.i]=wy.resolve(e,n);return r.i=(r.i+1)%P8e,i}}class j8e{constructor(){this.elts=[],this.i=0}}const P8e=12,C7=new WeakMap;class uN{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 D8e=Object.create(null);let hh=class TD{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&&oN(this.attrs,n||e.defaultAttrs||D8e)&&Rr.sameSet(this.marks,r||Rr.none)}copy(e=null){return e==this.content?this:new TD(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new TD(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 Ut.empty;let i=this.resolve(e),a=this.resolve(n),o=r?0:i.sharedDepth(n),l=i.start(o),u=i.node(o).content.cut(i.pos-l,a.pos-l);return new Ut(u,i.depth-o,a.depth-o)}replace(e,n,r){return A8e(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 wy.resolveCached(this,e)}resolveNoCache(e){return wy.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,a=>(r.isInSet(a.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Cee(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,a=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,a),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let c=i;c<a;c++)if(!this.type.allowsMarks(r.child(c).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let a=this.contentMatchAt(e).matchType(r),o=a&&a.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),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};hh.prototype.text=void 0;class dN 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):Cee(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 dN(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new dN(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 Cee(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class wm{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new R8e(e,n);if(r.next==null)return wm.empty;let i=jee(r);r.next&&r.err("Unexpected trailing text");let a=B8e(z8e(i));return $8e(a,r),a}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let a=n;i&&a<r;a++)i=i.matchType(e.child(a).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function a(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 p=a(f,l.concat(d));if(p)return p}}return null}return a(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),a=i.match;if(a.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<a.next.length;o++){let{type:l,next:c}=a.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 a=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)a+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return a}).join(`
  8142. `)}}wm.empty=new wm(!0);class R8e{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 jee(t){let e=[];do e.push(O8e(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function O8e(t){let e=[];do e.push(L8e(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function L8e(t){let e=U8e(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=F8e(t,e);else break;return e}function j7(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function F8e(t,e){let n=j7(t),r=n;return t.eat(",")&&(t.next!="}"?r=j7(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function I8e(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let a in n){let o=n[a];o.isInGroup(e)&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function U8e(t){if(t.eat("(")){let e=jee(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=I8e(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(a(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 a(o,l){if(o.type=="choice")return o.exprs.reduce((c,u)=>c.concat(a(u,l)),[]);if(o.type=="seq")for(let c=0;;c++){let u=a(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(a(o.expr,c),c),[r(c)]}else if(o.type=="plus"){let c=n();return i(a(o.expr,l),c),i(a(o.expr,c),c),[r(c)]}else{if(o.type=="opt")return[r(l)].concat(a(o.expr,l));if(o.type=="range"){let c=l;for(let u=0;u<o.min;u++){let d=n();i(a(o.expr,c),d),c=d}if(o.max==-1)i(a(o.expr,c),c);else for(let u=o.min;u<o.max;u++){let d=n();r(c,d),i(a(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 Pee(t,e){return e-t}function P7(t,e){let n=[];return r(e),n.sort(Pee);function r(i){let a=t[i];if(a.length==1&&!a[0].term)return r(a[0].to);n.push(i);for(let o=0;o<a.length;o++){let{term:l,to:c}=a[o];!l&&n.indexOf(c)==-1&&r(c)}}}function B8e(t){let e=Object.create(null);return n(P7(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]);P7(t,c).forEach(d=>{u||i.push([l,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let a=e[r.join(",")]=new wm(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Pee);a.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return a}}function $8e(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],a=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:c,next:u}=i.next[l];o.push(c.name),a&&!(c.isText||c.hasRequiredAttrs())&&(a=!1),r.indexOf(u)==-1&&r.push(u)}a&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Dee(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 Ree(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let a=t[r];if(a.hasDefault)i=a.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function Oee(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let a=t[i];a.validate&&a.validate(e[i])}}function Lee(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new V8e(t,r,e[r]);return n}let D7=class Fee{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=Lee(e,r.attrs),this.defaultAttrs=Dee(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==wm.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:Ree(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),a=i&&i.fillBefore(Et.empty,!0);return a?new hh(this,e,n.append(a),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){Oee(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((a,o)=>r[a]=new Fee(a,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 a in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function H8e(t,e,n){let r=n.split("|");return i=>{let a=i===null?"null":typeof i;if(r.indexOf(a)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${a}`)}}class V8e{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?H8e(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class SM{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=Lee(e,i.attrs),this.excluded=null;let a=Dee(this.attrs);this.instance=a?new Rr(this,a):null}create(e=null){return!e&&this.instance?this.instance:new Rr(this,Ree(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,o)=>r[a]=new SM(a,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){Oee(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Iee{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=Pa.from(e.nodes),n.marks=Pa.from(e.marks||{}),this.nodes=D7.compile(this.spec.nodes,this),this.marks=SM.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let a=this.nodes[i],o=a.spec.content||"",l=a.spec.marks;if(a.contentMatch=r[o]||(r[o]=wm.parse(o,this.nodes)),a.inlineContent=a.contentMatch.inlineContent,a.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!a.isInline||!a.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=a}a.markSet=l=="_"?null:l?R7(this,l.split(" ")):l==""||!a.inlineContent?[]:null}for(let i in this.marks){let a=this.marks[i],o=a.spec.excludes;a.excluded=o==null?[a]:o==""?[]:R7(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 D7){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 dN(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 R7(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t.marks[i],o=a;if(a)n.push(a);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 G8e(t){return t.tag!=null}function q8e(t){return t.style!=null}let k0=class AD{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(G8e(i))this.tags.push(i);else if(q8e(i)){let a=/[^=]*/.exec(i.style)[0];r.indexOf(a)<0&&r.push(a),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let a=e.nodes[i.node];return a.contentMatch.matchType(a)})}parse(e,n={}){let r=new L7(this,n,!1);return r.addAll(e,Rr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new L7(this,n,!0);return r.addAll(e,Rr.none,n.from,n.to),Ut.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let a=this.tags[i];if(X8e(e,a.tag)&&(a.namespace===void 0||e.namespaceURI==a.namespace)&&(!a.context||n.matchesContext(a.context))){if(a.getAttrs){let o=a.getAttrs(e);if(o===!1)continue;a.attrs=o||void 0}return a}}}matchStyle(e,n,r,i){for(let a=i?this.styles.indexOf(i)+1:0;a<this.styles.length;a++){let o=this.styles[a],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 a=i.priority==null?50:i.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<a)break}n.splice(o,0,i)}for(let i in e.marks){let a=e.marks[i].spec.parseDOM;a&&a.forEach(o=>{r(o=F7(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let a=e.nodes[i].spec.parseDOM;a&&a.forEach(o=>{r(o=F7(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new AD(e,AD.schemaRules(e)))}};const Uee={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},W8e={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},zee={ol:!0,ul:!0},_y=1,CD=2,T0=4;function O7(t,e,n){return e!=null?(e?_y:0)|(e==="full"?CD:0):t&&t.whitespace=="pre"?_y|CD:n&~T0}class J_{constructor(e,n,r,i,a,o){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=Rr.none,this.match=a||(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&_y)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let a=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-i[0].length))}}let n=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&&!Uee.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class L7{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,a,o=O7(null,n.preserveWhitespace,0)|(r?T0:0);i?a=new J_(i.type,i.attrs,Rr.none,!0,n.topMatch||i.type.contentMatch,o):r?a=new J_(null,null,Rr.none,!0,null,o):a=new J_(e.schema.topNodeType,null,Rr.none,!0,null,o),this.nodes=[a],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,a=i.options&CD?"full":this.localPreserveWS||(i.options&_y)>0,{schema:o}=this.parser;if(a==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(a)if(a==="full")r=r.replace(/\r\n?/g,`
  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,a=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;zee.hasOwnProperty(o)&&this.parser.normalizeLists&&K8e(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:W8e.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(Uee.hasOwnProperty(o))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),u=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=c&&c.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),u&&this.sync(a),this.needsBlock=d}else{let u=this.readStyles(e,n);u&&this.addElementByRule(e,c,u,c.consuming===!1?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 a=this.parser.matchedStyles[i],o=r.getPropertyValue(a);if(o)for(let l=void 0;;){let c=this.parser.matchStyle(a,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 a,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&&(a=!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)}a&&this.sync(l)&&this.open--}addAll(e,n,r,i){let a=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(o,n);this.findAtPoint(e,a)}findPlace(e,n,r){let i,a;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,a=c,!u.length))break;if(c.solid){if(r)break;l+=2}}if(!i)return null;this.sync(a);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 a=this.textblockFromContext();a&&(n=this.enterInner(a,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let a=this.top;a.match&&(a.match=a.match.matchType(e.type));let o=Rr.none;for(let l of i.concat(e.marks))(a.type?a.type.allowsMarkType(l.type):I7(l.type,e.type))&&(o=l.addToSet(o));return a.content.push(e.mark(o)),!0}return!1}enter(e,n,r,i){let a=this.findPlace(e.create(n),r,!1);return a&&(a=this.enterInner(e,n,r,!0,i)),a}enterInner(e,n,r,i=!1,a){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=O7(e,a,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):I7(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new J_(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|=_y)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),a=-(r?r.depth+1:0)+(i?0:1),o=(l,c)=>{for(;l>=0;l--){let u=n[l];if(u==""){if(l==n.length-1||l==0)continue;for(;c>=a;c--)if(o(l-1,c))return!0;return!1}else{let d=c>0||c==0&&i?this.nodes[c].type:r&&c>=a?r.node(c-a).type:null;if(!d||d.name!=u&&!d.isInGroup(u))return!1;c--}}return!0};return 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 K8e(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&zee.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function X8e(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function F7(t){let e={};for(let n in t)e[n]=t[n];return e}function I7(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let a=[],o=l=>{a.push(l);for(let c=0;c<l.edgeCount;c++){let{type:u,next:d}=l.edge(c);if(u==e||a.indexOf(d)<0&&o(d))return!0}};if(o(i.contentMatch))return!0}}class Pm{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=dj(n).createDocumentFragment());let i=r,a=[];return e.forEach(o=>{if(a.length||o.marks.length){let l=0,c=0;for(;l<a.length&&c<o.marks.length;){let u=o.marks[c];if(!this.marks[u.type.name]){c++;continue}if(!u.eq(a[l][0])||u.type.spec.spanning===!1)break;l++,c++}for(;l<a.length;)i=a.pop()[1];for(;c<o.marks.length;){let u=o.marks[c++],d=this.serializeMark(u,o.isInline,n);d&&(a.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(dj(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let a=this.serializeMark(e.marks[i],e.isInline,n);a&&((a.contentDOM||a.dom).appendChild(r),r=a.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&D1(dj(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 Pm(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=U7(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return U7(e.marks)}}function U7(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function dj(t){return t.document||window.document}const z7=new WeakMap;function Y8e(t){let e=z7.get(t);return e===void 0&&z7.set(t,e=Q8e(t)),e}function Q8e(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],a;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(a=Y8e(r))&&a.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let 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 p=f.indexOf(" ");p>0?c.setAttributeNS(f.slice(0,p),f.slice(p+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 p=e[f];if(p===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:m,contentDOM:x}=D1(t,p,n,r);if(c.appendChild(m),x){if(l)throw new RangeError("Multiple content holes");l=x}}}return{dom:c,contentDOM:l}}const Bee=65535,$ee=Math.pow(2,16);function Z8e(t,e){return t+e*$ee}function B7(t){return t&Bee}function J8e(t){return(t-(t&Bee))/$ee}const Hee=1,Vee=2,R1=4,Gee=8;class jD{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Gee)>0}get deletedBefore(){return(this.delInfo&(Hee|R1))>0}get deletedAfter(){return(this.delInfo&(Vee|R1))>0}get deletedAcross(){return(this.delInfo&R1)>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=B7(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+J8e(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,a=this.inverted?2:1,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+a],d=this.ranges[l+o],f=c+u;if(e<=f){let p=u?e==c?-1:e==f?1:n:n,m=c+i+(p<0?0:d);if(r)return m;let x=e==(n<0?c:f)?null:Z8e(l/3,e-c),b=e==c?Vee:e==f?Hee:R1;return(n<0?e!=c:e!=f)&&(b|=Gee),new jD(m,b,x)}i+=d-u}return r?e+i:new jD(e+i,0,null)}touches(e,n){let r=0,i=B7(n),a=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+a],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,a=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?a:0),c=o+(this.inverted?0:a),u=this.ranges[i+n],d=this.ranges[i+r];e(l,l+u,c,c+d),a+=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 a=this.from;a<this.to;a++){let o=this._maps[a],l=o.mapResult(e,n);if(l.recover!=null){let c=this.getMirror(a);if(c!=null&&c>a&&c<this.to){a=c,e=this._maps[c].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new jD(e,i,null)}}const hj=Object.create(null);class rs{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=hj[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 hj)throw new RangeError("Duplicate use of step JSON ID "+e);return hj[e]=n,n.prototype.jsonID=e,n}}class Bi{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Bi(e,null)}static fail(e){return new Bi(null,e)}static fromReplace(e,n,r,i){try{return Bi.ok(e.replace(n,r,i))}catch(a){if(a instanceof lN)return Bi.fail(a.message);throw a}}}function pL(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(pL(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return Et.fromArray(r)}class eh extends rs{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),a=new Ut(pL(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 Bi.fromReplace(e,this.from,this.to,a)}invert(){return new Rl(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 eh(n.pos,r.pos,this.mark)}merge(e){return e instanceof eh&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new eh(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 eh(n.from,n.to,e.markFromJSON(n.mark))}}rs.jsonID("addMark",eh);class Rl extends rs{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 Ut(pL(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return Bi.fromReplace(e,this.from,this.to,r)}invert(){return new eh(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 Rl(n.pos,r.pos,this.mark)}merge(e){return e instanceof Rl&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Rl(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 Rl(n.from,n.to,e.markFromJSON(n.mark))}}rs.jsonID("removeMark",Rl);class th extends rs{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Bi.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Bi.fromReplace(e,this.pos,this.pos+1,new Ut(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 th(this.pos,n.marks[i]);return new th(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 th(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 th(n.pos,e.markFromJSON(n.mark))}}rs.jsonID("addNodeMark",th);class _m extends rs{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Bi.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Bi.fromReplace(e,this.pos,this.pos+1,new Ut(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 th(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))}}rs.jsonID("removeNodeMark",_m);class xa extends rs{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&PD(e,this.from,this.to)?Bi.fail("Structure replace would overwrite content"):Bi.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 xa(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 xa(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof xa)||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?Ut.empty:new Ut(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new xa(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?Ut.empty:new Ut(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new xa(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 xa(n.from,n.to,Ut.fromJSON(e,n.slice),!!n.structure)}}rs.jsonID("replace",xa);class wa extends rs{constructor(e,n,r,i,a,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=a,this.insert=o,this.structure=l}apply(e){if(this.structure&&(PD(e,this.from,this.gapFrom)||PD(e,this.gapTo,this.to)))return Bi.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Bi.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Bi.fromReplace(e,this.from,this.to,r):Bi.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 wa(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new wa(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new wa(n.from,n.to,n.gapFrom,n.gapTo,Ut.fromJSON(e,n.slice),n.insert,!!n.structure)}}rs.jsonID("replaceAround",wa);function PD(t,e,n){let r=t.resolve(e),i=n-e,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let o=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function e6e(t,e,n,r){let i=[],a=[],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 p=Math.max(u,e),m=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==p&&o.mark.eq(f[b])?o.to=m:i.push(o=new Rl(p,m,f[b])));l&&l.to==p?l.to=m:a.push(l=new eh(p,m,r))}}),i.forEach(c=>t.step(c)),a.forEach(c=>t.step(c))}function t6e(t,e,n,r){let i=[],a=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;a++;let c=null;if(r instanceof SM){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],p;for(let m=0;m<i.length;m++){let x=i[m];x.step==a-1&&f.eq(i[m].style)&&(p=x)}p?(p.to=u,p.step=a):i.push({style:f,from:Math.max(l,e),to:u,step:a})}}}),i.forEach(o=>t.step(new Rl(o.from,o.to,o.style)))}function gL(t,e,n,r=n.contentMatch,i=!0){let a=t.doc.nodeAt(e),o=[],l=e+1;for(let c=0;c<a.childCount;c++){let u=a.child(c),d=l+u.nodeSize,f=r.matchType(u.type);if(!f)o.push(new xa(l,d,Ut.empty));else{r=f;for(let p=0;p<u.marks.length;p++)n.allowsMarkType(u.marks[p].type)||t.step(new Rl(l,d,u.marks[p]));if(i&&u.isText&&n.whitespace!="pre"){let p,m=/\r?\n|\r/g,x;for(;p=m.exec(u.text);)x||(x=new Ut(Et.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),o.push(new xa(l+p.index,l+p.index+p[0].length,x))}}l=d}if(!r.validEnd){let c=r.fillBefore(Et.empty,!0);t.replace(l,l,new Ut(c,0,0))}for(let c=o.length-1;c>=0;c--)t.step(o[c])}function n6e(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,a=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+i,c=t.$to.indexAfter(r)-a;if(r<t.depth&&o.canReplace(l,c,n))return r;if(r==0||o.type.spec.isolating||!n6e(o,l,c))break;l&&(i=1),c<o.childCount&&(a=1)}return null}function r6e(t,e,n){let{$from:r,$to:i,depth:a}=e,o=r.before(a+1),l=i.after(a+1),c=o,u=l,d=Et.empty,f=0;for(let x=a,b=!1;x>n;x--)b||r.index(x)>0?(b=!0,d=Et.from(r.node(x).copy(d)),f++):c--;let p=Et.empty,m=0;for(let x=a,b=!1;x>n;x--)b||i.after(x+1)<i.end(x)?(b=!0,p=Et.from(i.node(x).copy(p)),m++):u++;t.step(new wa(c,u,o,l,new Ut(d.append(p),f,m),d.size-f,!0))}function xL(t,e,n=null,r=t){let i=i6e(t,e),a=i&&a6e(r,e);return a?i.map($7).concat({type:e,attrs:n}).concat(a.map($7)):null}function $7(t){return{type:t,attrs:null}}function i6e(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.contentMatchAt(r).findWrapping(e);if(!a)return null;let o=a.length?a[0]:e;return n.canReplaceWith(r,i,o)?a:null}function a6e(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.child(r),o=e.contentMatch.findWrapping(a.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 s6e(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,a=e.end;t.step(new wa(i,a,i,a,new Ut(r,0,0),n.length,!0))}function o6e(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let a=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{let c=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,c)&&l6e(t.doc,t.mapping.slice(a).map(l),r)){let u=null;if(r.schema.linebreakReplacement){let m=r.whitespace=="pre",x=!!r.contentMatch.matchType(r.schema.linebreakReplacement);m&&!x?u=!1:!m&&x&&(u=!0)}u===!1&&Wee(t,o,l,a),gL(t,t.mapping.slice(a).map(l,1),r,void 0,u===null);let d=t.mapping.slice(a),f=d.map(l,1),p=d.map(l+o.nodeSize,1);return t.step(new wa(f,p,f+1,p-1,new Ut(Et.from(r.create(c,null,o.marks)),0,0),1,!0)),u===!0&&qee(t,o,l,a),!1}})}function qee(t,e,n,r){e.forEach((i,a)=>{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+a+o.index);t.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function Wee(t,e,n,r){e.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+a);t.replaceWith(o,o+1,e.type.schema.text(`
  8145. `))}})}function l6e(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function c6e(t,e,n,r,i){let a=t.doc.nodeAt(e);if(!a)throw new RangeError("No node at given position");n||(n=a.type);let o=n.create(r,null,i||a.marks);if(a.isLeaf)return t.replaceWith(e,e+a.nodeSize,o);if(!n.validContent(a.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new wa(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new Ut(Et.from(o),0,0),1,!0))}function ju(t,e,n=1,r){let i=t.resolve(e),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<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>a;u--,d--){let f=i.node(u),p=i.index(u);if(f.type.spec.isolating)return!1;let m=f.content.cutByIndex(p,f.childCount),x=r&&r[d+1];x&&(m=m.replaceChild(0,x.type.create(x.attrs)));let b=r&&r[d]||f;if(!f.canReplace(p+1,f.childCount)||!b.type.validContent(m))return!1}let l=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(l,l,c?c.type:i.node(a+1).type)}function u6e(t,e,n=1,r){let i=t.doc.resolve(e),a=Et.empty,o=Et.empty;for(let l=i.depth,c=i.depth-n,u=n-1;l>c;l--,u--){a=Et.from(i.node(l).copy(a));let d=r&&r[u];o=Et.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}t.step(new xa(e,e,new Ut(a.append(o),n,n),!0))}function zh(t,e){let n=t.resolve(e),r=n.index();return Kee(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function d6e(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let a=e.child(i),o=a.type==r?t.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(a.marks))return!1}return n.validEnd}function Kee(t,e){return!!(t&&e&&!t.isLeaf&&d6e(t,e))}function NM(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let a,o,l=r.index(i);if(i==r.depth?(a=r.nodeBefore,o=r.nodeAfter):n>0?(a=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(a=r.node(i).maybeChild(l-1),o=r.node(i+1)),a&&!a.isTextblock&&Kee(a,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function h6e(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,a=t.doc.resolve(e-n),o=a.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);Wee(t,d.node(),d.before(),l)}o.inlineContent&&gL(t,e+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=t.mapping.slice(l),u=c.map(e-n);if(t.step(new xa(u,c.map(e+n,-1),Ut.empty,!0)),r===!0){let d=t.doc.resolve(u);qee(t,d.node(),d.before(),t.steps.length)}return t}function f6e(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let a=r.index(i);if(r.node(i).canReplaceWith(a,a,n))return r.before(i+1);if(a>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let a=r.indexAfter(i);if(r.node(i).canReplaceWith(a,a,n))return r.after(i+1);if(a<r.node(i).childCount)return null}return null}function Xee(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let a=0;a<n.openStart;a++)i=i.firstChild.content;for(let a=1;a<=(n.openStart==0&&n.size?2:1);a++)for(let 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(a==1)d=u.canReplace(c,c,i);else{let f=u.contentMatchAt(c).findWrapping(i.firstChild.type);d=f&&u.canReplaceWith(c,c,f[0])}if(d)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function MM(t,e,n=e,r=Ut.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return Yee(i,a,r)?new xa(e,n,r):new m6e(i,a,r).fit()}function Yee(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class m6e{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 a=e.node(i);this.frontier.push({type:a.type,match:a.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=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 a=this.placed,o=r.depth,l=i.depth;for(;o&&l&&a.childCount==1;)a=a.firstChild.content,o--,l--;let c=new Ut(a,o,l);return e>-1?new wa(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new xa(r.pos,i.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let a=n.firstChild;if(n.childCount>1&&(i=0),a.type.spec.isolating&&i<=r){e=r;break}n=a.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,a=null;r?(a=fj(this.unplaced.content,r-1).firstChild,i=a.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)):a&&c.compatibleContent(a.type)))return{sliceDepth:r,frontierDepth:l,parent:a,inject:f};if(n==2&&o&&(d=u.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:a,wrap:d};if(a&&u.matchType(a.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=fj(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Ut(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=fj(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new Ut(d0(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new Ut(d0(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:a}){for(;this.depth>n;)this.closeFrontierNode();if(a)for(let b=0;b<a.length;b++)this.openFrontierNode(a[b]);let o=this.unplaced,l=r?r.content:o.content,c=o.openStart-e,u=0,d=[],{match:f,type:p}=this.frontier[n];if(i){for(let b=0;b<i.childCount;b++)d.push(i.child(b));f=f.matchFragment(i)}let m=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(Qee(b.mark(p.allowedMarks(b.marks)),u==1?c:0,u==l.childCount?m:-1)))}let x=u==l.childCount;x||(m=-1),this.placed=h0(this.placed,n,Et.from(d)),this.frontier[n].match=f,x&&m<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let b=0,y=l;b<m;b++){let v=y.lastChild;this.frontier.push({type:v.type,match:v.contentMatchAt(v.childCount)}),y=v.content}this.unplaced=x?e==0?Ut.empty:new Ut(d0(o.content,e-1,1),e-1,m<0?o.openEnd:e-1):new Ut(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||!mj(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],a=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=mj(e,n,i,r,a);if(o){for(let l=n-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=mj(e,l,u,c,!0);if(!d||d.childCount)continue e}return{depth:n,fit:o,move:a?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=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),a=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,a)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=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 fj(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Qee(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Qee(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 mj(t,e,n,r,i){let a=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let l=r.fillBefore(a.content,!0,o);return l&&!p6e(n,a.content,o)?l:null}function p6e(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function g6e(t){return t.spec.defining||t.spec.definingForContent}function x6e(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),a=t.doc.resolve(n);if(Yee(i,a,r))return t.step(new xa(e,n,r));let o=Jee(i,a);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let p=i.depth,m=i.pos-1;p>0;p--,m--){let x=i.node(p).type.spec;if(x.defining||x.definingAsContext||x.isolating)break;o.indexOf(p)>-1?l=p:i.before(p)==m&&o.splice(1,0,-p)}let c=o.indexOf(l),u=[],d=r.openStart;for(let p=r.content,m=0;;m++){let x=p.firstChild;if(u.push(x),m==r.openStart)break;p=x.content}for(let p=d-1;p>=0;p--){let m=u[p],x=g6e(m.type);if(x&&!m.sameMarkup(i.node(Math.abs(l)-1)))d=p;else if(x||!m.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let m=(p+d+1)%(r.openStart+1),x=u[m];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),M=i.index(y-1);if(S.canReplaceWith(M,M,x.type,x.marks))return t.replace(i.before(y),v?a.after(y):n,new Ut(Zee(r.content,0,r.openStart,m),m,r.openEnd))}}let f=t.steps.length;for(let p=o.length-1;p>=0&&(t.replace(e,n,r),!(t.steps.length>f));p--){let m=o[p];m<0||(e=i.before(m),n=a.after(m))}}function Zee(t,e,n,r,i){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(Zee(a.content,e+1,n,r,a)))}if(e>r){let a=i.contentMatchAt(0),o=a.fillBefore(t).append(t);t=o.append(a.matchFragment(o).fillBefore(Et.empty,!0))}return t}function b6e(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=f6e(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Ut(Et.from(r),0,0))}function y6e(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=Jee(r,i);for(let o=0;o<a.length;o++){let l=a[o],c=o==a.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 Jee(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let a=t.start(i);if(a<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(a==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==a-1)&&n.push(i)}return n}class Rg extends rs{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 Bi.fail("No node at attribute step's position");let r=Object.create(null);for(let a in n.attrs)r[a]=n.attrs[a];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return Bi.fromReplace(e,this.pos,this.pos+1,new Ut(Et.from(i),0,n.isLeaf?0:1))}getMap(){return uo.empty}invert(e){return new Rg(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 Rg(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 Rg(n.pos,n.attr,n.value)}}rs.jsonID("attr",Rg);class Ny extends rs{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 Bi.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)}}rs.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 ete{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=Ut.empty){let i=MM(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Ut(Et.from(r),0,0))}delete(e,n){return this.replace(e,n,Ut.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return x6e(this,e,n,r),this}replaceRangeWith(e,n,r){return b6e(this,e,n,r),this}deleteRange(e,n){return y6e(this,e,n),this}lift(e,n){return r6e(this,e,n),this}join(e,n=1){return h6e(this,e,n),this}wrap(e,n){return s6e(this,e,n),this}setBlockType(e,n=e,r,i=null){return o6e(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return c6e(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Rg(e,n,r)),this}setDocAttribute(e,n){return this.step(new Ny(e,n)),this}addNodeMark(e,n){return this.step(new th(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,a,o=[];for(;a=n.isInSet(i);)o.push(new _m(e,a)),i=a.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return u6e(this,e,n,r),this}addMark(e,n,r){return e6e(this,e,n,r),this}removeMark(e,n,r){return t6e(this,e,n,r),this}clearIncompatible(e,n,r){return gL(this,e,n,r),this}}const pj=Object.create(null);class An{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new v6e(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=Ut.empty){let r=n.content.lastChild,i=null;for(let l=0;l<n.openEnd;l++)i=r,r=r.lastChild;let a=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(a);e.replaceRange(d.map(c.pos),d.map(u.pos),l?Ut.empty:n),l==0&&G7(e,a,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:o,$to:l}=i[a],c=e.mapping.slice(r),u=c.map(o.pos),d=c.map(l.pos);a?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),G7(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new mn(e):lg(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let a=e.depth-1;a>=0;a--){let o=n<0?lg(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):lg(e.node(0),e.node(a),e.after(a+1),e.index(a)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new xo(e.node(0))}static atStart(e){return lg(e,e,0,0,1)||new xo(e)}static atEnd(e){return lg(e,e,e.content.size,e.childCount,-1)||new xo(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=pj[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 pj)throw new RangeError("Duplicate use of selection JSON ID "+e);return pj[e]=n,n.prototype.jsonID=e,n}getBookmark(){return mn.between(this.$anchor,this.$head).getBookmark()}}An.prototype.visible=!0;class v6e{constructor(e,n){this.$from=e,this.$to=n}}let H7=!1;function V7(t){!H7&&!t.parent.inlineContent&&(H7=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class mn extends An{constructor(e,n=e){V7(e),V7(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 An.near(r);let i=e.resolve(n.map(this.anchor));return new mn(i.parent.inlineContent?i:r,r)}replace(e,n=Ut.empty){if(super.replace(e,n),n==Ut.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof mn&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new EM(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 mn(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let a=An.findFrom(n,r,!0)||An.findFrom(n,-r,!0);if(a)n=a.$head;else return An.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(An.findFrom(e,-r,!0)||An.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new mn(e,n)}}An.jsonID("text",mn);class EM{constructor(e,n){this.anchor=e,this.head=n}map(e){return new EM(e.map(this.anchor),e.map(this.head))}resolve(e){return mn.between(e.resolve(this.anchor),e.resolve(this.head))}}class Qt extends An{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=e.resolve(i);return r?An.near(a):new Qt(a)}content(){return new Ut(Et.from(this.node),0,0)}eq(e){return e instanceof Qt&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new bL(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Qt(e.resolve(n.anchor))}static create(e,n){return new Qt(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Qt.prototype.visible=!1;An.jsonID("node",Qt);class bL{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new EM(r,r):new bL(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Qt.isSelectable(r)?new Qt(n):An.near(n)}}class xo extends An{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Ut.empty){if(n==Ut.empty){e.delete(0,e.doc.content.size);let r=An.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new xo(e)}map(e){return new xo(e)}eq(e){return e instanceof xo}getBookmark(){return w6e}}An.jsonID("all",xo);const w6e={map(){return this},resolve(t){return new xo(t)}};function lg(t,e,n,r,i,a=!1){if(e.inlineContent)return mn.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(!a&&Qt.isSelectable(l))return Qt.create(t,n-(i<0?l.nodeSize:0))}else{let c=lg(t,l,n+i,i<0?l.childCount:0,i,a);if(c)return c}n+=l.nodeSize*i}return null}function G7(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof xa||i instanceof wa))return;let a=t.mapping.maps[r],o;a.forEach((l,c,u,d)=>{o==null&&(o=d)}),t.setSelection(An.near(t.doc.resolve(o),n))}const q7=1,e1=2,W7=4;class _6e extends ete{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|q7)&~e1,this.storedMarks=null,this}get selectionSet(){return(this.updated&q7)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=e1,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&e1)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~e1,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 a=this.storedMarks;if(!a){let o=this.doc.resolve(n);a=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,a)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(An.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|=W7,this}get scrolledIntoView(){return(this.updated&W7)>0}}function K7(t,e){return!e||!t?t:t.bind(e)}class f0{constructor(e,n,r){this.name=e,this.init=K7(n.init,r),this.apply=K7(n.apply,r)}}const S6e=[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||An.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 gj{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=S6e.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 a=!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),a=!0}i&&(i[o]={state:r,n:n.length})}}if(!a)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new vg(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let a=r[i];n[a.name]=a.apply(e,this[a.name],this,n)}return n}get tr(){return new _6e(this)}static create(e){let n=new gj(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 gj(this.schema,e.plugins),r=n.fields,i=new vg(n);for(let a=0;a<r.length;a++){let o=r[a].name;i[o]=this.hasOwnProperty(o)?this[o]:r[a].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],a=i.spec.state;a&&a.toJSON&&(n[r]=a.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new gj(e.schema,e.plugins),a=new vg(i);return i.fields.forEach(o=>{if(o.name=="doc")a.doc=hh.fromJSON(e.schema,n.doc);else if(o.name=="selection")a.selection=An.fromJSON(a.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(a.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)){a[o.name]=u.fromJSON.call(c,e,n[l],a);return}}a[o.name]=o.init(e,a)}}),a}}function tte(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=tte(i,e,{})),n[r]=i}return n}class ui{constructor(e){this.spec=e,this.props={},e.props&&tte(e.props,this,this.props),this.key=e.key?e.key.key:nte("plugin")}getState(e){return e[this.key]}}const xj=Object.create(null);function nte(t){return t in xj?t+"$"+ ++xj[t]:(xj[t]=0,t+"$")}class oa{constructor(e="key"){this.key=nte(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const yL=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function rte(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const ite=(t,e,n)=>{let r=rte(t,n);if(!r)return!1;let i=vL(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 a=i.nodeBefore;if(fte(t,i,e,-1))return!0;if(r.parent.content.size==0&&(lx(a,"end")||Qt.isSelectable(a)))for(let o=r.depth;;o--){let l=MM(t.doc,r.before(o),r.after(o),Ut.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(lx(a,"end")?An.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):Qt.create(c.doc,i.pos-a.nodeSize)),e(c.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},N6e=(t,e,n)=>{let r=rte(t,n);if(!r)return!1;let i=vL(r);return i?ate(t,i,e):!1},M6e=(t,e,n)=>{let r=ote(t,n);if(!r)return!1;let i=wL(r);return i?ate(t,i,e):!1};function ate(t,e,n){let r=e.nodeBefore,i=r,a=e.pos-1;for(;!i.isTextblock;a--){if(i.type.spec.isolating)return!1;let d=i.lastChild;if(!d)return!1;i=d}let 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=MM(t.doc,a,c,Ut.empty);if(!u||u.from!=a||u instanceof xa&&u.slice.size>=c-a)return!1;if(n){let d=t.tr.step(u);d.setSelection(mn.create(d.doc,a)),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 ste=(t,e,n)=>{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;a=vL(r)}let o=a&&a.nodeBefore;return!o||!Qt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Qt.create(t.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function vL(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 ote(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const lte=(t,e,n)=>{let r=ote(t,n);if(!r)return!1;let i=wL(r);if(!i)return!1;let a=i.nodeAfter;if(fte(t,i,e,1))return!0;if(r.parent.content.size==0&&(lx(a,"start")||Qt.isSelectable(a))){let o=MM(t.doc,r.before(),r.after(),Ut.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(lx(a,"start")?An.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):Qt.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},cte=(t,e,n)=>{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;a=wL(r)}let o=a&&a.nodeAfter;return!o||!Qt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Qt.create(t.doc,a.pos)).scrollIntoView()),!0)};function wL(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 E6e=(t,e)=>{let n=t.selection,r=n instanceof Qt,i;if(r){if(n.node.isTextblock||!zh(t.doc,n.from))return!1;i=n.from}else if(i=NM(t.doc,n.from,-1),i==null)return!1;if(e){let a=t.tr.join(i);r&&a.setSelection(Qt.create(a.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},k6e=(t,e)=>{let n=t.selection,r;if(n instanceof Qt){if(n.node.isTextblock||!zh(t.doc,n.to))return!1;r=n.to}else if(r=NM(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},T6e=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&Ox(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},ute=(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 _L(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 A6e=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=_L(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(e){let l=n.after(),c=t.tr.replaceWith(l,l,o.createAndFill());c.setSelection(An.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},dte=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof xo||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=_L(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=t.tr.insert(o,a.createAndFill());l.setSelection(mn.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},hte=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let a=n.before();if(ju(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Ox(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function C6e(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Qt&&e.selection.node.isBlock)return!r.parentOffset||!ju(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],o,l,c=!1,u=!1;for(let m=r.depth;;m--)if(r.node(m).isBlock){c=r.end(m)==r.pos+(r.depth-m),u=r.start(m)==r.pos-(r.depth-m),l=_L(r.node(m-1).contentMatchAt(r.indexAfter(m-1))),a.unshift(c&&l?{type:l}:null),o=m;break}else{if(m==1)return!1;a.unshift(null)}let d=e.tr;(e.selection instanceof mn||e.selection instanceof xo)&&d.deleteSelection();let f=d.mapping.map(r.pos),p=ju(d.doc,f,a.length,a);if(p||(a[0]=l?{type:l}:null,p=ju(d.doc,f,a.length,a)),!p)return!1;if(d.split(f,a.length,a),!c&&u&&r.node(o).type!=l){let m=d.mapping.map(r.before(o)),x=d.doc.resolve(m);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 j6e=C6e(),P6e=(t,e)=>{let{$from:n,to:r}=t.selection,i,a=n.sharedDepth(r);return a==0?!1:(i=n.before(a),e&&e(t.tr.setSelection(Qt.create(t.doc,i))),!0)};function D6e(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,a=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(a-1,a)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(a,a+1)||!(i.isTextblock||zh(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function fte(t,e,n,r){let i=e.nodeBefore,a=e.nodeAfter,o,l,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&D6e(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(a.type))&&l.matchType(o[0]||a.type).validEnd){if(n){let m=e.pos+a.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 wa(e.pos-1,m,e.pos,m,new Ut(x,1,0),o.length,!0)),y=b.doc.resolve(m+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=a.type.spec.isolating||r>0&&c?null:An.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),p=f&&Ox(f);if(p!=null&&p>=e.depth)return n&&n(t.tr.lift(f,p).scrollIntoView()),!0;if(u&&lx(a,"start",!0)&&lx(i,"end")){let m=i,x=[];for(;x.push(m),!m.isTextblock;)m=m.lastChild;let b=a,y=1;for(;!b.isTextblock;b=b.firstChild)y++;if(m.canReplace(m.childCount,m.childCount,b.content)){if(n){let v=Et.empty;for(let M=x.length-1;M>=0;M--)v=Et.from(x[M].copy(v));let S=t.tr.step(new wa(e.pos-x.length,e.pos+a.nodeSize,e.pos+y,e.pos+a.nodeSize-y,new Ut(v,x.length,0),0,!0));n(S.scrollIntoView())}return!0}}return!1}function mte(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(e.tr.setSelection(mn.create(e.doc,t<0?i.start(a):i.end(a)))),!0):!1}}const R6e=mte(-1),O6e=mte(1);function L6e(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),l=o&&xL(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function X7(t,e=null){return function(n,r){let i=!1;for(let a=0;a<n.selection.ranges.length&&!i;a++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[a];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 a=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:c}}=n.selection.ranges[o];a.setBlockType(l,c,t,e)}r(a.scrollIntoView())}return!0}}function SL(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}SL(yL,ite,ste);SL(yL,lte,cte);SL(ute,dte,hte,j6e);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function F6e(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a);if(!o)return!1;let l=r?n.tr:null;return I6e(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function I6e(t,e,n,r=null){let i=!1,a=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);a=new uN(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new uN(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=xL(a,n,r,e);return l?(t&&U6e(t,e,l,i,n),!0):!1}function U6e(t,e,n,r,i){let a=Et.empty;for(let d=n.length-1;d>=0;d--)a=Et.from(n[d].type.create(n[d].attrs,a));t.step(new wa(e.start-(r?2:0),e.end,e.start,e.end,new Ut(a,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,p=!0;d<f;d++,p=!1)!p&&ju(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,a=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==t);return a?n?r.node(a.depth-1).type==t?B6e(e,n,t,a):$6e(e,n,a):!0:!1}}function B6e(t,e,n,r){let i=t.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new wa(a-1,o,a,o,new Ut(Et.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new uN(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(a,-1)-1);return zh(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function $6e(t,e,n){let r=t.tr,i=n.parent;for(let m=n.end,x=n.endIndex-1,b=n.startIndex;x>b;x--)m-=i.child(x).nodeSize,r.delete(m-1,m+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,c=n.endIndex==i.childCount,u=a.node(-1),d=a.index(-1);if(!u.canReplace(d+(l?0:1),d+1,o.content.append(c?Et.empty:Et.from(i))))return!1;let f=a.pos,p=f+o.nodeSize;return r.step(new wa(f-(l?1:0),p+(c?1:0),f+1,p-1,new Ut((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 H6e(t){return function(e,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,u=>u.childCount>0&&u.firstChild.type==t);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let l=a.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 Ut(Et.from(t.create(null,Et.from(l.type.create(null,d)))),u?3:1,0),p=a.start,m=a.end;n(e.tr.step(new wa(p-(u?3:1),m,p,m,f,1,!0)).scrollIntoView())}return!0}}const La=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 DD=null;const uu=function(t,e,n){let r=DD||(DD=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},V6e=function(){DD=null},Sm=function(t,e,n,r){return n&&(Y7(t,e,n,r,-1)||Y7(t,e,n,r,1))},G6e=/^(img|br|input|textarea|hr)$/i;function Y7(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Qo(t))){let o=t.parentNode;if(!o||o.nodeType!=1||gv(t)||G6e.test(t.nodeName)||t.contentEditable=="false")return!1;e=La(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(!((a=o.pmViewDesc)===null||a===void 0)&&a.ignoreForSelection)e+=i;else return!1;else t=o,e=i<0?Qo(t):0}else return!1}}function Qo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function q6e(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=Qo(t)}else if(t.parentNode&&!gv(t))e=La(t),t=t.parentNode;else return null}}function W6e(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&&!gv(t))e=La(t)+1,t=t.parentNode;else return null}}function K6e(t,e,n){for(let r=e==0,i=e==Qo(t);r||i;){if(t==n)return!0;let a=La(t);if(t=t.parentNode,!t)return!1;r=r&&a==0,i=i&&a==Qo(t)}}function gv(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 kM=function(t){return t.focusNode&&Sm(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 X6e(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Y6e(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Qo(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Qo(r.startContainer),r.startOffset)}}}const wc=typeof navigator<"u"?navigator:null,Q7=typeof document<"u"?document:null,Bh=wc&&wc.userAgent||"",RD=/Edge\/(\d+)/.exec(Bh),pte=/MSIE \d/.exec(Bh),OD=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Bh),$s=!!(pte||OD||RD),fh=pte?document.documentMode:OD?+OD[1]:RD?+RD[1]:0,il=!$s&&/gecko\/(\d+)/i.test(Bh);il&&+(/Firefox\/(\d+)/.exec(Bh)||[0,0])[1];const LD=!$s&&/Chrome\/(\d+)/.exec(Bh),Za=!!LD,gte=LD?+LD[1]:0,ys=!$s&&!!wc&&/Apple Computer/.test(wc.vendor),ux=ys&&(/Mobile\/\w+/.test(Bh)||!!wc&&wc.maxTouchPoints>2),Go=ux||(wc?/Mac/.test(wc.platform):!1),Q6e=wc?/Win/.test(wc.platform):!1,Su=/Android \d/.test(Bh),xv=!!Q7&&"webkitFontSmoothing"in Q7.documentElement.style,Z6e=xv?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function J6e(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 e$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 Z7(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,a=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=cx(o);continue}let l=o,c=l==a.body,u=c?J6e(a):e$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)a.defaultView.scrollBy(d,f);else{let m=l.scrollLeft,x=l.scrollTop;f&&(l.scrollTop+=f),d&&(l.scrollLeft+=d);let b=l.scrollLeft-m,y=l.scrollTop-x;e={left:e.left-b,top:e.top-y,right:e.right-b,bottom:e.bottom-y}}let p=c?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(p))break;o=p=="absolute"?o.offsetParent:cx(o)}}function t$e(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let a=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(a,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:xte(t.dom)}}function xte(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 n$e({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;bte(n,r==0?0:r-e)}function bte(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:a}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=a&&(r.scrollLeft=a)}}let eg=null;function r$e(t){if(t.setActive)return t.setActive();if(eg)return t.focus(eg);let e=xte(t);t.focus(eg==null?{get preventScroll(){return eg={preventScroll:!0},!0}}:void 0),eg||(eg=!1,bte(e,0))}function yte(t,e){let n,r=2e8,i,a=0,o=e.top,l=e.top,c,u;for(let d=t.firstChild,f=0;d;d=d.nextSibling,f++){let p;if(d.nodeType==1)p=d.getClientRects();else if(d.nodeType==3)p=uu(d).getClientRects();else continue;for(let m=0;m<p.length;m++){let x=p[m];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&&(a=f+(e.left>=(x.left+x.right)/2?1:0));continue}}else x.top>e.top&&!c&&x.left<=e.left&&x.right>=e.left&&(c=d,u={left:Math.max(x.left,Math.min(x.right,e.left)),top:x.top});!n&&(e.left>=x.right&&e.top>=x.top||e.left>=x.left&&e.top>=x.bottom)&&(a=f+1)}}return!n&&c&&(n=c,i=u,r=0),n&&n.nodeType==3?i$e(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:yte(n,i)}function i$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 a=Id(r,1);if(a.top!=a.bottom&&NL(e,a))return{node:t,offset:i+(e.left>=(a.left+a.right)/2?1:0)}}return{node:t,offset:0}}function NL(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function a$e(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function s$e(t,e,n){let{node:r,offset:i}=yte(e,n),a=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();a=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,i,a)}function o$e(t,e,n,r){let i=-1;for(let a=e,o=!1;a!=t.dom;){let l=t.docView.nearestDesc(a,!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;a=l.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function vte(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let o=t.childNodes[a];if(o.nodeType==1){let l=o.getClientRects();for(let c=0;c<l.length;c++){let u=l[c];if(NL(e,u))return vte(o,e,u)}}if((a=(a+1)%r)==i)break}return t}function l$e(t,e){let n=t.dom.ownerDocument,r,i=0,a=Y6e(n,e.left,e.top);a&&({node:r,offset:i}=a);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(!NL(e,u)||(o=vte(t.dom,e,u),!o))return null}if(ys)for(let u=o;r&&u;u=cx(u))u.draggable&&(r=void 0);if(o=a$e(o,e),r){if(il&&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;xv&&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=o$e(t,r,i,e))}l==null&&(l=s$e(t,o,e));let c=t.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function J7(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(J7(r))return r}return Array.prototype.find.call(n,J7)||t.getBoundingClientRect()}const c$e=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function wte(t,e,n){let{node:r,offset:i,atom:a}=t.docView.domFromPos(e,n<0?-1:1),o=xv||il;if(r.nodeType==3)if(o&&(c$e.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=Id(uu(r,i,i),n);if(il&&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 Jb(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++,Jb(Id(uu(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==Qo(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return bj(c.getBoundingClientRect(),!1)}if(a==null&&i<Qo(r)){let c=r.childNodes[i];if(c.nodeType==1)return bj(c.getBoundingClientRect(),!0)}return bj(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==Qo(r))){let c=r.childNodes[i-1],u=c.nodeType==3?uu(c,Qo(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return Jb(Id(u,1),!1)}if(a==null&&i<Qo(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 Jb(Id(u,-1),!0)}return Jb(Id(r.nodeType==3?uu(r):r,-n),n>=0)}function Jb(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 bj(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 _te(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 u$e(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return _te(t,e,()=>{let{node:a}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(a,!0);if(!l)break;if(l.node.isBlock){a=l.contentDOM||l.dom;break}a=l.dom.parentNode}let o=wte(t,i.pos,1);for(let l=a.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 d$e=/[\u0590-\u08ac]/;function h$e(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,l=t.domSelection();return l?!d$e.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?a:o:_te(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:f}=t.domSelectionRange(),p=l.caretBidiLevel;l.modify("move",n,"character");let m=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:x,focusOffset:b}=t.domSelectionRange(),y=x&&!m.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 p!=null&&(l.caretBidiLevel=p),y}):r.pos==r.start()||r.pos==r.end()}let e9=null,t9=null,n9=!1;function f$e(t,e,n){return e9==e&&t9==n?n9:(e9=e,t9=n,n9=n=="up"||n=="down"?u$e(t,e,n):h$e(t,e,n))}const al=0,r9=1,Lf=2,_c=3;class bv{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=al,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let a,o;if(e==this.contentDOM)a=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.previousSibling}for(;a&&!((o=a.pmViewDesc)&&o.parent==this);)a=a.previousSibling;return a?this.posBeforeChild(o)+o.size:this.posAtStart}else{let a,o;if(e==this.contentDOM)a=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.nextSibling}for(;a&&!((o=a.pmViewDesc)&&o.parent==this);)a=a.nextSibling;return a?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>La(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!1;break}if(a.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!0;break}if(a.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let a=this.getDesc(i),o;if(a&&(!n||a.node))if(r&&(o=a.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return a}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let a=this.getDesc(i);if(a)return a.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],a=r+i.size;if(r==e&&a!=r){for(;!i.border&&i.children.length;)for(let o=0;o<i.children.length;o++){let l=i.children[o];if(l.size){i=l;break}}return i}if(e<a)return i.descAt(e-r-i.border);r=a}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let a=0;r<this.children.length;r++){let o=this.children[r],l=a+o.size;if(l>e||o instanceof Nte){i=e-a;break}a=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let a;r&&!(a=this.children[r-1]).size&&a instanceof Ste&&a.side>=0;r--);if(n<=0){let a,o=!0;for(;a=r?this.children[r-1]:null,!(!a||a.dom.parentNode==this.contentDOM);r--,o=!1);return a&&n&&o&&!a.border&&!a.domAtom?a.domFromPos(a.size,n):{node:this.contentDOM,offset:a?La(a.dom)+1:0}}else{let a,o=!0;for(;a=r<this.children.length?this.children[r]:null,!(!a||a.dom.parentNode==this.contentDOM);r++,o=!1);return a&&o&&!a.border&&!a.domAtom?a.domFromPos(0,n):{node:this.contentDOM,offset:a?La(a.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,a=-1;for(let 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 p=this.children[f-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){i=La(p.dom)+1;break}e-=p.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)){a=La(f.dom);break}n+=f.size}a==-1&&(a=this.contentDOM.childNodes.length);break}o=u}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:a}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let a=Math.min(e,n),o=Math.max(e,n);for(let m=0,x=0;m<this.children.length;m++){let b=this.children[m],y=x+b.size;if(a>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((il||ys)&&e==n){let{node:m,offset:x}=l;if(m.nodeType==3){if(f=!!(x&&m.nodeValue[x-1]==`
  8147. `),f&&x==m.nodeValue.length)for(let b=m,y;b;b=b.parentNode){if(y=b.nextSibling){y.nodeName=="BR"&&(l=c={node:y.parentNode,offset:La(y)+1});break}let v=b.pmViewDesc;if(v&&v.node&&v.node.isBlock)break}}else{let b=m.childNodes[x-1];f=b&&(b.nodeName=="BR"||b.contentEditable=="false")}}if(il&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let m=d.focusNode.childNodes[d.focusOffset];m&&m.contentEditable=="false"&&(i=!0)}if(!(i||f&&ys)&&Sm(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Sm(c.node,c.offset,d.focusNode,d.focusOffset))return;let p=!1;if((u.extend||e==n)&&!(f&&il)){u.collapse(l.node,l.offset);try{e!=n&&u.extend(c.node,c.offset),p=!0}catch{}}if(!p){if(e>n){let x=l;l=c,c=x}let m=document.createRange();m.setEnd(c.node,c.offset),m.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(m)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let a=this.children[i],o=r+a.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+a.border,c=o-a.border;if(e>=l&&n<=c){this.dirty=e==r||n==o?Lf:r9,e==l&&n==c&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=_c:a.markDirty(e-l,n-l);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?Lf:_c}r=o}this.dirty=Lf}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Lf:r9;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Ste extends bv{constructor(e,n,r,i){let a,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)})),!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,a=this}matchesWidget(e){return this.dirty==al&&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 m$e extends bv{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 Nm extends bv{constructor(e,n,r,i,a){super(e,[],r,i),this.mark=n,this.spec=a}static create(e,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=Pm.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Nm(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&_c||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=_c&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=al){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=al}}slice(e,n,r){let i=Nm.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=ID(a,n,o,r)),e>0&&(a=ID(a,0,e,r));for(let l=0;l<a.length;l++)a[l].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class mh extends bv{constructor(e,n,r,i,a,o,l,c,u){super(e,[],a,o),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,n,r,i,a,o){let l=a.nodeViews[n.type.name],c,u=l&&l(n,a,()=>{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}=Pm.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 p=d;return d=kte(d,r,n),u?c=new p$e(e,n,r,i,d,f||null,p,u,a,o+1):n.isText?new TM(e,n,r,i,d,p,a):new mh(e,n,r,i,d,f||null,p,a,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==al&&e.eq(this.node)&&hN(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,a=e.composing?this.localCompositionInfo(e,n):null,o=a&&a.pos>-1?a:null,l=a&&a.pos<0,c=new x$e(this,o&&o.node,e);v$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,p)=>{c.syncToMarks(u.marks,r,e);let m;c.findNodeMatch(u,d,f,p)||l&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(m=c.findIndexWithChild(a.node))>-1&&c.updateNodeAt(u,d,f,m,e)||c.updateNextNode(u,d,f,e,p,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),Mte(this.contentDOM,this.children,e),ux&&w$e(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof mn)||r<n||i>n+this.node.content.size)return null;let a=e.input.compositionNode;if(!a||!this.dom.contains(a.parentNode))return null;if(this.node.inlineContent){let o=a.nodeValue,l=_$e(this.node.content,o,r-n,i-n);return l<0?null:{node:a,pos:l,text:o}}else return{node:a,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let a=n;for(;a.parentNode!=this.contentDOM;a=a.parentNode){for(;a.previousSibling;)a.parentNode.removeChild(a.previousSibling);for(;a.nextSibling;)a.parentNode.removeChild(a.nextSibling);a.pmViewDesc&&(a.pmViewDesc=void 0)}let o=new m$e(this,a,n,i);e.input.compositionNodes.push(o),this.children=ID(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==_c||!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=al}updateOuterDeco(e){if(hN(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Ete(this.dom,this.nodeDOM,FD(this.outerDeco,this.node,n),FD(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 i9(t,e,n,r,i){kte(r,e,t);let a=new mh(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class TM extends mh{constructor(e,n,r,i,a,o,l){super(e,n,r,i,a,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==_c||this.dirty!=al&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=al||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=al,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),a=document.createTextNode(i.text);return new TM(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=_c)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Nte extends bv{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==al&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class p$e extends mh{constructor(e,n,r,i,a,o,l,c,u,d){super(e,n,r,i,a,o,l,u,d),this.spec=c}update(e,n,r,i){if(this.dirty==_c)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let a=this.spec.update(e,n,r);return a&&this.updateInner(e,n,r,i),a}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Mte(t,e,n){let r=t.firstChild,i=!1;for(let a=0;a<e.length;a++){let o=e[a],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=a9(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof Nm){let c=r?r.previousSibling:t.lastChild;Mte(o.contentDOM,o.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=a9(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const A0=function(t){t&&(this.nodeName=t)};A0.prototype=Object.create(null);const Ff=[new A0];function FD(t,e,n){if(t.length==0)return Ff;let r=n?Ff[0]:new A0,i=[r];for(let a=0;a<t.length;a++){let o=t[a].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 Ete(t,e,n,r){if(n==Ff&&r==Ff)return e;let i=e;for(let a=0;a<r.length;a++){let o=r[a],l=n[a];if(a){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=Ff[0]),i=c}g$e(i,l||Ff[0],o)}return i}function g$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 a=0;a<r.length;a++)i.indexOf(r[a])==-1&&t.classList.remove(r[a]);for(let a=0;a<i.length;a++)r.indexOf(i[a])==-1&&t.classList.add(i[a]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function kte(t,e,n){return Ete(t,t,Ff,FD(e,n,t.nodeType!=1))}function hN(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 a9(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class x$e{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=b$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,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=al,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<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[a])&&!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=Nm.create(this.top,e[a],n,r);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,a++}}findNodeMatch(e,n,r,i){let a=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))a=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)){a=l;break}}return a<0?!1:(this.destroyBetween(this.index,a),this.index++,!0)}updateNodeAt(e,n,r,i,a){let o=this.top.children[i];return o.dirty==_c&&o.dom==o.contentDOM&&(o.dirty=Lf),o.update(e,n,r,a)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,a,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!=a)return!1;let d=c.dom,f,p=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=_c&&hN(n,c.outerDeco));if(!p&&c.update(e,n,r,i))return this.destroyBetween(this.index,l),c.dom!=d&&(this.changed=!0),this.index++,!0;if(!p&&(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=al),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,a,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!hN(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=mh.create(this.top,n,r,i,a,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,a){let o=mh.create(this.top,e,n,r,i,a);o.contentDOM&&o.updateChildren(i,a+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 a=new Ste(this.top,e,n,r);this.top.children.splice(this.index++,0,a),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Nm;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof TM)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ys||Za)&&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 Nte(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 b$e(t,e){let n=e,r=n.children.length,i=t.childCount,a=new Map,o=[];e:for(;i>0;){let l;for(;;)if(r){let u=n.children[r-1];if(u instanceof Nm)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,a.set(l,i),o.push(l)}}return{index:i,matched:a,matches:o.reverse()}}function y$e(t,e){return t.type.side-e.type.side}function v$e(t,e,n,r){let i=e.locals(t),a=0;if(i.length==0){for(let u=0;u<t.childCount;u++){let d=t.child(u);r(d,i,e.forChild(a,d),u),a+=d.nodeSize}return}let o=0,l=[],c=null;for(let u=0;;){let d,f;for(;o<i.length&&i[o].to==a;){let y=i[o++];y.widget&&(d?(f||(f=[d])).push(y):d=y)}if(d)if(f){f.sort(y$e);for(let y=0;y<f.length;y++)n(f[y],u,!!c)}else n(d,u,!!c);let p,m;if(c)m=-1,p=c,c=null;else if(u<t.childCount)m=u,p=t.child(u++);else break;for(let y=0;y<l.length;y++)l[y].to<=a&&l.splice(y--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)l.push(i[o++]);let x=a+p.nodeSize;if(p.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=p.cut(y-a),p=p.cut(0,y-a),x=y,m=-1)}else for(;o<i.length&&i[o].to<x;)o++;let b=p.isInline&&!p.isLeaf?l.filter(y=>!y.inline):l.slice();r(p,b,e.forChild(a,p),m),a=x}}function w$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 _$e(t,e,n,r){for(let i=0,a=0;i<t.childCount&&a<=r;){let o=t.child(i++),l=a;if(a+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<t.childCount;){let u=t.child(i++);if(a+=u.nodeSize,!u.isText)break;c+=u.text}if(a>=n){if(a>=r&&c.slice(r-e.length-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 ID(t,e,n,r,i){let a=[];for(let o=0,l=0;o<t.length;o++){let c=t[o],u=l,d=l+=c.size;u>=n||d<=e?a.push(c):(u<e&&a.push(c.slice(0,e-u,r)),i&&(a.push(i),i=void 0),d>n&&a.push(c.slice(n-u,c.size,r)))}return a}function ML(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),c,u;if(kM(n)){for(c=o;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&Qt.isSelectable(f)&&i.parent&&!(f.isInline&&K6e(n.focusNode,n.focusOffset,i.dom))){let p=i.posBefore;u=new Qt(o==p?l:r.resolve(p))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=o,p=o;for(let m=0;m<n.rangeCount;m++){let x=n.getRangeAt(m);f=Math.min(f,t.docView.posFromDOM(x.startContainer,x.startOffset,1)),p=Math.max(p,t.docView.posFromDOM(x.endContainer,x.endOffset,-1))}if(f<0)return null;[c,o]=p==t.state.selection.anchor?[p,f]:[f,p],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&&!a?1:-1;u=EL(t,d,l,f)}return u}function Tte(t){return t.editable?t.hasFocus():Cte(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Pu(t,e=!1){let n=t.state.selection;if(Ate(t,n),!!Tte(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Za){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Sm(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)N$e(t);else{let{anchor:r,head:i}=n,a,o;s9&&!(n instanceof mn)&&(n.$from.parent.inlineContent||(a=o9(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=o9(t,n.to))),t.docView.setSelection(r,i,t,e),s9&&(a&&l9(a),o&&l9(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&S$e(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const s9=ys||Za&&gte<63;function o9(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(ys&&i&&i.contentEditable=="false")return yj(i);if((!i||i.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(i)return yj(i);if(a)return yj(a)}}function yj(t){return t.contentEditable="true",ys&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function l9(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function S$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(()=>{(!Tte(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function N$e(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,La(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&$s&&fh<=11&&(n.disabled=!0,n.disabled=!1)}function Ate(t,e){if(e instanceof Qt){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(c9(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else c9(t)}function c9(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function EL(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||mn.between(e,n,r)}function u9(t){return t.editable&&!t.hasFocus()?!1:Cte(t)}function Cte(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 M$e(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Sm(e.node,e.offset,n.anchorNode,n.anchorOffset)}function UD(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return a&&An.findFrom(a,e)}function Hd(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function d9(t,e,n){let r=t.state.selection;if(r instanceof mn)if(n.indexOf("s")>-1){let{$head:i}=r,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!a||a.isText||!a.isLeaf)return!1;let o=t.state.doc.resolve(i.pos+a.nodeSize*(e<0?-1:1));return Hd(t,new mn(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=UD(t.state,e);return i&&i instanceof Qt?Hd(t,i):!1}else if(!(Go&&n.indexOf("m")>-1)){let i=r.$head,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!a||a.isText)return!1;let l=e<0?i.pos-a.nodeSize:i.pos;return a.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?Qt.isSelectable(a)?Hd(t,new Qt(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):xv?Hd(t,new mn(t.state.doc.resolve(e<0?l:l+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Qt&&r.node.isInline)return Hd(t,new mn(e>0?r.$to:r.$from));{let i=UD(t.state,e);return i?Hd(t,i):!1}}}function fN(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function C0(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function tg(t,e){return e<0?E$e(t):k$e(t)}function E$e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,a,o=!1;for(il&&n.nodeType==1&&r<fN(n)&&C0(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(C0(l,-1))i=n,a=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(jte(n))break;{let l=n.previousSibling;for(;l&&C0(l,-1);)i=n.parentNode,a=La(l),l=l.previousSibling;if(l)n=l,r=fN(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?zD(t,n,r):i&&zD(t,i,a)}function k$e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=fN(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(C0(l,1))a=n,o=++r;else break}else{if(jte(n))break;{let l=n.nextSibling;for(;l&&C0(l,1);)a=l.parentNode,o=La(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=fN(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}a&&zD(t,a,o)}function jte(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function T$e(t,e){for(;t&&e==t.childNodes.length&&!gv(t);)e=La(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 A$e(t,e){for(;t&&!e&&!gv(t);)e=La(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 zD(t,e,n){if(e.nodeType!=3){let a,o;(o=T$e(e,n))?(e=o,n=0):(a=A$e(e,n))&&(e=a,n=a.nodeValue.length)}let r=t.domSelection();if(!r)return;if(kM(r)){let a=document.createRange();a.setEnd(e,n),a.setStart(e,n),r.removeAllRanges(),r.addRange(a)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&Pu(t)},50)}function h9(t,e){let n=t.state.doc.resolve(e);if(!(Za||Q6e)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let a=t.coordsAtPos(e-1),o=(a.top+a.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(a.left-i.left)>1)return a.left<i.left?"ltr":"rtl"}if(e<n.end()){let a=t.coordsAtPos(e+1),o=(a.top+a.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(a.left-i.left)>1)return a.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function f9(t,e,n){let r=t.state.selection;if(r instanceof mn&&!r.empty||n.indexOf("s")>-1||Go&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=UD(t.state,e);if(o&&o instanceof Qt)return Hd(t,o)}if(!i.parent.inlineContent){let o=e<0?i:a,l=r instanceof xo?An.near(o,e):An.findFrom(o,e);return l?Hd(t,l):!1}return!1}function m9(t,e){if(!(t.state.selection instanceof mn))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let a=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let o=t.state.tr;return e<0?o.delete(n.pos-a.nodeSize,n.pos):o.delete(n.pos,n.pos+a.nodeSize),t.dispatch(o),!0}return!1}function p9(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function C$e(t){if(!ys||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;p9(t,r,"true"),setTimeout(()=>p9(t,r,"false"),20)}return!1}function j$e(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function P$e(t,e){let n=e.keyCode,r=j$e(e);if(n==8||Go&&n==72&&r=="c")return m9(t,-1)||tg(t,-1);if(n==46&&!e.shiftKey||Go&&n==68&&r=="c")return m9(t,1)||tg(t,1);if(n==13||n==27)return!0;if(n==37||Go&&n==66&&r=="c"){let i=n==37?h9(t,t.state.selection.from)=="ltr"?-1:1:-1;return d9(t,i,r)||tg(t,i)}else if(n==39||Go&&n==70&&r=="c"){let i=n==39?h9(t,t.state.selection.from)=="ltr"?1:-1:1;return d9(t,i,r)||tg(t,i)}else{if(n==38||Go&&n==80&&r=="c")return f9(t,-1,r)||tg(t,-1);if(n==40||Go&&n==78&&r=="c")return C$e(t)||f9(t,1,r)||tg(t,1);if(r==(Go?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function kL(t,e){t.someProp("transformCopied",m=>{e=m(e,t)});let n=[],{content:r,openStart:i,openEnd:a}=e;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let o=t.someProp("clipboardSerializer")||Pm.fromSchema(t.state.schema),l=Fte(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let u=c.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=Lte[u.nodeName.toLowerCase()]);){for(let m=d.length-1;m>=0;m--){let x=l.createElement(d[m]);for(;c.firstChild;)x.appendChild(c.firstChild);c.appendChild(x),f++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${a}${f?` -${f}`:""} ${JSON.stringify(n)}`);let p=t.someProp("clipboardTextSerializer",m=>m(e,t))||e.content.textBetween(0,e.content.size,`
  8148. `);return{dom:c,text:p,slice:e}}function Pte(t,e,n,r,i){let a=i.parent.type.spec.code,o,l;if(!n&&!e)return null;let c=!!e&&(r||a||!n);if(c){if(t.someProp("transformPastedText",p=>{e=p(e,a||r,t)}),a)return l=new Ut(Et.from(t.state.schema.text(e.replace(/\r\n?/g,`
  8149. `))),0,0),t.someProp("transformPasted",p=>{l=p(l,t,!0)}),l;let f=t.someProp("clipboardTextParser",p=>p(e,i,r,t));if(f)l=f;else{let p=i.marks(),{schema:m}=t.state,x=Pm.fromSchema(m);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let y=o.appendChild(document.createElement("p"));b&&y.appendChild(x.serializeNode(m.text(b,p)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),o=L$e(n),xv&&F$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 p=o.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;o=p}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||k0.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!D$e.test(p.parentNode.nodeName)?{ignore:!0}:null}})),d)l=I$e(g9(l,+d[1],+d[2]),d[4]);else if(l=Ut.maxOpen(R$e(l.content,i),!0),l.openStart||l.openEnd){let f=0,p=0;for(let m=l.content.firstChild;f<l.openStart&&!m.type.spec.isolating;f++,m=m.firstChild);for(let m=l.content.lastChild;p<l.openEnd&&!m.type.spec.isolating;p++,m=m.lastChild);l=g9(l,f,p)}return t.someProp("transformPasted",f=>{l=f(l,t,c)}),l}const D$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 R$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)),a,o=[];if(t.forEach(l=>{if(!o)return;let c=i.findWrapping(l.type),u;if(!c)return o=null;if(u=o.length&&a.length&&Rte(c,a,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=Ote(o[o.length-1],a.length));let d=Dte(l,c);o.push(d),i=i.matchType(d.type),a=c}}),o)return Et.from(o)}return t}function Dte(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,Et.from(t));return t}function Rte(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let a=Rte(t,e,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(Et.from(Dte(n,t,i+1))))}}function Ote(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Ote(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(Et.empty,!0);return t.copy(n.append(r))}function BD(t,e,n,r,i,a){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(a=0),i<r-1&&(l=BD(l,e,n,r,i+1,a)),i>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,a<=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 g9(t,e,n){return e<t.openStart&&(t=new Ut(BD(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Ut(BD(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Lte={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 x9=null;function Fte(){return x9||(x9=document.implementation.createHTMLDocument("title"))}let vj=null;function O$e(t){let e=window.trustedTypes;return e?(vj||(vj=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),vj.createHTML(t)):t}function L$e(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Fte().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&Lte[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=O$e(t),i)for(let a=0;a<i.length;a++)n=n.querySelector(i[a])||n;return n}function F$e(t){let e=t.querySelectorAll(Za?"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 I$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:a,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)),a++,o++}return new Ut(i,a,o)}const vs={},ws={},U$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 B$e(t){for(let e in vs){let n=vs[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{H$e(t,r)&&!TL(t,r)&&(t.editable||!(r.type in ws))&&n(t,r)},U$e[e]?{passive:!0}:void 0)}ys&&t.dom.addEventListener("input",()=>null),$D(t)}function nh(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function $$e(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 $D(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>TL(t,r))})}function TL(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function H$e(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 V$e(t,e){!TL(t,e)&&vs[e.type]&&(t.editable||!(e.type in ws))&&vs[e.type](t,e)}ws.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Ute(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Su&&Za&&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))||P$e(t,n)?n.preventDefault():nh(t,"key")};ws.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};ws.keypress=(t,e)=>{let n=e;if(Ute(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Go&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof mn)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),a=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,i,a))&&t.dispatch(a()),n.preventDefault()}};function AM(t){return{left:t.clientX,top:t.clientY}}function G$e(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function AL(t,e,n,r,i){if(r==-1)return!1;let a=t.state.doc.resolve(r);for(let o=a.depth+1;o>0;o--)if(t.someProp(e,l=>o>a.depth?l(t,n,a.nodeAfter,a.before(o),i,!0):l(t,n,a.node(o),a.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 q$e(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Qt.isSelectable(r)?(Og(t,new Qt(n)),!0):!1}function W$e(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Qt&&(r=n.node);let a=t.state.doc.resolve(e);for(let o=a.depth+1;o>0;o--){let l=o>a.depth?a.nodeAfter:a.node(o);if(Qt.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?i=a.before(n.$from.depth):i=a.before(o);break}}return i!=null?(Og(t,Qt.create(t.state.doc,i)),!0):!1}function K$e(t,e,n,r,i){return AL(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?W$e(t,n):q$e(t,n))}function X$e(t,e,n,r){return AL(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function Y$e(t,e,n,r){return AL(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||Q$e(t,n,r)}function Q$e(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Og(t,mn.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let a=i.depth+1;a>0;a--){let o=a>i.depth?i.nodeAfter:i.node(a),l=i.before(a);if(o.inlineContent)Og(t,mn.create(r,l+1,l+1+o.content.size));else if(Qt.isSelectable(o))Og(t,Qt.create(r,l));else continue;return!0}}function CL(t){return mN(t)}const Ite=Go?"metaKey":"ctrlKey";vs.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=CL(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&G$e(n,t.input.lastClick)&&!n[Ite]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?a="doubleClick":t.input.lastClick.type=="doubleClick"&&(a="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=t.posAtCoords(AM(n));o&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Z$e(t,o,n,!!r)):(a=="doubleClick"?X$e:Y$e)(t,o.pos,o.inside,n)?n.preventDefault():nh(t,"pointer"))};class Z$e{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[Ite],this.allowDefault=r.shiftKey;let a,o;if(n.inside>-1)a=e.state.doc.nodeAt(n.inside),o=n.inside;else{let d=e.state.doc.resolve(n.pos);a=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&&a.type.spec.draggable&&a.type.spec.selectable!==!1||u instanceof Qt&&u.from<=o&&u.to>o)&&(this.mightDrag={node:a,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&il&&!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)),nh(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(()=>Pu(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(AM(e))),this.updateAllowDefault(e),this.allowDefault||!n?nh(this.view,"pointer"):K$e(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ys&&this.mightDrag&&!this.mightDrag.node.isAtom||Za&&!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,An.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):nh(this.view,"pointer")}move(e){this.updateAllowDefault(e),nh(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)}}vs.touchstart=t=>{t.input.lastTouch=Date.now(),CL(t),nh(t,"pointer")};vs.touchmove=t=>{t.input.lastTouch=Date.now(),nh(t,"pointer")};vs.contextmenu=t=>CL(t);function Ute(t,e){return t.composing?!0:ys&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const J$e=Su?5e3:-1;ws.compositionstart=ws.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof mn&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),mN(t,!0),t.markCursor=null;else if(mN(t,!e.selection.empty),il&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,a=r.focusOffset;i&&i.nodeType==1&&a!=0;){let o=a<0?i.lastChild:i.childNodes[a-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,a=-1}}t.input.composing=!0}zte(t,J$e)};ws.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++,zte(t,20))};function zte(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>mN(t),e))}function Bte(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=tHe());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function eHe(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=q6e(e.focusNode,e.focusOffset),r=W6e(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,a=t.domObserver.lastChangedTextNode;if(n==a||r==a)return a;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function tHe(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function mN(t,e=!1){if(!(Su&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Bte(t),e||t.docView&&t.docView.dirty){let n=ML(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 nHe(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=$s&&fh<15||ux&&Z6e<604;vs.copy=ws.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=My?null:n.clipboardData,o=r.content(),{dom:l,text:c}=kL(t,o);a?(n.preventDefault(),a.clearData(),a.setData("text/html",l.innerHTML),a.setData("text/plain",c)):nHe(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function rHe(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function iHe(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 a=Pte(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,a||Ut.empty)))return!0;if(!a)return!1;let o=rHe(a),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(a);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function $te(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," "):""}ws.paste=(t,e)=>{let n=e;if(t.composing&&!Su)return;let r=My?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Ey(t,$te(r),r.getData("text/html"),i,n)?n.preventDefault():iHe(t,n)};class Hte{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const aHe=Go?"altKey":"ctrlKey";function Vte(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[aHe]}vs.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,a=i.empty?null:t.posAtCoords(AM(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Qt?i.to-1:i.to))){if(r&&r.mightDrag)o=Qt.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=Qt.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||!Za||gte>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 Hte(d,Vte(t,n),o)};vs.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};ws.dragover=ws.dragenter=(t,e)=>e.preventDefault();ws.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(AM(n));if(!i)return;let a=t.state.doc.resolve(i.pos),o=r&&r.slice;o?t.someProp("transformPasted",x=>{o=x(o,t,!1)}):o=Pte(t,$te(n.dataTransfer),My?null:n.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&Vte(t,n));if(t.someProp("handleDrop",x=>x(t,n,o||Ut.empty,l))){n.preventDefault();return}if(!o)return;n.preventDefault();let c=o?Xee(t.state.doc,a.pos,o):a.pos;c==null&&(c=a.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,p=u.doc;if(f?u.replaceRangeWith(d,d,o.content.firstChild):u.replaceRange(d,d,o),u.doc.eq(p))return;let m=u.doc.resolve(d);if(f&&Qt.isSelectable(o.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(o.content.firstChild))u.setSelection(new Qt(m));else{let x=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((b,y,v,S)=>x=S),u.setSelection(EL(t,m,u.doc.resolve(x)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};vs.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())&&Pu(t)},20))};vs.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)};vs.beforeinput=(t,e)=>{if(Za&&Su&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",a=>a(t,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 ws)vs[t]=ws[t];function ky(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 pN{constructor(e,n){this.toDOM=e,this.spec=n||Qf,this.side=this.spec.side||0}map(e,n,r,i){let{pos:a,deleted:o}=e.mapResult(n.from+i,this.side<0?-1:1);return o?null:new ms(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof pN&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&ky(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 a=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return a>=o?null:new ms(a,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof ph&&ky(this.attrs,e.attrs)&&ky(this.spec,e.spec)}static is(e){return e.type instanceof ph}destroy(){}}class jL{constructor(e,n){this.attrs=e,this.spec=n||Qf}map(e,n,r,i){let a=e.mapResult(n.from+i,1);if(a.deleted)return null;let o=e.mapResult(n.to+i,-1);return o.deleted||o.pos<=a.pos?null:new ms(a.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),a;return i==n.from&&!(a=e.child(r)).isText&&i+a.nodeSize==n.to}eq(e){return this==e||e instanceof jL&&ky(this.attrs,e.attrs)&&ky(this.spec,e.spec)}destroy(){}}class ms{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new ms(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 ms(e,e,new pN(n,r))}static inline(e,n,r,i){return new ms(e,n,new ph(r,i))}static node(e,n,r,i){return new ms(e,n,new jL(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof ph}get widget(){return this.type instanceof pN}}const cg=[],Qf={};class ai{constructor(e,n){this.local=e.length?e:cg,this.children=n.length?n:cg}static create(e,n){return n.length?gN(n,e,0,Qf):Xa}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,a){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!a||a(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,a)}}map(e,n,r){return this==Xa||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Qf)}mapInner(e,n,r,i,a){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):a.onRemove&&a.onRemove(this.local[l].spec)}return this.children.length?sHe(this.children,o||[],e,n,r,i,a):o?new ai(o.sort(Zf),cg):Xa}add(e,n){return n.length?this==Xa?ai.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,a=0;e.forEach((l,c)=>{let u=c+r,d;if(d=qte(n,l,u)){for(i||(i=this.children.slice());a<i.length&&i[a]<c;)a+=3;i[a]==c?i[a+2]=i[a+2].addInner(l,d,u+1):i.splice(a,0,c,c+l.nodeSize,gN(d,l,u+1,Qf)),a+=3}});let o=Gte(a?Wte(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new ai(o.length?this.local.concat(o).sort(Zf):this.local,i||this.children)}remove(e){return e.length==0||this==Xa?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let a=0;a<r.length;a+=3){let o,l=r[a]+n,c=r[a+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[a+2].removeInner(o,l+1);u!=Xa?r[a+2]=u:(r.splice(a,3),a-=3)}if(i.length){for(let a=0,o;a<e.length;a++)if(o=e[a])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 ai(i,r):Xa}forChild(e,n){if(this==Xa)return this;if(n.isLeaf)return ai.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 a=e+1,o=a+n.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<o&&c.to>a&&c.type instanceof ph){let u=Math.max(a,c.from)-a,d=Math.min(o,c.to)-a;u<d&&(i||(i=[])).push(c.copy(u,d))}}if(i){let l=new ai(i.sort(Zf),cg);return r?new Xd([l,r]):l}return r||Xa}eq(e){if(this==e)return!0;if(!(e instanceof ai)||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 PL(this.localsInner(e))}localsInner(e){if(this==Xa)return cg;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)}}ai.empty=new ai([],[]);ai.removeOverlap=PL;const Xa=ai.empty;class Xd{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,Qf));return Xd.from(r)}forChild(e,n){if(n.isLeaf)return ai.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(e,n);a!=Xa&&(a instanceof Xd?r=r.concat(a.members):r.push(a))}return Xd.from(r)}eq(e){if(!(e instanceof Xd)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let i=0;i<this.members.length;i++){let a=this.members[i].localsInner(e);if(a.length)if(!n)n=a;else{r&&(n=n.slice(),r=!1);for(let o=0;o<a.length;o++)n.push(a[o])}}return n?PL(r?n:n.sort(Zf)):cg}static from(e){switch(e.length){case 0:return Xa;case 1:return e[0];default:return new Xd(e.every(n=>n instanceof ai)?e:e.reduce((n,r)=>n.concat(r instanceof ai?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function sHe(t,e,n,r,i,a,o){let l=t.slice();for(let u=0,d=a;u<n.maps.length;u++){let f=0;n.maps[u].forEach((p,m,x,b)=>{let y=b-x-(m-p);for(let v=0;v<l.length;v+=3){let S=l[v+1];if(S<0||p>S+d-f)continue;let M=l[v]+d-f;m>=M?l[v+1]=p<=M?-2:-1:p>=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]+a),f=d-i;if(f<0||f>=r.content.size){c=!0;continue}let p=n.map(t[u+1]+a,-1),m=p-i,{index:x,offset:b}=r.content.findIndex(f),y=r.maybeChild(x);if(y&&b==f&&b+y.nodeSize==m){let v=l[u+2].mapInner(n,y,d+1,t[u]+a+1,o);v!=Xa?(l[u]=f,l[u+1]=m,l[u+2]=v):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=oHe(l,t,e,n,i,a,o),d=gN(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,p=0;f<d.children.length;f+=3){let m=d.children[f];for(;p<l.length&&l[p]<m;)p+=3;l.splice(p,0,d.children[f],d.children[f+1],d.children[f+2])}}return new ai(e.sort(Zf),l)}function Gte(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 ms(i.from+e,i.to+e,i.type))}return n}function oHe(t,e,n,r,i,a,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]+a+1);return n}function qte(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let a=0,o;a<t.length;a++)(o=t[a])&&o.from>n&&o.to<r&&((i||(i=[])).push(o),t[a]=null);return i}function Wte(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function gN(t,e,n,r){let i=[],a=!1;e.forEach((l,c)=>{let u=qte(t,l,c+n);if(u){a=!0;let d=gN(u,l,n+c+1,r);d!=Xa&&i.push(c,c+l.nodeSize,d)}});let o=Gte(a?Wte(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 ai(o,i):Xa}function Zf(t,e){return t.from-e.from||t.to-e.to}function PL(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let a=e[i];if(a.from==r.from){a.to!=r.to&&(e==t&&(e=t.slice()),e[i]=a.copy(a.from,r.to),b9(e,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,a.from),b9(e,i,r.copy(a.from,r.to)));break}}}return e}function b9(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!=Xa&&e.push(r)}),t.cursorWrapper&&e.push(ai.create(t.state.doc,[t.cursorWrapper.deco])),Xd.from(e)}const lHe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},cHe=$s&&fh<=11;class uHe{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 dHe{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new uHe,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]);$s&&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()}),cHe&&(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,lHe)),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(u9(this.view)){if(this.suppressingSelectionUpdates)return Pu(this.view);if($s&&fh<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Sm(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let a=e.focusNode;a;a=cx(a))n.add(a);for(let a=e.anchorNode;a;a=cx(a))if(n.has(a)){r=a;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&u9(e)&&!this.ignoreSelectionChange(r),a=-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&&(a=a<0?f.from:Math.min(f.from,a),o=o<0?f.to:Math.max(f.to,o),f.typeOver&&(l=!0))}if(il&&c.length){let d=c.filter(f=>f.nodeName=="BR");if(d.length==2){let[f,p]=d;f.parentNode&&f.parentNode.parentNode==p.parentNode?p.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let p of d){let m=p.parentNode;m&&m.nodeName=="LI"&&(!f||mHe(e,f)!=m)&&p.remove()}}}let u=null;a<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&kM(r)&&(u=ML(e))&&u.eq(An.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Pu(e),this.currentSelection.set(r),e.scrollToSelection()):(a>-1||i)&&(a>-1&&(e.docView.markDirty(a,o),hHe(e)),this.handleDOMChange(a,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Pu(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let f=e.addedNodes[d];n.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,a=e.nextSibling;if($s&&fh<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:f,nextSibling:p}=e.addedNodes[d];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(a=p)}let o=i&&i.parentNode==e.target?La(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=a&&a.parentNode==e.target?La(a):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 y9=new WeakMap,v9=!1;function hHe(t){if(!y9.has(t)&&(y9.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=il,v9)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."),v9=!0}}function w9(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Sm(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function fHe(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return w9(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?w9(t,n):null}function mHe(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 pHe(t,e,n){let{node:r,fromOffset:i,toOffset:a,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}],kM(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Za&&t.input.lastKeyCode===8)for(let y=a;y>i;y--){let v=r.childNodes[y-1],S=v.pmViewDesc;if(v.nodeName=="BR"&&!S){a=y;break}if(!S||S.size)break}let f=t.state.doc,p=t.someProp("domParser")||k0.fromSchema(t.state.schema),m=f.resolve(o),x=null,b=p.parse(r,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:i,to:a,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:gHe,context:m});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 gHe(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(ys&&/^(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||ys&&/^(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 xHe=/^(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 bHe(t,e,n,r,i){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let k=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,R=ML(t,k);if(R&&!t.state.selection.eq(R)){if(Za&&Su&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",D=>D(t,Af(13,"Enter"))))return;let A=t.state.tr.setSelection(R);k=="pointer"?A.setMeta("pointer",!0):k=="key"&&A.scrollIntoView(),a&&A.setMeta("composition",a),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=pHe(t,e,n),d=t.state.doc,f=d.slice(u.from,u.to),p,m;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(p=t.state.selection.to,m="end"):(p=t.state.selection.from,m="start"),t.input.lastKeyCode=null;let x=wHe(f.content,u.doc.content,u.from,p,m);if(x&&t.input.domChangeCount++,(ux&&t.input.lastIOSEnter>Date.now()-225||Su)&&i.some(k=>k.nodeType==1&&!xHe.test(k.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",k=>k(t,Af(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&c instanceof mn&&!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 k=_9(t,t.state.doc,u.sel);if(k&&!k.eq(t.state.selection)){let R=t.state.tr.setSelection(k);a&&R.setMeta("composition",a),t.dispatch(R)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof mn&&(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)),$s&&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(k=>k.nodeName=="DIV"||k.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",k=>k(t,Af(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&vHe(d,x.start,x.endA,b,y)&&t.someProp("handleKeyDown",k=>k(t,Af(8,"Backspace")))){Su&&Za&&t.domObserver.suppressSelectionUpdates();return}Za&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),Su&&!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(k){return k(t,Af(13,"Enter"))})},20));let M=x.start,T=x.endA,E=k=>{let R=k||t.state.tr.replace(M,T,u.doc.slice(x.start-u.from,x.endB-u.from));if(u.sel){let A=_9(t,R.doc,u.sel);A&&!(Za&&t.composing&&A.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(A.head==M||A.head==R.mapping.map(T)-1)||$s&&A.empty&&A.head==M)&&R.setSelection(A)}return a&&R.setMeta("composition",a),R.scrollIntoView()},C;if(S)if(b.pos==y.pos){$s&&fh<=11&&b.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Pu(t),20));let k=E(t.state.tr.delete(M,T)),R=d.resolve(x.start).marksAcross(d.resolve(x.endA));R&&k.ensureMarks(R),t.dispatch(k)}else if(x.endA==x.endB&&(C=yHe(b.parent.content.cut(b.parentOffset,y.parentOffset),v.parent.content.cut(v.parentOffset,x.endA-v.start())))){let k=E(t.state.tr);C.type=="add"?k.addMark(M,T,C.mark):k.removeMark(M,T,C.mark),t.dispatch(k)}else if(b.parent.child(b.index()).isText&&b.index()==y.index()-(y.textOffset?0:1)){let k=b.parent.textBetween(b.parentOffset,y.parentOffset),R=()=>E(t.state.tr.insertText(k,M,T));t.someProp("handleTextInput",A=>A(t,M,T,k,R))||t.dispatch(R())}else t.dispatch(E());else t.dispatch(E())}function _9(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:EL(t,e.resolve(n.anchor),e.resolve(n.head))}function yHe(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,a=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++)a=n[d].removeFromSet(a);if(i.length==1&&a.length==0)l=i[0],o="add",c=d=>d.mark(l.addToSet(d.marks));else if(i.length==0&&a.length==1)l=a[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 vHe(t,e,n,r,i){if(n-e<=i.pos-r.pos||_j(r,!0,!1)<i.pos)return!1;let a=t.resolve(e);if(!r.parent.isTextblock){let l=a.nodeAfter;return l!=null&&n==e+l.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=t.resolve(_j(a,!0,!0));return!o.parent.isTextblock||o.pos>n||_j(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function _j(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let a=t.node(r).maybeChild(t.indexAfter(r));for(;a&&!a.isLeaf;)a=a.firstChild,i++}return i}function wHe(t,e,n,r,i){let a=t.findDiffStart(e,n);if(a==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,a-Math.min(o,l));r-=o+c-a}if(o<a&&t.size<e.size){let c=r<=a&&r>=o?a-r:0;a-=c,a&&a<e.size&&S9(e.textBetween(a-1,a+1))&&(a+=c?1:-1),l=a+(l-o),o=a}else if(l<a){let c=r<=a&&r>=l?a-r:0;a-=c,a&&a<t.size&&S9(t.textBetween(a-1,a+1))&&(a+=c?1:-1),o=a+(o-l),l=a}return{start:a,endA:o,endB:l}}function S9(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 Kte{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(T9),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=E9(this),M9(this),this.nodeViews=k9(this),this.docView=i9(this.state.doc,N9(this),wj(this),this.dom,this),this.domObserver=new dHe(this,(r,i,a,o)=>bHe(this,r,i,a,o)),this.domObserver.start(),B$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&&$D(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(T9),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,a=!1,o=!1;e.storedMarks&&this.composing&&(Bte(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 m=k9(this);SHe(m,this.nodeViews)&&(this.nodeViews=m,a=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&$D(this),this.editable=E9(this),M9(this);let c=wj(this),u=N9(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=a||!this.docView.matchesNode(e.doc,u,c);(f||!e.selection.eq(i.selection))&&(o=!0);let p=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&t$e(this);if(o){this.domObserver.stop();let m=f&&($s||Za)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&_He(i.selection,e.selection);if(f){let x=Za?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=eHe(this)),(a||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=i9(e.doc,u,c,this.dom,this)),x&&!this.trackWrites&&(m=!0)}m||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&M$e(this))?Pu(this,m):(Ate(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():p&&n$e(p)}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 Qt){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Z7(this,n.getBoundingClientRect(),e)}else Z7(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let a=r.from+(this.state.doc.content.size-n.doc.content.size);(a>0&&this.state.doc.nodeAt(a))==r.node&&(i=a)}this.dragging=new Hte(e.slice,e.move,i<0?void 0:Qt.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 a=this.state.plugins;if(a)for(let o=0;o<a.length;o++){let l=a[o].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if($s){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&&r$e(this.dom),Pu(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 l$e(this,e)}coordsAtPos(e,n=1){return wte(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 f$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&&($$e(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,V6e())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return V$e(this,e)}domSelectionRange(){let e=this.domSelection();return e?ys&&this.root.nodeType===11&&X6e(this.dom.ownerDocument)==this.dom&&fHe(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Kte.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function N9(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"),[ms.node(0,t.state.doc.content.size,e)]}function M9(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:ms.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function E9(t){return!t.someProp("editable",e=>e(t.state)===!1)}function _He(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 k9(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 SHe(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 T9(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:"'"},xN={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},NHe=typeof navigator<"u"&&/Mac/.test(navigator.platform),MHe=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Fa=0;Fa<10;Fa++)Ph[48+Fa]=Ph[96+Fa]=String(Fa);for(var Fa=1;Fa<=24;Fa++)Ph[Fa+111]="F"+Fa;for(var Fa=65;Fa<=90;Fa++)Ph[Fa]=String.fromCharCode(Fa+32),xN[Fa]=String.fromCharCode(Fa);for(var Sj in Ph)xN.hasOwnProperty(Sj)||(xN[Sj]=Ph[Sj]);function EHe(t){var e=NHe&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||MHe&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?xN: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 kHe=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),THe=typeof navigator<"u"&&/Win/.test(navigator.platform);function AHe(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,a,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))a=!0;else if(/^mod$/i.test(c))kHe?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),a&&(n="Shift-"+n),n}function CHe(t){let e=Object.create(null);for(let n in t)e[AHe(n)]=t[n];return e}function Nj(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 jHe(t){return new ui({props:{handleKeyDown:Xte(t)}})}function Xte(t){let e=CHe(t);return function(n,r){let i=EHe(r),a,o=e[Nj(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Nj(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(THe&&r.ctrlKey&&r.altKey)&&(a=Ph[r.keyCode])&&a!=i){let l=e[Nj(a,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var PHe=Object.defineProperty,DL=(t,e)=>{for(var n in e)PHe(t,n,{get:e[n],enumerable:!0})};function CM(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var jM=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([o,l])=>[o,(...u)=>{const d=l(...u)(a);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],l=!!t,c=t||i.tr,u=()=>(!l&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(c),o.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(n).map(([f,p])=>[f,(...x)=>{const b=this.buildProps(c,e),y=p(...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,a=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([l,c])=>[l,(...u)=>c(...u)({...a,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:t,editor:r,view:a,state:CM({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}},Yte={};DL(Yte,{blur:()=>DHe,clearContent:()=>RHe,clearNodes:()=>OHe,command:()=>LHe,createParagraphNear:()=>FHe,cut:()=>IHe,deleteCurrentNode:()=>UHe,deleteNode:()=>zHe,deleteRange:()=>BHe,deleteSelection:()=>$He,enter:()=>HHe,exitCode:()=>VHe,extendMarkRange:()=>GHe,first:()=>qHe,focus:()=>KHe,forEach:()=>XHe,insertContent:()=>YHe,insertContentAt:()=>JHe,joinBackward:()=>nVe,joinDown:()=>tVe,joinForward:()=>rVe,joinItemBackward:()=>iVe,joinItemForward:()=>aVe,joinTextblockBackward:()=>sVe,joinTextblockForward:()=>oVe,joinUp:()=>eVe,keyboardShortcut:()=>cVe,lift:()=>uVe,liftEmptyBlock:()=>dVe,liftListItem:()=>hVe,newlineInCode:()=>fVe,resetAttributes:()=>mVe,scrollIntoView:()=>pVe,selectAll:()=>gVe,selectNodeBackward:()=>xVe,selectNodeForward:()=>bVe,selectParentNode:()=>yVe,selectTextblockEnd:()=>vVe,selectTextblockStart:()=>wVe,setContent:()=>_Ve,setMark:()=>zVe,setMeta:()=>BVe,setNode:()=>$Ve,setNodeSelection:()=>HVe,setTextDirection:()=>VVe,setTextSelection:()=>GVe,sinkListItem:()=>qVe,splitBlock:()=>WVe,splitListItem:()=>KVe,toggleList:()=>XVe,toggleMark:()=>YVe,toggleNode:()=>QVe,toggleWrap:()=>ZVe,undoInputRule:()=>JVe,unsetAllMarks:()=>eGe,unsetMark:()=>tGe,unsetTextDirection:()=>nGe,updateAttributes:()=>rGe,wrapIn:()=>iGe,wrapInList:()=>aGe});var DHe=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),RHe=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),OHe=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:a,$to:o})=>{t.doc.nodesBetween(a.pos,o.pos,(l,c)=>{if(l.type.isText)return;const{doc:u,mapping:d}=e,f=u.resolve(d.map(c)),p=u.resolve(d.map(c+l.nodeSize)),m=f.blockRange(p);if(!m)return;const x=Ox(m);if(l.type.isTextblock){const{defaultType:b}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(m.start,b)}(x||x===0)&&e.lift(m,x)})}),!0},LHe=t=>e=>t(e),FHe=()=>({state:t,dispatch:e})=>dte(t,e),IHe=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,a=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,a.content),r.setSelection(new mn(r.doc.resolve(Math.max(o-1,0)))),!0},UHe=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let a=i.depth;a>0;a-=1)if(i.node(a).type===r.type){if(e){const l=i.before(a),c=i.after(a);t.delete(l,c).scrollIntoView()}return!0}return!1};function Gi(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=Gi(t,n.schema),a=e.selection.$anchor;for(let o=a.depth;o>0;o-=1)if(a.node(o).type===i){if(r){const c=a.before(o),u=a.after(o);e.delete(c,u).scrollIntoView()}return!0}return!1},BHe=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},$He=()=>({state:t,dispatch:e})=>yL(t,e),HHe=()=>({commands:t})=>t.keyboardShortcut("Enter"),VHe=()=>({state:t,dispatch:e})=>A6e(t,e);function RL(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function bN(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:RL(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function Qte(t,e,n={}){return t.find(r=>r.type===e&&bN(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function A9(t,e,n={}){return!!Qte(t,e,n)}function OL(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),!Qte([...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&&A9([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;c<t.parent.childCount&&A9([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function Yu(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 GHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const a=Yu(t,r.schema),{doc:o,selection:l}=n,{$from:c,from:u,to:d}=l;if(i){const f=OL(c,a,e);if(f&&f.from<=u&&f.to>=d){const p=mn.create(o,f.from,f.to);n.setSelection(p)}}return!0},qHe=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 Zte(t){return t instanceof mn}function If(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Jte(t,e=null){if(!e)return null;const n=An.atStart(t),r=An.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,a=r.to;return e==="all"?mn.create(t,If(0,i,a),If(t.content.size,i,a)):mn.create(t,If(e,i,a),If(e,i,a))}function WHe(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function LL(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var KHe=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const o=()=>{(LL()||WHe())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(a&&t===null&&!Zte(n.state.selection))return o(),!0;const l=Jte(i.doc,t)||n.state.selection,c=n.state.selection.eq(l);return a&&(c||i.setSelection(l),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},XHe=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),YHe=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),ene=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&&ene(r)}return t};function t1(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 ene(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(a){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:a});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",a),Ty("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const c=new Iee({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?k0.fromSchema(c).parseSlice(t1(t),n.parseOptions):k0.fromSchema(c).parse(t1(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const a=k0.fromSchema(e);return n.slice?a.parseSlice(t1(t),n.parseOptions).content:a.parse(t1(t),n.parseOptions)}return Ty("",e,n)}function QHe(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof xa||i instanceof wa))return;const a=t.mapping.maps[r];let o=0;a.forEach((l,c,u,d)=>{o===0&&(o=d)}),t.setSelection(An.near(t.doc.resolve(o),n))}var ZHe=t=>!("type"in t),JHe=(t,e,n)=>({tr:r,dispatch:i,editor:a})=>{var o;if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const c=y=>{a.emit("contentError",{editor:a,error:y,disableCollaboration:()=>{"collaboration"in a.storage&&typeof a.storage.collaboration=="object"&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{Ty(e,a.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(y){c(y)}try{l=Ty(e,a.schema,{parseOptions:u,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:a.options.enableContentCheck})}catch(y){return c(y),!1}let{from:d,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},p=!0,m=!0;if((ZHe(l)?l:[l]).forEach(y=>{y.check(),p=p?y.isText&&y.marks.length===0:!1,m=m?y.isBlock:!1}),d===f&&m){const{parent:y}=r.doc.resolve(d);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(d-=1,f+=1)}let b;if(p){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,M=v.isText||v.isTextblock,T=v.content.size>0;S&&M&&T&&(d=Math.max(0,d-1)),r.replaceWith(d,f,b)}n.updateSelection&&QHe(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},eVe=()=>({state:t,dispatch:e})=>E6e(t,e),tVe=()=>({state:t,dispatch:e})=>k6e(t,e),nVe=()=>({state:t,dispatch:e})=>ite(t,e),rVe=()=>({state:t,dispatch:e})=>lte(t,e),iVe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=NM(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},aVe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=NM(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},sVe=()=>({state:t,dispatch:e})=>N6e(t,e),oVe=()=>({state:t,dispatch:e})=>M6e(t,e);function tne(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function lVe(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,a,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))a=!0;else if(/^mod$/i.test(c))LL()||tne()?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}`),a&&(n=`Shift-${n}`),n}var cVe=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const a=lVe(t).split(/-(?!$)/),o=a.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{n.someProp("handleKeyDown",u=>u(n,l))});return c?.steps.forEach(u=>{const d=u.map(r.mapping);d&&i&&r.maybeStep(d)}),!0};function Dh(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,o=e?Gi(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(f,p)=>{if(f.isText)return;const m=Math.max(r,p),x=Math.min(i,p+f.nodeSize);l.push({node:f,from:m,to:x})});const c=i-r,u=l.filter(f=>o?o.name===f.node.type.name:!0).filter(f=>bN(f.node.attrs,n,{strict:!1}));return a?!!u.length:u.reduce((f,p)=>f+p.to-p.from,0)>=c}var uVe=(t,e={})=>({state:n,dispatch:r})=>{const i=Gi(t,n.schema);return Dh(n,i,e)?T6e(n,r):!1},dVe=()=>({state:t,dispatch:e})=>hte(t,e),hVe=t=>({state:e,dispatch:n})=>{const r=Gi(t,e.schema);return z6e(r)(e,n)},fVe=()=>({state:t,dispatch:e})=>ute(t,e);function PM(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function C9(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}var mVe=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=PM(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=Gi(t,r.schema)),l==="mark"&&(o=Yu(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,f)=>{a&&a===d.type&&(c=!0,i&&n.setNodeMarkup(f,void 0,C9(d.attrs,e))),o&&d.marks.length&&d.marks.forEach(p=>{o===p.type&&(c=!0,i&&n.addMark(f,f+d.nodeSize,o.create(C9(p.attrs,e))))})})}),c},pVe=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),gVe=()=>({tr:t,dispatch:e})=>{if(e){const n=new xo(t.doc);t.setSelection(n)}return!0},xVe=()=>({state:t,dispatch:e})=>ste(t,e),bVe=()=>({state:t,dispatch:e})=>cte(t,e),yVe=()=>({state:t,dispatch:e})=>P6e(t,e),vVe=()=>({state:t,dispatch:e})=>O6e(t,e),wVe=()=>({state:t,dispatch:e})=>R6e(t,e);function HD(t,e,n={},r={}){return Ty(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var _Ve=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:o,commands:l})=>{const{doc:c}=a;if(r.preserveWhitespace!=="full"){const u=HD(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&a.replaceWith(0,c.content.size,u).setMeta("preventUpdate",!n),!0}return o&&a.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:c.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function nne(t,e){const n=Yu(e,t.schema),{from:r,to:i,empty:a}=t.selection,o=[];a?(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 rne(t,e){const n=new ete(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function SVe(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 NVe(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,a)=>{n(i)&&r.push({node:i,pos:a})}),r}function MVe(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=>MVe(e.$from,t)}function Xt(t,e,n){return t.config[e]===void 0&&t.parent?Xt(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Xt(t.parent,e,n):null}):t.config[e]}function FL(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Xt(e,"addExtensions",n);return r?[e,...FL(r())]:e}).flat(10)}function IL(t,e){const n=Pm.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function ine(t){return typeof t=="function"}function gr(t,e=void 0,...n){return ine(t)?e?t.bind(e)(...n):t(...n):t}function EVe(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 ane(t){const e=[],{nodeExtensions:n,markExtensions:r}=dx(t),i=[...n,...r],a={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=Xt(o,"addGlobalAttributes",l);if(!c)return;c().forEach(d=>{d.types.forEach(f=>{Object.entries(d.attributes).forEach(([p,m])=>{e.push({type:f,name:p,attribute:{...a,...m}})})})})}),i.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},c=Xt(o,"addAttributes",l);if(!c)return;const u=c();Object.entries(u).forEach(([d,f])=>{const p={...a,...f};typeof p?.default=="function"&&(p.default=p.default()),p?.isRequired&&p?.default===void 0&&delete p.default,e.push({type:o.name,name:d,attribute:p})})}),e}function vi(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,a])=>{if(!r[i]){r[i]=a;return}if(i==="class"){const l=a?String(a).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=a?a.split(";").map(d=>d.trim()).filter(Boolean):[],c=r[i]?r[i].split(";").map(d=>d.trim()).filter(Boolean):[],u=new Map;c.forEach(d=>{const[f,p]=d.split(":").map(m=>m.trim());u.set(f,p)}),l.forEach(d=>{const[f,p]=d.split(":").map(m=>m.trim());u.set(f,p)}),r[i]=Array.from(u.entries()).map(([d,f])=>`${d}: ${f}`).join("; ")}else r[i]=a}),r},{})}function yN(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)=>vi(n,r),{})}function kVe(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function j9(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((a,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):kVe(n.getAttribute(o.name));return l==null?a:{...a,[o.name]:l}},{});return{...r,...i}}}}function P9(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&EVe(n)?!1:n!=null))}function D9(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 TVe(t,e){var n;const r=ane(t),{nodeExtensions:i,markExtensions:a}=dx(t),o=(n=i.find(u=>Xt(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},p=t.reduce((v,S)=>{const M=Xt(S,"extendNodeSchema",f);return{...v,...M?M(u):{}}},{}),m=P9({...p,content:gr(Xt(u,"content",f)),marks:gr(Xt(u,"marks",f)),group:gr(Xt(u,"group",f)),inline:gr(Xt(u,"inline",f)),atom:gr(Xt(u,"atom",f)),selectable:gr(Xt(u,"selectable",f)),draggable:gr(Xt(u,"draggable",f)),code:gr(Xt(u,"code",f)),whitespace:gr(Xt(u,"whitespace",f)),linebreakReplacement:gr(Xt(u,"linebreakReplacement",f)),defining:gr(Xt(u,"defining",f)),isolating:gr(Xt(u,"isolating",f)),attrs:Object.fromEntries(d.map(D9))}),x=gr(Xt(u,"parseHTML",f));x&&(m.parseDOM=x.map(v=>j9(v,d)));const b=Xt(u,"renderHTML",f);b&&(m.toDOM=v=>b({node:v,HTMLAttributes:yN(v,d)}));const y=Xt(u,"renderText",f);return y&&(m.toText=y),[u.name,m]})),c=Object.fromEntries(a.map(u=>{const d=r.filter(y=>y.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},p=t.reduce((y,v)=>{const S=Xt(v,"extendMarkSchema",f);return{...y,...S?S(u):{}}},{}),m=P9({...p,inclusive:gr(Xt(u,"inclusive",f)),excludes:gr(Xt(u,"excludes",f)),group:gr(Xt(u,"group",f)),spanning:gr(Xt(u,"spanning",f)),code:gr(Xt(u,"code",f)),attrs:Object.fromEntries(d.map(D9))}),x=gr(Xt(u,"parseHTML",f));x&&(m.parseDOM=x.map(y=>j9(y,d)));const b=Xt(u,"renderHTML",f);return b&&(m.toDOM=y=>b({mark:y,HTMLAttributes:yN(y,d)})),[u.name,m]}));return new Iee({topNode:o,nodes:l,marks:c})}function AVe(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function UL(t){return t.sort((n,r)=>{const i=Xt(n,"priority")||100,a=Xt(r,"priority")||100;return i>a?-1:i<a?1:0})}function sne(t){const e=UL(FL(t)),n=AVe(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 one(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=`
  8150. `,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,i,(c,u,d,f)=>{var p;c.isBlock&&u>r&&(l+=a);const m=o?.[c.type.name];if(m)return d&&(l+=m({node:c,pos:u,parent:d,index:f,range:e})),!1;c.isText&&(l+=(p=c?.text)==null?void 0:p.slice(Math.max(r,u)-u,i-u))}),l}function CVe(t,e){const n={from:0,to:t.content.size};return one(t,n,e)}function lne(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function jVe(t,e){const n=Gi(e,t.schema),{from:r,to:i}=t.selection,a=[];t.doc.nodesBetween(r,i,l=>{a.push(l)});const o=a.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function cne(t,e){const n=PM(typeof e=="string"?e:e.name,t.schema);return n==="node"?jVe(t,e):n==="mark"?nne(t,e):{}}function PVe(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 DVe(t){const e=PVe(t);return e.length===1?e:e.filter((n,r)=>!e.filter((a,o)=>o!==r).some(a=>n.oldRange.from>=a.oldRange.from&&n.oldRange.to<=a.oldRange.to&&n.newRange.from>=a.newRange.from&&n.newRange.to<=a.newRange.to))}function une(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,a)=>{const o=[];if(i.ranges.length)i.forEach((l,c)=>{o.push({from:l,to:c})});else{const{from:l,to:c}=n[a];if(l===void 0||c===void 0)return;o.push({from:l,to:c})}o.forEach(({from:l,to:c})=>{const u=e.slice(a).map(l,-1),d=e.slice(a).map(c),f=e.invert().map(u,-1),p=e.invert().map(d);r.push({oldRange:{from:f,to:p},newRange:{from:u,to:d}})})}),DVe(r)}function zL(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),o=OL(a,i.type);o&&r.push({mark:i,...o})}):n.nodesBetween(t,e,(i,a)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(o=>({from:a,to:a+i.nodeSize,mark:o})))}),r}var RVe=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let a=r,o=null;for(;a>0&&o===null;){const l=i.node(a);l?.type.name===e?o=l:a-=1}return[o,a]};function Mj(t,e){return e.nodes[t]||e.marks[t]||null}function O1(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(a=>a.type===e&&a.name===r);return i?i.attribute.keepOnSplit:!1}))}var OVe=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,a,o,l)=>{var c,u;const d=((u=(c=i.type.spec).toText)==null?void 0:u.call(c,{node:i,pos:a,parent:o,index:l}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-a))}),n};function VD(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?Yu(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>a?a.name===f.type.name:!0).find(f=>bN(f.attrs,n,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:f,$to:p})=>{const m=f.pos,x=p.pos;t.doc.nodesBetween(m,x,(b,y)=>{if(!b.isText&&!b.marks.length)return;const v=Math.max(m,y),S=Math.min(x,y+b.nodeSize),M=S-v;o+=M,l.push(...b.marks.map(T=>({mark:T,from:v,to:S})))})}),o===0)return!1;const c=l.filter(f=>a?a.name===f.mark.type.name:!0).filter(f=>bN(f.mark.attrs,n,{strict:!1})).reduce((f,p)=>f+p.to-p.from,0),u=l.filter(f=>a?f.mark.type!==a&&f.mark.type.excludes(a):!0).reduce((f,p)=>f+p.to-p.from,0);return(c>0?c+u:c)>=o}function LVe(t,e,n={}){if(!e)return Dh(t,null,n)||VD(t,null,n);const r=PM(e,t.schema);return r==="node"?Dh(t,e,n):r==="mark"?VD(t,e,n):!1}var FVe=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=DM(l=>l.type.name===e)(t.selection);if(!a)return!1;const o=t.doc.resolve(a.pos+1);return i.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},IVe=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function R9(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function O9(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},a=gr(Xt(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function RM(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(a=>{i!==!1&&(RM(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function dne(t){return t instanceof Qt}function UVe(t,e,n){var r;const{selection:i}=e;let a=null;if(Zte(i)&&(a=i.$cursor),a){const l=(r=t.storedMarks)!=null?r:a.marks();return a.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,p)=>{if(u)return!1;if(d.isInline){const m=!p||p.type.allowsMarkType(n),x=!!n.isInSet(d.marks)||!d.marks.some(b=>b.type.excludes(n));u=m&&x}return!u}),u})}var zVe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:o,ranges:l}=a,c=Yu(t,r.schema);if(i)if(o){const u=nne(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,(p,m)=>{const x=Math.max(m,d),b=Math.min(m+p.nodeSize,f);p.marks.find(v=>v.type===c)?p.marks.forEach(v=>{c===v.type&&n.addMark(x,b,c.create({...v.attrs,...e}))}):n.addMark(x,b,c.create(e))})});return UVe(r,n,c)},BVe=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),$Ve=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=Gi(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:l})=>X7(a,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>X7(a,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},HVe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=If(t,0,r.content.size),a=Qt.create(r,i);e.setSelection(a)}return!0},VVe=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=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=a.from,l=a.to),i&&n.doc.nodesBetween(o,l,(c,u)=>{c.isText||n.setNodeMarkup(u,void 0,{...c.attrs,dir:t})}),!0},GVe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,o=mn.atStart(r).from,l=mn.atEnd(r).to,c=If(i,o,l),u=If(a,o,l),d=mn.create(r,c,u);e.setSelection(d)}return!0},qVe=t=>({state:e,dispatch:n})=>{const r=Gi(t,e.schema);return H6e(r)(e,n)};function L9(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 WVe=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:a,doc:o}=e,{$from:l,$to:c}=a,u=i.extensionManager.attributes,d=O1(u,l.node().type.name,l.node().attrs);if(a instanceof Qt&&a.node.isBlock)return!l.parentOffset||!ju(o,l.pos)?!1:(r&&(t&&L9(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,p=l.depth===0?void 0:SVe(l.node(-1).contentMatchAt(l.indexAfter(-1)));let m=f&&p?[{type:p,attrs:d}]:void 0,x=ju(e.doc,e.mapping.map(l.pos),1,m);if(!m&&!x&&ju(e.doc,e.mapping.map(l.pos),1,p?[{type:p}]:void 0)&&(x=!0,m=p?[{type:p,attrs:d}]:void 0),r){if(x&&(a instanceof mn&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,m),p&&!f&&!l.parentOffset&&l.parent.type!==p)){const b=e.mapping.map(l.before()),y=e.doc.resolve(b);l.node(-1).canReplaceWith(y.index(),y.index()+1,p)&&e.setNodeMarkup(e.mapping.map(l.before()),p)}t&&L9(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},KVe=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var o;const l=Gi(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 p=a.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 R=c.depth-S;R>=c.depth-3;R-=1)v=Et.from(c.node(R).copy(v));const M=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,T={...O1(p,c.node().type.name,c.node().attrs),...e},E=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(T))||void 0;v=v.append(Et.from(l.createAndFill(null,E)||void 0));const C=c.before(c.depth-(S-1));n.replace(C,c.after(-M),new Ut(v,4-S,0));let k=-1;n.doc.nodesBetween(C,n.doc.content.size,(R,A)=>{if(k>-1)return!1;R.isTextblock&&R.content.size===0&&(k=A+1)}),k>-1&&n.setSelection(mn.near(n.doc.resolve(k))),n.scrollIntoView()}return!0}const m=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,x={...O1(p,f.type.name,f.attrs),...e},b={...O1(p,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,u.pos);const y=m?[{type:l,attrs:x},{type:m,attrs:b}]:[{type:l,attrs:x}];if(!ju(n.doc,c.pos,2))return!1;if(i){const{selection:v,storedMarks:S}=r,{splittableMarks:M}=a.extensionManager,T=S||v.$to.parentOffset&&v.$from.marks();if(n.split(c.pos,2,y).scrollIntoView(),!T||!i)return!0;const E=T.filter(C=>M.includes(C.type.name));n.ensureMarks(E)}return!0},Ej=(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},kj=(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},XVe=(t,e,n,r={})=>({editor:i,tr:a,state:o,dispatch:l,chain:c,commands:u,can:d})=>{const{extensions:f,splittableMarks:p}=i.extensionManager,m=Gi(t,o.schema),x=Gi(e,o.schema),{selection:b,storedMarks:y}=o,{$from:v,$to:S}=b,M=v.blockRange(S),T=y||b.$to.parentOffset&&b.$from.marks();if(!M)return!1;const E=DM(C=>O9(C.type.name,f))(b);if(M.depth>=1&&E&&M.depth-E.depth<=1){if(E.node.type===m)return u.liftListItem(x);if(O9(E.node.type.name,f)&&m.validContent(E.node.content)&&l)return c().command(()=>(a.setNodeMarkup(E.pos,m),!0)).command(()=>Ej(a,m)).command(()=>kj(a,m)).run()}return!n||!T||!l?c().command(()=>d().wrapInList(m,r)?!0:u.clearNodes()).wrapInList(m,r).command(()=>Ej(a,m)).command(()=>kj(a,m)).run():c().command(()=>{const C=d().wrapInList(m,r),k=T.filter(R=>p.includes(R.type.name));return a.ensureMarks(k),C?!0:u.clearNodes()}).wrapInList(m,r).command(()=>Ej(a,m)).command(()=>kj(a,m)).run()},YVe=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,o=Yu(t,r.schema);return VD(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,e)},QVe=(t,e,n={})=>({state:r,commands:i})=>{const a=Gi(t,r.schema),o=Gi(e,r.schema),l=Dh(r,a,n);let c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),l?i.setNode(o,c):i.setNode(a,{...c,...n})},ZVe=(t,e={})=>({state:n,commands:r})=>{const i=Gi(t,n.schema);return Dh(n,i,e)?r.lift(i):r.wrapIn(i,e)},JVe=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let a;if(i.spec.isInputRules&&(a=i.getState(t))){if(e){const o=t.tr,l=a.transform;for(let c=l.steps.length-1;c>=0;c-=1)o.step(l.steps[c].invert(l.docs[c]));if(a.text){const c=o.doc.resolve(a.from).marks();o.replaceWith(a.from,a.to,t.schema.text(a.text,c))}else o.delete(a.from,a.to)}return!0}}return!1},eGe=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(a=>{t.removeMark(a.$from.pos,a.$to.pos)}),!0},tGe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,c=Yu(t,r.schema),{$from:u,empty:d,ranges:f}=l;if(!i)return!0;if(d&&o){let{from:p,to:m}=l;const x=(a=u.marks().find(y=>y.type===c))==null?void 0:a.attrs,b=OL(u,c,x);b&&(p=b.from,m=b.to),n.removeMark(p,m,c)}else f.forEach(p=>{n.removeMark(p.$from.pos,p.$to.pos,c)});return n.removeStoredMark(c),!0},nGe=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let a,o;return typeof t=="number"?(a=t,o=t):t&&"from"in t&&"to"in t?(a=t.from,o=t.to):(a=i.from,o=i.to),r&&e.doc.nodesBetween(a,o,(l,c)=>{if(l.isText)return;const u={...l.attrs};delete u.dir,e.setNodeMarkup(c,void 0,u)}),!0},rGe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=PM(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=Gi(t,r.schema)),l==="mark"&&(o=Yu(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;let p,m,x,b;n.selection.empty?r.doc.nodesBetween(d,f,(y,v)=>{a&&a===y.type&&(c=!0,x=Math.max(v,d),b=Math.min(v+y.nodeSize,f),p=v,m=y)}):r.doc.nodesBetween(d,f,(y,v)=>{v<d&&a&&a===y.type&&(c=!0,x=Math.max(v,d),b=Math.min(v+y.nodeSize,f),p=v,m=y),v>=d&&v<=f&&(a&&a===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 M=Math.max(v,d),T=Math.min(v+y.nodeSize,f);n.addMark(M,T,o.create({...S.attrs,...e}))}}))}),m&&(p!==void 0&&i&&n.setNodeMarkup(p,void 0,{...m.attrs,...e}),o&&m.marks.length&&m.marks.forEach(y=>{o===y.type&&i&&n.addMark(x,b,o.create({...y.attrs,...e}))}))}),c},iGe=(t,e={})=>({state:n,dispatch:r})=>{const i=Gi(t,n.schema);return L6e(i,e)(n,r)},aGe=(t,e={})=>({state:n,dispatch:r})=>{const i=Gi(t,n.schema);return F6e(i,e)(n,r)},sGe=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={}}},OM=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},oGe=(t,e)=>{if(RL(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 n1(t){var e;const{editor:n,from:r,to:i,text:a,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(p=>p.type.spec.code))return!1;let d=!1;const f=OVe(u)+a;return o.forEach(p=>{if(d)return;const m=oGe(f,p.find);if(!m)return;const x=c.state.tr,b=CM({state:c.state,transaction:x}),y={from:r-(m[0].length-a.length),to:i},{commands:v,chain:S,can:M}=new jM({editor:n,state:b});p.handler({state:b,range:y,match:m,commands:v,chain:S,can:M})===null||!x.steps.length||(p.undoable&&x.setMeta(l,{transform:x,from:r,to:i,text:a}),c.dispatch(x),d=!0)}),d}function lGe(t){const{editor:e,rules:n}=t,r=new ui({state:{init(){return null},apply(i,a,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=IL(Et.from(d),o.schema);const{from:f}=c,p=f+d.length;n1({editor:e,from:f,to:p,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:a}},props:{handleTextInput(i,a,o,l){return n1({editor:e,from:a,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&n1({editor:e,from:a.pos,to:a.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,a){if(a.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?n1({editor:e,from:o.pos,to:o.pos,text:`
  8151. `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function cGe(t){return Object.prototype.toString.call(t).slice(8,-1)}function r1(t){return cGe(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function hne(t,e){const n={...t};return r1(t)&&r1(e)&&Object.keys(e).forEach(r=>{r1(e[r])&&r1(t[r])?n[r]=hne(t[r],e[r]):n[r]=e[r]}),n}var BL=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{...gr(Xt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...gr(Xt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>hne(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 fne extends BL{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new fne(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 uGe(t){return typeof t=="number"}var dGe=class{constructor(t){this.find=t.find,this.handler=t.handler}},hGe=(t,e,n)=>{if(RL(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const a=[i.text];return a.index=i.index,a.input=t,a.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),a.push(i.replaceWith)),a}):[]};function fGe(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:l}=t,{commands:c,chain:u,can:d}=new jM({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(m,x)=>{var b,y,v,S,M;if((y=(b=m.type)==null?void 0:b.spec)!=null&&y.code||!(m.isText||m.isTextblock||m.isInline))return;const T=(M=(S=(v=m.content)==null?void 0:v.size)!=null?S:m.nodeSize)!=null?M:0,E=Math.max(r,x),C=Math.min(i,x+T);if(E>=C)return;const k=m.isText?m.text||"":m.textBetween(E-x,C-x,void 0,"");hGe(k,a.find,o).forEach(A=>{if(A.index===void 0)return;const D=E+A.index+1,U=D+A[0].length,F={from:n.tr.mapping.map(D),to:n.tr.mapping.map(U)},H=a.handler({state:n,range:F,match:A,commands:c,chain:u,can:d,pasteEvent:o,dropEvent:l});f.push(H)})}),f.every(m=>m!==null)}var i1=null,mGe=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function pGe(t){const{editor:e,rules:n}=t;let r=null,i=!1,a=!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:p,rule:m,pasteEvt:x})=>{const b=d.tr,y=CM({state:d,transaction:b});if(!(!fGe({editor:e,state:y,from:Math.max(f-1,0),to:p.b-1,rule:m,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 ui({view(f){const p=x=>{var b;r=(b=f.dom.parentElement)!=null&&b.contains(x.target)?f.dom.parentElement:null,r&&(i1=e)},m=()=>{i1&&(i1=null)};return window.addEventListener("dragstart",p),window.addEventListener("dragend",m),{destroy(){window.removeEventListener("dragstart",p),window.removeEventListener("dragend",m)}}},props:{handleDOMEvents:{drop:(f,p)=>{if(a=r===f.dom.parentElement,l=p,!a){const m=i1;m?.isEditable&&setTimeout(()=>{const x=m.state.selection;x&&m.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(f,p)=>{var m;const x=(m=p.clipboardData)==null?void 0:m.getData("text/html");return o=p,i=!!x?.includes("data-pm-slice"),!1}}},appendTransaction:(f,p,m)=>{const x=f[0],b=x.getMeta("uiEvent")==="paste"&&!i,y=x.getMeta("uiEvent")==="drop"&&!a,v=x.getMeta("applyPasteRules"),S=!!v;if(!b&&!y&&!S)return;if(S){let{text:E}=v;typeof E=="string"?E=E:E=IL(Et.from(E),m.schema);const{from:C}=v,k=C+E.length,R=mGe(E);return c({rule:d,state:m,from:C,to:{b:k},pasteEvt:R})}const M=p.doc.content.findDiffStart(m.doc.content),T=p.doc.content.findDiffEnd(m.doc.content);if(!(!uGe(M)||!T||M===T.b))return c({rule:d,state:m,from:M,to:T,pasteEvt:o})}}))}var LM=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=sne(t),this.schema=TVe(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:Mj(e.name,this.schema)},r=Xt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return UL([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Mj(r.name,this.schema)},a=[],o=Xt(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&Xt(r,"exitable",i)&&(l.ArrowRight=()=>$h.handleExit({editor:t,mark:r})),o){const p=Object.fromEntries(Object.entries(o()).map(([m,x])=>[m,()=>x({editor:t})]));l={...l,...p}}const c=jHe(l);a.push(c);const u=Xt(r,"addInputRules",i);if(R9(r,t.options.enableInputRules)&&u){const p=u();if(p&&p.length){const m=lGe({editor:t,rules:p}),x=Array.isArray(m)?m:[m];a.push(...x)}}const d=Xt(r,"addPasteRules",i);if(R9(r,t.options.enablePasteRules)&&d){const p=d();if(p&&p.length){const m=pGe({editor:t,rules:p});a.push(...m)}}const f=Xt(r,"addProseMirrorPlugins",i);if(f){const p=f();a.push(...p)}return a})}get attributes(){return ane(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=dx(this.extensions);return Object.fromEntries(e.filter(n=>!!Xt(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:Gi(n.name,this.schema)},a=Xt(n,"addNodeView",i);if(!a)return[];const o=a();if(!o)return[];const l=(c,u,d,f,p)=>{const m=yN(c,r);return o({node:c,view:u,getPos:d,decorations:f,innerDecorations:p,editor:t,extension:n,HTMLAttributes:m})};return[n.name,l]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=dx(this.extensions);return Object.fromEntries(e.filter(n=>!!Xt(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:Yu(n.name,this.schema)},a=Xt(n,"addMarkView",i);if(!a)return[];const o=(l,c,u)=>{const d=yN(l,r);return a()({mark:l,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{CGe(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:Mj(e.name,this.schema)};e.type==="mark"&&((n=gr(Xt(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Xt(e,"onBeforeCreate",r),a=Xt(e,"onCreate",r),o=Xt(e,"onUpdate",r),l=Xt(e,"onSelectionUpdate",r),c=Xt(e,"onTransaction",r),u=Xt(e,"onFocus",r),d=Xt(e,"onBlur",r),f=Xt(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),a&&this.editor.on("create",a),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)})}};LM.resolve=sne;LM.sort=UL;LM.flatten=FL;var gGe={};DL(gGe,{ClipboardTextSerializer:()=>pne,Commands:()=>gne,Delete:()=>xne,Drop:()=>bne,Editable:()=>yne,FocusEvents:()=>wne,Keymap:()=>_ne,Paste:()=>Sne,Tabindex:()=>Nne,TextDirection:()=>Mne,focusEventsPluginKey:()=>vne});var jr=class mne extends BL{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new mne(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},pne=jr.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new ui({key:new oa("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:a}=i,o=Math.min(...a.map(d=>d.$from.pos)),l=Math.max(...a.map(d=>d.$to.pos)),c=lne(n);return one(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),gne=jr.create({name:"commands",addCommands(){return{...Yte}}}),xne=jr.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const a=()=>{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=rne(t.before,[t,...e]);une(d).forEach(m=>{d.mapping.mapResult(m.oldRange.from).deletedAfter&&d.mapping.mapResult(m.oldRange.to).deletedBefore&&d.before.nodesBetween(m.oldRange.from,m.oldRange.to,(x,b)=>{const y=b+x.nodeSize-2,v=m.oldRange.from<=b&&y<=m.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:m.oldRange,newRange:m.newRange,partial:!v,editor:this.editor,transaction:t,combinedTransform:d})})});const p=d.mapping;d.steps.forEach((m,x)=>{var b,y;if(m instanceof Rl){const v=p.slice(x).map(m.from,-1),S=p.slice(x).map(m.to),M=p.invert().map(v,-1),T=p.invert().map(S),E=(b=d.doc.nodeAt(v-1))==null?void 0:b.marks.some(k=>k.eq(m.mark)),C=(y=d.doc.nodeAt(S))==null?void 0:y.marks.some(k=>k.eq(m.mark));this.editor.emit("delete",{type:"mark",mark:m.mark,from:m.from,to:m.to,deletedRange:{from:M,to:T},newRange:{from:v,to:S},partial:!!(C||E),editor:this.editor,transaction:t,combinedTransform:d})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(a,0):a()}}),bne=jr.create({name:"drop",addProseMirrorPlugins(){return[new ui({key:new oa("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),yne=jr.create({name:"editable",addProseMirrorPlugins(){return[new ui({key:new oa("editable"),props:{editable:()=>this.editor.options.editable}})]}}),vne=new oa("focusEvents"),wne=jr.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new ui({key:vne,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}}}})]}}),_ne=jr.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:p,parent:m}=f,x=f.parent.isTextblock&&p>0?l.doc.resolve(p-1):f,b=x.parent.type.spec.isolating,y=f.pos-f.parentOffset,v=b&&x.parent.childCount===1?y===f.pos:An.atStart(u).from===p;return!d||!m.type.isTextblock||m.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},a={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return LL()||tne()?a:i},addProseMirrorPlugins(){return[new ui({key:new oa("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:a,from:o,to:l}=e.selection,c=An.atStart(e.doc).from,u=An.atEnd(e.doc).to;if(a||!(o===c&&l===u)||!RM(n.doc))return;const p=n.tr,m=CM({state:n,transaction:p}),{commands:x}=new jM({editor:this.editor,state:m});if(x.clearNodes(),!!p.steps.length)return p}})]}}),Sne=jr.create({name:"paste",addProseMirrorPlugins(){return[new ui({key:new oa("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Nne=jr.create({name:"tabindex",addProseMirrorPlugins(){return[new ui({key:new oa("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Mne=jr.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 ui({key:new oa("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),xGe=class ug{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 ug(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 ug(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 ug(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=this.pos+r+(a?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 ug(l,this.editor,i,i?n:null);i&&(c.actualDepth=this.depth+1),e.push(new ug(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 a=i.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const c=o[l];if(a[c]!==n[c])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const a=Object.keys(n);return this.children.forEach(o=>{r&&i.length>0||(o.node.type.name===e&&a.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)}},bGe=`.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 yGe(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 vGe=class extends sGe{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:i,moved:a})=>this.options.onDrop(r,i,a)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=Jte(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=yGe(bGe,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=ine(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(i=>{const a=typeof i=="string"?`${i}$`:i.key;n=n.filter(o=>!o.key.startsWith(a))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[yne,pne.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),gne,wne,_ne,Nne,bne,Sne,xne,Mne.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 LM(r,this)}createCommandManager(){this.commandManager=new jM({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=HD(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=HD(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new Kte(t,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS();const r=this.view.dom;r.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(u=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(u)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),i=n.includes(t),a=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const 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)||a.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return cne(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return LVe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return IL(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
  8210. `,textSerializers:n={}}=t||{};return CVe(this.state.doc,{blockSeparator:e,textSerializers:{...lne(this.schema),...n}})}get isEmpty(){return RM(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 xGe(e,this)}get $doc(){return this.$pos(0)}};function hx(t){return new OM({find:t.find,handler:({state:e,range:n,match:r})=>{const i=gr(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:a}=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(zL(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(b=>b===t.type&&b!==m.mark.type)).filter(m=>m.to>u).length)return null;d<n.to&&a.delete(d,n.to),u>n.from&&a.delete(n.from+c,u);const p=n.from+c+o.length;a.addMark(n.from+c,p,t.type.create(i||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function Ene(t){return new OM({find:t.find,handler:({state:e,range:n,match:r})=>{const i=gr(t.getAttributes,void 0,r)||{},{tr:a}=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];a.insertText(f,o+r[0].length-1),a.replaceWith(d,l,c)}else if(r[0]){const u=t.type.isInline?o:o-1;a.insert(u,t.type.create(i)).delete(a.mapping.map(o),a.mapping.map(l))}a.scrollIntoView()},undoable:t.undoable})}function GD(t){return new OM({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=gr(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,a)},undoable:t.undoable})}function fx(t){return new OM({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=gr(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),c=o.doc.resolve(n.from).blockRange(),u=c&&xL(c,t.type,a);if(!u)return null;if(o.wrap(c,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:p}=e,{splittableMarks:m}=t.editor.extensionManager,x=p||f.$to.parentOffset&&f.$from.marks();if(x){const b=x.filter(y=>m.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,a).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 wGe=t=>"touches"in t,_Ge=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,a;this.node=t.node,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t?.options)!=null&&r.directions&&(this.directions=t.options.directions),(i=t.options)!=null&&i.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(a=t.options)!=null&&a.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles()}get dom(){return this.container}get contentDOM(){return this.contentElement}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",t.style.justifyContent="flex-start",t.style.alignItems="flex-start",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),i=e.includes("left"),a=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(t.style.left="0"),a&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{const e=this.createHandle(t);this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.wrapper.appendChild(e)})}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,wGe(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,t,e),a=this.applyConstraints(r,i,n);this.element.style.width=`${a.width}px`,this.element.style.height=`${a.height}px`,this.onResize&&this.onResize(a.width,a.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,i=this.startHeight;const a=t.includes("right"),o=t.includes("left"),l=t.includes("bottom"),c=t.includes("top");return a?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+(a?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,a,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),(a=this.maxSize)!=null&&a.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 SGe(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Qt){const a=r.index();return r.parent.canReplaceWith(a,a+1,e)}let i=r.depth;for(;i>=0;){const a=r.index(i);if(r.node(i).contentMatchAt(a).matchType(e))return!0;i-=1}return!1}var NGe={};DL(NGe,{createAtomBlockMarkdownSpec:()=>MGe,createBlockMarkdownSpec:()=>EGe,createInlineMarkdownSpec:()=>AGe,parseAttributes:()=>$L,parseIndentedBlocks:()=>qD,renderNestedMarkdownContent:()=>VL,serializeAttributes:()=>HL});function $L(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,u=>(n.push(u),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const u=i.map(d=>d.trim().slice(1));e.class=u.join(" ")}const a=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(e.id=a[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,u,d])=>{var f;const p=parseInt(((f=d.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),m=n[p];m&&(e[u]=m.slice(1,-1))});const c=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return c&&c.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function HL(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 MGe(t){const{nodeName:e,name:n,parseAttributes:r=$L,serializeAttributes:i=HL,defaultAttributes:a={},requiredAttributes:o=[],allowedAttributes:l}=t,c=n||e,u=d=>{if(!l)return d;const f={};return l.forEach(p=>{p in d&&(f[p]=d[p])}),f};return{parseMarkdown:(d,f)=>{const p={...a,...d.attributes};return f.createNode(e,p,[])},markdownTokenizer:{name:e,level:"block",start(d){var f;const p=new RegExp(`^:::${c}(?:\\s|$)`,"m"),m=(f=d.match(p))==null?void 0:f.index;return m!==void 0?m:-1},tokenize(d,f,p){const m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),x=d.match(m);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||{}),p=i(f),m=p?` {${p}}`:"";return`:::${c}${m} :::`}}}function EGe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=$L,serializeAttributes:a=HL,defaultAttributes:o={},content:l="block",allowedAttributes:c}=t,u=n||e,d=f=>{if(!c)return f;const p={};return c.forEach(m=>{m in f&&(p[m]=f[m])}),p};return{parseMarkdown:(f,p)=>{let m;if(r){const b=r(f);m=typeof b=="string"?[{type:"text",text:b}]:b}else l==="block"?m=p.parseChildren(f.tokens||[]):m=p.parseInline(f.tokens||[]);const x={...o,...f.attributes};return p.createNode(e,x,m)},markdownTokenizer:{name:e,level:"block",start(f){var p;const m=new RegExp(`^:::${u}`,"m"),x=(p=f.match(m))==null?void 0:p.index;return x!==void 0?x:-1},tokenize(f,p,m){var x;const b=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),y=f.match(b);if(!y)return;const[v,S=""]=y,M=i(S);let T=1;const E=v.length;let C="";const k=/^:::([\w-]*)(\s.*)?/gm,R=f.slice(E);for(k.lastIndex=0;;){const A=k.exec(R);if(A===null)break;const D=A.index,U=A[1];if(!((x=A[2])!=null&&x.endsWith(":::"))){if(U)T+=1;else if(T-=1,T===0){const F=R.slice(0,D);C=F.trim();const H=f.slice(0,E+D+A[0].length);let j=[];if(C)if(l==="block")for(j=m.blockTokens(F),j.forEach($=>{$.text&&(!$.tokens||$.tokens.length===0)&&($.tokens=m.inlineTokens($.text))});j.length>0;){const $=j[j.length-1];if($.type==="paragraph"&&(!$.text||$.text.trim()===""))j.pop();else break}else j=m.inlineTokens(C);return{type:e,raw:H,attributes:M,content:C,tokens:j}}}}}},renderMarkdown:(f,p)=>{const m=d(f.attrs||{}),x=a(m),b=x?` {${x}}`:"",y=p.renderChildren(f.content||[],`
  8211. `);return`:::${u}${b}
  8212. ${y}
  8213. :::`}}}function kGe(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,a,o]=r;e[i]=a||o,r=n.exec(t)}return e}function TGe(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function AGe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=kGe,serializeAttributes:a=TGe,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:c}=t,u=n||e,d=p=>{if(!c)return p;const m={};return c.forEach(x=>{x in p&&(m[x]=p[x])}),m},f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(p,m)=>{const x={...o,...p.attributes};if(l)return m.createNode(e,x);const b=r?r(p):p.content||"";return b?m.createNode(e,x,[m.createTextNode(b)]):m.createNode(e,x,[])},markdownTokenizer:{name:e,level:"inline",start(p){const m=l?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),x=p.match(m),b=x?.index;return b!==void 0?b:-1},tokenize(p,m,x){const b=l?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),y=p.match(b);if(!y)return;let v="",S="";if(l){const[,T]=y;S=T}else{const[,T,E]=y;S=T,v=E||""}const M=i(S.trim());return{type:e,raw:y[0],content:v.trim(),attributes:M}}},renderMarkdown:p=>{let m="";r?m=r(p):p.content&&p.content.length>0&&(m=p.content.filter(v=>v.type==="text").map(v=>v.text).join(""));const x=d(p.attrs||{}),b=a(x),y=b?` ${b}`:"";return l?`[${u}${y}]`:`[${u}${y}]${m}[/${u}]`}}}function qD(t,e,n){var r,i,a,o;const l=t.split(`
  8214. `),c=[];let u="",d=0;const f=e.baseIndentSize||2;for(;d<l.length;){const p=l[d],m=p.match(e.itemPattern);if(!m){if(c.length>0)break;if(p.trim()===""){d+=1,u=`${u}${p}
  8215. `;continue}else return}const x=e.extractItemData(m),{indentLevel:b,mainContent:y}=x;u=`${u}${p}
  8216. `;const v=[y];for(d+=1;d<l.length;){const E=l[d];if(E.trim()===""){const k=l.slice(d+1).findIndex(D=>D.trim()!=="");if(k===-1)break;if((((i=(r=l[d+1+k].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>b){v.push(E),u=`${u}${E}
  8217. `,d+=1;continue}else break}if((((o=(a=E.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:o.length)||0)>b)v.push(E),u=`${u}${E}
  8218. `,d+=1;else break}let S;const M=v.slice(1);if(M.length>0){const E=M.map(C=>C.slice(b+f)).join(`
  8219. `);E.trim()&&(e.customNestedParser?S=e.customNestedParser(E):S=n.blockTokens(E))}const T=e.createToken(x,S);c.push(T)}if(c.length!==0)return{items:c,raw:u}}function VL(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[a,...o]=t.content,l=e.renderChildren([a]),c=[`${i}${l}`];return o&&o.length>0&&o.forEach(u=>{const d=e.renderChildren([u]);if(d){const f=d.split(`
  8220. `).map(p=>p?e.indent(p):"").join(`
  8221. `);c.push(f)}}),c.join(`
  8222. `)}function CGe(t,e,n={}){const{state:r}=e,{doc:i,tr:a}=r,o=t;i.descendants((l,c)=>{const u=a.mapping.map(c),d=a.mapping.map(c)+l.nodeSize;let f=null;if(l.marks.forEach(m=>{if(m!==o)return!1;f=m}),!f)return;let p=!1;if(Object.keys(n).forEach(m=>{n[m]!==f.attrs[m]&&(p=!0)}),p){const m=t.type.create({...t.attrs,...n});a.removeMark(u,d,t.type),a.addMark(u,d,m)}}),a.docChanged&&e.view.dispatch(a)}var Gs=class kne extends BL{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new kne(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Mm(t){return new dGe({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=gr(t.getAttributes,void 0,r,i);if(a===!1||a===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),p=f+l.length;if(zL(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;p<n.to&&o.delete(p,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(a||{})),o.removeStoredMark(t.type)}}})}var Tj,F9;function jGe(){return F9||(F9=1,Tj=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!t(e[i],n[i]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;for(i of e.entries())if(!t(i[1],n.get(i[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(e[i]!==n[i])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(a=Object.keys(e),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!(o==="_owner"&&e.$$typeof)&&!t(e[o],n[o]))return!1}return!0}return e!==e&&n!==n}),Tj}var PGe=jGe();const DGe=hl(PGe);var RGe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},OGe=({contentComponent:t})=>{const e=fR.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(e)})};function LGe(){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]:wle.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 FGe=class extends Jr.Component{constructor(t){var e;super(t),this.editorContentRef=Jr.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=LGe(),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 s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:RGe(e,this.editorContentRef),...n}),t?.contentComponent&&s.jsx(OGe,{contentComponent:t.contentComponent})]})}},IGe=_.forwardRef((t,e)=>{const n=Jr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Jr.createElement(FGe,{key:n,innerRef:e,...t})}),UGe=Jr.memo(IGe),zGe=typeof window<"u"?_.useLayoutEffect:_.useEffect,BGe=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 $Ge(t){var e;const[n]=_.useState(()=>new BGe(t.editor)),r=xK.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:DGe);return zGe(()=>n.watch(t.editor),[t.editor,n]),_.useDebugValue(r),r}var HGe=!1,WD=typeof window>"u",VGe=WD||!!(typeof window<"u"&&window.next),GGe=class Tne{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?WD||VGe?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onBeforeCreate)==null?void 0:a.call(i,...r)},onBlur:(...r)=>{var i,a;return(a=(i=this.options.current).onBlur)==null?void 0:a.call(i,...r)},onCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onCreate)==null?void 0:a.call(i,...r)},onDestroy:(...r)=>{var i,a;return(a=(i=this.options.current).onDestroy)==null?void 0:a.call(i,...r)},onFocus:(...r)=>{var i,a;return(a=(i=this.options.current).onFocus)==null?void 0:a.call(i,...r)},onSelectionUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onSelectionUpdate)==null?void 0:a.call(i,...r)},onTransaction:(...r)=>{var i,a;return(a=(i=this.options.current).onTransaction)==null?void 0:a.call(i,...r)},onUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onUpdate)==null?void 0:a.call(i,...r)},onContentError:(...r)=>{var i,a;return(a=(i=this.options.current).onContentError)==null?void 0:a.call(i,...r)},onDrop:(...r)=>{var i,a;return(a=(i=this.options.current).onDrop)==null?void 0:a.call(i,...r)},onPaste:(...r)=>{var i,a;return(a=(i=this.options.current).onPaste)==null?void 0:a.call(i,...r)},onDelete:(...r)=>{var i,a;return(a=(i=this.options.current).onDelete)==null?void 0:a.call(i,...r)}};return new vGe(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((i,a)=>{var o;return i===((o=n.extensions)==null?void 0:o[a])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Tne.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 qGe(t={},e=[]){const n=_.useRef(t);n.current=t;const[r]=_.useState(()=>new GGe(n)),i=fR.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return _.useDebugValue(i),_.useEffect(r.onRender(e)),$Ge({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var WGe=_.createContext({editor:null});WGe.Consumer;var KGe=_.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),XGe=()=>_.useContext(KGe);Jr.forwardRef((t,e)=>{const{onDragStart:n}=XGe(),r=t.as||"div";return s.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});Jr.createContext({markViewContentRef:()=>{}});var vN=(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]},YGe=/^\s*>\s$/,QGe=Gs.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return vN("blockquote",{...vi(this.options.HTMLAttributes,t),children:vN("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:YGe,type:this.type})]}}),ZGe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,JGe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,e7e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,t7e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,n7e=$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 vN("strong",{...vi(this.options.HTMLAttributes,t),children:vN("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:ZGe,type:this.type}),hx({find:e7e,type:this.type})]},addPasteRules(){return[Mm({find:JGe,type:this.type}),Mm({find:t7e,type:this.type})]}}),r7e=/(^|[^`])`([^`]+)`(?!`)$/,i7e=/(^|[^`])`([^`]+)`(?!`)/g,a7e=$h.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",vi(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:r7e,type:this.type})]},addPasteRules(){return[Mm({find:i7e,type:this.type})]}}),Aj=4,s7e=/^```([a-z]+)?[\s\n]$/,o7e=/^~~~([a-z]+)?[\s\n]$/,l7e=Gs.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Aj,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const a=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return a||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",vi(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:Aj,{state:r}=t,{selection:i}=r,{$from:a,empty:o}=i;if(a.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,m=r.doc.textBetween(u,d,`
  8229. `,`
  8230. `).split(`
  8231. `).map(x=>l+x).join(`
  8232. `);return c.replaceWith(u,d,r.schema.text(m)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Aj,{state:r}=t,{selection:i}=r,{$from:a,empty:o}=i;return a.parent.type!==this.type?!1:o?t.commands.command(({tr:l})=>{var c;const{pos:u}=a,d=a.start(),f=a.end(),m=r.doc.textBetween(d,f,`
  8233. `,`
  8234. `).split(`
  8235. `);let x=0,b=0;const y=u-d;for(let C=0;C<m.length;C+=1){if(b+m[C].length>=y){x=C;break}b+=m[C].length+1}const S=((c=m[x].match(/^ */))==null?void 0:c[0])||"",M=Math.min(S.length,n);if(M===0)return!0;let T=d;for(let C=0;C<x;C+=1)T+=m[C].length+1;return l.delete(T,T+M),u-T<=M&&l.setSelection(mn.create(l.doc,T)),!0}):t.commands.command(({tr:l})=>{const{from:c,to:u}=i,p=r.doc.textBetween(c,u,`
  8236. `,`
  8237. `).split(`
  8238. `).map(m=>{var x;const b=((x=m.match(/^ */))==null?void 0:x[0])||"",y=Math.min(b.length,n);return m.slice(y)}).join(`
  8239. `);return l.replaceWith(c,u,r.schema.text(p)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
  8240. `);return!a||!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:a}=n;if(!a||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(An.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[GD({find:s7e,type:this.type,getAttributes:t=>({language:t[1]})}),GD({find:o7e,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new ui({key:new oa("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,a=i?.mode;if(!n||!a)return!1;const{tr:o,schema:l}=t.state,c=l.text(n.replace(/\r\n?/g,`
  8241. `));return o.replaceSelectionWith(this.type.create({language:a},c)),o.selection.$from.parent.type!==this.type&&o.setSelection(mn.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),c7e=Gs.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
  8242. `):""}),u7e=Gs.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",vi(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:a}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,c=a||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(p=>l.includes(p.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),d7e=Gs.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]}`,vi(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=>GD({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),h7e=Gs.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",vi(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!SGe(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return dne(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:a,tr:o,dispatch:l})=>{if(l){const{$to:c}=o.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(mn.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(Qt.create(o.doc,c.pos)):o.setSelection(mn.create(o.doc,c.pos));else{const d=a.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,f=d?.create();f&&(o.insert(u,f),o.setSelection(mn.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Ene({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),f7e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,m7e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,p7e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,g7e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,x7e=$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",vi(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:f7e,type:this.type}),hx({find:p7e,type:this.type})]},addPasteRules(){return[Mm({find:m7e,type:this.type}),Mm({find:g7e,type:this.type})]}});const b7e="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",y7e="ελ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",KD="numeric",XD="ascii",YD="alpha",j0="asciinumeric",m0="alphanumeric",QD="domain",Ane="emoji",v7e="scheme",w7e="slashscheme",Cj="whitespace";function _7e(t,e){return t in e||(e[t]=[]),e[t]}function Uf(t,e,n){e[KD]&&(e[j0]=!0,e[m0]=!0),e[XD]&&(e[j0]=!0,e[YD]=!0),e[j0]&&(e[m0]=!0),e[YD]&&(e[m0]=!0),e[m0]&&(e[QD]=!0),e[Ane]&&(e[QD]=!0);for(const r in e){const i=_7e(r,n);i.indexOf(t)<0&&i.push(t)}}function S7e(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Os(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Os.groups={};Os.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],a=e.jr[r][1];if(a&&i.test(t))return a}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||Os.groups;let i;return e&&e.j?i=e:(i=new Os(e),n&&r&&Uf(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const a=t.length;if(!a)return i;for(let o=0;o<a-1;o++)i=i.tt(t[o]);return i.tt(t[a-1],e,n,r)},tt(t,e,n,r){r=r||Os.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const a=e;let o,l=i.go(t);if(l?(o=new Os,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new Os,a){if(r)if(o.t&&typeof o.t=="string"){const c=Object.assign(S7e(o.t,r),n);Uf(a,c,r)}else n&&Uf(a,n,r);o.t=a}return i.j[t]=o,o}};const Mn=(t,e,n,r,i)=>t.ta(e,n,r,i),fi=(t,e,n,r,i)=>t.tr(e,n,r,i),I9=(t,e,n,r,i)=>t.ts(e,n,r,i),Ct=(t,e,n,r,i)=>t.tt(e,n,r,i),cu="WORD",ZD="UWORD",Cne="ASCIINUMERICAL",jne="ALPHANUMERICAL",Ay="LOCALHOST",JD="TLD",eR="UTLD",L1="SCHEME",dg="SLASH_SCHEME",GL="NUM",tR="WS",qL="NL",P0="OPENBRACE",D0="CLOSEBRACE",wN="OPENBRACKET",_N="CLOSEBRACKET",SN="OPENPAREN",NN="CLOSEPAREN",MN="OPENANGLEBRACKET",EN="CLOSEANGLEBRACKET",kN="FULLWIDTHLEFTPAREN",TN="FULLWIDTHRIGHTPAREN",AN="LEFTCORNERBRACKET",CN="RIGHTCORNERBRACKET",jN="LEFTWHITECORNERBRACKET",PN="RIGHTWHITECORNERBRACKET",DN="FULLWIDTHLESSTHAN",RN="FULLWIDTHGREATERTHAN",ON="AMPERSAND",LN="APOSTROPHE",FN="ASTERISK",Vd="AT",IN="BACKSLASH",UN="BACKTICK",zN="CARET",Yd="COLON",WL="COMMA",BN="DOLLAR",Jl="DOT",$N="EQUALS",KL="EXCLAMATION",Bo="HYPHEN",R0="PERCENT",HN="PIPE",VN="PLUS",GN="POUND",O0="QUERY",XL="QUOTE",Pne="FULLWIDTHMIDDLEDOT",YL="SEMI",ec="SLASH",L0="TILDE",qN="UNDERSCORE",Dne="EMOJI",WN="SYM";var Rne=Object.freeze({__proto__:null,ALPHANUMERICAL:jne,AMPERSAND:ON,APOSTROPHE:LN,ASCIINUMERICAL:Cne,ASTERISK:FN,AT:Vd,BACKSLASH:IN,BACKTICK:UN,CARET:zN,CLOSEANGLEBRACKET:EN,CLOSEBRACE:D0,CLOSEBRACKET:_N,CLOSEPAREN:NN,COLON:Yd,COMMA:WL,DOLLAR:BN,DOT:Jl,EMOJI:Dne,EQUALS:$N,EXCLAMATION:KL,FULLWIDTHGREATERTHAN:RN,FULLWIDTHLEFTPAREN:kN,FULLWIDTHLESSTHAN:DN,FULLWIDTHMIDDLEDOT:Pne,FULLWIDTHRIGHTPAREN:TN,HYPHEN:Bo,LEFTCORNERBRACKET:AN,LEFTWHITECORNERBRACKET:jN,LOCALHOST:Ay,NL:qL,NUM:GL,OPENANGLEBRACKET:MN,OPENBRACE:P0,OPENBRACKET:wN,OPENPAREN:SN,PERCENT:R0,PIPE:HN,PLUS:VN,POUND:GN,QUERY:O0,QUOTE:XL,RIGHTCORNERBRACKET:CN,RIGHTWHITECORNERBRACKET:PN,SCHEME:L1,SEMI:YL,SLASH:ec,SLASH_SCHEME:dg,SYM:WN,TILDE:L0,TLD:JD,UNDERSCORE:qN,UTLD:eR,UWORD:ZD,WORD:cu,WS:tR});const iu=/[a-z]/,e0=new RegExp("\\p{L}","u"),jj=new RegExp("\\p{Emoji}","u"),au=/\d/,Pj=/\s/,U9="\r",Dj=`
  8245. `,N7e="️",M7e="‍",Rj="";let a1=null,s1=null;function E7e(t=[]){const e={};Os.groups=e;const n=new Os;a1==null&&(a1=z9(b7e)),s1==null&&(s1=z9(y7e)),Ct(n,"'",LN),Ct(n,"{",P0),Ct(n,"}",D0),Ct(n,"[",wN),Ct(n,"]",_N),Ct(n,"(",SN),Ct(n,")",NN),Ct(n,"<",MN),Ct(n,">",EN),Ct(n,"(",kN),Ct(n,")",TN),Ct(n,"「",AN),Ct(n,"」",CN),Ct(n,"『",jN),Ct(n,"』",PN),Ct(n,"<",DN),Ct(n,">",RN),Ct(n,"&",ON),Ct(n,"*",FN),Ct(n,"@",Vd),Ct(n,"`",UN),Ct(n,"^",zN),Ct(n,":",Yd),Ct(n,",",WL),Ct(n,"$",BN),Ct(n,".",Jl),Ct(n,"=",$N),Ct(n,"!",KL),Ct(n,"-",Bo),Ct(n,"%",R0),Ct(n,"|",HN),Ct(n,"+",VN),Ct(n,"#",GN),Ct(n,"?",O0),Ct(n,'"',XL),Ct(n,"/",ec),Ct(n,";",YL),Ct(n,"~",L0),Ct(n,"_",qN),Ct(n,"\\",IN),Ct(n,"・",Pne);const r=fi(n,au,GL,{[KD]:!0});fi(r,au,r);const i=fi(r,iu,Cne,{[j0]:!0}),a=fi(r,e0,jne,{[m0]:!0}),o=fi(n,iu,cu,{[XD]:!0});fi(o,au,i),fi(o,iu,o),fi(i,au,i),fi(i,iu,i);const l=fi(n,e0,ZD,{[YD]:!0});fi(l,iu),fi(l,au,a),fi(l,e0,l),fi(a,au,a),fi(a,iu),fi(a,e0,a);const c=Ct(n,Dj,qL,{[Cj]:!0}),u=Ct(n,U9,tR,{[Cj]:!0}),d=fi(n,Pj,tR,{[Cj]:!0});Ct(n,Rj,d),Ct(u,Dj,c),Ct(u,Rj,d),fi(u,Pj,d),Ct(d,U9),Ct(d,Dj),fi(d,Pj,d),Ct(d,Rj,d);const f=fi(n,jj,Dne,{[Ane]:!0});Ct(f,"#"),fi(f,jj,f),Ct(f,N7e,f);const p=Ct(f,M7e);Ct(p,"#"),fi(p,jj,f);const m=[[iu,o],[au,i]],x=[[iu,null],[e0,l],[au,a]];for(let b=0;b<a1.length;b++)Ld(n,a1[b],JD,cu,m);for(let b=0;b<s1.length;b++)Ld(n,s1[b],eR,ZD,x);Uf(JD,{tld:!0,ascii:!0},e),Uf(eR,{utld:!0,alpha:!0},e),Ld(n,"file",L1,cu,m),Ld(n,"mailto",L1,cu,m),Ld(n,"http",dg,cu,m),Ld(n,"https",dg,cu,m),Ld(n,"ftp",dg,cu,m),Ld(n,"ftps",dg,cu,m),Uf(L1,{scheme:!0,ascii:!0},e),Uf(dg,{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]?{[v7e]:!0}:{[w7e]:!0};y.indexOf("-")>=0?S[QD]=!0:iu.test(y)?au.test(y)?S[j0]=!0:S[XD]=!0:S[KD]=!0,I9(n,y,y,S)}return I9(n,"localhost",Ay,{ascii:!0}),n.jd=new Os(WN),{start:n,tokens:Object.assign({groups:e},Rne)}}function One(t,e){const n=k7e(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,i=[];let a=0,o=0;for(;o<r;){let l=t,c=null,u=0,d=null,f=-1,p=-1;for(;o<r&&(c=l.go(n[o]));)l=c,l.accepts()?(f=0,p=0,d=l):f>=0&&(f+=n[o].length,p++),u+=n[o].length,a+=n[o].length,o++;a-=f,o-=p,u-=f,i.push({t:d.t,v:e.slice(a-u,a),s:a-u,e:a})}return i}function k7e(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),a,o=i<55296||i>56319||r+1===n||(a=t.charCodeAt(r+1))<56320||a>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function Ld(t,e,n,r,i){let a;const o=e.length;for(let l=0;l<o-1;l++){const c=e[l];t.j[c]?a=t.j[c]:(a=new Os(r),a.jr=i.slice(),t.j[c]=a),t=a}return a=new Os(n),a.jr=i.slice(),t.j[e[o-1]]=a,a}function z9(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let a=0;for(;i.indexOf(t[r+a])>=0;)a++;if(a>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+a),10);o>0;o--)n.pop();r+=a}else n.push(t[r]),r++}return e}const Cy={defaultProtocol:"http",events:null,format:B9,formatHref:B9,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function QL(t,e=null){let n=Object.assign({},Cy);t&&(n=Object.assign(n,t instanceof QL?t.o:t));const r=n.ignoreTags,i=[];for(let a=0;a<r.length;a++)i.push(r[a].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}QL.prototype={o:Cy,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]:Cy[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 B9(t){return t}function Lne(t,e){this.t="token",this.v=t,this.tk=e}Lne.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=Cy.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),a=this.toFormattedString(t),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:a,eventListeners:f}}};function FM(t,e){class n extends Lne{constructor(i,a){super(i,a),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const $9=FM("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),H9=FM("text"),T7e=FM("nl"),o1=FM("url",{isLink:!0,toHref(t=Cy.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===Yd}}),Io=t=>new Os(t);function A7e({groups:t}){const e=t.domain.concat([ON,FN,Vd,IN,UN,zN,BN,$N,Bo,GL,R0,HN,VN,GN,ec,WN,L0,qN]),n=[LN,Yd,WL,Jl,KL,R0,O0,XL,YL,MN,EN,P0,D0,_N,wN,SN,NN,kN,TN,AN,CN,jN,PN,DN,RN],r=[ON,LN,FN,IN,UN,zN,BN,$N,Bo,P0,D0,R0,HN,VN,GN,O0,ec,WN,L0,qN],i=Io(),a=Ct(i,L0);Mn(a,r,a),Mn(a,t.domain,a);const o=Io(),l=Io(),c=Io();Mn(i,t.domain,o),Mn(i,t.scheme,l),Mn(i,t.slashscheme,c),Mn(o,r,a),Mn(o,t.domain,o);const u=Ct(o,Vd);Ct(a,Vd,u),Ct(l,Vd,u),Ct(c,Vd,u);const d=Ct(a,Jl);Mn(d,r,a),Mn(d,t.domain,a);const f=Io();Mn(u,t.domain,f),Mn(f,t.domain,f);const p=Ct(f,Jl);Mn(p,t.domain,f);const m=Io($9);Mn(p,t.tld,m),Mn(p,t.utld,m),Ct(u,Ay,m);const x=Ct(f,Bo);Ct(x,Bo,x),Mn(x,t.domain,f),Mn(m,t.domain,f),Ct(m,Jl,p),Ct(m,Bo,x);const b=Ct(m,Yd);Mn(b,t.numeric,$9);const y=Ct(o,Bo),v=Ct(o,Jl);Ct(y,Bo,y),Mn(y,t.domain,o),Mn(v,r,a),Mn(v,t.domain,o);const S=Io(o1);Mn(v,t.tld,S),Mn(v,t.utld,S),Mn(S,t.domain,o),Mn(S,r,a),Ct(S,Jl,v),Ct(S,Bo,y),Ct(S,Vd,u);const M=Ct(S,Yd),T=Io(o1);Mn(M,t.numeric,T);const E=Io(o1),C=Io();Mn(E,e,E),Mn(E,n,C),Mn(C,e,E),Mn(C,n,C),Ct(S,ec,E),Ct(T,ec,E);const k=Ct(l,Yd),R=Ct(c,Yd),A=Ct(R,ec),D=Ct(A,ec);Mn(l,t.domain,o),Ct(l,Jl,v),Ct(l,Bo,y),Mn(c,t.domain,o),Ct(c,Jl,v),Ct(c,Bo,y),Mn(k,t.domain,E),Ct(k,ec,E),Ct(k,O0,E),Mn(D,t.domain,E),Mn(D,e,E),Ct(D,ec,E);const U=[[P0,D0],[wN,_N],[SN,NN],[MN,EN],[kN,TN],[AN,CN],[jN,PN],[DN,RN]];for(let F=0;F<U.length;F++){const[H,j]=U[F],$=Ct(E,H);Ct(C,H,$),Ct($,j,E);const K=Io(o1);Mn($,e,K);const V=Io();Mn($,n),Mn(K,e,K),Mn(K,n,V),Mn(V,e,K),Mn(V,n,V),Ct(K,j,E),Ct(V,j,E)}return Ct(i,Ay,S),Ct(i,qL,T7e),{start:i,tokens:Rne}}function C7e(t,e,n){let r=n.length,i=0,a=[],o=[];for(;i<r;){let l=t,c=null,u=null,d=0,f=null,p=-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()?(p=0,f=l):p>=0&&p++,i++,d++;if(p<0)i-=d,i<r&&(o.push(n[i]),i++);else{o.length>0&&(a.push(Oj(H9,e,o)),o=[]),i-=p,d-=p;const m=f.t,x=n.slice(i-d,i);a.push(Oj(m,e,x))}}return o.length>0&&a.push(Oj(H9,e,o)),a}function Oj(t,e,n){const r=n[0].s,i=n[n.length-1].e,a=e.slice(r,i);return new t(a,n)}const j7e=typeof console<"u"&&console&&console.warn||(()=>{}),P7e="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",qr={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function D7e(){return Os.groups={},qr.scanner=null,qr.parser=null,qr.tokenQueue=[],qr.pluginQueue=[],qr.customSchemes=[],qr.initialized=!1,qr}function V9(t,e=!1){if(qr.initialized&&j7e(`linkifyjs: already initialized - will not register custom scheme "${t}" ${P7e}`),!/^[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`);qr.customSchemes.push([t,e])}function R7e(){qr.scanner=E7e(qr.customSchemes);for(let t=0;t<qr.tokenQueue.length;t++)qr.tokenQueue[t][1]({scanner:qr.scanner});qr.parser=A7e(qr.scanner.tokens);for(let t=0;t<qr.pluginQueue.length;t++)qr.pluginQueue[t][1]({scanner:qr.scanner,parser:qr.parser});return qr.initialized=!0,qr}function ZL(t){return qr.initialized||R7e(),C7e(qr.parser.start,t,One(qr.scanner.start,t))}ZL.scan=One;function Fne(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 QL(n),i=ZL(t),a=[];for(let o=0;o<i.length;o++){const l=i[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&a.push(l.toFormattedObject(r))}return a}var JL="[\0-   ᠎ -\u2029  ]",O7e=new RegExp(JL),L7e=new RegExp(`${JL}$`),F7e=new RegExp(JL,"g");function I7e(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function U7e(t){return new ui({key:new oa("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(u=>u.docChanged)&&!n.doc.eq(r.doc),a=e.some(u=>u.getMeta("preventAutolink"));if(!i||a)return;const{tr:o}=r,l=rne(n.doc,[...e]);if(une(l).forEach(({newRange:u})=>{const d=NVe(r.doc,u,m=>m.isTextblock);let f,p;if(d.length>1)f=d[0],p=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(d.length){const m=r.doc.textBetween(u.from,u.to," "," ");if(!L7e.test(m))return;f=d[0],p=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&p){const m=p.split(O7e).filter(Boolean);if(m.length<=0)return!1;const x=m[m.length-1],b=f.pos+p.lastIndexOf(x);if(!x)return!1;const y=ZL(x).map(v=>v.toObject(t.defaultProtocol));if(!I7e(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=>{zL(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 z7e(t){return new ui({key:new oa("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,a;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(p=>p.nodeName==="A")}if(!o)return!1;const l=cne(e.state,t.type.name),c=(i=o?.href)!=null?i:l.href,u=(a=o?.target)!=null?a:l.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),o&&c?(window.open(c,u),!0):!1}}})}function B7e(t){return new ui({key:new oa("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:a}=e,{selection:o}=a,{empty:l}=o;if(l)return!1;let c="";r.content.forEach(d=>{c+=d.textContent});const u=Fne(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(F7e,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Ine=$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"){V9(t);return}V9(t.scheme,t.optionalSlashes)})},onDestroy(){D7e()},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",vi(this.options.HTMLAttributes,t),0]:["a",vi(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[Mm({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=Fne(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:o=>!!bf(o,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(a=>{this.options.shouldAutoLink(a.value)&&e.push({text:a.value,data:{href:a.href},index:a.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(U7e({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(z7e({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(B7e({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),$7e=Ine,H7e=Object.defineProperty,V7e=(t,e)=>{for(var n in e)H7e(t,n,{get:e[n],enumerable:!0})},G7e="listItem",G9="textStyle",q9=/^\s*([-+*])\s$/,Une=Gs.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",vi(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(G7e,this.editor.getAttributes(G9)).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(G9),editor:this.editor})),[t]}}),zne=Gs.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",vi(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)=>VL(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)}}}),q7e={};V7e(q7e,{findListItemPos:()=>yv,getNextListDepth:()=>eF,handleBackspace:()=>nR,handleDelete:()=>rR,hasListBefore:()=>Bne,hasListItemAfter:()=>W7e,hasListItemBefore:()=>$ne,listItemHasSubList:()=>Hne,nextListIsDeeper:()=>Vne,nextListIsHigher:()=>Gne});var yv=(t,e)=>{const{$from:n}=e.selection,r=Gi(t,e.schema);let i=null,a=n.depth,o=n.pos,l=null;for(;a>0&&l===null;)i=n.node(a),i.type===r?l=a:(a-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},eF=(t,e)=>{const n=yv(t,e);if(!n)return!1;const[,r]=RVe(e,t,n.$pos.pos+4);return r},Bne=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),a=t.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},$ne=(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)},Hne=(t,e,n)=>{if(!n)return!1;const r=Gi(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},nR=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Dh(t.state,e)&&Bne(t.state,e,n)){const{$anchor:l}=t.state.selection,c=t.state.doc.resolve(l.before()-1),u=[];c.node().descendants((p,m)=>{p.type.name===e&&u.push({node:p,pos:m})});const d=u.at(-1);if(!d)return!1;const f=t.state.doc.resolve(c.start()+d.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},f.end()).joinForward().run()}if(!Dh(t.state,e)||!IVe(t.state))return!1;const r=yv(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=Hne(e,t.state,a);return $ne(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Vne=(t,e)=>{const n=eF(t,e),r=yv(t,e);return!r||!n?!1:n>r.depth},Gne=(t,e)=>{const n=eF(t,e),r=yv(t,e);return!r||!n?!1:n<r.depth},rR=(t,e)=>{if(!Dh(t.state,e)||!FVe(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:Vne(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Gne(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},W7e=(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)},qne=jr.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&&rR(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&&rR(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&&nR(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&&nR(t,n,r)&&(e=!0)}),e}}}}),W9=/^(\s*)(\d+)\.\s+(.*)$/,K7e=/^\s/;function X7e(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],a=i.match(W9);if(!a)break;const[,o,l,c]=a,u=o.length;let d=c,f=n+1;const p=[i];for(;f<t.length;){const m=t[f];if(m.match(W9))break;if(m.trim()==="")p.push(m),d+=`
  8250. `,f+=1;else if(m.match(K7e))p.push(m),d+=`
  8251. ${m.slice(u+2)}`,f+=1;else break}e.push({indent:u,number:parseInt(l,10),content:d.trim(),raw:p.join(`
  8252. `)}),r=f,n=f}return[e,r]}function Wne(t,e,n){var r;const i=[];let a=0;for(;a<t.length;){const o=t[a];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 m=n.blockTokens(d);u.push(...m)}let f=a+1;const p=[];for(;f<t.length&&t[f].indent>e;)p.push(t[f]),f+=1;if(p.length>0){const m=Math.min(...p.map(b=>b.indent)),x=Wne(p,m,n);u.push({type:"list",ordered:!0,start:p[0].number,items:x,raw:p.map(b=>b.raw).join(`
  8255. `)})}i.push({type:"list_item",raw:o.raw,tokens:u}),a=f}else a+=1}return i}function Y7e(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const a=e.parseChildren([i]);r.push({type:"paragraph",content:a})}else{const a=e.parseChildren([i]);a.length>0&&r.push(...a)}}),{type:"listItem",content:r}})}var Q7e="listItem",K9="textStyle",X9=/^(\d+)\.\s$/,Kne=Gs.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",vi(this.options.HTMLAttributes,n),0]:["ol",vi(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?Y7e(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. `),[a,o]=X7e(i);if(a.length===0)return;const l=Wne(a,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=a[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(Q7e,this.editor.getAttributes(K9)).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:X9,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:X9,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(K9)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Z7e=/^\s*(\[([( |x])?\])\s$/,J7e=Gs.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",vi(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 VL(t,e,i)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),a=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),c=document.createElement("div"),u=d=>{var f,p;l.ariaLabel=((p=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:p.call(f,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return u(t),a.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:p})=>{const m=n();if(typeof m!="number")return!1;const x=p.doc.nodeAt(m);return p.setNodeMarkup(m,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,a.append(l,o),i.append(a,c),Object.entries(e).forEach(([d,f])=>{i.setAttribute(d,f)}),{dom:i,contentDOM:c,update:d=>d.type!==this.type?!1:(i.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,u(d),!0)}}},addInputRules(){return[fx({find:Z7e,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),e9e=Gs.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",vi(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=a=>{const o=qD(a,{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(a)},i=qD(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,o)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.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()}}});jr.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Une.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(zne.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(qne.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Kne.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(J7e.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(e9e.configure(this.options.taskList)),t}});var t9e=Gs.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",vi(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()}}}),n9e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,r9e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,i9e=$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",vi(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:n9e,type:this.type})]},addPasteRules(){return[Mm({find:r9e,type:this.type})]}}),a9e=Gs.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Xne=$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",vi(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const a=i[2].trim();return{type:"underline",raw:i[0],text:a,tokens:n.inlineTokens(a)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),s9e=Xne;function o9e(t={}){return new ui({view(e){return new l9e(e,t)}})}class l9e{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let a=o=>{this[i](o)};return e.dom.addEventListener(i,a),{name:i,handler:a}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,a=i.getBoundingClientRect(),o=a.width/i.offsetWidth,l=a.height/i.offsetHeight;if(n){let f=e.nodeBefore,p=e.nodeAfter;if(f||p){let m=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(m){let x=m.getBoundingClientRect(),b=f?x.bottom:x.top;f&&p&&(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),p=this.width/2*o;r={left:f.left-p,right:f.left+p,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(),p=f.width/c.offsetWidth,m=f.height/c.offsetHeight;u=f.left-c.scrollLeft*p,d=f.top-c.scrollTop*m}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,a=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!a){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Xee(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 gi extends An{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return gi.valid(r)?new gi(r):An.near(r)}content(){return Ut.empty}eq(e){return e instanceof gi&&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 gi(e.resolve(n.pos))}getBookmark(){return new tF(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!c9e(e)||!u9e(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&&gi.valid(e))return e;let i=e.pos,a=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){a=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(gi.valid(c))return c}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!Qt.isSelectable(a)){e=e.doc.resolve(i+a.nodeSize*n),r=!1;continue e}break}a=o,i+=n;let l=e.doc.resolve(i);if(gi.valid(l))return l}return null}}}gi.prototype.visible=!1;gi.findFrom=gi.findGapCursorFrom;An.jsonID("gapcursor",gi);class tF{constructor(e){this.pos=e}map(e){return new tF(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return gi.valid(n)?new gi(n):An.near(n)}}function Yne(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function c9e(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||Yne(i.type))return!0;if(i.inlineContent)return!1}}return!0}function u9e(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||Yne(i.type))return!0;if(i.inlineContent)return!1}}return!0}function d9e(){return new ui({props:{decorations:p9e,createSelectionBetween(t,e,n){return e.pos==n.pos&&gi.valid(n)?new gi(n):null},handleClick:f9e,handleKeyDown:h9e,handleDOMEvents:{beforeinput:m9e}}})}const h9e=Xte({ArrowLeft:l1("horiz",-1),ArrowRight:l1("horiz",1),ArrowUp:l1("vert",-1),ArrowDown:l1("vert",1)});function l1(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,a){let o=r.selection,l=e>0?o.$to:o.$from,c=o.empty;if(o instanceof mn){if(!a.endOfTextblock(n)||l.depth==0)return!1;c=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=gi.findGapCursorFrom(l,e,c);return u?(i&&i(r.tr.setSelection(new gi(u))),!0):!1}}function f9e(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!gi.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Qt.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new gi(r))),!0)}function m9e(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof gi))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 a=t.state.tr.replace(n.pos,n.pos,new Ut(i,0,0));return a.setSelection(mn.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function p9e(t){if(!(t.selection instanceof gi))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ai.create(t.doc,[ms.widget(t.selection.head,e,{key:"gapcursor"})])}var KN=200,_a=function(){};_a.prototype.append=function(e){return e.length?(e=_a.from(e),!this.length&&e||e.length<KN&&this.leafAppend(e)||this.length<KN&&e.leafPrepend(this)||this.appendInner(e)):this};_a.prototype.prepend=function(e){return e.length?_a.from(e).append(this):this};_a.prototype.appendInner=function(e){return new g9e(this,e)};_a.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?_a.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};_a.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};_a.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)};_a.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(a,o){return i.push(e(a,o))},n,r),i};_a.from=function(e){return e instanceof _a?e:e&&e.length?new Qne(e):_a.empty};var Qne=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,a){return i==0&&a==this.length?this:new e(this.values.slice(i,a))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,a,o,l){for(var c=a;c<o;c++)if(i(this.values[c],l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(i,a,o,l){for(var c=a-1;c>=o;c--)if(i(this.values[c],l+c)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=KN)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=KN)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})(_a);_a.empty=new Qne([]);var g9e=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,a,o){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(a,l),o)===!1||a>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,a)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,a,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(a,l)-l,o+l)===!1||a<l&&this.left.forEachInvertedInner(r,Math.min(i,l),a,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var a=this.left.length;return i<=a?this.left.slice(r,i):r>=a?this.right.slice(r-a,i-a):this.left.slice(r,a).append(this.right.slice(0,i-a))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(_a);const x9e=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,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=e.tr,l,c,u=[],d=[];return this.items.forEach((f,p)=>{if(!f.step){i||(i=this.remapping(r,p+1),a=i.maps.length),a--,d.push(f);return}if(i){d.push(new tc(f.map));let m=f.step.map(i.slice(a)),x;m&&o.maybeStep(m).doc&&(x=o.mapping.maps[o.mapping.maps.length-1],u.push(new tc(x,void 0,void 0,u.length+d.length))),a--,x&&i.appendMap(x,a)}else o.maybeStep(f.step);if(f.selection)return l=i?f.selection.map(i.slice(a)):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 a=[],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]),p=new tc(e.mapping.maps[d],f,n),m;(m=c&&c.merge(p))&&(p=m,d?a.pop():l=l.slice(0,l.length-1)),a.push(p),n&&(o++,n=void 0),i||(c=p)}let u=o-r.depth;return u>y9e&&(l=b9e(l,u),o-=u),new jl(l.append(a),o)}remapping(e,n){let r=new Sy;return this.items.forEach((i,a)=>{let o=i.mirrorOffset!=null&&a-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),a=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},i);let c=n;this.items.forEach(p=>{let m=a.getMirror(--c);if(m==null)return;o=Math.min(o,m);let x=a.maps[m];if(p.step){let b=e.steps[m].invert(e.docs[m]),y=p.selection&&p.selection.map(a.slice(c+1,m));y&&l++,r.push(new tc(x,b,y))}else r.push(new tc(x))},i);let u=[];for(let p=n;p<o;p++)u.push(new tc(a.maps[p]));let d=this.items.slice(0,i).append(u).append(r),f=new jl(d,l);return f.emptyItemCount()>x9e&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],a=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&a++;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&&a++;let f=new tc(u.invert(),c,d),p,m=i.length-1;(p=i.length&&i[m].merge(f))?i[m]=p:i.push(f)}}else o.map&&r--},this.items.length,0),new jl(_a.from(i.reverse()),a)}}jl.empty=new jl(_a.empty,0);function b9e(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 Gd{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const y9e=20;function v9e(t,e,n,r){let i=n.getMeta(Jf),a;if(i)return i.historyState;n.getMeta(S9e)&&(t=new Gd(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 Gd(t.done.addTransform(n,void 0,r,F1(e)),t.undone,Y9(n.mapping.maps),t.prevTime,t.prevComposition):new Gd(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||!w9e(n,t.prevRanges)),u=o?Lj(t.prevRanges,n.mapping):Y9(n.mapping.maps);return new Gd(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,F1(e)),jl.empty,u,n.time,l??t.prevComposition)}else return(a=n.getMeta("rebased"))?new Gd(t.done.rebased(n,a),t.undone.rebased(n,a),Lj(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Gd(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Lj(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function w9e(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let a=0;a<e.length;a+=2)r<=e[a+1]&&i>=e[a]&&(n=!0)}),n}function Y9(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,a,o)=>e.push(a,o));return e}function Lj(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),a=e.map(t[r+1],-1);i<=a&&n.push(i,a)}return n}function _9e(t,e,n){let r=F1(e),i=Jf.get(e).spec.config,a=(n?t.undone:t.done).popEvent(e,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),l=(n?t.done:t.undone).addTransform(a.transform,e.selection.getBookmark(),i,r),c=new Gd(n?l:a.remaining,n?a.remaining:l,null,0,-1);return a.transform.setSelection(o).setMeta(Jf,{redo:n,historyState:c})}let Fj=!1,Q9=null;function F1(t){let e=t.plugins;if(Q9!=e){Fj=!1,Q9=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Fj=!0;break}}return Fj}const Jf=new oa("history"),S9e=new oa("closeHistory");function N9e(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new ui({key:Jf,state:{init(){return new Gd(jl.empty,jl.empty,null,0,-1)},apply(e,n,r){return v9e(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?Jne:r=="historyRedo"?ere:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function Zne(t,e){return(n,r)=>{let i=Jf.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=_9e(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const Jne=Zne(!1,!0),ere=Zne(!0,!0);jr.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 ui({key:new oa("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const a=this.storage.characters({node:r.doc});if(a>i){const o=a-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}),a=this.storage.characters({node:e.doc});if(a<=r||i>r&&a>r&&a<=i)return!0;if(i>r&&a>r&&a>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,c=a-r,u=l-c,d=l;return e.deleteRange(u,d),!(this.storage.characters({node:e.doc})>r)}})]}});var M9e=jr.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[o9e(this.options)]}});jr.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new ui({key:new oa("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,a=[];if(!n||!r)return ai.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";a.push(ms.node(u,u+c.nodeSize,{class:this.options.className}))}),ai.create(t,a)}}})]}});var E9e=jr.create({name:"gapCursor",addProseMirrorPlugins(){return[d9e()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=gr(Xt(t,"allowGapCursor",n)))!=null?e:null}}});jr.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new ui({key:new oa("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!n)return null;const a=this.editor.isEmpty;return t.descendants((o,l)=>{const c=r>=l&&r<=l+o.nodeSize,u=!o.isLeaf&&RM(o);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];a&&d.push(this.options.emptyEditorClass);const f=ms.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}),ai.create(t,i)}}})]}});jr.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new ui({key:new oa("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||dne(n.selection)||t.view.dragging?null:ai.create(n.doc,[ms.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function Z9({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var k9e=jr.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new oa(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 ui({key:e,appendTransaction:(i,a,o)=>{const{doc:l,tr:c,schema:u}=o,d=e.getState(o),f=l.content.size,p=u.nodes[n];if(d)return c.insert(f,p.create())},state:{init:(i,a)=>{const o=a.tr.doc.lastChild;return!Z9({node:o,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const o=i.doc.lastChild;return!Z9({node:o,types:r})}}})]}}),T9e=jr.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Jne(t,e),redo:()=>({state:t,dispatch:e})=>ere(t,e)}},addProseMirrorPlugins(){return[N9e(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()}}}),A9e=jr.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(n7e.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(QGe.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(Une.configure(this.options.bulletList)),this.options.code!==!1&&i.push(a7e.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(l7e.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(c7e.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(M9e.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(E9e.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(u7e.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(d7e.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(T9e.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(h7e.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(x7e.configure(this.options.italic)),this.options.listItem!==!1&&i.push(zne.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(qne.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(Ine.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(Kne.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(t9e.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(i9e.configure(this.options.strike)),this.options.text!==!1&&i.push(a9e.configure(this.options.text)),this.options.underline!==!1&&i.push(Xne.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(k9e.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),C9e=A9e,j9e=jr.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")}}}),P9e=j9e,D9e=20,tre=(t,e=0)=>{const n=[];return!t.children.length||e>D9e||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...tre(r,e+1))}),n},R9e=t=>{if(!t.children.length)return;const e=tre(t);e&&e.forEach(n=>{var r,i;const a=n.getAttribute("style"),o=(i=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:i.getAttribute("style");n.setAttribute("style",`${o};${a}`)})},nre=$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&&R9e(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",vi(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(i=>i.type===this.type).some(i=>Object.values(i.attrs).some(a=>!!a))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),O9e=jr.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const a=r[i].split(":");if(a.length>=2){const o=a[0].trim().toLowerCase(),l=a.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()}}}),rre=jr.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const a=r[i].split(":");if(a.length>=2){const o=a[0].trim().toLowerCase(),l=a.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()}}}),L9e=jr.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()}}}),F9e=jr.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()}}}),I9e=jr.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()}}});jr.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(O9e.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(rre.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(L9e.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(F9e.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(I9e.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(nre.configure(this.options.textStyle)),t}});var U9e=rre,z9e=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,B9e=Gs.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",vi(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,i,a,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=(a=t.attrs)==null?void 0:a.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:a,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 _Ge({element:l,node:i,getPos:a,onResize:(d,f)=>{l.style.width=`${d}px`,l.style.height=`${f}px`},onCommit:(d,f)=>{const p=a();p!==void 0&&this.editor.chain().setNodeSelection(p).updateAttributes(this.name,{width:d,height:f}).run()},onUpdate:(d,f,p)=>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[Ene({find:z9e,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),$9e=B9e;function iR({content:t,onChange:e,placeholder:n}){const r=qGe({extensions:[C9e.configure({heading:!1,codeBlock:!1,code:!1}),s9e,$7e.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),P9e.configure({types:["paragraph"]}),nre,U9e,$9e.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})=>s.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}),a=()=>{const o=window.prompt("Enter URL:");o&&r.chain().focus().setLink({href:o}).run()};return s.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[s.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[s.jsx(i,{onClick:()=>r.chain().focus().toggleBold().run(),isActive:r.isActive("bold"),title:"Bold",children:s.jsx(gce,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:s.jsx(cde,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:s.jsx(Jhe,{className:"w-4 h-4"})}),s.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),s.jsx(i,{onClick:()=>r.chain().focus().toggleBulletList().run(),isActive:r.isActive("bulletList"),title:"Bullet List",children:s.jsx(p2,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:s.jsx(yW,{className:"w-4 h-4"})}),s.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),s.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("left").run(),isActive:r.isActive({textAlign:"left"}),title:"Align Left",children:s.jsx(Ghe,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("center").run(),isActive:r.isActive({textAlign:"center"}),title:"Align Center",children:s.jsx(Bhe,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("right").run(),isActive:r.isActive({textAlign:"right"}),title:"Align Right",children:s.jsx(Hhe,{className:"w-4 h-4"})}),s.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),s.jsx(i,{onClick:a,isActive:r.isActive("link"),title:"Add Link",children:s.jsx(Fy,{className:"w-4 h-4"})}),r.isActive("link")&&s.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:s.jsx(RR,{className:"w-4 h-4"})})]}),s.jsx(UGe,{editor:r})]})}function ire({archiveId:t,archiveName:e,onClose:n}){const r=an(),[i,a]=_.useState(!1),[o,l]=_.useState(null),[c,u]=_.useState({}),{data:d,isLoading:f,error:p}=at({queryKey:["archive-project-page",t],queryFn:()=>ue.getArchiveProjectPage(t)}),m=mt({mutationFn:E=>ue.updateArchiveProjectPage(t,E),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),a(!1),u({})}});_.useEffect(()=>{const E=C=>{C.key==="Escape"&&(o!==null?l(null):i?v():n())};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[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||""}),a(!0)},y=()=>{m.mutate(c)},v=()=>{a(!1),u({})},S=E=>{const C=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],k=new DOMParser().parseFromString(E,"text/html"),R=A=>{if(A.nodeType===Node.TEXT_NODE)return A.textContent||"";if(A.nodeType===Node.ELEMENT_NODE){const D=A,U=D.tagName.toLowerCase();if(!C.includes(U))return Array.from(D.childNodes).map(R).join("");let F="";if(U==="a"&&D.getAttribute("href")){const j=D.getAttribute("href");j?.toLowerCase().startsWith("http")&&(F=` href="${j}" target="_blank" rel="noopener noreferrer"`)}if(U==="img"){const j=D.getAttribute("src");if(!j?.toLowerCase().startsWith("http"))return"";F=` src="${j}" style="max-width: 100%; height: auto;"`}const H=Array.from(D.childNodes).map(R).join("");return["br","img"].includes(U)?`<${U}${F} />`:`<${U}${F}>${H}</${U}>`}return""};return Array.from(k.body.childNodes).map(R).join("")},M=d&&(d.title||d.description||d.designer||d.profile_title||x.length>0),T=E=>{E.target===E.currentTarget&&n()};return s.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:T,children:[s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ls,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&s.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[!i&&M&&s.jsxs(Te,{variant:"ghost",size:"sm",onClick:b,children:[s.jsx(rm,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&s.jsxs(s.Fragment,{children:[s.jsx(Te,{variant:"ghost",size:"sm",onClick:v,children:"Cancel"}),s.jsxs(Te,{variant:"primary",size:"sm",onClick:y,disabled:m.isPending,children:[s.jsx(hs,{className:"w-4 h-4 mr-1"}),"Save"]})]}),s.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[f&&s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),p&&s.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!M&&s.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[s.jsx(Ls,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),s.jsx("p",{children:"No project page data found in this 3MF file."}),s.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),d&&M&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-4",children:[i?s.jsx("input",{type:"text",value:c.title||"",onChange:E=>u({...c,title:E.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&&s.jsx("h3",{className:"text-xl font-semibold text-white",children:d.title}),s.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(am,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:c.designer||"",onChange:E=>u({...c,designer:E.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.designer&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(am,{className:"w-4 h-4"}),s.jsx("span",{children:d.designer}),d.designer_user_id&&s.jsx("a",{href:`https://makerworld.com/en/@${d.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:s.jsx(Kr,{className:"w-3 h-3"})})]}),d.creation_date&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(si,{className:"w-4 h-4"}),s.jsx("span",{children:d.creation_date})]}),i?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ls,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:c.license||"",onChange:E=>u({...c,license:E.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.license&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(Ls,{className:"w-4 h-4"}),s.jsx("span",{children:d.license})]}),d.origin&&s.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:d.origin})]})]}),(d.description||i)&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?s.jsx(iR,{content:c.description||"",onChange:E=>u({...c,description:E}),placeholder:"Enter description..."}):s.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)&&s.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),i?s.jsxs("div",{className:"space-y-2",children:[s.jsx("input",{type:"text",value:c.profile_title||"",onChange:E=>u({...c,profile_title:E.target.value}),placeholder:"Profile Title",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-white"}),s.jsx(iR,{content:c.profile_description||"",onChange:E=>u({...c,profile_description:E}),placeholder:"Profile description..."})]}):s.jsxs(s.Fragment,{children:[d.profile_title&&s.jsx("p",{className:"text-white font-medium",children:d.profile_title}),d.profile_description&&s.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&&s.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",d.profile_user_name]})]})]}),x.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[s.jsx(Ou,{className:"w-4 h-4"}),"Images (",x.length,")"]}),s.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:x.map((E,C)=>s.jsx("button",{onClick:()=>l(C),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:s.jsx("img",{src:E.url,alt:E.name,className:"w-full h-full object-cover"})},E.path))})]}),d.design_model_id&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.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:[s.jsx(Kr,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),o!==null&&x[o]&&s.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>l(null),children:[s.jsx("button",{onClick:E=>{E.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:s.jsx(gh,{className:"w-6 h-6 text-white"})}),s.jsx("img",{src:x[o].url,alt:x[o].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:E=>E.stopPropagation()}),s.jsx("button",{onClick:E=>{E.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:s.jsx(gs,{className:"w-6 h-6 text-white"})}),s.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:s.jsx(Rt,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[o+1," / ",x.length]})]})]})}const H9e=[.25,.5,.75,1,1.5,2,3,4];function ng(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}function V9e({archiveId:t,timelapseSrc:e,onClose:n,onSave:r}){const{showToast:i}=Hn(),a=_.useRef(null),o=_.useRef(null),[l,c]=_.useState(!1),[u,d]=_.useState(0),[f,p]=_.useState(0),[m,x]=_.useState(0),[b,y]=_.useState(0),[v,S]=_.useState(1),[M,T]=_.useState(null),[E,C]=_.useState(null),[k,R]=_.useState(.8),[A,D]=_.useState(!1),{data:U,isLoading:F}=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:m,trimEnd:b,speed:v,saveMode:"replace"},M||void 0),onSuccess:B=>{i(B.message,"success"),r?.(),n()},onError:B=>{i(B.message||"Processing failed","error")}});_.useEffect(()=>{U?.duration&&b===0&&y(U.duration)},[U?.duration,b]),_.useEffect(()=>{const B=X=>{X.key==="Escape"&&n()};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[n]),_.useEffect(()=>{const B=a.current;if(!B)return;const X=()=>{const xe=B.currentTime;d(xe),xe>=b&&(B.currentTime=m)},ne=()=>{p(B.duration),b===0&&y(B.duration)},se=()=>c(!0),be=()=>c(!1);return B.addEventListener("timeupdate",X),B.addEventListener("durationchange",ne),B.addEventListener("play",se),B.addEventListener("pause",be),()=>{B.removeEventListener("timeupdate",X),B.removeEventListener("durationchange",ne),B.removeEventListener("play",se),B.removeEventListener("pause",be)}},[m,b]),_.useEffect(()=>{const B=o.current,X=a.current;!B||!X||!E||(B.currentTime=X.currentTime,B.playbackRate=X.playbackRate,l&&!A?B.play().catch(()=>{}):B.pause())},[l,E,A]),_.useEffect(()=>{o.current&&(o.current.volume=A?0:k)},[k,A]),_.useEffect(()=>{a.current&&(a.current.playbackRate=v),o.current&&(o.current.playbackRate=v)},[v]);const $=_.useCallback(()=>{const B=a.current;B&&(l?B.pause():(B.currentTime<m&&(B.currentTime=m),B.play()))},[l,m]),K=B=>{const X=a.current;X&&(X.currentTime=Math.max(m,Math.min(b,B)))},V=B=>{const X=B.target.files?.[0];X&&(E&&URL.revokeObjectURL(E),T(X),C(URL.createObjectURL(X)))},Q=()=>{E&&URL.revokeObjectURL(E),T(null),C(null)};_.useEffect(()=>()=>{E&&URL.revokeObjectURL(E)},[E]);const Z=b-m,ae=Z/v;return F?s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:s.jsxs("div",{className:"flex items-center gap-3 text-white",children:[s.jsx(ht,{className:"w-6 h-6 animate-spin"}),"Loading video info..."]})}):s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:s.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:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(ah,{className:"w-5 h-5 text-bambu-green"}),"Edit Timelapse"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Te,{variant:"primary",size:"sm",onClick:()=>j.mutate(),disabled:j.isPending,children:j.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(hs,{className:"w-4 h-4"}),"Save"]})}),s.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[s.jsxs("div",{className:"relative",children:[s.jsx("video",{ref:a,src:e,className:"w-full rounded-lg bg-black",onClick:$,muted:!!E}),!l&&s.jsx("button",{onClick:$,className:"absolute inset-0 flex items-center justify-center bg-black/30 hover:bg-black/40 transition-colors",children:s.jsx("div",{className:"p-4 bg-bambu-green rounded-full",children:s.jsx(Is,{className:"w-8 h-8 text-white"})})}),E&&s.jsx("audio",{ref:o,src:E,loop:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(phe,{className:"w-4 h-4"}),s.jsx("span",{children:"Trim"}),s.jsxs("span",{className:"ml-auto",children:[ng(m)," - ",ng(b)," (",ng(Z),")"]})]}),s.jsxs("div",{className:"relative h-16 bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 flex",children:H?.thumbnails.map((B,X)=>s.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${B})`}},X))}),s.jsx("div",{className:"absolute inset-y-0 left-0 bg-black/60",style:{width:`${m/f*100}%`}}),s.jsx("div",{className:"absolute inset-y-0 right-0 bg-black/60",style:{width:`${(f-b)/f*100}%`}}),s.jsx("div",{className:"absolute inset-y-0 border-2 border-bambu-green",style:{left:`${m/f*100}%`,right:`${(f-b)/f*100}%`}}),s.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-white shadow-lg",style:{left:`${u/f*100}%`}}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:m,onChange:B=>{const X=parseFloat(B.target.value);X<b-1&&(x(X),a.current&&a.current.currentTime<X&&(a.current.currentTime=X))},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 50% 0 0)"}}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:b,onChange:B=>{const X=parseFloat(B.target.value);X>m+1&&y(X)},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 0 0 50%)"}})]}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:u,onChange:B=>K(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`}),s.jsx("div",{className:"flex items-center justify-center gap-2",children:s.jsx("button",{onClick:$,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?s.jsx(CR,{className:"w-5 h-5 text-white"}):s.jsx(Is,{className:"w-5 h-5 text-white"})})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(d2,{className:"w-4 h-4"}),s.jsx("span",{children:"Speed"}),s.jsxs("span",{className:"ml-auto",children:[v,"x (output: ",ng(ae),")"]})]}),s.jsx("div",{className:"flex gap-1",children:H9e.map(B=>s.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))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(bP,{className:"w-4 h-4"}),s.jsx("span",{children:"Music Overlay"})]}),M?s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(bP,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:M.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[(M.size/1024/1024).toFixed(1)," MB"]})]}),s.jsx("button",{onClick:()=>D(!A),className:"p-2 hover:bg-bambu-dark-tertiary rounded transition-colors",children:A?s.jsx(lfe,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(sfe,{className:"w-4 h-4 text-bambu-green"})}),s.jsx("input",{type:"range",min:0,max:1,step:.1,value:k,onChange:B=>R(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`}),s.jsx("button",{onClick:Q,className:"p-2 hover:bg-red-500/20 rounded transition-colors",children:s.jsx(rn,{className:"w-4 h-4 text-red-400"})})]}):s.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:[s.jsx(Ua,{className:"w-8 h-8 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Drop audio file or click to upload"}),s.jsx("span",{className:"text-xs text-bambu-gray/60",children:"MP3, WAV, M4A, AAC, OGG"}),s.jsx("input",{type:"file",accept:".mp3,.wav,.m4a,.aac,.ogg,audio/*",onChange:V,className:"hidden"})]})]}),s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg text-sm space-y-1",children:[s.jsxs("p",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white",children:"Original:"})," ",ng(f)," @ ",U?.width,"x",U?.height]}),s.jsxs("p",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white",children:"Output:"})," ",ng(ae)," @ ",v,"x speed",M&&" + music overlay"]})]})]}),j.isPending&&s.jsxs("div",{className:"absolute inset-0 bg-black/80 flex flex-col items-center justify-center gap-4",children:[s.jsx(ht,{className:"w-12 h-12 text-bambu-green animate-spin"}),s.jsx("p",{className:"text-white text-lg",children:"Processing timelapse..."}),s.jsx("p",{className:"text-bambu-gray text-sm",children:"This may take a few moments"})]})]})})}const G9e=[.25,.5,.75,1,1.5,2,3,4];function are({src:t,title:e,downloadFilename:n,archiveId:r,onClose:i,onEdit:a}){const o=_.useRef(null),[l,c]=_.useState(!0),[u,d]=_.useState(1),[f,p]=_.useState(0),[m,x]=_.useState(0),[b,y]=_.useState(!1);_.useEffect(()=>{const k=o.current;k&&(k.playbackRate=u)},[u]),_.useEffect(()=>{const k=R=>{R.key==="Escape"&&i()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[i]),_.useEffect(()=>{const k=o.current;if(!k)return;const R=()=>p(k.currentTime),A=()=>x(k.duration),D=()=>c(!0),U=()=>c(!1);return k.addEventListener("timeupdate",R),k.addEventListener("durationchange",A),k.addEventListener("play",D),k.addEventListener("pause",U),()=>{k.removeEventListener("timeupdate",R),k.removeEventListener("durationchange",A),k.removeEventListener("play",D),k.removeEventListener("pause",U)}},[]);const v=()=>{const k=o.current;k&&(l?k.pause():k.play())},S=k=>{const R=o.current;R&&(R.currentTime=parseFloat(k.target.value))},M=()=>{const k=o.current;k&&(k.currentTime=Math.max(0,k.currentTime-5))},T=()=>{const k=o.current;k&&(k.currentTime=Math.min(m,k.currentTime+5))},E=k=>{const R=Math.floor(k/60),A=Math.floor(k%60);return`${R}:${A.toString().padStart(2,"0")}`},C=()=>{const k=document.createElement("a");k.href=t,k.download=n,k.click()};return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:[s.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(ah,{className:"w-5 h-5 text-bambu-green"}),e]}),s.jsxs("div",{className:"flex items-center gap-2",children:[r&&s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>y(!0),children:[s.jsx(Qi,{className:"w-4 h-4"}),"Edit"]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:C,children:[s.jsx(yi,{className:"w-4 h-4"}),"Download"]}),s.jsx("button",{onClick:i,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"p-4",children:[s.jsx("video",{ref:o,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:v}),s.jsxs("div",{className:"mt-4 space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:E(f)}),s.jsx("input",{type:"range",min:0,max:m||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`}),s.jsx("span",{className:"text-xs text-bambu-gray w-12",children:E(m)})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:M,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:s.jsx(Ehe,{className:"w-5 h-5 text-bambu-gray"})}),s.jsx("button",{onClick:v,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?s.jsx(CR,{className:"w-5 h-5 text-white"}):s.jsx(Is,{className:"w-5 h-5 text-white"})}),s.jsx("button",{onClick:T,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:s.jsx(DR,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Speed:"}),s.jsx("div",{className:"flex gap-1",children:G9e.map(k=>s.jsxs("button",{onClick:()=>d(k),className:`px-2 py-1 text-xs rounded transition-colors ${u===k?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[k,"x"]},k))})]})]})]})]})]}),b&&r&&s.jsx(V9e,{archiveId:r,timelapseSrc:t,onClose:()=>y(!1),onSave:a})]})}function q9e({archiveIds:t,onClose:e}){_.useEffect(()=>{const a=o=>{o.key==="Escape"&&e()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e]);const{data:n,isLoading:r,error:i}=at({queryKey:["archive-comparison",t],queryFn:()=>ue.compareArchives(t)});return s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[90vh] flex flex-col border border-bambu-dark-tertiary",onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Compare Archives (",t.length,")"]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white p-1",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"flex-1 overflow-auto p-4 bg-bambu-dark-secondary",children:r?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i?s.jsxs("div",{className:"text-center py-12 text-red-400",children:[s.jsx(Cn,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),s.jsx("p",{children:"Failed to load comparison"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:i instanceof Error?i.message:"Unknown error"})]}):n?s.jsx(W9e,{comparison:n}):null}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsx(Te,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function W9e({comparison:t}){return s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.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=>s.jsxs("th",{className:"text-left text-sm font-medium pb-2 px-2 min-w-[120px]",children:[s.jsx("div",{className:"text-white truncate max-w-[150px]",title:e.print_name,children:e.print_name}),s.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))]})}),s.jsx("tbody",{className:"divide-y divide-bambu-gray/20",children:t.comparison.map(e=>s.jsxs("tr",{className:e.has_difference?"bg-yellow-500/5":"",children:[s.jsx("td",{className:"py-2 pr-4 text-sm",children:s.jsxs("div",{className:"flex items-center gap-2",children:[e.has_difference&&s.jsx(Cn,{className:"w-3 h-3 text-yellow-400 flex-shrink-0"}),s.jsx("span",{className:e.has_difference?"text-yellow-400":"text-bambu-gray",children:e.label})]})}),e.values.map((n,r)=>s.jsxs("td",{className:"py-2 px-2 text-sm text-white",children:[n??s.jsx("span",{className:"text-bambu-gray/50",children:"-"}),e.unit&&n!==null&&s.jsx("span",{className:"text-bambu-gray ml-1",children:e.unit})]},r))]},e.field))})]})}),t.differences.length>0&&s.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[s.jsxs("h4",{className:"text-sm font-medium text-yellow-400 mb-2 flex items-center gap-2",children:[s.jsx(Cn,{className:"w-4 h-4"}),t.differences.length," Difference",t.differences.length>1?"s":""," Found"]}),s.jsxs("ul",{className:"text-sm text-white/80 space-y-1",children:[t.differences.slice(0,5).map(e=>s.jsxs("li",{children:[s.jsx("span",{className:"text-yellow-400",children:e.label}),": ",e.values.join(" vs ")," ",e.unit||""]},e.field)),t.differences.length>5&&s.jsxs("li",{className:"text-bambu-gray",children:["...and ",t.differences.length-5," more"]})]})]}),t.success_correlation.has_both_outcomes?s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg",children:[s.jsxs("h4",{className:"text-sm font-medium text-white mb-3 flex items-center gap-2",children:[s.jsx(Ia,{className:"w-4 h-4 text-bambu-green"}),"Success/Failure Analysis"]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm mb-3",children:[s.jsxs("span",{className:"text-bambu-green",children:[t.success_correlation.successful_count," successful"]}),s.jsxs("span",{className:"text-red-400",children:[t.success_correlation.failed_count," failed"]})]}),t.success_correlation.insights&&t.success_correlation.insights.length>0?s.jsx("div",{className:"space-y-2",children:t.success_correlation.insights.map(e=>s.jsxs("div",{className:"text-sm p-2 bg-bambu-dark-secondary rounded",children:[s.jsxs("span",{className:"text-white font-medium",children:[e.label,":"]})," ",s.jsx("span",{className:"text-white/80",children:e.insight})]},e.field))}):s.jsx("p",{className:"text-sm text-bambu-gray",children:"No clear correlations found between settings and outcomes."})]}):s.jsx("div",{className:"p-4 bg-bambu-dark rounded-lg text-sm text-bambu-gray",children:s.jsx("p",{children:t.success_correlation.message||"Need both successful and failed prints for correlation analysis."})})]})}function K9e(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function X9e(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 a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function Y9e({upload:t,projects:e,onArchive:n,onDiscard:r,isArchiving:i,isDiscarding:a}){const[o,l]=_.useState(!1),[c,u]=_.useState(t.tags||""),[d,f]=_.useState(t.notes||""),[p,m]=_.useState(t.project_id),[x,b]=_.useState(!1);return s.jsx(_t,{children:s.jsxs(Nt,{className:"py-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(zf,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:t.filename}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[s.jsx("span",{children:K9e(t.file_size)}),s.jsx("span",{children:"·"}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Jn,{className:"w-3 h-3"}),X9e(t.uploaded_at)]}),t.source_ip&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsxs("span",{children:["from ",t.source_ip]})]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>l(!o),className:"p-1 text-bambu-gray hover:text-white transition-colors",children:o?s.jsx(xh,{className:"w-5 h-5"}):s.jsx(ei,{className:"w-5 h-5"})}),s.jsx(Te,{variant:"primary",size:"sm",onClick:()=>n(t.id,{tags:c,notes:d,project_id:p||void 0}),disabled:i,children:i?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(fo,{className:"w-4 h-4"}),"Archive"]})}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>b(!0),disabled:a,children:a?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(rn,{className:"w-4 h-4 text-red-400"})})]})]}),x&&s.jsx(Qn,{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&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),s.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),s.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Project"}),s.jsxs("select",{value:p||"",onChange:y=>m(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:[s.jsx("option",{value:"",children:"No project"}),e.map(y=>s.jsx("option",{value:y.id,children:y.name},y.id))]})]})]})]})})}function Q9e(){const t=an(),{showToast:e}=Hn(),[n,r]=_.useState(!1),[i,a]=_.useState(!1),[o,l]=_.useState(new Set),[c,u]=_.useState(new Set),{data:d,isLoading:f}=at({queryKey:["pending-uploads"],queryFn:ag.list,refetchInterval:1e4}),{data:p}=at({queryKey:["projects"],queryFn:()=>ue.getProjects()}),m=mt({mutationFn:({id:v,data:S})=>ag.archive(v,S),onMutate:({id:v})=>{l(S=>new Set(S).add(v))},onSettled:(v,S,{id:M})=>{l(T=>{const E=new Set(T);return E.delete(M),E})},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=>ag.discard(v),onMutate:v=>{u(S=>new Set(S).add(v))},onSettled:(v,S,M)=>{u(T=>{const E=new Set(T);return E.delete(M),E})},onSuccess:()=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e("Upload discarded")},onError:v=>{e(v.message||"Failed to discard","error")}}),b=mt({mutationFn:ag.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:ag.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?s.jsx(_t,{children:s.jsx(Nt,{className:"py-8 flex justify-center",children:s.jsx(ht,{className:"w-6 h-6 animate-spin text-bambu-green"})})}):!d||d.length===0?null:s.jsxs("div",{className:"mb-6",children:[s.jsxs(_t,{className:"border-l-4 border-l-yellow-500",children:[s.jsx(Wn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ua,{className:"w-5 h-5 text-yellow-500"}),s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Pending Uploads (",d.length,")"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Te,{variant:"primary",size:"sm",onClick:()=>r(!0),disabled:b.isPending,children:b.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(fo,{className:"w-4 h-4"}),"Archive All"]})}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>a(!0),disabled:y.isPending,children:y.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(rn,{className:"w-4 h-4"}),"Discard All"]})})]})]})}),s.jsxs(Nt,{children:[s.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."}),s.jsx("div",{className:"space-y-3",children:d.map(v=>s.jsx(Y9e,{upload:v,projects:p||[],onArchive:(S,M)=>m.mutate({id:S,data:M}),onDiscard:S=>x.mutate(S),isArchiving:o.has(v.id),isDiscarding:c.has(v.id)},v.id))})]})]}),n&&s.jsx(Qn,{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&&s.jsx(Qn,{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(),a(!1)},onCancel:()=>a(!1)})]})}function Z9e({onClose:t}){const e=an(),{showToast:n}=Hn(),[r,i]=_.useState(""),[a,o]=_.useState(null),[l,c]=_.useState(""),[u,d]=_.useState(null),[f,p]=_.useState("count");_.useEffect(()=>{const A=D=>{D.key==="Escape"&&(a?o(null):u?d(null):t())};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[t,a,u]);const{data:m,isLoading:x}=at({queryKey:["tags"],queryFn:ue.getTags}),b=mt({mutationFn:({oldName:A,newName:D})=>ue.renameTag(A,D),onSuccess:(A,{oldName:D,newName:U})=>{e.invalidateQueries({queryKey:["tags"]}),e.invalidateQueries({queryKey:["archives"]}),n(`Renamed "${D}" to "${U}" 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,D)=>{e.invalidateQueries({queryKey:["tags"]}),e.invalidateQueries({queryKey:["archives"]}),n(`Deleted "${D}" 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("")},M=()=>{if(!a||!l.trim())return;const A=l.trim();if(A===a){S();return}b.mutate({oldName:a,newName:A})},T=A=>{A.key==="Enter"?(A.preventDefault(),M()):A.key==="Escape"&&(A.preventDefault(),S())},E=A=>{d(A),o(null)},C=()=>{u&&y.mutate(u)},k=m?.filter(A=>A.name.toLowerCase().includes(r.toLowerCase())).sort((A,D)=>f==="count"&&D.count-A.count||A.name.localeCompare(D.name)),R=m?.reduce((A,D)=>A+D.count,0)||0;return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(_t,{className:"w-full max-w-lg max-h-[80vh] flex flex-col",children:s.jsxs(Nt,{className:"p-0 flex flex-col min-h-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(yh,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Manage Tags"})]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.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)})]}),s.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=>p(A.target.value),children:[s.jsx("option",{value:"count",children:"Sort by Count"}),s.jsx("option",{value:"name",children:"Sort by Name"})]})]}),m&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[m.length," tag",m.length!==1?"s":""," across ",R," usage",R!==1?"s":""]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 p-4",children:x?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 animate-spin text-bambu-gray"})}):k?.length?s.jsx("div",{className:"space-y-2",children:k.map(A=>s.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary transition-colors group",children:a===A.name?s.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[s.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:D=>c(D.target.value),onKeyDown:T,autoFocus:!0}),s.jsx(Te,{size:"sm",variant:"primary",onClick:M,disabled:!l.trim()||b.isPending,className:"p-1.5",children:b.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Ia,{className:"w-4 h-4"})}),s.jsx(Te,{size:"sm",variant:"ghost",onClick:S,className:"p-1.5",children:s.jsx(Rt,{className:"w-4 h-4"})})]}):u===A.name?s.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[s.jsx(Cn,{className:"w-4 h-4 text-yellow-400 flex-shrink-0"}),s.jsxs("span",{className:"text-sm text-bambu-gray-light flex-1",children:['Delete "',A.name,'" from ',A.count," archive",A.count!==1?"s":"","?"]}),s.jsx(Te,{size:"sm",variant:"danger",onClick:C,disabled:y.isPending,className:"p-1.5",children:y.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(rn,{className:"w-4 h-4"})}),s.jsx(Te,{size:"sm",variant:"ghost",onClick:()=>d(null),className:"p-1.5",children:s.jsx(Rt,{className:"w-4 h-4"})})]}):s.jsxs(s.Fragment,{children:[s.jsx(yh,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"text-white flex-1 truncate",children:A.name}),s.jsx("span",{className:"px-2 py-0.5 rounded-full bg-bambu-dark-tertiary text-bambu-gray text-xs",children:A.count}),s.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[s.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:s.jsx(Qi,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E(A.name),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",title:"Delete tag",children:s.jsx(rn,{className:"w-4 h-4"})})]})]})},A.name))}):s.jsx("div",{className:"text-center py-8 text-bambu-gray",children:r?"No tags match your search":"No tags found"})}),s.jsx("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary flex-shrink-0",children:s.jsx(Te,{variant:"secondary",onClick:t,className:"flex-1",children:"Close"})})]})})})}function XN(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function t0(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function Cf(t){if(!t)return!1;const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function J9e({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o,timeFormat:l="system",t:c}){o&&console.log("ArchiveCard isHighlighted=true for archive:",t.id);const u=an(),{showToast:d}=Hn(),{hasPermission:f,canModify:p}=Ai(),m=IR(),[x,b]=_.useState(!1),[y,v]=_.useState(!1),[S,M]=_.useState(!1),[T,E]=_.useState(!1),[C,k]=_.useState(!1),[R,A]=_.useState(!1),[D,U]=_.useState([]),[F,H]=_.useState(!1),[j,$]=_.useState(!1),[K,V]=_.useState(!1),[Q,Z]=_.useState(!1),[ae,B]=_.useState(!1),[X,ne]=_.useState(!1),[se,be]=_.useState(null),[xe,de]=_.useState(null),[Pe,ie]=_.useState(!1),Me=_.useRef(null),Oe=_.useRef(null),{data:ge}=at({queryKey:["archive-plates",t.id],queryFn:()=>ue.getArchivePlates(t.id),enabled:Pe,staleTime:300*1e3}),Ke=ge?.plates??[],G=ge?.is_multi_plate??!1,Y=xe??0,ce=mt({mutationFn:re=>ue.uploadSource3mf(t.id,re),onSuccess:re=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.source3mfAttached",{filename:re.filename}))},onError:re=>{d(re.message||c("archives.toast.failedUploadSource3mf"),"error")}}),q=mt({mutationFn:()=>ue.deleteSource3mf(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.source3mfRemoved"))},onError:re=>{d(re.message||c("archives.toast.failedRemoveSource3mf"),"error")}}),te=mt({mutationFn:re=>ue.uploadF3d(t.id,re),onSuccess:re=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.f3dAttached",{filename:re.filename}))},onError:re=>{d(re.message||c("archives.toast.failedUploadF3d"),"error")}}),I=mt({mutationFn:()=>ue.deleteF3d(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.f3dRemoved"))},onError:re=>{d(re.message||c("archives.toast.failedRemoveF3d"),"error")}}),fe=mt({mutationFn:()=>ue.scanArchiveTimelapse(t.id),onSuccess:re=>{re.status==="attached"?(u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.timelapseAttached",{filename:re.filename}))):re.status==="exists"?d(c("archives.toast.timelapseAlreadyAttached")):re.status==="not_found"&&re.available_files&&re.available_files.length>0?(U(re.available_files),A(!0)):d(re.message||c("archives.toast.noMatchingTimelapse"),"warning")},onError:re=>{d(re.message||c("archives.toast.failedScanTimelapse"),"error")}}),me=mt({mutationFn:re=>ue.selectArchiveTimelapse(t.id,re),onSuccess:re=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.timelapseAttached",{filename:re.filename})),A(!1),U([])},onError:re=>{d(re.message||c("archives.toast.failedAttachTimelapse"),"error")}}),ke=mt({mutationFn:()=>ue.deleteArchive(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.archiveDeleted"))},onError:()=>{d(c("archives.toast.failedDeleteArchive"),"error")}}),z=mt({mutationFn:()=>ue.toggleFavorite(t.id),onSuccess:re=>{u.invalidateQueries({queryKey:["archives"]}),d(re.is_favorite?c("archives.toast.addedToFavorites"):c("archives.toast.removedFromFavorites"))}}),{data:O}=at({queryKey:["archive-folders",t.id],queryFn:()=>ue.getLibraryFoldersByArchive(t.id)}),ee=mt({mutationFn:re=>ue.updateArchive(t.id,{project_id:re}),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),u.invalidateQueries({queryKey:["projects"]}),d(c("archives.toast.projectUpdated"))},onError:()=>{d(c("archives.toast.failedUpdateProject"),"error")}}),le=re=>{re.preventDefault(),be({x:re.clientX,y:re.clientY})},we=[...Cf(t.filename)?[{label:c("archives.menu.print"),icon:s.jsx(Ur,{className:"w-4 h-4"}),onClick:()=>v(!0),disabled:!p("archives","reprint",t.created_by_id),title:p("archives","reprint",t.created_by_id)?void 0:c("archives.permission.noReprint")},{label:c("archives.menu.schedule"),icon:s.jsx(si,{className:"w-4 h-4"}),onClick:()=>Z(!0),disabled:!f("queue:create"),title:f("queue:create")?void 0:c("archives.permission.noAddToQueue")},{label:c("archives.menu.openInBambuStudio"),icon:s.jsx(Kr,{className:"w-4 h-4"}),onClick:()=>{const re=t.print_name||t.filename||"model",Fe=`${window.location.origin}${ue.getArchiveForSlicer(t.id,re)}`;mu(Fe)}}]:[{label:c("archives.menu.slice"),icon:s.jsx(Kr,{className:"w-4 h-4"}),onClick:()=>{const re=t.print_name||t.filename||"model",Fe=`${window.location.origin}${ue.getArchiveForSlicer(t.id,re)}`;mu(Fe)}}],{label:t.external_url?c("archives.menu.externalLink"):c("archives.menu.viewOnMakerWorld"),icon:s.jsx(sh,{className:"w-4 h-4"}),onClick:()=>{const re=t.external_url||t.makerworld_url;re&&window.open(re,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:c("archives.menu.preview3d"),icon:s.jsx(lo,{className:"w-4 h-4"}),onClick:()=>b(!0)},{label:c("archives.menu.viewTimelapse"),icon:s.jsx(ah,{className:"w-4 h-4"}),onClick:()=>k(!0),disabled:!t.timelapse_path},{label:c("archives.menu.scanForTimelapse"),icon:s.jsx(K1,{className:"w-4 h-4"}),onClick:()=>fe.mutate(),disabled:!t.printer_id||!!t.timelapse_path||fe.isPending||!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?c("archives.menu.downloadSource3mf"):c("archives.menu.uploadSource3mf"),icon:s.jsx(G1,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const re=document.createElement("a");re.href=ue.getSource3mfDownloadUrl(t.id),re.download=`${t.print_name||t.filename}_source.3mf`,re.click()}else Me.current?.click()},disabled:!t.source_3mf_path&&!p("archives","update",t.created_by_id),title:!t.source_3mf_path&&!p("archives","update",t.created_by_id)?c("archives.permission.noUploadFiles"):void 0},...t.source_3mf_path?[{label:c("archives.menu.replaceSource3mf"),icon:s.jsx(Ua,{className:"w-4 h-4"}),onClick:()=>Me.current?.click(),disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},{label:c("archives.menu.removeSource3mf"),icon:s.jsx(rn,{className:"w-4 h-4"}),onClick:()=>B(!0),danger:!0,disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")}]:[],{label:t.f3d_path?c("archives.menu.replaceF3d"):c("archives.menu.uploadF3d"),icon:s.jsx(lo,{className:"w-4 h-4"}),onClick:()=>Oe.current?.click(),disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},...t.f3d_path?[{label:c("archives.menu.downloadF3d"),icon:s.jsx(yi,{className:"w-4 h-4"}),onClick:()=>{const re=document.createElement("a");re.href=ue.getF3dDownloadUrl(t.id),re.download=`${t.print_name||t.filename}.f3d`,re.click()}},{label:c("archives.menu.removeF3d"),icon:s.jsx(rn,{className:"w-4 h-4"}),onClick:()=>ne(!0),danger:!0,disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")}]:[],{label:"",divider:!0,onClick:()=>{}},{label:c("archives.menu.download"),icon:s.jsx(yi,{className:"w-4 h-4"}),onClick:()=>{const re=document.createElement("a");re.href=ue.getArchiveDownload(t.id),re.download=`${t.print_name||t.filename}.3mf`,re.click()},disabled:!f("archives:read"),title:f("archives:read")?void 0:c("archives.permission.noDownload")},{label:c("archives.menu.copyDownloadLink"),icon:s.jsx(Fl,{className:"w-4 h-4"}),onClick:()=>{const re=`${window.location.origin}${ue.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(re).then(()=>{d(c("archives.toast.linkCopied"))}).catch(()=>{d(c("archives.toast.failedCopyLink"),"error")})},disabled:!f("archives:read"),title:f("archives:read")?void 0:c("archives.permission.noCopyLink")},{label:c("archives.menu.qrCode"),icon:s.jsx(NW,{className:"w-4 h-4"}),onClick:()=>H(!0)},{label:t.photos?.length?c("archives.menu.viewPhotosCount",{count:t.photos.length}):c("archives.menu.viewPhotos"),icon:s.jsx(Ug,{className:"w-4 h-4"}),onClick:()=>$(!0),disabled:!t.photos?.length},{label:c("archives.menu.projectPage"),icon:s.jsx(Ls,{className:"w-4 h-4"}),onClick:()=>V(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?c("archives.menu.removeFromFavorites"):c("archives.menu.addToFavorites"),icon:s.jsx(im,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>z.mutate(),disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},{label:c("archives.menu.edit"),icon:s.jsx(Qi,{className:"w-4 h-4"}),onClick:()=>E(!0),disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},...t.project_id&&t.project_name?[{label:c("archives.menu.goToProject",{name:t.project_name}),icon:s.jsx(Ja,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:c("archives.menu.addToProject"),icon:s.jsx(Ja,{className:"w-4 h-4"}),onClick:()=>{},disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives"),submenu:(()=>{const re=[];if(t.project_id&&re.push({label:c("archives.menu.removeFromProject"),icon:s.jsx(Rt,{className:"w-4 h-4"}),onClick:()=>ee.mutate(null),disabled:!p("archives","update",t.created_by_id)}),!a)re.push({label:c("archives.menu.loading"),icon:s.jsx(ht,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const Fe=a.filter($e=>$e.status==="active");Fe.length===0?re.push({label:c("archives.menu.noProjectsAvailable"),icon:s.jsx(Ja,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):Fe.forEach($e=>{re.push({label:$e.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:$e.color||"#888"}}),onClick:()=>ee.mutate($e.id),disabled:t.project_id===$e.id||!p("archives","update",t.created_by_id)})})}return re})()},{label:c(n?"archives.menu.deselect":"archives.menu.select"),icon:n?s.jsx(ol,{className:"w-4 h-4"}):s.jsx(ll,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:c("archives.menu.delete"),icon:s.jsx(rn,{className:"w-4 h-4"}),onClick:()=>M(!0),danger:!0,disabled:!p("archives","delete",t.created_by_id),title:p("archives","delete",t.created_by_id)?void 0:c("archives.permission.noDelete")}];return s.jsxs(_t,{"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:le,onClick:i?()=>r(t.id):void 0,children:[i&&s.jsx("button",{className:"absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:re=>{re.stopPropagation(),r(t.id)},children:n?s.jsx(ol,{className:"w-5 h-5 text-bambu-green"}):s.jsx(ll,{className:"w-5 h-5 text-white"})}),s.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",onMouseEnter:()=>ie(!0),onMouseLeave:()=>ie(!1),children:[t.thumbnail_path?s.jsx("img",{src:xe!==null&&Ke.length>0?ue.getArchivePlateThumbnail(t.id,Ke[Y]?.index??0):ue.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center",children:s.jsx(Ou,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),G&&Ke.length>1&&s.jsxs(s.Fragment,{children:[s.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:re=>{re.stopPropagation(),de(Fe=>{const $e=Fe??0;return $e>0?$e-1:Ke.length-1})},title:c("archives.card.previousPlate"),children:s.jsx(gh,{className:"w-4 h-4 text-white"})}),s.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:re=>{re.stopPropagation(),de(Fe=>{const $e=Fe??0;return $e<Ke.length-1?$e+1:0})},title:c("archives.card.nextPlate"),children:s.jsx(gs,{className:"w-4 h-4 text-white"})}),s.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:Ke.map((re,Fe)=>s.jsx("button",{className:`w-2 h-2 rounded-full transition-colors ${Fe===Y?"bg-bambu-green":"bg-white/50 hover:bg-white/80"}`,onClick:$e=>{$e.stopPropagation(),de(Fe)},title:re.name||c("archives.card.plateNumber",{index:re.index})},re.index))})]}),s.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:re=>{re.stopPropagation();const Fe=re.currentTarget.getBoundingClientRect();be({x:Fe.left,y:Fe.bottom+4})},title:c("archives.card.moreOptions"),children:s.jsx(ih,{className:"w-5 h-5 text-white"})}),s.jsx("button",{className:`absolute top-2 right-2 p-1 rounded transition-colors ${p("archives","update",t.created_by_id)?"bg-black/50 hover:bg-black/70":"bg-black/30 cursor-not-allowed"}`,onClick:re=>{re.stopPropagation(),p("archives","update",t.created_by_id)&&z.mutate()},disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?t.is_favorite?c("archives.card.removeFromFavorites"):c("archives.card.addToFavorites"):c("archives.permission.noUpdateArchives"),children:s.jsx(im,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"} ${p("archives","update",t.created_by_id)?"":"opacity-50"}`})}),(t.status==="failed"||t.status==="aborted")&&s.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"?c("archives.card.cancelled"):c("archives.card.failed")}),t.duplicate_count>0&&s.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:c("archives.card.duplicateTitle"),children:[s.jsx(Fl,{className:"w-3 h-3"}),c("archives.card.duplicate")]}),t.source_3mf_path&&s.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:re=>{re.stopPropagation();const Fe=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",$e=`${window.location.origin}${ue.getSource3mfForSlicer(t.id,Fe)}`;mu($e)},title:c("archives.card.openSource3mf"),children:s.jsx(G1,{className:"w-4 h-4 text-orange-400"})}),t.f3d_path&&s.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:re=>{re.stopPropagation(),window.location.href=ue.getF3dDownloadUrl(t.id)},title:c("archives.card.downloadF3d"),children:s.jsx(lo,{className:"w-4 h-4 text-cyan-400"})}),t.timelapse_path&&s.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:re=>{re.stopPropagation(),k(!0)},title:c("archives.card.viewTimelapse"),children:s.jsx(ah,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&s.jsxs("button",{className:`absolute bottom-2 ${t.timelapse_path?"right-12":"right-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:re=>{re.stopPropagation(),$(!0)},title:t.photos.length===1?c("archives.card.viewPhoto"):c("archives.card.viewPhotos",{count:t.photos.length}),children:[s.jsx(Ug,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&s.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})]}),O&&O.length>0&&s.jsx(Ds,{to:`/files?folder=${O[0].id}`,className:"absolute bottom-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:re=>re.stopPropagation(),title:c("archives.card.openFolder",{name:O[0].name}),style:{left:t.source_3mf_path?t.f3d_path?"5.5rem":"3rem":t.f3d_path?"3rem":"0.5rem"},children:s.jsx(Il,{className:"w-4 h-4 text-yellow-400"})})]}),s.jsxs(Nt,{className:"p-4 flex-1 flex flex-col",children:[s.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),s.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:e}),s.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${Cf(t.filename)?"bg-bambu-green/20 text-bambu-green":"bg-orange-500/20 text-orange-400"}`,title:Cf(t.filename)?c("archives.card.slicedFile"):c("archives.card.sourceFile"),children:Cf(t.filename)?c("archives.card.gcode"):c("archives.card.source")}),t.project_name&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full truncate max-w-[120px]",style:{backgroundColor:`${a?.find(re=>re.id===t.project_id)?.color||"#6b7280"}20`,color:a?.find(re=>re.id===t.project_id)?.color||"#6b7280"},title:c("archives.card.project",{name:t.project_name}),children:t.project_name})]}),s.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)&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${t0(t.print_time_seconds||0)}
  8268. Actual: ${t0(t.actual_time_seconds||0)}
  8269. Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${t0(t.actual_time_seconds)}`:`Estimated: ${t0(t.print_time_seconds||0)}`,children:[s.jsx(Jn,{className:"w-3 h-3"}),t0(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&s.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&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[s.jsx(mc,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[s.jsx(sl,{className:"w-3 h-3"}),t.total_layers&&s.jsx("span",{children:t.total_layers===1?c("archives.card.layer",{count:t.total_layers}):c("archives.card.layers",{count:t.total_layers})}),t.total_layers&&t.layer_height&&s.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&s.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.object_count!=null&&t.object_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.object_count===1?c("archives.card.object",{count:t.object_count}):c("archives.card.objects",{count:t.object_count}),children:[s.jsx(lo,{className:"w-3 h-3"}),t.object_count===1?c("archives.card.object",{count:t.object_count}):c("archives.card.objects",{count:t.object_count})]}),t.sliced_for_model&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:c("archives.card.slicedFor",{model:t.sliced_for_model}),children:[s.jsx(Ur,{className:"w-3 h-3"}),t.sliced_for_model]}),t.filament_type&&s.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[s.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&s.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((re,Fe)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:re},title:re},Fe))})]})]}),(t.tags||t.notes)&&s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t.notes&&s.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:s.jsx(EW,{className:"w-3 h-3"})}),t.tags?.split(",").map((re,Fe)=>s.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:re.trim()},Fe))]}),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[s.jsx("span",{children:$g(t.created_at,l)}),s.jsxs("div",{className:"flex items-center gap-2",children:[t.created_by_username&&s.jsxs("span",{className:"flex items-center gap-1",title:c("archives.card.uploadedBy",{name:t.created_by_username}),children:[s.jsx(am,{className:"w-3 h-3"}),t.created_by_username]}),s.jsx("span",{children:XN(t.file_size)})]})]}),s.jsxs("div",{className:"flex gap-1 mt-3",children:[Cf(t.filename)?s.jsxs(s.Fragment,{children:[s.jsxs(Te,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>v(!0),disabled:!p("archives","reprint",t.created_by_id),title:p("archives","reprint",t.created_by_id)?void 0:c("archives.card.noPermissionReprint"),children:[s.jsx(Ur,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:c("archives.card.reprint")})]}),s.jsxs(Te,{variant:"secondary",size:"sm",className:"flex-1 min-w-0",onClick:()=>Z(!0),disabled:!f("queue:create"),title:f("queue:create")?c("archives.card.schedulePrint"):c("archives.permission.noAddToQueue"),children:[s.jsx(si,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:c("archives.card.schedule")})]}),s.jsx(Te,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const re=t.print_name||t.filename||"model",Fe=`${window.location.origin}${ue.getArchiveForSlicer(t.id,re)}`;mu(Fe)},title:c("archives.card.openInBambuStudio"),children:s.jsx(Kr,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}):s.jsxs(Te,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>{const re=t.print_name||t.filename||"model",Fe=`${window.location.origin}${ue.getArchiveForSlicer(t.id,re)}`;mu(Fe)},title:c("archives.card.openInBambuStudioToSlice"),children:[s.jsx(Kr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:c("archives.card.slice")})]}),s.jsx(Te,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const re=t.external_url||t.makerworld_url;re&&window.open(re,"_blank")},disabled:!t.external_url&&!t.makerworld_url,title:t.external_url?c("archives.card.externalLink"):t.makerworld_url?c("archives.card.makerWorld",{designer:t.designer||c("archives.card.viewProject")}):c("archives.card.noExternalLink"),children:s.jsx(sh,{className:`w-3 h-3 sm:w-4 sm:h-4 ${!t.external_url&&!t.makerworld_url?"opacity-20":""}`})}),s.jsx(Te,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>b(!0),title:c("archives.card.preview3d"),children:s.jsx(lo,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Te,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const re=document.createElement("a");re.href=ue.getArchiveDownload(t.id),re.download=`${t.print_name||t.filename}.3mf`,re.click()},title:c("archives.card.download"),children:s.jsx(yi,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>E(!0),disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?c("archives.card.edit"):c("archives.card.noPermissionEdit"),children:s.jsx(Qi,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>M(!0),disabled:!p("archives","delete",t.created_by_id),title:p("archives","delete",t.created_by_id)?c("archives.card.delete"):c("archives.card.noPermissionDelete"),children:s.jsx(rn,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),T&&s.jsx(yee,{archive:t,onClose:()=>E(!1)}),x&&s.jsx(pee,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>b(!1)}),y&&s.jsx(jh,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>v(!1)}),S&&s.jsx(Qn,{title:c("archives.modal.deleteArchive"),message:c("archives.modal.deleteConfirm",{name:t.print_name||t.filename}),confirmText:c("archives.modal.deleteButton"),variant:"danger",onConfirm:()=>{ke.mutate(),M(!1)},onCancel:()=>M(!1)}),ae&&s.jsx(Qn,{title:c("archives.modal.removeSource3mf"),message:c("archives.modal.removeSource3mfConfirm",{name:t.print_name||t.filename}),confirmText:c("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{q.mutate(),B(!1)},onCancel:()=>B(!1)}),X&&s.jsx(Qn,{title:c("archives.modal.removeF3d"),message:c("archives.modal.removeF3dConfirm",{name:t.print_name||t.filename}),confirmText:c("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{I.mutate(),ne(!1)},onCancel:()=>ne(!1)}),se&&s.jsx(vee,{x:se.x,y:se.y,items:we,onClose:()=>be(null)}),C&&t.timelapse_path&&s.jsx(are,{src:ue.getArchiveTimelapse(t.id),title:c("archives.modal.timelapse",{name:t.print_name||t.filename}),downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>k(!1),onEdit:()=>{u.invalidateQueries({queryKey:["archives"]}),k(!1)}}),R&&D.length>0&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),s.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),s.jsx("button",{onClick:()=>{A(!1),U([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:D.map(re=>s.jsxs("button",{onClick:()=>me.mutate(re.name),disabled:me.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:[s.jsx(ah,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-white font-medium truncate",children:re.name}),s.jsxs("p",{className:"text-sm text-gray-400",children:[XN(re.size),re.mtime&&` • ${$g(re.mtime,l)}`]})]})]},re.name))}),s.jsx("div",{className:"p-4 border-t border-gray-700",children:s.jsx(Te,{variant:"secondary",onClick:()=>{A(!1),U([])},className:"w-full",children:"Cancel"})})]})}),F&&s.jsx(wee,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>H(!1)}),j&&t.photos&&t.photos.length>0&&s.jsx(_ee,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>$(!1),onDelete:async re=>{try{await ue.deleteArchivePhoto(t.id,re),u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.photoDeleted"))}catch{d(c("archives.toast.failedDeletePhoto"),"error")}}}),K&&s.jsx(ire,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>V(!1)}),Q&&s.jsx(jh,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>Z(!1)}),s.jsx("input",{ref:Me,type:"file",accept:".3mf",className:"hidden",onChange:re=>{const Fe=re.target.files?.[0];Fe&&ce.mutate(Fe),re.target.value=""}}),s.jsx("input",{ref:Oe,type:"file",accept:".f3d",className:"hidden",onChange:re=>{const Fe=re.target.files?.[0];Fe&&te.mutate(Fe),re.target.value=""}})]})}function eqe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o,t:l}){const c=an(),{showToast:u}=Hn(),{hasPermission:d,canModify:f}=Ai(),[p,m]=_.useState(!1),[x,b]=_.useState(!1),[y,v]=_.useState(!1),[S,M]=_.useState(!1),[T,E]=_.useState(!1),[C,k]=_.useState(!1),[R,A]=_.useState(!1),[D,U]=_.useState([]),[F,H]=_.useState(!1),[j,$]=_.useState(!1),[K,V]=_.useState(!1),[Q,Z]=_.useState(!1),[ae,B]=_.useState(!1),[X,ne]=_.useState(null),se=_.useRef(null),be=_.useRef(null),xe=mt({mutationFn:I=>ue.uploadSource3mf(t.id,I),onSuccess:I=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.source3mfAttached",{filename:I.filename}))},onError:I=>{u(I.message||l("archives.toast.failedUploadSource3mf"),"error")}}),de=mt({mutationFn:()=>ue.deleteSource3mf(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.source3mfRemoved"))},onError:I=>{u(I.message||l("archives.toast.failedRemoveSource3mf"),"error")}}),Pe=mt({mutationFn:I=>ue.uploadF3d(t.id,I),onSuccess:I=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.f3dAttached",{filename:I.filename}))},onError:I=>{u(I.message||l("archives.toast.failedUploadF3d"),"error")}}),ie=mt({mutationFn:()=>ue.deleteF3d(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.f3dRemoved"))},onError:I=>{u(I.message||l("archives.toast.failedRemoveF3d"),"error")}}),Me=mt({mutationFn:()=>ue.scanArchiveTimelapse(t.id),onSuccess:I=>{I.status==="attached"?(c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.timelapseAttached",{filename:I.filename}))):I.status==="exists"?u(l("archives.toast.timelapseAlreadyAttached")):I.status==="not_found"&&I.available_files&&I.available_files.length>0?(U(I.available_files),A(!0)):u(I.message||l("archives.toast.noMatchingTimelapse"),"warning")},onError:I=>{u(I.message||l("archives.toast.failedScanTimelapse"),"error")}}),Oe=mt({mutationFn:I=>ue.selectArchiveTimelapse(t.id,I),onSuccess:I=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.timelapseAttached",{filename:I.filename})),A(!1),U([])},onError:I=>{u(I.message||l("archives.toast.failedAttachTimelapse"),"error")}}),ge=mt({mutationFn:()=>ue.deleteArchive(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.archiveDeleted"))},onError:()=>{u(l("archives.toast.failedDeleteArchive"),"error")}}),Ke=mt({mutationFn:()=>ue.toggleFavorite(t.id),onSuccess:I=>{c.invalidateQueries({queryKey:["archives"]}),u(I.is_favorite?l("archives.toast.addedToFavorites"):l("archives.toast.removedFromFavorites"))}}),{data:G}=at({queryKey:["archive-folders",t.id],queryFn:()=>ue.getLibraryFoldersByArchive(t.id)}),Y=mt({mutationFn:I=>ue.updateArchive(t.id,{project_id:I}),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),c.invalidateQueries({queryKey:["projects"]}),u(l("archives.toast.projectUpdated"))},onError:()=>{u(l("archives.toast.failedUpdateProject"),"error")}}),ce=I=>{I.preventDefault(),ne({x:I.clientX,y:I.clientY})},te=[...Cf(t.filename)?[{label:l("archives.menu.print"),icon:s.jsx(Ur,{className:"w-4 h-4"}),onClick:()=>v(!0),disabled:!f("archives","reprint",t.created_by_id),title:f("archives","reprint",t.created_by_id)?void 0:l("archives.permission.noReprint")},{label:l("archives.menu.schedule"),icon:s.jsx(si,{className:"w-4 h-4"}),onClick:()=>M(!0),disabled:!d("queue:create"),title:d("queue:create")?void 0:l("archives.permission.noAddToQueue")},{label:l("archives.menu.openInBambuStudio"),icon:s.jsx(Kr,{className:"w-4 h-4"}),onClick:()=>{const I=t.print_name||t.filename||"model",fe=`${window.location.origin}${ue.getArchiveForSlicer(t.id,I)}`;mu(fe)}}]:[{label:l("archives.menu.slice"),icon:s.jsx(Kr,{className:"w-4 h-4"}),onClick:()=>{const I=t.print_name||t.filename||"model",fe=`${window.location.origin}${ue.getArchiveForSlicer(t.id,I)}`;mu(fe)}}],{label:t.external_url?l("archives.menu.externalLink"):l("archives.menu.viewOnMakerWorld"),icon:s.jsx(sh,{className:"w-4 h-4"}),onClick:()=>{const I=t.external_url||t.makerworld_url;I&&window.open(I,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:l("archives.menu.preview3d"),icon:s.jsx(lo,{className:"w-4 h-4"}),onClick:()=>E(!0)},{label:l("archives.menu.viewTimelapse"),icon:s.jsx(ah,{className:"w-4 h-4"}),onClick:()=>k(!0),disabled:!t.timelapse_path},{label:l("archives.menu.scanForTimelapse"),icon:s.jsx(K1,{className:"w-4 h-4"}),onClick:()=>Me.mutate(),disabled:!t.printer_id||!!t.timelapse_path||Me.isPending||!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?l("archives.menu.downloadSource3mf"):l("archives.menu.uploadSource3mf"),icon:s.jsx(G1,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const I=document.createElement("a");I.href=ue.getSource3mfDownloadUrl(t.id),I.download=`${t.print_name||t.filename}_source.3mf`,I.click()}else se.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)?l("archives.permission.noUploadFiles"):void 0},...t.source_3mf_path?[{label:l("archives.menu.replaceSource3mf"),icon:s.jsx(Ua,{className:"w-4 h-4"}),onClick:()=>se.current?.click(),disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")},{label:l("archives.menu.removeSource3mf"),icon:s.jsx(rn,{className:"w-4 h-4"}),onClick:()=>Z(!0),danger:!0,disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")}]:[],{label:t.f3d_path?l("archives.menu.replaceF3d"):l("archives.menu.uploadF3d"),icon:s.jsx(lo,{className:"w-4 h-4"}),onClick:()=>be.current?.click(),disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")},...t.f3d_path?[{label:l("archives.menu.downloadF3d"),icon:s.jsx(yi,{className:"w-4 h-4"}),onClick:()=>{const I=document.createElement("a");I.href=ue.getF3dDownloadUrl(t.id),I.download=`${t.print_name||t.filename}.f3d`,I.click()}},{label:l("archives.menu.removeF3d"),icon:s.jsx(rn,{className:"w-4 h-4"}),onClick:()=>B(!0),danger:!0,disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")}]:[],{label:"",divider:!0,onClick:()=>{}},{label:l("archives.menu.download"),icon:s.jsx(yi,{className:"w-4 h-4"}),onClick:()=>{const I=document.createElement("a");I.href=ue.getArchiveDownload(t.id),I.download=`${t.print_name||t.filename}.3mf`,I.click()},disabled:!d("archives:read"),title:d("archives:read")?void 0:l("archives.permission.noDownload")},{label:l("archives.menu.copyDownloadLink"),icon:s.jsx(Fl,{className:"w-4 h-4"}),onClick:()=>{const I=`${window.location.origin}${ue.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(I).then(()=>{u(l("archives.toast.linkCopied"))}).catch(()=>{u(l("archives.toast.failedCopyLink"),"error")})},disabled:!d("archives:read"),title:d("archives:read")?void 0:l("archives.permission.noCopyLink")},{label:l("archives.menu.qrCode"),icon:s.jsx(NW,{className:"w-4 h-4"}),onClick:()=>H(!0)},{label:t.photos?.length?l("archives.menu.viewPhotosCount",{count:t.photos.length}):l("archives.menu.viewPhotos"),icon:s.jsx(Ug,{className:"w-4 h-4"}),onClick:()=>$(!0),disabled:!t.photos?.length},{label:l("archives.menu.projectPage"),icon:s.jsx(Ls,{className:"w-4 h-4"}),onClick:()=>V(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?l("archives.menu.removeFromFavorites"):l("archives.menu.addToFavorites"),icon:s.jsx(im,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>Ke.mutate(),disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")},{label:l("archives.menu.edit"),icon:s.jsx(Qi,{className:"w-4 h-4"}),onClick:()=>m(!0),disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")},...t.project_id&&t.project_name?[{label:l("archives.menu.goToProject",{name:t.project_name}),icon:s.jsx(Ja,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:l("archives.menu.addToProject"),icon:s.jsx(Ja,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const I=[];if(t.project_id&&I.push({label:l("archives.menu.removeFromProject"),icon:s.jsx(Rt,{className:"w-4 h-4"}),onClick:()=>Y.mutate(null)}),!a)I.push({label:l("archives.menu.loading"),icon:s.jsx(ht,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const fe=a.filter(me=>me.status==="active");fe.length===0?I.push({label:l("archives.menu.noProjectsAvailable"),icon:s.jsx(Ja,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):fe.forEach(me=>{I.push({label:me.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:me.color||"#888"}}),onClick:()=>Y.mutate(me.id),disabled:t.project_id===me.id})})}return I})()},{label:l(n?"archives.menu.deselect":"archives.menu.select"),icon:n?s.jsx(ol,{className:"w-4 h-4"}):s.jsx(ll,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:l("archives.menu.delete"),icon:s.jsx(rn,{className:"w-4 h-4"}),onClick:()=>b(!0),danger:!0,disabled:!f("archives","delete",t.created_by_id),title:f("archives","delete",t.created_by_id)?void 0:l("archives.permission.noDelete")}];return s.jsxs(s.Fragment,{children:[s.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:ce,children:[s.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[i&&s.jsx("button",{onClick:()=>r(t.id),children:n?s.jsx(ol,{className:"w-4 h-4 text-bambu-green"}):s.jsx(ll,{className:"w-4 h-4 text-bambu-gray"})}),t.thumbnail_path?s.jsx("img",{src:ue.getArchiveThumbnail(t.id),alt:"",className:"w-10 h-10 object-cover rounded"}):s.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:s.jsx(Ou,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),s.jsxs("div",{className:"col-span-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-white text-sm truncate",children:t.print_name||t.filename}),t.timelapse_path&&s.jsx("span",{title:l("archives.list.hasTimelapse"),children:s.jsx(ah,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})}),G&&G.length>0&&s.jsx(Ds,{to:`/files?folder=${G[0].id}`,className:"flex-shrink-0",title:l("archives.card.openFolder",{name:G[0].name}),onClick:I=>I.stopPropagation(),children:s.jsx(Il,{className:"w-3.5 h-3.5 text-yellow-400"})})]}),(t.filament_type||t.sliced_for_model)&&s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.sliced_for_model&&s.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",title:l("archives.card.slicedFor",{model:t.sliced_for_model}),children:[s.jsx(Ur,{className:"w-2.5 h-2.5"}),t.sliced_for_model]}),t.sliced_for_model&&t.filament_type&&s.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.filament_type&&s.jsx("span",{className:"text-xs text-bambu-gray",children:t.filament_type}),t.filament_color&&s.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((I,fe)=>s.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:I},title:I},fe))})]})]}),s.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:e}),s.jsxs("div",{className:"col-span-2 text-sm text-bambu-gray",children:[s.jsx("div",{children:Bg(t.created_at)}),t.created_by_username&&s.jsxs("div",{className:"flex items-center gap-1 text-xs opacity-75",title:l("archives.card.uploadedBy",{name:t.created_by_username}),children:[s.jsx(am,{className:"w-3 h-3"}),t.created_by_username]})]}),s.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:XN(t.file_size)}),s.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{const I=t.print_name||t.filename||"model",fe=`${window.location.origin}${ue.getArchiveForSlicer(t.id,I)}`;mu(fe)},title:l("archives.card.openInBambuStudio"),children:s.jsx(Kr,{className:"w-4 h-4"})}),(t.external_url||t.makerworld_url)&&s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>window.open(t.external_url||t.makerworld_url,"_blank"),title:t.external_url?l("archives.card.externalLink"):"MakerWorld",children:s.jsx(sh,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{const I=document.createElement("a");I.href=ue.getArchiveDownload(t.id),I.download=`${t.print_name||t.filename}.3mf`,I.click()},title:l("archives.card.download"),children:s.jsx(yi,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>m(!0),disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?l("archives.card.edit"):l("archives.card.noPermissionEdit"),children:s.jsx(Qi,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>b(!0),disabled:!f("archives","delete",t.created_by_id),title:f("archives","delete",t.created_by_id)?l("archives.card.delete"):l("archives.card.noPermissionDelete"),children:s.jsx(rn,{className:"w-4 h-4 text-red-400"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:I=>{const fe=I.currentTarget.getBoundingClientRect();ne({x:fe.left,y:fe.bottom+4})},title:l("archives.card.moreOptions"),children:s.jsx(ih,{className:"w-4 h-4"})})]})]}),p&&s.jsx(yee,{archive:t,onClose:()=>m(!1)}),T&&s.jsx(pee,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>E(!1)}),y&&s.jsx(jh,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>v(!1)}),x&&s.jsx(Qn,{title:l("archives.modal.deleteArchive"),message:l("archives.modal.deleteConfirm",{name:t.print_name||t.filename}),confirmText:l("archives.modal.deleteButton"),variant:"danger",onConfirm:()=>{ge.mutate(),b(!1)},onCancel:()=>b(!1)}),Q&&s.jsx(Qn,{title:l("archives.modal.removeSource3mf"),message:l("archives.modal.removeSource3mfConfirm",{name:t.print_name||t.filename}),confirmText:l("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{de.mutate(),Z(!1)},onCancel:()=>Z(!1)}),ae&&s.jsx(Qn,{title:l("archives.modal.removeF3d"),message:l("archives.modal.removeF3dConfirm",{name:t.print_name||t.filename}),confirmText:l("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{ie.mutate(),B(!1)},onCancel:()=>B(!1)}),X&&s.jsx(vee,{x:X.x,y:X.y,items:te,onClose:()=>ne(null)}),C&&t.timelapse_path&&s.jsx(are,{src:ue.getArchiveTimelapse(t.id),title:l("archives.modal.timelapse",{name:t.print_name||t.filename}),downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>k(!1),onEdit:()=>{c.invalidateQueries({queryKey:["archives"]}),k(!1)}}),R&&D.length>0&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),s.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),s.jsx("button",{onClick:()=>{A(!1),U([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:D.map(I=>s.jsxs("button",{onClick:()=>Oe.mutate(I.name),disabled:Oe.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors mb-1",children:[s.jsx("div",{className:"font-medium text-white",children:I.name}),s.jsxs("div",{className:"text-sm text-gray-400 flex gap-3",children:[s.jsx("span",{children:XN(I.size)}),I.mtime&&s.jsx("span",{children:Bg(I.mtime)})]})]},I.name))})]})}),F&&s.jsx(wee,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>H(!1)}),j&&t.photos&&s.jsx(_ee,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>$(!1),onDelete:async I=>{try{await ue.deleteArchivePhoto(t.id,I),c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.photoDeleted"))}catch{u(l("archives.toast.failedDeletePhoto"),"error")}}}),K&&s.jsx(ire,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>V(!1)}),S&&s.jsx(jh,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>M(!1)}),s.jsx("input",{ref:se,type:"file",accept:".3mf",className:"hidden",onChange:I=>{const fe=I.target.files?.[0];fe&&xe.mutate(fe),I.target.value=""}}),s.jsx("input",{ref:be,type:"file",accept:".f3d",className:"hidden",onChange:I=>{const fe=I.target.files?.[0];fe&&Pe.mutate(fe),I.target.value=""}})]})}const tqe=[{id:"all",label:"All Archives",icon:s.jsx(Il,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:s.jsx(Jn,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:s.jsx(si,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:s.jsx(si,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:s.jsx(im,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:s.jsx($i,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:s.jsx(Fl,{className:"w-4 h-4"})}];function nqe(){const{t}=$n(),e=an(),{showToast:n}=Hn(),{hasPermission:r,hasAnyPermission:i}=Ai(),a=_.useRef(null),[o,l]=_.useState(""),[c,u]=_.useState(()=>{const W=localStorage.getItem("archiveFilterPrinter");return W?Number(W):null}),[d,f]=_.useState(()=>localStorage.getItem("archiveFilterMaterial")),[p,m]=_.useState(()=>{const W=localStorage.getItem("archiveFilterColors");return W?new Set(JSON.parse(W)):new Set}),[x,b]=_.useState(()=>localStorage.getItem("archiveColorFilterMode")||"or"),[y,v]=_.useState(()=>localStorage.getItem("archiveFilterFavorites")==="true"),[S,M]=_.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[T,E]=_.useState(()=>localStorage.getItem("archiveFilterTag")),[C,k]=_.useState(()=>localStorage.getItem("archiveFilterFileType")||"all"),[R,A]=_.useState(!1),[D,U]=_.useState([]),[F,H]=_.useState(!1),[j,$]=_.useState(new Set),[K,V]=_.useState(!1),[Q,Z]=_.useState(!1),[ae,B]=_.useState(!1),[X,ne]=_.useState(!1),[se,be]=_.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[xe,de]=_.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[Pe,ie]=_.useState(()=>localStorage.getItem("archiveCollection")||"all"),[Me,Oe]=_.useState(!1),[ge,Ke]=_.useState(!1),[G,Y]=_.useState(!1),[ce,q]=_.useState(!1),[te,I]=_.useState(null);_.useEffect(()=>{if(te){const W=setTimeout(()=>{const Ye=document.querySelector(`[data-archive-id="${te}"]`);Ye&&Ye.scrollIntoView({behavior:"smooth",block:"center"})},100),De=setTimeout(()=>I(null),5e3);return()=>{clearTimeout(W),clearTimeout(De)}}},[te]);const{data:fe,isLoading:me}=at({queryKey:["archives",c],queryFn:()=>ue.getArchives(c||void 0)}),{data:ke}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:z}=at({queryKey:["projects"],queryFn:()=>ue.getProjects()}),{data:O}=at({queryKey:["settings"],queryFn:ue.getSettings}),ee=O?.time_format||"system",le=mt({mutationFn:async W=>(await Promise.all(W.map(De=>ue.deleteArchive(De))),W.length),onSuccess:W=>{e.invalidateQueries({queryKey:["archives"]}),$(new Set),n(`${W} archive${W!==1?"s":""} deleted`)},onError:()=>{n(t("archives.toast.failedDeleteArchives"),"error")}});_.useEffect(()=>{c!==null?localStorage.setItem("archiveFilterPrinter",c.toString()):localStorage.removeItem("archiveFilterPrinter")},[c]),_.useEffect(()=>{d?localStorage.setItem("archiveFilterMaterial",d):localStorage.removeItem("archiveFilterMaterial")},[d]),_.useEffect(()=>{localStorage.setItem("archiveFilterColors",JSON.stringify([...p]))},[p]),_.useEffect(()=>{localStorage.setItem("archiveColorFilterMode",x)},[x]),_.useEffect(()=>{localStorage.setItem("archiveFilterFavorites",y.toString())},[y]),_.useEffect(()=>{localStorage.setItem("archiveHideFailed",S.toString())},[S]),_.useEffect(()=>{T?localStorage.setItem("archiveFilterTag",T):localStorage.removeItem("archiveFilterTag")},[T]),_.useEffect(()=>{localStorage.setItem("archiveFilterFileType",C)},[C]),_.useEffect(()=>{localStorage.setItem("archiveViewMode",se)},[se]),_.useEffect(()=>{localStorage.setItem("archiveSortBy",xe)},[xe]),_.useEffect(()=>{localStorage.setItem("archiveCollection",Pe)},[Pe]);const _e=new Map(ke?.map(W=>[W.id,W.name])||[]),we=[...new Set(fe?.flatMap(W=>W.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),re=[...new Set(fe?.flatMap(W=>W.filament_color?.split(",")||[]).filter(Boolean)||[])],Fe=[...new Set(fe?.flatMap(W=>W.tags?.split(",").map(De=>De.trim())||[]).filter(Boolean)||[])].sort(),$e=fe?.filter(W=>{const De=new Date,Ye=Ii(W.created_at)||new Date(0);let xt=!0;switch(Pe){case"recent":xt=De.getTime()-Ye.getTime()<1440*60*1e3;break;case"this-week":xt=De.getTime()-Ye.getTime()<10080*60*1e3;break;case"this-month":xt=Ye.getMonth()===De.getMonth()&&Ye.getFullYear()===De.getFullYear();break;case"favorites":xt=W.is_favorite===!0;break;case"failed":xt=W.status==="failed"||W.status==="aborted";break;case"duplicates":xt=W.duplicate_count>0;break}const ft=(W.print_name||W.filename).toLowerCase().includes(o.toLowerCase()),Bt=!d||W.filament_type?.split(", ").includes(d),Lt=W.filament_color?.split(",")||[],vn=p.size===0||(x==="or"?Lt.some(Fn=>p.has(Fn)):[...p].every(Fn=>Lt.includes(Fn))),Jt=Pe==="favorites"||!y||W.is_favorite,rr=Pe==="failed"||!S||W.status!=="failed"&&W.status!=="aborted",hr=W.tags?.split(",").map(Fn=>Fn.trim())||[],Dn=!T||hr.includes(T),ln=Cf(W.filename);return xt&&ft&&Bt&&vn&&Jt&&rr&&Dn&&(C==="all"||C==="gcode"&&ln||C==="source"&&!ln)}).sort((W,De)=>{switch(xe){case"date-desc":return(Ii(De.created_at)?.getTime()||0)-(Ii(W.created_at)?.getTime()||0);case"date-asc":return(Ii(W.created_at)?.getTime()||0)-(Ii(De.created_at)?.getTime()||0);case"name-asc":return(W.print_name||W.filename).localeCompare(De.print_name||De.filename);case"name-desc":return(De.print_name||De.filename).localeCompare(W.print_name||W.filename);case"size-desc":return De.file_size-W.file_size;case"size-asc":return W.file_size-De.file_size;default:return 0}}),Ve=K||j.size>0,He=W=>{$(De=>{const Ye=new Set(De);return Ye.has(W)?Ye.delete(W):Ye.add(W),Ye})},ye=()=>{$e&&$(new Set($e.map(W=>W.id)))},je=()=>{$(new Set),V(!1)},Be=W=>{m(De=>{const Ye=new Set(De);return Ye.has(W)?Ye.delete(W):Ye.add(W),Ye})},Se=()=>{m(new Set)},Xe=()=>{l(""),u(null),f(null),v(!1),M(!1),E(null),k("all")},Ne=o||c||d||y||S||T||C!=="all",tt=_.useCallback(W=>{W.preventDefault(),W.dataTransfer.types.includes("Files")&&H(!0)},[]),Ee=_.useCallback(W=>{W.preventDefault(),W.currentTarget===W.target&&H(!1)},[]),We=_.useCallback(W=>{W.preventDefault(),H(!1);const De=Array.from(W.dataTransfer.files).filter(Ye=>Ye.name.endsWith(".3mf"));De.length>0?(U(De),A(!0)):W.dataTransfer.files.length>0&&n(t("archives.page.only3mfSupported"),"warning")},[n,t]),ze=_.useCallback(W=>{const De=W.target;if(De.tagName==="INPUT"||De.tagName==="TEXTAREA"||De.isContentEditable){W.key==="Escape"&&De.blur();return}switch(W.key){case"/":W.preventDefault(),a.current?.focus();break;case"u":case"U":!W.metaKey&&!W.ctrlKey&&(W.preventDefault(),A(!0));break;case"Escape":Ve&&je();break}},[Ve]);return _.useEffect(()=>(document.addEventListener("keydown",ze),()=>document.removeEventListener("keydown",ze)),[ze]),s.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:tt,onDragLeave:Ee,onDrop:We,children:[F&&s.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:s.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[s.jsx(Ua,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),s.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),s.jsx("p",{className:"text-bambu-gray",children:t("archives.releaseToUpload")})]})}),Ve&&s.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:[s.jsxs(Te,{variant:"secondary",size:"sm",onClick:je,children:[s.jsx(Rt,{className:"w-4 h-4"}),"Close"]}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs("span",{className:"text-white font-medium",children:[j.size," selected"]}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:ye,children:"Select All"}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>B(!0),disabled:!i("archives:update_own","archives:update_all"),title:i("archives:update_own","archives:update_all")?void 0:t("archives.permission.noUpdateArchives"),children:[s.jsx(yh,{className:"w-4 h-4"}),"Tags"]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>ne(!0),disabled:!i("archives:update_own","archives:update_all"),title:i("archives:update_own","archives:update_all")?void 0:t("archives.permission.noUpdateArchives"),children:[s.jsx(Ja,{className:"w-4 h-4"}),"Project"]}),s.jsxs(Te,{variant:"secondary",size:"sm",disabled:!i("archives:update_own","archives:update_all"),title:i("archives:update_own","archives:update_all")?void 0:t("archives.permission.noUpdateArchives"),onClick:()=>{const W=Array.from(j);Promise.all(W.map(De=>ue.toggleFavorite(De))).then(()=>{e.invalidateQueries({queryKey:["archives"]}),n(`Toggled favorites for ${W.length} archive${W.length!==1?"s":""}`)}).catch(()=>{n(t("archives.toast.failedUpdateFavorites"),"error")})},children:[s.jsx(im,{className:"w-4 h-4"}),"Favorite"]}),s.jsxs(Te,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>Z(!0),disabled:!i("archives:delete_own","archives:delete_all"),title:i("archives:delete_own","archives:delete_all")?void 0:t("archives.permission.noDelete"),children:[s.jsx(rn,{className:"w-4 h-4"}),"Delete"]})]}),s.jsxs("div",{className:"flex items-center justify-between mb-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),s.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:Pe,onChange:W=>ie(W.target.value),children:tqe.map(W=>s.jsx("option",{value:W.id,children:W.label},W.id))})]}),s.jsxs("p",{className:"text-bambu-gray",children:[$e?.length||0," of ",fe?.length||0," prints"]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative",children:[s.jsxs(Te,{variant:"secondary",onClick:()=>Oe(!Me),disabled:ge,children:[ge?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(q1,{className:"w-4 h-4"}),"Export"]}),Me&&s.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:[s.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()=>{Oe(!1),Ke(!0);try{const{blob:W,filename:De}=await ue.exportArchives({format:"csv",printerId:c||void 0,status:Pe==="failed"?"failed":void 0,search:o||void 0}),Ye=URL.createObjectURL(W),xt=document.createElement("a");xt.href=Ye,xt.download=De,xt.click(),URL.revokeObjectURL(Ye),n(t("archives.toast.exportDownloaded"))}catch{n(t("archives.toast.exportFailed"),"error")}finally{Ke(!1)}},children:[s.jsx(Ls,{className:"w-4 h-4"}),"Export as CSV"]}),s.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()=>{Oe(!1),Ke(!0);try{const{blob:W,filename:De}=await ue.exportArchives({format:"xlsx",printerId:c||void 0,status:Pe==="failed"?"failed":void 0,search:o||void 0}),Ye=URL.createObjectURL(W),xt=document.createElement("a");xt.href=Ye,xt.download=De,xt.click(),URL.revokeObjectURL(Ye),n(t("archives.toast.exportDownloaded"))}catch{n(t("archives.toast.exportFailed"),"error")}finally{Ke(!1)}},children:[s.jsx(q1,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),j.size>=2&&j.size<=5&&s.jsxs(Te,{variant:"secondary",onClick:()=>Y(!0),children:[s.jsx(_g,{className:"w-4 h-4"}),"Compare (",j.size,")"]}),!Ve&&s.jsxs(Te,{variant:"secondary",onClick:()=>V(!0),children:[s.jsx(ol,{className:"w-4 h-4"}),"Select"]}),s.jsxs(Te,{onClick:()=>A(!0),disabled:!r("archives:create"),title:r("archives:create")?void 0:t("archives.permission.noCreate"),children:[s.jsx(Ua,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),s.jsx(_t,{className:"mb-6",children:s.jsxs(Nt,{className:"py-4",children:[s.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:gap-4 md:items-center md:flex-wrap",children:[s.jsxs("div",{className:"w-full md:flex-1 relative md:min-w-[200px]",children:[s.jsx(ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{ref:a,type:"text",placeholder:t("archives.searchPlaceholder"),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:o,onChange:W=>l(W.target.value)})]}),s.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:[s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(u2,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.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:c||"",onChange:W=>u(W.target.value?Number(W.target.value):null),children:[s.jsx("option",{value:"",children:"All Printers"}),ke?.map(W=>s.jsx("option",{value:W.id,children:W.name},W.id))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(mc,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.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:d||"",onChange:W=>f(W.target.value||null),children:[s.jsx("option",{value:"",children:"All Materials"}),we.map(W=>s.jsx("option",{value:W,children:W},W))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(G1,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.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:C,onChange:W=>k(W.target.value),children:[s.jsx("option",{value:"all",children:"All Files"}),s.jsx("option",{value:"gcode",children:"Sliced (GCODE)"}),s.jsx("option",{value:"source",children:"Source Only"})]})]}),s.jsxs("button",{onClick:()=>v(!y),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${y?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:t(y?"archives.showAll":"archives.showFavoritesOnly"),children:[s.jsx(im,{className:`w-4 h-4 ${y?"fill-yellow-400":""}`}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),s.jsxs("button",{onClick:()=>M(!S),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${S?"bg-red-500/20 border-red-500 text-red-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:t(S?"archives.showFailedPrints":"archives.hideFailedPrints"),children:[s.jsx($i,{className:"w-4 h-4 "}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),Fe.length>0&&s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(yh,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.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:W=>E(W.target.value||null),children:[s.jsx("option",{value:"",children:"All Tags"}),Fe.map(W=>s.jsx("option",{value:W,children:W},W))]}),s.jsx("button",{onClick:()=>q(!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:t("archives.manageTags"),children:s.jsx(x2,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(fW,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.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:xe,onChange:W=>de(W.target.value),children:[s.jsx("option",{value:"date-desc",children:t("archives.sortNewest")}),s.jsx("option",{value:"date-asc",children:t("archives.sortOldest")}),s.jsxs("option",{value:"name-asc",children:[t("archives.sortName")," A-Z"]}),s.jsxs("option",{value:"name-desc",children:[t("archives.sortName")," Z-A"]}),s.jsx("option",{value:"size-desc",children:t("archives.sortLargest")}),s.jsx("option",{value:"size-asc",children:t("archives.sortSmallest")})]})]}),s.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden flex-shrink-0",children:[s.jsx("button",{className:`p-2 ${se==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>be("grid"),title:t("archives.gridView"),children:s.jsx(m2,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${se==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>be("list"),title:t("archives.listView"),children:s.jsx(p2,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${se==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>be("calendar"),title:t("archives.calendarView"),children:s.jsx(Ace,{className:"w-4 h-4"})})]})]}),Ne&&s.jsxs(Te,{variant:"ghost",size:"sm",onClick:Xe,className:"text-bambu-gray hover:text-white",children:[s.jsx(Rt,{className:"w-4 h-4"}),"Reset"]})]}),re.length>0&&s.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),p.size>1&&s.jsx("button",{onClick:()=>b(W=>W==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${x==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:x==="or"?"Match ANY selected color":"Match ALL selected colors",children:x.toUpperCase()}),s.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:re.map(W=>s.jsx("button",{onClick:()=>Be(W),className:`w-6 h-6 rounded-full border-2 transition-all ${p.has(W)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:W},title:W},W))}),p.size>0&&s.jsxs("button",{onClick:Se,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[s.jsx(Rt,{className:"w-3 h-3"}),"Clear"]})]})]})}),s.jsx(Q9e,{}),me?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("archives.loadingArchives")}):$e?.length===0?s.jsx(_t,{children:s.jsxs(Nt,{className:"text-center py-12",children:[s.jsx("p",{className:"text-bambu-gray",children:t(o?"archives.noArchivesSearch":"archives.noArchivesYet")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):se==="calendar"?s.jsx(_t,{className:"p-6",children:s.jsx(T8e,{archives:$e||[],onArchiveClick:W=>{l(""),be("grid"),I(W.id)},highlightedArchiveId:te})}):se==="grid"?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:$e?.map(W=>s.jsx(J9e,{archive:W,printerName:W.printer_id?_e.get(W.printer_id)||"Unknown":W.sliced_for_model?`Sliced for ${W.sliced_for_model}`:"No Printer",isSelected:j.has(W.id),onSelect:He,selectionMode:Ve,projects:z,isHighlighted:W.id===te,timeFormat:ee,t},W.id))}):se==="list"?s.jsx(_t,{children:s.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[s.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[s.jsx("div",{className:"col-span-1"}),s.jsx("div",{className:"col-span-4",children:"Name"}),s.jsx("div",{className:"col-span-2",children:"Printer"}),s.jsx("div",{className:"col-span-2",children:"Date"}),s.jsx("div",{className:"col-span-1",children:"Size"}),s.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),$e?.map(W=>s.jsx(eqe,{archive:W,printerName:W.printer_id?_e.get(W.printer_id)||"Unknown":W.sliced_for_model?`Sliced for ${W.sliced_for_model}`:"No Printer",isSelected:j.has(W.id),onSelect:He,selectionMode:Ve,projects:z,isHighlighted:W.id===te,t},W.id))]})}):null,R&&s.jsx(y8e,{onClose:()=>{A(!1),U([])},initialFiles:D}),Q&&s.jsx(Qn,{title:t("archives.modal.deleteArchives"),message:t("archives.modal.deleteArchivesConfirm",{count:j.size}),confirmText:t("archives.modal.deleteCount",{count:j.size}),variant:"danger",onConfirm:()=>{le.mutate(Array.from(j)),Z(!1)},onCancel:()=>Z(!1)}),ae&&s.jsx(_8e,{selectedIds:Array.from(j),existingTags:Fe,onClose:()=>B(!1)}),X&&s.jsx(S8e,{selectedIds:Array.from(j),onClose:()=>ne(!1)}),G&&j.size>=2&&j.size<=5&&s.jsx(q9e,{archiveIds:Array.from(j),onClose:()=>{Y(!1),$(new Set),V(!1)}}),ce&&s.jsx(Z9e,{onClose:()=>q(!1)})]})}function rqe(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return _.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const IM=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 nF(t){return"nodeType"in t}function qs(t){var e,n;return t?Lx(t)?t:nF(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function rF(t){const{Document:e}=qs(t);return t instanceof e}function vv(t){return Lx(t)?!1:t instanceof qs(t).HTMLElement}function sre(t){return t instanceof qs(t).SVGElement}function Fx(t){return t?Lx(t)?t.document:nF(t)?rF(t)?t:vv(t)||sre(t)?t.ownerDocument:document:document:document}const Sc=IM?_.useLayoutEffect:_.useEffect;function iF(t){const e=_.useRef(t);return Sc(()=>{e.current=t}),_.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 iqe(){const t=_.useRef(null),e=_.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=_.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function jy(t,e){e===void 0&&(e=[t]);const n=_.useRef(t);return Sc(()=>{n.current!==t&&(n.current=t)},e),n}function wv(t,e){const n=_.useRef();return _.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function YN(t){const e=iF(t),n=_.useRef(null),r=_.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function aR(t){const e=_.useRef();return _.useEffect(()=>{e.current=t},[t]),e.current}let Ij={};function _v(t,e){return _.useMemo(()=>{if(e)return e;const n=Ij[t]==null?0:Ij[t]+1;return Ij[t]=n,t+"-"+n},[t,e])}function ore(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((a,o)=>{const l=Object.entries(o);for(const[c,u]of l){const d=a[c];d!=null&&(a[c]=d+t*u)}return a},{...e})}}const Lg=ore(1),Py=ore(-1);function aqe(t){return"clientX"in t&&"clientY"in t}function aF(t){if(!t)return!1;const{KeyboardEvent:e}=qs(t.target);return e&&t instanceof e}function sqe(t){if(!t)return!1;const{TouchEvent:e}=qs(t.target);return e&&t instanceof e}function sR(t){if(sqe(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 aqe(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}}}),J9="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function oqe(t){return t.matches(J9)?t:t.querySelector(J9)}const lqe={display:"none"};function cqe(t){let{id:e,value:n}=t;return Jr.createElement("div",{id:e,style:lqe},n)}function uqe(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 Jr.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function dqe(){const[t,e]=_.useState("");return{announce:_.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const lre=_.createContext(null);function hqe(t){const e=_.useContext(lre);_.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function fqe(){const[t]=_.useState(()=>new Set),e=_.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[_.useCallback(r=>{let{type:i,event:a}=r;t.forEach(o=>{var l;return(l=o[i])==null?void 0:l.call(o,a)})},[t]),e]}const mqe={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. `},pqe={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 gqe(t){let{announcements:e=pqe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=mqe}=t;const{announce:a,announcement:o}=dqe(),l=_v("DndLiveRegion"),[c,u]=_.useState(!1);if(_.useEffect(()=>{u(!0)},[]),hqe(_.useMemo(()=>({onDragStart(f){let{active:p}=f;a(e.onDragStart({active:p}))},onDragMove(f){let{active:p,over:m}=f;e.onDragMove&&a(e.onDragMove({active:p,over:m}))},onDragOver(f){let{active:p,over:m}=f;a(e.onDragOver({active:p,over:m}))},onDragEnd(f){let{active:p,over:m}=f;a(e.onDragEnd({active:p,over:m}))},onDragCancel(f){let{active:p,over:m}=f;a(e.onDragCancel({active:p,over:m}))}}),[a,e])),!c)return null;const d=Jr.createElement(Jr.Fragment,null,Jr.createElement(cqe,{id:r,value:i.draggable}),Jr.createElement(uqe,{id:l,announcement:o}));return n?gu.createPortal(d,n):d}var Xi;(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"})(Xi||(Xi={}));function QN(){}function ZN(t,e){return _.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function cre(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return _.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const zl=Object.freeze({x:0,y:0});function ure(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function dre(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function xqe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function eq(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 hre(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function tq(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 fre=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=tq(e,e.left,e.top),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=ure(tq(c),i);a.push({id:l,data:{droppableContainer:o,value:u}})}}return a.sort(dre)},bqe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=eq(e),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=eq(c),d=i.reduce((p,m,x)=>p+ure(u[x],m),0),f=Number((d/4).toFixed(4));a.push({id:l,data:{droppableContainer:o,value:f}})}}return a.sort(dre)};function yqe(t,e){const n=Math.max(e.top,t.top),r=Math.max(e.left,t.left),i=Math.min(e.left+e.width,t.left+t.width),a=Math.min(e.top+e.height,t.top+t.height),o=i-r,l=a-n;if(r<i&&n<a){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 vqe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=[];for(const a of r){const{id:o}=a,l=n.get(o);if(l){const c=yqe(l,e);c>0&&i.push({id:o,data:{droppableContainer:a,value:c}})}}return i.sort(xqe)};function wqe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function mre(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:zl}function _qe(t){return function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];return i.reduce((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 Sqe=_qe(1);function Nqe(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 Mqe(t,e,n){const r=Nqe(e);if(!r)return t;const{scaleX:i,scaleY:a,x:o,y:l}=r,c=t.left-o-(1-i)*parseFloat(n),u=t.top-l-(1-a)*parseFloat(n.slice(n.indexOf(" ")+1)),d=i?t.width/i:t.width,f=a?t.height/a:t.height;return{width:d,height:f,top:u,right:c+d,bottom:u+f,left:c}}const Eqe={ignoreTransform:!1};function Ix(t,e){e===void 0&&(e=Eqe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=qs(t).getComputedStyle(t);u&&(n=Mqe(n,u,d))}const{top:r,left:i,width:a,height:o,bottom:l,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:l,right:c}}function nq(t){return Ix(t,{ignoreTransform:!0})}function kqe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function Tqe(t,e){return e===void 0&&(e=qs(t).getComputedStyle(t)),e.position==="fixed"}function Aqe(t,e){e===void 0&&(e=qs(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const a=e[i];return typeof a=="string"?n.test(a):!1})}function UM(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(rF(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!vv(i)||sre(i)||n.includes(i))return n;const a=qs(t).getComputedStyle(i);return i!==t&&Aqe(i,a)&&n.push(i),Tqe(i,a)?n:r(i.parentNode)}return t?r(t):n}function pre(t){const[e]=UM(t,1);return e??null}function Uj(t){return!IM||!t?null:Lx(t)?t:nF(t)?rF(t)||t===Fx(t).scrollingElement?window:vv(t)?t:null:null}function gre(t){return Lx(t)?t.scrollX:t.scrollLeft}function xre(t){return Lx(t)?t.scrollY:t.scrollTop}function oR(t){return{x:gre(t),y:xre(t)}}var ga;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(ga||(ga={}));function bre(t){return!IM||!t?!1:t===document.scrollingElement}function yre(t){const e={x:0,y:0},n=bre(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},i=t.scrollTop<=e.y,a=t.scrollLeft<=e.x,o=t.scrollTop>=r.y,l=t.scrollLeft>=r.x;return{isTop:i,isLeft:a,isBottom:o,isRight:l,maxScroll:r,minScroll:e}}const Cqe={x:.2,y:.2};function jqe(t,e,n,r,i){let{top:a,left:o,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=Cqe);const{isTop:u,isBottom:d,isLeft:f,isRight:p}=yre(t),m={x:0,y:0},x={x:0,y:0},b={height:e.height*i.y,width:e.width*i.x};return!u&&a<=e.top+b.height?(m.y=ga.Backward,x.y=r*Math.abs((e.top+b.height-a)/b.height)):!d&&c>=e.bottom-b.height&&(m.y=ga.Forward,x.y=r*Math.abs((e.bottom-b.height-c)/b.height)),!p&&l>=e.right-b.width?(m.x=ga.Forward,x.x=r*Math.abs((e.right-b.width-l)/b.width)):!f&&o<=e.left+b.width&&(m.x=ga.Backward,x.x=r*Math.abs((e.left+b.width-o)/b.width)),{direction:m,speed:x}}function Pqe(t){if(t===document.scrollingElement){const{innerWidth:a,innerHeight:o}=window;return{top:0,left:0,right:a,bottom:o,width:a,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 vre(t){return t.reduce((e,n)=>Lg(e,oR(n)),zl)}function Dqe(t){return t.reduce((e,n)=>e+gre(n),0)}function Rqe(t){return t.reduce((e,n)=>e+xre(n),0)}function Oqe(t,e){if(e===void 0&&(e=Ix),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);pre(t)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const Lqe=[["x",["left","right"],Dqe],["y",["top","bottom"],Rqe]];class sF{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=UM(n),i=vre(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,o,l]of Lqe)for(const c of o)Object.defineProperty(this,c,{get:()=>{const u=l(r),d=i[a]-u;return this.rect[c]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class F0{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 Fqe(t){const{EventTarget:e}=qs(t);return t instanceof e?t:Fx(t)}function zj(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 qo;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(qo||(qo={}));function rq(t){t.preventDefault()}function Iqe(t){t.stopPropagation()}var Yn;(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"})(Yn||(Yn={}));const wre={start:[Yn.Space,Yn.Enter],cancel:[Yn.Esc],end:[Yn.Space,Yn.Enter,Yn.Tab]},Uqe=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case Yn.Right:return{...n,x:n.x+25};case Yn.Left:return{...n,x:n.x-25};case Yn.Down:return{...n,y:n.y+25};case Yn.Up:return{...n,y:n.y-25}}};class zM{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 F0(Fx(n)),this.windowListeners=new F0(qs(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(qo.Resize,this.handleCancel),this.windowListeners.add(qo.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(qo.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&Oqe(r),n(zl)}handleKeyDown(e){if(aF(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=wre,coordinateGetter:o=Uqe,scrollBehavior:l="smooth"}=i,{code:c}=e;if(a.end.includes(c)){this.handleEnd(e);return}if(a.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:u}=r.current,d=u?{x:u.left,y:u.top}:zl;this.referenceCoordinates||(this.referenceCoordinates=d);const f=o(e,{active:n,context:r.current,currentCoordinates:d});if(f){const p=Py(f,d),m={x:0,y:0},{scrollableAncestors:x}=r.current;for(const b of x){const y=e.code,{isTop:v,isRight:S,isLeft:M,isBottom:T,maxScroll:E,minScroll:C}=yre(b),k=Pqe(b),R={x:Math.min(y===Yn.Right?k.right-k.width/2:k.right,Math.max(y===Yn.Right?k.left:k.left+k.width/2,f.x)),y:Math.min(y===Yn.Down?k.bottom-k.height/2:k.bottom,Math.max(y===Yn.Down?k.top:k.top+k.height/2,f.y))},A=y===Yn.Right&&!S||y===Yn.Left&&!M,D=y===Yn.Down&&!T||y===Yn.Up&&!v;if(A&&R.x!==f.x){const U=b.scrollLeft+p.x,F=y===Yn.Right&&U<=E.x||y===Yn.Left&&U>=C.x;if(F&&!p.y){b.scrollTo({left:U,behavior:l});return}F?m.x=b.scrollLeft-U:m.x=y===Yn.Right?b.scrollLeft-E.x:b.scrollLeft-C.x,m.x&&b.scrollBy({left:-m.x,behavior:l});break}else if(D&&R.y!==f.y){const U=b.scrollTop+p.y,F=y===Yn.Down&&U<=E.y||y===Yn.Up&&U>=C.y;if(F&&!p.x){b.scrollTo({top:U,behavior:l});return}F?m.y=b.scrollTop-U:m.y=y===Yn.Down?b.scrollTop-E.y:b.scrollTop-C.y,m.y&&b.scrollBy({top:-m.y,behavior:l});break}}this.handleMove(e,Lg(Py(f,this.referenceCoordinates),m))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}zM.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=wre,onActivation:i}=e,{active:a}=n;const{code:o}=t.nativeEvent;if(r.start.includes(o)){const l=a.activatorNode.current;return l&&t.target!==l?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function iq(t){return!!(t&&"distance"in t)}function aq(t){return!!(t&&"delay"in t)}class oF{constructor(e,n,r){var i;r===void 0&&(r=Fqe(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:a}=e,{target:o}=a;this.props=e,this.events=n,this.document=Fx(o),this.documentListeners=new F0(this.document),this.listeners=new F0(r),this.windowListeners=new F0(qs(o)),this.initialCoordinates=(i=sR(a))!=null?i:zl,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(qo.Resize,this.handleCancel),this.windowListeners.add(qo.DragStart,rq),this.windowListeners.add(qo.VisibilityChange,this.handleCancel),this.windowListeners.add(qo.ContextMenu,rq),this.documentListeners.add(qo.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(aq(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(iq(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(qo.Click,Iqe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(qo.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:a}=this,{onMove:o,options:{activationConstraint:l}}=a;if(!i)return;const c=(n=sR(e))!=null?n:zl,u=Py(i,c);if(!r&&l){if(iq(l)){if(l.tolerance!=null&&zj(u,l.tolerance))return this.handleCancel();if(zj(u,l.distance))return this.handleStart()}if(aq(l)&&zj(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===Yn.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 BM extends oF{constructor(e){const{event:n}=e,r=Fx(n.target);super(e,zqe,r)}}BM.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 Bqe={move:{name:"mousemove"},end:{name:"mouseup"}};var lR;(function(t){t[t.RightClick=2]="RightClick"})(lR||(lR={}));class $qe extends oF{constructor(e){super(e,Bqe,Fx(e.event.target))}}$qe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===lR.RightClick?!1:(r?.({event:n}),!0)}}];const Bj={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Hqe extends oF{constructor(e){super(e,Bj)}static setup(){return window.addEventListener(Bj.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Bj.move.name,e)};function e(){}}}Hqe.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 I0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(I0||(I0={}));var JN;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(JN||(JN={}));function Vqe(t){let{acceleration:e,activator:n=I0.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:l=JN.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:p}=t;const m=qqe({delta:f,disabled:!a}),[x,b]=iqe(),y=_.useRef({x:0,y:0}),v=_.useRef({x:0,y:0}),S=_.useMemo(()=>{switch(n){case I0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case I0.DraggableRect:return i}},[n,i,c]),M=_.useRef(null),T=_.useCallback(()=>{const C=M.current;if(!C)return;const k=y.current.x*v.current.x,R=y.current.y*v.current.y;C.scrollBy(k,R)},[]),E=_.useMemo(()=>l===JN.TreeOrder?[...u].reverse():u,[l,u]);_.useEffect(()=>{if(!a||!u.length||!S){b();return}for(const C of E){if(r?.(C)===!1)continue;const k=u.indexOf(C),R=d[k];if(!R)continue;const{direction:A,speed:D}=jqe(C,R,S,e,p);for(const U of["x","y"])m[U][A[U]]||(D[U]=0,A[U]=0);if(D.x>0||D.y>0){b(),M.current=C,x(T,o),y.current=D,v.current=A;return}}y.current={x:0,y:0},v.current={x:0,y:0},b()},[e,T,r,b,a,o,JSON.stringify(S),JSON.stringify(m),x,u,E,d,JSON.stringify(p)])}const Gqe={x:{[ga.Backward]:!1,[ga.Forward]:!1},y:{[ga.Backward]:!1,[ga.Forward]:!1}};function qqe(t){let{delta:e,disabled:n}=t;const r=aR(e);return wv(i=>{if(n||!r||!i)return Gqe;const a={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[ga.Backward]:i.x[ga.Backward]||a.x===-1,[ga.Forward]:i.x[ga.Forward]||a.x===1},y:{[ga.Backward]:i.y[ga.Backward]||a.y===-1,[ga.Forward]:i.y[ga.Forward]||a.y===1}}},[n,e,r])}function Wqe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return wv(i=>{var a;return e==null?null:(a=r??i)!=null?a:null},[r,e])}function Kqe(t,e){return _.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,a=i.activators.map(o=>({eventName:o.eventName,handler:e(o.handler,r)}));return[...n,...a]},[]),[t,e])}var Dy;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(Dy||(Dy={}));var cR;(function(t){t.Optimized="optimized"})(cR||(cR={}));const sq=new Map;function Xqe(t,e){let{dragging:n,dependencies:r,config:i}=e;const[a,o]=_.useState(null),{frequency:l,measure:c,strategy:u}=i,d=_.useRef(t),f=y(),p=jy(f),m=_.useCallback(function(v){v===void 0&&(v=[]),!p.current&&o(S=>S===null?v:S.concat(v.filter(M=>!S.includes(M))))},[p]),x=_.useRef(null),b=wv(v=>{if(f&&!n)return sq;if(!v||v===sq||d.current!==t||a!=null){const S=new Map;for(let M of t){if(!M)continue;if(a&&a.length>0&&!a.includes(M.id)&&M.rect.current){S.set(M.id,M.rect.current);continue}const T=M.node.current,E=T?new sF(c(T),T):null;M.rect.current=E,E&&S.set(M.id,E)}return S}return v},[t,a,n,f,c]);return _.useEffect(()=>{d.current=t},[t]),_.useEffect(()=>{f||m()},[n,f]),_.useEffect(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),_.useEffect(()=>{f||typeof l!="number"||x.current!==null||(x.current=setTimeout(()=>{m(),x.current=null},l))},[l,f,m,...r]),{droppableRects:b,measureDroppableContainers:m,measuringScheduled:a!=null};function y(){switch(u){case Dy.Always:return!1;case Dy.BeforeDragging:return n;default:return!n}}}function _re(t,e){return wv(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function Yqe(t,e){return _re(t,e)}function Qqe(t){let{callback:e,disabled:n}=t;const r=iF(e),i=_.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(r)},[r,n]);return _.useEffect(()=>()=>i?.disconnect(),[i]),i}function $M(t){let{callback:e,disabled:n}=t;const r=iF(e),i=_.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(r)},[n]);return _.useEffect(()=>()=>i?.disconnect(),[i]),i}function Zqe(t){return new sF(Ix(t),t)}function oq(t,e,n){e===void 0&&(e=Zqe);const[r,i]=_.useState(null);function a(){i(c=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=c??n)!=null?u:null}const d=e(t);return JSON.stringify(c)===JSON.stringify(d)?c:d})}const o=Qqe({callback(c){if(t)for(const u of c){const{type:d,target:f}=u;if(d==="childList"&&f instanceof HTMLElement&&f.contains(t)){a();break}}}}),l=$M({callback:a});return Sc(()=>{a(),t?(l?.observe(t),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[t]),r}function Jqe(t){const e=_re(t);return mre(t,e)}const lq=[];function eWe(t){const e=_.useRef(t),n=wv(r=>t?r&&r!==lq&&t&&e.current&&t.parentNode===e.current.parentNode?r:UM(t):lq,[t]);return _.useEffect(()=>{e.current=t},[t]),n}function tWe(t){const[e,n]=_.useState(null),r=_.useRef(t),i=_.useCallback(a=>{const o=Uj(a.target);o&&n(l=>l?(l.set(o,oR(o)),new Map(l)):null)},[]);return _.useEffect(()=>{const a=r.current;if(t!==a){o(a);const l=t.map(c=>{const u=Uj(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,oR(u)]):null}).filter(c=>c!=null);n(l.length?new Map(l):null),r.current=t}return()=>{o(t),o(a)};function o(l){l.forEach(c=>{const u=Uj(c);u?.removeEventListener("scroll",i)})}},[i,t]),_.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,o)=>Lg(a,o),zl):vre(t):zl,[t,e])}function cq(t,e){e===void 0&&(e=[]);const n=_.useRef(null);return _.useEffect(()=>{n.current=null},e),_.useEffect(()=>{const r=t!==zl;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?Py(t,n.current):zl}function nWe(t){_.useEffect(()=>{if(!IM)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 rWe(t,e){return _.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:a}=r;return n[i]=o=>{a(o,e)},n},{}),[t,e])}function Sre(t){return _.useMemo(()=>t?kqe(t):null,[t])}const uq=[];function iWe(t,e){e===void 0&&(e=Ix);const[n]=t,r=Sre(n?qs(n):null),[i,a]=_.useState(uq);function o(){a(()=>t.length?t.map(c=>bre(c)?r:new sF(e(c),c)):uq)}const l=$M({callback:o});return Sc(()=>{l?.disconnect(),o(),t.forEach(c=>l?.observe(c))},[t]),i}function aWe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return vv(e)?e:t}function sWe(t){let{measure:e}=t;const[n,r]=_.useState(null),i=_.useCallback(u=>{for(const{target:d}of u)if(vv(d)){r(f=>{const p=e(d);return f?{...f,width:p.width,height:p.height}:p});break}},[e]),a=$M({callback:i}),o=_.useCallback(u=>{const d=aWe(u);a?.disconnect(),d&&a?.observe(d),r(d?e(d):null)},[e,a]),[l,c]=YN(o);return _.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const oWe=[{sensor:BM,options:{}},{sensor:zM,options:{}}],lWe={current:{}},I1={draggable:{measure:nq},droppable:{measure:nq,strategy:Dy.WhileDragging,frequency:cR.Optimized},dragOverlay:{measure:Ix}};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 cWe={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:QN},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:I1,measureDroppableContainers:QN,windowRect:null,measuringScheduled:!1},uWe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:QN,draggableNodes:new Map,over:null,measureDroppableContainers:QN},HM=_.createContext(uWe),Nre=_.createContext(cWe);function dWe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new U0}}}function hWe(t,e){switch(e.type){case Xi.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case Xi.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 Xi.DragEnd:case Xi.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Xi.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 Xi.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,a=t.droppable.containers.get(n);if(!a||r!==a.key)return t;const o=new U0(t.droppable.containers);return o.set(n,{...a,disabled:i}),{...t,droppable:{...t.droppable,containers:o}}}case Xi.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const a=new U0(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function fWe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=_.useContext(HM),a=aR(r),o=aR(n?.id);return _.useEffect(()=>{if(!e&&!r&&a&&o!=null){if(!aF(a)||document.activeElement===a.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=oqe(d);if(f){f.focus();break}}})}},[r,e,i,o,a]),null}function mWe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,a)=>a({transform:i,...r}),n):n}function pWe(t){return _.useMemo(()=>({draggable:{...I1.draggable,...t?.draggable},droppable:{...I1.droppable,...t?.droppable},dragOverlay:{...I1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function gWe(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const a=_.useRef(!1),{x:o,y:l}=typeof i=="boolean"?{x:i,y:i}:i;Sc(()=>{if(!o&&!l||!e){a.current=!1;return}if(a.current||!r)return;const u=e?.node.current;if(!u||u.isConnected===!1)return;const d=n(u),f=mre(d,r);if(o||(f.x=0),l||(f.y=0),a.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const p=pre(u);p&&p.scrollBy({top:f.y,left:f.x})}},[e,o,l,r,n])}const Mre=_.createContext({...zl,scaleX:1,scaleY:1});var qd;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(qd||(qd={}));const Ere=_.memo(function(e){var n,r,i,a;let{id:o,accessibility:l,autoScroll:c=!0,children:u,sensors:d=oWe,collisionDetection:f=vqe,measuring:p,modifiers:m,...x}=e;const b=_.useReducer(hWe,void 0,dWe),[y,v]=b,[S,M]=fqe(),[T,E]=_.useState(qd.Uninitialized),C=T===qd.Initialized,{draggable:{active:k,nodes:R,translate:A},droppable:{containers:D}}=y,U=k!=null?R.get(k):null,F=_.useRef({initial:null,translated:null}),H=_.useMemo(()=>{var We;return k!=null?{id:k,data:(We=U?.data)!=null?We:lWe,rect:F}:null},[k,U]),j=_.useRef(null),[$,K]=_.useState(null),[V,Q]=_.useState(null),Z=jy(x,Object.values(x)),ae=_v("DndDescribedBy",o),B=_.useMemo(()=>D.getEnabled(),[D]),X=pWe(p),{droppableRects:ne,measureDroppableContainers:se,measuringScheduled:be}=Xqe(B,{dragging:C,dependencies:[A.x,A.y],config:X.droppable}),xe=Wqe(R,k),de=_.useMemo(()=>V?sR(V):null,[V]),Pe=Ee(),ie=Yqe(xe,X.draggable.measure);gWe({activeNode:k!=null?R.get(k):null,config:Pe.layoutShiftCompensation,initialRect:ie,measure:X.draggable.measure});const Me=oq(xe,X.draggable.measure,ie),Oe=oq(xe?xe.parentElement:null),ge=_.useRef({activatorEvent:null,active:null,activeNode:xe,collisionRect:null,collisions:null,droppableRects:ne,draggableNodes:R,draggingNode:null,draggingNodeRect:null,droppableContainers:D,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Ke=D.getNodeFor((n=ge.current.over)==null?void 0:n.id),G=sWe({measure:X.dragOverlay.measure}),Y=(r=G.nodeRef.current)!=null?r:xe,ce=C?(i=G.rect)!=null?i:Me:null,q=!!(G.nodeRef.current&&G.rect),te=Jqe(q?null:Me),I=Sre(Y?qs(Y):null),fe=eWe(C?Ke??xe:null),me=iWe(fe),ke=mWe(m,{transform:{x:A.x-te.x,y:A.y-te.y,scaleX:1,scaleY:1},activatorEvent:V,active:H,activeNodeRect:Me,containerNodeRect:Oe,draggingNodeRect:ce,over:ge.current.over,overlayNodeRect:G.rect,scrollableAncestors:fe,scrollableAncestorRects:me,windowRect:I}),z=de?Lg(de,A):null,O=tWe(fe),ee=cq(O),le=cq(O,[Me]),_e=Lg(ke,ee),we=ce?Sqe(ce,ke):null,re=H&&we?f({active:H,collisionRect:we,droppableRects:ne,droppableContainers:B,pointerCoordinates:z}):null,Fe=hre(re,"id"),[$e,Ve]=_.useState(null),He=q?ke:Lg(ke,le),ye=wqe(He,(a=$e?.rect)!=null?a:null,Me),je=_.useRef(null),Be=_.useCallback((We,ze)=>{let{sensor:W,options:De}=ze;if(j.current==null)return;const Ye=R.get(j.current);if(!Ye)return;const xt=We.nativeEvent,ft=new W({active:j.current,activeNode:Ye,event:xt,options:De,context:ge,onAbort(Lt){if(!R.get(Lt))return;const{onDragAbort:Jt}=Z.current,rr={id:Lt};Jt?.(rr),S({type:"onDragAbort",event:rr})},onPending(Lt,vn,Jt,rr){if(!R.get(Lt))return;const{onDragPending:Dn}=Z.current,ln={id:Lt,constraint:vn,initialCoordinates:Jt,offset:rr};Dn?.(ln),S({type:"onDragPending",event:ln})},onStart(Lt){const vn=j.current;if(vn==null)return;const Jt=R.get(vn);if(!Jt)return;const{onDragStart:rr}=Z.current,hr={activatorEvent:xt,active:{id:vn,data:Jt.data,rect:F}};gu.unstable_batchedUpdates(()=>{rr?.(hr),E(qd.Initializing),v({type:Xi.DragStart,initialCoordinates:Lt,active:vn}),S({type:"onDragStart",event:hr}),K(je.current),Q(xt)})},onMove(Lt){v({type:Xi.DragMove,coordinates:Lt})},onEnd:Bt(Xi.DragEnd),onCancel:Bt(Xi.DragCancel)});je.current=ft;function Bt(Lt){return async function(){const{active:Jt,collisions:rr,over:hr,scrollAdjustedTranslate:Dn}=ge.current;let ln=null;if(Jt&&Dn){const{cancelDrop:fr}=Z.current;ln={activatorEvent:xt,active:Jt,collisions:rr,delta:Dn,over:hr},Lt===Xi.DragEnd&&typeof fr=="function"&&await Promise.resolve(fr(ln))&&(Lt=Xi.DragCancel)}j.current=null,gu.unstable_batchedUpdates(()=>{v({type:Lt}),E(qd.Uninitialized),Ve(null),K(null),Q(null),je.current=null;const fr=Lt===Xi.DragEnd?"onDragEnd":"onDragCancel";if(ln){const Fn=Z.current[fr];Fn?.(ln),S({type:fr,event:ln})}})}}},[R]),Se=_.useCallback((We,ze)=>(W,De)=>{const Ye=W.nativeEvent,xt=R.get(De);if(j.current!==null||!xt||Ye.dndKit||Ye.defaultPrevented)return;const ft={active:xt};We(W,ze.options,ft)===!0&&(Ye.dndKit={capturedBy:ze.sensor},j.current=De,Be(W,ze))},[R,Be]),Xe=Kqe(d,Se);nWe(d),Sc(()=>{Me&&T===qd.Initializing&&E(qd.Initialized)},[Me,T]),_.useEffect(()=>{const{onDragMove:We}=Z.current,{active:ze,activatorEvent:W,collisions:De,over:Ye}=ge.current;if(!ze||!W)return;const xt={active:ze,activatorEvent:W,collisions:De,delta:{x:_e.x,y:_e.y},over:Ye};gu.unstable_batchedUpdates(()=>{We?.(xt),S({type:"onDragMove",event:xt})})},[_e.x,_e.y]),_.useEffect(()=>{const{active:We,activatorEvent:ze,collisions:W,droppableContainers:De,scrollAdjustedTranslate:Ye}=ge.current;if(!We||j.current==null||!ze||!Ye)return;const{onDragOver:xt}=Z.current,ft=De.get(Fe),Bt=ft&&ft.rect.current?{id:ft.id,rect:ft.rect.current,data:ft.data,disabled:ft.disabled}:null,Lt={active:We,activatorEvent:ze,collisions:W,delta:{x:Ye.x,y:Ye.y},over:Bt};gu.unstable_batchedUpdates(()=>{Ve(Bt),xt?.(Lt),S({type:"onDragOver",event:Lt})})},[Fe]),Sc(()=>{ge.current={activatorEvent:V,active:H,activeNode:xe,collisionRect:we,collisions:re,droppableRects:ne,draggableNodes:R,draggingNode:Y,draggingNodeRect:ce,droppableContainers:D,over:$e,scrollableAncestors:fe,scrollAdjustedTranslate:_e},F.current={initial:ce,translated:we}},[H,xe,re,we,R,Y,ce,ne,D,$e,fe,_e]),Vqe({...Pe,delta:A,draggingRect:we,pointerCoordinates:z,scrollableAncestors:fe,scrollableAncestorRects:me});const Ne=_.useMemo(()=>({active:H,activeNode:xe,activeNodeRect:Me,activatorEvent:V,collisions:re,containerNodeRect:Oe,dragOverlay:G,draggableNodes:R,droppableContainers:D,droppableRects:ne,over:$e,measureDroppableContainers:se,scrollableAncestors:fe,scrollableAncestorRects:me,measuringConfiguration:X,measuringScheduled:be,windowRect:I}),[H,xe,Me,V,re,Oe,G,R,D,ne,$e,se,fe,me,X,be,I]),tt=_.useMemo(()=>({activatorEvent:V,activators:Xe,active:H,activeNodeRect:Me,ariaDescribedById:{draggable:ae},dispatch:v,draggableNodes:R,over:$e,measureDroppableContainers:se}),[V,Xe,H,Me,v,ae,R,$e,se]);return Jr.createElement(lre.Provider,{value:M},Jr.createElement(HM.Provider,{value:tt},Jr.createElement(Nre.Provider,{value:Ne},Jr.createElement(Mre.Provider,{value:ye},u)),Jr.createElement(fWe,{disabled:l?.restoreFocus===!1})),Jr.createElement(gqe,{...l,hiddenTextDescribedById:ae}));function Ee(){const We=$?.autoScrollEnabled===!1,ze=typeof c=="object"?c.enabled===!1:c===!1,W=C&&!We&&!ze;return typeof c=="object"?{...c,enabled:W}:{enabled:W}}}),xWe=_.createContext(null),dq="button",bWe="Draggable";function yWe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=_v(bWe),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:p}=_.useContext(HM),{role:m=dq,roleDescription:x="draggable",tabIndex:b=0}=i??{},y=c?.id===e,v=_.useContext(y?Mre:xWe),[S,M]=YN(),[T,E]=YN(),C=rWe(o,e),k=jy(n);Sc(()=>(f.set(e,{id:e,key:a,node:S,activatorNode:T,data:k}),()=>{const A=f.get(e);A&&A.key===a&&f.delete(e)}),[f,e]);const R=_.useMemo(()=>({role:m,tabIndex:b,"aria-disabled":r,"aria-pressed":y&&m===dq?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,m,b,y,x,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:R,isDragging:y,listeners:r?void 0:C,node:S,over:p,setNodeRef:M,setActivatorNodeRef:E,transform:v}}function vWe(){return _.useContext(Nre)}const wWe="Droppable",_We={timeout:25};function SWe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=_v(wWe),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=_.useContext(HM),d=_.useRef({disabled:n}),f=_.useRef(!1),p=_.useRef(null),m=_.useRef(null),{disabled:x,updateMeasurementsFor:b,timeout:y}={..._We,...i},v=jy(b??r),S=_.useCallback(()=>{if(!f.current){f.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{u(Array.isArray(v.current)?v.current:[v.current]),m.current=null},y)},[y]),M=$M({callback:S,disabled:x||!o}),T=_.useCallback((R,A)=>{M&&(A&&(M.unobserve(A),f.current=!1),R&&M.observe(R))},[M]),[E,C]=YN(T),k=jy(e);return _.useEffect(()=>{!M||!E.current||(M.disconnect(),f.current=!1,M.observe(E.current))},[E,M]),_.useEffect(()=>(l({type:Xi.RegisterDroppable,element:{id:r,key:a,disabled:n,node:E,rect:p,data:k}}),()=>l({type:Xi.UnregisterDroppable,key:a,id:r})),[r]),_.useEffect(()=>{n!==d.current.disabled&&(l({type:Xi.SetDroppableDisabled,id:r,key:a,disabled:n}),d.current.disabled=n)},[r,a,n,l]),{active:o,rect:p,isOver:c?.id===r,node:E,over:c,setNodeRef:C}}function VM(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function NWe(t,e){return t.reduce((n,r,i)=>{const a=e.get(r);return a&&(n[i]=a),n},Array(t.length))}function c1(t){return t!==null&&t>=0}function MWe(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 EWe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const lF=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const a=VM(e,r,n),o=e[i],l=a[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}},u1={scaleX:1,scaleY:1},kWe=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:i,rects:a,overIndex:o}=t;const l=(e=a[n])!=null?e:r;if(!l)return null;if(i===n){const u=a[o];return u?{x:0,y:n<o?u.top+u.height-(l.top+l.height):u.top-l.top,...u1}:null}const c=TWe(a,i,n);return i>n&&i<=o?{x:0,y:-l.height-c,...u1}:i<n&&i>=o?{x:0,y:l.height+c,...u1}:{x:0,y:0,...u1}};function TWe(t,e,n){const r=t[e],i=t[e-1],a=t[e+1];return r?n<e?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}const kre="Sortable",Tre=Jr.createContext({activeIndex:-1,containerId:kre,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:lF,disabled:{draggable:!1,droppable:!1}});function Are(t){let{children:e,id:n,items:r,strategy:i=lF,disabled:a=!1}=t;const{active:o,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:d}=vWe(),f=_v(kre,n),p=l.rect!==null,m=_.useMemo(()=>r.map(C=>typeof C=="object"&&"id"in C?C.id:C),[r]),x=o!=null,b=o?m.indexOf(o.id):-1,y=u?m.indexOf(u.id):-1,v=_.useRef(m),S=!MWe(m,v.current),M=y!==-1&&b===-1||S,T=EWe(a);Sc(()=>{S&&x&&d(m)},[S,m,x,d]),_.useEffect(()=>{v.current=m},[m]);const E=_.useMemo(()=>({activeIndex:b,containerId:f,disabled:T,disableTransforms:M,items:m,overIndex:y,useDragOverlay:p,sortedRects:NWe(m,c),strategy:i}),[b,f,T.draggable,T.droppable,M,m,y,c,p,i]);return Jr.createElement(Tre.Provider,{value:E},e)}const AWe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return VM(n,r,i).indexOf(e)},CWe=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:l,previousContainerId:c,transition:u}=t;return!u||!r||l!==a&&i===o?!1:n?!0:o!==i&&e===c},jWe={duration:200,easing:"ease"},Cre="transform",PWe=mx.Transition.toString({property:Cre,duration:0,easing:"linear"}),DWe={roleDescription:"sortable"};function RWe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[a,o]=_.useState(null),l=_.useRef(n);return Sc(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const u=Ix(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]),_.useEffect(()=>{a&&o(null)},[a]),a}function jre(t){let{animateLayoutChanges:e=CWe,attributes:n,disabled:r,data:i,getNewIndex:a=AWe,id:o,strategy:l,resizeObserverConfig:c,transition:u=jWe}=t;const{items:d,containerId:f,activeIndex:p,disabled:m,disableTransforms:x,sortedRects:b,overIndex:y,useDragOverlay:v,strategy:S}=_.useContext(Tre),M=OWe(r,m),T=d.indexOf(o),E=_.useMemo(()=>({sortable:{containerId:f,index:T,items:d},...i}),[f,i,T,d]),C=_.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:k,node:R,isOver:A,setNodeRef:D}=SWe({id:o,data:E,disabled:M.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...c}}),{active:U,activatorEvent:F,activeNodeRect:H,attributes:j,setNodeRef:$,listeners:K,isDragging:V,over:Q,setActivatorNodeRef:Z,transform:ae}=yWe({id:o,data:E,attributes:{...DWe,...n},disabled:M.draggable}),B=rqe(D,$),X=!!U,ne=X&&!x&&c1(p)&&c1(y),se=!v&&V,be=se&&ne?ae:null,de=ne?be??(l??S)({rects:b,activeNodeRect:H,activeIndex:p,overIndex:y,index:T}):null,Pe=c1(p)&&c1(y)?a({id:o,items:d,activeIndex:p,overIndex:y}):T,ie=U?.id,Me=_.useRef({activeId:ie,items:d,newIndex:Pe,containerId:f}),Oe=d!==Me.current.items,ge=e({active:U,containerId:f,isDragging:V,isSorting:X,id:o,index:T,items:d,newIndex:Me.current.newIndex,previousItems:Me.current.items,previousContainerId:Me.current.containerId,transition:u,wasDragging:Me.current.activeId!=null}),Ke=RWe({disabled:!ge,index:T,node:R,rect:k});return _.useEffect(()=>{X&&Me.current.newIndex!==Pe&&(Me.current.newIndex=Pe),f!==Me.current.containerId&&(Me.current.containerId=f),d!==Me.current.items&&(Me.current.items=d)},[X,Pe,f,d]),_.useEffect(()=>{if(ie===Me.current.activeId)return;if(ie!=null&&Me.current.activeId==null){Me.current.activeId=ie;return}const Y=setTimeout(()=>{Me.current.activeId=ie},50);return()=>clearTimeout(Y)},[ie]),{active:U,activeIndex:p,attributes:j,data:E,rect:k,index:T,newIndex:Pe,items:d,isOver:A,isSorting:X,isDragging:V,listeners:K,node:R,overIndex:y,over:Q,setNodeRef:B,setActivatorNodeRef:Z,setDroppableNodeRef:D,setDraggableNodeRef:$,transform:Ke??de,transition:G()};function G(){if(Ke||Oe&&Me.current.newIndex===T)return PWe;if(!(se&&!aF(F)||!u)&&(X||ge))return mx.Transition.toString({...u,property:Cre})}}function OWe(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 e2(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 LWe=[Yn.Down,Yn.Right,Yn.Up,Yn.Left],Pre=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:l}}=e;if(LWe.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];a.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const p=i.get(f.id);if(p)switch(t.code){case Yn.Down:r.top<p.top&&c.push(f);break;case Yn.Up:r.top>p.top&&c.push(f);break;case Yn.Left:r.left>p.left&&c.push(f);break;case Yn.Right:r.left<p.left&&c.push(f);break}});const u=bqe({collisionRect:r,droppableRects:i,droppableContainers:c});let d=hre(u,"id");if(d===o?.id&&u.length>1&&(d=u[1].id),d!=null){const f=a.get(n.id),p=a.get(d),m=p?i.get(p.id):null,x=p?.node.current;if(x&&m&&f&&p){const y=UM(x).some((C,k)=>l[k]!==C),v=Dre(f,p),S=FWe(f,p),M=y||!v?{x:0,y:0}:{x:S?r.width-m.width:0,y:S?r.height-m.height:0},T={x:m.left,y:m.top};return M.x&&M.y?T:Py(T,M)}}}};function Dre(t,e){return!e2(t)||!e2(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function FWe(t,e){return!e2(t)||!e2(e)||!Dre(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function Rre(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 IWe(t,e="system",n){if(!t)return n?.("queue.time.asap")??"ASAP";const r=Ii(t);if(!r)return n?.("queue.time.asap")??"ASAP";const i=new Date,a=r.getTime()-i.getTime();return a<-6e4?n?.("queue.time.overdue")??"Overdue":a<0?n?.("queue.time.now")??"Now":a<6e4?n?.("queue.time.lessThanMinute")??"In less than a minute":a<36e5?n?.("queue.time.inMinutes",{count:Math.round(a/6e4)})??`In ${Math.round(a/6e4)} min`:a<864e5?n?.("queue.time.inHours",{count:Math.round(a/36e5)})??`In ${Math.round(a/36e5)} hours`:$g(t,e)}function UWe({status:t,waitingReason:e,t:n}){if(t==="pending"&&e)return s.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:[s.jsx(Jn,{className:"w-3.5 h-3.5"}),n("queue.status.waiting")]});const r={pending:{icon:Jn,color:"text-status-warning bg-status-warning/10 border-status-warning/20",label:n("queue.status.pending")},printing:{icon:Is,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:n("queue.status.printing")},completed:{icon:Ar,color:"text-status-ok bg-status-ok/10 border-status-ok/20",label:n("queue.status.completed")},failed:{icon:Yi,color:"text-status-error bg-status-error/10 border-status-error/20",label:n("queue.status.failed")},skipped:{icon:DR,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:n("queue.status.skipped")},cancelled:{icon:Rt,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:n("queue.status.cancelled")}},{icon:i,color:a,label:o}=r[t];return s.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${a}`,children:[s.jsx(i,{className:"w-3.5 h-3.5"}),o]})}function zWe({selectedCount:t,printers:e,onSave:n,onClose:r,isSaving:i,t:a}){const[o,l]=_.useState("unchanged"),[c,u]=_.useState("unchanged"),[d,f]=_.useState("unchanged"),[p,m]=_.useState("unchanged"),[x,b]=_.useState("unchanged"),[y,v]=_.useState("unchanged"),[S,M]=_.useState("unchanged"),[T,E]=_.useState("unchanged"),[C,k]=_.useState("unchanged"),[R,A]=_.useState("unchanged"),D=()=>{const F={};o!=="unchanged"&&(F.printer_id=o),c!=="unchanged"&&(F.manual_start=c),d!=="unchanged"&&(F.auto_off_after=d),p!=="unchanged"&&(F.require_previous_success=p),x!=="unchanged"&&(F.bed_levelling=x),y!=="unchanged"&&(F.flow_cali=y),S!=="unchanged"&&(F.vibration_cali=S),T!=="unchanged"&&(F.layer_inspect=T),C!=="unchanged"&&(F.timelapse=C),R!=="unchanged"&&(F.use_ams=R),n(F)},U=o!=="unchanged"||c!=="unchanged"||d!=="unchanged"||p!=="unchanged"||x!=="unchanged"||y!=="unchanged"||S!=="unchanged"||T!=="unchanged"||C!=="unchanged"||R!=="unchanged";return s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:s.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:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:a("queue.bulkEdit.title",{count:t})}),s.jsx("button",{onClick:r,className:"p-1 hover:bg-bambu-dark rounded",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:a("queue.bulkEdit.description")}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:a("queue.bulkEdit.printer")}),s.jsxs("select",{value:o===null?"null":o==="unchanged"?"unchanged":String(o),onChange:F=>{const H=F.target.value;l(H==="unchanged"?"unchanged":H==="null"?null:Number(H))},className:"w-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:[s.jsx("option",{value:"unchanged",children:a("queue.bulkEdit.noChange")}),s.jsx("option",{value:"null",children:a("queue.filter.unassigned")}),e.map(F=>s.jsx("option",{value:F.id,children:F.name},F.id))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:a("queue.bulkEdit.queueOptions")}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(su,{label:a("queue.bulkEdit.staged"),value:c,onChange:u,t:a}),s.jsx(su,{label:a("queue.bulkEdit.autoPowerOff"),value:d,onChange:f,t:a}),s.jsx(su,{label:a("queue.bulkEdit.requirePrevious"),value:p,onChange:m,t:a})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:a("queue.bulkEdit.printOptions")}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(su,{label:a("queue.bulkEdit.bedLevelling"),value:x,onChange:b,t:a}),s.jsx(su,{label:a("queue.bulkEdit.flowCalibration"),value:y,onChange:v,t:a}),s.jsx(su,{label:a("queue.bulkEdit.vibrationCalibration"),value:S,onChange:M,t:a}),s.jsx(su,{label:a("queue.bulkEdit.layerInspection"),value:T,onChange:E,t:a}),s.jsx(su,{label:a("queue.bulkEdit.timelapse"),value:C,onChange:k,t:a}),s.jsx(su,{label:a("queue.bulkEdit.useAms"),value:R,onChange:A,t:a})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Te,{variant:"secondary",onClick:r,children:a("common.cancel")}),s.jsx(Te,{onClick:D,disabled:!U||i,children:a(i?"common.saving":"queue.bulkEdit.applyChanges")})]})]})})}function su({label:t,value:e,onChange:n,t:r}){return s.jsxs("div",{className:"flex items-center justify-between py-1",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:t}),s.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded-lg p-0.5",children:[s.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:"—"}),s.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:r("common.off")}),s.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:r("common.on")})]})]})}function $j({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:a,onRequeue:o,onStart:l,timeFormat:c="system",isSelected:u=!1,onToggleSelect:d,hasPermission:f,canModify:p,t:m}){const x=f("queue:reorder"),{attributes:b,listeners:y,setNodeRef:v,transform:S,transition:M,isDragging:T}=jre({id:t.id,disabled:t.status!=="pending"||!x}),E={transform:mx.Transform.toString(S),transition:M},C=t.status==="printing",k=t.status==="pending",R=["completed","failed","skipped","cancelled"].includes(t.status);return s.jsx("div",{ref:v,style:E,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. ${T?"opacity-50 scale-[1.02] shadow-xl z-50":""}
  8277. ${C?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
  8278. `,children:s.jsxs("div",{className:"flex items-center gap-4 p-4",children:[k&&d&&s.jsx("button",{onClick:A=>{A.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&&s.jsx(Ia,{className:"w-4 h-4"})}),k?s.jsx("div",{...b,...y,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:s.jsx(zg,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}):e!==void 0?s.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]}):s.jsx("div",{className:"w-8"}),s.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?s.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?s.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"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:s.jsx(sl,{className:"w-6 h-6"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.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?s.jsx(Ds,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:m("queue.viewArchive"),children:s.jsx(Kr,{className:"w-3.5 h-3.5"})}):t.library_file_id?s.jsx(Ds,{to:`/library?highlight=${t.library_file_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:m("queue.viewInFileManager"),children:s.jsx(Kr,{className:"w-3.5 h-3.5"})}):null]}),s.jsxs("div",{className:"flex items-center gap-3 text-sm text-bambu-gray",children:[s.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:[s.jsx(Ur,{className:"w-3.5 h-3.5"}),t.target_model?`${m("queue.filter.any")} ${t.target_model}${t.target_location?` @ ${t.target_location}`:""}${t.required_filament_types?.length?` (${t.required_filament_types.join(", ")})`:""}`:t.printer_id===null?m("queue.filter.unassigned"):t.printer_name||`${m("common.printer")} #${t.printer_id}`]}),t.print_time_seconds&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(xu,{className:"w-3.5 h-3.5"}),Rre(t.print_time_seconds)]}),t.created_by_username&&s.jsxs("span",{className:"flex items-center gap-1.5",title:m("queue.addedBy",{name:t.created_by_username}),children:[s.jsx(am,{className:"w-3.5 h-3.5"}),t.created_by_username]}),k&&!t.manual_start&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(Jn,{className:"w-3.5 h-3.5"}),IWe(t.scheduled_time,c,m)]})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.manual_start&&s.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:[s.jsx(bW,{className:"w-3 h-3"}),m("queue.badges.staged")]}),t.require_previous_success&&s.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:m("queue.badges.requiresPrevious")}),t.auto_off_after&&s.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:[s.jsx(Gu,{className:"w-3 h-3"}),m("queue.badges.autoPowerOff")]})]}),C&&s.jsxs("div",{className:"mt-3",children:[s.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:m("queue.printingInProgress")})]}),t.waiting_reason&&t.status==="pending"&&s.jsxs("p",{className:"text-xs text-purple-400 mt-2 flex items-start gap-1",children:[s.jsx($i,{className:"w-3 h-3 mt-0.5 flex-shrink-0"}),s.jsx("span",{children:t.waiting_reason})]}),t.error_message&&s.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[s.jsx($i,{className:"w-3 h-3"}),t.error_message]})]}),s.jsx(UWe,{status:t.status,waitingReason:t.waiting_reason,t:m}),s.jsxs("div",{className:"flex items-center gap-1",children:[C&&s.jsx(Te,{variant:"ghost",size:"sm",onClick:a,disabled:!f("printers:control"),title:f("printers:control")?m("queue.actions.stopPrint"):m("queue.permissions.noStopPrint"),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Kce,{className:"w-4 h-4"})}),k&&s.jsxs(s.Fragment,{children:[t.manual_start&&s.jsx(Te,{variant:"ghost",size:"sm",onClick:l,disabled:!f("printers:control"),title:f("printers:control")?m("queue.actions.startPrint"):m("queue.permissions.noStartPrint"),className:"text-bambu-green hover:text-bambu-green-light hover:bg-bambu-green/10",children:s.jsx(Is,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:n,disabled:!p("queue","update",t.created_by_id),title:p("queue","update",t.created_by_id)?m("common.edit"):m("queue.permissions.noEdit"),children:s.jsx(Qi,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:r,disabled:!p("queue","delete",t.created_by_id),title:p("queue","delete",t.created_by_id)?m("common.cancel"):m("queue.permissions.noCancel"),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Rt,{className:"w-4 h-4"})})]}),R&&s.jsxs(s.Fragment,{children:[s.jsx(Te,{variant:"ghost",size:"sm",onClick:o,disabled:!f("queue:create"),title:f("queue:create")?m("queue.actions.requeue"):m("queue.permissions.noRequeue"),className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:s.jsx(Dr,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:i,disabled:!p("queue","delete",t.created_by_id),title:p("queue","delete",t.created_by_id)?m("common.remove"):m("queue.permissions.noRemove"),children:s.jsx(rn,{className:"w-4 h-4"})})]})]})]})})}function BWe(){const{t}=$n(),e=an(),{showToast:n}=Hn(),{hasPermission:r,hasAnyPermission:i,canModify:a}=Ai(),[o,l]=_.useState(null),[c,u]=_.useState(""),[d,f]=_.useState(""),[p,m]=_.useState(!1),[x,b]=_.useState(null),[y,v]=_.useState(null),[S,M]=_.useState(null),[T,E]=_.useState([]),[C,k]=_.useState(!1),[R,A]=_.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[D,U]=_.useState(()=>{const I=localStorage.getItem("queue.historySortAsc");return I!==null?I==="true":!1}),[F,H]=_.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[j,$]=_.useState(()=>{const I=localStorage.getItem("queue.pendingSortAsc");return I!==null?I==="true":!0});_.useEffect(()=>{localStorage.setItem("queue.historySortBy",R)},[R]),_.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(D))},[D]),_.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",F)},[F]),_.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(j))},[j]);const K=cre(ZN(BM,{activationConstraint:{distance:8}}),ZN(zM,{coordinateGetter:Pre})),{data:V}=at({queryKey:["settings"],queryFn:ue.getSettings}),Q=V?.time_format||"system",{data:Z,isLoading:ae}=at({queryKey:["queue",o,c],queryFn:()=>ue.getQueue(o||void 0,c||void 0),refetchInterval:5e3}),{data:B}=at({queryKey:["printers"],queryFn:()=>ue.getPrinters()}),X=mt({mutationFn:I=>ue.cancelQueueItem(I),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.cancelled"))},onError:()=>n(t("queue.toast.cancelFailed"),"error")}),ne=mt({mutationFn:I=>ue.removeFromQueue(I),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.removed"))},onError:()=>n(t("queue.toast.removeFailed"),"error")}),se=mt({mutationFn:I=>ue.stopQueueItem(I),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.stopped"))},onError:()=>n(t("queue.toast.stopFailed"),"error")}),be=mt({mutationFn:I=>ue.startQueueItem(I),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.released"))},onError:()=>n(t("queue.toast.startFailed"),"error")}),xe=mt({mutationFn:I=>ue.reorderQueue(I),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]})},onError:()=>n(t("queue.toast.reorderFailed"),"error")}),de=mt({mutationFn:async()=>{const I=Z?.filter(fe=>["completed","failed","skipped","cancelled"].includes(fe.status))||[];for(const fe of I)await ue.removeFromQueue(fe.id);return I.length},onSuccess:I=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.historyCleared",{count:I}))},onError:()=>n(t("queue.toast.clearHistoryFailed"),"error")}),Pe=mt({mutationFn:I=>ue.bulkUpdateQueue(I),onSuccess:I=>{e.invalidateQueries({queryKey:["queue"]}),E([]),k(!1),n(I.message)},onError:()=>n(t("queue.toast.updateFailed"),"error")}),ie=mt({mutationFn:async I=>{for(const fe of I)await ue.cancelQueueItem(fe);return I.length},onSuccess:I=>{e.invalidateQueries({queryKey:["queue"]}),E([]),n(t("queue.toast.bulkCancelled",{count:I}))},onError:()=>n(t("queue.toast.bulkCancelFailed"),"error")}),Me=I=>{E(fe=>fe.includes(I)?fe.filter(me=>me!==I):[...fe,I])},Oe=_.useMemo(()=>{const I=new Set;return B?.forEach(fe=>{fe.location&&I.add(fe.location)}),Z?.forEach(fe=>{fe.target_location&&I.add(fe.target_location)}),Array.from(I).sort()},[B,Z]),ge=_.useCallback(I=>d?I.target_location?I.target_location===d:I.printer_id?B?.find(me=>me.id===I.printer_id)?.location===d:!1:!0,[d,B]),Ke=_.useMemo(()=>{let I=Z?.filter(me=>me.status==="pending")||[];d&&(I=I.filter(ge));const fe=me=>{if(!me.scheduled_time)return 0;const ke=new Date(me.scheduled_time).getTime(),z=Date.now()+4320*60*60*1e3;return ke>z?0:ke};return[...I].sort((me,ke)=>{let z;if(F==="name"){const O=me.archive_name||me.library_file_name||"",ee=ke.archive_name||ke.library_file_name||"";z=O.localeCompare(ee)}else F==="printer"?z=(me.printer_name||"").localeCompare(ke.printer_name||""):F==="time"?z=fe(me)-fe(ke):z=me.position-ke.position;return j?z:-z})},[Z,F,j,ge,d]),G=()=>{const I=Ke.map(fe=>fe.id);T.length===I.length?E([]):E(I)},Y=_.useMemo(()=>{let I=Z?.filter(fe=>fe.status==="printing")||[];return d&&(I=I.filter(ge)),I},[Z,d,ge]),ce=_.useMemo(()=>{let I=Z?.filter(fe=>["completed","failed","skipped","cancelled"].includes(fe.status))||[];return d&&(I=I.filter(ge)),[...I].sort((fe,me)=>{let ke;if(R==="name"){const z=fe.archive_name||fe.library_file_name||"",O=me.archive_name||me.library_file_name||"";ke=z.localeCompare(O)}else R==="printer"?ke=(fe.printer_name||"").localeCompare(me.printer_name||""):ke=new Date(me.completed_at||me.created_at).getTime()-new Date(fe.completed_at||fe.created_at).getTime();return D?-ke:ke})},[Z,R,D,ge,d]),q=_.useMemo(()=>Ke.reduce((I,fe)=>I+(fe.print_time_seconds||0),0),[Ke]),te=I=>{const{active:fe,over:me}=I;if(!me||fe.id===me.id)return;const ke=Ke.findIndex(O=>O.id===fe.id),z=Ke.findIndex(O=>O.id===me.id);if(ke!==-1&&z!==-1){const ee=VM(Ke,ke,z).map((le,_e)=>({id:le.id,position:_e+1}));xe.mutate(ee)}};return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsx("div",{className:"flex items-center justify-between mb-8",children:s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[s.jsx(yW,{className:"w-7 h-7 text-bambu-green"}),t("queue.title")]}),s.jsx("p",{className:"text-bambu-gray mt-1",children:t("queue.subtitle")})]})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[s.jsx(_t,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:s.jsx(Nt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:s.jsx(Is,{className:"w-5 h-5 text-blue-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:Y.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.printing")})]})]})})}),s.jsx(_t,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:s.jsx(Nt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center",children:s.jsx(Jn,{className:"w-5 h-5 text-yellow-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:Ke.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.queued")})]})]})})}),s.jsx(_t,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:s.jsx(Nt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:s.jsx(xu,{className:"w-5 h-5 text-bambu-green"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:Rre(q)}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.totalTime")})]})]})})}),s.jsx(_t,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:s.jsx(Nt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-500/20 flex items-center justify-center",children:s.jsx(Ar,{className:"w-5 h-5 text-gray-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:ce.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.history")})]})]})})})]}),s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.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:o===-1?"unassigned":o||"",onChange:I=>{const fe=I.target.value;l(fe==="unassigned"?-1:fe===""?null:Number(fe))},children:[s.jsx("option",{value:"",children:t("queue.filter.allPrinters")}),s.jsx("option",{value:"unassigned",children:t("queue.filter.unassigned")}),B?.map(I=>s.jsx("option",{value:I.id,children:I.name},I.id))]}),s.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:c,onChange:I=>u(I.target.value),children:[s.jsx("option",{value:"",children:t("queue.filter.allStatus")}),s.jsx("option",{value:"pending",children:t("queue.status.pending")}),s.jsx("option",{value:"printing",children:t("queue.status.printing")}),s.jsx("option",{value:"completed",children:t("queue.status.completed")}),s.jsx("option",{value:"failed",children:t("queue.status.failed")}),s.jsx("option",{value:"skipped",children:t("queue.status.skipped")}),s.jsx("option",{value:"cancelled",children:t("queue.status.cancelled")})]}),Oe.length>0&&s.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:d,onChange:I=>f(I.target.value),children:[s.jsx("option",{value:"",children:t("queue.filter.allLocations")}),Oe.map(I=>s.jsx("option",{value:I,children:I},I))]}),s.jsx("div",{className:"flex-1"}),ce.length>0&&s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>m(!0),disabled:!r("queue:delete_all"),title:r("queue:delete_all")?void 0:t("queue.permissions.noClearHistory"),children:[s.jsx(rn,{className:"w-4 h-4"}),t("queue.clearHistory")]})]}),ae?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("common.loading")}):Z?.length===0?s.jsxs(_t,{className:"p-12 text-center border-dashed",children:[s.jsx(si,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),s.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:t("queue.empty.title")}),s.jsx("p",{className:"text-bambu-gray max-w-md mx-auto",children:t("queue.empty.description")})]}):s.jsxs("div",{className:"space-y-8",children:[Y.length>0&&s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),t("queue.sections.currentlyPrinting")]}),s.jsx("div",{className:"space-y-3",children:Y.map(I=>s.jsx($j,{item:I,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>M({type:"stop",item:I}),onRequeue:()=>{},onStart:()=>{},timeFormat:Q,hasPermission:r,canModify:a,t},I.id))})]}),Ke.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Jn,{className:"w-5 h-5 text-yellow-400"}),t("queue.sections.queued"),s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",t("queue.itemCount",{count:Ke.length}),")"]}),s.jsx("span",{className:"text-xs text-bambu-gray ml-2",title:t("queue.reorderHint"),children:t("queue.dragToReorder")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.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:F,onChange:I=>H(I.target.value),children:[s.jsx("option",{value:"position",children:t("queue.sort.byPosition")}),s.jsx("option",{value:"name",children:t("queue.sort.byName")}),s.jsx("option",{value:"printer",children:t("queue.sort.byPrinter")}),s.jsx("option",{value:"time",children:t("queue.sort.bySchedule")})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>$(!j),title:t(j?"common.ascending":"common.descending"),className:"px-2",children:j?s.jsx(Ig,{className:"w-4 h-4"}):s.jsx(G0,{className:"w-4 h-4"})})]})]}),s.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-bambu-dark rounded-lg",children:[s.jsxs(Te,{variant:"ghost",size:"sm",onClick:G,className:"flex items-center gap-2",children:[T.length===Ke.length&&Ke.length>0?s.jsx(ol,{className:"w-4 h-4 text-bambu-green"}):s.jsx(ll,{className:"w-4 h-4"}),T.length===Ke.length&&Ke.length>0?t("queue.bulkEdit.deselectAll"):t("queue.bulkEdit.selectAll")]}),T.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:t("queue.bulkEdit.selected",{count:T.length})}),s.jsx("div",{className:"h-4 w-px bg-bambu-dark-tertiary"}),s.jsxs(Te,{variant:"ghost",size:"sm",onClick:()=>k(!0),className:"flex items-center gap-2 text-bambu-green hover:text-bambu-green-light",disabled:!i("queue:update_own","queue:update_all"),title:i("queue:update_own","queue:update_all")?void 0:t("queue.permissions.noEditItems"),children:[s.jsx(Qi,{className:"w-4 h-4"}),t("queue.bulkEdit.editSelected")]}),s.jsxs(Te,{variant:"ghost",size:"sm",onClick:()=>ie.mutate(T),className:"flex items-center gap-2 text-red-400 hover:text-red-300",disabled:ie.isPending||!i("queue:delete_own","queue:delete_all"),title:i("queue:delete_own","queue:delete_all")?void 0:t("queue.permissions.noCancelItems"),children:[s.jsx(Rt,{className:"w-4 h-4"}),t("queue.bulkEdit.cancelSelected")]})]})]}),s.jsx(Ere,{sensors:K,collisionDetection:fre,onDragEnd:te,children:s.jsx(Are,{items:Ke.map(I=>I.id),strategy:kWe,children:s.jsx("div",{className:"space-y-3",children:Ke.map((I,fe)=>s.jsx($j,{item:I,position:fe+1,onEdit:()=>b(I),onCancel:()=>M({type:"cancel",item:I}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>be.mutate(I.id),timeFormat:Q,isSelected:T.includes(I.id),onToggleSelect:()=>Me(I.id),hasPermission:r,canModify:a,t},I.id))})})})]}),ce.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ar,{className:"w-5 h-5 text-bambu-gray"}),t("queue.sections.history"),s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",t("queue.itemCount",{count:ce.length}),")"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.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:R,onChange:I=>A(I.target.value),children:[s.jsx("option",{value:"date",children:t("queue.sort.byDate")}),s.jsx("option",{value:"name",children:t("queue.sort.byName")}),s.jsx("option",{value:"printer",children:t("queue.sort.byPrinter")})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>U(!D),title:t(D?"queue.sort.ascendingOldest":"queue.sort.descendingNewest"),className:"px-2",children:D?s.jsx(Ig,{className:"w-4 h-4"}):s.jsx(G0,{className:"w-4 h-4"})})]})]}),s.jsx("div",{className:"space-y-3",children:ce.slice(0,20).map((I,fe)=>s.jsx($j,{item:I,position:fe+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>M({type:"remove",item:I}),onStop:()=>{},onRequeue:()=>v(I),onStart:()=>{},timeFormat:Q,hasPermission:r,canModify:a,t},I.id))})]})]}),x&&s.jsx(jh,{mode:"edit-queue-item",archiveId:x.archive_id??void 0,libraryFileId:x.library_file_id??void 0,archiveName:x.archive_name||x.library_file_name||`File #${x.archive_id||x.library_file_id}`,queueItem:x,onClose:()=>b(null)}),y&&s.jsx(jh,{mode:"add-to-queue",archiveId:y.archive_id??void 0,libraryFileId:y.library_file_id??void 0,archiveName:y.archive_name||y.library_file_name||`File #${y.archive_id||y.library_file_id}`,onClose:()=>v(null)}),S&&s.jsx(Qn,{title:S.type==="cancel"?t("queue.confirm.cancelTitle"):S.type==="stop"?t("queue.confirm.stopTitle"):t("queue.confirm.removeTitle"),message:S.type==="cancel"?t("queue.confirm.cancelMessage",{name:S.item.archive_name||S.item.library_file_name||t("queue.confirm.thisPrint")}):S.type==="stop"?t("queue.confirm.stopMessage",{name:S.item.archive_name||S.item.library_file_name||t("queue.confirm.thisPrint")}):t("queue.confirm.removeMessage",{name:S.item.archive_name||S.item.library_file_name||t("queue.confirm.thisItem")}),confirmText:S.type==="cancel"?t("queue.confirm.cancelButton"):S.type==="stop"?t("queue.confirm.stopButton"):t("common.remove"),variant:"danger",onConfirm:()=>{S.type==="cancel"?X.mutate(S.item.id):S.type==="stop"?se.mutate(S.item.id):ne.mutate(S.item.id),M(null)},onCancel:()=>M(null)}),p&&s.jsx(Qn,{title:t("queue.confirm.clearHistoryTitle"),message:t("queue.confirm.clearHistoryMessage",{count:ce.length}),confirmText:t("queue.clearHistory"),variant:"danger",onConfirm:()=>{de.mutate(),m(!1)},onCancel:()=>m(!1)}),C&&s.jsx(zWe,{selectedCount:T.length,printers:B?.map(I=>({id:I.id,name:I.name}))||[],onSave:I=>{Object.keys(I).length>0&&Pe.mutate({item_ids:T,...I})},onClose:()=>k(!1),isSaving:Pe.isPending,t})]})}function $We({printDates:t,months:e=3}){const n=_.useRef(null),[r,i]=_.useState(0);_.useEffect(()=>{const S=n.current;if(!S)return;const M=new ResizeObserver(T=>{const E=T[0]?.contentRect.width||0;i(E)});return M.observe(S),()=>M.disconnect()},[]);const{weeks:a,monthLabels:o,printCounts:l}=_.useMemo(()=>{const S={};t.forEach(U=>{const F=U.split("T")[0];S[F]=(S[F]||0)+1});const M=new Date,T=new Date(M);T.setMonth(T.getMonth()-e),T.setDate(T.getDate()-T.getDay());const E=[],C=[];let k=[],R=-1;const A=new Date(T);let D=0;for(;A<=M;)A.getDay()===0&&k.length>0&&(E.push(k),k=[],D++),A.getMonth()!==R&&(C.push({month:A.toLocaleDateString("en-US",{month:"short"}),weekIndex:D}),R=A.getMonth()),k.push(new Date(A)),A.setDate(A.getDate()+1);return k.length>0&&E.push(k),{weeks:E,monthLabels:C,printCounts:S}},[t,e]),c=Math.max(1,...Object.values(l)),u=S=>{if(S===0)return"bg-bambu-dark";const M=S/c;return M<=.25?"bg-bambu-green/30":M<=.5?"bg-bambu-green/50":M<=.75?"bg-bambu-green/75":"bg-bambu-green"},d=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],f=a.length,p=32,m=2,x=r-p-16,b=f>0?Math.floor((x-(f-1)*m)/f):12,y=Math.max(8,Math.min(20,b)),v=y<=10?10:12;return s.jsx("div",{ref:n,className:"w-full flex justify-center",children:r>0&&s.jsxs("div",{children:[s.jsx("div",{className:"flex mb-1",style:{marginLeft:p+4},children:o.map(({month:S,weekIndex:M},T)=>s.jsx("div",{className:"text-bambu-gray",style:{fontSize:v,marginLeft:T===0?0:`${(M-(o[T-1]?.weekIndex||0))*(y+m)-24}px`},children:S},T))}),s.jsxs("div",{className:"flex",style:{gap:m},children:[s.jsx("div",{className:"flex flex-col",style:{gap:m,marginRight:4,width:p},children:d.map((S,M)=>s.jsx("div",{className:"text-bambu-gray flex items-center",style:{width:p,height:y,fontSize:v,visibility:M%2===1?"visible":"hidden"},children:S},S))}),a.map((S,M)=>s.jsx("div",{className:"flex flex-col",style:{gap:m},children:[0,1,2,3,4,5,6].map(T=>{const E=S.find(A=>A.getDay()===T);if(!E)return s.jsx("div",{style:{width:y,height:y}},T);const C=E.toISOString().split("T")[0],k=l[C]||0,R=C===new Date().toISOString().split("T")[0];return s.jsx("div",{className:`rounded-sm ${u(k)} ${R?"ring-1 ring-white":""}`,style:{width:y,height:y},title:`${E.toLocaleDateString()}: ${k} print${k!==1?"s":""}`},T)})},M))]}),s.jsxs("div",{className:"flex items-center gap-2 mt-3 text-bambu-gray",style:{fontSize:v},children:[s.jsx("span",{children:"Less"}),s.jsxs("div",{className:"flex",style:{gap:m},children:[s.jsx("div",{className:"rounded-sm bg-bambu-dark",style:{width:y,height:y}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/30",style:{width:y,height:y}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/50",style:{width:y,height:y}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/75",style:{width:y,height:y}}),s.jsx("div",{className:"rounded-sm bg-bambu-green",style:{width:y,height:y}})]}),s.jsx("span",{children:"More"})]})]})})}const d1=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function HWe(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 VWe({archives:t,currency:e="$"}){const[n,r]=_.useState("30d"),i=_.useMemo(()=>{const p=HWe(n);return t.filter(m=>(Ii(m.completed_at||m.created_at)||new Date(0))>=p)},[t,n]),a=_.useMemo(()=>{const p=new Map;return i.forEach(m=>{const x=Ii(m.completed_at||m.created_at)||new Date,b=`${x.getFullYear()}-${String(x.getMonth()+1).padStart(2,"0")}-${String(x.getDate()).padStart(2,"0")}`,y=p.get(b)||{date:b,filament:0,cost:0,prints:0};y.filament+=m.filament_used_grams||0,y.cost+=m.cost||0,y.prints+=1,p.set(b,y)}),Array.from(p.values()).sort((m,x)=>m.date.localeCompare(x.date)).map(m=>({...m,dateLabel:new Date(m.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),o=_.useMemo(()=>{if(n==="7d"||n==="30d")return a;const p=new Map;return i.forEach(m=>{const x=Ii(m.completed_at||m.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=p.get(y)||{week:y,filament:0,cost:0,prints:0};v.filament+=m.filament_used_grams||0,v.cost+=m.cost||0,v.prints+=1,p.set(y,v)}),Array.from(p.values()).sort((m,x)=>m.week.localeCompare(x.week)).map(m=>({date:m.week,dateLabel:`Week of ${new Date(m.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...m}))},[i,a,n]),l=_.useMemo(()=>{const p=new Map;return i.forEach(m=>{const b=(m.filament_type||"Unknown").split(", ");b.forEach(y=>{const v=(m.filament_used_grams||0)/b.length;p.set(y,(p.get(y)||0)+v)})}),Array.from(p.entries()).map(([m,x])=>({name:m,value:Math.round(x)})).sort((m,x)=>x.value-m.value)},[i]),c=_.useMemo(()=>{const p=new Date,m=[];for(let x=5;x>=0;x--){const b=new Date(p.getFullYear(),p.getMonth()-x,1),y=new Date(p.getFullYear(),p.getMonth()-x+1,0),v=b.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),S=t.filter(M=>{const T=Ii(M.completed_at||M.created_at)||new Date(0);return T>=b&&T<=y});m.push({month:v,filament:Math.round(S.reduce((M,T)=>M+(T.filament_used_grams||0),0)),cost:S.reduce((M,T)=>M+(T.cost||0),0),prints:S.length})}return m},[t]),u=n==="7d"||n==="30d"?a:o,d=i.reduce((p,m)=>p+(m.filament_used_grams||0),0),f=i.reduce((p,m)=>p+(m.cost||0),0);return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),s.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(p=>s.jsx("button",{onClick:()=>r(p),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===p?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:p==="all"?"All":p.replace("d","D")},p))})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[(d/1e3).toFixed(2),"kg"]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,f.toFixed(2)]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[i.length," prints"]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.length>0?(d/i.length).toFixed(0):0,"g"]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,i.length>0?(f/i.length).toFixed(2):"0.00"," avg"]})]})]}),u.length>0?s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),s.jsx(v1,{width:"100%",height:250,children:s.jsxs(UCe,{data:u,children:[s.jsx("defs",{children:s.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[s.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),s.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),s.jsx(BS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(HS,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),s.jsx(VS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:p=>`${p}g`}),s.jsx(_1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:p=>[`${Number(p??0).toFixed(0)}g`,"Filament"]}),s.jsx(PZ,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):s.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),l.length>0?s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(v1,{width:160,height:160,children:s.jsxs(FCe,{children:[s.jsx(nZ,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((p,m)=>s.jsx(cv,{fill:d1[m%d1.length]},`cell-${m}`))}),s.jsx(_1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:p=>[`${p??0}g`,"Usage"]})]})}),s.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:l.map((p,m)=>{const x=l.reduce((y,v)=>y+v.value,0),b=x>0?(p.value/x*100).toFixed(0):0;return s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:d1[m%d1.length]}}),s.jsx("span",{className:"text-white truncate flex-1",children:p.name}),s.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[b,"%"]})]},p.name)})})]}):s.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),s.jsx(v1,{width:"100%",height:200,children:s.jsxs(MCe,{data:c,children:[s.jsx(BS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(HS,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),s.jsx(VS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:p=>`${p}g`}),s.jsx(_1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(p,m)=>[m==="filament"?`${p??0}g`:m==="cost"?`${e}${Number(p??0).toFixed(2)}`:p??0,m==="filament"?"Filament":m==="cost"?"Cost":"Prints"]}),s.jsx(dO,{}),s.jsx(lZ,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function GWe({id:t,title:e,component:n,isHidden:r,size:i,onToggleVisibility:a,onToggleSize:o}){const{attributes:l,listeners:c,setNodeRef:u,transform:d,transition:f,isDragging:p}=jre({id:t}),m={transform:mx.Transform.toString(d),transition:f,opacity:p?.5:1};return r?null:s.jsxs("div",{ref:u,style:{...m,gridColumn:`span ${i}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${p?"ring-2 ring-bambu-green shadow-lg":""}`,children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.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:s.jsx(zg,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}),s.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.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?s.jsx(wW,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):s.jsx(vW,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),s.jsx("button",{onClick:a,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:s.jsx(l2,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),s.jsx("div",{className:"p-4",children:typeof n=="function"?n(i):n})]})}function qWe({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i,renderControls:a}){const o=()=>{const T={};return t.forEach(E=>{T[E.id]=E.defaultSize||4}),T},[l,c]=_.useState(()=>{const T=localStorage.getItem(e);if(T)try{const E=JSON.parse(T);return E.sizes||(E.sizes=o()),E}catch{}return{order:t.map(E=>E.id),hidden:t.filter(E=>E.defaultVisible===!1).map(E=>E.id),sizes:o()}}),[u,d]=_.useState(!1);_.useEffect(()=>{const T=()=>d(E=>!E);return window.addEventListener("toggle-hidden-panel",T),()=>window.removeEventListener("toggle-hidden-panel",T)},[]),_.useEffect(()=>{localStorage.setItem(e,JSON.stringify(l))},[l,e]),_.useEffect(()=>{const E=t.map(C=>C.id).filter(C=>!l.order.includes(C));E.length>0&&c(C=>({...C,order:[...C.order,...E]}))},[t,l.order]);const f=cre(ZN(BM,{activationConstraint:{distance:8}}),ZN(zM,{coordinateGetter:Pre})),p=T=>{const{active:E,over:C}=T;C&&E.id!==C.id&&c(k=>{const R=k.order.indexOf(E.id),A=k.order.indexOf(C.id);return{...k,order:VM(k.order,R,A)}})},m=T=>{c(E=>({...E,hidden:E.hidden.includes(T)?E.hidden.filter(C=>C!==T):[...E.hidden,T]}))},x=T=>{c(E=>{const C=E.sizes[T]||4,k=C===1?2:C===2?4:1;return{...E,sizes:{...E.sizes,[T]:k}}})},b=()=>{const T={order:t.map(E=>E.id),hidden:t.filter(E=>E.defaultVisible===!1).map(E=>E.id),sizes:o()};c(T),i?.()},y=l.order.map(T=>t.find(E=>E.id===T)).filter(Boolean),v=y.filter(T=>!l.hidden.includes(T.id)),S=y.filter(T=>l.hidden.includes(T.id)),M=a?.({hiddenCount:S.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:b});return s.jsxs("div",{className:"space-y-4",children:[M,!r&&!a&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(Te,{variant:"secondary",size:"sm",onClick:b,children:[s.jsx(Rh,{className:"w-4 h-4"}),"Reset Layout"]}),S.length>0&&s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[s.jsx(Ru,{className:"w-4 h-4"}),S.length," Hidden"]})]}),u&&S.length>0&&s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:S.map(T=>s.jsxs("button",{onClick:()=>m(T.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:[s.jsx(Ru,{className:"w-3 h-3"}),T.title]},T.id))})]}),s.jsx(Ere,{sensors:f,collisionDetection:fre,onDragEnd:p,children:s.jsx(Are,{items:v.map(T=>T.id),strategy:lF,children:s.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:v.map(T=>s.jsx(GWe,{id:T.id,title:T.title,component:T.component,isHidden:l.hidden.includes(T.id),size:l.sizes[T.id]||2,onToggleVisibility:()=>m(T.id),onToggleSize:()=>x(T.id)},T.id))})})}),v.length===0&&s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx("p",{children:"All widgets are hidden."}),s.jsx(Te,{className:"mt-4",onClick:b,children:"Reset Layout"})]})]})}function WWe({stats:t,currency:e,t:n}){return s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:s.jsx(mc,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.totalPrints")}),s.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:s.jsx(Jn,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.printTime")}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:s.jsx(mc,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.filamentUsed")}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:s.jsx(hP,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.filamentCost")}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:s.jsx(vh,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.energyUsed")}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:s.jsx(hP,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.energyCost")}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function KWe({stats:t,printerMap:e,size:n=1,t:r}){const i=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0,a=n===1?112:n===2?128:144,o=a/2-8,l=o*2*Math.PI;return s.jsxs("div",{className:"flex items-center gap-6",children:[s.jsxs("div",{className:"relative flex-shrink-0",style:{width:a,height:a},children:[s.jsxs("svg",{className:"w-full h-full -rotate-90",children:[s.jsx("circle",{cx:a/2,cy:a/2,r:o,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),s.jsx("circle",{cx:a/2,cy:a/2,r:o,fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${i/100*l} ${l}`})]}),s.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:s.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[i,"%"]})})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ar,{className:"w-4 h-4 text-status-ok flex-shrink-0"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:r("stats.successful")}),s.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Yi,{className:"w-4 h-4 text-status-error flex-shrink-0"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:r("stats.failed")}),s.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&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:r("stats.printsByPrinter")}),s.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(([c,u])=>s.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[s.jsx("span",{className:"text-bambu-gray truncate max-w-[120px]",children:e.get(c)||`${r("common.printer")} ${c}`}),s.jsx("span",{className:"text-white font-medium",children:u})]},c))})]})]})]})}function XWe({stats:t,printerMap:e,size:n=1,t:r}){const i=t?.average_time_accuracy;if(i==null)return s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx("p",{className:"text-bambu-gray text-center py-4",children:r("stats.noTimeAccuracyData")})});const o=(Math.min(150,Math.max(50,i))-50)/100*100,c=(b=>b>=95&&b<=105?"#00ae42":b>105?"#3b82f6":"#f97316")(i),u=i-100,d=n===1?112:n===2?128:144,f=d/2-8,p=f*2*Math.PI,m=n===1?3:n===2?6:999,x=t?.time_accuracy_by_printer?Object.entries(t.time_accuracy_by_printer).slice(0,m):[];return s.jsxs("div",{className:"flex items-center gap-6",children:[s.jsxs("div",{className:"relative flex-shrink-0",style:{width:d,height:d},children:[s.jsxs("svg",{className:"w-full h-full -rotate-90",children:[s.jsx("circle",{cx:d/2,cy:d/2,r:f,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),s.jsx("circle",{cx:d/2,cy:d/2,r:f,fill:"none",stroke:c,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${o/100*p} ${p}`})]}),s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[s.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[i.toFixed(0),"%"]}),s.jsxs("span",{className:`text-xs ${u>=0?"text-blue-400":"text-orange-400"}`,children:[u>=0?"+":"",u.toFixed(0),"%"]})]})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[s.jsx(kW,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{children:r("stats.perfectEstimate")})]}),x.length>0&&s.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:x.map(([b,y])=>s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(b)||`${r("common.printer")} ${b}`}),s.jsxs("span",{className:`font-medium ${y>=95&&y<=105?"text-status-ok":y>105?"text-blue-400":"text-status-warning"}`,children:[y.toFixed(0),"%"]})]},b))})]})]})}function YWe({stats:t,size:e=1,t:n}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return s.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noFilamentData")});const r=Object.entries(t.prints_by_filament_type).sort(([,l],[,c])=>c-l),i=e===1?5:e===2?8:999,a=r.slice(0,i),o=r.length>i;return e===4&&a.length>4?s.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4",children:a.map(([l,c])=>{const u=Math.round(c/(t.total_prints||1)*100);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-white truncate max-w-[120px]",children:l}),s.jsx("span",{className:"text-bambu-gray",children:c})]}),s.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:s.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${u}%`}})})]},l)})}):s.jsxs("div",{className:"space-y-3",children:[a.map(([l,c])=>{const u=Math.round(c/(t.total_prints||1)*100);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-white",children:l}),s.jsxs("span",{className:"text-bambu-gray",children:[c," ",n("common.prints")]})]}),s.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:s.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${u}%`}})})]},l)}),o&&s.jsx("p",{className:"text-xs text-bambu-gray text-center pt-1",children:n("common.more",{count:r.length-i})})]})}function QWe({printDates:t,size:e=2}){const n=e===1?3:e===2?6:12;return s.jsx($We,{printDates:t,months:n})}function ZWe({stats:t,printerMap:e,t:n}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?s.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noPrinterData")}):s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([r,i])=>s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:s.jsx(Ur,{className:"w-4 h-4 text-bambu-green"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium text-sm",children:e.get(r)||`${n("common.printer")} ${r}`}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[i," ",n("common.prints")]})]})]},r))})}function JWe({archives:t,currency:e,t:n}){return!t||t.length===0?s.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noPrintData")}):s.jsx(VWe,{archives:t,currency:e})}function eKe({size:t=1,t:e}){const{data:n,isLoading:r}=at({queryKey:["failureAnalysis"],queryFn:()=>ue.getFailureAnalysis({days:30})});if(r)return s.jsx("div",{className:"flex justify-center py-4",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!n||n.total_prints===0)return s.jsx("p",{className:"text-bambu-gray text-center py-4",children:e("stats.noPrintDataLast30Days")});const i=t===1?5:t===2?8:999,a=Object.entries(n.failures_by_reason).sort(([,c],[,u])=>u-c),o=a.slice(0,i),l=a.length>i;return s.jsxs("div",{className:`${t>=2?"flex gap-8":"space-y-4"}`,children:[s.jsxs("div",{className:t>=2?"flex-shrink-0":"",children:[s.jsx("div",{className:"flex items-center gap-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Cn,{className:`w-5 h-5 ${n.failure_rate>20?"text-status-error":n.failure_rate>10?"text-status-warning":"text-status-ok"}`}),s.jsxs("span",{className:`font-bold text-white ${t>=2?"text-3xl":"text-2xl"}`,children:[n.failure_rate.toFixed(1),"%"]})]})}),s.jsx("div",{className:"text-sm text-bambu-gray mt-1",children:e("stats.failedPrintsCount",{failed:n.failed_prints,total:n.total_prints})}),n.trend&&n.trend.length>=2&&s.jsx("div",{className:`${t>=2?"mt-4":"mt-2 pt-2 border-t border-bambu-dark-tertiary"}`,children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(AW,{className:`w-4 h-4 ${n.trend[n.trend.length-1].failure_rate<n.trend[n.trend.length-2].failure_rate?"text-status-ok":"text-status-error"}`}),s.jsx("span",{className:"text-bambu-gray",children:e("stats.lastWeekRate",{rate:n.trend[n.trend.length-1].failure_rate.toFixed(1)})})]})})]}),o.length>0&&s.jsxs("div",{className:`flex-1 ${t>=2?"border-l border-bambu-dark-tertiary pl-8":"pt-2"}`,children:[s.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:t>=2?e("stats.failureReasons"):e("stats.topFailureReasons")}),s.jsx("div",{className:`${t===4?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,children:o.map(([c,u])=>s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("span",{className:`text-white truncate ${t===4?"max-w-[200px]":"max-w-[160px]"}`,children:c||e("common.unknown")}),s.jsx("span",{className:"text-bambu-gray ml-2",children:u})]},c))}),l&&s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:e("common.more",{count:a.length-i})})]})]})}function tKe(){const{t}=$n(),{showToast:e}=Hn(),{hasPermission:n}=Ai(),[r,i]=_.useState(!1),[a,o]=_.useState(!1),[l,c]=_.useState(0),[u,d]=_.useState(0),[f,p]=_.useState(!1);_.useEffect(()=>{const A=()=>{try{const U=localStorage.getItem("bambusy-dashboard-layout");if(U){const F=JSON.parse(U);d(F.hidden?.length||0)}}catch{d(0)}};A(),window.addEventListener("storage",A);const D=setInterval(A,500);return()=>{window.removeEventListener("storage",A),clearInterval(D)}},[l]);const{data:m,isLoading:x,refetch:b}=at({queryKey:["archiveStats"],queryFn:ue.getArchiveStats}),{data:y}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:v}=at({queryKey:["archives"],queryFn:()=>ue.getArchives(void 0,void 0,1e3,0)}),{data:S}=at({queryKey:["settings"],queryFn:ue.getSettings}),M=async A=>{o(!1),i(!0);try{const{blob:D,filename:U}=await ue.exportStats({format:A,days:90}),F=URL.createObjectURL(D),H=document.createElement("a");H.href=F,H.download=U,H.click(),URL.revokeObjectURL(F),e(t("stats.exportDownloaded"))}catch{e(t("stats.exportFailed"),"error")}finally{i(!1)}},T=async()=>{p(!0);try{const A=await ue.recalculateCosts();await b(),e(t("stats.recalculatedCosts",{count:A.updated}))}catch{e(t("stats.recalculateFailed"),"error")}finally{p(!1)}},E=S?.currency||"$",C=new Map(y?.map(A=>[String(A.id),A.name])||[]),k=v?.map(A=>A.created_at)||[];if(x)return s.jsx("div",{className:"p-4 md:p-8",children:s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("stats.loadingStats")})});const R=[{id:"quick-stats",title:t("stats.quickStats"),component:s.jsx(WWe,{stats:m,currency:E,t}),defaultSize:2},{id:"success-rate",title:t("stats.successRate"),component:A=>s.jsx(KWe,{stats:m,printerMap:C,size:A,t}),defaultSize:1},{id:"time-accuracy",title:t("stats.timeAccuracy"),component:A=>s.jsx(XWe,{stats:m,printerMap:C,size:A,t}),defaultSize:1},{id:"filament-types",title:t("stats.filamentTypes"),component:A=>s.jsx(YWe,{stats:m,size:A,t}),defaultSize:1},{id:"failure-analysis",title:t("stats.failureAnalysis"),component:A=>s.jsx(eKe,{size:A,t}),defaultSize:1},{id:"print-activity",title:t("stats.printActivity"),component:A=>s.jsx(QWe,{printDates:k,size:A}),defaultSize:2},{id:"prints-by-printer",title:t("stats.printsByPrinter"),component:s.jsx(ZWe,{stats:m,printerMap:C,t}),defaultSize:2},{id:"filament-trends",title:t("stats.filamentTrends"),component:s.jsx(JWe,{archives:v||[],currency:E,t}),defaultSize:4}];return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:t("stats.title")}),s.jsx("p",{className:"text-bambu-gray",children:t("stats.subtitle")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[u>0&&s.jsxs(Te,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[s.jsx(Ru,{className:"w-4 h-4"}),t("stats.hiddenCount",{count:u})]}),s.jsxs(Te,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),c(A=>A+1),e(t("stats.layoutReset"))},disabled:!n("settings:update"),title:n("settings:update")?void 0:t("stats.noPermissionResetLayout"),children:[s.jsx(Rh,{className:"w-4 h-4"}),t("stats.resetLayout")]}),s.jsxs(Te,{variant:"secondary",onClick:T,disabled:f||!n("archives:update_all"),title:n("archives:update_all")?t("stats.recalculateCostsHint"):t("stats.noPermissionRecalculate"),children:[f?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(kce,{className:"w-4 h-4"}),t("stats.recalculateCosts")]}),s.jsxs("div",{className:"relative",children:[s.jsxs(Te,{variant:"secondary",onClick:()=>o(!a),disabled:r,children:[r?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(q1,{className:"w-4 h-4"}),t("stats.exportStats")]}),a&&s.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:[s.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:()=>M("csv"),children:[s.jsx(Ls,{className:"w-4 h-4"}),t("stats.exportAsCsv")]}),s.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:()=>M("xlsx"),children:[s.jsx(q1,{className:"w-4 h-4"}),t("stats.exportAsExcel")]})]})]})]})]}),s.jsx(qWe,{widgets:R,storageKey:"bambusy-dashboard-layout",hideControls:!0},l)]})}function nKe({plug:t,onEdit:e}){const n=an(),{showToast:r}=Hn(),[i,a]=_.useState(!1),[o,l]=_.useState(!1),[c,u]=_.useState(!1),[d,f]=_.useState(!1),{data:p,isLoading:m}=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 D=n.getQueryData(["smart-plug-status",t.id]),U=A==="on"?"ON":A==="off"||p?.state==="ON"?"OFF":"ON";return n.setQueryData(["smart-plug-status",t.id],F=>({...F,state:U})),{previousStatus:D}},onError:(A,D,U)=>{U?.previousStatus&&n.setQueryData(["smart-plug-status",t.id],U.previousStatus),r(`Failed to turn ${D} "${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"]})}}),M=p?.state==="ON",T=t.plug_type==="mqtt"&&p?.energy?.power!==null&&p?.energy?.power!==void 0,E=(p?.reachable??!1)||T,C=y.isPending,R=(()=>{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 s.jsxs(s.Fragment,{children:[s.jsx(_t,{className:"relative",children:s.jsxs(Nt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2 mb-3",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx("div",{className:`p-2 rounded-lg flex-shrink-0 ${t.plug_type==="mqtt"?E?"bg-teal-500/20":"bg-red-500/20":E?M?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:t.plug_type==="mqtt"?s.jsx(jR,{className:`w-5 h-5 ${E?"text-teal-400":"text-red-400"}`}):t.plug_type==="homeassistant"?s.jsx(f2,{className:`w-5 h-5 ${E?M?"text-bambu-green":"text-bambu-gray":"text-red-400"}`}):s.jsx(tl,{className:`w-5 h-5 ${E?M?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("h3",{className:"font-medium text-white truncate",children:t.name}),s.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})]})]}),s.jsxs("div",{className:"flex flex-col items-end gap-1 flex-shrink-0",children:[m?s.jsx(ht,{className:"w-4 h-4 text-bambu-gray animate-spin"}):t.plug_type==="mqtt"?s.jsxs("div",{className:"flex items-center gap-1.5 text-sm whitespace-nowrap",children:[s.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"}),E&&s.jsx("span",{className:"text-status-ok",children:"✓"})]}):t.plug_type==="homeassistant"?s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx("span",{className:"px-1 py-0.5 bg-blue-500/20 text-blue-400 text-[10px] font-medium rounded",children:"HA"}),s.jsx("span",{className:E?M?"text-status-ok":"text-bambu-gray":"text-status-error",children:E?p?.state||"?":"Offline"})]}):E?s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx(Sg,{className:"w-4 h-4 text-status-ok"}),s.jsx("span",{className:M?"text-status-ok":"text-bambu-gray",children:p?.state||"Unknown"})]}):s.jsxs("div",{className:"flex items-center gap-1 text-sm text-status-error",children:[s.jsx(sm,{className:"w-4 h-4"}),s.jsx("span",{children:"Offline"})]}),R&&s.jsxs("a",{href:R,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:[s.jsx(Kr,{className:"w-3 h-3"}),"Admin"]})]})]}),b&&s.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),s.jsx("span",{className:"text-sm text-white",children:b.name})]}),(t.power_alert_enabled||t.schedule_enabled||t.plug_type==="mqtt")&&s.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.plug_type==="mqtt"&&s.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:[s.jsx(Ru,{className:"w-3 h-3"}),"Monitor Only"]}),t.power_alert_enabled&&s.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:[s.jsx(wg,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&s.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:[s.jsx(si,{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"&&s.jsxs("div",{className:"flex gap-2 mb-3",children:[s.jsxs(Te,{size:"sm",variant:M?"primary":"secondary",disabled:!E||C,onClick:()=>l(!0),className:"flex-1",children:[C?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Gu,{className:"w-4 h-4"}),"On"]}),s.jsxs(Te,{size:"sm",variant:M?"secondary":"primary",disabled:!E||C,onClick:()=>u(!0),className:"flex-1",children:[C?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(g2,{className:"w-4 h-4"}),"Off"]})]}),t.plug_type==="mqtt"&&p?.energy&&s.jsxs("div",{className:"flex gap-2 mb-3 px-3 py-2 bg-bambu-dark rounded-lg",children:[p.energy.power!==null&&p.energy.power!==void 0&&s.jsxs("div",{className:"flex-1 text-center",children:[s.jsxs("p",{className:"text-lg font-semibold text-white",children:[Math.round(p.energy.power),"W"]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Power"})]}),p.energy.today!==null&&p.energy.today!==void 0&&s.jsxs("div",{className:"flex-1 text-center border-l border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-lg font-semibold text-white",children:p.energy.today.toFixed(2)}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"kWh Today"})]})]}),s.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:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(bh,{className:"w-4 h-4"}),t.plug_type==="mqtt"?"Settings":"Automation Settings"]}),s.jsx("span",{children:d?"-":"+"})]}),d&&s.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(m2,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Show in Switchbar"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.show_in_switchbar,onChange:A=>v.mutate({show_in_switchbar:A.target.checked}),className:"sr-only peer"}),s.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"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Enabled"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.enabled,onChange:A=>v.mutate({enabled:A.target.checked}),className:"sr-only peer"}),s.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"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Auto On"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:A=>v.mutate({auto_on:A.target.checked}),className:"sr-only peer"}),s.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"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:A=>v.mutate({auto_off:A.target.checked}),className:"sr-only peer"}),s.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&&s.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),s.jsxs("div",{className:"flex gap-2",children:[s.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:[s.jsx(Jn,{className:"w-4 h-4"}),"Time"]}),s.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:[s.jsx(b2,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),s.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"})]}):s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),s.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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]})]}),s.jsxs("div",{className:"flex gap-2 pt-2",children:[s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(fg,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>a(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(rn,{className:"w-4 h-4"})})]})]})]})}),i&&s.jsx(Qn,{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(),a(!1)},onCancel:()=>a(!1)}),o&&s.jsx(Qn,{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&&s.jsx(Qn,{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 rKe({plug:t,onClose:e}){const n=an(),r=!!t,[i,a]=_.useState(t?.plug_type||"tasmota"),[o,l]=_.useState(t?.name||""),[c,u]=_.useState(t?.ip_address||""),[d,f]=_.useState(t?.username||""),[p,m]=_.useState(t?.password||""),[x,b]=_.useState(t?.ha_entity_id||""),[y,v]=_.useState(t?.mqtt_power_topic||t?.mqtt_topic||""),[S,M]=_.useState(t?.mqtt_power_path||""),[T,E]=_.useState((t?.mqtt_power_multiplier??t?.mqtt_multiplier??1).toString()),[C,k]=_.useState(t?.mqtt_energy_topic||""),[R,A]=_.useState(t?.mqtt_energy_path||""),[D,U]=_.useState((t?.mqtt_energy_multiplier??1).toString()),[F,H]=_.useState(t?.mqtt_state_topic||""),[j,$]=_.useState(t?.mqtt_state_path||""),[K,V]=_.useState(t?.mqtt_state_on_value||""),[Q,Z]=_.useState(t?.ha_power_entity||""),[ae,B]=_.useState(t?.ha_energy_today_entity||""),[X,ne]=_.useState(t?.ha_energy_total_entity||""),[se,be]=_.useState(""),[xe,de]=_.useState(""),[Pe,ie]=_.useState(!1),Me=_.useRef(null),[Oe,ge]=_.useState(""),[Ke,G]=_.useState(!1),Y=_.useRef(null),[ce,q]=_.useState(""),[te,I]=_.useState(!1),fe=_.useRef(null),[me,ke]=_.useState(""),[z,O]=_.useState(!1),ee=_.useRef(null),[le,_e]=_.useState(t?.printer_id||null),[we,re]=_.useState(null),[Fe,$e]=_.useState(null),[Ve,He]=_.useState(t?.power_alert_enabled||!1),[ye,je]=_.useState(t?.power_alert_high?.toString()||""),[Be,Se]=_.useState(t?.power_alert_low?.toString()||""),[Xe,Ne]=_.useState(t?.schedule_enabled||!1),[tt,Ee]=_.useState(t?.schedule_on_time||""),[We,ze]=_.useState(t?.schedule_off_time||""),[W,De]=_.useState(t?.show_in_switchbar||!1),[Ye,xt]=_.useState(!1),[ft,Bt]=_.useState({scanned:0,total:0}),[Lt,vn]=_.useState([]),Jt=_.useRef(null),{data:rr}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:hr}=at({queryKey:["smart-plugs"],queryFn:ue.getSmartPlugs}),{data:Dn}=at({queryKey:["settings"],queryFn:ue.getSettings}),ln=!!(Dn?.ha_enabled&&Dn?.ha_url&&Dn?.ha_token);_.useEffect(()=>{const pe=setTimeout(()=>{de(se)},300);return()=>clearTimeout(pe)},[se]),_.useEffect(()=>{const pe=Ie=>{Me.current&&!Me.current.contains(Ie.target)&&ie(!1),Y.current&&!Y.current.contains(Ie.target)&&G(!1),fe.current&&!fe.current.contains(Ie.target)&&I(!1),ee.current&&!ee.current.contains(Ie.target)&&O(!1)};return document.addEventListener("mousedown",pe),()=>document.removeEventListener("mousedown",pe)},[]);const{data:fr,isLoading:Fn,error:Kn}=at({queryKey:["ha-entities",xe],queryFn:()=>ue.getHAEntities(xe||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});_.useEffect(()=>{const pe=Ie=>{Ie.key==="Escape"&&e()};return window.addEventListener("keydown",pe),()=>{window.removeEventListener("keydown",pe),Jt.current&&clearInterval(Jt.current)}},[e]);const wi=async()=>{xt(!0),vn([]),Bt({scanned:0,total:0}),$e(null);try{await ue.startTasmotaScan();const pe=async()=>{try{const Ie=await ue.getTasmotaScanStatus();Bt({scanned:Ie.scanned,total:Ie.total});const Le=await ue.getDiscoveredTasmotaDevices();vn(Le),Ie.running||(xt(!1),Jt.current&&(clearInterval(Jt.current),Jt.current=null))}catch(Ie){console.error("Polling error:",Ie)}};await pe(),Jt.current=setInterval(pe,500)}catch(pe){xt(!1);const Ie=pe instanceof Error?pe.message:typeof pe=="string"?pe:JSON.stringify(pe);$e(Ie||"Failed to start scan")}},Ba=async()=>{try{await ue.stopTasmotaScan()}catch{}xt(!1),Jt.current&&(clearInterval(Jt.current),Jt.current=null)},Ae=pe=>{u(pe.ip_address),l(pe.name),re(null)},Ze=mt({mutationFn:()=>ue.testSmartPlugConnection(c,d||null,p||null),onSuccess:pe=>{re(pe),$e(null),!o&&pe.device_name&&l(pe.device_name)},onError:pe=>{re(null),$e(pe.message)}}),st=mt({mutationFn:pe=>ue.createSmartPlug(pe),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:pe=>{$e(pe.message)}}),lt=mt({mutationFn:pe=>ue.updateSmartPlug(t.id,pe),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:pe=>{$e(pe.message)}}),ot=rr?.filter(pe=>!hr?.some(Le=>Le.printer_id===pe.id&&Le.id!==t?.id)),kt=pe=>{if(pe.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 Le=y.trim(),Ce=C.trim(),ut=F.trim();if(!Le&&!Ce&&!ut){$e("At least one MQTT topic must be configured for power, energy, or state monitoring");return}}const Ie={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"&&Q||null,ha_energy_today_entity:i==="homeassistant"&&ae||null,ha_energy_total_entity:i==="homeassistant"&&X||null,mqtt_power_topic:i==="mqtt"&&y.trim()||null,mqtt_power_path:i==="mqtt"&&S.trim()||null,mqtt_power_multiplier:i==="mqtt"&&parseFloat(T)||1,mqtt_energy_topic:i==="mqtt"&&C.trim()||null,mqtt_energy_path:i==="mqtt"&&R.trim()||null,mqtt_energy_multiplier:i==="mqtt"&&parseFloat(D)||1,mqtt_state_topic:i==="mqtt"&&F.trim()||null,mqtt_state_path:i==="mqtt"&&j.trim()||null,mqtt_state_on_value:i==="mqtt"&&K.trim()||null,username:i==="tasmota"&&d.trim()||null,password:i==="tasmota"&&p.trim()||null,printer_id:le,power_alert_enabled:Ve,power_alert_high:ye?parseFloat(ye):null,power_alert_low:Be?parseFloat(Be):null,schedule_enabled:Xe,schedule_on_time:tt||null,schedule_off_time:We||null,show_in_switchbar:W};r?lt.mutate(Ie):st.mutate(Ie)},he=st.isPending||lt.isPending;return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:s.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:pe=>pe.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Smart Plug":"Add Smart Plug"}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:kt,className:"p-6 space-y-4 overflow-y-auto",children:[Fe&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:Fe}),!r&&s.jsxs("div",{className:"flex gap-2 mb-2",children:[s.jsxs("button",{type:"button",onClick:()=>{a("tasmota"),re(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:[s.jsx(tl,{className:"w-4 h-4"}),"Tasmota"]}),s.jsxs("button",{type:"button",onClick:()=>{a("homeassistant"),re(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:[s.jsx(f2,{className:"w-4 h-4"}),"HA"]}),s.jsxs("button",{type:"button",onClick:()=>{a("mqtt"),re(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:[s.jsx(jR,{className:"w-4 h-4"}),"MQTT"]})]}),!r&&i==="tasmota"&&s.jsxs("div",{className:"space-y-3",children:[Ye?s.jsxs(Te,{type:"button",variant:"secondary",onClick:Ba,className:"w-full",children:[s.jsx(Rt,{className:"w-4 h-4"}),"Stop Scanning"]}):s.jsxs(Te,{type:"button",variant:"primary",onClick:wi,className:"w-full",children:[s.jsx(ba,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),Ye&&ft.total>0&&s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray",children:[s.jsx("span",{children:"Scanning network..."}),s.jsxs("span",{children:[ft.scanned," / ",ft.total]})]}),s.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:s.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${ft.scanned/ft.total*100}%`}})})]}),Lt.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",Lt.length," device(s) - click to select:"]}),s.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:Lt.map(pe=>s.jsxs("button",{type:"button",onClick:()=>Ae(pe),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:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(tl,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:pe.name}),s.jsx("p",{className:"text-xs text-bambu-gray",children:pe.ip_address})]})]}),pe.state&&s.jsxs("span",{className:`flex items-center gap-1 text-xs ${pe.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[s.jsx(Gu,{className:"w-3 h-3"}),pe.state]})]},pe.ip_address))})]}),!Ye&&Lt.length===0&&ft.total>0&&s.jsx("p",{className:"text-xs text-bambu-gray text-center py-2",children:"No Tasmota devices found on your network"})]}),i==="homeassistant"&&s.jsxs("div",{className:"space-y-3",children:[!ln&&s.jsxs("div",{className:"space-y-3",children:[s.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"," ",s.jsx("span",{className:"font-medium",children:"Settings → Network → Home Assistant"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1 opacity-50",children:"Select Entity *"}),s.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:s.jsx("option",{children:"Choose an entity..."})})]})]}),ln&&s.jsxs(s.Fragment,{children:[Fn&&s.jsxs("div",{className:"flex items-center justify-center py-4 text-bambu-gray",children:[s.jsx(ht,{className:"w-5 h-5 animate-spin mr-2"}),"Loading entities..."]}),Kn&&s.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: ",Kn.message]}),(()=>{const pe=hr?.filter(Ce=>Ce.ha_entity_id&&Ce.id!==t?.id).map(Ce=>Ce.ha_entity_id)||[],Ie=(fr||[]).filter(Ce=>!pe.includes(Ce.entity_id)),Le=fr?.find(Ce=>Ce.entity_id===x);return s.jsxs("div",{ref:Me,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Select Entity *"}),s.jsxs("div",{className:"relative",children:[s.jsx(ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),s.jsx("input",{type:"text",value:Pe?se:Le?`${Le.friendly_name} (${Le.entity_id})`:"",onChange:Ce=>{be(Ce.target.value),Pe||ie(!0)},onFocus:()=>{ie(!0),be("")},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&&!Pe&&s.jsx("button",{type:"button",onClick:()=>{b(""),be("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Rt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),Fn&&s.jsx(ht,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray animate-spin"})]}),Pe&&s.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:[Fn&&s.jsxs("div",{className:"px-3 py-2 text-sm text-bambu-gray flex items-center gap-2",children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),"Loading..."]}),!Fn&&Ie.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:xe?`No entities found matching "${xe}"`:"No entities available"}),!Fn&&Ie.map(Ce=>s.jsxs("button",{type:"button",onClick:()=>{b(Ce.entity_id),ie(!1),be(""),o||l(Ce.friendly_name)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary transition-colors ${Ce.entity_id===x?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Ce.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray flex items-center justify-between",children:[s.jsx("span",{children:Ce.entity_id}),s.jsx("span",{className:Ce.state==="on"?"text-bambu-green":"",children:Ce.state})]})]},Ce.entity_id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:xe?`Searching all entities (${Ie.length} found)`:`Showing switch, light, input_boolean (${Ie.length} available)`})]})})(),x&&bn&&bn.length>0&&s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4 space-y-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium mb-1",children:"Energy Monitoring (Optional)"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Search and select sensors that provide power/energy data."})]}),(()=>{const pe=bn.filter(Ce=>Ce.unit_of_measurement==="W"||Ce.unit_of_measurement==="kW"||Ce.unit_of_measurement==="mW"),Ie=Oe?pe.filter(Ce=>Ce.entity_id.toLowerCase().includes(Oe.toLowerCase())||Ce.friendly_name.toLowerCase().includes(Oe.toLowerCase())):pe,Le=bn.find(Ce=>Ce.entity_id===Q);return s.jsxs("div",{ref:Y,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Power Sensor (W)"}),s.jsxs("div",{className:"relative",children:[s.jsx(ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),s.jsx("input",{type:"text",value:Ke?Oe:Le?`${Le.friendly_name} (${Le.state} ${Le.unit_of_measurement})`:"",onChange:Ce=>{ge(Ce.target.value),Ke||G(!0)},onFocus:()=>{G(!0),ge("")},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"}),Q&&!Ke&&s.jsx("button",{type:"button",onClick:()=>{Z(""),ge("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Rt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),Ke&&s.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:[s.jsx("button",{type:"button",onClick:()=>{Z(""),G(!1),ge("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Ie.map(Ce=>s.jsxs("button",{type:"button",onClick:()=>{Z(Ce.entity_id),G(!1),ge("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Ce.entity_id===Q?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Ce.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[Ce.entity_id," • ",Ce.state," ",Ce.unit_of_measurement]})]},Ce.entity_id)),Ie.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const pe=bn.filter(Ce=>Ce.unit_of_measurement==="kWh"||Ce.unit_of_measurement==="Wh"||Ce.unit_of_measurement==="MWh"),Ie=ce?pe.filter(Ce=>Ce.entity_id.toLowerCase().includes(ce.toLowerCase())||Ce.friendly_name.toLowerCase().includes(ce.toLowerCase())):pe,Le=bn.find(Ce=>Ce.entity_id===ae);return s.jsxs("div",{ref:fe,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy Today (kWh)"}),s.jsxs("div",{className:"relative",children:[s.jsx(ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),s.jsx("input",{type:"text",value:te?ce:Le?`${Le.friendly_name} (${Le.state} ${Le.unit_of_measurement})`:"",onChange:Ce=>{q(Ce.target.value),te||I(!0)},onFocus:()=>{I(!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"}),ae&&!te&&s.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:s.jsx(Rt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),te&&s.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:[s.jsx("button",{type:"button",onClick:()=>{B(""),I(!1),q("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Ie.map(Ce=>s.jsxs("button",{type:"button",onClick:()=>{B(Ce.entity_id),I(!1),q("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Ce.entity_id===ae?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Ce.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[Ce.entity_id," • ",Ce.state," ",Ce.unit_of_measurement]})]},Ce.entity_id)),Ie.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const pe=bn.filter(Ce=>Ce.unit_of_measurement==="kWh"||Ce.unit_of_measurement==="Wh"||Ce.unit_of_measurement==="MWh"),Ie=me?pe.filter(Ce=>Ce.entity_id.toLowerCase().includes(me.toLowerCase())||Ce.friendly_name.toLowerCase().includes(me.toLowerCase())):pe,Le=bn.find(Ce=>Ce.entity_id===X);return s.jsxs("div",{ref:ee,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Total Energy (kWh)"}),s.jsxs("div",{className:"relative",children:[s.jsx(ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),s.jsx("input",{type:"text",value:z?me:Le?`${Le.friendly_name} (${Le.state} ${Le.unit_of_measurement})`:"",onChange:Ce=>{ke(Ce.target.value),z||O(!0)},onFocus:()=>{O(!0),ke("")},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"}),X&&!z&&s.jsx("button",{type:"button",onClick:()=>{ne(""),ke("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Rt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),z&&s.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:[s.jsx("button",{type:"button",onClick:()=>{ne(""),O(!1),ke("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Ie.map(Ce=>s.jsxs("button",{type:"button",onClick:()=>{ne(Ce.entity_id),O(!1),ke("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Ce.entity_id===X?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Ce.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[Ce.entity_id," • ",Ce.state," ",Ce.unit_of_measurement]})]},Ce.entity_id)),Ie.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})()]})]})]}),i==="mqtt"&&s.jsxs("div",{className:"space-y-3",children:[!Dn?.mqtt_broker&&s.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"," ",s.jsx("span",{className:"font-medium",children:"Settings → Network → MQTT Publishing"})," ","(you don't need to enable publishing, just fill in the broker details)."]}),Dn?.mqtt_broker&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg text-sm text-blue-300",children:[s.jsx("p",{className:"font-medium mb-1",children:"Monitor Only"}),s.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."})]}),s.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-white font-medium text-sm",children:"Power Monitoring"}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),s.jsx("input",{type:"text",value:y,onChange:pe=>v(pe.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"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),s.jsx("input",{type:"text",value:S,onChange:pe=>M(pe.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Multiplier"}),s.jsx("input",{type:"text",value:T,onChange:pe=>E(pe.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"})]})]}),s.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.',s.jsx("br",{}),"Use multiplier 0.001 for mW→W, 1000 for kW→W."]})]}),s.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("p",{className:"text-white font-medium text-sm",children:["Energy Monitoring ",s.jsx("span",{className:"text-bambu-gray font-normal",children:"(optional)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),s.jsx("input",{type:"text",value:C,onChange:pe=>k(pe.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"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),s.jsx("input",{type:"text",value:R,onChange:pe=>A(pe.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Multiplier"}),s.jsx("input",{type:"text",value:D,onChange:pe=>U(pe.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"})]})]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:["JSON path extracts value from JSON payload. Leave empty for raw values.",s.jsx("br",{}),"Use multiplier 0.001 for Wh→kWh, 1000 for MWh→kWh."]})]}),s.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("p",{className:"text-white font-medium text-sm",children:["State Monitoring ",s.jsx("span",{className:"text-bambu-gray font-normal",children:"(optional)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),s.jsx("input",{type:"text",value:F,onChange:pe=>H(pe.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"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),s.jsx("input",{type:"text",value:j,onChange:pe=>$(pe.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"ON Value"}),s.jsx("input",{type:"text",value:K,onChange:pe=>V(pe.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"})]})]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:["JSON path extracts value from JSON payload. Leave empty for raw values.",s.jsx("br",{}),'ON value: the exact string that means "ON". Leave empty for auto-detect (ON, true, 1).']})]})]})]}),i==="tasmota"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:c,onChange:pe=>{u(pe.target.value),re(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"}),s.jsxs(Te,{type:"button",variant:"secondary",onClick:()=>Ze.mutate(),disabled:!c.trim()||Ze.isPending,children:[Ze.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Sg,{className:"w-4 h-4"}),"Test"]})]})]}),i==="tasmota"&&we&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${we.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:we.success?s.jsxs(s.Fragment,{children:[s.jsx(Ar,{className:"w-5 h-5"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Connected!"}),s.jsxs("p",{className:"text-sm opacity-80",children:[we.device_name&&`Device: ${we.device_name} - `,"State: ",we.state]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(sm,{className:"w-5 h-5"}),s.jsx("span",{children:"Connection failed"})]})}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:o,onChange:pe=>l(pe.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"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),s.jsx("input",{type:"text",value:d,onChange:pe=>f(pe.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),s.jsx("input",{type:"password",value:p,onChange:pe=>m(pe.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"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"})]}),i!=="mqtt"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),s.jsxs("select",{value:le??"",onChange:pe=>_e(pe.target.value?Number(pe.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:[s.jsx("option",{value:"",children:"No printer (manual control only)"}),ot?.map(pe=>s.jsx("option",{value:pe.id,children:pe.name},pe.id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(wg,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-white font-medium",children:"Power Alerts"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:Ve,onChange:pe=>He(pe.target.checked),className:"sr-only peer"}),s.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"})]})]}),Ve&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if above (W)"}),s.jsx("input",{type:"number",value:ye,onChange:pe=>je(pe.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if below (W)"}),s.jsx("input",{type:"number",value:Be,onChange:pe=>Se(pe.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"})]})]}),s.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"&&s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Jn,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-white font-medium",children:"Daily Schedule"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:Xe,onChange:pe=>Ne(pe.target.checked),className:"sr-only peer"}),s.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"})]})]}),Xe&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn On at"}),s.jsx("input",{type:"time",value:tt,onChange:pe=>Ee(pe.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn Off at"}),s.jsx("input",{type:"time",value:We,onChange:pe=>ze(pe.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"})]})]}),s.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."})]})]}),s.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(m2,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white font-medium",children:"Show in Switchbar"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:W,onChange:pe=>De(pe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Te,{type:"submit",disabled:he,className:"flex-1",children:[he?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(hs,{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 s.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:s.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 iKe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function aKe({provider:t,onEdit:e}){const n=an(),[r,i]=_.useState(!1),[a,o]=_.useState(!1),[l,c]=_.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"]})}}),p=mt({mutationFn:()=>ue.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=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 s.jsxs(s.Fragment,{children:[s.jsx(_t,{className:"relative",children:s.jsxs(Nt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-start justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:s.jsx(wg,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-medium text-white",children:t.name}),s.jsx("p",{className:"text-sm text-bambu-gray",children:iKe[t.provider_type]||t.provider_type})]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[t.last_success&&s.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||(Ii(t.last_error_at)?.getTime()||0)>(Ii(t.last_success)?.getTime()||0))&&s.jsx("span",{className:"text-xs text-status-error",title:t.last_error,children:"Error"}),s.jsx(On,{checked:t.enabled,onChange:b=>f.mutate({enabled:b})})]})]}),d&&s.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),s.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&s.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:s.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),s.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&s.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&&s.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&&s.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&s.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&s.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&s.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&s.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&s.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&s.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&&s.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&&s.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&&s.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&&s.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&&s.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&&s.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[s.jsx(W1,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&s.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[s.jsx(si,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),s.jsx("div",{className:"mb-3",children:s.jsxs(Te,{size:"sm",variant:"secondary",disabled:m.isPending,onClick:()=>{c(null),m.mutate()},className:"w-full",children:[m.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(PR,{className:"w-4 h-4"}),"Send Test Notification"]})}),l&&s.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?s.jsx(Ar,{className:"w-4 h-4"}):s.jsx(Yi,{className:"w-4 h-4"}),s.jsx("span",{children:l.message})]}),s.jsxs("button",{onClick:()=>o(!a),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors border-t border-bambu-dark-tertiary",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(bh,{className:"w-4 h-4"}),"Event Settings"]}),a?s.jsx(xh,{className:"w-4 h-4"}):s.jsx(ei,{className:"w-4 h-4"})]}),a&&s.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Enabled"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),s.jsx(On,{checked:t.enabled,onChange:b=>f.mutate({enabled:b})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Started"}),s.jsx(On,{checked:t.on_print_start,onChange:b=>f.mutate({on_print_start:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Plate Not Empty"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Objects detected before print"})]}),s.jsx(On,{checked:t.on_plate_not_empty??!0,onChange:b=>f.mutate({on_plate_not_empty:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),s.jsx(On,{checked:t.on_print_complete,onChange:b=>f.mutate({on_print_complete:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),s.jsx(On,{checked:t.on_print_failed,onChange:b=>f.mutate({on_print_failed:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),s.jsx(On,{checked:t.on_print_stopped,onChange:b=>f.mutate({on_print_stopped:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),s.jsx(On,{checked:t.on_print_progress,onChange:b=>f.mutate({on_print_progress:b})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),s.jsx(On,{checked:t.on_printer_offline,onChange:b=>f.mutate({on_printer_offline:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),s.jsx(On,{checked:t.on_printer_error,onChange:b=>f.mutate({on_printer_error:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),s.jsx(On,{checked:t.on_filament_low,onChange:b=>f.mutate({on_filament_low:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),s.jsx(On,{checked:t.on_maintenance_due??!1,onChange:b=>f.mutate({on_maintenance_due:b})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS Alarms"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS Humidity High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS humidity exceeds threshold"})]}),s.jsx(On,{checked:t.on_ams_humidity_high??!1,onChange:b=>f.mutate({on_ams_humidity_high:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS Temperature High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS temperature exceeds threshold"})]}),s.jsx(On,{checked:t.on_ams_temperature_high??!1,onChange:b=>f.mutate({on_ams_temperature_high:b})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS-HT Alarms"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS-HT Humidity High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT humidity exceeds threshold"})]}),s.jsx(On,{checked:t.on_ams_ht_humidity_high??!1,onChange:b=>f.mutate({on_ams_ht_humidity_high:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS-HT Temperature High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT temperature exceeds threshold"})]}),s.jsx(On,{checked:t.on_ams_ht_temperature_high??!1,onChange:b=>f.mutate({on_ams_ht_temperature_high:b})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Queue"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Job Added"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Job added to queue"})]}),s.jsx(On,{checked:t.on_queue_job_added??!1,onChange:b=>f.mutate({on_queue_job_added:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Job Assigned"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Model-based job assigned to printer"})]}),s.jsx(On,{checked:t.on_queue_job_assigned??!1,onChange:b=>f.mutate({on_queue_job_assigned:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Job Started"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Queue job started printing"})]}),s.jsx(On,{checked:t.on_queue_job_started??!1,onChange:b=>f.mutate({on_queue_job_started:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Job Waiting"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Job waiting for filament"})]}),s.jsx(On,{checked:t.on_queue_job_waiting??!0,onChange:b=>f.mutate({on_queue_job_waiting:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Job Skipped"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Job skipped (previous failed)"})]}),s.jsx(On,{checked:t.on_queue_job_skipped??!0,onChange:b=>f.mutate({on_queue_job_skipped:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Job Failed"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Job failed to start"})]}),s.jsx(On,{checked:t.on_queue_job_failed??!0,onChange:b=>f.mutate({on_queue_job_failed:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Queue Complete"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"All queue jobs finished"})]}),s.jsx(On,{checked:t.on_queue_completed??!1,onChange:b=>f.mutate({on_queue_completed:b})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(W1,{className:"w-4 h-4 text-purple-400"}),s.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),s.jsx(On,{checked:t.quiet_hours_enabled,onChange:b=>f.mutate({quiet_hours_enabled:b})})]}),t.quiet_hours_enabled&&s.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Jn,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("span",{className:"text-sm text-white",children:[x(t.quiet_hours_start)||"22:00"," - ",x(t.quiet_hours_end)||"07:00"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(si,{className:"w-4 h-4 text-emerald-400"}),s.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),s.jsx(On,{checked:t.daily_digest_enabled,onChange:b=>f.mutate({daily_digest_enabled:b})})]}),t.daily_digest_enabled&&s.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Jn,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("span",{className:"text-sm text-white",children:["Send at ",x(t.daily_digest_time)||"08:00"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),s.jsxs("div",{className:"flex gap-2 pt-2",children:[s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(fg,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(rn,{className:"w-4 h-4"})})]})]})]})}),r&&s.jsx(Qn,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{p.mutate(),i(!1)},onCancel:()=>i(!1)})]})}const hq=[{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 sKe({provider:t,onClose:e}){const n=an(),r=!!t,[i,a]=_.useState(t?.name||""),[o,l]=_.useState(t?.provider_type||"email"),[c,u]=_.useState(t?.printer_id||null),[d,f]=_.useState(t?.quiet_hours_enabled||!1),[p,m]=_.useState(t?.quiet_hours_start||"22:00"),[x,b]=_.useState(t?.quiet_hours_end||"07:00"),[y,v]=_.useState(t?.daily_digest_enabled||!1),[S,M]=_.useState(t?.daily_digest_time||"08:00"),[T,E]=_.useState(t?.on_print_start??!1),[C,k]=_.useState(t?.on_print_complete??!0),[R,A]=_.useState(t?.on_print_failed??!0),[D,U]=_.useState(t?.on_print_stopped??!0),[F,H]=_.useState(t?.on_print_progress??!1),[j,$]=_.useState(t?.on_printer_offline??!1),[K,V]=_.useState(t?.on_printer_error??!1),[Q,Z]=_.useState(t?.on_filament_low??!1),[ae,B]=_.useState(t?.on_maintenance_due??!1),[X,ne]=_.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([q,te])=>[q,String(te)])):{}),[se,be]=_.useState(null),[xe,de]=_.useState(null),{data:Pe}=at({queryKey:["printers"],queryFn:ue.getPrinters});_.useEffect(()=>{const q=te=>{te.key==="Escape"&&e()};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[e]);const ie=mt({mutationFn:()=>ue.testNotificationConfig({provider_type:o,config:X}),onSuccess:q=>{be(q),de(null)},onError:q=>{be({success:!1,message:q.message})}}),Me=mt({mutationFn:q=>ue.createNotificationProvider(q),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:q=>{de(q.message)}}),Oe=mt({mutationFn:q=>ue.updateNotificationProvider(t.id,q),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:q=>{de(q.message)}}),ge=q=>{if(q.preventDefault(),de(null),!i.trim()){de("Name is required");return}const te=Y(o);for(const fe of te)if(!X[fe.key]?.trim()){de(`${fe.label} is required`);return}const I={name:i.trim(),provider_type:o,config:X,printer_id:c,quiet_hours_enabled:d,quiet_hours_start:d?p:null,quiet_hours_end:d?x:null,daily_digest_enabled:y,daily_digest_time:y?S:null,on_print_start:T,on_print_complete:C,on_print_failed:R,on_print_stopped:D,on_print_progress:F,on_printer_offline:j,on_printer_error:K,on_filament_low:Q,on_maintenance_due:ae};r?Oe.mutate(I):Me.mutate(I)},Ke=Me.isPending||Oe.isPending,G=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:te=>te.payload_format!=="slack"},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1,showIf:te=>te.payload_format!=="slack"}];default:return[]}},Y=q=>G(q).filter(te=>te.required),ce=G(o);return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:s.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:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:ge,className:"p-6 space-y-4",children:[xe&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:xe}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:i,onChange:q=>a(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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),s.jsx("select",{value:o,onChange:q=>{l(q.target.value),ne({}),be(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:hq.map(q=>s.jsx("option",{value:q.value,children:q.label},q.value))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:hq.find(q=>q.value===o)?.description})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),ce.filter(q=>!("showIf"in q)||q.showIf?.(X)!==!1).map(q=>s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[q.label," ",q.required&&"*"]}),q.type==="select"&&"options"in q&&q.options?s.jsx("select",{value:X[q.key]||q.options[0]?.value||"",onChange:te=>{ne({...X,[q.key]:te.target.value}),be(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(te=>s.jsx("option",{value:te.value,children:te.label},te.value))}):s.jsx("input",{type:q.type,value:X[q.key]||"",onChange:te=>{ne({...X,[q.key]:te.target.value}),be(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))]}),s.jsx("div",{className:"flex gap-2",children:s.jsxs(Te,{type:"button",variant:"secondary",onClick:()=>{be(null),ie.mutate()},disabled:ie.isPending||!X[Y(o)[0]?.key],className:"flex-1",children:[ie.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(PR,{className:"w-4 h-4"}),"Test Configuration"]})}),se&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${se.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:se.success?s.jsxs(s.Fragment,{children:[s.jsx(Ar,{className:"w-5 h-5"}),s.jsx("span",{children:se.message})]}):s.jsxs(s.Fragment,{children:[s.jsx(Yi,{className:"w-5 h-5"}),s.jsx("span",{children:se.message})]})}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),s.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:[s.jsx("option",{value:"",children:"All printers"}),Pe?.map(q=>s.jsx("option",{value:q.id,children:q.name},q.id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),s.jsx(On,{checked:d,onChange:f})]}),d&&s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),s.jsx("input",{type:"time",value:p,onChange:q=>m(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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),s.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"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),s.jsx(On,{checked:y,onChange:v})]}),y&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),s.jsx("input",{type:"time",value:S,onChange:q=>M(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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),s.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Start"}),s.jsx(On,{checked:T,onChange:E})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Complete"}),s.jsx(On,{checked:C,onChange:k})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Failed"}),s.jsx(On,{checked:R,onChange:A})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Stopped"}),s.jsx(On,{checked:D,onChange:U})]}),s.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-white",children:"Progress"}),s.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),s.jsx(On,{checked:F,onChange:H})]})]})]}),s.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Offline"}),s.jsx(On,{checked:j,onChange:$})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Error"}),s.jsx(On,{checked:K,onChange:V})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),s.jsx(On,{checked:Q,onChange:Z})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),s.jsx(On,{checked:ae,onChange:B})]})]})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Te,{type:"submit",disabled:Ke,className:"flex-1",children:[Ke?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(hs,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function oKe({template:t,onClose:e}){const n=an(),r=_.useRef(null),[i,a]=_.useState(t.title_template),[o,l]=_.useState(t.body_template),[c,u]=_.useState(null),[d,f]=_.useState(!0),{data:p}=at({queryKey:["template-variables"],queryFn:ue.getTemplateVariables}),m=p?.find(E=>E.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});_.useEffect(()=>{const E=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[e]);const y=mt({mutationFn:E=>ue.updateNotificationTemplate(t.id,E),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:E=>{u(E.message)}}),v=mt({mutationFn:()=>ue.resetNotificationTemplate(t.id),onSuccess:E=>{a(E.title_template),l(E.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:E=>{u(E.message)}}),S=E=>{if(E.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})},M=E=>{const C=r.current;if(!C)return;const k=C.selectionStart,R=C.selectionEnd,A=o,D=A.substring(0,k),U=A.substring(R),F=D+`{${E}}`+U;l(F),setTimeout(()=>{C.focus();const H=k+E.length+2;C.setSelectionRange(H,H)},0)},T=i!==t.title_template||o!==t.body_template;return s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),s.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("form",{onSubmit:S,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[c&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:c}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),s.jsx("input",{type:"text",value:i,onChange:E=>a(E.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..."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),s.jsx("textarea",{ref:r,value:o,onChange:E=>l(E.target.value),rows:4,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none",placeholder:"Notification body..."})]}),m&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:m.variables.map(E=>s.jsxs("button",{type:"button",onClick:()=>M(E),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:[s.jsx(ur,{className:"w-3 h-3"}),E]},E))}),s.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[s.jsx(Ru,{className:"w-4 h-4"}),"Live Preview"]}),s.jsx("button",{type:"button",onClick:()=>f(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&s.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:b?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):x?s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),s.jsx("div",{className:"text-white font-medium",children:x.title})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),s.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:x.body})]})]}):s.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[s.jsxs(Te,{type:"button",variant:"ghost",onClick:()=>v.mutate(),disabled:v.isPending,className:"text-orange-400 hover:text-orange-300",children:[v.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(Rh,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsxs(Te,{onClick:S,disabled:y.isPending||!T,children:[y.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(hs,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const lKe={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"},cKe={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 uKe({onClose:t}){const e=an(),{showToast:n}=Hn(),[r,i]=_.useState(7),[a,o]=_.useState(null),[l,c]=_.useState(!1),{data:u}=at({queryKey:["settings"],queryFn:ue.getSettings}),d=u?.time_format||"system",{data:f,isLoading:p,refetch:m,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 M=Ii(S);if(!M)return"";const E=new Date().getTime()-M.getTime();return E<6e4?"Just now":E<36e5?`${Math.floor(E/6e4)}m ago`:E<864e5?`${Math.floor(E/36e5)}h ago`:M.toLocaleDateString()+" "+Pfe(M,d)};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.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:[s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(q0,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),b&&s.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:s.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[s.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",s.jsx("span",{className:"text-white font-medium",children:b.total})," notifications"]}),s.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[s.jsx(Ar,{className:"w-4 h-4"}),b.success_count," sent"]}),b.failure_count>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(Yi,{className:"w-4 h-4"}),b.failure_count," failed"]})]})}),s.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[s.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:[s.jsx("option",{value:1,children:"Last 24 hours"}),s.jsx("option",{value:7,children:"Last 7 days"}),s.jsx("option",{value:30,children:"Last 30 days"}),s.jsx("option",{value:90,children:"Last 90 days"})]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.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"]}),s.jsx("div",{className:"flex-1"}),s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>m(),disabled:x,children:[x?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Dr,{className:"w-4 h-4"}),"Refresh"]}),s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>y.mutate(),disabled:y.isPending,className:"text-red-400 hover:text-red-300",children:[y.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(rn,{className:"w-4 h-4"}),"Clear Old"]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:p?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-green animate-spin"})}):f&&f.length>0?s.jsx("div",{className:"space-y-2",children:f.map(S=>s.jsx(dKe,{log:S,isExpanded:a===S.id,onToggle:()=>o(a===S.id?null:S.id),formatDate:v,formatFullDate:M=>$g(M,d)},S.id))}):s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(q0,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{className:"text-sm",children:l?"No failed notifications":"No notifications logged"})]})})]})})}function dKe({log:t,isExpanded:e,onToggle:n,formatDate:r,formatFullDate:i}){return s.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:[s.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?s.jsx(Ar,{className:"w-4 h-4 text-bambu-green shrink-0"}):s.jsx(Yi,{className:"w-4 h-4 text-red-400 shrink-0"}),s.jsx("span",{className:`text-xs font-medium ${cKe[t.event_type]||"text-bambu-gray"}`,children:lKe[t.event_type]||t.event_type}),s.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||"Unknown Provider"}),t.printer_name&&s.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),s.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?s.jsx(xh,{className:"w-4 h-4 text-bambu-gray shrink-0"}):s.jsx(ei,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&s.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),s.jsx("p",{className:"text-sm text-white",children:t.title})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),s.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),s.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),s.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[s.jsxs("span",{children:["Provider: ",t.provider_type]}),s.jsxs("span",{children:["Time: ",i(t.created_at)]})]})]})]})}async function hKe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function fKe(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 mKe(){const t=an(),[e,n]=_.useState(!1),[r,i]=_.useState(""),[a,o]=_.useState("auto"),[l,c]=_.useState(!1),[u,d]=_.useState("all"),[f,p]=_.useState(!1),[m,x]=_.useState(!1),{data:b,isLoading:y}=at({queryKey:["spoolman-settings"],queryFn:hKe}),{data:v,isLoading:S,refetch:M}=at({queryKey:["spoolman-status"],queryFn:ue.getSpoolmanStatus,refetchInterval:3e4}),{data:T}=at({queryKey:["printers"],queryFn:ue.getPrinters});_.useEffect(()=>{b&&(n(b.spoolman_enabled==="true"),i(b.spoolman_url||""),o(b.spoolman_sync_mode||"auto"),p(!0))},[b]),_.useEffect(()=>{if(!f||!b)return;if(b.spoolman_enabled==="true"!==e||(b.spoolman_url||"")!==r||(b.spoolman_sync_mode||"auto")!==a){const $=setTimeout(()=>{E.mutate()},500);return()=>clearTimeout($)}},[e,r,a,f]);const E=mt({mutationFn:()=>fKe({spoolman_enabled:e?"true":"false",spoolman_url:r,spoolman_sync_mode:a}),onSuccess:()=>{t.invalidateQueries({queryKey:["spoolman-settings"]}),t.invalidateQueries({queryKey:["spoolman-status"]}),c(!0),setTimeout(()=>c(!1),2e3)}}),C=mt({mutationFn:ue.connectSpoolman,onSuccess:()=>{M()}}),k=mt({mutationFn:ue.disconnectSpoolman,onSuccess:()=>{M()}}),R=mt({mutationFn:ue.syncAllPrintersAms,onSuccess:j=>{j.success}}),A=mt({mutationFn:j=>ue.syncPrinterAms(j),onSuccess:j=>{j.success}}),D=()=>{u==="all"?R.mutate():A.mutate(u)},U=R.isPending||A.isPending,F=u==="all"?R.data:A.data,H=u==="all"?R.isSuccess:A.isSuccess;return y?s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Mu,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),s.jsx(Nt,{children:s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Mu,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),E.isPending&&s.jsx(ht,{className:"w-4 h-4 text-bambu-green animate-spin"}),l&&s.jsx(Ia,{className:"w-4 h-4 text-bambu-green"})]})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),s.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Zo,{className:"w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-xs text-blue-300",children:[s.jsx("p",{className:"font-medium mb-1",children:"How Sync Works"}),s.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-blue-300/80",children:[s.jsx("li",{children:"Only official Bambu Lab spools with RFID are synced"}),s.jsx("li",{children:"New spools are auto-created in Spoolman on first sync"}),s.jsx("li",{children:"Non-Bambu Lab spools (third-party, refilled) are skipped"})]}),s.jsx("p",{className:"font-medium mt-2 mb-1",children:"Linking Existing Spools"}),s.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".'})]})]})}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Enable Spoolman"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:e,onChange:j=>n(j.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),s.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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),s.jsxs("select",{value:a,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:[s.jsx("option",{value:"auto",children:"Automatic"}),s.jsx("option",{value:"manual",children:"Manual Only"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a==="auto"?"AMS data syncs automatically when changes are detected":"Only sync when manually triggered"})]}),e&&s.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),S?s.jsx(ht,{className:"w-4 h-4 text-bambu-gray animate-spin"}):v?.connected?s.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[s.jsx(Ia,{className:"w-4 h-4"}),"Connected"]}):s.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[s.jsx(Rt,{className:"w-4 h-4"}),"Disconnected"]})]}),s.jsx("div",{className:"flex gap-2",children:v?.connected?s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>k.mutate(),disabled:k.isPending,children:[k.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(pde,{className:"w-4 h-4"}),"Disconnect"]}):s.jsxs(Te,{size:"sm",onClick:()=>C.mutate(),disabled:C.isPending||!r,children:[C.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(uc,{className:"w-4 h-4"}),"Connect"]})})]}),C.isError&&s.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:C.error.message}),v?.connected&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.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:[s.jsx("option",{value:"all",children:"All Printers"}),T?.map(j=>s.jsx("option",{value:j.id,children:j.name},j.id))]}),s.jsx(ei,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:D,disabled:U,children:[U?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Dr,{className:"w-4 h-4"}),"Sync"]})]})]}),H&&F&&s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsx("div",{className:`p-2 rounded text-sm ${F.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:F.success?`Synced ${F.synced_count} spool${F.synced_count!==1?"s":""} successfully`:`Synced ${F.synced_count} spool${F.synced_count!==1?"s":""} with ${F.errors.length} error${F.errors.length!==1?"s":""}`}),F.skipped_count>0&&s.jsxs("div",{className:"p-2 bg-amber-500/10 border border-amber-500/30 rounded text-sm",children:[s.jsxs("div",{className:"flex items-center justify-between text-amber-400 mb-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Cn,{className:"w-3.5 h-3.5"}),s.jsxs("span",{className:"font-medium",children:[F.skipped_count," spool",F.skipped_count!==1?"s":""," skipped"]})]}),F.skipped_count>5&&s.jsx("button",{onClick:()=>x(!m),className:"text-xs text-amber-400 hover:text-amber-300 underline",children:m?"Show less":"Show all"})]}),s.jsxs("ul",{className:"text-xs text-amber-300/80 space-y-0.5",children:[(m?F.skipped:F.skipped.slice(0,5)).map((j,$)=>s.jsxs("li",{className:"flex items-center gap-2",children:[j.color&&s.jsx("span",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:`#${j.color}`}}),s.jsx("span",{children:j.location}),s.jsxs("span",{className:"text-amber-300/60",children:["- ",j.reason]})]},$)),!m&&F.skipped_count>5&&s.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",F.skipped_count-5," more"]})]})]}),F.errors.length>0&&s.jsxs("div",{className:"p-2 bg-red-500/10 border border-red-500/30 rounded text-sm",children:[s.jsx("div",{className:"text-red-400 font-medium mb-1",children:"Errors:"}),s.jsx("ul",{className:"text-xs text-red-300/80 space-y-0.5",children:F.errors.map((j,$)=>s.jsx("li",{children:j},$))})]})]})]})]})]})}function pKe({link:t,onClose:e}){const n=an(),{mode:r}=Oh(),i=!!t,a=_.useRef(null),[o,l]=_.useState(t?.name||""),[c,u]=_.useState(t?.url||""),[d,f]=_.useState(t?.icon||"link"),[p,m]=_.useState(!!t?.custom_icon),[x,b]=_.useState(t?.custom_icon?ue.getExternalLinkIconUrl(t.id):null),[y,v]=_.useState(null),[S,M]=_.useState(null);_.useEffect(()=>{const U=F=>{F.key==="Escape"&&e()};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[e]);const T=mt({mutationFn:async U=>{const F=await ue.createExternalLink(U);return y?await ue.uploadExternalLinkIcon(F.id,y):F},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:U=>{M(U.message)}}),E=mt({mutationFn:async U=>{let F=await ue.updateExternalLink(t.id,U);return y?F=await ue.uploadExternalLinkIcon(t.id,y):!p&&t?.custom_icon&&(F=await ue.deleteExternalLinkIcon(t.id)),F},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:U=>{M(U.message)}}),C=U=>{const F=U.target.files?.[0];if(F){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(F.type)){M("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(F.size>1024*1024){M("Image file must be less than 1MB");return}v(F),m(!0);const j=new FileReader;j.onload=$=>{b($.target?.result)},j.readAsDataURL(F)}},k=()=>{v(null),b(null),m(!1),a.current&&(a.current.value="")},R=U=>{if(U.preventDefault(),M(null),!o.trim()){M("Name is required");return}if(!c.trim()){M("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){M("URL must start with http:// or https://");return}const F={name:o.trim(),url:c.trim(),icon:d};i?E.mutate(F):T.mutate(F)},A=T.isPending||E.isPending,D=y2(d);return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:U=>U.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:p&&x?s.jsx("img",{src:x,alt:"",className:`w-5 h-5 rounded ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):s.jsx(D,{className:"w-5 h-5"})}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Link":"Add External Link"})]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:R,className:"p-6 space-y-4",children:[S&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:S}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:o,onChange:U=>l(U.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"URL *"}),s.jsx("input",{type:"text",value:c,onChange:U=>u(U.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"})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("label",{className:"block text-sm text-bambu-gray",children:"Icon"}),s.jsxs("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-white",children:"Custom Icon"}),s.jsx("input",{ref:a,type:"file",accept:"image/png,image/jpeg,image/gif,image/svg+xml,image/webp,image/x-icon",className:"hidden",onChange:C}),p&&x?s.jsxs("div",{className:"flex items-center gap-2",children:[s.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"}`}),s.jsx("button",{type:"button",onClick:k,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:s.jsx(rn,{className:"w-4 h-4"})})]}):s.jsxs(Te,{type:"button",variant:"secondary",size:"sm",onClick:()=>a.current?.click(),children:[s.jsx(Ua,{className:"w-4 h-4"}),"Upload"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"PNG, JPG, GIF, SVG, WebP, or ICO. Max 1MB."})]}),!p&&s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),s.jsx(Sfe,{value:d,onChange:f})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Te,{type:"submit",disabled:A,className:"flex-1",children:[A?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(hs,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function gKe(){const t=an(),[e,n]=_.useState(!1),[r,i]=_.useState(null),[a,o]=_.useState(null),[l,c]=_.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"]})}}),p=mt({mutationFn:S=>ue.reorderExternalLinks(S),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),m=(S,M)=>{c(M),S.dataTransfer.effectAllowed="move"},x=S=>{S.preventDefault(),S.dataTransfer.dropEffect="move"},b=(S,M)=>{if(S.preventDefault(),l===null||l===M||!u)return;const T=u.map(R=>R.id),E=T.indexOf(l),C=T.indexOf(M);if(E===-1||C===-1)return;const k=[...T];k.splice(E,1),k.splice(C,0,l),p.mutate(k),c(null)},y=S=>{o(S)},v=()=>{a&&(f.mutate(a.id),o(null))};return s.jsxs(s.Fragment,{children:[s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(uc,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),s.jsxs(Te,{size:"sm",onClick:()=>n(!0),children:[s.jsx(ur,{className:"w-4 h-4"}),"Add Link"]})]})}),s.jsxs(Nt,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Add external links to the sidebar navigation. Drag to reorder."}),d?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?s.jsx("div",{className:"space-y-2",children:u.map(S=>{const M=y2(S.icon);return s.jsxs("div",{draggable:!0,onDragStart:T=>m(T,S.id),onDragOver:x,onDrop:T=>b(T,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:[s.jsx(zg,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0"}),s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray",children:s.jsx(M,{className:"w-4 h-4"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-white font-medium truncate",children:S.name}),s.jsx(Kr,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),s.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:S.url})]}),s.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[s.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:s.jsx(Qi,{className:"w-4 h-4"})}),s.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:s.jsx(rn,{className:"w-4 h-4"})})]})]},S.id)})}):s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(uc,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),s.jsx("p",{children:"No external links configured"}),s.jsx("p",{className:"text-sm",children:'Click "Add Link" to add one'})]})]})]}),(e||r)&&s.jsx(pKe,{link:r,onClose:()=>{n(!1),i(null)}}),a&&s.jsx(Qn,{title:"Delete Link",message:`Are you sure you want to delete "${a.name}"? This action cannot be undone.`,confirmText:"Delete",cancelText:"Cancel",variant:"danger",onConfirm:v,onCancel:()=>o(null)})]})}function xKe(){const t=an(),{showToast:e}=Hn(),[n,r]=_.useState(!1),[i,a]=_.useState(""),[o,l]=_.useState("immediate"),[c,u]=_.useState("3DPrinter-X1-Carbon"),[d,f]=_.useState(!1),[p,m]=_.useState(null),{data:x,isLoading:b}=at({queryKey:["virtual-printer-settings"],queryFn:p1.getSettings,refetchInterval:1e4}),{data:y}=at({queryKey:["virtual-printer-models"],queryFn:p1.getModels});_.useEffect(()=>{if(x){r(x.enabled);let R=x.mode==="queue"?"review":x.mode;R!=="immediate"&&R!=="review"&&R!=="print_queue"&&(R="immediate"),l(R),u(x.model)}},[x]);const v=mt({mutationFn:R=>p1.updateSettings(R),onSuccess:()=>{t.invalidateQueries({queryKey:["virtual-printer-settings"]}),e("Virtual printer settings updated"),m(null)},onError:R=>{if(e(R.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)}m(null)}}),S=()=>{const R=!n;if(R&&!i&&!x?.access_code_set){e("Please set an access code first","error");return}r(R),m("toggle"),v.mutate({enabled:R,access_code:i||void 0,mode:o})},M=()=>{if(!i){e("Access code cannot be empty","error");return}if(i.length!==8){e("Access code must be exactly 8 characters","error");return}m("accessCode"),v.mutate({access_code:i}),a("")},T=R=>{l(R),m("mode"),v.mutate({mode:R})},E=R=>{u(R),m("model"),v.mutate({model:R})};if(b)return s.jsx(_t,{children:s.jsx(Nt,{className:"py-8 flex justify-center",children:s.jsx(ht,{className:"w-6 h-6 animate-spin text-bambu-green"})})});const C=x?.status,k=C?.running||!1;return s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[s.jsx("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ur,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Virtual Printer"})]}),C&&s.jsxs("div",{className:`flex items-center gap-2 text-sm ${k?"text-green-400":"text-bambu-gray"}`,children:[s.jsx("span",{className:`w-2 h-2 rounded-full ${k?"bg-green-400 animate-pulse":"bg-gray-500"}`}),k?"Running":"Stopped"]})]})}),s.jsxs(Nt,{className:"space-y-4",children:[s.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."}),s.jsxs("div",{className:"flex items-center justify-between py-3 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-white font-medium",children:"Enable Virtual Printer"}),s.jsx("div",{className:"text-sm text-bambu-gray",children:k?'Visible as "Bambuddy" in slicer discovery':"Not visible to slicers"})]}),s.jsx("button",{onClick:S,disabled:p==="toggle",className:`relative w-12 h-6 rounded-full transition-colors ${n?"bg-bambu-green":"bg-bambu-dark-tertiary"} ${p==="toggle"?"opacity-50":""}`,children:s.jsx("span",{className:`absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform ${n?"translate-x-6":""}`})})]}),s.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-white font-medium mb-2",children:"Printer Model"}),s.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:"Select which printer model to emulate."}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{value:c,onChange:R=>E(R.target.value),disabled:p==="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(([,R],[,A])=>R.localeCompare(A)).map(([R,A])=>s.jsx("option",{value:R,children:A},R))}),s.jsx(ei,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),n&&k&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[s.jsx(Zo,{className:"w-3 h-3 inline mr-1"}),"Changing the model will restart the virtual printer"]})]}),s.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-white font-medium mb-2",children:"Access Code"}),s.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:x?.access_code_set?s.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[s.jsx(Ia,{className:"w-4 h-4"}),"Access code is set"]}):s.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[s.jsx(Cn,{className:"w-4 h-4"}),"No access code set - required to enable"]})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx("input",{type:d?"text":"password",value:i,onChange:R=>a(R.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"}),s.jsx("button",{onClick:()=>f(!d),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:d?s.jsx(l2,{className:"w-4 h-4"}):s.jsx(Ru,{className:"w-4 h-4"})})]}),s.jsx(Te,{onClick:M,disabled:!i||p==="accessCode",variant:"primary",children:p==="accessCode"?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):"Save"})]}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["Must be exactly 8 characters. Used by slicers to authenticate.",i&&s.jsxs("span",{className:i.length===8?"text-green-400":"text-yellow-400",children:[" ","(",i.length,"/8)"]})]})]}),s.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-white font-medium mb-2",children:"Mode"}),s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("button",{onClick:()=>T("immediate"),disabled:p==="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:[s.jsx("div",{className:"text-white font-medium",children:"Archive"}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Archive files immediately"})]}),s.jsxs("button",{onClick:()=>T("review"),disabled:p==="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:[s.jsx("div",{className:"text-white font-medium",children:"Review"}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Review and tag before archiving"})]}),s.jsxs("button",{onClick:()=>T("print_queue"),disabled:p==="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:[s.jsx("div",{className:"text-white font-medium",children:"Queue"}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Archive and add to print queue"})]})]})]})]})]})}),s.jsxs("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:[s.jsx(_t,{className:"border-l-4 border-l-yellow-500",children:s.jsx(Nt,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Cn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"text-white font-medium mb-2",children:"Setup Required"}),s.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."}),s.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:[s.jsx(Kr,{className:"w-4 h-4"}),"Read the setup guide before enabling"]})]})]})})}),s.jsx(_t,{children:s.jsx(Nt,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Zo,{className:"w-5 h-5 text-blue-400 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:s.jsx("strong",{className:"text-white",children:"How it works:"})}),s.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[s.jsx("li",{children:"Complete the setup guide for your platform"}),s.jsx("li",{children:"Enable the virtual printer and set an access code"}),s.jsx("li",{children:'In Bambu Studio or OrcaSlicer, go to "Add Printer"'}),s.jsx("li",{children:'The "Bambuddy" printer should appear in the discovery list'}),s.jsx("li",{children:"Connect using the access code you set"}),s.jsx("li",{children:'When you "print" to Bambuddy, the 3MF file is archived instead'})]})]})]})})}),C&&k&&s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsx("h3",{className:"text-md font-semibold text-white",children:"Status Details"})}),s.jsx(Nt,{children:s.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Printer Name"}),s.jsx("div",{className:"text-white",children:C.name})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Model"}),s.jsx("div",{className:"text-white",children:C.model_name||C.model})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Serial Number"}),s.jsx("div",{className:"text-white font-mono",children:C.serial})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Mode"}),s.jsx("div",{className:"text-white capitalize",children:C.mode})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Pending Files"}),s.jsx("div",{className:"text-white",children:C.pending_files})]})]})})]})]})]})}function fq({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:s.jsx(Ar,{className:"w-3 h-3"}),failed:s.jsx(Yi,{className:"w-3 h-3"}),skipped:s.jsx(DR,{className:"w-3 h-3"}),running:s.jsx(ht,{className:"w-3 h-3 animate-spin"})};return s.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 bKe(t){return t?new Date(t).toLocaleString():"-"}function mq(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 a=Math.abs(i);if(a<60)return`${a}m ago`;const o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}else{if(i<60)return`in ${i}m`;const a=Math.floor(i/60);return a<24?`in ${a}h`:`in ${Math.floor(a/24)}d`}}function yKe(){const t=an(),{showToast:e}=Hn(),[n,r]=_.useState(""),[i,a]=_.useState(""),[o,l]=_.useState("main"),[c,u]=_.useState(!1),[d,f]=_.useState("daily"),[p,m]=_.useState(!0),[x,b]=_.useState(!0),[y,v]=_.useState(!1),[S,M]=_.useState(!0),[T,E]=_.useState(!1),[C,k]=_.useState(!1),[R,A]=_.useState(""),[D,U]=_.useState(!1),[F,H]=_.useState(null),[j,$]=_.useState(null),K=_.useRef(null);_.useEffect(()=>{if(T||C){const ke=z=>(z.preventDefault(),z.returnValue="A backup operation is in progress. Are you sure you want to leave?",z.returnValue);return window.addEventListener("beforeunload",ke),()=>window.removeEventListener("beforeunload",ke)}},[T,C]);const[V,Q]=_.useState(!1),[Z,ae]=_.useState(null),B=_.useRef(null),X=_.useRef(!1),{data:ne,isLoading:se}=at({queryKey:["github-backup-config"],queryFn:ue.getGitHubBackupConfig}),{data:be}=at({queryKey:["github-backup-status"],queryFn:ue.getGitHubBackupStatus,refetchInterval:me=>me.state.data?.is_running?500:1e4}),{data:xe}=at({queryKey:["github-backup-logs"],queryFn:()=>ue.getGitHubBackupLogs(20)}),{data:de}=at({queryKey:["cloud-status"],queryFn:ue.getCloudStatus}),{data:Pe}=at({queryKey:["printers"],queryFn:ue.getPrinters}),ie=dW({queries:(Pe??[]).map(me=>({queryKey:["printerStatus",me.id],queryFn:()=>ue.getPrinterStatus(me.id),staleTime:1e4,refetchInterval:3e4}))}),Me=(Pe??[]).map((me,ke)=>({printer:me,connected:ie[ke]?.data?.connected??!1})),Oe=Me.length,ge=Me.filter(me=>me.connected).length,Ke=Oe>0&&ge===0,G=ge>0&&ge<Oe;_.useEffect(()=>{ne&&(r(ne.repository_url),l(ne.branch),u(ne.schedule_enabled),f(ne.schedule_type),m(ne.backup_kprofiles),b(ne.backup_cloud_profiles),v(ne.backup_settings),M(ne.enabled),a(""),setTimeout(()=>{X.current=!0},100))},[ne]);const Y=_.useCallback(async(me=!1)=>{if(ne?.has_token)try{me&&i?(await ue.saveGitHubBackupConfig({repository_url:n,access_token:i,branch:o,schedule_enabled:c,schedule_type:d,backup_kprofiles:p,backup_cloud_profiles:x,backup_settings:y,enabled:S}),a(""),e("Token updated")):(await ue.updateGitHubBackupConfig({repository_url:n,branch:o,schedule_enabled:c,schedule_type:d,backup_kprofiles:p,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(ke){e(`Failed to save: ${ke.message}`,"error")}},[ne?.has_token,n,i,o,c,d,p,x,y,S,t,e]);_.useEffect(()=>{if(!(!X.current||!ne?.has_token))return B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{Y(!1)},500),()=>{B.current&&clearTimeout(B.current)}},[n,o,c,d,p,x,y,S,Y,ne?.has_token]),_.useEffect(()=>{if(!(!X.current||!ne?.has_token||!i))return B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{Y(!0)},1e3),()=>{B.current&&clearTimeout(B.current)}},[i,Y,ne?.has_token]);const ce=mt({mutationFn:me=>ue.saveGitHubBackupConfig(me),onSuccess:()=>{t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]}),e("GitHub backup enabled"),a(""),X.current=!0},onError:me=>{e(`Failed to save: ${me.message}`,"error")}}),q=mt({mutationFn:ue.triggerGitHubBackup,onSuccess:me=>{t.invalidateQueries({queryKey:["github-backup-status"]}),t.invalidateQueries({queryKey:["github-backup-logs"]}),me.success?me.files_changed>0?e(`Backup complete - ${me.files_changed} files updated`):e("Backup skipped - no changes"):e(`Backup failed: ${me.message}`,"error")},onError:me=>{e(`Backup failed: ${me.message}`,"error")}}),te=mt({mutationFn:()=>ue.clearGitHubBackupLogs(0),onSuccess:me=>{t.invalidateQueries({queryKey:["github-backup-logs"]}),e(`Cleared ${me.deleted} logs`)},onError:me=>{e(`Failed to clear logs: ${me.message}`,"error")}}),I=async()=>{Q(!0),ae(null);try{let me;if(i){if(!n){e("Enter repository URL","error"),Q(!1);return}me=await ue.testGitHubConnection(n,i)}else if(ne?.has_token)me=await ue.testGitHubStoredConnection();else{e("Enter repository URL and access token","error"),Q(!1);return}ae({success:me.success,message:me.message})}catch(me){ae({success:!1,message:me.message})}finally{Q(!1)}},fe=()=>{if(!n){e("Repository URL is required","error");return}if(!i){e("Access token is required","error");return}ce.mutate({repository_url:n,access_token:i,branch:o,schedule_enabled:c,schedule_type:d,backup_kprofiles:p,backup_cloud_profiles:x,backup_settings:y,enabled:S})};return se?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(ht,{className:"w-8 h-8 animate-spin text-bambu-green"})}):s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-6",children:[s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(fP,{className:"w-5 h-5 text-gray-400"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"GitHub Backup"})]}),ne&&de?.is_authenticated&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Enabled"}),s.jsx(On,{checked:S,onChange:M})]})]})}),s.jsx(Nt,{className:"space-y-4",children:de?.is_authenticated?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically sync your profiles to a private GitHub repository for backup and version history."}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Repository URL"}),s.jsx("input",{type:"text",value:n,onChange:me=>{r(me.target.value),ae(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"})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:["Personal Access Token ",ne?.has_token&&s.jsx("span",{className:"text-green-400",children:"(saved)"})]}),s.jsx("input",{type:"password",value:i,onChange:me=>{a(me.target.value),ae(null)},placeholder:ne?.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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Fine-grained token with Contents read/write permission"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Branch"}),s.jsx("input",{type:"text",value:o,onChange:me=>l(me.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Auto-backup"}),s.jsxs("select",{value:c?d:"disabled",onChange:me=>{me.target.value==="disabled"?u(!1):(u(!0),f(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",children:[s.jsx("option",{value:"disabled",children:"Manual only"}),s.jsx("option",{value:"hourly",children:"Hourly"}),s.jsx("option",{value:"daily",children:"Daily"}),s.jsx("option",{value:"weekly",children:"Weekly"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Include in backup"}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:`flex items-start gap-2 ${Ke?"cursor-not-allowed opacity-60":"cursor-pointer"}`,children:[s.jsx("input",{type:"checkbox",checked:p,onChange:me=>m(me.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:Ke}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`text-sm ${Ke?"text-bambu-gray":"text-white"}`,children:"K-Profiles"}),Ke&&s.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:[s.jsx(Cn,{className:"w-3 h-3"}),"No printers connected"]}),G&&s.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:[s.jsx(Cn,{className:"w-3 h-3"}),ge,"/",Oe," connected"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Pressure advance calibration from connected printers"})]})]}),s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:x,onChange:me=>b(me.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:!de?.is_authenticated}),s.jsxs("div",{children:[s.jsx("span",{className:`text-sm ${de?.is_authenticated?"text-white":"text-bambu-gray"}`,children:"Cloud Profiles"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament, printer, and process presets from Bambu Cloud"})]})]}),s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:y,onChange:me=>v(me.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"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white text-sm",children:"App Settings"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Bambuddy configuration (excludes sensitive data)"})]})]})]})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 space-y-3",children:[be?.configured&&s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("div",{className:"flex items-center gap-2 text-bambu-gray",children:be.last_backup_at?s.jsxs(s.Fragment,{children:[s.jsxs("span",{children:["Last backup: ",mq(be.last_backup_at)]}),s.jsx(fq,{status:be.last_backup_status})]}):s.jsx("span",{children:"No backups yet"})}),be.next_scheduled_run&&s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx(Jn,{className:"w-3 h-3 inline mr-1"}),"Next: ",mq(be.next_scheduled_run)]})]}),Z&&s.jsxs("div",{className:`text-sm flex items-center gap-1 ${Z.success?"text-green-400":"text-red-400"}`,children:[Z.success?s.jsx(Ar,{className:"w-4 h-4"}):s.jsx(Yi,{className:"w-4 h-4"}),Z.message]}),s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:be?.configured?s.jsx(s.Fragment,{children:q.isPending||be.is_running?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-green",children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),s.jsx("span",{className:"text-sm",children:be.progress||"Starting backup..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs(Te,{variant:"primary",size:"sm",onClick:()=>q.mutate(),disabled:!ne?.enabled,children:[s.jsx(Is,{className:"w-4 h-4"}),"Backup Now"]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:I,disabled:V,children:[V?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Dr,{className:"w-4 h-4"}),"Test"]})]})}):s.jsxs(s.Fragment,{children:[s.jsxs(Te,{variant:"primary",size:"sm",onClick:fe,disabled:ce.isPending||!n||!i,children:[ce.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Ar,{className:"w-4 h-4"}),"Enable Backup"]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:I,disabled:V||!n||!i,children:[V?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Dr,{className:"w-4 h-4"}),"Test Connection"]})]})})]})]}):s.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[s.jsx(Cn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),s.jsx("p",{className:"text-sm text-yellow-400",children:"Bambu Cloud login required. Sign in under Profiles → Cloud Profiles to enable GitHub backup."})]})})]}),xe&&xe.length>0&&s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(q0,{className:"w-5 h-5 text-gray-400"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"History"})]}),s.jsxs(Te,{variant:"ghost",size:"sm",onClick:()=>te.mutate(),disabled:te.isPending,children:[s.jsx(rn,{className:"w-4 h-4"}),"Clear"]})]})}),s.jsx(Nt,{children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"text-bambu-gray border-b border-bambu-dark-tertiary",children:[s.jsx("th",{className:"text-left py-2 px-2",children:"Date"}),s.jsx("th",{className:"text-left py-2 px-2",children:"Status"}),s.jsx("th",{className:"text-left py-2 px-2",children:"Commit"})]})}),s.jsx("tbody",{children:xe.slice(0,10).map(me=>s.jsxs("tr",{className:"border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-secondary",children:[s.jsx("td",{className:"py-2 px-2 text-white",children:bKe(me.started_at)}),s.jsx("td",{className:"py-2 px-2",children:s.jsx(fq,{status:me.status})}),s.jsx("td",{className:"py-2 px-2",children:me.commit_sha?s.jsxs("a",{href:`${ne?.repository_url}/commit/${me.commit_sha}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline inline-flex items-center gap-1",children:[me.commit_sha.substring(0,7),s.jsx(Kr,{className:"w-3 h-3"})]}):s.jsx("span",{className:"text-bambu-gray",children:"-"})})]},me.id))})]})})})]})]}),s.jsx("div",{className:"space-y-6",children:s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Mu,{className:"w-5 h-5 text-gray-400"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Local Backup"})]})}),s.jsxs(Nt,{className:"space-y-4",children:[s.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."}),s.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Download Backup"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Complete backup: database + all files (ZIP)"})]}),s.jsxs(Te,{variant:"secondary",size:"sm",disabled:T||C,onClick:async()=>{E(!0),A("Preparing backup...");try{A("Creating backup archive... This may take a while for large archives.");const{blob:me,filename:ke}=await ue.exportBackup();A("Downloading backup file...");const z=URL.createObjectURL(me),O=document.createElement("a");O.href=z,O.download=ke,O.click(),URL.revokeObjectURL(z),e("Backup downloaded successfully")}catch(me){e(`Failed to create backup: ${me instanceof Error?me.message:"Unknown error"}`,"error")}finally{E(!1),A("")}},children:[s.jsx(yi,{className:"w-4 h-4"}),"Download"]})]}),s.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Restore Backup"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Replace all data from a backup file"})]}),s.jsx("input",{ref:K,type:"file",accept:".zip",className:"hidden",onChange:me=>{const ke=me.target.files?.[0];ke&&(H(ke),U(!0)),me.target.value=""}}),s.jsxs(Te,{variant:"secondary",size:"sm",disabled:C||T,onClick:()=>K.current?.click(),children:[s.jsx(Ua,{className:"w-4 h-4"}),"Restore"]})]}),j&&s.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:s.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[j.success?s.jsx(Ar,{className:"w-4 h-4 text-green-400 mt-0.5 flex-shrink-0"}):s.jsx(Yi,{className:"w-4 h-4 text-red-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:j.success?"text-green-200":"text-red-200",children:[j.message,j.success&&s.jsx("div",{className:"mt-2",children:s.jsxs(Te,{size:"sm",onClick:()=>window.location.reload(),children:[s.jsx(Rh,{className:"w-3 h-3"}),"Reload Now"]})})]})]})}),s.jsx("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:s.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[s.jsx(Cn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-yellow-200",children:[s.jsx("span",{className:"font-medium",children:"Restore replaces all data."})," ",s.jsx("span",{className:"text-yellow-200/70",children:"Your current database and files will be completely replaced. A restart is required after restore."})]})]})})]})]})}),D&&F&&s.jsx(Qn,{title:"Restore Backup",message:`Are you sure you want to restore from "${F.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()=>{U(!1),k(!0),$(null);try{A("Uploading backup file...");const me=await ue.importBackup(F);$(me),me.success?e("Backup restored. Please restart Bambuddy.","success"):e(me.message,"error")}catch(me){const ke=me instanceof Error?me.message:"Failed to restore backup";$({success:!1,message:ke}),e(ke,"error")}finally{k(!1),A(""),H(null)}},onCancel:()=>{U(!1),H(null)}}),(T||C)&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[100]",children:s.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:[s.jsx("div",{className:"flex justify-center mb-4",children:s.jsxs("div",{className:"relative",children:[s.jsx("div",{className:"w-16 h-16 border-4 border-bambu-dark-tertiary rounded-full"}),s.jsx("div",{className:"w-16 h-16 border-4 border-bambu-green border-t-transparent rounded-full absolute inset-0 animate-spin"})]})}),s.jsx("h3",{className:"text-xl font-semibold text-white mb-2",children:T?"Creating Backup":"Restoring Backup"}),s.jsx("p",{className:"text-bambu-gray mb-4",children:R||(T?"Preparing...":"Processing...")}),s.jsx("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:s.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[s.jsx(Cn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),s.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 vKe={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 wKe(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,wKe(t,e.$ref),n+1);if(e.allOf){const r={};for(const i of e.allOf){const a=p0(t,i,n+1);typeof a=="object"&&a!==null&&Object.assign(r,a)}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,a]of Object.entries(e.properties))r[i]=p0(t,a,n+1);return r}return{};default:return null}}function _Ke({path:t,method:e,spec:n,schema:r,apiKey:i}){const[a,o]=_.useState(!1),[l,c]=_.useState({}),[u,d]=_.useState(""),[f,p]=_.useState(null),[m,x]=_.useState(!1),[b,y]=_.useState(!1);_.useEffect(()=>{if(a&&n.parameters){const R={};for(const A of n.parameters)A.schema?.default!==void 0&&(R[A.name]=String(A.schema.default));c(A=>({...R,...A}))}},[a,n.parameters]),_.useEffect(()=>{if(a&&n.requestBody?.content?.["application/json"]?.schema&&!u){const R=n.requestBody.content["application/json"].schema,A=p0(r,R);d(JSON.stringify(A,null,2))}},[a,n.requestBody,r,u]);const S=(()=>{const R=[];for(const A of n.parameters||[])if(A.in==="path"||A.required){const D=l[A.name];(D===void 0||D==="")&&R.push(A.name)}return R})(),M=async()=>{if(S.length>0){p({status:0,statusText:"Validation Error",headers:{},body:`Missing required parameters: ${S.join(", ")}`,duration:0});return}x(!0),p(null);try{let R=t;const A=new URLSearchParams;for(const ae of n.parameters||[]){const B=l[ae.name];B!==void 0&&B!==""&&(ae.in==="path"?R=R.replace(`{${ae.name}}`,encodeURIComponent(B)):ae.in==="query"&&A.append(ae.name,B))}const D=A.toString(),U=`${R}${D?`?${D}`:""}`,F={"Content-Type":"application/json"};i&&(F["X-API-Key"]=i);const H={method:e.toUpperCase(),headers:F};["post","put","patch"].includes(e)&&u&&(H.body=u);const j=performance.now(),$=await fetch(U,H),K=Math.round(performance.now()-j),V={};$.headers.forEach((ae,B)=>{V[B]=ae});let Q;$.headers.get("content-type")?.includes("application/json")?Q=await $.json():Q=await $.text(),p({status:$.status,statusText:$.statusText,headers:V,body:Q,duration:K})}catch(R){p({status:0,statusText:"Network Error",headers:{},body:R instanceof Error?R.message:"Unknown error",duration:0})}finally{x(!1)}},T=async()=>{if(f){const R=typeof f.body=="string"?f.body:JSON.stringify(f.body,null,2);try{await navigator.clipboard.writeText(R),y(!0),setTimeout(()=>y(!1),2e3)}catch{const A=document.createElement("textarea");A.value=R,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)}}},E=(n.parameters||[]).filter(R=>R.in==="path"),C=(n.parameters||[]).filter(R=>R.in==="query"),k=["post","put","patch"].includes(e)&&n.requestBody;return s.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[s.jsxs("button",{onClick:()=>o(!a),className:"w-full flex items-center gap-3 p-3 hover:bg-bambu-dark-tertiary/50 transition-colors text-left",children:[a?s.jsx(ei,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}):s.jsx(gs,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:`px-2 py-0.5 text-xs font-mono font-semibold uppercase rounded border ${vKe[e]||"bg-gray-500/20 text-gray-400"}`,children:e}),s.jsx("code",{className:"text-sm text-white font-mono flex-1 truncate",children:t}),n.summary&&s.jsx("span",{className:"text-sm text-bambu-gray truncate max-w-[40%]",children:n.summary})]}),a&&s.jsxs("div",{className:"border-t border-bambu-dark-tertiary p-4 space-y-4 bg-bambu-dark/50",children:[n.description&&s.jsx("p",{className:"text-sm text-bambu-gray",children:n.description}),E.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-white",children:"Path Parameters"}),s.jsx("div",{className:"space-y-2",children:E.map(R=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[R.name,R.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),s.jsx("input",{type:"text",value:l[R.name]||"",onChange:A=>c(D=>({...D,[R.name]:A.target.value})),placeholder:R.description||R.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"})]},R.name))})]}),C.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-white",children:"Query Parameters"}),s.jsx("div",{className:"space-y-2",children:C.map(R=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[R.name,R.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),R.schema?.enum?s.jsxs("select",{value:l[R.name]||"",onChange:A=>c(D=>({...D,[R.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:[s.jsx("option",{value:"",children:"-- Select --"}),R.schema.enum.map(A=>s.jsx("option",{value:A,children:A},A))]}):s.jsx("input",{type:"text",value:l[R.name]||"",onChange:A=>c(D=>({...D,[R.name]:A.target.value})),placeholder:R.description||R.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"})]},R.name))})]}),k&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-white",children:"Request Body"}),s.jsx("textarea",{value:u,onChange:R=>d(R.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..."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Te,{onClick:M,disabled:m,children:[m?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Is,{className:"w-4 h-4"}),"Execute"]}),S.length>0&&s.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[s.jsx($i,{className:"w-3 h-3"}),"Fill in: ",S.join(", ")]})]}),f&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h4",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Response",s.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]}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[f.duration,"ms"]})]}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:T,children:b?s.jsx(Ar,{className:"w-3 h-3 text-green-400"}):s.jsx(Fl,{className:"w-3 h-3"})})]}),s.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 SKe({apiKey:t=""}){const[e,n]=_.useState(null),[r,i]=_.useState(!0),[a,o]=_.useState(null),[l,c]=_.useState(new Set),[u,d]=_.useState("");if(_.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 s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(a||!e)return s.jsx(_t,{children:s.jsx(Nt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-red-400",children:[s.jsx($i,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),s.jsx("p",{children:"Failed to load API schema"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:a})]})})});const f={};for(const[y,v]of Object.entries(e.paths))for(const[S,M]of Object.entries(v)){if(S==="parameters")continue;const T=M.tags||["Other"];for(const E of T)f[E]||(f[E]=[]),f[E].push({path:y,method:S,spec:M})}const p=Object.entries(f).map(([y,v])=>{if(!u)return{tag:y,endpoints:v};const S=v.filter(({path:M,method:T,spec:E})=>{const C=u.toLowerCase();return M.toLowerCase().includes(C)||T.toLowerCase().includes(C)||(E.summary?.toLowerCase()||"").includes(C)||(E.description?.toLowerCase()||"").includes(C)});return{tag:y,endpoints:S}}).filter(({endpoints:y})=>y.length>0).sort((y,v)=>y.tag.localeCompare(v.tag)),m=y=>{c(v=>{const S=new Set(v);return S.has(y)?S.delete(y):S.add(y),S})},x=()=>{c(new Set(p.map(y=>y.tag)))},b=()=>{c(new Set)};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("div",{className:"flex-1",children:s.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"})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Te,{variant:"secondary",size:"sm",onClick:x,children:"Expand All"}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:b,children:"Collapse All"}),s.jsxs("a",{href:"/docs",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-sm text-bambu-green hover:underline",children:[s.jsx(Kr,{className:"w-4 h-4"}),"Swagger UI"]})]})]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[p.reduce((y,v)=>y+v.endpoints.length,0)," endpoints in ",p.length," categories"]}),s.jsx("div",{className:"space-y-3",children:p.map(({tag:y,endpoints:v})=>s.jsxs(_t,{children:[s.jsx("button",{onClick:()=>m(y),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/30 transition-colors text-left",children:s.jsxs("div",{className:"flex items-center gap-2",children:[l.has(y)?s.jsx(ei,{className:"w-5 h-5 text-bambu-gray"}):s.jsx(gs,{className:"w-5 h-5 text-bambu-gray"}),s.jsx("h3",{className:"text-base font-semibold text-white capitalize",children:y.replace(/-/g," ")}),s.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)&&s.jsx(Nt,{className:"pt-0 space-y-2",children:v.map(({path:S,method:M,spec:T})=>s.jsx(_Ke,{path:S,method:M,spec:T,schema:e,apiKey:t},`${M}-${S}`))})]},y))})]})}const NKe=["general","network","plugs","notifications","filament","apikeys","virtual-printer","users","backup"];function MKe(){const t=an(),e=Mc(),[n,r]=wR(),{t:i,i18n:a}=$n(),{showToast:o}=Hn(),{authEnabled:l,user:c,refreshAuth:u}=Ai(),{mode:d,darkStyle:f,darkBackground:p,darkAccent:m,lightStyle:x,lightBackground:b,lightAccent:y,setDarkStyle:v,setDarkBackground:S,setDarkAccent:M,setLightStyle:T,setLightBackground:E,setLightAccent:C}=Oh(),[k,R]=_.useState(null),[A,D]=_.useState(!1),[U,F]=_.useState(null),[H,j]=_.useState(!1),[$,K]=_.useState(null),[V,Q]=_.useState(null),[Z,ae]=_.useState(!1),[B,X]=_.useState(OW()),ne=n.get("tab"),se=ne&&NKe.includes(ne)?ne:"general",[be,xe]=_.useState(se),de=oe=>{xe(oe),oe==="general"?n.delete("tab"):n.set("tab",oe),r(n,{replace:!0})},[Pe,ie]=_.useState(!1),[Me,Oe]=_.useState(""),[ge,Ke]=_.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[G,Y]=_.useState(null),[ce,q]=_.useState(null),[te,I]=_.useState(""),[fe,me]=_.useState(!1),[ke,z]=_.useState(!1),[O,ee]=_.useState(null),[le,_e]=_.useState(!1),[we,re]=_.useState(!1),[Fe,$e]=_.useState(!1),[Ve,He]=_.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[ye,je]=_.useState(!1),[Be,Se]=_.useState(!1),[Xe,Ne]=_.useState(!1),[tt,Ee]=_.useState(null),[We,ze]=_.useState(null),[W,De]=_.useState(null),[Ye,xt]=_.useState(!1),[ft,Bt]=_.useState({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]}),[Lt,vn]=_.useState(!1),[Jt,rr]=_.useState(null),[hr,Dn]=_.useState(null),[ln,fr]=_.useState({name:"",description:"",permissions:[]}),[Fn,Kn]=_.useState(new Set),[bn,wi]=_.useState(null),[Ba,Ae]=_.useState(!1),[Ze,st]=_.useState({}),[lt,ot]=_.useState({}),kt=oe=>{X(oe),Cfe(oe),o(i("settings.toast.settingsSaved"),"success")},he=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:pe,isLoading:Ie}=at({queryKey:["settings"],queryFn:ue.getSettings}),{data:Le,isLoading:Ce}=at({queryKey:["smart-plugs"],queryFn:ue.getSmartPlugs}),{data:ut,isLoading:St}=at({queryKey:["smart-plugs-energy",Le?.map(oe=>oe.id)],queryFn:async()=>{if(!Le||Le.length===0)return null;const oe=await Promise.all(Le.filter(is=>is.enabled).map(async is=>{try{const as=await ue.getSmartPlugStatus(is.id);return{plug:is,status:as}}catch{return{plug:is,status:null}}}));let wt=0,Rn=0,Zn=0,Mo=0,Ju=0;for(const{plug:is,status:as}of oe){const Hx=is.plug_type==="mqtt"&&as?.energy?.power!=null;(as?.reachable||Hx)&&as?.energy&&(Ju++,as.energy?.power!=null&&(wt+=as.energy.power),as.energy?.today!=null&&(Rn+=as.energy.today),as.energy?.yesterday!=null&&(Zn+=as.energy.yesterday),as.energy?.total!=null&&(Mo+=as.energy.total))}return{totalPower:wt,totalToday:Rn,totalYesterday:Zn,totalLifetime:Mo,reachableCount:Ju,totalPlugs:Le.filter(is=>is.enabled).length}},enabled:be==="plugs"&&!!Le&&Le.length>0,refetchInterval:be==="plugs"?1e4:!1}),{data:At,isLoading:Tt}=at({queryKey:["notification-providers"],queryFn:ue.getNotificationProviders}),{data:Ft,isLoading:Pt}=at({queryKey:["api-keys"],queryFn:ue.getAPIKeys}),Mt=mt({mutationFn:oe=>ue.createAPIKey(oe),onSuccess:oe=>{Y(oe.key||null),ie(!1),Oe(""),t.invalidateQueries({queryKey:["api-keys"]}),o(i("settings.toast.apiKeyCreated"))},onError:oe=>{o(`Failed to create API key: ${oe.message}`,"error")}}),en=mt({mutationFn:oe=>ue.deleteAPIKey(oe),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),o(i("settings.toast.apiKeyDeleted"))},onError:oe=>{o(`Failed to delete API key: ${oe.message}`,"error")}}),{data:$t}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:dn,isLoading:cn}=at({queryKey:["notification-templates"],queryFn:ue.getNotificationTemplates}),{data:Sn}=at({queryKey:["virtual-printer-settings"],queryFn:p1.getSettings,refetchInterval:1e4}),Gt=Sn?.status?.running??!1,{data:sn}=at({queryKey:["ffmpeg-status"],queryFn:ue.checkFfmpeg}),{data:un}=at({queryKey:["version"],queryFn:ue.getVersion}),{data:Yt,refetch:tr,isRefetching:jn}=at({queryKey:["updateCheck"],queryFn:ue.checkForUpdates,staleTime:300*1e3}),{data:ii,refetch:nr}=at({queryKey:["updateStatus"],queryFn:ue.getUpdateStatus,refetchInterval:oe=>{const wt=oe.state.data;return wt?.status==="downloading"||wt?.status==="installing"?1e3:!1}}),{data:lr}=at({queryKey:["mqtt-status"],queryFn:ue.getMQTTStatus,refetchInterval:be==="network"?5e3:!1}),{data:et}=at({queryKey:["github-backup-status"],queryFn:ue.getGitHubBackupStatus}),{data:jt}=at({queryKey:["cloud-status"],queryFn:ue.getCloudStatus}),{hasPermission:qt}=Ai(),{data:yt=[],isLoading:wn}=at({queryKey:["users"],queryFn:()=>ue.getUsers(),enabled:l&&qt("users:read")}),{data:Fr=[],isLoading:Yr}=at({queryKey:["groups"],queryFn:()=>ue.getGroups(),enabled:l&&qt("groups:read")}),{data:Br}=at({queryKey:["permissions"],queryFn:()=>ue.getPermissions(),enabled:l&&qt("groups:read")}),Ws=mt({mutationFn:oe=>ue.createUser(oe),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),t.invalidateQueries({queryKey:["groups"]}),Se(!1),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]}),o(i("settings.toast.userCreated"))},onError:oe=>{o(oe.message,"error")}}),tn=mt({mutationFn:({id:oe,data:wt})=>ue.updateUser(oe,wt),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),t.invalidateQueries({queryKey:["groups"]}),Ne(!1),Ee(null),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]}),o(i("settings.toast.userUpdated"))},onError:oe=>{o(oe.message,"error")}}),on=mt({mutationFn:({id:oe,deleteItems:wt})=>ue.deleteUser(oe,wt),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),o(i("settings.toast.userDeleted")),ze(null),De(null)},onError:oe=>{o(oe.message,"error")}}),_i=async oe=>{ze(oe),xt(!0);try{const wt=await ue.getUserItemsCount(oe);De(wt)}catch{De({archives:0,queue_items:0,library_files:0})}finally{xt(!1)}},Ss=mt({mutationFn:oe=>ue.createGroup(oe),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),vn(!1),la(),o(i("settings.toast.groupCreated"))},onError:oe=>{o(oe.message,"error")}}),_o=mt({mutationFn:({id:oe,data:wt})=>ue.updateGroup(oe,wt),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),rr(null),la(),o(i("settings.toast.groupUpdated"))},onError:oe=>{o(oe.message,"error")}}),So=mt({mutationFn:oe=>ue.deleteGroup(oe),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),o(i("settings.toast.groupDeleted"))},onError:oe=>{o(oe.message,"error")}}),No=()=>{if(!ft.username||!ft.password){o(i("settings.toast.fillRequiredFields"),"error");return}if(ft.password!==ft.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(ft.password.length<6){o(i("settings.toast.passwordTooShort"),"error");return}Ws.mutate({username:ft.username,password:ft.password,role:ft.role,group_ids:ft.group_ids.length>0?ft.group_ids:void 0})},Ns=oe=>{if(ft.password){if(ft.password!==ft.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(ft.password.length<6){o(i("settings.toast.passwordTooShort"),"error");return}}const wt={username:ft.username||void 0,password:ft.password||void 0,role:ft.role,group_ids:ft.group_ids};wt.password||delete wt.password,tn.mutate({id:oe,data:wt})},Si=oe=>{Ee(oe.id),Bt({username:oe.username,password:"",confirmPassword:"",role:oe.role,group_ids:oe.groups?.map(wt=>wt.id)||[]}),Ne(!0)},Ks=oe=>{Bt(wt=>({...wt,group_ids:wt.group_ids.includes(oe)?wt.group_ids.filter(Rn=>Rn!==oe):[...wt.group_ids,oe]}))},la=()=>{fr({name:"",description:"",permissions:[]}),Kn(new Set)},$r=()=>{if(!ln.name.trim()){o(i("settings.toast.enterGroupName"),"error");return}Ss.mutate({name:ln.name,description:ln.description||void 0,permissions:ln.permissions})},Ux=()=>{if(Jt){if(!ln.name.trim()){o(i("settings.toast.enterGroupName"),"error");return}_o.mutate({id:Jt.id,data:{name:ln.name!==Jt.name?ln.name:void 0,description:ln.description,permissions:ln.permissions}})}},Hh=oe=>{rr(oe),fr({name:oe.name,description:oe.description||"",permissions:oe.permissions});const wt=new Set;Br?.categories.forEach(Rn=>{Rn.permissions.some(Zn=>oe.permissions.includes(Zn.value))&&wt.add(Rn.name)}),Kn(wt)},Hl=oe=>{Kn(wt=>{const Rn=new Set(wt);return Rn.has(oe)?Rn.delete(oe):Rn.add(oe),Rn})},zx=oe=>{fr(wt=>{const Rn=wt.permissions.includes(oe)?wt.permissions.filter(Zn=>Zn!==oe):[...wt.permissions,oe];return{...wt,permissions:Rn}})},Dm=(oe,wt)=>{fr(Rn=>{const Zn=oe.permissions.map(is=>is.value),Mo=Rn.permissions.filter(is=>!Zn.includes(is)),Ju=wt?[...Mo,...Zn]:Mo;return{...Rn,permissions:Ju}})},Rm=oe=>oe.permissions.every(wt=>ln.permissions.includes(wt.value)),Vh=oe=>{const wt=oe.permissions.filter(Rn=>ln.permissions.includes(Rn.value));return wt.length>0&&wt.length<oe.permissions.length},Qu=mt({mutationFn:ue.applyUpdate,onSuccess:oe=>{oe.is_docker?o(oe.message,"error"):nr()}}),[Cc,ca]=_.useState(null),pl=mt({mutationFn:ue.testAllNotificationProviders,onSuccess:oe=>{ca(oe),t.invalidateQueries({queryKey:["notification-providers"]}),oe.failed===0?o(`All ${oe.tested} providers tested successfully!`,"success"):o(`${oe.success}/${oe.tested} providers succeeded`,oe.failed>0?"error":"success")},onError:oe=>{o(`Failed to test providers: ${oe.message}`,"error")}}),Vl=mt({mutationFn:async oe=>{if(!Le)return{success:0,failed:0};const wt=Le.filter(Zn=>Zn.enabled),Rn=await Promise.all(wt.map(async Zn=>{try{return await ue.controlSmartPlug(Zn.id,oe),{success:!0}}catch{return{success:!1}}}));return{success:Rn.filter(Zn=>Zn.success).length,failed:Rn.filter(Zn=>!Zn.success).length}},onSuccess:(oe,wt)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),oe.failed===0?o(`All ${oe.success} plugs turned ${wt}`,"success"):o(`${oe.success} plugs turned ${wt}, ${oe.failed} failed`,"error")},onError:oe=>{o(`Failed: ${oe.message}`,"error")}}),gl=_.useRef(null),Om=_.useRef(!1),Lm=_.useRef(!0);_.useEffect(()=>{if(pe&&!k){const oe={...pe,external_url:pe.external_url||window.location.origin};R(oe),setTimeout(()=>{Lm.current=!1},100)}},[pe,k]);const Fm=mt({mutationFn:ue.updateSettings,onSuccess:oe=>{t.setQueryData(["settings"],oe),R(oe),t.invalidateQueries({queryKey:["archiveStats"]}),o(i("settings.toast.settingsSaved"),"success")},onError:oe=>{o(`Failed to save: ${oe.message}`,"error")},onSettled:()=>{Om.current=!1}}),Zu=mt({mutationFn:({id:oe,data:wt})=>ue.updatePrinter(oe,wt),onSuccess:()=>{t.invalidateQueries({queryKey:["printers"]}),o(i("settings.toast.cameraSettingsSaved"),"success")},onError:oe=>{o(`Failed to update printer: ${oe.message}`,"error")}});_.useEffect(()=>{if(!(Lm.current||!k||!pe||!(pe.auto_archive!==k.auto_archive||pe.save_thumbnails!==k.save_thumbnails||pe.capture_finish_photo!==k.capture_finish_photo||pe.default_filament_cost!==k.default_filament_cost||pe.currency!==k.currency||pe.energy_cost_per_kwh!==k.energy_cost_per_kwh||pe.energy_tracking_mode!==k.energy_tracking_mode||pe.check_updates!==k.check_updates||(pe.check_printer_firmware??!0)!==(k.check_printer_firmware??!0)||pe.notification_language!==k.notification_language||pe.ams_humidity_good!==k.ams_humidity_good||pe.ams_humidity_fair!==k.ams_humidity_fair||pe.ams_temp_good!==k.ams_temp_good||pe.ams_temp_fair!==k.ams_temp_fair||pe.ams_history_retention_days!==k.ams_history_retention_days||pe.per_printer_mapping_expanded!==k.per_printer_mapping_expanded||pe.date_format!==k.date_format||pe.time_format!==k.time_format||pe.default_printer_id!==k.default_printer_id||pe.ftp_retry_enabled!==k.ftp_retry_enabled||pe.ftp_retry_count!==k.ftp_retry_count||pe.ftp_retry_delay!==k.ftp_retry_delay||pe.ftp_timeout!==k.ftp_timeout||pe.mqtt_enabled!==k.mqtt_enabled||pe.mqtt_broker!==k.mqtt_broker||pe.mqtt_port!==k.mqtt_port||pe.mqtt_username!==k.mqtt_username||pe.mqtt_password!==k.mqtt_password||pe.mqtt_topic_prefix!==k.mqtt_topic_prefix||pe.mqtt_use_tls!==k.mqtt_use_tls||pe.external_url!==k.external_url||pe.ha_enabled!==k.ha_enabled||pe.ha_url!==k.ha_url||pe.ha_token!==k.ha_token||(pe.library_archive_mode??"ask")!==(k.library_archive_mode??"ask")||Number(pe.library_disk_warning_gb??5)!==Number(k.library_disk_warning_gb??5)||(pe.camera_view_mode??"window")!==(k.camera_view_mode??"window")||pe.prometheus_enabled!==k.prometheus_enabled||pe.prometheus_token!==k.prometheus_token))&&!Om.current)return gl.current&&clearTimeout(gl.current),gl.current=setTimeout(()=>{if(Om.current)return;Om.current=!0;const wt={auto_archive:k.auto_archive,save_thumbnails:k.save_thumbnails,capture_finish_photo:k.capture_finish_photo,default_filament_cost:k.default_filament_cost,currency:k.currency,energy_cost_per_kwh:k.energy_cost_per_kwh,energy_tracking_mode:k.energy_tracking_mode,check_updates:k.check_updates,check_printer_firmware:k.check_printer_firmware,notification_language:k.notification_language,ams_humidity_good:k.ams_humidity_good,ams_humidity_fair:k.ams_humidity_fair,ams_temp_good:k.ams_temp_good,ams_temp_fair:k.ams_temp_fair,ams_history_retention_days:k.ams_history_retention_days,per_printer_mapping_expanded:k.per_printer_mapping_expanded,date_format:k.date_format,time_format:k.time_format,default_printer_id:k.default_printer_id,ftp_retry_enabled:k.ftp_retry_enabled,ftp_retry_count:k.ftp_retry_count,ftp_retry_delay:k.ftp_retry_delay,ftp_timeout:k.ftp_timeout,mqtt_enabled:k.mqtt_enabled,mqtt_broker:k.mqtt_broker,mqtt_port:k.mqtt_port,mqtt_username:k.mqtt_username,mqtt_password:k.mqtt_password,mqtt_topic_prefix:k.mqtt_topic_prefix,mqtt_use_tls:k.mqtt_use_tls,external_url:k.external_url,ha_enabled:k.ha_enabled,ha_url:k.ha_url,ha_token:k.ha_token,library_archive_mode:k.library_archive_mode,library_disk_warning_gb:k.library_disk_warning_gb,camera_view_mode:k.camera_view_mode,prometheus_enabled:k.prometheus_enabled,prometheus_token:k.prometheus_token};Fm.mutate(wt)},500),()=>{gl.current&&clearTimeout(gl.current)}},[k,pe,Fm]);const hn=_.useCallback((oe,wt)=>{R(Rn=>Rn?{...Rn,[oe]:wt}:null)},[]),Sv=async(oe,wt,Rn)=>{if(!wt){o(i("settings.toast.enterCameraUrl"),"error");return}ot(Zn=>({...Zn,[oe]:!0})),st(Zn=>({...Zn,[oe]:null}));try{const Zn=await ue.testExternalCamera(oe,wt,Rn);st(Mo=>({...Mo,[oe]:Zn})),Zn.success?o(i("settings.toast.cameraConnected",{resolution:Zn.resolution||""}),"success"):o(Zn.error||i("settings.toast.connectionFailed"),"error")}catch(Zn){const Mo=Zn instanceof Error?Zn.message:i("settings.toast.testFailed");st(Ju=>({...Ju,[oe]:{success:!1,error:Mo}})),o(Mo,"error")}finally{ot(Zn=>({...Zn,[oe]:!1}))}},[Bx,Nv]=_.useState({}),$x=_.useRef({}),Im=_.useRef(new Set);_.useEffect(()=>{if($t){const oe={};$t.forEach(wt=>{wt.external_camera_url&&!Im.current.has(wt.id)&&(oe[wt.id]=wt.external_camera_url,Im.current.add(wt.id))}),Object.keys(oe).length>0&&Nv(wt=>({...wt,...oe}))}},[$t]);const GM=(oe,wt)=>{Nv(Rn=>({...Rn,[oe]:wt})),$x.current[oe]&&clearTimeout($x.current[oe]),$x.current[oe]=setTimeout(()=>{Zu.mutate({id:oe,data:{external_camera_url:wt||null}})},800)},Mv=(oe,wt)=>{const Rn={};wt.type!==void 0&&(Rn.external_camera_type=wt.type||null),wt.enabled!==void 0&&(Rn.external_camera_enabled=wt.enabled),Zu.mutate({id:oe,data:Rn})};return Ie||!k?s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"mb-8",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:i("settings.title")}),s.jsx("p",{className:"text-bambu-gray",children:i("settings.configureBambuddy")})]}),s.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary overflow-x-auto",children:[s.jsx("button",{onClick:()=>de("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${be==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:i("settings.tabs.general")}),s.jsxs("button",{onClick:()=>de("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(tl,{className:"w-4 h-4"}),i("settings.tabs.smartPlugs"),Le&&Le.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Le.length})]}),s.jsxs("button",{onClick:()=>de("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(wg,{className:"w-4 h-4"}),i("settings.tabs.notifications"),At&&At.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:At.length})]}),s.jsxs("button",{onClick:()=>de("filament"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="filament"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(due,{className:"w-4 h-4"}),i("settings.tabs.filament")]}),s.jsxs("button",{onClick:()=>de("network"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="network"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Sg,{className:"w-4 h-4"}),i("settings.tabs.network"),s.jsx("span",{className:`w-2 h-2 rounded-full ${lr?.enabled?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>de("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Ho,{className:"w-4 h-4"}),i("settings.tabs.apiKeys"),Ft&&Ft.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Ft.length})]}),s.jsxs("button",{onClick:()=>de("virtual-printer"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="virtual-printer"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Ur,{className:"w-4 h-4"}),i("settings.tabs.virtualPrinter"),s.jsx("span",{className:`w-2 h-2 rounded-full ${Gt?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>de("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(mg,{className:"w-4 h-4"}),i("settings.tabs.users"),l&&s.jsx("span",{className:`w-2 h-2 rounded-full ${l?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>de("backup"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="backup"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Mu,{className:"w-4 h-4"}),i("settings.tabs.backup"),s.jsx("span",{className:`w-2 h-2 rounded-full ${jt?.is_authenticated&&et?.configured&&et?.enabled?"bg-green-400":"bg-gray-500"}`})]})]}),be==="general"&&s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[s.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-xl",children:[s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.general")})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(sh,{className:"w-4 h-4 inline mr-1"}),i("settings.language")]}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{value:a.language,onChange:oe=>{a.changeLanguage(oe.target.value),o(i("settings.toast.settingsSaved"),"success")},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:mz.map(oe=>s.jsxs("option",{value:oe.code,children:[oe.nativeName," (",oe.name,")"]},oe.code))}),s.jsx(ei,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.languageDescription")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.defaultView")}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{value:B,onChange:oe=>kt(oe.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(oe=>s.jsx("option",{value:oe.to,children:i(oe.labelKey)},oe.id))}),s.jsx(ei,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.defaultViewDescription")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date Format"}),s.jsxs("div",{className:"relative",children:[s.jsxs("select",{value:k.date_format||"system",onChange:oe=>hn("date_format",oe.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:[s.jsx("option",{value:"system",children:i("settings.systemDefault")}),s.jsx("option",{value:"us",children:"US (MM/DD/YYYY)"}),s.jsx("option",{value:"eu",children:"EU (DD/MM/YYYY)"}),s.jsx("option",{value:"iso",children:"ISO (YYYY-MM-DD)"})]}),s.jsx(ei,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),s.jsxs("div",{className:"relative",children:[s.jsxs("select",{value:k.time_format||"system",onChange:oe=>hn("time_format",oe.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:[s.jsx("option",{value:"system",children:i("settings.systemDefault")}),s.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),s.jsx("option",{value:"24h",children:"24-hour (15:30)"})]}),s.jsx(ei,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),s.jsxs("div",{className:"relative",children:[s.jsxs("select",{value:k.default_printer_id??"",onChange:oe=>hn("default_printer_id",oe.target.value?Number(oe.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:[s.jsx("option",{value:"",children:i("settings.noDefaultPrinter")}),$t?.map(oe=>s.jsx("option",{value:oe.id,children:oe.name},oe.id))]}),s.jsx(ei,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Pre-select this printer for uploads, reprints, and other operations."})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.sidebarOrder")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:he,children:[s.jsx(Rh,{className:"w-4 h-4"}),"Reset"]})]})]})]}),s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(SW,{className:"w-5 h-5"}),"Appearance"]})}),s.jsxs(Nt,{className:"space-y-6",children:[s.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:[s.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Dark Mode",d==="dark"&&s.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),s.jsxs("select",{value:p,onChange:oe=>{S(oe.target.value),o(i("settings.toast.settingsSaved"),"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:[s.jsx("option",{value:"neutral",children:"Neutral"}),s.jsx("option",{value:"warm",children:"Warm"}),s.jsx("option",{value:"cool",children:"Cool"}),s.jsx("option",{value:"oled",children:"OLED Black"}),s.jsx("option",{value:"slate",children:"Slate Blue"}),s.jsx("option",{value:"forest",children:"Forest Green"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),s.jsxs("select",{value:m,onChange:oe=>{M(oe.target.value),o(i("settings.toast.settingsSaved"),"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:[s.jsx("option",{value:"green",children:"Green"}),s.jsx("option",{value:"teal",children:"Teal"}),s.jsx("option",{value:"blue",children:"Blue"}),s.jsx("option",{value:"orange",children:"Orange"}),s.jsx("option",{value:"purple",children:"Purple"}),s.jsx("option",{value:"red",children:"Red"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),s.jsxs("select",{value:f,onChange:oe=>{v(oe.target.value),o(i("settings.toast.settingsSaved"),"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:[s.jsx("option",{value:"classic",children:"Classic"}),s.jsx("option",{value:"glow",children:"Glow"}),s.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),s.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:[s.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Light Mode",d==="light"&&s.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),s.jsxs("select",{value:b,onChange:oe=>{E(oe.target.value),o(i("settings.toast.settingsSaved"),"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:[s.jsx("option",{value:"neutral",children:"Neutral"}),s.jsx("option",{value:"warm",children:"Warm"}),s.jsx("option",{value:"cool",children:"Cool"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),s.jsxs("select",{value:y,onChange:oe=>{C(oe.target.value),o(i("settings.toast.settingsSaved"),"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:[s.jsx("option",{value:"green",children:"Green"}),s.jsx("option",{value:"teal",children:"Teal"}),s.jsx("option",{value:"blue",children:"Blue"}),s.jsx("option",{value:"orange",children:"Orange"}),s.jsx("option",{value:"purple",children:"Purple"}),s.jsx("option",{value:"red",children:"Red"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),s.jsxs("select",{value:x,onChange:oe=>{T(oe.target.value),o(i("settings.toast.settingsSaved"),"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:[s.jsx("option",{value:"classic",children:"Classic"}),s.jsx("option",{value:"glow",children:"Glow"}),s.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Toggle between dark and light mode using the sun/moon icon in the sidebar."})]})]}),s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.archiveSettings")})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Auto-archive prints"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:k.auto_archive,onChange:oe=>hn("auto_archive",oe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.saveThumbnails")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:k.save_thumbnails,onChange:oe=>hn("save_thumbnails",oe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.captureFinishPhoto")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:k.capture_finish_photo,onChange:oe=>hn("capture_finish_photo",oe.target.checked),className:"sr-only peer"}),s.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"})]})]}),k.capture_finish_photo&&sn&&!sn.installed&&s.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[s.jsx(Cn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),s.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",s.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",s.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]})]}),s.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-md",children:[s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(OR,{className:"w-5 h-5 text-bambu-green"}),"Camera"]})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Camera View Mode"}),s.jsxs("select",{value:k.camera_view_mode??"window",onChange:oe=>hn("camera_view_mode",oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"window",children:i("settings.newWindow")}),s.jsx("option",{value:"embedded",children:i("settings.embeddedOverlay")})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:k.camera_view_mode==="embedded"?"Camera opens in a resizable overlay on the main screen":"Camera opens in a separate browser window"})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4",children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-2",children:i("settings.externalCameras")}),s.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?s.jsx("div",{className:"space-y-3",children:$t.map(oe=>s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-white font-medium text-sm",children:oe.name}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:oe.external_camera_enabled,onChange:wt=>Mv(oe.id,{enabled:wt.target.checked}),className:"sr-only peer"}),s.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"})]})]}),oe.external_camera_enabled&&s.jsxs("div",{className:"space-y-2 mt-2",children:[s.jsx("input",{type:"text",placeholder:oe.external_camera_type==="usb"?"Device path (/dev/video0)":"Camera URL (rtsp://... or http://...)",value:Bx[oe.id]??oe.external_camera_url??"",onChange:wt=>GM(oe.id,wt.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"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("select",{value:oe.external_camera_type||"mjpeg",onChange:wt=>Mv(oe.id,{type:wt.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:[s.jsx("option",{value:"mjpeg",children:"MJPEG Stream"}),s.jsx("option",{value:"rtsp",children:"RTSP Stream"}),s.jsx("option",{value:"snapshot",children:"HTTP Snapshot"}),s.jsx("option",{value:"usb",children:"USB Camera (V4L2)"})]}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>Sv(oe.id,Bx[oe.id]??oe.external_camera_url??"",oe.external_camera_type||"mjpeg"),disabled:lt[oe.id]||!(Bx[oe.id]??oe.external_camera_url),children:lt[oe.id]?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):"Test"})]}),Ze[oe.id]&&s.jsx("div",{className:`text-xs flex items-center gap-1 ${Ze[oe.id]?.success?"text-green-500":"text-red-500"}`,children:Ze[oe.id]?.success?s.jsxs(s.Fragment,{children:[s.jsx(Ar,{className:"w-3 h-3"}),"Connected",Ze[oe.id]?.resolution&&` (${Ze[oe.id]?.resolution})`]}):s.jsxs(s.Fragment,{children:[s.jsx(Yi,{className:"w-3 h-3"}),Ze[oe.id]?.error||i("settings.toast.connectionFailed")]})})]})]},oe.id))}):s.jsx("p",{className:"text-xs text-bambu-gray italic",children:i("settings.noPrintersConfigured")})]})]})]}),s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.costTracking")})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),s.jsx("input",{type:"number",step:"0.01",min:"0",value:k.default_filament_cost,onChange:oe=>hn("default_filament_cost",parseFloat(oe.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),s.jsxs("select",{value:k.currency,onChange:oe=>hn("currency",oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"USD",children:"USD ($)"}),s.jsx("option",{value:"EUR",children:"EUR (€)"}),s.jsx("option",{value:"GBP",children:"GBP (£)"}),s.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),s.jsx("option",{value:"JPY",children:"JPY (¥)"}),s.jsx("option",{value:"CNY",children:"CNY (¥)"}),s.jsx("option",{value:"CAD",children:"CAD ($)"}),s.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),s.jsx("input",{type:"number",step:"0.01",min:"0",value:k.energy_cost_per_kwh,onChange:oe=>hn("energy_cost_per_kwh",parseFloat(oe.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),s.jsxs("select",{value:k.energy_tracking_mode||"total",onChange:oe=>hn("energy_tracking_mode",oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"print",children:i("settings.printsOnly")}),s.jsx("option",{value:"total",children:i("settings.totalConsumption")})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:k.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ls,{className:"w-5 h-5 text-bambu-green"}),"File Manager"]})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Create Archive Entry When Printing"}),s.jsxs("select",{value:k.library_archive_mode??"ask",onChange:oe=>hn("library_archive_mode",oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"always",children:i("settings.archiveMode.always")}),s.jsx("option",{value:"never",children:i("settings.archiveMode.never")}),s.jsx("option",{value:"ask",children:i("settings.archiveMode.ask")})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"When printing from File Manager, optionally create an archive entry"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Low Disk Space Warning"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"0.5",max:"100",step:"0.5",value:k.library_disk_warning_gb??5,onChange:oe=>hn("library_disk_warning_gb",parseFloat(oe.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"}),s.jsx("span",{className:"text-bambu-gray",children:"GB"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Show warning when free disk space falls below this threshold"})]})]})]})]}),s.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-sm",children:[s.jsx(gKe,{}),s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.checkForUpdatesLabel")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:k.check_updates,onChange:oe=>hn("check_updates",oe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.checkPrinterFirmware")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Check for printer firmware updates from Bambu Lab"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:k.check_printer_firmware??!0,onChange:oe=>hn("check_printer_firmware",oe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.currentVersion")}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",un?.version||"..."]})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>tr(),disabled:jn,children:[jn?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Dr,{className:"w-4 h-4"}),"Check now"]})]}),Yt?.update_available?s.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{children:[s.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",Yt.latest_version]}),Yt.release_name&&Yt.release_name!==Yt.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:Yt.release_name})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[Yt.release_notes&&s.jsx("button",{onClick:()=>_e(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),Yt.release_url&&s.jsx("a",{href:Yt.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:i("settings.viewReleaseOnGitHub"),children:s.jsx(Kr,{className:"w-4 h-4"})})]})]}),ii?.status==="downloading"||ii?.status==="installing"?s.jsxs("div",{className:"mt-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),s.jsx("span",{children:ii.message})]}),s.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:s.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${ii.progress}%`}})})]}):ii?.status==="complete"?s.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:ii.message}):ii?.status==="error"?s.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:ii.error||ii.message}):Yt?.is_docker?s.jsxs("div",{className:"mt-3 p-3 bg-bambu-dark-tertiary rounded-lg",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Update via Docker Compose:"}),s.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"})]}):s.jsxs(Te,{className:"mt-3",onClick:()=>Qu.mutate(),disabled:Qu.isPending,children:[Qu.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(yi,{className:"w-4 h-4"}),"Install Update"]})]}):Yt?.error?s.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: ",Yt.error]}):Yt&&!Yt.update_available?s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.dataManagement")})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.clearNotificationLogs")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.clearNotificationLogsDescription")})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>me(!0),children:[s.jsx(rn,{className:"w-4 h-4"}),i("common.clear")]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.resetUiPreferences")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.resetUiPreferencesDescription")})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>z(!0),children:[s.jsx(rn,{className:"w-4 h-4"}),"Reset"]})]}),s.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Backup & Restore"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Export/import settings and configure GitHub backup"})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>de("backup"),children:[s.jsx(Mu,{className:"w-4 h-4"}),"Go to Backup"]})]})]})]})]})]}),be==="network"&&k&&s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[s.jsxs("div",{className:"flex-1 lg:max-w-xl space-y-4",children:[s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(sh,{className:"w-5 h-5 text-blue-400"}),"External URL"]})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"The external URL where Bambuddy is accessible. Used for notification images and external integrations."}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Bambuddy URL"}),s.jsx("input",{type:"text",value:k.external_url??"",onChange:oe=>hn("external_url",oe.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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Include protocol and port (e.g., http://192.168.1.100:8000)"})]})]})]}),s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Dr,{className:"w-5 h-5 text-blue-400"}),"FTP Retry"]})}),s.jsxs(Nt,{className:"space-y-4",children:[s.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."}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.enableRetry")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically retry failed FTP operations"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:k.ftp_retry_enabled??!0,onChange:oe=>hn("ftp_retry_enabled",oe.target.checked),className:"sr-only peer"}),s.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"})]})]}),k.ftp_retry_enabled&&s.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry attempts"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"1",max:"10",value:k.ftp_retry_count??3,onChange:oe=>hn("ftp_retry_count",Math.min(10,Math.max(1,parseInt(oe.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"}),s.jsx("span",{className:"text-bambu-gray",children:"times"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Number of retry attempts before giving up (1-10)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry delay"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"1",max:"30",value:k.ftp_retry_delay??2,onChange:oe=>hn("ftp_retry_delay",Math.min(30,Math.max(1,parseInt(oe.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"}),s.jsx("span",{className:"text-bambu-gray",children:"seconds"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Wait time between retries (1-30)"})]})]}),s.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Connection timeout"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"10",max:"120",value:k.ftp_timeout??30,onChange:oe=>hn("ftp_timeout",Math.min(120,Math.max(10,parseInt(oe.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"}),s.jsx("span",{className:"text-bambu-gray",children:"seconds"})]}),s.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)"})]})]})]})]}),s.jsxs("div",{className:"flex-1 lg:max-w-xl space-y-4",children:[s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(f2,{className:"w-5 h-5 text-bambu-green"}),"Home Assistant"]}),k.ha_enabled&&bn&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${bn.success?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${bn.success?"text-green-400":"text-red-400"}`,children:bn.success?"Connected":"Disconnected"})]})]})}),s.jsxs(Nt,{className:"space-y-4",children:[s.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."}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.enableHomeAssistant")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.homeAssistantDescription")})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:k.ha_enabled??!1,onChange:oe=>hn("ha_enabled",oe.target.checked),className:"sr-only peer"}),s.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"})]})]}),k.ha_enabled&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Home Assistant URL"}),s.jsx("input",{type:"text",value:k.ha_url??"",onChange:oe=>hn("ha_url",oe.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Long-Lived Access Token"}),s.jsx("input",{type:"password",value:k.ha_token??"",onChange:oe=>hn("ha_token",oe.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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Create a token in HA: Profile → Long-Lived Access Tokens → Create Token"})]}),k.ha_url&&k.ha_token&&s.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:s.jsxs(Te,{variant:"secondary",size:"sm",disabled:Ba,onClick:async()=>{Ae(!0),wi(null);try{const oe=await ue.testHAConnection(k.ha_url,k.ha_token);wi(oe)}catch(oe){wi({success:!1,message:null,error:oe instanceof Error?oe.message:i("common.unknownError")})}finally{Ae(!1)}},children:[Ba?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Sg,{className:"w-4 h-4"}),i("settings.testConnection")]})})]})]})]}),s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Sg,{className:"w-5 h-5 text-blue-400"}),"MQTT Publishing"]}),lr?.enabled&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${lr.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${lr.connected?"text-green-400":"text-red-400"}`,children:lr.connected?"Connected":"Disconnected"})]})]})}),s.jsxs(Nt,{className:"space-y-4",children:[s.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."}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.enableMqtt")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Publish events to external MQTT broker"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:k.mqtt_enabled??!1,onChange:oe=>hn("mqtt_enabled",oe.target.checked),className:"sr-only peer"}),s.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"})]})]}),k.mqtt_enabled&&s.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Broker hostname"}),s.jsx("input",{type:"text",value:k.mqtt_broker??"",onChange:oe=>hn("mqtt_broker",oe.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"})]}),s.jsxs("div",{className:"flex items-end gap-4",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Port"}),s.jsx("input",{type:"number",min:"1",max:"65535",value:k.mqtt_port??1883,onChange:oe=>hn("mqtt_port",Math.min(65535,Math.max(1,parseInt(oe.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"})]}),s.jsxs("div",{className:"flex items-center gap-3 pb-2",children:[s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:k.mqtt_use_tls??!1,onChange:oe=>{const wt=oe.target.checked;hn("mqtt_use_tls",wt);const Rn=k.mqtt_port??1883;wt&&Rn===1883?hn("mqtt_port",8883):!wt&&Rn===8883&&hn("mqtt_port",1883)},className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]}),s.jsx("span",{className:"text-white text-sm",children:i("settings.useTls")})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username (optional)"}),s.jsx("input",{type:"text",value:k.mqtt_username??"",onChange:oe=>hn("mqtt_username",oe.target.value),placeholder:i("settings.leaveEmptyForAnonymous"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password (optional)"}),s.jsx("input",{type:"password",value:k.mqtt_password??"",onChange:oe=>hn("mqtt_password",oe.target.value),placeholder:i("settings.leaveEmptyForAnonymous"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic prefix"}),s.jsx("input",{type:"text",value:k.mqtt_topic_prefix??"bambuddy",onChange:oe=>hn("mqtt_topic_prefix",oe.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"}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["Topics will be: ",k.mqtt_topic_prefix||"bambuddy","/printers/<serial>/status, etc."]})]}),lr&&s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:`w-2 h-2 rounded-full ${lr.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:"text-bambu-gray",children:lr.connected?s.jsxs(s.Fragment,{children:[i("settings.mqttConnectedTo")," ",s.jsxs("span",{className:"text-white",children:[lr.broker,":",lr.port]})]}):i("settings.spoolmanDisconnected")})]})})]})]})]})]}),s.jsx("div",{className:"flex-1 lg:max-w-md space-y-4",children:s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(yP,{className:"w-5 h-5 text-orange-400"}),"Prometheus Metrics"]})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsxs("p",{className:"text-sm text-bambu-gray",children:["Expose printer metrics at ",s.jsx("code",{className:"bg-bambu-dark px-1 rounded",children:"/api/v1/metrics"})," for Prometheus/Grafana monitoring."]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.enableMetricsEndpoint")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.prometheusDescription")})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:k.prometheus_enabled??!1,onChange:oe=>hn("prometheus_enabled",oe.target.checked),className:"sr-only peer"}),s.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"})]})]}),k.prometheus_enabled&&s.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Bearer Token (optional)"}),s.jsx("input",{type:"password",value:k.prometheus_token??"",onChange:oe=>hn("prometheus_token",oe.target.value),placeholder:i("settings.leaveEmptyForNoAuth"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["If set, requests must include ",s.jsx("code",{className:"bg-bambu-dark px-1 rounded",children:"Authorization: Bearer <token>"})]})]}),s.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-sm text-white mb-2",children:i("settings.availableMetrics")}),s.jsxs("div",{className:"text-xs text-bambu-gray space-y-1",children:[s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_printer_connected"})," - Connection status"]}),s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_printer_state"})," - Printer state (idle/printing/etc)"]}),s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_print_progress"})," - Print progress 0-100%"]}),s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_bed_temp_celsius"})," - Bed temperature"]}),s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_nozzle_temp_celsius"})," - Nozzle temperature"]}),s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_prints_total"})," - Total prints by result"]}),s.jsx("p",{className:"text-bambu-gray/70 italic",children:"...and more (layers, fans, queue, filament usage)"})]})]})]})]})]})})]}),bn&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-6 max-w-md w-full mx-4",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[bn.success?s.jsx(Ar,{className:"w-8 h-8 text-green-400"}):s.jsx(Yi,{className:"w-8 h-8 text-red-400"}),s.jsx("h3",{className:"text-lg font-medium text-white",children:bn.success?"Connection Successful":"Connection Failed"})]}),s.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."}),s.jsx("div",{className:"flex justify-end",children:s.jsx(Te,{variant:"primary",onClick:()=>wi(null),children:"OK"})})]})}),be==="plugs"&&s.jsxs("div",{className:"max-w-4xl",children:[s.jsxs("div",{className:"flex items-start justify-between mb-6",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(tl,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),s.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."})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[Le&&Le.filter(oe=>oe.enabled).length>1&&s.jsxs(s.Fragment,{children:[s.jsxs(Te,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>ee("on"),disabled:Vl.isPending,title:i("settings.turnAllPlugsOn"),children:[Vl.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Gu,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),s.jsxs(Te,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>ee("off"),disabled:Vl.isPending,title:i("settings.turnAllPlugsOff"),children:[Vl.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(g2,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),s.jsxs(Te,{className:"whitespace-nowrap",onClick:()=>{F(null),D(!0)},children:[s.jsx(ur,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),Le&&Le.length>0&&s.jsxs(_t,{className:"mb-6",children:[s.jsx(Wn,{children:s.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[s.jsx(vh,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",St&&s.jsx(ht,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),s.jsx(Nt,{children:ut?s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(vh,{className:"w-3 h-3"}),"Current Power"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[ut.totalPower.toFixed(1),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"W"})]}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[ut.reachableCount,"/",ut.totalPlugs," plugs online"]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(si,{className:"w-3 h-3"}),"Today"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[ut.totalToday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),k&&k.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(ut.totalToday*k.energy_cost_per_kwh).toFixed(2)," ",k.currency]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(yP,{className:"w-3 h-3"}),"Yesterday"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[ut.totalYesterday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),k&&k.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(ut.totalYesterday*k.energy_cost_per_kwh).toFixed(2)," ",k.currency]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(hP,{className:"w-3 h-3"}),"Total"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[ut.totalLifetime.toFixed(1),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),k&&k.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(ut.totalLifetime*k.energy_cost_per_kwh).toFixed(2)," ",k.currency]})]})]}):St?null:s.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),Ce?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Le&&Le.length>0?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Le.map(oe=>s.jsx(nKe,{plug:oe,onEdit:wt=>{F(wt),D(!0)}},oe.id))}):s.jsx(_t,{children:s.jsx(Nt,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(tl,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),s.jsx("p",{className:"text-lg font-medium text-white mb-2",children:i("settings.noSmartPlugsTitle")}),s.jsx("p",{className:"text-sm mb-4",children:i("settings.noSmartPlugsDescription")}),s.jsxs(Te,{onClick:()=>{F(null),D(!0)},children:[s.jsx(ur,{className:"w-4 h-4"}),i("settings.addFirstSmartPlug")]})]})})})]}),be==="notifications"&&s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(wg,{className:"w-5 h-5 text-bambu-green"}),i("settings.providers")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>ae(!0),children:[s.jsx(q0,{className:"w-4 h-4"}),i("settings.log")]}),At&&At.length>0&&s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>{ca(null),pl.mutate()},disabled:pl.isPending,children:[pl.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(PR,{className:"w-4 h-4"}),i("settings.testAll")]}),s.jsxs(Te,{size:"sm",onClick:()=>{K(null),j(!0)},children:[s.jsx(ur,{className:"w-4 h-4"}),"Add"]})]})]}),s.jsx(_t,{className:"mb-4",children:s.jsx(Nt,{className:"py-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm font-medium",children:i("settings.notificationLanguage")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.notificationLanguageDescription")})]}),s.jsx("select",{value:k.notification_language||"en",onChange:oe=>hn("notification_language",oe.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:mz.map(oe=>s.jsx("option",{value:oe.code,children:oe.nativeName},oe.code))})]})})}),Cc&&s.jsx(_t,{className:"mb-4",children:s.jsxs(Nt,{className:"py-3",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm font-medium text-white",children:i("settings.testResults")}),s.jsx("button",{onClick:()=>ca(null),className:"text-bambu-gray hover:text-white text-xs",children:i("common.dismiss")})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm mb-2",children:[s.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[s.jsx(Ar,{className:"w-4 h-4"}),i("settings.testPassedCount",{count:Cc.success})]}),Cc.failed>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(Yi,{className:"w-4 h-4"}),i("settings.testFailedCount",{count:Cc.failed})]})]}),Cc.results.filter(oe=>!oe.success).length>0&&s.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:Cc.results.filter(oe=>!oe.success).map(oe=>s.jsxs("div",{className:"text-xs text-red-400",children:[s.jsxs("span",{className:"font-medium",children:[oe.provider_name,":"]})," ",oe.message]},oe.provider_id))})]})}),Tt?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-green animate-spin"})}):At&&At.length>0?s.jsx("div",{className:"space-y-3",children:At.map(oe=>s.jsx(aKe,{provider:oe,onEdit:wt=>{K(wt),j(!0)}},oe.id))}):s.jsx(_t,{children:s.jsx(Nt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(wg,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{className:"text-sm font-medium text-white mb-2",children:i("settings.noProvidersTitle")}),s.jsx("p",{className:"text-xs mb-3",children:i("settings.noProvidersDescription")}),s.jsxs(Te,{size:"sm",onClick:()=>{K(null),j(!0)},children:[s.jsx(ur,{className:"w-4 h-4"}),i("settings.addProvider")]})]})})})]}),s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[s.jsx(Ls,{className:"w-5 h-5 text-bambu-green"}),i("settings.messageTemplates")]}),s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:i("settings.messageTemplatesDescription")}),cn?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-green animate-spin"})}):dn&&dn.length>0?s.jsx("div",{className:"space-y-2",children:dn.map(oe=>s.jsx(_t,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>Q(oe),children:s.jsx(Nt,{className:"py-2.5 px-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-white font-medium text-sm truncate",children:oe.name}),s.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:oe.title_template})]}),s.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:wt=>{wt.stopPropagation(),Q(oe)},children:s.jsx(fg,{className:"w-4 h-4 text-bambu-gray"})})]})})},oe.id))}):s.jsx(_t,{children:s.jsx(Nt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Ls,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{className:"text-sm",children:i("settings.noTemplatesAvailable")})]})})})]})]}),be==="apikeys"&&s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ho,{className:"w-5 h-5 text-bambu-green"}),i("settings.apiKeys")]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:i("settings.apiKeysDescription")})]}),s.jsxs(Te,{size:"sm",onClick:()=>ie(!0),className:"flex-shrink-0",children:[s.jsx(ur,{className:"w-4 h-4"}),i("settings.createKey")]})]}),G&&s.jsx(_t,{className:"mb-6 border-bambu-green",children:s.jsx(Nt,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Ar,{className:"w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-white font-medium mb-1",children:i("settings.apiKeyCreated")}),s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:i("settings.apiKeyCopyWarning")}),s.jsxs("div",{className:"flex items-center gap-2 bg-bambu-dark rounded-lg p-2",children:[s.jsx("code",{className:"flex-1 text-sm text-bambu-green font-mono break-all",children:G}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(G);else{const oe=document.createElement("textarea");oe.value=G,oe.style.position="fixed",oe.style.left="-999999px",document.body.appendChild(oe),oe.select(),document.execCommand("copy"),document.body.removeChild(oe)}o(i("settings.toast.keyCopied"))}catch{o(i("settings.toast.copyFailed"),"error")}},children:s.jsx(Fl,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex gap-2 mt-3",children:[s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>{I(G),o(i("settings.toast.keyAddedToBrowser"))},children:i("settings.useInApiBrowser")}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>Y(null),children:i("common.dismiss")})]})]})]})})}),Pe&&s.jsxs(_t,{className:"mb-6",children:[s.jsx(Wn,{children:s.jsx("h3",{className:"text-base font-semibold text-white",children:i("settings.createNewApiKey")})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.keyName")}),s.jsx("input",{type:"text",value:Me,onChange:oe=>Oe(oe.target.value),placeholder:i("settings.keyNamePlaceholder"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:i("common.permissions")}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:ge.can_read_status,onChange:oe=>Ke(wt=>({...wt,can_read_status:oe.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:i("settings.readStatus")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.readStatusDescription")})]})]}),s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:ge.can_queue,onChange:oe=>Ke(wt=>({...wt,can_queue:oe.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:i("settings.manageQueue")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.manageQueueDescription")})]})]}),s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:ge.can_control_printer,onChange:oe=>Ke(wt=>({...wt,can_control_printer:oe.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:i("settings.controlPrinter")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.controlPrinterDescription")})]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[s.jsxs(Te,{onClick:()=>Mt.mutate({name:Me||i("settings.unnamedKey"),...ge}),disabled:Mt.isPending,children:[Mt.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(ur,{className:"w-4 h-4"}),i("settings.createKey")]}),s.jsx(Te,{variant:"secondary",onClick:()=>ie(!1),children:i("common.cancel")})]})]})]}),Pt?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Ft&&Ft.length>0?s.jsx("div",{className:"space-y-3",children:Ft.map(oe=>s.jsx(_t,{children:s.jsx(Nt,{className:"py-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ho,{className:`w-5 h-5 ${oe.enabled?"text-bambu-green":"text-bambu-gray"}`}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:oe.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[oe.key_prefix,"••••••••",oe.last_used&&` · ${i("settings.lastUsed")}: ${Bg(oe.last_used)}`]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex gap-1 text-xs",children:[oe.can_read_status&&s.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:i("settings.read")}),oe.can_queue&&s.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:i("queue.title")}),oe.can_control_printer&&s.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:i("settings.control")})]}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>q(oe.id),children:s.jsx(rn,{className:"w-4 h-4 text-red-400"})})]})]})})},oe.id))}):s.jsx(_t,{children:s.jsx(Nt,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Ho,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),s.jsx("p",{className:"text-lg font-medium text-white mb-2",children:i("settings.apiKeysEmptyTitle")}),s.jsx("p",{className:"text-sm mb-4",children:i("settings.apiKeysEmptyDescription")}),s.jsxs(Te,{onClick:()=>ie(!0),children:[s.jsx(ur,{className:"w-4 h-4"}),i("settings.createFirstKey")]})]})})}),s.jsxs(_t,{className:"mt-6",children:[s.jsx(Wn,{children:s.jsx("h3",{className:"text-base font-semibold text-white",children:i("settings.webhookEndpoints")})}),s.jsxs(Nt,{className:"space-y-3 text-sm",children:[s.jsx("p",{className:"text-bambu-gray",children:i("settings.webhookApiKeyHint")}),s.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-blue-400",children:"GET"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/status"}),s.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.getAllStatus")]})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-blue-400",children:"GET"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/status/:id"}),s.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.getSpecificStatus")]})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-green-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/queue"}),s.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.addToQueue")]})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-orange-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/pause"}),s.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.pausePrint")]})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-orange-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/resume"}),s.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.resumePrint")]})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-red-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/stop"}),s.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.stopPrint")]})]})]})]})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(sh,{className:"w-5 h-5 text-bambu-green"}),i("settings.apiBrowser")]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:i("settings.apiBrowserDescription")})]}),s.jsx(_t,{className:"mb-4",children:s.jsxs(Nt,{className:"py-3",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:i("settings.apiKeyForTesting")}),s.jsx("input",{type:"text",value:te,onChange:oe=>I(oe.target.value),placeholder:i("settings.apiKeyPlaceholder"),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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:i("settings.apiKeyHint")})]})}),s.jsx(SKe,{apiKey:te})]})]}),be==="virtual-printer"&&s.jsx(xKe,{}),be==="filament"&&k&&s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[s.jsx("div",{className:"flex-1 lg:max-w-xl",children:s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.amsDisplayThresholds")})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.amsThresholdsDescription")}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(AR,{className:"w-4 h-4 text-blue-400"}),s.jsx("span",{className:"font-medium",children:i("settings.humidity")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.goodGreen")," ≤"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"0",max:"100",value:k.ams_humidity_good??40,onChange:oe=>hn("ams_humidity_good",parseInt(oe.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"}),s.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.fairOrange")," ≤"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"0",max:"100",value:k.ams_humidity_fair??60,onChange:oe=>hn("ams_humidity_fair",parseInt(oe.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"}),s.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.aboveFairBad")})]}),s.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(b2,{className:"w-4 h-4 text-orange-400"}),s.jsx("span",{className:"font-medium",children:i("settings.temperature")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.goodBlue")," ≤"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:k.ams_temp_good??28,onChange:oe=>hn("ams_temp_good",parseFloat(oe.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"}),s.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.fairOrange")," ≤"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:k.ams_temp_fair??35,onChange:oe=>hn("ams_temp_fair",parseFloat(oe.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"}),s.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.aboveFairHot")})]}),s.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(Mu,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"font-medium",children:i("settings.historyRetention")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.keepSensorHistory")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"1",max:"365",value:k.ams_history_retention_days??30,onChange:oe=>hn("ams_history_retention_days",parseInt(oe.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"}),s.jsx("span",{className:"text-bambu-gray",children:i("common.days")})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.historyRetentionDescription")})]}),s.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(Ur,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"font-medium",children:i("settings.printModal")})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-white",children:i("settings.expandCustomMapping")}),s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:i("settings.expandCustomMappingDescription")})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:k.per_printer_mapping_expanded??!1,onChange:oe=>hn("per_printer_mapping_expanded",oe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})]})]})]})}),s.jsx("div",{className:"flex-1 lg:max-w-xl",children:s.jsx(mKe,{})})]}),ce!==null&&s.jsx(Qn,{title:i("settings.deleteApiKeyTitle"),message:i("settings.deleteApiKeyMessage"),confirmText:i("settings.deleteKey"),variant:"danger",onConfirm:()=>{en.mutate(ce),q(null)},onCancel:()=>q(null)}),A&&s.jsx(rKe,{plug:U,onClose:()=>{D(!1),F(null)}}),H&&s.jsx(sKe,{provider:$,onClose:()=>{j(!1),K(null)}}),V&&s.jsx(oKe,{template:V,onClose:()=>Q(null)}),Z&&s.jsx(uKe,{onClose:()=>ae(!1)}),fe&&s.jsx(Qn,{title:i("settings.clearNotificationLogs"),message:i("settings.clearLogsMessage"),confirmText:i("settings.clearLogs"),variant:"warning",onConfirm:async()=>{me(!1);try{const oe=await ue.clearNotificationLogs(30);o(oe.message,"success")}catch{o(i("settings.toast.clearLogsFailed"),"error")}},onCancel:()=>me(!1)}),ke&&s.jsx(Qn,{title:i("settings.resetUiPreferences"),message:i("settings.resetUiPreferencesMessage"),confirmText:i("settings.resetPreferences"),variant:"default",onConfirm:()=>{z(!1),localStorage.clear(),o(i("settings.toast.uiPreferencesReset"),"success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>z(!1)}),O&&s.jsx(Qn,{title:`Turn All Plugs ${O==="on"?"On":"Off"}`,message:`This will turn ${O==="on"?"ON":"OFF"} all ${Le?.filter(oe=>oe.enabled).length||0} enabled smart plugs. ${O==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${O==="on"?"On":"Off"}`,variant:O==="off"?"danger":"warning",onConfirm:()=>{const oe=O;ee(null),Vl.mutate(oe)},onCancel:()=>ee(null)}),le&&Yt?.release_notes&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>_e(!1),children:s.jsxs(_t,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:oe=>oe.stopPropagation(),children:[s.jsxs(Wn,{className:"flex flex-row items-center justify-between shrink-0",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Release Notes - v",Yt.latest_version]}),Yt.release_name&&Yt.release_name!==Yt.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray",children:Yt.release_name})]}),s.jsx("button",{onClick:()=>_e(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsx(Nt,{className:"overflow-y-auto flex-1",children:s.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:Yt.release_notes})}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[Yt.release_url&&s.jsx("a",{href:Yt.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:s.jsxs(Te,{variant:"secondary",className:"w-full",children:[s.jsx(Kr,{className:"w-4 h-4"}),"View on GitHub"]})}),s.jsx(Te,{onClick:()=>_e(!1),className:"flex-1",children:"Close"})]})]})}),be==="users"&&s.jsxs("div",{className:"space-y-6",children:[s.jsx(_t,{children:s.jsx(Nt,{className:"py-4",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.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?s.jsx(nT,{className:"w-5 h-5 text-green-400"}):s.jsx(tT,{className:"w-5 h-5 text-gray-400"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white font-medium",children:i("settings.authentication")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:i(l?"settings.authEnabledDescription":"settings.authDisabledDescription")})]})]}),l?c?.is_admin&&s.jsxs(Te,{variant:"secondary",onClick:()=>re(!0),children:[s.jsx(tT,{className:"w-4 h-4"}),i("common.disable")]}):s.jsxs(Te,{onClick:()=>e("/setup"),children:[s.jsx(nT,{className:"w-4 h-4"}),i("common.enable")]})]})})}),l&&s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-6",children:[c&&s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(mg,{className:"w-5 h-5 text-bambu-green"}),i("settings.currentUser")]}),s.jsxs(Te,{size:"sm",variant:"ghost",onClick:()=>$e(!0),children:[s.jsx(Ho,{className:"w-4 h-4"}),i("settings.changePassword")]})]})}),s.jsx(Nt,{children:s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium text-lg",children:c.username}),s.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[c.is_admin&&s.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-purple-500/20 text-purple-300",children:i("settings.admin")}),c.groups?.map(oe=>s.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${oe.name==="Administrators"?"bg-purple-500/20 text-purple-300":oe.name==="Operators"?"bg-blue-500/20 text-blue-300":oe.name==="Viewers"?"bg-green-500/20 text-green-300":"bg-gray-500/20 text-gray-300"}`,children:oe.name},oe.id))]})]})})})]}),s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(mg,{className:"w-5 h-5 text-bambu-green"}),i("settings.users")]}),qt("users:create")&&s.jsxs(Te,{size:"sm",onClick:()=>{Se(!0),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:[s.jsx(ur,{className:"w-4 h-4"}),i("settings.addUser")]})]})}),s.jsx(Nt,{children:wn?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-green animate-spin"})}):yt.length===0?s.jsx("p",{className:"text-center text-bambu-gray py-8",children:i("settings.noUsersFound")}):s.jsx("div",{className:"divide-y divide-bambu-dark-tertiary",children:yt.map(oe=>s.jsxs("div",{className:"py-3 flex items-center justify-between",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-white font-medium truncate",children:oe.username}),s.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[oe.is_admin&&s.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-purple-500/20 text-purple-300",children:i("settings.admin")}),oe.groups?.map(wt=>s.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${wt.name==="Administrators"?"bg-purple-500/20 text-purple-300":wt.name==="Operators"?"bg-blue-500/20 text-blue-300":wt.name==="Viewers"?"bg-green-500/20 text-green-300":"bg-gray-500/20 text-gray-300"}`,children:wt.name},wt.id))]})]}),s.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[qt("users:update")&&s.jsx(Te,{size:"sm",variant:"ghost",onClick:()=>Si(oe),children:s.jsx(fg,{className:"w-4 h-4"})}),qt("users:delete")&&oe.id!==c?.id&&s.jsx(Te,{size:"sm",variant:"ghost",onClick:()=>_i(oe.id),children:s.jsx(rn,{className:"w-4 h-4"})})]})]},oe.id))})})]})]}),s.jsx("div",{children:s.jsxs(_t,{children:[s.jsx(Wn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(rT,{className:"w-5 h-5 text-bambu-green"}),i("settings.groups")]}),qt("groups:create")&&s.jsxs(Te,{size:"sm",onClick:()=>{vn(!0),la()},children:[s.jsx(ur,{className:"w-4 h-4"}),i("settings.addGroup")]})]})}),s.jsx(Nt,{children:Yr?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Fr.length===0?s.jsx("p",{className:"text-center text-bambu-gray py-8",children:i("settings.noGroupsFound")}):s.jsx("div",{className:"divide-y divide-bambu-dark-tertiary",children:Fr.map(oe=>s.jsxs("div",{className:"py-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(rT,{className:`w-4 h-4 ${oe.name==="Administrators"?"text-purple-400":oe.name==="Operators"?"text-blue-400":oe.name==="Viewers"?"text-green-400":"text-bambu-gray"}`}),s.jsx("span",{className:"text-white font-medium",children:oe.name}),oe.is_system&&s.jsx("span",{className:"px-2 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:i("settings.system")})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[qt("groups:update")&&s.jsx(Te,{size:"sm",variant:"ghost",onClick:()=>Hh(oe),children:s.jsx(fg,{className:"w-4 h-4"})}),qt("groups:delete")&&!oe.is_system&&s.jsx(Te,{size:"sm",variant:"ghost",onClick:()=>Dn(oe.id),children:s.jsx(rn,{className:"w-4 h-4"})})]})]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1 ml-6",children:oe.description||i("settings.noDescription")}),s.jsxs("div",{className:"flex items-center gap-4 mt-2 ml-6 text-xs text-bambu-gray",children:[s.jsx("span",{children:i("settings.userCount",{count:oe.user_count})}),s.jsx("span",{children:i("settings.permissionCount",{count:oe.permissions.length})})]})]},oe.id))})})]})})]}),!l&&s.jsx(_t,{children:s.jsx(Nt,{className:"py-6",children:s.jsxs("div",{className:"text-center",children:[s.jsx(tT,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:i("settings.authDisabledTitle")}),s.jsx("p",{className:"text-sm text-bambu-gray mb-4 max-w-md mx-auto",children:i("settings.authDisabledMessage")}),s.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray mb-6 text-left max-w-xs mx-auto",children:[s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Ar,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:i("settings.authDisabledFeature1")})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Ar,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:i("settings.authDisabledFeature2")})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Ar,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:i("settings.authDisabledFeature3")})]})]}),s.jsxs(Te,{onClick:()=>e("/setup"),children:[s.jsx(nT,{className:"w-4 h-4"}),i("settings.enableAuthentication")]})]})})})]}),Be&&s.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{Se(!1),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:s.jsxs(_t,{className:"w-full max-w-md",onClick:oe=>oe.stopPropagation(),children:[s.jsx(Wn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(mg,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.createUser")})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{Se(!1),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:s.jsx(Rt,{className:"w-5 h-5"})})]})}),s.jsxs(Nt,{children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.username")}),s.jsx("input",{type:"text",value:ft.username,onChange:oe=>Bt({...ft,username:oe.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:i("settings.enterUsername"),autoComplete:"username"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.password")}),s.jsx("input",{type:"password",value:ft.password,onChange:oe=>Bt({...ft,password:oe.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:i("settings.enterPassword"),autoComplete:"new-password",minLength:6})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.confirmPassword")}),s.jsx("input",{type:"password",value:ft.confirmPassword,onChange:oe=>Bt({...ft,confirmPassword:oe.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 ${ft.confirmPassword&&ft.password!==ft.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmPasswordPlaceholder"),autoComplete:"new-password",minLength:6}),ft.confirmPassword&&ft.password!==ft.confirmPassword&&s.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Groups"}),s.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:[Fr.map(oe=>s.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:ft.group_ids.includes(oe.id),onChange:()=>Ks(oe.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),s.jsx("span",{className:"text-sm text-white",children:oe.name}),oe.is_system&&s.jsx("span",{className:"text-xs text-yellow-400",children:"(System)"})]},oe.id)),Fr.length===0&&s.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.noGroupsAvailable")})]})]})]}),s.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:()=>{Se(!1),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:"Cancel"}),s.jsx(Te,{onClick:No,disabled:Ws.isPending||!ft.username||!ft.password||ft.password!==ft.confirmPassword||ft.password.length<6,children:Ws.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):s.jsxs(s.Fragment,{children:[s.jsx(ur,{className:"w-4 h-4"}),"Create User"]})})]})]})]})}),Xe&&tt!==null&&s.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{Ne(!1),Ee(null),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:s.jsxs(_t,{className:"w-full max-w-md",onClick:oe=>oe.stopPropagation(),children:[s.jsx(Wn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(fg,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.editUser")})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{Ne(!1),Ee(null),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:s.jsx(Rt,{className:"w-5 h-5"})})]})}),s.jsxs(Nt,{children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.username")}),s.jsx("input",{type:"text",value:ft.username,onChange:oe=>Bt({...ft,username:oe.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:i("settings.enterUsername"),autoComplete:"username"})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:["Password ",s.jsx("span",{className:"text-bambu-gray font-normal",children:"(leave blank to keep current)"})]}),s.jsx("input",{type:"password",value:ft.password,onChange:oe=>Bt({...ft,password:oe.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:i("settings.enterNewPassword"),autoComplete:"new-password",minLength:6})]}),ft.password&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.confirmPassword")}),s.jsx("input",{type:"password",value:ft.confirmPassword,onChange:oe=>Bt({...ft,confirmPassword:oe.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 ${ft.confirmPassword&&ft.password!==ft.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmNewPassword"),autoComplete:"new-password",minLength:6}),ft.confirmPassword&&ft.password!==ft.confirmPassword&&s.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Groups"}),s.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:Fr.map(oe=>s.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:ft.group_ids.includes(oe.id),onChange:()=>Ks(oe.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),s.jsx("span",{className:"text-sm text-white",children:oe.name}),oe.is_system&&s.jsx("span",{className:"text-xs text-yellow-400",children:"(System)"})]},oe.id))})]})]}),s.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:()=>{Ne(!1),Ee(null),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:"Cancel"}),s.jsx(Te,{onClick:()=>Ns(tt),disabled:tn.isPending||!ft.username||!!(ft.password&&(ft.password!==ft.confirmPassword||ft.password.length<6)),children:tn.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),"Saving..."]}):s.jsxs(s.Fragment,{children:[s.jsx(hs,{className:"w-4 h-4"}),"Save Changes"]})})]})]})]})}),We!==null&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:()=>{ze(null),De(null)},children:s.jsxs(_t,{className:"w-full max-w-md",onClick:oe=>oe.stopPropagation(),children:[s.jsx(Wn,{children:s.jsxs("div",{className:"flex items-center gap-2 text-red-400",children:[s.jsx(rn,{className:"w-5 h-5"}),s.jsx("h3",{className:"text-lg font-semibold",children:i("settings.deleteUserTitle")})]})}),s.jsx(Nt,{className:"space-y-4",children:Ye?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-2 border-bambu-green border-t-transparent"})}):W&&W.archives+W.queue_items+W.library_files>0?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-white",children:i("settings.userHasCreated")}),s.jsxs("ul",{className:"list-disc list-inside text-bambu-gray space-y-1",children:[W.archives>0&&s.jsxs("li",{children:[W.archives," archive",W.archives!==1?"s":""]}),W.queue_items>0&&s.jsxs("li",{children:[W.queue_items," queue item",W.queue_items!==1?"s":""]}),W.library_files>0&&s.jsxs("li",{children:[W.library_files," library file",W.library_files!==1?"s":""]})]}),s.jsx("p",{className:"text-bambu-gray text-sm",children:i("settings.userItemsQuestion")}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Te,{variant:"danger",onClick:()=>on.mutate({id:We,deleteItems:!0}),disabled:on.isPending,className:"justify-center",children:"Delete user AND their items"}),s.jsx(Te,{variant:"secondary",onClick:()=>on.mutate({id:We,deleteItems:!1}),disabled:on.isPending,className:"justify-center",children:"Delete user, keep items (become ownerless)"}),s.jsx(Te,{variant:"ghost",onClick:()=>{ze(null),De(null)},disabled:on.isPending,className:"justify-center",children:"Cancel"})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-white",children:i("settings.deleteUserConfirm")}),s.jsx("p",{className:"text-bambu-gray text-sm",children:i("settings.actionCannotBeUndone")}),s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx(Te,{variant:"ghost",onClick:()=>{ze(null),De(null)},disabled:on.isPending,children:"Cancel"}),s.jsx(Te,{variant:"danger",onClick:()=>on.mutate({id:We,deleteItems:!1}),disabled:on.isPending,children:"Delete User"})]})]})})]})}),(Lt||Jt)&&s.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{vn(!1),rr(null),la()},children:s.jsxs(_t,{className:"w-full max-w-2xl max-h-[90vh] overflow-y-auto",onClick:oe=>oe.stopPropagation(),children:[s.jsx(Wn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(rT,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:Jt?"Edit Group":"Create Group"})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{vn(!1),rr(null),la()},children:s.jsx(Rt,{className:"w-5 h-5"})})]})}),s.jsxs(Nt,{children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.groupName")}),s.jsx("input",{type:"text",value:ln.name,onChange:oe=>fr({...ln,name:oe.target.value}),disabled:Jt?.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:i("settings.enterGroupName")}),Jt?.is_system&&s.jsx("p",{className:"text-xs text-yellow-400 mt-1",children:i("settings.systemGroupWarning")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Description"}),s.jsx("textarea",{value:ln.description,onChange:oe=>fr({...ln,description:oe.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:i("settings.enterDescriptionOptional")})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:["Permissions (",ln.permissions.length," selected)"]}),s.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:Br?.categories.map(oe=>s.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[s.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(oe.name),children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{type:"button",onClick:wt=>{wt.stopPropagation(),Dm(oe,!Rm(oe))},className:`w-5 h-5 rounded border flex items-center justify-center transition-colors ${Rm(oe)?"bg-bambu-green border-bambu-green":Vh(oe)?"bg-bambu-green/50 border-bambu-green":"border-bambu-gray hover:border-white"}`,children:(Rm(oe)||Vh(oe))&&s.jsx(Ia,{className:"w-3 h-3 text-white"})}),s.jsx("span",{className:"text-white font-medium",children:oe.name}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:["(",oe.permissions.filter(wt=>ln.permissions.includes(wt.value)).length,"/",oe.permissions.length,")"]})]}),Fn.has(oe.name)?s.jsx(ei,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(gs,{className:"w-4 h-4 text-bambu-gray"})]}),Fn.has(oe.name)&&s.jsx("div",{className:"p-3 bg-bambu-dark space-y-2",children:oe.permissions.map(wt=>s.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-secondary cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:ln.permissions.includes(wt.value),onChange:()=>zx(wt.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"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:wt.label})]},wt.value))})]},oe.name))})]})]}),s.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:()=>{vn(!1),rr(null),la()},children:"Cancel"}),s.jsx(Te,{onClick:Jt?Ux:$r,disabled:Ss.isPending||_o.isPending||!ln.name.trim(),children:Ss.isPending||_o.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),Jt?"Saving...":"Creating..."]}):s.jsxs(s.Fragment,{children:[s.jsx(hs,{className:"w-4 h-4"}),Jt?"Save Changes":"Create Group"]})})]})]})]})}),hr!==null&&s.jsx(Qn,{title:i("settings.deleteGroupTitle"),message:i("settings.deleteGroupMessage"),confirmText:i("settings.deleteGroup"),variant:"danger",onConfirm:()=>{So.mutate(hr),Dn(null)},onCancel:()=>Dn(null)}),be==="backup"&&s.jsx(yKe,{}),we&&s.jsx(Qn,{title:i("settings.disableAuthenticationTitle"),message:i("settings.disableAuthenticationMessage"),confirmText:i("settings.disableAuthentication"),variant:"danger",onConfirm:async()=>{try{await ue.disableAuth(),o(i("settings.toast.authDisabled"),"success"),await u(),re(!1),window.location.href="/"}catch(oe){const wt=oe instanceof Error?oe.message:i("settings.toast.authDisableFailed");o(wt,"error")}},onCancel:()=>re(!1)}),Fe&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>{$e(!1),He({currentPassword:"",newPassword:"",confirmPassword:""})},children:s.jsxs(_t,{className:"w-full max-w-md",onClick:oe=>oe.stopPropagation(),children:[s.jsx(Wn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ho,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.changePassword")})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{$e(!1),He({currentPassword:"",newPassword:"",confirmPassword:""})},children:s.jsx(Rt,{className:"w-5 h-5"})})]})}),s.jsxs(Nt,{children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Current Password"}),s.jsx("input",{type:"password",value:Ve.currentPassword,onChange:oe=>He({...Ve,currentPassword:oe.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:i("settings.enterCurrentPassword"),autoComplete:"current-password"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"New Password"}),s.jsx("input",{type:"password",value:Ve.newPassword,onChange:oe=>He({...Ve,newPassword:oe.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:i("settings.enterNewPasswordMin6"),autoComplete:"new-password",minLength:6})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Confirm New Password"}),s.jsx("input",{type:"password",value:Ve.confirmPassword,onChange:oe=>He({...Ve,confirmPassword:oe.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 ${Ve.confirmPassword&&Ve.newPassword!==Ve.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmNewPassword"),autoComplete:"new-password",minLength:6}),Ve.confirmPassword&&Ve.newPassword!==Ve.confirmPassword&&s.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]})]}),s.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:()=>{$e(!1),He({currentPassword:"",newPassword:"",confirmPassword:""})},children:"Cancel"}),s.jsx(Te,{onClick:async()=>{if(Ve.newPassword!==Ve.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(Ve.newPassword.length<6){o(i("settings.toast.passwordTooShort"),"error");return}je(!0);try{await ue.changePassword(Ve.currentPassword,Ve.newPassword),o(i("settings.toast.passwordChanged"),"success"),$e(!1),He({currentPassword:"",newPassword:"",confirmPassword:""})}catch(oe){const wt=oe instanceof Error?oe.message:"Failed to change password";o(wt,"error")}finally{je(!1)}},disabled:ye||!Ve.currentPassword||!Ve.newPassword||Ve.newPassword!==Ve.confirmPassword||Ve.newPassword.length<6,children:ye?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),"Changing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ho,{className:"w-4 h-4"}),"Change Password"]})})]})]})]})})]})}const Ore=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},EKe=t=>t.startsWith("HH")?"HF":"S",kKe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},uR=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 Hj({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:o}){const l=EKe(t.nozzle_id),c=t.nozzle_diameter,u=()=>{r&&a?a():e()};return s.jsxs("div",{className:"flex items-center gap-2",children:[r&&s.jsx("button",{onClick:a,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?s.jsx(ol,{className:"w-4 h-4 text-bambu-green"}):s.jsx(ll,{className:"w-4 h-4"})}),s.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:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:Ore(t.k_value)}),s.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),o&&s.jsx("span",{title:"Has note",children:s.jsx(EW,{className:"w-3 h-3 text-yellow-500"})}),s.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[l," ",c]})]}),o&&s.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&&s.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:s.jsx(Fl,{className:"w-4 h-4"})})]})}function Vj({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:a="",initialNoteKey:o=null,onClose:l,onSave:c,onSaveNote:u,hasPermission:d}){const{t:f}=$n(),{showToast:p}=Hn(),[m,x]=_.useState(t?.name||""),[b,y]=_.useState(t?.k_value?Ore(t.k_value):"0.020"),[v,S]=_.useState(t?.filament_id||""),[M,T]=_.useState(t?.nozzle_id?kKe(t.nozzle_id):"HH00"),[E,C]=_.useState(t?.nozzle_diameter||n),[k,R]=_.useState(t?[t.extruder_id]:i?[0,1]:[0]),[A,D]=_.useState(!1),[U,F]=_.useState({current:0,total:0}),[H,j]=_.useState(a),$=Jr.useMemo(()=>{const X=new Map;for(const ne of r)if(ne.filament_id&&!X.has(ne.filament_id)){const se=uR(ne.name||"");X.set(ne.filament_id,{id:ne.filament_id,name:se||ne.filament_id})}return Array.from(X.values()).sort((ne,se)=>ne.name.localeCompare(se.name))},[r]),K=mt({mutationFn:X=>(console.log("[KProfile] Calling API..."),ue.setKProfile(e,X)),onSuccess:X=>{if(console.log("[KProfile] Save success:",X),p(f("kProfiles.toast.profileSaved")),u&&H!==a){let ne;H===""&&o?ne=o:t&&t.slot_id>0?ne=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:ne=`name_${m}_${v}`,u(ne,H)}D(!0),setTimeout(()=>{D(!1),c()},2500)},onError:X=>{console.error("[KProfile] Save error:",X),p(X.message,"error"),D(!1)}}),V=mt({mutationFn:X=>(console.log("[KProfile] Deleting profile..."),ue.deleteKProfile(e,X)),onSuccess:X=>{console.log("[KProfile] Delete success:",X),p(f("kProfiles.toast.profileDeleted")),D(!0),setTimeout(()=>{D(!1),l()},4e3)},onError:X=>{console.error("[KProfile] Delete error:",X),p(X.message,"error"),D(!1)}}),[Q,Z]=_.useState(!1),ae=()=>{t&&V.mutate({slot_id:t.slot_id,extruder_id:t.extruder_id,nozzle_id:t.nozzle_id,nozzle_diameter:t.nozzle_diameter,filament_id:t.filament_id,setting_id:t.setting_id})},B=async X=>{if(X.preventDefault(),i&&!t&&k.length===0){p(f("kProfiles.toast.selectAtLeastOneExtruder"),"error");return}const ne=parseFloat(b).toFixed(6),se=`${M}-${E}`;if(t||k.length===1){const xe={name:m,k_value:ne,filament_id:v,nozzle_id:se,nozzle_diameter:E,extruder_id:t?t.extruder_id:k[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",xe),K.mutate(xe);return}D(!0),F({current:1,total:k.length});const be=k.map(xe=>({name:m,k_value:ne,filament_id:v,nozzle_id:se,nozzle_diameter:E,extruder_id:xe,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${be.length} profiles in batch:`,be);try{if(await ue.setKProfilesBatch(e,be),p(f("kProfiles.toast.profilesSaved",{count:k.length})),u&&H){const xe=`name_${m}_${v}`;u(xe,H)}}catch(xe){console.error("[KProfile] Failed to save batch:",xe),p(f("kProfiles.toast.failedToSaveBatch"),"error"),D(!1),F({current:0,total:0});return}F({current:k.length,total:k.length}),setTimeout(()=>{D(!1),F({current:0,total:0}),c()},3e3)};return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[s.jsxs(_t,{className:"w-full max-w-md relative",children:[A&&s.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),s.jsx("p",{className:"text-white font-medium",children:U.total>1?f("kProfiles.modal.savingExtruder",{current:U.current,total:U.total}):f("kProfiles.modal.syncing")}),s.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:f("kProfiles.modal.pleaseWait")})]}),s.jsxs(Nt,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:f(t?"kProfiles.modal.editTitle":"kProfiles.modal.addTitle")}),s.jsx("button",{onClick:l,className:"text-bambu-gray hover:text-white transition-colors",disabled:A,children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:B,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.profileName")}),s.jsx("input",{type:"text",value:m,onChange:X=>x(X.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:f("kProfiles.modal.profileNamePlaceholder"),required:!t})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.kValue")}),s.jsx("input",{type:"text",inputMode:"decimal",value:b,onChange:X=>{const ne=X.target.value;(ne===""||/^\d*\.?\d*$/.test(ne))&&y(ne)},onBlur:X=>{const ne=parseFloat(X.target.value);isNaN(ne)||y((Math.trunc(ne*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:f("kProfiles.modal.kValuePlaceholder"),required:!0}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:f("kProfiles.modal.kValueHelp")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.filament")}),s.jsxs("select",{value:v,onChange:X=>{const ne=X.target.value;if(S(ne),!t&&ne&&!m){const se=$.find(be=>be.id===ne);se&&x(`${M==="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:[s.jsx("option",{value:"",children:f("kProfiles.modal.selectFilament")}),t?.filament_id&&s.jsx("option",{value:t.filament_id,children:$.find(X=>X.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&$.map(X=>s.jsx("option",{value:X.id,children:X.name},X.id))]}),!t&&$.length===0&&s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:f("kProfiles.modal.noFilamentsHelp")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.flowType")}),s.jsxs("select",{value:M,onChange:X=>{const ne=X.target.value;if(T(ne),!t&&v&&!m){const se=$.find(be=>be.id===v);se&&x(`${ne==="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:[s.jsx("option",{value:"HH00",children:f("kProfiles.modal.highFlow")}),s.jsx("option",{value:"HS00",children:f("kProfiles.modal.standard")})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.nozzleSize")}),s.jsxs("select",{value:E,onChange:X=>C(X.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:[s.jsx("option",{value:"0.2",children:"0.2mm"}),s.jsx("option",{value:"0.4",children:"0.4mm"}),s.jsx("option",{value:"0.6",children:"0.6mm"}),s.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f(t?"kProfiles.modal.extruder":"kProfiles.modal.extruders")}),t?s.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?f("kProfiles.modal.left"):f("kProfiles.modal.right")}):s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:k.includes(1),onChange:X=>{X.target.checked?R([...k,1]):R(k.filter(ne=>ne!==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"}),s.jsx("span",{className:"text-white",children:f("kProfiles.modal.left")})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:k.includes(0),onChange:X=>{X.target.checked?R([...k,0]):R(k.filter(ne=>ne!==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"}),s.jsx("span",{className:"text-white",children:f("kProfiles.modal.right")})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.notes")}),s.jsx("textarea",{value:H,onChange:X=>j(X.target.value),placeholder:f("kProfiles.modal.notesPlaceholder"),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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:f("kProfiles.modal.notesHelp")})]}),s.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&s.jsx(Te,{type:"button",variant:"secondary",onClick:()=>Z(!0),disabled:V.isPending||A||!d("kprofiles:delete"),title:d("kprofiles:delete")?void 0:f("kProfiles.permission.noDelete"),className:"text-red-500 hover:bg-red-500/10",children:V.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(rn,{className:"w-4 h-4"})}),s.jsx(Te,{type:"button",variant:"secondary",onClick:l,disabled:A,className:"flex-1",children:f("common.cancel")}),s.jsxs(Te,{type:"submit",disabled:K.isPending||A||!d(t?"kprofiles:update":"kprofiles:create"),title:d(t?"kprofiles:update":"kprofiles:create")?void 0:f(t?"kProfiles.permission.noUpdate":"kProfiles.permission.noCreate"),className:"flex-1",children:[K.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(d2,{className:"w-4 h-4"}),f("common.save")]})]})]})]})]}),Q&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:s.jsx(_t,{className:"w-full max-w-sm",children:s.jsxs(Nt,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:s.jsx(rn,{className:"w-5 h-5 text-red-500"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:f("kProfiles.deleteConfirm.title")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:f("kProfiles.deleteConfirm.cannotUndo")})]})]}),s.jsx("p",{className:"text-bambu-gray mb-6",children:f("kProfiles.deleteConfirm.message",{name:t?.name})}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:()=>Z(!1),className:"flex-1",children:f("common.cancel")}),s.jsxs(Te,{onClick:()=>{Z(!1),ae()},disabled:V.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[V.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(rn,{className:"w-4 h-4"}),f("common.delete")]})]})]})})})]})}const h1={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function TKe(){const{t}=$n(),{showToast:e}=Hn(),{hasPermission:n}=Ai(),[r,i]=_.useState(null),[a,o]=_.useState(()=>localStorage.getItem(h1.NOZZLE_DIAMETER)||"0.4"),[l,c]=_.useState(null),[u,d]=_.useState(!1),[f,p]=_.useState(null),[m,x]=_.useState(""),[b,y]=_.useState("all"),[v,S]=_.useState("all"),[M,T]=_.useState(()=>localStorage.getItem(h1.SORT_OPTION)||"name"),[E,C]=_.useState(!1),[k,R]=_.useState(new Set),[A,D]=_.useState(!1),[U,F]=_.useState(!1),H=_.useCallback(I=>`${I.slot_id}_${I.extruder_id}`,[]);_.useEffect(()=>{localStorage.setItem(h1.NOZZLE_DIAMETER,a)},[a]),_.useEffect(()=>{localStorage.setItem(h1.SORT_OPTION,M)},[M]);const{data:j,isLoading:$}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:K,isLoading:V,isFetching:Q,error:Z,refetch:ae}=at({queryKey:["kprofiles",r,a],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",r,"nozzle",a);const I=await ue.getKProfiles(r,a);return console.log("[KProfiles] Received profiles:",I?.profiles?.length||0,"profiles"),I},enabled:!!r,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:B}=at({queryKey:["kprofiles",r,"0.4"],queryFn:()=>ue.getKProfiles(r,"0.4"),enabled:!!r,staleTime:6e4}),{data:X,refetch:ne}=at({queryKey:["kprofile-notes",r],queryFn:()=>ue.getKProfileNotes(r),enabled:!!r,staleTime:3e4}),se=Z?.message?.includes("not connected");_.useEffect(()=>{if(!r&&j&&j.length>0){const I=j.find(fe=>fe.is_active);I&&i(I.id)}},[r,j]),_.useEffect(()=>{if(r){const I=setTimeout(()=>{ae()},150);return()=>clearTimeout(I)}},[r,a]);const be=j?.filter(I=>I.is_active)||[],xe=Jr.useMemo(()=>K?.profiles?K.profiles.filter(fe=>{const me=m.toLowerCase(),ke=!me||fe.name.toLowerCase().includes(me)||fe.filament_id.toLowerCase().includes(me),z=b==="all"||b==="left"&&fe.extruder_id===1||b==="right"&&fe.extruder_id===0,O=v==="all"||v==="hf"&&fe.nozzle_id.startsWith("HH")||v==="s"&&fe.nozzle_id.startsWith("HS");return ke&&z&&O}).sort((fe,me)=>{switch(M){case"k_value":return parseFloat(fe.k_value)-parseFloat(me.k_value);case"filament":return uR(fe.name).localeCompare(uR(me.name));case"name":default:return fe.name.localeCompare(me.name)}}):[],[K?.profiles,m,b,v,M]),de=j?.find(I=>I.id===r),Pe=de?.nozzle_count===2;_.useEffect(()=>{const I=fe=>{fe.target instanceof HTMLInputElement||fe.target instanceof HTMLTextAreaElement||fe.target instanceof HTMLSelectElement||l||u||f||(fe.key==="r"||fe.key==="R"?(fe.preventDefault(),ae()):fe.key==="n"||fe.key==="N"?(fe.preventDefault(),d(!0)):fe.key==="Escape"&&E&&(fe.preventDefault(),C(!1),R(new Set)))};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[l,u,f,E,ae]);const ie=_.useCallback(()=>{if(!K?.profiles||K.profiles.length===0){e(t("kProfiles.toast.noProfilesToExport"),"error");return}const I={version:1,exported_at:new Date().toISOString(),printer:de?.name||"Unknown",nozzle_diameter:a,profiles:K.profiles.map(z=>({name:z.name,k_value:z.k_value,filament_id:z.filament_id,nozzle_id:z.nozzle_id,nozzle_diameter:z.nozzle_diameter,extruder_id:z.extruder_id}))},fe=new Blob([JSON.stringify(I,null,2)],{type:"application/json"}),me=URL.createObjectURL(fe),ke=document.createElement("a");ke.href=me,ke.download=`kprofiles_${de?.name||"printer"}_${a}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(ke),ke.click(),document.body.removeChild(ke),URL.revokeObjectURL(me),e(t("kProfiles.toast.exportedProfiles",{count:K.profiles.length}))},[K?.profiles,de,a,e,t]),Me=_.useCallback(()=>{const I=document.createElement("input");I.type="file",I.accept=".json",I.onchange=async fe=>{const me=fe.target.files?.[0];if(me)try{const ke=await me.text(),z=JSON.parse(ke);if(!z.profiles||!Array.isArray(z.profiles)){e(t("kProfiles.toast.invalidFileFormat"),"error");return}let O=0;for(const ee of z.profiles)if(!(!ee.name||!ee.k_value||!ee.filament_id))try{await ue.setKProfile(r,{name:ee.name,k_value:parseFloat(ee.k_value).toFixed(6),filament_id:ee.filament_id,nozzle_id:ee.nozzle_id||`HH00-${a}`,nozzle_diameter:ee.nozzle_diameter||a,extruder_id:ee.extruder_id??0,slot_id:0}),O++,await new Promise(le=>setTimeout(le,500))}catch(le){console.error("Failed to import profile:",ee.name,le)}e(t("kProfiles.toast.importedProfiles",{count:O,total:z.profiles.length})),ae()}catch(ke){console.error("Import error:",ke),e(t("kProfiles.toast.failedToParseImport"),"error")}},I.click()},[r,a,e,ae,t]),Oe=_.useCallback(I=>{R(fe=>{const me=new Set(fe);return me.has(I)?me.delete(I):me.add(I),me})},[]),ge=_.useCallback(()=>{R(new Set(xe.map(I=>H(I))))},[xe,H]),Ke=_.useCallback(()=>{k.size!==0&&D(!0)},[k.size]),G=_.useCallback(async()=>{const I=xe.filter(me=>k.has(H(me)));F(!0);let fe=0;for(const me of I)try{await ue.deleteKProfile(r,{slot_id:me.slot_id,extruder_id:me.extruder_id,nozzle_id:me.nozzle_id,nozzle_diameter:me.nozzle_diameter,filament_id:me.filament_id,setting_id:me.setting_id}),fe++,await new Promise(ke=>setTimeout(ke,300))}catch(ke){console.error("Failed to delete profile:",me.name,ke)}e(t("kProfiles.toast.profilesDeleted",{count:fe})),F(!1),D(!1),C(!1),R(new Set),ae()},[r,k,xe,e,ae,H,t]),Y=_.useCallback(I=>{const fe=[];return I.setting_id&&fe.push(I.setting_id),fe.push(`slot_${I.slot_id}_${I.filament_id}_${I.extruder_id}`),fe.push(`name_${I.name}_${I.filament_id}`),fe},[]),ce=_.useCallback(async(I,fe)=>{if(r)try{await ue.setKProfileNote(r,I,fe),ne()}catch(me){console.error("Failed to save note:",me),e(t("kProfiles.toast.failedToSaveNote"),"error")}},[r,ne,e]),q=_.useCallback(I=>{if(!X?.notes)return{note:"",key:null};const fe=Y(I);for(const me of fe)if(X.notes[me])return{note:X.notes[me],key:me};return{note:"",key:null}},[X,Y]),te=_.useCallback(I=>q(I).note,[q]);return $?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!j||j.length===0?s.jsx(_t,{children:s.jsxs(Nt,{className:"py-12 text-center",children:[s.jsx($i,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noPrintersConfigured")}),s.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.addPrinterInSettings")})]})}):be.length===0?s.jsx(_t,{children:s.jsxs(Nt,{className:"py-12 text-center",children:[s.jsx(Ur,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noActivePrinters")}),s.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.enablePrinterConnection")})]})}):s.jsxs(s.Fragment,{children:[Q&&!V&&s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[s.jsx(ht,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),s.jsx("p",{className:"text-white font-medium",children:t("kProfiles.loadingProfiles")})]}),s.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[s.jsxs("div",{className:"flex-1 min-w-48",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("kProfiles.printer")}),s.jsx("select",{value:r||"",onChange:I=>i(parseInt(I.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:be.map(I=>s.jsx("option",{value:I.id,children:I.name},I.id))})]}),s.jsxs("div",{className:"w-32",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("kProfiles.nozzle")}),s.jsxs("select",{value:a,onChange:I=>o(I.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:[s.jsx("option",{value:"0.2",children:"0.2mm"}),s.jsx("option",{value:"0.4",children:"0.4mm"}),s.jsx("option",{value:"0.6",children:"0.6mm"}),s.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),s.jsxs("div",{className:"flex items-end gap-2",children:[s.jsxs(Te,{variant:"secondary",onClick:()=>ae(),disabled:Q||!n("kprofiles:read"),title:n("kprofiles:read")?void 0:t("kProfiles.permission.noRead"),children:[s.jsx(Dr,{className:`w-4 h-4 ${Q?"animate-spin":""}`}),t("kProfiles.refresh")]}),s.jsxs(Te,{onClick:()=>d(!0),disabled:!n("kprofiles:create"),title:n("kprofiles:create")?void 0:t("kProfiles.permission.noCreate"),children:[s.jsx(ur,{className:"w-4 h-4"}),t("kProfiles.addProfile")]})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[s.jsxs("div",{className:"flex-1 min-w-48 relative",children:[s.jsx(ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:m,onChange:I=>x(I.target.value),placeholder:t("kProfiles.searchPlaceholder"),className:"w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),Pe&&s.jsx("div",{className:"w-36",children:s.jsxs("select",{value:b,onChange:I=>y(I.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:[s.jsx("option",{value:"all",children:t("kProfiles.allExtruders")}),s.jsx("option",{value:"left",children:t("kProfiles.leftOnly")}),s.jsx("option",{value:"right",children:t("kProfiles.rightOnly")})]})}),s.jsx("div",{className:"w-32",children:s.jsxs("select",{value:v,onChange:I=>S(I.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:[s.jsx("option",{value:"all",children:t("kProfiles.allFlow")}),s.jsx("option",{value:"hf",children:t("kProfiles.hfOnly")}),s.jsx("option",{value:"s",children:t("kProfiles.sOnly")})]})}),s.jsx("div",{className:"w-32",children:s.jsxs("select",{value:M,onChange:I=>T(I.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:[s.jsx("option",{value:"name",children:t("kProfiles.sortName")}),s.jsx("option",{value:"k_value",children:t("kProfiles.sortKValue")}),s.jsx("option",{value:"filament",children:t("kProfiles.sortFilament")})]})})]}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[s.jsxs(Te,{variant:"secondary",onClick:ie,disabled:!K?.profiles?.length||!n("kprofiles:read"),title:n("kprofiles:read")?void 0:t("kProfiles.permission.noExport"),children:[s.jsx(yi,{className:"w-4 h-4"}),t("kProfiles.export")]}),s.jsxs(Te,{variant:"secondary",onClick:Me,disabled:!n("kprofiles:create"),title:n("kprofiles:create")?void 0:t("kProfiles.permission.noImport"),children:[s.jsx(Ua,{className:"w-4 h-4"}),t("kProfiles.import")]}),s.jsx("div",{className:"flex-1"}),E?s.jsxs(s.Fragment,{children:[s.jsxs(Te,{variant:"secondary",onClick:ge,children:[s.jsx(ol,{className:"w-4 h-4"}),t("kProfiles.selectAll")]}),s.jsxs(Te,{variant:"secondary",onClick:Ke,disabled:k.size===0||!n("kprofiles:delete"),className:"text-red-500 hover:bg-red-500/10",title:n("kprofiles:delete")?void 0:t("kProfiles.permission.noDelete"),children:[s.jsx(rn,{className:"w-4 h-4"}),t("kProfiles.delete")," (",k.size,")"]}),s.jsxs(Te,{variant:"secondary",onClick:()=>{C(!1),R(new Set)},children:[s.jsx(Rt,{className:"w-4 h-4"}),t("common.cancel")]})]}):s.jsxs(Te,{variant:"secondary",onClick:()=>C(!0),disabled:!xe.length||!n("kprofiles:delete"),title:n("kprofiles:delete")?void 0:t("kProfiles.permission.noDelete"),children:[s.jsx(ol,{className:"w-4 h-4"}),t("kProfiles.select")]})]}),V?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):se?s.jsx(_t,{children:s.jsxs(Nt,{className:"py-12 text-center",children:[s.jsx(sm,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.printerOffline")}),s.jsx("p",{className:"text-bambu-gray mb-4",children:t("kProfiles.printerOfflineDesc")}),s.jsxs(Te,{variant:"secondary",onClick:()=>ae(),children:[s.jsx(Dr,{className:"w-4 h-4"}),t("common.refresh")]})]})}):xe.length>0?Pe?s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:t("kProfiles.leftExtruder")}),s.jsx("div",{className:"space-y-1",children:xe.filter(I=>I.extruder_id===1).map(I=>s.jsx(Hj,{profile:I,onEdit:()=>c(I),onCopy:()=>p(I),selectionMode:E,isSelected:k.has(H(I)),onToggleSelect:()=>Oe(H(I)),note:te(I)},H(I)))})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:t("kProfiles.rightExtruder")}),s.jsx("div",{className:"space-y-1",children:xe.filter(I=>I.extruder_id===0).map(I=>s.jsx(Hj,{profile:I,onEdit:()=>c(I),onCopy:()=>p(I),selectionMode:E,isSelected:k.has(H(I)),onToggleSelect:()=>Oe(H(I)),note:te(I)},H(I)))})]})]}):s.jsx("div",{className:"space-y-1",children:xe.map(I=>s.jsx(Hj,{profile:I,onEdit:()=>c(I),onCopy:()=>p(I),selectionMode:E,isSelected:k.has(H(I)),onToggleSelect:()=>Oe(H(I)),note:te(I)},H(I)))}):m||b!=="all"||v!=="all"?s.jsx(_t,{children:s.jsxs(Nt,{className:"py-12 text-center",children:[s.jsx(ba,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noMatchingProfiles")}),s.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.noMatchingProfilesDesc")})]})}):s.jsx(_t,{children:s.jsxs(Nt,{className:"py-12 text-center",children:[s.jsx(d2,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noKProfiles")}),s.jsx("p",{className:"text-bambu-gray mb-4",children:t("kProfiles.noKProfilesDesc",{diameter:a})}),s.jsxs(Te,{onClick:()=>d(!0),children:[s.jsx(ur,{className:"w-4 h-4"}),t("kProfiles.createFirstProfile")]})]})}),l&&r&&(()=>{const{note:I,key:fe}=q(l);return s.jsx(Vj,{profile:l,printerId:r,nozzleDiameter:a,existingProfiles:B?.profiles||K?.profiles,isDualNozzle:Pe,initialNote:I,initialNoteKey:fe,onSaveNote:ce,hasPermission:n,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),c(null),ae()},onSave:()=>{c(null),ae()}})})(),u&&r&&s.jsx(Vj,{printerId:r,nozzleDiameter:a,existingProfiles:B?.profiles||K?.profiles,isDualNozzle:Pe,onSaveNote:ce,hasPermission:n,onClose:()=>{d(!1),ae()},onSave:()=>{d(!1),ae()}}),f&&r&&s.jsx(Vj,{printerId:r,nozzleDiameter:a,existingProfiles:B?.profiles||K?.profiles,isDualNozzle:Pe,onSaveNote:ce,hasPermission:n,profile:{...f,slot_id:0,name:`${f.name} (Copy)`},onClose:()=>{p(null),ae()},onSave:()=>{p(null),ae()}}),A&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(_t,{className:"w-full max-w-sm",children:s.jsxs(Nt,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:s.jsx(rn,{className:"w-5 h-5 text-red-500"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:t("kProfiles.bulkDelete.title")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("kProfiles.bulkDelete.cannotUndo")})]})]}),s.jsx("p",{className:"text-bambu-gray mb-6",children:t("kProfiles.bulkDelete.message",{count:k.size})}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:()=>D(!1),disabled:U,className:"flex-1",children:t("common.cancel")}),s.jsxs(Te,{onClick:G,disabled:U,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[U?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(rn,{className:"w-4 h-4"}),t("common.delete")]})]})]})})})]})}function cF(t,e){const n=`${t} ${e||""}`,r=n.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),i=r?r[1].trim():null,a=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),o=a?(a[1]||a[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 Ry(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function AKe(t,e){const n=Ii(t);if(!n)return"";const i=new Date().getTime()-n.getTime(),a=Math.floor(i/6e4),o=Math.floor(i/36e5),l=Math.floor(i/864e5);return a<1?e("profiles.time.justNow"):a<60?e("profiles.time.minsAgo",{count:a}):o<24?e("profiles.time.hoursAgo",{count:o}):l<7?e("profiles.time.daysAgo",{count:l}):n.toLocaleDateString()}function CKe({onSuccess:t,t:e}){const{showToast:n}=Hn(),[r,i]=_.useState("email"),[a,o]=_.useState(""),[l,c]=_.useState(""),[u,d]=_.useState(""),[f,p]=_.useState(""),[m,x]=_.useState("global"),b=mt({mutationFn:()=>ue.cloudLogin(a,l,m),onSuccess:T=>{T.success?(n(e("profiles.login.toast.loggedIn")),t()):T.needs_verification?(n(e("profiles.login.toast.codeSent")),i("code")):n(T.message,"error")},onError:T=>n(T.message,"error")}),y=mt({mutationFn:()=>ue.cloudVerify(a,u),onSuccess:T=>{T.success?(n(e("profiles.login.toast.loggedIn")),t()):n(T.message,"error")},onError:T=>n(T.message,"error")}),v=mt({mutationFn:()=>ue.cloudSetToken(f),onSuccess:()=>{n(e("profiles.login.toast.tokenSet")),t()},onError:T=>n(T.message,"error")}),S=T=>{T.preventDefault(),r==="email"?b.mutate():r==="code"?y.mutate():r==="token"&&v.mutate()},M=b.isPending||y.isPending||v.isPending;return s.jsx(_t,{className:"max-w-md mx-auto",children:s.jsxs(Nt,{children:[s.jsxs("div",{className:"text-center mb-6",children:[s.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:s.jsx(o2,{className:"w-6 h-6 text-bambu-green"})}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:e("profiles.login.title")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:e("profiles.login.subtitle")})]}),s.jsxs("form",{onSubmit:S,className:"space-y-4",children:[r==="email"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.email")}),s.jsx("input",{type:"email",value:a,onChange:T=>o(T.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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.password")}),s.jsx("input",{type:"password",value:l,onChange:T=>c(T.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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.region")}),s.jsxs("select",{value:m,onChange:T=>x(T.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:[s.jsx("option",{value:"global",children:e("profiles.login.regionGlobal")}),s.jsx("option",{value:"china",children:e("profiles.login.regionChina")})]})]})]}),r==="code"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.verificationCode")}),s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:e("profiles.login.checkEmail",{email:a})}),s.jsx("input",{type:"text",value:u,onChange:T=>d(T.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})]}),r==="token"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.accessToken")}),s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:e("profiles.login.accessTokenHint")}),s.jsx("textarea",{value:f,onChange:T=>p(T.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})]}),s.jsxs("div",{className:"flex gap-2",children:[r==="code"&&s.jsx(Te,{type:"button",variant:"secondary",onClick:()=>i("email"),className:"flex-1",children:e("profiles.login.back")}),s.jsxs(Te,{type:"submit",disabled:M,className:"flex-1",children:[M?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Dz,{className:"w-4 h-4"}),e(r==="email"?"profiles.login.loginButton":r==="code"?"profiles.login.verifyButton":"profiles.login.setTokenButton")]})]}),r==="email"&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("button",{type:"button",onClick:()=>i("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[s.jsx(Ho,{className:"w-4 h-4"}),e("profiles.login.useToken")]})}),r==="token"&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("button",{type:"button",onClick:()=>i("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[s.jsx(Dz,{className:"w-4 h-4"}),e("profiles.login.useEmail")]})})]})]})})}function rg({label:t,value:e,options:n,onChange:r}){const[i,a]=_.useState(!1),o=n.find(l=>l.value===e);return s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onClick:()=>a(!i),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white hover:border-bambu-gray-dark transition-colors",children:[s.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),s.jsx("span",{children:o?.label||"All"}),s.jsx(ei,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"rotate-180":""}`})]}),i&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),s.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=>s.jsxs("button",{onClick:()=>{r(l.value),a(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center justify-between hover:bg-bambu-dark-tertiary transition-colors ${e===l.value?"text-bambu-green":"text-white"}`,children:[s.jsx("span",{children:l.label}),l.count!==void 0&&s.jsx("span",{className:"text-bambu-gray text-xs",children:l.count})]},l.value))})]})]})}function jKe(){const[t,e]=_.useState(!1);_.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?s.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:s.jsx(Ig,{className:"w-5 h-5"})}):null}function Gj({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:o,t:l}){const c=cF(t.name),u=Ry(t.setting_id);return s.jsxs("div",{className:"flex items-center gap-2 group",children:[s.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:s.jsxs("div",{className:"flex items-center gap-2",children:[i&&a!==void 0&&s.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-blue-500 text-white text-xs flex items-center justify-center font-medium",children:a+1}),!i&&u&&s.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:l("profiles.presets.myPreset")}),s.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),c.filamentType&&t.type==="filament"&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.filamentType}),c.layerHeight&&t.type==="process"&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.layerHeight}),c.printer&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.printer})]})}),s.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1",title:l("profiles.presets.duplicate"),children:s.jsx(Fl,{className:"w-4 h-4"})})]})}function dR(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(a=>n+" "+a).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+" "+dR(i,e+1)).join(`,
  8286. `)+`
  8287. `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
  8288. `+r.map(([a,o])=>n+" "+JSON.stringify(a)+": "+dR(o,e+1)).join(`,
  8289. `)+`
  8290. `+n+"}"}return String(t)}function PKe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i,hasPermission:a,t:o}){const{showToast:l}=Hn(),c=an(),[u,d]=_.useState(!1),{data:f,isLoading:p}=at({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>ue.getCloudSettingDetail(t.setting_id)}),m=mt({mutationFn:()=>ue.deleteCloudSetting(t.setting_id),onSuccess:()=>{l(o("profiles.presets.toast.deleted")),c.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:y=>l(y.message,"error")}),x=Ry(t.setting_id),b=cF(t.name,f?.setting?.inherits);return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(_t,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:s.jsxs(Nt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),x&&s.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:o("profiles.presets.editable")})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[s.jsx("span",{className:"capitalize",children:o(`profiles.presets.types.${t.type}`)}),b.printer&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"•"}),s.jsx("span",{children:b.printer})]})]})]}),s.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:p?s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):f?s.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:dR(f)}):s.jsx("div",{className:"text-center py-16 text-bambu-gray",children:o("profiles.presets.failedToLoadDetails")})}),u?s.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[s.jsx(Cn,{className:"w-5 h-5"}),s.jsx("span",{className:"font-medium",children:o("profiles.presets.deleteConfirm")})]}),s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:o("profiles.presets.deleteWarning",{name:t.name})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{variant:"secondary",onClick:()=>d(!1),disabled:m.isPending,className:"flex-1",children:o("common.cancel")}),s.jsxs(Te,{variant:"danger",onClick:()=>m.mutate(),disabled:m.isPending,className:"flex-1",children:[m.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(rn,{className:"w-4 h-4"}),o("common.delete")]})]})]}):s.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{variant:"secondary",onClick:e,className:"flex-1",children:o("common.close")}),s.jsxs(Te,{variant:"secondary",onClick:r,disabled:!a("cloud:auth"),title:a("cloud:auth")?void 0:o("profiles.presets.noDuplicatePermission"),children:[s.jsx(Fl,{className:"w-4 h-4"}),o("profiles.presets.duplicate")]}),x&&s.jsxs(s.Fragment,{children:[s.jsxs(Te,{variant:"secondary",onClick:i,disabled:p||!f||!a("cloud:auth"),title:a("cloud:auth")?void 0:o("profiles.presets.noEditPermission"),children:[s.jsx(Qi,{className:"w-4 h-4"}),o("common.edit")]}),s.jsx(Te,{variant:"danger",onClick:()=>d(!0),disabled:!a("cloud:auth"),title:a("cloud:auth")?void 0:o("profiles.presets.noDeletePermission"),children:s.jsx(rn,{className:"w-4 h-4"})})]})]})})]})})})}function Lre(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function Fre(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function DKe({onClose:t,onApply:e,t:n}){const{showToast:r}=Hn(),[i,a]=_.useState(Lre),[o,l]=_.useState("all"),[c,u]=_.useState(null),[d,f]=_.useState(""),[p,m]=_.useState(""),[x,b]=_.useState("{}"),[y,v]=_.useState(null),[S,M]=_.useState(null),T=o==="all"?i:i.filter(H=>H.type===o),E=H=>{a(H),Fre(H)},C=H=>{const j=i.filter($=>$.id!==H);E(j),M(null),r(n("profiles.templates.toast.deleted"))},k=H=>{u(H.id),f(H.name),m(H.description),b(JSON.stringify(H.settings,null,2)),v(null)},R=()=>{if(!(!c||!d.trim()))try{const H=JSON.parse(x),j=i.map($=>$.id===c?{...$,name:d.trim(),description:p.trim(),settings:H}:$);E(j),u(null),r(n("profiles.templates.toast.updated"))}catch(H){v(H.message)}},A=()=>{u(null),f(""),m(""),b("{}"),v(null)},D=H=>{const j=i.map($=>$.id===H?{...$,showInModal:!$.showInModal}:$);E(j)},U={filament:{label:n("profiles.presets.types.filament"),icon:TR,color:"text-amber-400"},print:{label:n("profiles.presets.types.process"),icon:bh,color:"text-blue-400"},printer:{label:n("profiles.presets.types.printer"),icon:Ur,color:"text-purple-400"}},F=S?i.find(H=>H.id===S):null;return _.useEffect(()=>{const H=j=>{j.key==="Escape"&&(S?M(null):c?A():t())};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[S,c,t]),s.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[F&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:s.jsx(_t,{className:"w-full max-w-md",children:s.jsxs(Nt,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:s.jsx(Cn,{className:"w-6 h-6 text-red-400"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:n("profiles.templates.deleteTitle")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:n("profiles.templates.deleteWarning")})]})]}),s.jsx("p",{className:"text-white mb-6",children:n("profiles.templates.deleteConfirm",{name:F.name})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{variant:"secondary",onClick:()=>M(null),className:"flex-1",children:n("common.cancel")}),s.jsxs(Te,{onClick:()=>C(S),className:"flex-1 bg-red-500 hover:bg-red-600",children:[s.jsx(rn,{className:"w-4 h-4"}),n("common.delete")]})]})]})})}),s.jsx(_t,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:s.jsxs(Nt,{className:"p-0 flex flex-col h-full",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(W0,{className:"w-5 h-5 text-amber-400"}),n("profiles.templates.title")]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:n("profiles.templates.typeFilter")}),["all","filament","print","printer"].map(H=>s.jsx("button",{onClick:()=>l(H),className:`px-3 py-1 text-sm rounded-lg transition-colors ${o===H?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:H==="all"?n("common.all"):U[H].label},H))]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:T.length===0?s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(W0,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),s.jsx("p",{children:n("profiles.templates.noTemplates")}),s.jsx("p",{className:"text-sm mt-1",children:n("profiles.templates.createFirst")})]}):s.jsx("div",{className:"space-y-2",children:T.map(H=>{const j=U[H.type],$=j.icon;return c===H.id?s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[s.jsx("input",{type:"text",value:d,onChange:K=>f(K.target.value),placeholder:n("profiles.templates.namePlaceholder"),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}),s.jsx("input",{type:"text",value:p,onChange:K=>m(K.target.value),placeholder:n("profiles.templates.descriptionPlaceholder"),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"})]}),s.jsxs("div",{className:"mb-3",children:[s.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:n("profiles.templates.settingsJson")}),s.jsx("textarea",{value:x,onChange:K=>{b(K.target.value),v(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${y?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),y&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:y})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Te,{size:"sm",onClick:R,disabled:!d.trim(),children:[s.jsx(hs,{className:"w-4 h-4"}),"Save"]}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:A,children:"Cancel"})]})]},H.id):s.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:[s.jsx($,{className:`w-5 h-5 ${j.color} flex-shrink-0`}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:H.name}),s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:H.description})]}),s.jsx("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:n("profiles.templates.fieldsCount",{count:Object.keys(H.settings).length})}),s.jsx("button",{onClick:()=>D(H.id),className:`p-1 transition-colors ${H.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:H.showInModal?n("profiles.templates.shownInModals"):n("profiles.templates.hiddenInModals"),children:H.showInModal?s.jsx(Ru,{className:"w-4 h-4"}):s.jsx(l2,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>e(H),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:n("profiles.templates.apply")}),s.jsx("button",{onClick:()=>k(H),className:"p-1 text-bambu-gray hover:text-white",title:n("common.edit"),children:s.jsx(Qi,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>M(H.id),className:"p-1 text-bambu-gray hover:text-red-400",title:n("common.delete"),children:s.jsx(rn,{className:"w-4 h-4"})})]},H.id)})})})]})})]})}function Ire({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i,t:a}){const[o,l]=_.useState("changes"),[c,u]=_.useState(""),d=_.useMemo(()=>{const x=new Set([...Object.keys(e),...Object.keys(n)]),b=[];for(const y of x){if(y==="inherits"||y==="version")continue;const v=e[y],S=n[y],M=y in e,T=y in n;let E;!M&&T?E="added":M&&!T?E="removed":JSON.stringify(v)!==JSON.stringify(S)?E="changed":E="same",b.push({key:y,left:v,right:S,status:E})}return b.sort((y,v)=>{const S={changed:0,added:1,removed:2,same:3};return S[y.status]!==S[v.status]?S[y.status]-S[v.status]:y.key.localeCompare(v.key)})},[e,n]),f=_.useMemo(()=>{let x=[...d];if(o==="changes"&&(x=x.filter(b=>b.status!=="same")),c){const b=c.toLowerCase();x=x.filter(y=>y.key.toLowerCase().includes(b)||String(y.left).toLowerCase().includes(b)||String(y.right).toLowerCase().includes(b))}return x},[d,o,c]),p=_.useMemo(()=>({added:d.filter(x=>x.status==="added").length,removed:d.filter(x=>x.status==="removed").length,changed:d.filter(x=>x.status==="changed").length,same:d.filter(x=>x.status==="same").length}),[d]),m=x=>{if(x===void 0)return"—";if(x===null)return"null";if(Array.isArray(x))return x.length===0?"[]":x.length===1?String(x[0]):x.join(", ");if(typeof x=="object")return JSON.stringify(x);const b=String(x);if(b.includes("\\n")||b.length>100){const y=b.split("\\n").length;if(y>1)return`[${y} lines of G-code/script]`;if(b.length>100)return b.substring(0,100)+"…"}return b};return _.useEffect(()=>{const x=b=>{b.key==="Escape"&&t()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsx(_t,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:s.jsxs(Nt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(_g,{className:"w-5 h-5 text-blue-400"}),a("profiles.diff.title")]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:a("profiles.diff.left")}),s.jsx("p",{className:"text-white font-medium truncate",children:r})]}),s.jsxs("div",{className:"text-center",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:a("profiles.diff.right")}),s.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[s.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[s.jsx(ur,{className:"w-3.5 h-3.5"}),p.added," ",a("profiles.diff.added")]}),s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(xP,{className:"w-3.5 h-3.5"}),p.removed," ",a("profiles.diff.removed")]}),s.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[s.jsx(uP,{className:"w-3.5 h-3.5"}),p.changed," ",a("profiles.diff.changed")]}),s.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[s.jsx(eT,{className:"w-3.5 h-3.5"}),p.same," ",a("profiles.diff.same")]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative",children:[s.jsx(ba,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:c,onChange:x=>u(x.target.value),placeholder:a("profiles.diff.searchFields"),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"})]}),p.same>0&&s.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>l("changes"),className:`px-3 py-1.5 text-sm transition-colors ${o==="changes"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:a("profiles.diff.changes")}),s.jsx("button",{onClick:()=>l("all"),className:`px-3 py-1.5 text-sm transition-colors ${o==="all"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:a("common.all")})]})]})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:f.length===0?s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(eT,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),s.jsx("p",{children:a(o==="changes"?"profiles.diff.noDifferences":"profiles.diff.noFieldsMatch")})]}):s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:s.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[s.jsx("th",{className:"text-left p-3 w-1/3",children:a("profiles.diff.field")}),s.jsx("th",{className:"text-left p-3 w-1/3",children:r}),s.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),s.jsx("tbody",{children:f.map(x=>{const b={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[x.status],y={added:s.jsx(ur,{className:"w-3.5 h-3.5 text-green-400"}),removed:s.jsx(xP,{className:"w-3.5 h-3.5 text-red-400"}),changed:s.jsx(uP,{className:"w-3.5 h-3.5 text-amber-400"}),same:s.jsx(eT,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[x.status];return s.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${b}`,children:[s.jsx("td",{className:"p-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[y,s.jsx("span",{className:"text-sm text-white font-mono",children:x.key})]})}),s.jsx("td",{className:"p-3",children:s.jsx("span",{className:`text-sm font-mono break-all ${x.status==="removed"?"text-red-300":x.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(x.left)})}),s.jsx("td",{className:"p-3",children:s.jsx("span",{className:`text-sm font-mono break-all ${x.status==="added"?"text-green-300":x.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(x.right)})})]},x.key)})})]})})]})})})}function RKe({onClose:t,initialData:e,allPresets:n,t:r}){const{showToast:i}=Hn(),a=an(),o=!!e?.setting_id,[l,c]=_.useState("common"),[u,d]=_.useState(e?.type||"filament"),[f,p]=_.useState(e?.name?o?e.name:`${e.name} (Copy)`:""),[m,x]=_.useState(e?.base_id||""),[b,y]=_.useState(""),[v,S]=_.useState(e?.setting||{inherits:""}),[M,T]=_.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[E,C]=_.useState(null),[k,R]=_.useState(""),[A,D]=_.useState(!1),[U,F]=_.useState(""),[H,j]=_.useState(!1),[$,K]=_.useState(Lre),[V,Q]=_.useState(!1),[Z,ae]=_.useState(""),[B,X]=_.useState(""),[ne,se]=_.useState(!0),[be,xe]=_.useState(null),[de,Pe]=_.useState(!1),ie=_.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[u]||[],[n,u]),Me=_.useMemo(()=>ie.filter(je=>Ry(je.setting_id)),[ie]),{data:Oe}=at({queryKey:["cloudFields",u],queryFn:()=>ue.getCloudFields(u==="print"?"process":u),staleTime:1e3*60*60}),{data:ge}=at({queryKey:["allPresetDetails",u,Me.map(je=>je.setting_id).join(",")],queryFn:async()=>{const je={};for(let Se=0;Se<Me.length;Se+=5){const Xe=Me.slice(Se,Se+5);(await Promise.all(Xe.map(async tt=>{try{const Ee=await ue.getCloudSettingDetail(tt.setting_id);return{id:tt.setting_id,detail:Ee}}catch{return null}}))).forEach(tt=>{tt&&(je[tt.id]=tt.detail)})}return je},enabled:Me.length>0,staleTime:1e3*60*10}),{data:Ke,isLoading:G}=at({queryKey:["cloudSettingDetail",m],queryFn:()=>ue.getCloudSettingDetail(m),enabled:!!m});_.useEffect(()=>{l!=="json"&&T(JSON.stringify(v,null,2))},[v,l]);const Y=_.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[u]||[]).filter(Be=>!Ry(Be.setting_id)).sort((Be,Se)=>Be.name.localeCompare(Se.name)),[n,u]);_.useEffect(()=>{if(!m)return;const je=Y.find(Be=>Be.setting_id===m);je&&(y(je.name),o||(S({inherits:je.name}),T(JSON.stringify({inherits:je.name},null,2))))},[m,Y,o]);const ce=_.useMemo(()=>{const je=Oe?.fields||[],Be=new Set(je.map(tt=>tt.key)),Se=new Set,Xe=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);ge&&Object.values(ge).forEach(tt=>{tt?.setting&&Object.keys(tt.setting).forEach(Ee=>{!Be.has(Ee)&&!Xe.has(Ee)&&Se.add(Ee)})}),Object.keys(v).forEach(tt=>{!Be.has(tt)&&!Xe.has(tt)&&Se.add(tt)});const Ne=Array.from(Se).sort().map(tt=>({key:tt,label:tt.replace(/_/g," ").replace(/\b\w/g,Ee=>Ee.toUpperCase()),type:"text",category:"discovered",description:r("profiles.presets.discoveredFromPresets")}));return[...je,...Ne]},[Oe,ge,v,r]),q=ce.filter(je=>je.label.toLowerCase().includes(k.toLowerCase())||je.key.toLowerCase().includes(k.toLowerCase())),te=()=>{if(U.trim()){const je=U.trim().toLowerCase().replace(/\s+/g,"_");I(je,""),F(""),j(!1),i(r("profiles.presets.toast.fieldAdded",{key:je}))}},I=(je,Be)=>{S(Se=>{const Xe={...Se};return Be===""||Be===void 0?delete Xe[je]:Xe[je]=Be,Xe})},fe=je=>{S(Be=>({...Be,...je.settings})),xe(je.name),i(r("profiles.templates.toast.applied"))},me=()=>{if(!Z.trim())return;const je={...v};if(delete je.inherits,Object.keys(je).length===0){i(r("profiles.presets.noOverridesToSave"),"error");return}const Be={id:Date.now().toString(),name:Z.trim(),description:B.trim()||r("profiles.presets.customTemplate"),type:u,settings:je,showInModal:ne},Se=[...$,Be];K(Se),Fre(Se),Q(!1),ae(""),X(""),se(!0),i(r("profiles.templates.toast.created"))},ke=_.useMemo(()=>$.filter(je=>je.type===u&&je.showInModal),[u,$]),z=je=>{T(je);try{const Be=JSON.parse(je);S(Be),C(null)}catch(Be){C(Be.message)}},O=je=>{je.preventDefault(),D(!1);const Be=je.dataTransfer.files[0];if(Be&&Be.name.endsWith(".json")){const Se=new FileReader;Se.onload=Xe=>{try{const Ne=Xe.target?.result,tt=JSON.parse(Ne),Ee=tt.setting||tt;S(We=>({...We,...Ee})),T(JSON.stringify({...v,...Ee},null,2)),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJsonFile"),"error")}},Se.readAsText(Be)}},ee=mt({mutationFn:()=>{const je={...v},Be=u==="filament"?"filament_settings_id":u==="print"?"print_settings_id":"printer_settings_id";je[Be]=`"${f}"`;const Se={type:u,name:f,base_id:m,setting:je};return ue.createCloudSetting(Se)},onSuccess:async()=>{i(r("profiles.presets.toast.created")),await a.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:je=>i(je.message,"error")}),le=mt({mutationFn:()=>{if(!e?.setting_id)throw new Error(r("profiles.presets.noSettingId"));return ue.updateCloudSetting(e.setting_id,{name:f,setting:v})},onSuccess:async()=>{i(r("profiles.presets.toast.updated")),a.removeQueries({queryKey:["cloudSettingDetail"]}),await a.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:je=>i(je.message,"error")}),_e=o?le:ee,we=Ke?.setting?.inherits,re=we?Y.find(je=>je.name===we):void 0,{data:Fe}=at({queryKey:["cloudSettingDetail",re?.setting_id],queryFn:()=>ue.getCloudSettingDetail(re.setting_id),enabled:!!re?.setting_id}),$e=_.useMemo(()=>{const je=Fe?.setting||{},Be=Ke?.setting||{},Se=m&&ge?.[m]?.setting?ge[m].setting:{};return{...je,...Be,...Se}},[m,Ke,Fe,ge]),Ve=je=>{if(je==null)return"";if(Array.isArray(je)){const Be=[...new Set(je.map(Se=>String(Se)))];return Be.length===1?Be[0]:je.join(", ")}return String(je)},He=je=>{const Be=v[je.key],Se=$e[je.key],Xe=Ve(Se),Ne=G?r("common.loading"):Xe||"",tt="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(je.type==="boolean"){const Ee=Be==="1"||Be===void 0&&Se==="1";return s.jsx("button",{type:"button",onClick:()=>I(je.key,Be==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${Ee?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:s.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${Ee?"translate-x-3.5":"translate-x-0.5"}`})})}return je.type==="select"?s.jsxs("select",{value:Be||"",onChange:Ee=>I(je.key,Ee.target.value),className:tt,children:[s.jsx("option",{value:"",children:Ne}),je.options?.map(Ee=>s.jsx("option",{value:Ee.value,children:Ee.label},Ee.value))]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:je.type==="number"?"number":"text",value:Be!==void 0?String(Be):"",onChange:Ee=>I(je.key,Ee.target.value),step:je.step,min:je.min,max:je.max,placeholder:Ne,className:tt}),je.unit&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:je.unit})]})},ye=_.useMemo(()=>Ke?.setting?Ke.setting:{},[Ke]);return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:je=>{je.preventDefault(),D(!0)},onDragLeave:()=>D(!1),onDrop:O,children:[de&&m&&s.jsx(Ire,{onClose:()=>Pe(!1),leftPreset:ye,rightPreset:v,leftLabel:r("profiles.presets.baseLabel",{name:b||m}),rightLabel:r("profiles.presets.currentLabel",{name:f||r("profiles.presets.newPreset")}),t:r}),s.jsx(_t,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:s.jsxs(Nt,{className:"p-0 flex flex-col h-full",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:r(o?"profiles.presets.editPreset":e?"profiles.presets.duplicatePreset":"profiles.presets.createNewPreset")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:r("profiles.presets.customizeSettings")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[m&&s.jsxs("button",{onClick:()=>Pe(!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:r("profiles.presets.compareWithBase"),children:[s.jsx(_g,{className:"w-4 h-4"}),r("profiles.presets.compare")]}),s.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]})]}),A&&s.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:s.jsxs("div",{className:"text-center",children:[s.jsx(Ua,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),s.jsx("p",{className:"text-bambu-green font-medium",children:r("profiles.presets.dropJsonToImport")})]})}),s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("common.type")}),s.jsxs("select",{value:u,onChange:je=>{d(je.target.value),x("")},className:"w-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:[s.jsx("option",{value:"filament",children:r("profiles.presets.types.filament")}),s.jsx("option",{value:"print",children:r("profiles.presets.types.process")}),s.jsx("option",{value:"printer",children:r("profiles.presets.types.printer")})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.basePreset")}),s.jsxs("select",{value:m,onChange:je=>x(je.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:[s.jsx("option",{value:"",children:r("profiles.presets.selectBasePreset")}),Y.map(je=>s.jsx("option",{value:je.setting_id,children:je.name},je.setting_id))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.presetName")}),s.jsx("input",{type:"text",value:f,onChange:je=>p(je.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:r("profiles.presets.myCustomPreset")})]})]}),b&&s.jsx("div",{className:"text-xs text-bambu-gray",children:s.jsxs("p",{className:"flex items-center gap-1",children:[s.jsx(Ia,{className:"w-3 h-3 text-bambu-green"}),r("profiles.presets.inheritsFrom")," ",s.jsx("span",{className:"text-white",children:b}),G&&s.jsx(ht,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),s.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[s.jsxs("button",{onClick:()=>c("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(Rz,{className:"w-4 h-4"}),r("profiles.presets.tabs.common")]}),s.jsxs("button",{onClick:()=>c("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(p2,{className:"w-4 h-4"}),r("profiles.presets.tabs.allFields")]}),s.jsxs("button",{onClick:()=>c("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(pW,{className:"w-4 h-4"}),"JSON",E&&s.jsx($i,{className:"w-3 h-3 text-red-400"})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("button",{onClick:()=>{const je={name:f,type:u,base_id:m,setting:v},Be=new Blob([JSON.stringify(je,null,2)],{type:"application/json"}),Se=URL.createObjectURL(Be),Xe=document.createElement("a");Xe.href=Se,Xe.download=`${f||"preset"}.json`,document.body.appendChild(Xe),Xe.click(),document.body.removeChild(Xe),URL.revokeObjectURL(Se),i(r("profiles.presets.toast.exported"))},className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:r("profiles.presets.exportToJson"),children:[s.jsx(yi,{className:"w-4 h-4"}),r("common.download")]}),s.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:r("profiles.presets.importFromJson"),children:[s.jsx(Ua,{className:"w-4 h-4"}),r("common.upload")]}),s.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:je=>{const Be=je.target.files?.[0];if(Be){const Se=new FileReader;Se.onload=Xe=>{try{const Ne=JSON.parse(Xe.target?.result),tt=Ne.setting||Ne;S(Ee=>({...Ee,...tt})),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJson"),"error")}},Se.readAsText(Be)}}})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[l==="common"&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[s.jsx(W0,{className:"w-4 h-4 text-amber-400"}),r("profiles.templates.title")]}),Object.keys(v).filter(je=>je!=="inherits").length>0&&s.jsxs("button",{onClick:()=>Q(!V),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[s.jsx(hs,{className:"w-3 h-3"}),r("profiles.presets.saveAsTemplate")]})]}),V&&s.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[s.jsx("input",{type:"text",value:Z,onChange:je=>ae(je.target.value),placeholder:r("profiles.templates.namePlaceholder"),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}),s.jsx("input",{type:"text",value:B,onChange:je=>X(je.target.value),placeholder:r("profiles.templates.descriptionPlaceholder"),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"})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Te,{size:"sm",onClick:me,disabled:!Z.trim(),children:[s.jsx(hs,{className:"w-3 h-3"}),r("common.save")]}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>Q(!1),children:r("common.cancel")})]}),s.jsxs("button",{onClick:()=>se(!ne),className:`flex items-center gap-1.5 text-xs transition-colors ${ne?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[ne?s.jsx(Ru,{className:"w-3.5 h-3.5"}):s.jsx(l2,{className:"w-3.5 h-3.5"}),r(ne?"profiles.templates.shownInModals":"profiles.templates.hiddenInModals")]})]})]}),be&&s.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:[s.jsx(Ia,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("span",{className:"text-sm text-bambu-green",children:[r("profiles.presets.templateApplied")," ",s.jsx("span",{className:"font-medium",children:be})]}),s.jsx("button",{onClick:()=>xe(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:s.jsx(Rt,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[ke.map(je=>s.jsxs("button",{onClick:()=>fe(je),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:je.name}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:je.description})]},je.id)),ke.length===0&&s.jsx("p",{className:"col-span-3 text-center text-bambu-gray text-sm py-4",children:r("profiles.presets.noTemplatesSelected")})]}),s.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:r("profiles.presets.manageTemplatesHint")})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.commonSettings")}),s.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:ce.slice(0,10).map(je=>s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:je.label}),s.jsx("div",{className:"w-48",children:He(je)})]},je.key))})]}),Object.keys(v).length>1&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.currentOverrides")}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(v).filter(([je])=>je!=="inherits").map(([je,Be])=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[je,": ",String(Be).slice(0,20),s.jsx("button",{onClick:()=>I(je,void 0),className:"hover:text-white",children:s.jsx(Rt,{className:"w-3 h-3"})})]},je))})]})]}),l==="fields"&&s.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[s.jsx("h3",{className:"text-sm font-medium text-white",children:r("profiles.presets.availableFields")}),s.jsx("span",{className:"text-xs text-bambu-gray",children:ge?r("profiles.templates.fieldsCount",{count:ce.length}):r("common.loading")})]}),s.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[s.jsx(ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:k,onChange:je=>R(je.target.value),placeholder:r("profiles.presets.searchFieldsPlaceholder"),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"})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[q.filter(je=>!(je.key in v)).map(je=>{const Be=$e[je.key],Se=Ve(Be);return s.jsxs("div",{onClick:()=>{S(Xe=>({...Xe,[je.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:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-sm text-white truncate",children:je.label}),s.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:je.key})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Se&&s.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?"...":""]}),s.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:s.jsx(ur,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},je.key)}),q.filter(je=>!(je.key in v)).length===0&&s.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:r(k?"profiles.presets.noMatchingFields":"profiles.presets.allFieldsAdded")})]}),s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:H?s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:U,onChange:je=>F(je.target.value),onKeyDown:je=>je.key==="Enter"&&te(),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}),s.jsx(Te,{size:"sm",onClick:te,disabled:!U.trim(),children:s.jsx(ur,{className:"w-4 h-4"})}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>{j(!1),F("")},children:s.jsx(Rt,{className:"w-4 h-4"})})]}):s.jsxs("button",{onClick:()=>j(!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:[s.jsx(ur,{className:"w-4 h-4"}),r("profiles.presets.addCustomField")]})})]}),s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[s.jsx("h3",{className:"text-sm font-medium text-white",children:r("profiles.presets.yourOverrides")}),s.jsx("span",{className:"text-xs text-bambu-gray",children:r("profiles.templates.fieldsCount",{count:Object.keys(v).filter(je=>je!=="inherits").length})})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(v).filter(([je])=>je!=="inherits").map(([je,Be])=>{const Se=ce.find(Xe=>Xe.key===je);return s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:Se?.label||je}),s.jsx("p",{className:"text-xs text-bambu-gray-dark",children:je})]}),s.jsx("button",{onClick:()=>I(je,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:s.jsx(Rt,{className:"w-4 h-4"})})]}),Se?He(Se):s.jsx("input",{type:"text",value:String(Be),onChange:Xe=>I(je,Xe.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"})]},je)}),Object.keys(v).filter(je=>je!=="inherits").length===0&&s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(Rz,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),s.jsx("p",{className:"text-sm",children:r("profiles.presets.noOverridesYet")}),s.jsx("p",{className:"text-xs mt-1",children:r("profiles.presets.clickFieldsToAdd")})]})]}),Object.keys(v).filter(je=>je!=="inherits").length>0&&s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:s.jsxs("button",{onClick:()=>{Q(!0),c("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:[s.jsx(hs,{className:"w-4 h-4"}),r("profiles.presets.saveAsTemplate")]})})]})]}),l==="json"&&s.jsxs("div",{className:"space-y-2",children:[E&&s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx($i,{className:"w-4 h-4"}),E]}),s.jsx("textarea",{value:M,onChange:je=>z(je.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 ${E?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),s.jsx("p",{className:"text-xs text-bambu-gray",children:r("profiles.presets.jsonTip")})]})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[s.jsx(Te,{variant:"secondary",onClick:t,className:"flex-1",children:r("common.cancel")}),s.jsxs(Te,{onClick:()=>_e.mutate(),disabled:_e.isPending||!f.trim()||!o&&!m||!!E,className:"flex-1",children:[_e.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):o?s.jsx(hs,{className:"w-4 h-4"}):s.jsx(ur,{className:"w-4 h-4"}),r(o?"common.save":e?"common.duplicate":"common.create")]})]})]})})]})}function OKe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i,hasPermission:a,t:o}){const[l,c]=_.useState(""),[u,d]=_.useState("all"),[f,p]=_.useState("all"),[m,x]=_.useState("all"),[b,y]=_.useState("all"),[v,S]=_.useState("all"),[M,T]=_.useState("all"),[E,C]=_.useState(null),[k,R]=_.useState(!1),[A,D]=_.useState(!1),[U,F]=_.useState(null),[H,j]=_.useState(null),[$,K]=_.useState(null),[V,Q]=_.useState(!1),[Z,ae]=_.useState([null,null]),[B,X]=_.useState(!1),[ne,se]=_.useState(null),be=an(),xe=_.useMemo(()=>[...t.filament.map(te=>({...te,type:"filament"})),...t.printer.map(te=>({...te,type:"printer"})),...t.process.map(te=>({...te,type:"process"}))].map(te=>({...te,meta:cF(te.name)})),[t]),de=_.useMemo(()=>{const q=new Set,te=new Set,I=new Set;return xe.forEach(fe=>{fe.meta.nozzle&&q.add(fe.meta.nozzle),fe.meta.filamentType&&te.add(fe.meta.filamentType),fe.meta.layerHeight&&I.add(fe.meta.layerHeight)}),{printers:i.map(fe=>({id:fe.id.toString(),name:fe.name})),nozzles:Array.from(q).sort((fe,me)=>parseFloat(fe)-parseFloat(me)),filaments:Array.from(te).sort(),layerHeights:Array.from(I).sort((fe,me)=>parseFloat(fe)-parseFloat(me))}},[xe,i]),Pe=_.useMemo(()=>m==="all"?null:i.find(te=>te.id.toString()===m)?.model||null,[m,i]),ie=_.useMemo(()=>xe.filter(q=>u==="all"||q.type===u).filter(q=>{if(f==="all")return!0;const te=Ry(q.setting_id);return f==="custom"?te:!te}).filter(q=>{if(m==="all"||!Pe)return!0;const te=q.meta.printer?.toLowerCase()||"",I=Pe.toLowerCase();return te.includes(I)||I.includes(te)}).filter(q=>b==="all"||q.meta.nozzle===b).filter(q=>v==="all"||q.meta.filamentType===v).filter(q=>M==="all"||q.meta.layerHeight===M).filter(q=>l===""||q.name.toLowerCase().includes(l.toLowerCase())).sort((q,te)=>q.name.localeCompare(te.name)),[xe,u,f,m,Pe,b,v,M,l]),Me=q=>{if(V){const te=Z[0]?.setting_id===q.setting_id,I=Z[1]?.setting_id===q.setting_id;if(te)ae([Z[1],null]);else if(I)ae([Z[0],null]);else if(!Z[0])ae([q,null]);else if(Z[1]){if(Z[0].type!==q.type)return;ae([Z[0],q])}else{if(Z[0].type!==q.type)return;ae([Z[0],q])}}else C(q)},Oe=q=>{if(Z[0]?.setting_id===q.setting_id)return 0;if(Z[1]?.setting_id===q.setting_id)return 1},ge=async q=>{try{const te=await ue.getCloudSettingDetail(q.setting_id),I=q.type==="process"?"print":q.type;F({type:I,name:q.name,base_id:te.base_id||"GFSA00",setting:te.setting||{}}),C(null)}catch(te){console.error("Failed to fetch preset details for duplication:",te)}},Ke=async q=>{try{be.removeQueries({queryKey:["cloudSettingDetail",q.setting_id]});const te=await ue.getCloudSettingDetail(q.setting_id),I=q.type==="process"?"print":q.type;j({type:I,name:q.name,base_id:te.base_id||"GFSA00",setting:te.setting||{},setting_id:q.setting_id}),C(null)}catch(te){console.error("Failed to fetch preset details for editing:",te)}},G=()=>{d("all"),p("all"),x("all"),y("all"),S("all"),T("all"),c("")},Y=u!=="all"||f!=="all"||m!=="all"||b!=="all"||v!=="all"||M!=="all"||l!=="",ce=t.filament.length+t.printer.length+t.process.length;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-4 mb-6",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:l,onChange:q=>c(q.target.value),placeholder:o("profiles.cloudView.searchPlaceholder"),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"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Te,{variant:V?"primary":"secondary",onClick:()=>{V?(Q(!1),ae([null,null])):Q(!0)},children:[s.jsx(_g,{className:"w-4 h-4"}),o(V?"common.cancel":"profiles.presets.compare")]}),s.jsxs(Te,{variant:"secondary",onClick:()=>D(!0),disabled:!a("cloud:auth"),title:a("cloud:auth")?void 0:o("profiles.cloudView.noTemplatesPermission"),children:[s.jsx(W0,{className:"w-4 h-4"}),o("profiles.cloudView.templates")]}),s.jsxs(Te,{variant:"secondary",onClick:n,disabled:r||!a("cloud:auth"),title:a("cloud:auth")?void 0:o("profiles.cloudView.noRefreshPermission"),children:[s.jsx(Dr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),o("profiles.cloudView.refresh")]}),s.jsxs(Te,{onClick:()=>R(!0),disabled:!a("cloud:auth"),title:a("cloud:auth")?void 0:o("profiles.cloudView.noCreatePermission"),children:[s.jsx(ur,{className:"w-4 h-4"}),o("profiles.cloudView.newPreset")]})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(u2,{className:"w-4 h-4 text-bambu-gray"}),s.jsx(rg,{label:o("profiles.cloudView.filters.type"),value:u,options:[{value:"all",label:o("profiles.cloudView.filters.all"),count:ce},{value:"filament",label:o("profiles.cloudView.filters.filament"),count:t.filament.length},{value:"printer",label:o("profiles.cloudView.filters.printer"),count:t.printer.length},{value:"process",label:o("profiles.cloudView.filters.process"),count:t.process.length}],onChange:q=>d(q)}),s.jsx(rg,{label:o("profiles.cloudView.filters.owner"),value:f,options:[{value:"all",label:o("profiles.cloudView.filters.all")},{value:"custom",label:o("profiles.cloudView.filters.myPresets")},{value:"builtin",label:o("profiles.cloudView.filters.builtIn")}],onChange:q=>p(q)}),de.printers.length>0&&s.jsx(rg,{label:o("profiles.cloudView.filters.printer"),value:m,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...de.printers.map(q=>({value:q.id,label:q.name}))],onChange:x}),de.nozzles.length>0&&s.jsx(rg,{label:o("profiles.cloudView.filters.nozzle"),value:b,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...de.nozzles.map(q=>({value:q,label:q}))],onChange:y}),de.filaments.length>0&&(u==="all"||u==="filament")&&s.jsx(rg,{label:o("profiles.cloudView.filters.filament"),value:v,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...de.filaments.map(q=>({value:q,label:q}))],onChange:S}),de.layerHeights.length>0&&(u==="all"||u==="process")&&s.jsx(rg,{label:o("profiles.cloudView.filters.layer"),value:M,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...de.layerHeights.map(q=>({value:q,label:q}))],onChange:T}),Y&&s.jsx("button",{onClick:G,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:o("profiles.cloudView.clearFilters")})]})]}),V&&s.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(_g,{className:"w-5 h-5 text-blue-400"}),s.jsx("span",{className:"text-white font-medium",children:o("profiles.cloudView.compareMode")}),s.jsx("span",{className:"text-bambu-gray",children:Z[0]?o("profiles.cloudView.selectAnotherPreset",{type:Z[0].type}):o("profiles.cloudView.clickTwoPresets")})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${Z[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Z[0]?Z[0].name:o("profiles.cloudView.selectFirst")}),s.jsx(uP,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${Z[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Z[1]?Z[1].name:o("profiles.cloudView.selectSecond")})]}),Z[0]&&Z[1]&&s.jsxs(Te,{size:"sm",onClick:async()=>{try{const[q,te]=await Promise.all([ue.getCloudSettingDetail(Z[0].setting_id),ue.getCloudSettingDetail(Z[1].setting_id)]);se([q.setting||{},te.setting||{}]),X(!0)}catch{}},children:[s.jsx(_g,{className:"w-4 h-4"}),o("profiles.cloudView.compareNow")]})]})]})}),s.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Jn,{className:"w-3 h-3"}),o("profiles.cloudView.lastSynced")," ",AKe(e.toISOString(),o)]}),s.jsx("span",{children:o("profiles.cloudView.showingCount",{showing:ie.length,total:ce})}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),s.jsxs("span",{children:["= ",o("profiles.presets.myPreset")]})]})]}),ie.length===0?s.jsxs("div",{className:"text-center py-16",children:[s.jsx(sl,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),s.jsx("p",{className:"text-bambu-gray",children:o("profiles.cloudView.noPresetsFound")}),Y&&s.jsx("button",{onClick:G,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:o("profiles.cloudView.clearFilters")})]}):s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[s.jsx(TR,{className:"w-4 h-4 text-amber-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.filament")}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ie.filter(q=>q.type==="filament").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ie.filter(q=>q.type==="filament").map(q=>s.jsx(Gj,{setting:q,onClick:()=>Me(q),onDuplicate:()=>ge(q),compareMode:V,isCompareSelected:Oe(q)!==void 0,compareIndex:Oe(q),compareDisabled:V&&!!Z[0]&&Z[0].type!==q.type,t:o},q.setting_id)),ie.filter(q=>q.type==="filament").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noFilamentPresets")})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[s.jsx(bh,{className:"w-4 h-4 text-blue-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.process")}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ie.filter(q=>q.type==="process").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ie.filter(q=>q.type==="process").map(q=>s.jsx(Gj,{setting:q,onClick:()=>Me(q),onDuplicate:()=>ge(q),compareMode:V,isCompareSelected:Oe(q)!==void 0,compareIndex:Oe(q),compareDisabled:V&&!!Z[0]&&Z[0].type!==q.type,t:o},q.setting_id)),ie.filter(q=>q.type==="process").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noProcessPresets")})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[s.jsx(Ur,{className:"w-4 h-4 text-purple-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.printer")}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ie.filter(q=>q.type==="printer").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ie.filter(q=>q.type==="printer").map(q=>s.jsx(Gj,{setting:q,onClick:()=>Me(q),onDuplicate:()=>ge(q),compareMode:V,isCompareSelected:Oe(q)!==void 0,compareIndex:Oe(q),compareDisabled:V&&!!Z[0]&&Z[0].type!==q.type,t:o},q.setting_id)),ie.filter(q=>q.type==="printer").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noPrinterPresets")})]})]})]}),E&&s.jsx(PKe,{setting:E,onClose:()=>C(null),onDeleted:()=>C(null),onDuplicate:()=>ge(E),onEdit:()=>Ke(E),hasPermission:a,t:o}),(k||U||H||$)&&s.jsx(RKe,{onClose:()=>{R(!1),F(null),j(null),K(null)},initialData:H||U||($?{type:$.type,name:"",base_id:"",setting:$.setting}:void 0),allPresets:t,t:o}),A&&s.jsx(DKe,{onClose:()=>D(!1),onApply:q=>{K({type:q.type,setting:q.settings}),D(!1)},t:o}),B&&ne&&Z[0]&&Z[1]&&s.jsx(Ire,{onClose:()=>{X(!1),se(null)},leftPreset:ne[0],rightPreset:ne[1],leftLabel:Z[0].name,rightLabel:Z[1].name,t:o})]})}function LKe(){const{t}=$n(),e=an(),{showToast:n}=Hn(),{hasPermission:r}=Ai(),[i,a]=_.useState("cloud"),[o,l]=_.useState(),{data:c,isLoading:u}=at({queryKey:["cloudStatus"],queryFn:ue.getCloudStatus}),{data:d=[]}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:f,isLoading:p,refetch:m,dataUpdatedAt:x}=at({queryKey:["cloudSettings"],queryFn:()=>ue.getCloudSettings(),enabled:!!c?.is_authenticated,retry:!1,staleTime:1e3*60*5});_.useEffect(()=>{x&&l(new Date(x))},[x]);const b=mt({mutationFn:ue.cloudLogout,onSuccess:()=>{e.invalidateQueries({queryKey:["cloudStatus"]}),e.removeQueries({queryKey:["cloudSettings"]}),n(t("profiles.toast.loggedOut"))}}),y=()=>{e.invalidateQueries({queryKey:["cloudStatus"]})};return u?s.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s.jsxs("div",{className:"p-6 lg:p-8",children:[s.jsxs("div",{className:"mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:t("profiles.title")}),s.jsx("p",{className:"text-bambu-gray",children:t("profiles.subtitle")})]}),s.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[s.jsxs("button",{onClick:()=>a("cloud"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i==="cloud"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(o2,{className:"w-4 h-4"}),t("profiles.tabs.cloud")]}),s.jsxs("button",{onClick:()=>a("kprofiles"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i==="kprofiles"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(d2,{className:"w-4 h-4"}),t("profiles.tabs.kprofiles")]})]}),i==="cloud"&&s.jsxs(s.Fragment,{children:[c?.is_authenticated&&s.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:[t("profiles.connectedAs")," ",s.jsx("span",{className:"text-white",children:c.email})]})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>b.mutate(),disabled:b.isPending||!r("cloud:auth"),title:r("cloud:auth")?void 0:t("profiles.noLogoutPermission"),children:[s.jsx(gP,{className:"w-4 h-4"}),t("profiles.logout")]})]}),c?.is_authenticated?p?s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):f?s.jsx(OKe,{settings:f,lastSyncTime:o,onRefresh:()=>m(),isRefreshing:p,printers:d,hasPermission:r,t}):s.jsxs("div",{className:"text-center py-16",children:[s.jsx("p",{className:"text-bambu-gray mb-4",children:t("profiles.failedToLoad")}),s.jsx(Te,{onClick:()=>m(),children:t("profiles.retry")})]}):s.jsx(CKe,{onSuccess:y,t})]}),i==="kprofiles"&&s.jsx(TKe,{}),s.jsx(jKe,{})]})}const g0={Droplet:TR,Flame:Pue,Ruler:dhe,Sparkles:W0,Square:ll,Cable:Mce,Wrench:om,Calendar:si,Timer:xu,Cog:aue,Fan:gW,Zap:vh,Wind:CW,Thermometer:b2,Layers:sl,Box:lo,Target:kW,RefreshCw:Dr,Settings:x2,Filter:u2,CircleDot:Vce};function z0(t){return t&&g0[t]||om}function ig(t,e,n){if(e==="days"){if(t<1)return n?n("common.today"):"Today";if(t===1)return n?n("maintenance.day"):"1 day";if(t<7){const i=Math.round(t);return n?n("maintenance.days",{count:i}):`${i} days`}if(t<180){const i=Math.round(t/7);return i===1?n?n("maintenance.week"):"1 week":n?n("maintenance.weeks",{count:i}):`${i} weeks`}const r=Math.round(t/30);return r===1?n?n("maintenance.month"):"1 month":n?n("maintenance.months",{count:r}):`${r} months`}else{if(t<1)return`${Math.round(t*60)}m`;if(t<24)return`${t<10?t.toFixed(1):Math.round(t)}h`;const r=t/24;if(r<7)return`${r<2?r.toFixed(1):Math.round(r)}d`;const i=r/7;return i<12?`${i<2?i.toFixed(1):Math.round(i)}w`:`${Math.round(i/4)}mo`}}function qj(t,e,n){return e==="days"?t===1?n?n("maintenance.day"):"1 day":t===7?n?n("maintenance.week"):"1 week":t===14?n?n("maintenance.weeks",{count:2}):"2 weeks":t===30?n?n("maintenance.month"):"1 month":t===60?n?n("maintenance.months",{count:2}):"2 months":t===90?n?n("maintenance.months",{count:3}):"3 months":t===180?n?n("maintenance.months",{count:6}):"6 months":t===365?n?n("maintenance.year"):"1 year":n?n("maintenance.days",{count:t}):`${t} days`:`${t}h`}function FKe(t,e){const n=(e||"").toUpperCase().replace(/[- ]/g,""),r=n.includes("X1"),i=n.includes("P1"),a=n.includes("A1MINI"),o=n.includes("A1")&&!a,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":a?"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":a||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":a?"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":a||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":a||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 IKe({item:t,onPerform:e,onToggle:n,hasPermission:r,t:i}){const a=z0(t.maintenance_type_icon),o=t.interval_type||"hours",c=(()=>{if(o==="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))})(),u=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",d=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",f=()=>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",p=()=>{if(!t.enabled)return i("common.disabled");if(o==="days"){const m=t.days_until_due??0;return t.is_due?i("maintenance.overdueBy",{duration:ig(Math.abs(m),"days",i)}):t.is_warning?i("maintenance.dueIn",{duration:ig(m,"days",i)}):i("maintenance.timeLeft",{duration:ig(m,"days",i)})}else return t.is_due?i("maintenance.overdueBy",{duration:ig(Math.abs(t.hours_until_due),"hours",i)}):t.is_warning?i("maintenance.dueIn",{duration:ig(t.hours_until_due,"hours",i)}):i("maintenance.timeLeft",{duration:ig(t.hours_until_due,"hours",i)})};return s.jsx("div",{className:`rounded-xl border p-4 transition-all ${f()}`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.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:[s.jsx(a,{className:`w-5 h-5 ${u()}`}),t.enabled&&(t.is_due||t.is_warning)&&s.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`})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),o==="days"&&s.jsx("span",{title:i("maintenance.timeBasedInterval"),children:s.jsx(si,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const m=t.maintenance_type_wiki_url||FKe(t.maintenance_type_name,t.printer_model);return m?s.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-bambu-green transition-colors shrink-0",title:i("maintenance.viewDocumentation"),onClick:x=>x.stopPropagation(),children:s.jsx(Kr,{className:"w-3.5 h-3.5"})}):null})()]}),s.jsx("div",{className:"mt-2 mb-1.5",children:s.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${d()}`,style:{width:`${c}%`}})})}),s.jsxs("div",{className:`text-xs flex items-center gap-1 ${u()}`,children:[t.is_due&&s.jsx(Cn,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&s.jsx(Jn,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&s.jsx(Ia,{className:"w-3 h-3"}),p()]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx("span",{title:r("maintenance:update")?void 0:i("maintenance.noPermissionUpdate"),children:s.jsx(On,{checked:t.enabled,onChange:m=>n(t.id,m),disabled:!r("maintenance:update")})}),s.jsxs(Te,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled||!r("maintenance:update"),title:r("maintenance:update")?void 0:i("maintenance.noPermissionPerform"),className:"!px-3",children:[s.jsx(Rh,{className:"w-3.5 h-3.5"}),i("common.reset")]})]})]})})}function UKe({overview:t,onPerform:e,onToggle:n,onSetHours:r,hasPermission:i,t:a}){const[o,l]=_.useState(!0),[c,u]=_.useState(!1),[d,f]=_.useState(t.total_print_hours.toFixed(1)),p=[...t.maintenance_items].sort((b,y)=>b.is_due&&!y.is_due?-1:!b.is_due&&y.is_due?1:b.is_warning&&!y.is_warning?-1:!b.is_warning&&y.is_warning?1:b.maintenance_type_id-y.maintenance_type_id),m=p.find(b=>b.enabled&&(b.is_due||b.is_warning)),x=()=>{const b=parseFloat(d);!isNaN(b)&&b>=0&&(r(t.printer_id,b),u(!1))};return s.jsxs(_t,{className:"overflow-hidden",children:[s.jsxs("div",{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),s.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&s.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:[s.jsx(Cn,{className:"w-3 h-3"}),a("maintenance.overdueCount",{count:t.due_count})]}),t.warning_count>0&&s.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:[s.jsx(Jn,{className:"w-3 h-3"}),a("maintenance.dueSoonCount",{count:t.warning_count})]}),t.due_count===0&&t.warning_count===0&&s.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:[s.jsx(Ia,{className:"w-3 h-3"}),a("maintenance.allGood")]})]})]}),s.jsxs("button",{onClick:()=>l(!o),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:[o?s.jsx(xh,{className:"w-4 h-4"}):s.jsx(ei,{className:"w-4 h-4"}),a(o?"common.collapse":"common.expand")]})]}),s.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:s.jsx(xu,{className:"w-4 h-4 text-bambu-gray"})}),c?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",value:d,onChange:b=>f(b.target.value),onKeyDown:b=>{b.key==="Enter"&&x(),b.key==="Escape"&&u(!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}),s.jsx("span",{className:"text-xs text-bambu-gray",children:a("common.hours")}),s.jsx(Te,{size:"sm",onClick:x,children:a("common.save")}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>u(!1),children:a("common.cancel")})]}):s.jsxs("button",{onClick:()=>{i("maintenance:update")&&(f(Math.round(t.total_print_hours).toString()),u(!0))},className:`group ${i("maintenance:update")?"":"cursor-not-allowed opacity-60"}`,title:i("maintenance:update")?void 0:a("maintenance.noPermissionEditHours"),children:[s.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)," ",a("common.hours"),s.jsx(rm,{className:`w-3 h-3 text-bambu-gray ${i("maintenance:update")?"group-hover:text-bambu-green":""}`})]}),s.jsx("div",{className:"text-xs text-bambu-gray",children:a("maintenance.totalPrintTime")})]})]}),s.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),m&&s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${m.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const b=z0(m.maintenance_type_icon);return s.jsx(b,{className:`w-4 h-4 ${m.is_due?"text-red-400":"text-amber-400"}`})})()}),s.jsxs("div",{children:[s.jsx("div",{className:`text-sm font-medium ${m.is_due?"text-red-400":"text-amber-400"}`,children:m.maintenance_type_name}),s.jsx("div",{className:`text-xs ${m.is_due?"text-red-400/70":"text-amber-400/70"}`,children:m.is_due?a("common.overdue"):a("maintenance.dueSoon")})]})]})]})]}),o&&s.jsx(Nt,{className:"pt-0 border-t border-bambu-dark-tertiary",children:s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:p.map(b=>s.jsx(IKe,{item:b,onPerform:e,onToggle:n,hasPermission:i,t:a},b.id))})})]})}function zKe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:a,onAssignType:o,onRemoveItem:l,hasPermission:c,t:u}){const[d,f]=_.useState(null),[p,m]=_.useState(""),[x,b]=_.useState("hours"),[y,v]=_.useState(!1),[S,M]=_.useState(""),[T,E]=_.useState("100"),[C,k]=_.useState("hours"),[R,A]=_.useState("Wrench"),[D,U]=_.useState(""),[F,H]=_.useState(new Set),[j,$]=_.useState(null),K=_.useMemo(()=>t?t.map(I=>({id:I.printer_id,name:I.printer_name})):[],[t]),V=I=>t?t.filter(fe=>fe.maintenance_items.some(me=>me.maintenance_type_id===I)).map(fe=>({printerId:fe.printer_id,printerName:fe.printer_name,itemId:fe.maintenance_items.find(me=>me.maintenance_type_id===I)?.id})):[],Q=I=>{if(!t)return[];const fe=new Set(V(I).map(me=>me.printerId));return K.filter(me=>!fe.has(me.id))},[Z,ae]=_.useState(null),[B,X]=_.useState(""),[ne,se]=_.useState(""),[be,xe]=_.useState("hours"),[de,Pe]=_.useState("Wrench"),[ie,Me]=_.useState(""),Oe=I=>{ae(I),X(I.name),se(I.default_interval_hours.toString()),xe(I.interval_type||"hours"),Pe(I.icon||"Wrench"),Me(I.wiki_url||"")},ge=()=>{Z&&B.trim()&&parseFloat(ne)>0&&(i(Z.id,{name:B.trim(),default_interval_hours:parseFloat(ne),interval_type:be,icon:de,wiki_url:ie.trim()||null}),ae(null))},Ke=(I,fe,me)=>{const ke=parseFloat(p);if(!isNaN(ke)&&ke>0){const z=Math.abs(ke-fe)<.01?null:ke;n(I,{custom_interval_hours:z,custom_interval_type:x!==me?x:null})}f(null)},G=I=>{I.preventDefault(),S.trim()&&parseFloat(T)>0&&F.size>0&&(r({name:S.trim(),default_interval_hours:parseFloat(T),interval_type:C,icon:R,wiki_url:D.trim()||null},Array.from(F)),M(""),E("100"),k("hours"),U(""),H(new Set),v(!1))},Y=I=>{H(fe=>{const me=new Set(fe);return me.has(I)?me.delete(I):me.add(I),me})},ce=t?.map(I=>({printerId:I.printer_id,printerName:I.printer_name,items:I.maintenance_items.sort((fe,me)=>fe.maintenance_type_id-me.maintenance_type_id)})).sort((I,fe)=>I.printerName.localeCompare(fe.printerName))||[],q=e.filter(I=>I.is_system),te=e.filter(I=>!I.is_system);return s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:u("maintenance.maintenanceTypes")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:u("maintenance.maintenanceTypesDescription")})]}),s.jsxs(Te,{onClick:()=>v(!y),disabled:!c("maintenance:create"),title:c("maintenance:create")?void 0:u("maintenance.noPermissionEditTypes"),children:[s.jsx(ur,{className:"w-4 h-4"}),u("maintenance.addCustomType")]})]}),y&&s.jsx(_t,{className:"mb-6",children:s.jsx(Nt,{className:"py-4",children:s.jsxs("form",{onSubmit:G,children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[s.jsxs("div",{className:"lg:col-span-2",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("common.name")}),s.jsx("input",{type:"text",value:S,onChange:I=>M(I.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:u("maintenance.exampleName"),autoFocus:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.intervalType")}),s.jsxs("select",{value:C,onChange:I=>{k(I.target.value),I.target.value==="days"?E("30"):E("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:[s.jsx("option",{value:"hours",children:u("maintenance.printHours")}),s.jsx("option",{value:"days",children:u("maintenance.calendarDays")})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.intervalValue",{type:C==="days"?u("maintenance.calendarDays").toLowerCase():u("common.hours")})}),s.jsx("input",{type:"number",value:T,onChange:I=>E(I.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"})]})]}),s.jsx("div",{className:"mt-4 flex items-end justify-between",children:s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.icon")}),s.jsx("div",{className:"flex gap-1",children:Object.keys(g0).map(I=>{const fe=g0[I];return s.jsx("button",{type:"button",onClick:()=>A(I),className:`p-2 rounded-lg transition-colors ${R===I?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:s.jsx(fe,{className:"w-4 h-4"})},I)})})]})}),s.jsxs("div",{className:"mt-4",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.documentationLink")}),s.jsx("input",{type:"url",value:D,onChange:I=>U(I.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/..."})]}),s.jsxs("div",{className:"mt-4",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.assignToPrinters")}),s.jsx("div",{className:"flex flex-wrap gap-2",children:K.map(I=>s.jsx("button",{type:"button",onClick:()=>Y(I.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${F.has(I.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:I.name},I.id))}),F.size===0&&s.jsx("p",{className:"text-xs text-orange-400 mt-1",children:u("maintenance.selectAtLeastOnePrinter")})]}),s.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:()=>{v(!1),H(new Set)},children:u("common.cancel")}),s.jsx(Te,{type:"submit",disabled:!S.trim()||F.size===0,children:u("maintenance.addType")})]})]})})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[q.map(I=>{const fe=z0(I.icon),me=I.interval_type||"hours";return s.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:s.jsx(fe,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-white truncate",children:I.name}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[me==="days"?s.jsx(si,{className:"w-3 h-3"}):s.jsx(xu,{className:"w-3 h-3"}),qj(I.default_interval_hours,me,u)]})]})]})},I.id)}),te.map(I=>{const fe=z0(I.icon),me=I.interval_type||"hours";if(Z?.id===I.id)return s.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx("input",{type:"text",value:B,onChange:le=>X(le.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:u("common.name"),autoFocus:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("select",{value:be,onChange:le=>xe(le.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:[s.jsx("option",{value:"hours",children:u("maintenance.printHours")}),s.jsx("option",{value:"days",children:u("maintenance.calendarDays")})]}),s.jsx("input",{type:"number",value:ne,onChange:le=>se(le.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"})]}),s.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(g0).map(le=>{const _e=g0[le];return s.jsx("button",{type:"button",onClick:()=>Pe(le),className:`p-1.5 rounded transition-colors ${de===le?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s.jsx(_e,{className:"w-3.5 h-3.5"})},le)})}),s.jsx("input",{type:"url",value:ie,onChange:le=>Me(le.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:u("maintenance.documentationLink")}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{size:"sm",onClick:ge,disabled:!B.trim(),children:u("common.save")}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>ae(null),children:u("common.cancel")})]})]})},I.id);const z=V(I.id),O=Q(I.id),ee=j===I.id;return s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:s.jsx(fe,{className:"w-5 h-5 text-bambu-green"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm font-medium text-white truncate",children:I.name}),s.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:u("maintenance.custom")})]}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[me==="days"?s.jsx(si,{className:"w-3 h-3"}):s.jsx(xu,{className:"w-3 h-3"}),qj(I.default_interval_hours,me,u)]})]}),s.jsxs("button",{onClick:()=>$(ee?null:I.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${z.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:u("maintenance.printersAssignedClick",{count:z.length}),children:[s.jsx(Ur,{className:"w-3 h-3"}),s.jsx("span",{className:"text-xs font-medium",children:z.length}),s.jsx(ei,{className:`w-3 h-3 transition-transform ${ee?"rotate-180":""}`})]}),s.jsx("button",{onClick:()=>Oe(I),disabled:!c("maintenance:update"),title:c("maintenance:update")?void 0:u("maintenance.noPermissionEditTypes"),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:s.jsx(rm,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{confirm(u("maintenance.deleteTypeConfirm",{name:I.name}))&&a(I.id)},disabled:!c("maintenance:delete"),title:c("maintenance:delete")?void 0:u("maintenance.noPermissionDeleteTypes"),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:s.jsx(rn,{className:"w-4 h-4"})})]}),ee&&s.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:u("maintenance.assignedToPrinters")}),z.length===0?s.jsx("p",{className:"text-xs text-orange-400",children:u("maintenance.noPrintersAssigned")}):s.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:z.map(le=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[le.printerName,s.jsx("button",{onClick:()=>le.itemId&&l(le.itemId),disabled:!c("maintenance:delete"),title:c("maintenance:delete")?u("maintenance.removeFromPrinter"):u("maintenance.noPermissionRemovePrinter"),className:`ml-1 ${c("maintenance:delete")?"hover:text-red-400":"opacity-50 cursor-not-allowed"}`,children:"×"})]},le.printerId))}),O.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:u("maintenance.addPrinterShort")}),O.map(le=>s.jsxs("button",{onClick:()=>o(le.id,I.id),disabled:!c("maintenance:create"),title:c("maintenance:create")?void 0:u("maintenance.noPermissionAssignPrinter"),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:["+ ",le.name]},le.id))]})]})]},I.id)})]})]}),ce.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"mb-4",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:u("maintenance.intervalOverrides")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:u("maintenance.intervalOverridesDescription")})]}),s.jsx("div",{className:"space-y-4",children:ce.map(I=>s.jsx(_t,{children:s.jsxs(Nt,{className:"py-4",children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:I.printerName}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:I.items.map(fe=>{const me=z0(fe.maintenance_type_icon),ke=e.find(_e=>_e.id===fe.maintenance_type_id),z=ke?.default_interval_hours||fe.interval_hours,O=ke?.interval_type||"hours",ee=fe.interval_type||"hours",le=d===fe.id;return s.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[s.jsx(me,{className:"w-4 h-4 text-bambu-gray shrink-0"}),s.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:fe.maintenance_type_name}),le?s.jsxs("div",{className:"flex items-center gap-1",children:[x==="days"?s.jsx(si,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):s.jsx(xu,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),s.jsxs("select",{value:x,onChange:_e=>b(_e.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[s.jsx("option",{value:"hours",children:u("maintenance.printHours")}),s.jsx("option",{value:"days",children:u("maintenance.calendarDays")})]}),s.jsx("input",{type:"number",value:p,onChange:_e=>m(_e.target.value),onKeyDown:_e=>{_e.key==="Enter"&&Ke(fe.id,z,O),_e.key==="Escape"&&f(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),s.jsx(Te,{size:"sm",onClick:()=>Ke(fe.id,z,O),children:"OK"})]}):s.jsxs("button",{onClick:()=>{c("maintenance:update")&&(f(fe.id),m(fe.interval_hours.toString()),b(ee))},disabled:!c("maintenance:update"),title:c("maintenance:update")?void 0:u("maintenance.noPermissionEditIntervals"),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:[ee==="days"?s.jsx(si,{className:"w-3 h-3"}):s.jsx(xu,{className:"w-3 h-3"}),qj(fe.interval_hours,ee,u),s.jsx(rm,{className:"w-3 h-3 text-bambu-gray"})]})]},fe.id)})})]})},I.printerId))})]}),ce.length===0&&s.jsx(_t,{children:s.jsxs(Nt,{className:"text-center py-12",children:[s.jsx(Jn,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),s.jsx("p",{className:"text-bambu-gray",children:u("common.noPrinters")}),s.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:u("maintenance.intervalOverridesDescription")})]})})]})}function BKe(){const{t}=$n(),e=an(),{showToast:n}=Hn(),{hasPermission:r}=Ai(),[i,a]=_.useState("status"),{data:o,isLoading:l}=at({queryKey:["maintenanceOverview"],queryFn:ue.getMaintenanceOverview}),{data:c}=at({queryKey:["maintenanceTypes"],queryFn:ue.getMaintenanceTypes}),u=mt({mutationFn:({id:E,notes:C})=>ue.performMaintenance(E,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.maintenanceComplete"))},onError:E=>{n(E.message,"error")}}),d=mt({mutationFn:({id:E,data:C})=>ue.updateMaintenanceItem(E,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:E=>{n(E.message,"error")}}),f=mt({mutationFn:({id:E,data:C})=>ue.updateMaintenanceType(E,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onError:E=>{n(E.message,"error")}}),p=mt({mutationFn:ue.deleteMaintenanceType,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeDeleted"))},onError:E=>{n(E.message,"error")}}),m=mt({mutationFn:({printerId:E,hours:C})=>ue.setPrinterHours(E,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.printHoursUpdated"))},onError:E=>{n(E.message,"error")}}),x=mt({mutationFn:({printerId:E,typeId:C})=>ue.assignMaintenanceType(E,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerAssigned"))},onError:E=>{n(E.message,"error")}}),b=mt({mutationFn:ue.removeMaintenanceItem,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerRemoved"))},onError:E=>{n(E.message,"error")}}),y=E=>{u.mutate({id:E})},v=(E,C)=>{d.mutate({id:E,data:{enabled:C}})},S=(E,C)=>{m.mutate({printerId:E,hours:C})};if(l)return s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})});const M=o?.reduce((E,C)=>E+C.due_count,0)||0,T=o?.reduce((E,C)=>E+C.warning_count,0)||0;return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:t("maintenance.title")}),s.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:i==="status"?s.jsxs(s.Fragment,{children:[M>0&&s.jsx("span",{className:"text-red-400",children:t("maintenance.dueCount",{count:M})}),M>0&&T>0&&" · ",T>0&&s.jsx("span",{className:"text-amber-400",children:t("maintenance.warningCount",{count:T})}),M===0&&T===0&&s.jsx("span",{className:"text-bambu-green",children:t("maintenance.allOk")})]}):t("maintenance.configureSettings")})]}),s.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>a("status"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${i==="status"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:t("maintenance.statusTab")}),s.jsx("button",{onClick:()=>a("settings"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${i==="settings"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:t("maintenance.settingsTab")})]}),i==="status"?s.jsx("div",{className:"space-y-6",children:o&&o.length>0?[...o].sort((E,C)=>{const k=E.due_count*10+E.warning_count,R=C.due_count*10+C.warning_count;return k!==R?R-k:E.printer_name.localeCompare(C.printer_name)}).map(E=>s.jsx(UKe,{overview:E,onPerform:y,onToggle:v,onSetHours:S,hasPermission:r,t},E.printer_id)):s.jsx(_t,{children:s.jsxs(Nt,{className:"text-center py-16",children:[s.jsx(om,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),s.jsx("p",{className:"text-lg font-medium text-white mb-2",children:t("common.noPrinters")}),s.jsx("p",{className:"text-bambu-gray",children:t("maintenance.configureSettings")})]})})}):s.jsx(zKe,{overview:o,types:c||[],onUpdateInterval:(E,C)=>d.mutate({id:E,data:C}),onAddType:async(E,C)=>{const k=await ue.createMaintenanceType(E);for(const R of C)await ue.assignMaintenanceType(R,k.id);e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onUpdateType:(E,C)=>f.mutate({id:E,data:C}),onDeleteType:E=>p.mutate(E),onAssignType:(E,C)=>x.mutate({printerId:E,typeId:C}),onRemoveItem:E=>b.mutate(E),hasPermission:r,t})]})}const pq=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function Ure({project:t,onClose:e,onSave:n,isLoading:r,t:i}){const[a,o]=_.useState(t?.name||""),[l,c]=_.useState(t?.description||""),[u,d]=_.useState(t?.color||pq[0]),[f,p]=_.useState(t?.target_count?.toString()||""),[m,x]=_.useState(t?.target_parts_count?.toString()||""),[b,y]=_.useState(t?.status||"active"),[v,S]=_.useState(t?.tags||""),[M,T]=_.useState(t?.due_date?.split("T")[0]||""),[E,C]=_.useState(t?.priority||"normal"),k=R=>{R.preventDefault(),n({name:a.trim(),description:l.trim()||void 0,color:u,target_count:f?parseInt(f,10):void 0,target_parts_count:m?parseInt(m,10):void 0,tags:v.trim()||void 0,due_date:M||void 0,priority:E,...t&&{status:b}})};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[s.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i(t?"projects.editProject":"projects.newProject")})}),s.jsxs("form",{onSubmit:k,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.name")}),s.jsx("input",{type:"text",value:a,onChange:R=>o(R.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:i("projects.namePlaceholder"),required:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.description")}),s.jsx("textarea",{value:l,onChange:R=>c(R.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:i("projects.descriptionPlaceholder"),rows:2})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.color")}),s.jsx("div",{className:"flex gap-2 flex-wrap",children:pq.map(R=>s.jsx("button",{type:"button",onClick:()=>d(R),className:`w-8 h-8 rounded-full transition-transform ${u===R?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:R}},R))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.targetPlates")}),s.jsx("input",{type:"number",value:f,onChange:R=>p(R.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:i("projects.targetPlatesPlaceholder"),min:"1"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("projects.targetPlatesHelp")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.targetParts")}),s.jsx("input",{type:"number",value:m,onChange:R=>x(R.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:i("projects.targetPartsPlaceholder"),min:"1"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("projects.targetPartsHelp")})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.tagsLabel")}),s.jsx("input",{type:"text",value:v,onChange:R=>S(R.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:i("projects.tagsPlaceholder")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.dueDate")}),s.jsx("input",{type:"date",value:M,onChange:R=>T(R.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.priority")}),s.jsxs("select",{value:E,onChange:R=>C(R.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:[s.jsx("option",{value:"low",children:i("projects.priorityLow")}),s.jsx("option",{value:"normal",children:i("projects.priorityNormal")}),s.jsx("option",{value:"high",children:i("projects.priorityHigh")}),s.jsx("option",{value:"urgent",children:i("projects.priorityUrgent")})]})]})]}),t&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.status")}),s.jsxs("select",{value:b,onChange:R=>y(R.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:[s.jsx("option",{value:"active",children:i("projects.statusActive")}),s.jsx("option",{value:"completed",children:i("projects.statusCompleted")}),s.jsx("option",{value:"archived",children:i("projects.statusArchived")})]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),s.jsx(Te,{type:"submit",disabled:!a.trim()||r,children:r?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):i(t?"common.save":"projects.create")})]})]})]})})}function $Ke({project:t,onClick:e,onEdit:n,onDelete:r,hasPermission:i,t:a}){const o=t.target_count?Math.round(t.archive_count/t.target_count*100):0,l=t.target_parts_count?Math.round(t.completed_count/t.target_parts_count*100):0,c=t.status==="completed",u=t.status==="archived",[d,f]=_.useState(!1),m=c?{icon:s2,color:"text-bambu-green",bg:"bg-bambu-green/10"}:u?{icon:fo,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:Jn,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:Ja,color:"text-bambu-gray",bg:"bg-bambu-gray/10"};return s.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:[s.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`}}),s.jsxs("div",{className:"p-5 pl-6",children:[s.jsxs("div",{className:"flex items-start justify-between mb-4",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx("div",{className:`p-2 rounded-lg ${m.bg} flex-shrink-0`,children:s.jsx(m.icon,{className:`w-5 h-5 ${m.color}`})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("h3",{className:"font-semibold text-white truncate",children:t.name}),t.target_parts_count?s.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${l>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.completed_count,"/",t.target_parts_count," ",a("projects.parts")]}):t.target_count?s.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.archive_count,"/",t.target_count," ",a("projects.plates")]}):t.completed_count>0?s.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," ",a("projects.parts")]}):null,c&&s.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap",children:a("projects.done")}),u&&s.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded-full whitespace-nowrap",children:a("projects.statusArchived")})]}),t.description&&s.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1 line-clamp-1",children:t.description}),t.archives&&t.archives.length>0&&(()=>{const x=t.archives.map(S=>S.filament_type).filter(Boolean).flatMap(S=>S.split(",").map(M=>M.trim())).filter(Boolean),b=[...new Set(x)],y=t.archives.map(S=>S.filament_color).filter(Boolean).flatMap(S=>S.split(",").map(M=>M.trim())).filter(S=>S.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(S)),v=[...new Set(y)];return b.length===0&&v.length===0?null:s.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[b.slice(0,3).map(S=>s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded",children:S},S)),v.length>0&&s.jsxs("div",{className:"flex items-center gap-0.5",children:[v.slice(0,5).map(S=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:S.startsWith("#")?S:`#${S}`},title:S},S)),v.length>5&&s.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",v.length-5]})]})]})})()]})]}),s.jsxs("div",{className:"relative",onClick:x=>x.stopPropagation(),children:[s.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:()=>f(!d),children:s.jsx(ih,{className:"w-4 h-4"})}),d&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>f(!1)}),s.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:[s.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(),f(!1))},disabled:!i("projects:update"),title:i("projects:update")?void 0:a("projects.noEditPermission"),children:[s.jsx(rm,{className:"w-4 h-4"}),a("common.edit")]}),s.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(),f(!1))},disabled:!i("projects:delete"),title:i("projects:delete")?void 0:a("projects.noDeletePermission"),children:[s.jsx(rn,{className:"w-4 h-4"}),a("common.delete")]})]})]})]})]}),s.jsx("div",{className:"mb-4",children:t.target_count||t.target_parts_count?s.jsxs("div",{className:"space-y-3",children:[t.target_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:a("projects.plates")}),s.jsxs("span",{className:o>=100?"text-bambu-green font-medium":"text-white",children:[t.archive_count," / ",t.target_count]})]}),s.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:s.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.target_parts_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:a("projects.parts")}),s.jsxs("span",{className:l>=100?"text-bambu-green font-medium":"text-white",children:[t.completed_count," / ",t.target_parts_count]})]}),s.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:s.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(l,100)}%`,background:l>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${l>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.failed_count>0&&s.jsxs("div",{className:"text-xs text-red-400",children:[t.failed_count," ",a("projects.failed")]})]}):t.completed_count>0||t.failed_count>0?s.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[t.completed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[s.jsx(fo,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.completed_count," ",a("projects.completed")]})]}),t.failed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",children:[s.jsx(Cn,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.failed_count," ",a("projects.failed")]})]}),t.queue_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",children:[s.jsx(Jn,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.queue_count," ",a("projects.inQueue")]})]})]}):s.jsx("div",{className:"text-xs text-bambu-gray/60 italic",children:a("projects.noPrintsYet")})}),t.archives&&t.archives.length>0&&s.jsxs("div",{className:"mb-4",children:[s.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:t.archives.slice(0,4).map(x=>s.jsxs("div",{className:"relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary",title:x.print_name||"Unknown",children:[x.thumbnail_path?s.jsx("img",{src:ue.getArchiveThumbnail(x.id),alt:x.print_name||"",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray/50",children:s.jsx(mc,{className:"w-6 h-6"})}),x.status==="failed"&&s.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:s.jsx(Cn,{className:"w-4 h-4 text-white"})})]},x.id))}),t.archive_count>4&&s.jsx("p",{className:"text-xs text-bambu-gray mt-1.5 text-center",children:a("common.more",{count:t.archive_count-4})})]}),s.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-4 text-xs text-bambu-gray",children:[s.jsxs("div",{className:"flex items-center gap-1.5",title:a("projects.printJobs"),children:[s.jsx(sl,{className:"w-3.5 h-3.5 text-blue-400"}),s.jsxs("span",{children:[t.archive_count," ",a("projects.plates")]})]}),s.jsxs("div",{className:"flex items-center gap-1.5",title:a("projects.partsPrinted"),children:[s.jsx(mc,{className:"w-3.5 h-3.5 text-bambu-green"}),s.jsxs("span",{children:[t.completed_count," ",a("projects.parts")]})]}),t.failed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",title:a("projects.failedParts"),children:[s.jsx(Cn,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:t.failed_count})]}),t.queue_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-yellow-400",title:a("projects.inQueue"),children:[s.jsx(pP,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:t.queue_count})]})]}),s.jsx(gs,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function HKe(){const{t}=$n(),e=Mc(),n=an(),{showToast:r}=Hn(),{hasPermission:i}=Ai(),[a,o]=_.useState(!1),[l,c]=_.useState(),[u,d]=_.useState("active"),[f,p]=_.useState(null),{data:m,isLoading:x}=at({queryKey:["projects",u==="all"?void 0:u],queryFn:()=>ue.getProjects(u==="all"?void 0:u)}),b=mt({mutationFn:H=>ue.createProject(H),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),r(t("projects.toast.created"),"success")},onError:H=>{r(H.message,"error")}}),y=mt({mutationFn:({id:H,data:j})=>ue.updateProject(H,j),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),c(void 0),r(t("projects.toast.updated"),"success")},onError:H=>{r(H.message,"error")}}),v=mt({mutationFn:H=>ue.deleteProject(H),onSuccess:()=>{p(null),r(t("projects.toast.deleted"),"success"),setTimeout(()=>window.location.reload(),100)},onError:H=>{p(null),r(H.message,"error")}}),S=mt({mutationFn:H=>ue.importProject(H),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success")},onError:H=>{r(H.message,"error")}}),M=_.useRef(null),T=async()=>{try{const H=await ue.getProjects(),j=await Promise.all(H.map(async Q=>await ue.exportProjectJson(Q.id))),$=new Blob([JSON.stringify(j,null,2)],{type:"application/json"}),K=URL.createObjectURL($),V=document.createElement("a");V.href=K,V.download=`bambuddy_projects_${new Date().toISOString().split("T")[0]}.json`,V.click(),URL.revokeObjectURL(K),r(t("projects.toast.exported"),"success")}catch(H){r(H.message,"error")}},E=()=>{M.current?.click()},C=async H=>{const j=H.target.files?.[0];if(j){try{if(j.name.toLowerCase().endsWith(".zip")){const K=new FormData;K.append("file",j);const V=await fetch("/api/v1/projects/import/file",{method:"POST",body:K});if(!V.ok){const Q=await V.json();throw new Error(Q.detail||"Import failed")}n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success")}else{const K=await j.text(),V=JSON.parse(K),Q=Array.isArray(V)?V:[V];for(const Z of Q)await S.mutateAsync(Z);Q.length>1&&r(t("projects.toast.multipleImported",{count:Q.length}),"success")}}catch($){r(`${t("projects.toast.importFailed")}: ${$.message}`,"error")}H.target.value=""}},k=H=>{l?y.mutate({id:l.id,data:H}):b.mutate(H)},R=H=>{c(H),o(!0)},A=H=>{e(`/projects/${H.id}`)},D=H=>{p(H)},U=()=>{f!==null&&v.mutate(f)},F=m?.reduce((H,j)=>(H[j.status]=(H[j.status]||0)+1,H.all=(H.all||0)+1,H),{})||{};return s.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[s.jsx("input",{ref:M,type:"file",accept:".json,.zip",onChange:C,className:"hidden"}),s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:s.jsx(Ja,{className:"w-6 h-6 text-bambu-green"})}),t("projects.title")]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("projects.subtitle")})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Te,{variant:"secondary",onClick:E,disabled:!i("projects:create"),title:i("projects:create")?t("projects.importProject"):t("projects.noImportPermission"),children:[s.jsx(Ua,{className:"w-4 h-4 mr-2"}),t("projects.import")]}),s.jsxs(Te,{variant:"secondary",onClick:T,disabled:!i("projects:read"),title:i("projects:read")?t("projects.exportAll"):t("projects.noExportPermission"),children:[s.jsx(yi,{className:"w-4 h-4 mr-2"}),t("projects.export")]}),s.jsxs(Te,{onClick:()=>o(!0),className:"sm:w-auto w-full",disabled:!i("projects:create"),title:i("projects:create")?void 0:t("projects.noCreatePermission"),children:[s.jsx(ur,{className:"w-4 h-4 mr-2"}),t("projects.newProject")]})]})]}),s.jsx("div",{className:"flex gap-1 p-1 bg-bambu-dark rounded-xl w-fit",children:[{key:"active",label:t("projects.statusActive"),icon:Jn},{key:"completed",label:t("projects.statusCompleted"),icon:s2},{key:"archived",label:t("projects.statusArchived"),icon:fo},{key:"all",label:t("common.all"),icon:Ja}].map(({key:H,label:j,icon:$})=>s.jsxs("button",{onClick:()=>d(H),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${u===H?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[s.jsx($,{className:"w-4 h-4"}),s.jsx("span",{children:j}),F[H]>0&&s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${u===H?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:F[H]})]},H))}),x?s.jsx("div",{className:"flex items-center justify-center py-20",children:s.jsxs("div",{className:"flex flex-col items-center gap-3",children:[s.jsx(ht,{className:"w-8 h-8 animate-spin text-bambu-green"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("projects.loading")})]})}):m?.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-4",children:[s.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:s.jsx(Ja,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:u==="all"?t("projects.noProjects"):t("projects.noProjectsFiltered",{status:u})}),s.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:u==="all"?t("projects.createFirst"):t("projects.noProjectsFilteredHelp",{status:u})}),u==="all"&&s.jsxs(Te,{onClick:()=>o(!0),disabled:!i("projects:create"),title:i("projects:create")?void 0:t("projects.noCreatePermission"),children:[s.jsx(ur,{className:"w-4 h-4 mr-2"}),t("projects.createFirstButton")]})]}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8",children:m?.map(H=>s.jsx($Ke,{project:H,onClick:()=>A(H),onEdit:()=>R(H),onDelete:()=>D(H.id),hasPermission:i,t},H.id))}),f!==null&&s.jsx(Qn,{title:t("projects.deleteProject"),message:t("projects.deleteConfirm"),confirmText:t("projects.deleteProject"),variant:"danger",onConfirm:U,onCancel:()=>p(null)}),a&&s.jsx(Ure,{project:l,onClose:()=>{o(!1),c(void 0)},onSave:k,isLoading:b.isPending||y.isPending,t})]})}function VKe(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 GKe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function qKe({status:t,t:e}){const n={active:"bg-bambu-green/20 text-bambu-green",completed:"bg-blue-500/20 text-blue-400",archived:"bg-bambu-gray/20 text-bambu-gray"},r=n[t]||n.active,i={active:e("projectDetail.status.active"),completed:e("projectDetail.status.completed"),archived:e("projectDetail.status.archived")};return s.jsx("span",{className:`px-2 py-1 rounded text-sm font-medium ${r}`,children:i[t]||t.charAt(0).toUpperCase()+t.slice(1)})}function gq({icon:t,label:e,value:n,subValue:r,hint:i,color:a="text-bambu-gray"}){return s.jsx(_t,{children:s.jsx(Nt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",title:i,children:[s.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${a}`,children:s.jsx(t,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:e}),s.jsx("p",{className:"text-xl font-semibold text-white",children:n}),r&&s.jsx("p",{className:"text-xs text-bambu-gray/70",children:r})]})]})})})}function WKe({archives:t,t:e}){return t.length===0?s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(mc,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),s.jsx("p",{children:e("projectDetail.noPrints")})]}):s.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(n=>s.jsxs(Ds,{to:`/archives?search=${encodeURIComponent(n.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:[n.thumbnail_path?s.jsx("img",{src:ue.getArchiveThumbnail(n.id),alt:n.print_name||"Print",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:s.jsx(mc,{className:"w-8 h-8"})}),n.status==="failed"&&s.jsx("div",{className:"absolute inset-0 bg-red-500/30 flex items-center justify-center",children:s.jsx(Yi,{className:"w-8 h-8 text-white"})}),n.status==="completed"&&s.jsx("div",{className:"absolute top-1 right-1",children:s.jsx(Ar,{className:"w-4 h-4 text-bambu-green"})}),s.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:s.jsx("p",{className:"text-xs text-white truncate",children:n.print_name||"Unknown"})})]},n.id))})}function KKe({priority:t,t:e}){const n={low:{color:"bg-gray-500/20 text-gray-400",label:e("projectDetail.priority.low")},normal:{color:"bg-blue-500/20 text-blue-400",label:e("projectDetail.priority.normal")},high:{color:"bg-orange-500/20 text-orange-400",label:e("projectDetail.priority.high")},urgent:{color:"bg-red-500/20 text-red-400",label:e("projectDetail.priority.urgent")}},{color:r,label:i}=n[t]||n.normal;return s.jsxs("span",{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${r}`,children:[t==="urgent"&&s.jsx(Cn,{className:"w-3 h-3"}),i]})}function XKe(t){return t?Bg(t,{year:"numeric",month:"short",day:"numeric"}):""}function Wj(t,e){if(!t)return null;const n=Ii(t);if(!n)return null;const r=new Date,i=Math.ceil((n.getTime()-r.getTime())/(1e3*60*60*24));return i<0?{color:"text-red-400",label:e("projectDetail.dueDate.overdue")}:i===0?{color:"text-orange-400",label:e("projectDetail.dueDate.today")}:i<=3?{color:"text-yellow-400",label:e("projectDetail.dueDate.daysLeft",{count:i})}:{color:"text-bambu-gray",label:e("projectDetail.dueDate.daysLeft",{count:i})}}function YKe(){const{id:t}=r2(),e=Mc(),{t:n}=$n(),r=an(),{showToast:i}=Hn(),{hasPermission:a}=Ai(),[o,l]=_.useState(!1),[c,u]=_.useState(!1),[d,f]=_.useState(""),p=parseInt(t||"0",10),{data:m,isLoading:x,error:b}=at({queryKey:["project",p],queryFn:()=>ue.getProject(p),enabled:p>0}),{data:y,isLoading:v}=at({queryKey:["project-archives",p],queryFn:()=>ue.getProjectArchives(p),enabled:p>0}),{data:S,isLoading:M}=at({queryKey:["project-bom",p],queryFn:()=>ue.getProjectBOM(p),enabled:p>0}),{data:T,isLoading:E}=at({queryKey:["project-timeline",p],queryFn:()=>ue.getProjectTimeline(p,20),enabled:p>0}),{data:C}=at({queryKey:["settings"],queryFn:ue.getSettings}),{data:k}=at({queryKey:["project-folders",p],queryFn:()=>ue.getLibraryFoldersByProject(p),enabled:p>0}),R=C?.currency||"$",A=C?.time_format||"system",D=mt({mutationFn:Se=>ue.updateProject(p,Se),onSuccess:()=>{r.invalidateQueries({queryKey:["project",p]}),r.invalidateQueries({queryKey:["projects"]}),l(!1),u(!1),i(n("projectDetail.toast.projectUpdated"),"success")},onError:Se=>{i(Se.message,"error")}}),U=()=>{f(m?.notes||""),u(!0)},F=()=>{D.mutate({notes:d})},H=()=>{u(!1),f("")},[j,$]=_.useState(""),[K,V]=_.useState(1),[Q,Z]=_.useState(""),[ae,B]=_.useState(""),[X,ne]=_.useState(""),[se,be]=_.useState(!1),[xe,de]=_.useState(!1),[Pe,ie]=_.useState(null),[Me,Oe]=_.useState(""),[ge,Ke]=_.useState(1),[G,Y]=_.useState(""),[ce,q]=_.useState(""),[te,I]=_.useState(""),[fe,me]=_.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),ke=mt({mutationFn:Se=>ue.createBOMItem(p,Se),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),$(""),V(1),Z(""),B(""),ne(""),be(!1),i(n("projectDetail.toast.partAdded"),"success")},onError:Se=>i(Se.message,"error")}),z=mt({mutationFn:({itemId:Se,data:Xe})=>ue.updateBOMItem(p,Se,Xe),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),ie(null)},onError:Se=>i(Se.message,"error")}),O=mt({mutationFn:Se=>ue.deleteBOMItem(p,Se),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),i(n("projectDetail.toast.partRemoved"),"success")},onError:Se=>i(Se.message,"error")}),ee=Se=>{Se.preventDefault(),j.trim()&&ke.mutate({name:j.trim(),quantity_needed:K,unit_price:Q?parseFloat(Q):void 0,sourcing_url:ae.trim()||void 0,remarks:X.trim()||void 0})},le=Se=>{const Xe=Se.is_complete?0:Se.quantity_needed;z.mutate({itemId:Se.id,data:{quantity_acquired:Xe}})},_e=(Se,Xe)=>{me({isOpen:!0,title:n("projectDetail.bom.deletePart"),message:n("projectDetail.bom.deleteConfirm",{name:Xe}),onConfirm:()=>{me(Ne=>({...Ne,isOpen:!1})),O.mutate(Se)}})},we=Se=>{ie(Se),Oe(Se.name),Ke(Se.quantity_needed),Y(Se.unit_price?.toString()||""),q(Se.sourcing_url||""),I(Se.remarks||"")},re=Se=>{Se.preventDefault(),!(!Pe||!Me.trim())&&z.mutate({itemId:Pe.id,data:{name:Me.trim(),quantity_needed:ge,unit_price:G?parseFloat(G):void 0,sourcing_url:ce.trim()||void 0,remarks:te.trim()||void 0}})},Fe=()=>{ie(null)},$e=async()=>{try{const Se=await fetch(`/api/v1/projects/${p}/export`);if(!Se.ok)throw new Error(n("projectDetail.toast.exportFailed"));const Xe=await Se.blob(),Ne=URL.createObjectURL(Xe),tt=document.createElement("a");tt.href=Ne;const We=Se.headers.get("Content-Disposition")?.match(/filename="(.+)"/);tt.download=We?.[1]||`${m?.name||"project"}_${new Date().toISOString().split("T")[0]}.zip`,tt.click(),URL.revokeObjectURL(Ne),i(n("projectDetail.toast.projectExported"),"success")}catch(Se){i(Se.message,"error")}},Ve=mt({mutationFn:()=>ue.createTemplateFromProject(p),onSuccess:()=>{r.invalidateQueries({queryKey:["projects"]}),i(n("projectDetail.toast.templateCreated"),"success")},onError:Se=>i(Se.message,"error")}),He=Se=>$g(Se,A,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(x)return s.jsx("div",{className:"flex items-center justify-center py-24",children:s.jsx(ht,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(b||!m)return s.jsxs("div",{className:"text-center py-24",children:[s.jsx("p",{className:"text-bambu-gray",children:b?`${n("common.error")}: ${b.message}`:n("projectDetail.notFound")}),s.jsx(Te,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:n("projectDetail.backToProjects")})]});const ye=m.stats,je=ye?.progress_percent??0,Be=ye?.parts_progress_percent??0;return s.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(Ds,{to:"/projects",className:"hover:text-white transition-colors",children:n("navigation.projects")}),s.jsx(gs,{className:"w-4 h-4"}),s.jsx("span",{className:"text-white",children:m.name})]}),s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("button",{onClick:()=>e("/projects"),className:"p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors",children:s.jsx(lce,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:m.color||"#6b7280"}}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:m.name}),m.description&&s.jsx("p",{className:"text-bambu-gray mt-1",children:m.description})]})]}),s.jsx(qKe,{status:m.status,t:n})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Te,{variant:"secondary",onClick:$e,disabled:!a("projects:read"),title:a("projects:read")?n("projectDetail.exportProject"):n("projectDetail.noExportPermission"),children:[s.jsx(yi,{className:"w-4 h-4 mr-2"}),n("projectDetail.export")]}),s.jsxs(Te,{onClick:()=>l(!0),disabled:!a("projects:update"),title:a("projects:update")?void 0:n("projectDetail.noEditPermission"),children:[s.jsx(rm,{className:"w-4 h-4 mr-2"}),n("common.edit")]})]})]}),(m.target_count||m.target_parts_count)&&s.jsx(_t,{children:s.jsxs(Nt,{className:"p-4 space-y-4",children:[m.target_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:n("projectDetail.progress.platesProgress")}),s.jsxs("span",{className:"text-sm font-medium text-white",children:[ye?.total_archives||0," / ",m.target_count," ",n("projectDetail.progress.printJobs")]})]}),s.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(je,100)}%`,backgroundColor:je>=100?"#22c55e":m.color||"#6b7280"}})}),s.jsxs("div",{className:"flex justify-between mt-1",children:[s.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:je.toFixed(0)})}),ye?.remaining_prints!=null&&ye.remaining_prints>0&&s.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:ye.remaining_prints})})]})]}),m.target_parts_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:n("projectDetail.progress.partsProgress")}),s.jsxs("span",{className:"text-sm font-medium text-white",children:[ye?.completed_prints||0," / ",m.target_parts_count," ",n("projectDetail.progress.parts")]})]}),s.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(Be,100)}%`,backgroundColor:Be>=100?"#22c55e":m.color||"#6b7280"}})}),s.jsxs("div",{className:"flex justify-between mt-1",children:[s.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:Be.toFixed(0)})}),ye?.remaining_parts!=null&&ye.remaining_parts>0&&s.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:ye.remaining_parts})})]})]})]})}),ye&&s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(_t,{children:s.jsx(Nt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:s.jsx(mc,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.printJobs")}),s.jsxs("p",{className:"text-xl font-semibold text-white",children:[ye.total_archives," ",s.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:n("projectDetail.stats.total")})]}),ye.failed_prints>0&&s.jsx("p",{className:"text-sm text-status-error",children:n("projectDetail.stats.failed",{count:ye.failed_prints})}),s.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.partsPrinted",{count:ye.completed_prints})})]})]})})}),s.jsx(gq,{icon:Jn,label:n("projectDetail.stats.printTime"),value:VKe(ye.total_print_time_hours),color:"text-yellow-400"}),s.jsx(gq,{icon:Ur,label:n("projectDetail.stats.filamentUsed"),value:GKe(ye.total_filament_grams),color:"text-purple-400"})]}),ye&&(ye.estimated_cost>0||m.budget)&&s.jsx(_t,{children:s.jsxs(Nt,{className:"p-4",children:[s.jsx("h2",{className:"text-lg font-semibold text-white mb-3",children:n("projectDetail.cost.title")}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.filamentCost")}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[R,ye.estimated_cost.toFixed(2)]})]}),ye.total_energy_kwh>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.energy")}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[ye.total_energy_kwh.toFixed(2)," kWh",ye.total_energy_cost>0&&s.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",R,ye.total_energy_cost.toFixed(2),")"]})]})]}),m.budget&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.budget")}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[R,m.budget.toFixed(2)]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.remaining")}),s.jsxs("p",{className:`text-lg font-semibold ${m.budget-ye.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[R,(m.budget-ye.estimated_cost).toFixed(2)]})]})]})]})]})}),m.children&&m.children.length>0&&s.jsx(_t,{children:s.jsxs(Nt,{className:"p-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[s.jsx(Iue,{className:"w-5 h-5"}),n("projectDetail.subProjects.title",{count:m.children.length})]}),s.jsx("div",{className:"space-y-2",children:m.children.map(Se=>s.jsxs(Ds,{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:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Se.color||"#6b7280"}}),s.jsx("span",{className:"text-white",children:Se.name}),s.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&&s.jsxs("span",{className:"text-sm text-bambu-gray",children:[Se.progress_percent.toFixed(0),"%"]})]},Se.id))})]})}),m.parent_id&&m.parent_name&&s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(sl,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.partOf")}),s.jsx(Ds,{to:`/projects/${m.parent_id}`,className:"text-bambu-green hover:underline",children:m.parent_name})]}),(m.tags||m.due_date||m.priority!=="normal")&&s.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[m.priority&&m.priority!=="normal"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.priorityLabel")}),s.jsx(KKe,{priority:m.priority,t:n})]}),m.due_date&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(si,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-white",children:XKe(m.due_date)}),Wj(m.due_date,n)&&s.jsxs("span",{className:`text-xs ${Wj(m.due_date,n).color}`,children:["(",Wj(m.due_date,n).label,")"]})]}),m.tags&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(yh,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:m.tags.split(",").map((Se,Xe)=>s.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:Se.trim()},Xe))})]})]}),s.jsx(_t,{children:s.jsxs(Nt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ls,{className:"w-5 h-5"}),n("projectDetail.notes.title")]}),c?s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Te,{variant:"secondary",size:"sm",onClick:H,disabled:D.isPending,children:[s.jsx(Rt,{className:"w-4 h-4 mr-1"}),n("common.cancel")]}),s.jsxs(Te,{size:"sm",onClick:F,disabled:D.isPending,children:[D.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin mr-1"}):s.jsx(hs,{className:"w-4 h-4 mr-1"}),n("common.save")]})]}):s.jsxs(Te,{variant:"secondary",size:"sm",onClick:U,disabled:!a("projects:update"),title:a("projects:update")?void 0:n("projectDetail.notes.noEditPermission"),children:[s.jsx(rm,{className:"w-4 h-4 mr-1"}),n("common.edit")]})]}),c?s.jsx(iR,{content:d,onChange:f,placeholder:n("projectDetail.notes.placeholder")}):m.notes?s.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:m.notes}}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.notes.empty")})]})}),s.jsx(_t,{children:s.jsxs(Nt,{className:"p-4",children:[s.jsx("div",{className:"flex items-center justify-between mb-3",children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Il,{className:"w-5 h-5"}),n("projectDetail.files.title")]})}),s.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[s.jsx(Ds,{to:"/files",className:"text-bambu-green hover:underline",children:n("projectDetail.files.linkFolders")})," ",n("projectDetail.files.forQuickAccess")]}),k&&k.length>0?s.jsx("div",{className:"space-y-2",children:k.map(Se=>s.jsxs(Ds,{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:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(Il,{className:"w-5 h-5 text-bambu-green flex-shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:Se.name}),s.jsx("p",{className:"text-xs text-bambu-gray",children:n("projectDetail.files.fileCount",{count:Se.file_count})})]})]}),s.jsx(gs,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},Se.id))}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.files.empty")})]})}),s.jsx(_t,{children:s.jsxs(Nt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(MW,{className:"w-5 h-5"}),n("projectDetail.bom.title"),ye&&ye.bom_total_items>0&&s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",n("projectDetail.bom.acquired",{completed:ye.bom_completed_items,total:ye.bom_total_items}),")"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[S&&S.some(Se=>Se.is_complete)&&s.jsx("button",{onClick:()=>de(!xe),className:`text-xs px-2 py-1 rounded transition-colors ${xe?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:n(xe?"projectDetail.bom.showAll":"projectDetail.bom.hideDone")}),!se&&s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>be(!0),disabled:!a("projects:update"),title:a("projects:update")?void 0:n("projectDetail.bom.noAddPermission"),children:[s.jsx(ur,{className:"w-4 h-4 mr-1"}),n("projectDetail.bom.addPart")]})]})]}),se&&s.jsxs("form",{onSubmit:ee,className:"bg-bambu-dark rounded-lg p-4 mb-4 space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[s.jsx("input",{type:"text",value:j,onChange:Se=>$(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:n("projectDetail.bom.partNamePlaceholder"),autoFocus:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"number",value:K,onChange:Se=>V(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:n("projectDetail.bom.qty")}),s.jsx("input",{type:"number",step:"0.01",value:Q,onChange:Se=>Z(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:n("projectDetail.bom.price",{currency:R})})]})]}),s.jsx("input",{type:"url",value:ae,onChange:Se=>B(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:n("projectDetail.bom.sourcingUrlPlaceholder")}),s.jsx("input",{type:"text",value:X,onChange:Se=>ne(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:n("projectDetail.bom.remarksPlaceholder")}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(Te,{type:"button",variant:"secondary",size:"sm",onClick:()=>be(!1),children:n("common.cancel")}),s.jsx(Te,{type:"submit",size:"sm",disabled:!j.trim()||ke.isPending,children:ke.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):n("projectDetail.bom.addPart")})]})]}),M?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(ht,{className:"w-6 h-6 animate-spin text-bambu-green"})}):S&&S.length>0?s.jsxs("div",{className:"space-y-2",children:[S.filter(Se=>!xe||!Se.is_complete).map(Se=>s.jsx("div",{className:`p-3 rounded-lg transition-colors ${Se.is_complete?"bg-status-ok/10":"bg-bambu-dark"}`,children:Pe?.id===Se.id?s.jsxs("form",{onSubmit:re,className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[s.jsx("input",{type:"text",value:Me,onChange:Xe=>Oe(Xe.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:n("projectDetail.bom.partName"),autoFocus:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"number",value:ge,onChange:Xe=>Ke(parseInt(Xe.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:n("projectDetail.bom.qty")}),s.jsx("input",{type:"number",step:"0.01",value:G,onChange:Xe=>Y(Xe.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:n("projectDetail.bom.price",{currency:R})})]})]}),s.jsx("input",{type:"url",value:ce,onChange:Xe=>q(Xe.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:n("projectDetail.bom.sourcingUrlPlaceholder")}),s.jsx("input",{type:"text",value:te,onChange:Xe=>I(Xe.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:n("projectDetail.bom.remarksPlaceholder")}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(Te,{type:"button",variant:"secondary",size:"sm",onClick:Fe,children:n("common.cancel")}),s.jsx(Te,{type:"submit",size:"sm",disabled:!Me.trim()||z.isPending,children:z.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):n("common.save")})]})]}):s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("button",{onClick:()=>a("projects:update")&&le(Se),disabled:z.isPending||!a("projects:update"),title:a("projects:update")?void 0:n("projectDetail.bom.noUpdatePermission"),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":a("projects:update")?"border-bambu-gray hover:border-bambu-green":"border-bambu-gray/50 cursor-not-allowed"}`,children:Se.is_complete&&s.jsx(Ar,{className:"w-3 h-3"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsxs("p",{className:`text-sm font-medium ${Se.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[Se.name,s.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",Se.quantity_needed]})]}),Se.unit_price!==null&&s.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[R,(Se.unit_price*Se.quantity_needed).toFixed(2)]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>a("projects:update")&&we(Se),disabled:!a("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${a("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:a("projects:update")?n("common.edit"):n("projectDetail.bom.noEditPermission"),children:s.jsx(Qi,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>a("projects:update")&&_e(Se.id,Se.name),disabled:!a("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${a("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:a("projects:update")?n("common.delete"):n("projectDetail.bom.noDeletePermission"),children:s.jsx(rn,{className:"w-4 h-4"})})]})]}),Se.sourcing_url&&s.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:Xe=>Xe.stopPropagation(),children:[s.jsx(Kr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:(()=>{try{return new URL(Se.sourcing_url).hostname.replace("www.","")}catch{return Se.sourcing_url}})()})]}),Se.remarks&&s.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:Se.remarks})]})]})},Se.id)),S.some(Se=>Se.unit_price!==null)&&s.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary flex justify-between text-sm",children:[s.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.bom.totalCost")}),s.jsxs("span",{className:"text-white font-medium",children:[R,S.reduce((Se,Xe)=>Se+(Xe.unit_price||0)*Xe.quantity_needed,0).toFixed(2)]})]})]}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.bom.empty")})]})}),s.jsx(_t,{children:s.jsxs(Nt,{className:"p-4",children:[s.jsx("div",{className:"flex items-center justify-between mb-3",children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(q0,{className:"w-5 h-5"}),n("projectDetail.timeline.title")]})}),E?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(ht,{className:"w-6 h-6 animate-spin text-bambu-green"})}):T&&T.length>0?s.jsx("div",{className:"space-y-3",children:T.slice(0,10).map((Se,Xe)=>s.jsxs("div",{className:"flex gap-3",children:[s.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"&&s.jsx(Ar,{className:"w-4 h-4"}),Se.event_type==="print_failed"&&s.jsx(Yi,{className:"w-4 h-4"}),Se.event_type==="print_started"&&s.jsx(Ur,{className:"w-4 h-4"}),Se.event_type==="queued"&&s.jsx(pP,{className:"w-4 h-4"}),Se.event_type==="project_created"&&s.jsx(ur,{className:"w-4 h-4"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white",children:Se.title}),Se.description&&s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:Se.description}),s.jsx("p",{className:"text-xs text-bambu-gray/70",children:He(Se.timestamp)})]})]},Xe))}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.timeline.empty")})]})}),!m.is_template&&s.jsx("div",{className:"flex justify-end",children:s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>Ve.mutate(),disabled:Ve.isPending||!a("projects:create"),title:a("projects:create")?void 0:n("projectDetail.template.noCreatePermission"),children:[Ve.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(Fl,{className:"w-4 h-4 mr-2"}),n("projectDetail.template.saveAsTemplate")]})}),ye&&(ye.queued_prints>0||ye.in_progress_prints>0)&&s.jsx(_t,{children:s.jsxs(Nt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(pP,{className:"w-5 h-5"}),n("projectDetail.queue.title")]}),s.jsx(Ds,{to:`/queue?project=${p}`,className:"text-sm text-bambu-green hover:underline",children:n("projectDetail.queue.viewAll")})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[ye.in_progress_prints>0&&s.jsx("span",{className:"text-yellow-400",children:n("projectDetail.queue.printing",{count:ye.in_progress_prints})}),ye.queued_prints>0&&s.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.queue.queued",{count:ye.queued_prints})})]})]})}),s.jsxs("div",{children:[s.jsx("div",{className:"flex items-center justify-between mb-4",children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(mc,{className:"w-5 h-5"}),n("projectDetail.prints.title",{count:y?.length||0})]})}),v?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 animate-spin text-bambu-green"})}):s.jsx(WKe,{archives:y||[],t:n})]}),o&&s.jsx(Ure,{t:n,project:{...m,archive_count:ye?.total_archives||0,total_items:ye?.total_items||0,completed_count:ye?.completed_prints||0,failed_count:ye?.failed_prints||0,queue_count:ye?.queued_prints||0,progress_percent:ye?.progress_percent||null,archives:[]},onClose:()=>l(!1),onSave:Se=>D.mutate(Se),isLoading:D.isPending}),fe.isOpen&&s.jsx(Qn,{title:fe.title,message:fe.message,confirmText:n("common.delete"),variant:"danger",onConfirm:fe.onConfirm,onCancel:()=>me(Se=>({...Se,isOpen:!1}))})]})}function hg(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 QKe(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 ZKe({parentId:t,onClose:e,onSave:n,isLoading:r,t:i}){const[a,o]=_.useState(""),l=c=>{c.preventDefault(),n({name:a.trim(),parent_id:t})};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[s.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("fileManager.newFolder")})}),s.jsxs("form",{onSubmit:l,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("fileManager.folderName")}),s.jsx("input",{type:"text",value:a,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",placeholder:i("fileManager.folderNamePlaceholder"),autoFocus:!0,required:!0})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),s.jsx(Te,{type:"submit",disabled:!a.trim()||r,children:r?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):i("common.create")})]})]})]})})}function JKe({type:t,currentName:e,onClose:n,onSave:r,isLoading:i,t:a}){const[o,l]=_.useState(e),c=u=>{u.preventDefault(),o.trim()&&o.trim()!==e&&r(o.trim())};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[s.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:a(t==="file"?"fileManager.renameFile":"fileManager.renameFolder")})}),s.jsxs("form",{onSubmit:c,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:a("common.name")}),s.jsx("input",{type:"text",value:o,onChange:u=>l(u.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})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:n,children:a("common.cancel")}),s.jsx(Te,{type:"submit",disabled:!o.trim()||o.trim()===e||i,children:i?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):a("common.rename")})]})]})]})})}function eXe({folders:t,selectedFiles:e,currentFolderId:n,onClose:r,onMove:i,isLoading:a,t:o}){const[l,c]=_.useState(null),u=(f,p=0)=>{const m=[];for(const x of f)m.push({id:x.id,name:x.name,depth:p}),x.children.length>0&&m.push(...u(x.children,p+1));return m},d=[{id:null,name:o("fileManager.rootNoFolder"),depth:0},...u(t)];return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[s.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:o("fileManager.moveFiles",{count:e.length})})}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1",children:d.map(f=>s.jsxs("button",{onClick:()=>c(f.id),disabled:f.id===n,className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===f.id?"bg-bambu-green/20 text-bambu-green":f.id===n?"opacity-50 cursor-not-allowed text-bambu-gray":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${12+f.depth*16}px`},children:[s.jsx(Il,{className:"w-4 h-4"}),f.name,f.id===n&&s.jsxs("span",{className:"text-xs text-bambu-gray ml-auto",children:["(",o("fileManager.current"),")"]})]},f.id??"root"))}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:r,children:o("common.cancel")}),s.jsx(Te,{onClick:()=>i(l),disabled:a,children:a?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):o("common.move")})]})]})]})})}function tXe({folder:t,onClose:e,onLink:n,isLoading:r,t:i}){const[a,o]=_.useState("project"),[l,c]=_.useState(t.project_id||t.archive_id||null);_.useState(()=>{t.archive_id&&o("archive")});const{data:u}=at({queryKey:["projects"],queryFn:()=>ue.getProjects()}),{data:d}=at({queryKey:["archives-for-link"],queryFn:()=>ue.getArchives(void 0,void 0,100)}),f=()=>{n(a==="project"?{project_id:l,archive_id:0}:{project_id:0,archive_id:l})},p=()=>{n({project_id:0,archive_id:0})},m=t.project_id||t.archive_id;return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(uc,{className:"w-5 h-5 text-bambu-green"}),i("fileManager.linkFolder")]}),s.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:i("fileManager.linkFolderDescription",{name:t.name})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:()=>{o("project"),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${a==="project"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[s.jsx(mW,{className:"w-4 h-4"}),i("fileManager.project")]}),s.jsxs("button",{onClick:()=>{o("archive"),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${a==="archive"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[s.jsx(fo,{className:"w-4 h-4"}),i("fileManager.archive")]})]}),s.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1 bg-bambu-dark rounded-lg p-2",children:a==="project"?u&&u.length>0?u.map(x=>s.jsxs("button",{onClick:()=>c(x.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===x.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:x.color||"#00ae42"}}),s.jsx("span",{className:"truncate",children:x.name})]},x.id)):s.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:i("fileManager.noProjectsFound")}):d&&d.length>0?d.map(x=>s.jsxs("button",{onClick:()=>c(x.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===x.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[s.jsx(zf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"truncate",children:x.print_name||x.filename})]},x.id)):s.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:i("fileManager.noArchivesFound")})})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-between",children:[m&&s.jsxs(Te,{variant:"danger",onClick:p,disabled:r,children:[s.jsx(RR,{className:"w-4 h-4 mr-2"}),i("fileManager.unlink")]}),s.jsxs("div",{className:`flex gap-2 ${m?"":"ml-auto"}`,children:[s.jsx(Te,{variant:"secondary",onClick:e,children:i("common.cancel")}),s.jsx(Te,{onClick:f,disabled:!l||r,children:r?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):i("fileManager.link")})]})]})]})})}function nXe({folderId:t,onClose:e,onUploadComplete:n,t:r}){const[i,a]=_.useState([]),[o,l]=_.useState(!1),[c,u]=_.useState(!1),[d,f]=_.useState(!0),[p,m]=_.useState(!1),[x,b]=_.useState(!0),y=_.useRef(null),v=j=>{j.preventDefault(),l(!0)},S=j=>{j.preventDefault(),l(!1)},M=j=>{j.preventDefault(),l(!1);const $=Array.from(j.dataTransfer.files);E($)},T=j=>{j.target.files&&E(Array.from(j.target.files))},E=j=>{const $=j.map(K=>({file:K,status:"pending",isZip:K.name.toLowerCase().endsWith(".zip")}));a(K=>[...K,...$])},C=j=>{a($=>$.filter((K,V)=>V!==j))},k=i.some(j=>j.isZip&&j.status==="pending"),R=i.some(j=>j.file.name.toLowerCase().endsWith(".stl")&&j.status==="pending"),A=async()=>{if(i.length!==0){u(!0);for(let j=0;j<i.length;j++)if(i[j].status==="pending"){a($=>$.map((K,V)=>V===j?{...K,status:"uploading"}:K));try{if(i[j].isZip){const $=await ue.extractZipFile(i[j].file,t,d,p,x);a(K=>K.map((V,Q)=>Q===j?{...V,status:$.errors.length>0&&$.extracted===0?"error":"success",extractedCount:$.extracted,error:$.errors.length>0?`${$.errors.length} files failed`:void 0}:V))}else await ue.uploadLibraryFile(i[j].file,t,x),a($=>$.map((K,V)=>V===j?{...K,status:"success"}:K))}catch($){a(K=>K.map((V,Q)=>Q===j?{...V,status:"error",error:$ instanceof Error?$.message:"Upload failed"}:V))}}u(!1),n(),e()}},D=i.filter(j=>j.status==="pending").length,U=i.filter(j=>j.status==="success").length,F=i.filter(j=>j.status==="error").length,H=i.length>0&&D===0&&!c;return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r("fileManager.uploadFiles")}),s.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("div",{onDragOver:v,onDragLeave:S,onDrop:M,onClick:()=>y.current?.click(),className:`border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,children:[s.jsx(Ua,{className:`w-10 h-10 mx-auto mb-3 ${o?"text-bambu-green":"text-bambu-gray"}`}),s.jsx("p",{className:"text-white font-medium",children:r(o?"fileManager.dropFilesHere":"fileManager.dragDropFiles")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:r("fileManager.orClickToBrowse")}),s.jsx("p",{className:"text-xs text-bambu-gray/70 mt-2",children:r("fileManager.allFileTypesSupported")})]}),s.jsx("input",{ref:y,type:"file",multiple:!0,className:"hidden",onChange:T}),k&&s.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(fo,{className:"w-5 h-5 text-blue-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-sm text-blue-300 font-medium",children:r("fileManager.zipFilesDetected")}),s.jsx("p",{className:"text-xs text-blue-300/70 mt-1",children:r("fileManager.zipExtractOptions")}),s.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:d,onChange:j=>f(j.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("span",{className:"text-sm text-white",children:r("fileManager.preserveZipStructure")})]}),s.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:p,onChange:j=>m(j.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("span",{className:"text-sm text-white",children:r("fileManager.createFolderFromZip")})]})]})]})}),(R||k)&&s.jsx("div",{className:"p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Ou,{className:"w-5 h-5 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-sm text-bambu-green font-medium",children:r("fileManager.stlThumbnailGeneration")}),s.jsx("p",{className:"text-xs text-bambu-green/70 mt-1",children:r(k&&!R?"fileManager.zipMayContainStl":"fileManager.thumbnailsCanBeGenerated")}),s.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:x,onChange:j=>b(j.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("span",{className:"text-sm text-white",children:r("fileManager.generateThumbnailsForStl")})]})]})]})}),i.length>0&&s.jsx("div",{className:"max-h-48 overflow-y-auto space-y-2",children:i.map((j,$)=>s.jsxs("div",{className:"flex items-center gap-3 p-2 bg-bambu-dark rounded-lg",children:[j.isZip?s.jsx(fo,{className:"w-4 h-4 text-blue-400 flex-shrink-0"}):s.jsx(c2,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:j.file.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[(j.file.size/1024/1024).toFixed(2)," MB",j.isZip&&j.status==="pending"&&s.jsxs("span",{className:"text-blue-400 ml-2",children:["• ",r("fileManager.willBeExtracted")]}),j.extractedCount!==void 0&&s.jsxs("span",{className:"text-green-400 ml-2",children:["• ",r("fileManager.filesExtracted",{count:j.extractedCount})]})]})]}),j.status==="pending"&&s.jsx("button",{onClick:()=>C($),className:"p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Rt,{className:"w-4 h-4 text-bambu-gray"})}),j.status==="uploading"&&s.jsx(ht,{className:"w-4 h-4 text-bambu-green animate-spin"}),j.status==="success"&&s.jsx(Ar,{className:"w-4 h-4 text-green-500"}),j.status==="error"&&s.jsx("span",{title:j.error,children:s.jsx(Yi,{className:"w-4 h-4 text-red-500"})})]},$))}),H&&s.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:s.jsxs("p",{className:"text-sm text-white",children:[r("fileManager.uploadComplete",{succeeded:U}),F>0&&s.jsxs("span",{className:"text-red-400",children:[", ",r("fileManager.uploadFailed",{count:F})]})]})})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2",children:[s.jsx(Te,{variant:"secondary",onClick:e,children:r(H?"common.close":"common.cancel")}),!H&&s.jsx(Te,{onClick:A,disabled:D===0||c,children:c?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 mr-2 animate-spin"}),r("fileManager.uploading")]}):s.jsxs(s.Fragment,{children:[s.jsx(Ua,{className:"w-4 h-4 mr-2"}),r("common.upload")," ",D>0?`(${D})`:""]})})]})]})})}function zre({folder:t,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o=0,wrapNames:l=!1,hasPermission:c,t:u}){const[d,f]=_.useState(!0),[p,m]=_.useState(!1),x=t.children.length>0,b=t.project_id||t.archive_id;return s.jsxs("div",{children:[s.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:[x?s.jsx("button",{onClick:y=>{y.stopPropagation(),f(!d)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(gs,{className:`w-3.5 h-3.5 transition-transform ${d?"rotate-90":""}`})}):s.jsx("div",{className:"w-4.5"}),s.jsx(Il,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),s.jsx("span",{className:`text-sm flex-1 min-w-0 ${l?"break-all":"truncate"}`,title:t.name,children:t.name}),b&&s.jsxs("button",{onClick:y=>{y.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:[s.jsx(uc,{className:"w-3 h-3"}),t.project_name?s.jsx(mW,{className:"w-3 h-3"}):s.jsx(fo,{className:"w-3 h-3"})]}),t.file_count>0&&s.jsx("span",{className:"flex-shrink-0 text-xs text-bambu-gray",children:t.file_count}),!b&&s.jsx("button",{onClick:y=>{y.stopPropagation(),i(t)},className:"flex-shrink-0 p-1 rounded hover:bg-bambu-dark-tertiary",title:u("fileManager.linkToProjectOrArchive"),children:s.jsx(uc,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-bambu-green"})}),s.jsx("div",{className:`flex-shrink-0 flex items-center gap-0.5 transition-opacity ${l?"":"opacity-0 group-hover:opacity-100"}`,onClick:y=>y.stopPropagation(),children:s.jsxs("div",{className:"relative",children:[s.jsx("button",{onClick:()=>m(!p),className:"p-1 rounded hover:bg-bambu-dark-tertiary",children:s.jsx(ih,{className:"w-3.5 h-3.5 text-bambu-gray"})}),p&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>m(!1)}),s.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:[s.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")&&(a(t),m(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:u("fileManager.noPermissionRenameFolder"),children:[s.jsx(Qi,{className:"w-3.5 h-3.5"}),u("common.rename")]}),s.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:u("fileManager.noPermissionLinkFolder"),children:[s.jsx(uc,{className:"w-3.5 h-3.5"}),u(b?"fileManager.changeLink":"fileManager.linkTo")]}),s.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:u("fileManager.noPermissionDeleteFolder"),children:[s.jsx(rn,{className:"w-3.5 h-3.5"}),u("common.delete")]})]})]})]})})]}),x&&d&&s.jsx("div",{children:t.children.map(y=>s.jsx(zre,{folder:y,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o+1,wrapNames:l,hasPermission:c,t:u},y.id))})]})}function hR(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function rXe({file:t,isSelected:e,isMobile:n,onSelect:r,onDelete:i,onDownload:a,onAddToQueue:o,onPrint:l,onRename:c,onGenerateThumbnail:u,thumbnailVersion:d,hasPermission:f,canModify:p,t:m}){const[x,b]=_.useState(!1);return s.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:[s.jsxs("div",{className:"aspect-square bg-bambu-dark flex items-center justify-center overflow-hidden",children:[t.thumbnail_path?s.jsx("img",{src:`${ue.getLibraryFileThumbnailUrl(t.id)}${d?`?v=${d}`:""}`,alt:t.filename,className:"w-full h-full object-cover"}):s.jsx(zf,{className:"w-12 h-12 text-bambu-gray/30"}),s.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()})]}),s.jsxs("div",{className:"p-3",children:[s.jsx("h3",{className:"text-sm font-medium text-white truncate",title:t.print_name||t.filename,children:t.print_name||t.filename}),s.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-bambu-gray",children:[s.jsx("span",{children:hg(t.file_size)}),t.print_time_seconds&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Jn,{className:"w-3 h-3"}),QKe(t.print_time_seconds)]})]}),t.print_count>0&&s.jsx("div",{className:"mt-1 text-xs text-bambu-green",children:m("fileManager.printedCount",{count:t.print_count})}),t.created_by_username&&s.jsx("div",{className:"mt-1 text-xs text-bambu-gray",children:m("fileManager.uploadedBy",{name:t.created_by_username})})]}),s.jsxs("div",{className:`absolute bottom-2 right-2 transition-opacity ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:y=>y.stopPropagation(),children:[s.jsx("button",{onClick:()=>b(!x),className:"p-1.5 rounded bg-bambu-dark-secondary/90 hover:bg-bambu-dark-tertiary",children:s.jsx(ih,{className:"w-4 h-4 text-bambu-gray"})}),x&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>b(!1)}),s.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&&hR(t.filename)&&s.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("printers:control")?"text-bambu-green hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("printers:control")&&(l(t),b(!1))},disabled:!f("printers:control"),title:f("printers:control")?void 0:m("fileManager.noPermissionPrint"),children:[s.jsx(Ur,{className:"w-3.5 h-3.5"}),m("common.print")]}),o&&hR(t.filename)&&s.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("queue:create")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("queue:create")&&(o(t.id),b(!1))},disabled:!f("queue:create"),title:f("queue:create")?void 0:m("fileManager.noPermissionAddToQueue"),children:[s.jsx(Jn,{className:"w-3.5 h-3.5"}),m("fileManager.addToQueue")]}),s.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("library:read")&&(a(t.id),b(!1))},disabled:!f("library:read"),title:f("library:read")?void 0:m("fileManager.noPermissionDownload"),children:[s.jsx(yi,{className:"w-3.5 h-3.5"}),m("common.download")]}),c&&s.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)&&(c(t),b(!1))},disabled:!p("library","update",t.created_by_id),title:p("library","update",t.created_by_id)?void 0:m("fileManager.noPermissionRenameFile"),children:[s.jsx(Qi,{className:"w-3.5 h-3.5"}),m("common.rename")]}),u&&t.file_type==="stl"&&s.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:m("fileManager.noPermissionGenerateThumbnail"),children:[s.jsx(Ou,{className:"w-3.5 h-3.5"}),m("fileManager.generateThumbnail")]}),s.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:m("fileManager.noPermissionDeleteFile"),children:[s.jsx(rn,{className:"w-3.5 h-3.5"}),m("common.delete")]})]})]})]}),s.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&&s.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})})]})}function iXe(){const{t}=$n(),e=an(),{showToast:n}=Hn(),{hasPermission:r,hasAnyPermission:i,canModify:a}=Ai(),[o]=wR(),l=o.get("folder"),c=l?parseInt(l,10):null,[u,d]=_.useState(c),[f,p]=_.useState([]),[m,x]=_.useState(!1),[b,y]=_.useState(!1),[v,S]=_.useState(!1),[M,T]=_.useState(null),[E,C]=_.useState(null),[k,R]=_.useState(null),[A,D]=_.useState(null),[U,F]=_.useState(null),[H,j]=_.useState({}),[$,K]=_.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[V,Q]=_.useState(()=>localStorage.getItem("library-wrap-folders")==="true"),[Z,ae]=_.useState(()=>{const W=localStorage.getItem("library-sidebar-width");return W?parseInt(W,10):256}),[B,X]=_.useState(!1),ne=_.useRef(null);_.useEffect(()=>{if(!B)return;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const W=Ye=>{if(!ne.current)return;const xt=ne.current.parentElement?.getBoundingClientRect();if(!xt)return;const ft=Ye.clientX-xt.left,Bt=Math.min(500,Math.max(200,ft));ae(Bt)},De=()=>{X(!1),document.body.style.userSelect="",document.body.style.cursor="",localStorage.setItem("library-sidebar-width",String(Z))};return document.addEventListener("mousemove",W),document.addEventListener("mouseup",De),()=>{document.removeEventListener("mousemove",W),document.removeEventListener("mouseup",De),document.body.style.userSelect="",document.body.style.cursor=""}},[B,Z]);const[se,be]=_.useState(""),[xe,de]=_.useState("all"),[Pe,ie]=_.useState(()=>localStorage.getItem("library-sort-field")||"name"),[Me,Oe]=_.useState(()=>localStorage.getItem("library-sort-direction")||"asc"),ge=IR();_.useEffect(()=>{const W=o.get("folder");if(W){const De=parseInt(W,10);d(De)}},[o]);const{data:Ke}=at({queryKey:["settings"],queryFn:()=>ue.getSettings()}),{data:G,isLoading:Y}=at({queryKey:["library-folders"],queryFn:()=>ue.getLibraryFolders()}),{data:ce,isLoading:q}=at({queryKey:["library-files",u],queryFn:()=>ue.getLibraryFiles(u,u===null)}),{data:te}=at({queryKey:["library-stats"],queryFn:()=>ue.getLibraryStats()}),I=_.useMemo(()=>{if(!ce)return[];const W=new Set(ce.map(De=>De.file_type));return Array.from(W).sort()},[ce]),fe=_.useMemo(()=>{if(!ce)return[];let W=[...ce];if(se.trim()){const De=se.toLowerCase();W=W.filter(Ye=>Ye.filename.toLowerCase().includes(De)||Ye.print_name&&Ye.print_name.toLowerCase().includes(De))}return xe!=="all"&&(W=W.filter(De=>De.file_type===xe)),W.sort((De,Ye)=>{let xt=0;switch(Pe){case"name":xt=(De.print_name||De.filename).localeCompare(Ye.print_name||Ye.filename);break;case"date":xt=new Date(De.created_at).getTime()-new Date(Ye.created_at).getTime();break;case"size":xt=De.file_size-Ye.file_size;break;case"type":xt=De.file_type.localeCompare(Ye.file_type);break;case"prints":xt=De.print_count-Ye.print_count;break}return Me==="asc"?xt:-xt}),W},[ce,se,xe,Pe,Me]),me=_.useMemo(()=>{if(!te||!Ke)return!1;const W=(Ke.library_disk_warning_gb||5)*1024*1024*1024;return te.disk_free_bytes<W},[te,Ke]),ke=mt({mutationFn:W=>ue.createLibraryFolder(W),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),x(!1),n(t("fileManager.toast.folderCreated"),"success")},onError:W=>n(W.message,"error")}),z=mt({mutationFn:W=>ue.deleteLibraryFolder(W),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-stats"]}),u===E?.id&&d(null),C(null),n(t("fileManager.toast.folderDeleted"),"success")},onError:W=>{C(null),n(W.message,"error")}}),O=mt({mutationFn:W=>ue.deleteLibraryFile(W),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),p(W=>W.filter(De=>De!==E?.id)),C(null),n(t("fileManager.toast.fileDeleted"),"success")},onError:W=>{C(null),n(W.message,"error")}}),ee=mt({mutationFn:W=>ue.bulkDeleteLibrary(W,[]),onSuccess:(W,De)=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),n(t("fileManager.toast.filesDeleted",{count:De.length}),"success"),p([]),C(null)},onError:W=>{C(null),n(W.message,"error")}}),le=mt({mutationFn:({fileIds:W,folderId:De})=>ue.moveLibraryFiles(W,De),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),p([]),y(!1),n(t("fileManager.toast.filesMoved"),"success")},onError:W=>n(W.message,"error")}),_e=mt({mutationFn:({id:W,data:De})=>ue.updateLibraryFolder(W,De),onSuccess:(W,De)=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["project-folders"]}),e.invalidateQueries({queryKey:["archive-folders"]}),T(null);const Ye=De.data.project_id===0&&De.data.archive_id===0;n(t(Ye?"fileManager.toast.folderUnlinked":"fileManager.toast.folderLinked"),"success")},onError:W=>n(W.message,"error")}),we=mt({mutationFn:W=>ue.addLibraryFilesToQueue(W),onSuccess:W=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["queue"]}),e.invalidateQueries({queryKey:["archives"]}),p([]),W.added.length>0&&W.errors.length===0?n(t("fileManager.toast.addedToQueue",{count:W.added.length}),"success"):W.added.length>0&&W.errors.length>0?n(t("fileManager.toast.addedToQueuePartial",{added:W.added.length,failed:W.errors.length}),"success"):n(t("fileManager.toast.failedToAddToQueue",{error:W.errors[0]?.error||"Unknown error"}),"error")},onError:W=>n(W.message,"error")}),re=mt({mutationFn:({id:W,filename:De})=>ue.updateLibraryFile(W,{filename:De}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),F(null),n(t("fileManager.toast.fileRenamed"),"success")},onError:W=>{F(null),n(W.message,"error")}}),Fe=mt({mutationFn:({id:W,name:De})=>ue.updateLibraryFolder(W,{name:De}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),F(null),n(t("fileManager.toast.folderRenamed"),"success")},onError:W=>{F(null),n(W.message,"error")}}),$e=mt({mutationFn:()=>ue.batchGenerateStlThumbnails({all_missing:!0}),onSuccess:W=>{if(e.invalidateQueries({queryKey:["library-files"]}),W.succeeded>0){const De=Date.now(),Ye={};W.results.forEach(xt=>{xt.success&&(Ye[xt.file_id]=De)}),j(xt=>({...xt,...Ye}))}W.succeeded>0&&W.failed===0?n(t("fileManager.toast.thumbnailsGenerated",{count:W.succeeded}),"success"):W.succeeded>0&&W.failed>0?n(t("fileManager.toast.thumbnailsGeneratedPartial",{succeeded:W.succeeded,failed:W.failed}),"success"):W.processed===0?n(t("fileManager.toast.noStlMissingThumbnails"),"info"):n(t("fileManager.toast.failedToGenerateThumbnails",{error:W.results[0]?.error||"Unknown error"}),"error")},onError:W=>n(W.message,"error")}),Ve=mt({mutationFn:W=>ue.batchGenerateStlThumbnails({file_ids:[W]}),onSuccess:W=>{if(e.invalidateQueries({queryKey:["library-files"]}),W.succeeded>0){const De=W.results[0]?.file_id;De&&j(Ye=>({...Ye,[De]:Date.now()})),n(t("fileManager.toast.thumbnailGenerated"),"success")}else n(t("fileManager.toast.failedToGenerateThumbnail",{error:W.results[0]?.error||"Unknown error"}),"error")},onError:W=>n(W.message,"error")}),He=_.useCallback(W=>{const De=W.toLowerCase();return De.endsWith(".gcode")||De.includes(".gcode.")},[]),ye=_.useMemo(()=>ce?ce.filter(W=>f.includes(W.id)&&He(W.filename)):[],[ce,f,He]),je=_.useCallback(W=>{p(De=>De.includes(W)?De.filter(Ye=>Ye!==W):[...De,W])},[]),Be=_.useCallback(()=>{fe.length>0&&p(fe.map(W=>W.id))},[fe]),Se=_.useCallback(()=>{p([])},[]),Xe=()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]})},Ne=W=>{window.open(ue.getLibraryFileDownloadUrl(W),"_blank")},tt=()=>{E&&(E.type==="file"?O.mutate(E.id):E.type==="folder"?z.mutate(E.id):E.type==="bulk"&&ee.mutate(f))},Ee=z.isPending||O.isPending||ee.isPending,We=W=>{K(W),localStorage.setItem("library-view-mode",W)},ze=Y||q;return s.jsxs("div",{className:"p-4 md:p-8 min-h-[calc(100vh-64px)] lg:h-[calc(100vh-64px)] flex flex-col",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:s.jsx(Il,{className:"w-6 h-6 text-bambu-green"})}),t("fileManager.title")]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("fileManager.subtitle")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex items-center bg-bambu-dark rounded-lg p-1",children:[s.jsx("button",{onClick:()=>We("grid"),className:`p-1.5 rounded transition-colors ${$==="grid"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.gridView"),children:s.jsx(m2,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>We("list"),className:`p-1.5 rounded transition-colors ${$==="list"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.listView"),children:s.jsx(p2,{className:"w-4 h-4"})})]}),s.jsxs(Te,{variant:"secondary",onClick:()=>$e.mutate(),disabled:$e.isPending||!i("library:update_own","library:update_all"),title:i("library:update_own","library:update_all")?t("fileManager.generateThumbnailsForMissing"):t("fileManager.noPermissionGenerateThumbnail"),children:[$e.isPending?s.jsx(ht,{className:"w-4 h-4 mr-2 animate-spin"}):s.jsx(Ou,{className:"w-4 h-4 mr-2"}),t("fileManager.generateThumbnails")]}),s.jsxs(Te,{variant:"secondary",onClick:()=>x(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionCreateFolder"),children:[s.jsx(Lue,{className:"w-4 h-4 mr-2"}),t("fileManager.newFolder")]}),s.jsxs(Te,{onClick:()=>S(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[s.jsx(Ua,{className:"w-4 h-4 mr-2"}),t("common.upload")]})]})]}),me&&te&&Ke&&s.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:[s.jsx(Cn,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-sm text-amber-500 font-medium",children:t("fileManager.lowDiskSpaceWarning")}),s.jsx("p",{className:"text-xs text-amber-500/80",children:t("fileManager.lowDiskSpaceDetails",{free:hg(te.disk_free_bytes),total:hg(te.disk_total_bytes),threshold:Ke.library_disk_warning_gb})})]})]}),te&&s.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:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(c2,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.files"),":"]}),s.jsx("span",{className:"text-white font-medium",children:te.total_files})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(Il,{className:"w-4 h-4 text-blue-400"}),s.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.folders"),":"]}),s.jsx("span",{className:"text-white font-medium",children:te.total_folders})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(h2,{className:"w-4 h-4 text-amber-400"}),s.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.size"),":"]}),s.jsx("span",{className:"text-white font-medium",children:hg(te.total_size_bytes)})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm sm:ml-auto",children:[s.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.free"),":"]}),s.jsx("span",{className:`font-medium ${me?"text-amber-500":"text-white"}`,children:hg(te.disk_free_bytes)})]})]}),s.jsxs("div",{className:"flex-1 flex flex-col lg:flex-row gap-4 lg:gap-6 min-h-0",children:[s.jsx("div",{className:"lg:hidden",children:s.jsxs("select",{value:u??"",onChange:W=>d(W.target.value?parseInt(W.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:[s.jsxs("option",{value:"",children:["📁 ",t("fileManager.allFiles")]}),G&&(()=>{const W=(De,Ye=0)=>{const xt=[];for(const ft of De)xt.push({id:ft.id,name:ft.name,fileCount:ft.file_count,depth:Ye}),ft.children.length>0&&xt.push(...W(ft.children,Ye+1));return xt};return W(G).map(De=>s.jsxs("option",{value:De.id,children:["│ ".repeat(De.depth),"📂 ",De.name," ",De.fileCount>0?`(${De.fileCount})`:""]},De.id))})()]})}),s.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:`${Z}px`},children:[s.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 ${B?"bg-bambu-green":"hover:bg-bambu-green/50"}`,onMouseDown:W=>{W.preventDefault(),X(!0)},onDoubleClick:()=>{ae(256),localStorage.setItem("library-sidebar-width","256")},title:t("fileManager.dragToResizeTooltip"),children:s.jsxs("div",{className:`flex flex-col gap-1 opacity-0 group-hover/resize:opacity-100 transition-opacity ${B?"opacity-100":""}`,children:[s.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),s.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),s.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"})]})}),s.jsxs("div",{className:"p-3 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsx("h2",{className:"text-sm font-medium text-white",children:t("fileManager.folders")}),s.jsx("button",{onClick:()=>{const W=!V;Q(W),localStorage.setItem("library-wrap-folders",String(W))},className:`text-xs px-1.5 py-0.5 rounded transition-colors ${V?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white hover:bg-bambu-dark"}`,title:t(V?"fileManager.disableTextWrapping":"fileManager.enableTextWrapping"),children:t("fileManager.wrap")})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[s.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors ${u===null?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,onClick:()=>d(null),children:[s.jsx(zf,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm",children:t("fileManager.allFiles")})]}),G?.map(W=>s.jsx(zre,{folder:W,selectedFolderId:u,onSelect:d,onDelete:De=>C({type:"folder",id:De}),onLink:T,onRename:De=>F({type:"folder",id:De.id,name:De.name}),wrapNames:V,hasPermission:r,t},W.id))]})]}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[ce&&ce.length>0&&s.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:[s.jsxs("div",{className:"relative w-full sm:w-auto sm:flex-1 sm:max-w-xs",children:[s.jsx(ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:t("fileManager.searchFiles"),value:se,onChange:W=>be(W.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"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(u2,{className:"w-4 h-4 text-bambu-gray hidden sm:block"}),s.jsxs("select",{value:xe,onChange:W=>de(W.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:[s.jsx("option",{value:"all",children:t("fileManager.allTypes")}),I.map(W=>s.jsx("option",{value:W,children:W.toUpperCase()},W))]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{value:Pe,onChange:W=>{const De=W.target.value;ie(De),localStorage.setItem("library-sort-field",De)},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:[s.jsx("option",{value:"name",children:t("common.name")}),s.jsx("option",{value:"date",children:t("common.date")}),s.jsx("option",{value:"size",children:t("fileManager.size")}),s.jsx("option",{value:"type",children:t("common.type")}),s.jsx("option",{value:"prints",children:t("fileManager.prints")})]}),s.jsx("button",{onClick:()=>Oe(W=>{const De=W==="asc"?"desc":"asc";return localStorage.setItem("library-sort-direction",De),De}),className:"p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:t(Me==="asc"?"fileManager.ascending":"fileManager.descending"),children:Me==="asc"?s.jsx(hce,{className:"w-4 h-4 text-white"}):s.jsx(ace,{className:"w-4 h-4 text-white"})})]}),(se||xe!=="all")&&s.jsx("span",{className:"text-sm text-bambu-gray hidden sm:inline",children:t("fileManager.resultsCount",{showing:fe.length,total:ce.length})})]}),fe.length>0&&s.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:[f.length===fe.length&&f.length>0?s.jsxs(Te,{variant:"secondary",size:"sm",onClick:Se,children:[s.jsx(ll,{className:"w-4 h-4 sm:mr-1"}),s.jsx("span",{className:"hidden sm:inline",children:t("fileManager.deselectAll")})]}):s.jsxs(Te,{variant:"secondary",size:"sm",onClick:Be,children:[s.jsx(ol,{className:"w-4 h-4 sm:mr-1"}),s.jsx("span",{className:"hidden sm:inline",children:t("fileManager.selectAll")})]}),f.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-sm text-bambu-gray ml-2",children:t("fileManager.selected",{count:f.length})}),s.jsx("div",{className:"hidden sm:block flex-1"}),s.jsxs("div",{className:"w-full sm:w-auto flex flex-wrap items-center gap-2 mt-2 sm:mt-0",children:[ye.length===1&&s.jsxs(Te,{variant:"primary",size:"sm",onClick:()=>D(ye[0]),disabled:!r("printers:control"),title:r("printers:control")?void 0:t("fileManager.noPermissionPrint"),children:[s.jsx(Is,{className:"w-4 h-4 sm:mr-1"}),s.jsx("span",{className:"hidden sm:inline",children:t("common.print")})]}),ye.length>0&&s.jsxs(Te,{variant:ye.length===1?"secondary":"primary",size:"sm",onClick:()=>we.mutate(ye.map(W=>W.id)),disabled:we.isPending||!r("queue:create"),title:r("queue:create")?void 0:t("fileManager.noPermissionAddToQueue"),children:[s.jsx(Jn,{className:"w-4 h-4 sm:mr-1"}),s.jsx("span",{className:"hidden sm:inline",children:we.isPending?t("fileManager.adding"):`${t("fileManager.addToQueue")}${ye.length<f.length?` (${ye.length})`:""}`})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>y(!0),disabled:!i("library:update_own","library:update_all"),title:i("library:update_own","library:update_all")?void 0:t("fileManager.noPermissionMoveFiles"),children:[s.jsx(Vde,{className:"w-4 h-4 sm:mr-1"}),s.jsx("span",{className:"hidden sm:inline",children:t("common.move")})]}),s.jsxs(Te,{variant:"danger",size:"sm",onClick:()=>{f.length===1?C({type:"file",id:f[0]}):C({type:"bulk",id:0,count:f.length})},disabled:!i("library:delete_own","library:delete_all"),title:i("library:delete_own","library:delete_all")?void 0:t("fileManager.noPermissionDeleteFiles"),children:[s.jsx(rn,{className:"w-4 h-4 sm:mr-1"}),s.jsx("span",{className:"hidden sm:inline",children:t("common.delete")})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:Se,children:[s.jsx(Rt,{className:"w-4 h-4 sm:mr-1"}),s.jsx("span",{className:"hidden sm:inline",children:t("common.clear")})]})]})]})]}),ze?s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsxs("div",{className:"flex flex-col items-center gap-3",children:[s.jsx(ht,{className:"w-8 h-8 animate-spin text-bambu-green"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("fileManager.loadingFiles")})]})}):ce?.length===0?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[s.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:s.jsx(zf,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t(u!==null?"fileManager.folderIsEmpty":"fileManager.noFilesYet")}),s.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t(u!==null?"fileManager.folderEmptyDescription":"fileManager.noFilesDescription")}),s.jsxs(Te,{onClick:()=>S(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[s.jsx(ur,{className:"w-4 h-4 mr-2"}),t("fileManager.uploadFiles")]})]}):fe.length===0?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[s.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:s.jsx(ba,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t("fileManager.noMatchingFiles")}),s.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t("fileManager.noMatchingFilesDescription")}),s.jsx(Te,{variant:"secondary",onClick:()=>{be(""),de("all")},children:t("fileManager.clearFilters")})]}):$==="grid"?s.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:s.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:fe.map(W=>s.jsx(rXe,{file:W,isSelected:f.includes(W.id),isMobile:ge,t,onSelect:je,onDelete:De=>C({type:"file",id:De}),onDownload:Ne,onAddToQueue:De=>we.mutate([De]),onPrint:R,onRename:De=>F({type:"file",id:De.id,name:De.filename}),onGenerateThumbnail:De=>Ve.mutate(De.id),thumbnailVersion:H[W.id],hasPermission:r,canModify:a},W.id))})}):s.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:s.jsxs("div",{className:"bg-bambu-card rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[s.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:[s.jsx("div",{className:"w-6"}),s.jsx("div",{children:t("common.name")}),s.jsx("div",{children:t("common.type")}),s.jsx("div",{children:t("fileManager.size")}),s.jsx("div",{children:t("fileManager.prints")}),s.jsx("div",{})]}),fe.map(W=>s.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 ${f.includes(W.id)?"bg-bambu-green/10":""}`,onClick:()=>je(W.id),children:[s.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${f.includes(W.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:f.includes(W.id)&&s.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})}),s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsxs("div",{className:"relative group/thumb",children:[s.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark flex-shrink-0 overflow-hidden",children:W.thumbnail_path?s.jsx("img",{src:`${ue.getLibraryFileThumbnailUrl(W.id)}${H[W.id]?`?v=${H[W.id]}`:""}`,alt:"",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center",children:s.jsx(zf,{className:"w-5 h-5 text-bambu-gray/50"})})}),W.thumbnail_path&&s.jsx("div",{className:"absolute left-0 top-full mt-2 z-50 hidden group-hover/thumb:block",children:s.jsx("div",{className:"w-48 h-48 rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary shadow-xl overflow-hidden",children:s.jsx("img",{src:`${ue.getLibraryFileThumbnailUrl(W.id)}${H[W.id]?`?v=${H[W.id]}`:""}`,alt:W.filename,className:"w-full h-full object-contain"})})})]}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-sm text-white truncate",children:W.print_name||W.filename})})]}),s.jsx("div",{children:s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${W.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":W.file_type==="gcode"?"bg-blue-500/20 text-blue-400":W.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:W.file_type.toUpperCase()})}),s.jsx("div",{className:"text-sm text-bambu-gray",children:hg(W.file_size)}),s.jsx("div",{className:"text-sm text-bambu-gray",children:W.print_count>0?`${W.print_count}x`:"-"}),s.jsxs("div",{className:"flex items-center gap-1",onClick:De=>De.stopPropagation(),children:[hR(W.filename)&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>r("printers:control")&&R(W),className:`p-1.5 rounded transition-colors ${r("printers:control")?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("printers:control")?t("common.print"):t("fileManager.noPermissionPrint"),disabled:!r("printers:control"),children:s.jsx(Ur,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>r("queue:create")&&we.mutate([W.id]),className:`p-1.5 rounded transition-colors ${r("queue:create")?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("queue:create")?t("fileManager.addToQueue"):t("fileManager.noPermissionAddToQueue"),disabled:we.isPending||!r("queue:create"),children:s.jsx(Jn,{className:"w-4 h-4"})})]}),s.jsx("button",{onClick:()=>r("library:read")&&Ne(W.id),className:`p-1.5 rounded transition-colors ${r("library:read")?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("library:read")?t("common.download"):t("fileManager.noPermissionDownload"),disabled:!r("library:read"),children:s.jsx(yi,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>a("library","update",W.created_by_id)&&F({type:"file",id:W.id,name:W.filename}),className:`p-1.5 rounded transition-colors ${a("library","update",W.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:a("library","update",W.created_by_id)?t("common.rename"):t("fileManager.noPermissionRenameFile"),disabled:!a("library","update",W.created_by_id),children:s.jsx(Qi,{className:"w-4 h-4"})}),W.file_type==="stl"&&s.jsx("button",{onClick:()=>a("library","update",W.created_by_id)&&Ve.mutate(W.id),className:`p-1.5 rounded transition-colors ${a("library","update",W.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:a("library","update",W.created_by_id)?t("fileManager.generateThumbnail"):t("fileManager.noPermissionGenerateThumbnail"),disabled:Ve.isPending||!a("library","update",W.created_by_id),children:s.jsx(Ou,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>a("library","delete",W.created_by_id)&&C({type:"file",id:W.id}),className:`p-1.5 rounded transition-colors ${a("library","delete",W.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:a("library","delete",W.created_by_id)?t("common.delete"):t("fileManager.noPermissionDeleteFile"),disabled:!a("library","delete",W.created_by_id),children:s.jsx(rn,{className:"w-4 h-4"})})]})]},W.id))]})})]})]}),m&&s.jsx(ZKe,{parentId:u,onClose:()=>x(!1),onSave:W=>ke.mutate(W),isLoading:ke.isPending,t}),b&&G&&s.jsx(eXe,{folders:G,selectedFiles:f,currentFolderId:u,onClose:()=>y(!1),onMove:W=>le.mutate({fileIds:f,folderId:W}),isLoading:le.isPending,t}),v&&s.jsx(nXe,{folderId:u,onClose:()=>S(!1),onUploadComplete:Xe,t}),M&&s.jsx(tXe,{folder:M,onClose:()=>T(null),onLink:W=>_e.mutate({id:M.id,data:W}),isLoading:_e.isPending,t}),E&&s.jsx(Qn,{title:E.type==="folder"?t("fileManager.deleteFolder"):E.type==="bulk"?t("fileManager.deleteFilesCount",{count:E.count}):t("fileManager.deleteFile"),message:E.type==="folder"?t("fileManager.deleteFolderConfirm"):E.type==="bulk"?t("fileManager.deleteFilesConfirm",{count:E.count}):t("fileManager.deleteFileConfirm"),confirmText:t("common.delete"),variant:"danger",isLoading:Ee,loadingText:t("fileManager.deleting"),onConfirm:tt,onCancel:()=>C(null)}),k&&s.jsx(jh,{mode:"reprint",libraryFileId:k.id,archiveName:k.print_name||k.filename,onClose:()=>R(null),onSuccess:()=>{R(null),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),A&&s.jsx(jh,{mode:"reprint",libraryFileId:A.id,archiveName:A.print_name||A.filename,onClose:()=>D(null),onSuccess:()=>{D(null),p([]),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),U&&s.jsx(JKe,{type:U.type,currentName:U.name,onClose:()=>F(null),onSave:W=>{U.type==="file"?re.mutate({id:U.id,filename:W}):Fe.mutate({id:U.id,name:W})},isLoading:re.isPending||Fe.isPending,t})]})}const Kj=5,aXe=2e3,sXe=3e4,oXe=5e3;function lXe(){const{t}=$n(),{printerId:e}=r2(),n=parseInt(e||"0",10),[r,i]=_.useState("stream"),[a,o]=_.useState(!1),[l,c]=_.useState(!0),[u,d]=_.useState(Date.now()),[f,p]=_.useState(!1),[m,x]=_.useState(!1),[b,y]=_.useState(0),[v,S]=_.useState(!1),[M,T]=_.useState(0),[E,C]=_.useState(1),[k,R]=_.useState({x:0,y:0}),[A,D]=_.useState(!1),[U,F]=_.useState({x:0,y:0}),[H,j]=_.useState(null),[$,K]=_.useState(null),V=_.useRef(null),Q=_.useRef(null),Z=_.useRef(null),ae=_.useRef(null),B=_.useRef(null),{data:X}=at({queryKey:["printer",n],queryFn:()=>ue.getPrinter(n),enabled:n>0});_.useEffect(()=>(X&&(document.title=`${X.name} - Camera`),()=>{document.title="Bambuddy"}),[X]);const ne=_.useRef(!1);_.useEffect(()=>{const le=`/api/v1/printers/${n}/camera/stop`;ne.current=!1;const _e=()=>{n>0&&!ne.current&&(ne.current=!0,navigator.sendBeacon(le))},we=()=>{_e()};window.addEventListener("beforeunload",we);const re=V.current;return()=>{window.removeEventListener("beforeunload",we),re&&(re.src=""),_e()}},[n]),_.useEffect(()=>{if(l&&!f){const _e=setTimeout(()=>{c(!1)},r==="stream"?3e3:2e4);return()=>clearTimeout(_e)}},[r,l,u,f]),_.useEffect(()=>{const le=()=>{const _e=!!document.fullscreenElement;x(_e),C(1),R({x:0,y:0}),r==="stream"&&!f&&(V.current&&(V.current.src=""),setTimeout(()=>{c(!0),d(Date.now())},200))};return document.addEventListener("fullscreenchange",le),()=>document.removeEventListener("fullscreenchange",le)},[r,f]),_.useEffect(()=>{let le;const _e=()=>{clearTimeout(le),le=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener("resize",_e),()=>{clearTimeout(le),window.removeEventListener("resize",_e)}},[]),_.useEffect(()=>()=>{Z.current&&clearTimeout(Z.current),ae.current&&clearInterval(ae.current),B.current&&clearInterval(B.current)},[]);const se=_.useCallback(()=>{if(b>=Kj){S(!1),o(!0);return}const le=Math.min(aXe*Math.pow(2,b),sXe);S(!0),T(Math.ceil(le/1e3)),ae.current=setInterval(()=>{T(_e=>_e<=1?(ae.current&&clearInterval(ae.current),0):_e-1)},1e3),Z.current=setTimeout(()=>{y(_e=>_e+1),S(!1),c(!0),o(!1),V.current&&(V.current.src=""),d(Date.now())},le)},[b]);_.useEffect(()=>{if(r!=="stream"||l||v||f){B.current&&(clearInterval(B.current),B.current=null);return}return B.current=setInterval(async()=>{try{const le=await fetch(`/api/v1/printers/${n}/camera/status`);if(le.ok){const _e=await le.json();(_e.stalled||!_e.active&&!a)&&(console.log(`Stream issue detected: stalled=${_e.stalled}, active=${_e.active}, reconnecting...`),B.current&&(clearInterval(B.current),B.current=null),c(!1),se())}}catch{}},oXe),()=>{B.current&&(clearInterval(B.current),B.current=null)}},[r,l,a,v,f,n,se]);const be=()=>{c(!1),r==="stream"&&b<Kj?se():o(!0)},xe=()=>{if(c(!1),o(!1),y(0),S(!1),Z.current&&clearTimeout(Z.current),ae.current&&clearInterval(ae.current),V.current&&!localStorage.getItem("cameraWindowState")){const le=V.current,_e=le.naturalWidth,we=le.naturalHeight;if(_e>0&&we>0){const $e=window.outerWidth-window.innerWidth,Ve=window.outerHeight-window.innerHeight,He=_e+16+$e,ye=we+45+16+Ve;try{window.resizeTo(He,ye)}catch{}}}},de=()=>{n>0&&fetch(`/api/v1/printers/${n}/camera/stop`).catch(()=>{})},Pe=le=>{r===le||f||(p(!0),c(!0),o(!1),y(0),S(!1),C(1),R({x:0,y:0}),Z.current&&clearTimeout(Z.current),ae.current&&clearInterval(ae.current),V.current&&(V.current.src=""),r==="stream"&&de(),setTimeout(()=>{i(le),d(Date.now()),p(!1)},100))},ie=()=>{f||(p(!0),c(!0),o(!1),y(0),S(!1),Z.current&&clearTimeout(Z.current),ae.current&&clearInterval(ae.current),V.current&&(V.current.src=""),r==="stream"&&de(),setTimeout(()=>{d(Date.now()),p(!1)},100))},Me=()=>{Q.current&&(document.fullscreenElement?document.exitFullscreen():Q.current.requestFullscreen())},Oe=()=>{C(le=>Math.min(le+.5,4))},ge=()=>{C(le=>{const _e=Math.max(le-.5,1);return _e===1&&R({x:0,y:0}),_e})},Ke=le=>{le.preventDefault(),le.deltaY<0?Oe():ge()},G=le=>{E>1&&(le.preventDefault(),D(!0),F({x:le.clientX-k.x,y:le.clientY-k.y}))},Y=_.useCallback(()=>{if(!Q.current)return{x:300,y:200};const le=Q.current.getBoundingClientRect(),_e=le.width*(E-1)/2,we=le.height*(E-1)/2;return{x:Math.max(50,_e),y:Math.max(50,we)}},[E]),ce=le=>{if(A&&E>1){const _e=le.clientX-U.x,we=le.clientY-U.y,re=Y();R({x:Math.max(-re.x,Math.min(re.x,_e)),y:Math.max(-re.y,Math.min(re.y,we))})}},q=()=>{D(!1)},te=le=>{if(le.length<2)return 0;const _e=le[0].clientX-le[1].clientX,we=le[0].clientY-le[1].clientY;return Math.sqrt(_e*_e+we*we)},I=le=>le.length<2?{x:le[0].clientX,y:le[0].clientY}:{x:(le[0].clientX+le[1].clientX)/2,y:(le[0].clientY+le[1].clientY)/2},fe=le=>{le.touches.length===2?(le.preventDefault(),j(te(le.touches)),K(I(le.touches))):le.touches.length===1&&E>1&&(le.preventDefault(),D(!0),F({x:le.touches[0].clientX-k.x,y:le.touches[0].clientY-k.y}))},me=le=>{if(le.touches.length===2&&H!==null){le.preventDefault();const _e=te(le.touches),we=_e/H;C(Fe=>{const $e=Math.max(1,Math.min(4,Fe*we));return $e===1&&R({x:0,y:0}),$e}),j(_e);const re=I(le.touches);if($){const Fe=Y();R($e=>({x:Math.max(-Fe.x,Math.min(Fe.x,$e.x+(re.x-$.x))),y:Math.max(-Fe.y,Math.min(Fe.y,$e.y+(re.y-$.y)))}))}K(re)}else if(le.touches.length===1&&A&&E>1){le.preventDefault();const _e=le.touches[0].clientX-U.x,we=le.touches[0].clientY-U.y,re=Y();R({x:Math.max(-re.x,Math.min(re.x,_e)),y:Math.max(-re.y,Math.min(re.y,we))})}},ke=le=>{le.touches.length<2&&(j(null),K(null)),le.touches.length===0&&D(!1)},z=()=>{C(1),R({x:0,y:0})},O=f?"":r==="stream"?`/api/v1/printers/${n}/camera/stream?fps=15&t=${u}`:`/api/v1/printers/${n}/camera/snapshot?t=${u}`,ee=l||f||v;return n?s.jsxs("div",{ref:Q,className:"min-h-screen bg-black flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[s.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[s.jsx(Ug,{className:"w-4 h-4"}),X?.name||`Printer ${n}`]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[s.jsx("button",{onClick:()=>Pe("stream"),disabled:ee,className:`px-3 py-1 text-xs rounded transition-colors ${r==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:t("camera.live")}),s.jsx("button",{onClick:()=>Pe("snapshot"),disabled:ee,className:`px-3 py-1 text-xs rounded transition-colors ${r==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:t("camera.snapshot")})]}),s.jsx("button",{onClick:ie,disabled:ee,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:t(r==="stream"?"camera.restartStream":"camera.refreshSnapshot"),children:s.jsx(Dr,{className:`w-4 h-4 text-bambu-gray ${ee?"animate-spin":""}`})}),s.jsx("button",{onClick:Me,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:t(m?"camera.exitFullscreen":"camera.fullscreen"),children:m?s.jsx(_W,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(Pde,{className:"w-4 h-4 text-bambu-gray"})})]})]}),s.jsx("div",{className:"flex-1 flex items-center justify-center p-2 overflow-hidden",onWheel:Ke,onMouseMove:ce,onMouseUp:q,onMouseLeave:q,onTouchStart:fe,onTouchMove:me,onTouchEnd:ke,style:{touchAction:"none"},children:s.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(l||f)&&!v&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:s.jsxs("div",{className:"text-center",children:[s.jsx(Dr,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t(r==="stream"?"camera.connectingToCamera":"camera.capturingSnapshot")})]})}),v&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:s.jsxs("div",{className:"text-center p-4",children:[s.jsx(sm,{className:"w-10 h-10 text-orange-400 mx-auto mb-3"}),s.jsx("p",{className:"text-white mb-2",children:t("camera.connectionLost")}),s.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:t("camera.reconnecting",{countdown:M,attempt:b+1,max:Kj})}),s.jsx("button",{onClick:ie,className:"px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors",children:t("camera.reconnectNow")})]})}),a&&!v&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:s.jsxs("div",{className:"text-center p-4",children:[s.jsx(Cn,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),s.jsx("p",{className:"text-white mb-2",children:t("camera.cameraUnavailable")}),s.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:t("camera.cameraUnavailableDesc")}),s.jsx("button",{onClick:ie,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:t("camera.retry")})]})}),s.jsx("img",{ref:V,src:O,alt:t("camera.cameraStream"),className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${E}) translate(${k.x/E}px, ${k.y/E}px)`,cursor:E>1?A?"grabbing":"grab":"default"},onError:O?be:void 0,onLoad:O?xe:void 0,onMouseDown:G,draggable:!1},u),s.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:[s.jsx("button",{onClick:ge,disabled:E<=1,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomOut"),children:s.jsx(FR,{className:"w-4 h-4 text-white"})}),s.jsxs("button",{onClick:z,className:"px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]",title:t("camera.resetZoom"),children:[Math.round(E*100),"%"]}),s.jsx("button",{onClick:Oe,disabled:E>=4,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomIn"),children:s.jsx(LR,{className:"w-4 h-4 text-white"})})]})]})})]}):s.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:s.jsx("p",{className:"text-white",children:t("camera.invalidPrinterId")})})}function cXe(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"),a=i!=="false"&&i!=="0";return{size:t.get("size")||"medium",fps:r,showCamera:a,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 uXe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function dXe(t,e){const n=new Date,r=new Date(n.getTime()+t*60*1e3),i=new Date;i.setHours(0,0,0,0);const a=new Date(r);a.setHours(0,0,0,0);const o=r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return a.getTime()===i.getTime()?o:a.getTime()===i.getTime()+864e5?`${e("streamOverlay.tomorrow")} ${o}`:r.toLocaleDateString([],{weekday:"short"})+" "+o}function hXe(t,e){if(t.stg_cur_name)return t.stg_cur_name;switch(t.state){case"RUNNING":return e("streamOverlay.status.printing");case"PAUSE":return e("streamOverlay.status.paused");case"FINISH":return e("streamOverlay.status.finished");case"FAILED":return e("streamOverlay.status.failed");case"IDLE":return e("streamOverlay.status.idle");default:return t.state||e("streamOverlay.status.unknown")}}function fXe(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 mXe(){const{printerId:t}=r2(),[e]=wR(),{t:n}=$n(),r=an(),i=parseInt(t||"0",10),[a,o]=_.useState(Date.now()),l=_.useMemo(()=>cXe(e),[e]),c=fXe(l.size),{data:u}=at({queryKey:["printer",i],queryFn:()=>ue.getPrinter(i),enabled:i>0}),{data:d}=at({queryKey:["printerStatus",i],queryFn:()=>ue.getPrinterStatus(i),enabled:i>0,refetchInterval:2e3});_.useEffect(()=>{if(!i)return;const y=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,v=new WebSocket(y);return v.onmessage=S=>{try{const M=JSON.parse(S.data);M.type==="printer_status"&&M.printer_id===i&&r.setQueryData(["printerStatus",i],M.status)}catch{}},v.onerror=()=>{},()=>{v.close()}},[i,r]),_.useEffect(()=>(document.title=u?`${u.name} - ${n("streamOverlay.title")}`:n("streamOverlay.title"),()=>{document.title="Bambuddy"}),[u,n]);const f=()=>{setTimeout(()=>{o(Date.now())},3e3)};if(!i)return s.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:s.jsx("p",{className:"text-white",children:n("streamOverlay.invalidPrinterId")})});if(!d)return s.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:s.jsx("p",{className:"text-gray-400",children:n("common.loading")})});const p=d.state==="RUNNING"||d.state==="PAUSE",m=d.progress||0,x=`/api/v1/printers/${i}/camera/stream?fps=${l.fps}&t=${a}`;return s.jsxs("div",{className:"min-h-screen bg-black relative overflow-hidden",children:[l.showCamera&&s.jsx("img",{src:x,alt:n("streamOverlay.cameraStream"),className:"absolute inset-0 w-full h-full object-contain",onError:f},a),s.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"absolute top-4 right-4 z-10",children:s.jsx("img",{src:"/img/bambuddy_logo_dark_transparent.png",alt:"Bambuddy",className:`${c.logoHeight} object-contain drop-shadow-lg hover:scale-105 transition-transform`})}),s.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:s.jsxs("div",{className:`${c.container}`,children:[l.showPrinter&&u&&s.jsxs("div",{className:`flex items-center ${c.gap} mb-2`,children:[s.jsx(Ur,{className:`${c.icon} text-white/70`}),s.jsx("span",{className:`${c.text} text-white font-medium`,children:u.name})]}),l.showFilename&&d.current_print&&s.jsx("div",{className:`${c.textLarge} text-white font-semibold mb-2 truncate drop-shadow-md`,children:d.current_print.replace(/\.gcode\.3mf$|\.3mf$|\.gcode$/i,"")}),l.showStatus&&s.jsx("div",{className:`${c.text} text-white/70 mb-2`,children:hXe(d,n)}),l.showProgress&&p&&s.jsxs("div",{className:"mb-3",children:[s.jsxs("div",{className:`flex items-center justify-between mb-1 ${c.text}`,children:[s.jsx("span",{className:"text-white/70",children:n("streamOverlay.progress")}),s.jsxs("span",{className:"text-white font-bold",children:[Math.round(m),"%"]})]}),s.jsx("div",{className:`w-full bg-white/20 rounded-full ${c.progressHeight}`,children:s.jsx("div",{className:`bg-bambu-green ${c.progressHeight} rounded-full transition-all duration-500`,style:{width:`${m}%`}})})]}),p&&(l.showLayers||l.showEta)&&s.jsxs("div",{className:`flex items-center ${c.gap} flex-wrap`,children:[l.showLayers&&d.layer_num!=null&&d.total_layers!=null&&d.total_layers>0&&s.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[s.jsx(sl,{className:c.icon}),s.jsxs("span",{className:c.text,children:[s.jsx("span",{className:"text-white",children:d.layer_num}),s.jsx("span",{className:"mx-1",children:"/"}),s.jsx("span",{children:d.total_layers})]})]}),l.showEta&&d.remaining_time!=null&&d.remaining_time>0&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[s.jsx(xu,{className:c.icon}),s.jsx("span",{className:`${c.text} text-white`,children:uXe(d.remaining_time*60)})]}),s.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[s.jsx(Jn,{className:c.icon}),s.jsxs("span",{className:`${c.text} text-white`,children:[n("streamOverlay.eta")," ",dXe(d.remaining_time,n)]})]})]})]}),!p&&s.jsx("div",{className:`${c.text} text-white/70 py-2`,children:d.connected?n("streamOverlay.printerIdle"):n("streamOverlay.printerOffline")})]})})]})}function pXe(){const{t}=$n(),{id:e}=r2(),{mode:n}=Oh(),{data:r,isLoading:i,error:a}=at({queryKey:["external-link",e],queryFn:()=>ue.getExternalLink(Number(e)),enabled:!!e});return i?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):a||!r?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[s.jsx(Cn,{className:"w-12 h-12"}),s.jsx("p",{children:t("common.linkNotFound")})]}):s.jsx("iframe",{src:r.url,className:"h-full w-full border-0",style:{colorScheme:n},title:r.name,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"})}const xq=["DEBUG","INFO","WARNING","ERROR"],Xj={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},gXe={DEBUG:a2,INFO:Zo,WARNING:Cn,ERROR:$i};function xXe(){const t=an(),[e,n]=_.useState(!0),[r,i]=_.useState(new Set),[a,o]=_.useState(""),[l,c]=_.useState("ALL"),[u,d]=_.useState(!1),[f,p]=_.useState(!1),m=_.useRef(null),{data:x,isLoading:b,refetch:y}=at({queryKey:["application-logs",l,a],queryFn:()=>Ng.getLogs({limit:200,level:l==="ALL"?void 0:l,search:a||void 0}),refetchInterval:f?2e3:!1,enabled:u});_.useEffect(()=>{u||p(!1)},[u]);const v=mt({mutationFn:()=>Ng.clearLogs(),onSuccess:()=>{t.invalidateQueries({queryKey:["application-logs"]})}});_.useEffect(()=>{e&&m.current&&x?.entries&&(m.current.scrollTop=m.current.scrollHeight)},[x?.entries,e]);const S=k=>{i(R=>{const A=new Set(R);return A.has(k)?A.delete(k):A.add(k),A})},M=k=>{const R=k.split(" ");return R.length>=2?R[1]:k},T=_.useMemo(()=>x?.entries??[],[x?.entries]),E=_.useMemo(()=>[...T].reverse(),[T]),C=({level:k})=>{const R=gXe[k]||Zo;return s.jsx(R,{className:`w-3.5 h-3.5 ${Xj[k]||"text-gray-400"}`})};return s.jsxs("div",{className:"bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsxs("button",{onClick:()=>d(!u),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${f?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:s.jsx(a2,{className:"w-5 h-5"})}),s.jsxs("div",{className:"text-left",children:[s.jsx("p",{className:"font-medium text-white",children:"Application Logs"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:f?`Live streaming - ${x?.filtered_count??0} entries`:"View and filter application logs"})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[f&&s.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-1 bg-bambu-green/20 rounded text-bambu-green text-xs",children:[s.jsx("span",{className:"w-1.5 h-1.5 bg-bambu-green rounded-full animate-pulse"}),"Live"]}),u?s.jsx(xh,{className:"w-5 h-5 text-bambu-gray"}):s.jsx(ei,{className:"w-5 h-5 text-bambu-gray"})]})]}),u&&s.jsxs("div",{className:"border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[f?s.jsxs("button",{onClick:k=>{k.stopPropagation(),p(!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:[s.jsx(ll,{className:"w-4 h-4"}),"Stop"]}):s.jsxs("button",{onClick:k=>{k.stopPropagation(),p(!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:[s.jsx(Is,{className:"w-4 h-4"}),"Start"]}),s.jsxs("button",{onClick:()=>v.mutate(),disabled:v.isPending||T.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:[s.jsx(rn,{className:"w-4 h-4"}),"Clear"]}),s.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:s.jsx(Dr,{className:`w-4 h-4 ${b?"animate-spin":""}`})}),s.jsx("div",{className:"flex-1"}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:e,onChange:k=>n(k.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark-tertiary"}),"Auto-scroll"]}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:[x?.filtered_count??0,"/",x?.total_in_file??0]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(ba,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:"Search message or logger name...",value:a,onChange:k=>o(k.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"}),a&&s.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:s.jsx(Rt,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark-secondary rounded border border-bambu-dark-tertiary",children:[s.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"}),xq.map((k,R)=>s.jsx("button",{onClick:()=>c(k),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${R===xq.length-1?"rounded-r":""} ${l===k?`${Xj[k]} bg-bambu-dark-tertiary`:"text-bambu-gray hover:text-white"}`,children:k},k))]})]})]}),s.jsx("div",{ref:m,className:"overflow-auto font-mono text-xs bg-black min-h-[300px] max-h-[500px]",children:T.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-[300px] text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:"No log entries found"}),s.jsx("p",{className:"text-sm",children:"Log file may be empty or cleared"})]}):s.jsx("div",{className:"divide-y divide-bambu-dark-tertiary/30",children:E.map((k,R)=>{const A=r.has(R),D=k.message.includes(`
  8291. `);return s.jsx("div",{className:`p-2 cursor-pointer hover:bg-bambu-dark-secondary/50 transition-colors ${A?"bg-bambu-dark-secondary/30":""}`,onClick:()=>D&&S(R),children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-bambu-gray/70 shrink-0 w-20",children:M(k.timestamp)}),s.jsx("span",{className:"shrink-0",children:s.jsx(C,{level:k.level})}),s.jsxs("span",{className:"text-purple-400/80 shrink-0 max-w-[200px] truncate",title:k.logger_name,children:["[",k.logger_name,"]"]}),s.jsx("span",{className:`flex-1 ${Xj[k.level]||"text-white/80"} ${!A&&D?"truncate":""}`,children:A?s.jsx("pre",{className:"whitespace-pre-wrap break-all",children:k.message}):k.message.split(`
  8292. `)[0]}),D&&s.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:A?s.jsx(xh,{className:"w-3.5 h-3.5"}):s.jsx(ei,{className:"w-3.5 h-3.5"})})]})},R)})})}),s.jsx("div",{className:"flex items-center justify-between p-3 border-t border-bambu-dark-tertiary text-sm text-bambu-gray",children:f?s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Auto-refreshing every 2 seconds"]}):s.jsx("span",{children:"Click Start to enable live log streaming"})})]})]})}function bXe(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 mi({icon:t,label:e,value:n,subValue:r,color:i="text-bambu-green"}){return s.jsxs("div",{className:"flex items-start gap-3 p-4 bg-bambu-dark rounded-lg",children:[s.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark-tertiary ${i}`,children:s.jsx(t,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:e}),s.jsx("p",{className:"text-lg font-semibold text-white truncate",children:n}),r&&s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:r})]})]})}function bq({percent:t,color:e="bg-bambu-green"}){return s.jsx("div",{className:"w-full h-2 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:`h-full ${e} transition-all duration-300`,style:{width:`${Math.min(100,t)}%`}})})}function Fd({title:t,icon:e,children:n}){return s.jsxs(_t,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[s.jsx(e,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:t})]}),n]})}function yXe(){const{t}=$n(),e=an(),[n,r]=_.useState(null),[i,a]=_.useState(!1),[o,l]=_.useState(!1),{data:c,isLoading:u,refetch:d,isFetching:f}=at({queryKey:["systemInfo"],queryFn:ue.getSystemInfo,refetchInterval:3e4}),{data:p}=at({queryKey:["debugLogging"],queryFn:Ng.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:m}=at({queryKey:["settings"],queryFn:ue.getSettings}),{data:x}=at({queryKey:["library-stats"],queryFn:ue.getLibraryStats}),b=m?.time_format||"system",y=async()=>{l(!0);try{const T=await Ng.setDebugLogging(!p?.enabled);e.setQueryData(["debugLogging"],T)}catch(T){console.error("Failed to toggle debug logging:",T)}finally{l(!1)}},v=async()=>{r(null),a(!0);try{await Ng.downloadSupportBundle()}catch(T){r(T instanceof Error?T.message:"Failed to download support bundle")}finally{a(!1)}};if(u)return s.jsx("div",{className:"flex items-center justify-center h-64",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(!c)return s.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",M=c.memory.percent_used>90?"bg-red-500":c.memory.percent_used>75?"bg-yellow-500":"bg-bambu-green";return s.jsxs("div",{className:"p-6 space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:t("system.title","System Information")}),s.jsx("p",{className:"text-bambu-gray mt-1",children:t("system.subtitle","Monitor system resources and database statistics")})]}),s.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:[s.jsx(Dr,{className:`w-4 h-4 ${f?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),s.jsx(Fd,{title:t("system.application","Application"),icon:yf,children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(mi,{icon:yf,label:t("system.version","Version"),value:`v${c.app.version}`}),s.jsx(mi,{icon:Jn,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),s.jsx(mi,{icon:yf,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),s.jsx(Fd,{title:t("support.title","Support & Troubleshooting"),icon:tde,children:s.jsxs("div",{className:"space-y-4",children:[s.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.")}),s.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${p?.enabled?"bg-amber-500/20 text-amber-500":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:s.jsx(a2,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:t("support.debugLogging","Debug Logging")}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[p?.enabled?t("support.debugLoggingEnabled","Capturing detailed logs"):t("support.debugLoggingDisabled","Normal logging level"),p?.enabled&&p.duration_seconds!==null&&s.jsxs("span",{className:"text-amber-400 ml-2",children:["(",Math.floor(p.duration_seconds/60),"m ",p.duration_seconds%60,"s)"]})]})]})]}),s.jsxs("button",{onClick:y,disabled:o,className:`px-4 py-2 rounded-lg font-medium transition-colors flex items-center gap-2 ${p?.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&&s.jsx(ht,{className:"w-4 h-4 animate-spin"}),p?.enabled?t("support.disableDebug","Disable"):t("support.enableDebug","Enable")]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-green",children:s.jsx(yi,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:t("support.supportBundle","Support Bundle")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.supportBundleDescription","Download system info and logs as a ZIP file")})]})]}),s.jsxs("button",{onClick:v,disabled:i||!p?.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:p?.enabled?void 0:t("support.enableDebugFirst","Enable debug logging first"),children:[i&&s.jsx(ht,{className:"w-4 h-4 animate-spin"}),t("common.download","Download")]})]}),n&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/30 rounded-lg text-red-400 text-sm",children:n}),!p?.enabled&&s.jsx("div",{className:"p-4 bg-bambu-dark-tertiary/50 rounded-lg",children:s.jsxs("p",{className:"text-sm text-bambu-gray",children:[s.jsx("span",{className:"text-amber-400 font-medium",children:t("support.instructions","To report an issue:")}),s.jsx("br",{}),"1. ",t("support.step1","Enable debug logging"),s.jsx("br",{}),"2. ",t("support.step2","Reproduce the issue"),s.jsx("br",{}),"3. ",t("support.step3","Download the support bundle"),s.jsx("br",{}),"4. ",t("support.step4","Attach the ZIP file to your issue report")]})}),s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg space-y-3",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:t("support.privacyTitle","What's in the support bundle?")}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-bambu-green font-medium mb-1",children:t("support.collected","Collected:")}),s.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[s.jsxs("li",{children:["• ",t("support.collectItem1","App version and debug mode")]}),s.jsxs("li",{children:["• ",t("support.collectItem2","OS, architecture, Python version")]}),s.jsxs("li",{children:["• ",t("support.collectItem3","Database statistics (counts only)")]}),s.jsxs("li",{children:["• ",t("support.collectItem4","Printer models and nozzle counts")]}),s.jsxs("li",{children:["• ",t("support.collectItem5","Non-sensitive settings (themes, formats)")]}),s.jsxs("li",{children:["• ",t("support.collectItem6","Debug logs (sanitized)")]})]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-red-400 font-medium mb-1",children:t("support.notCollected","NOT collected:")}),s.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[s.jsxs("li",{children:["• ",t("support.notItem1","Printer names, IPs, serial numbers")]}),s.jsxs("li",{children:["• ",t("support.notItem2","Access codes and passwords")]}),s.jsxs("li",{children:["• ",t("support.notItem3","Email addresses")]}),s.jsxs("li",{children:["• ",t("support.notItem4","API keys and tokens")]}),s.jsxs("li",{children:["• ",t("support.notItem5","Webhook URLs")]}),s.jsxs("li",{children:["• ",t("support.notItem6","Your hostname or username")]})]})]})]}),s.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].")})]}),s.jsx(xXe,{})]})}),s.jsxs(Fd,{title:t("system.database","Database"),icon:Mu,children:[s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[s.jsx(mi,{icon:fo,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),s.jsx(mi,{icon:s2,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),s.jsx(mi,{icon:Yi,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),s.jsx(mi,{icon:ht,label:t("system.printing","Printing"),value:c.database.archives_printing,color:"text-yellow-500"})]}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(mi,{icon:Ur,label:t("system.printers","Printers"),value:c.database.printers}),s.jsx(mi,{icon:SW,label:t("system.filaments","Filaments"),value:c.database.filaments}),s.jsx(mi,{icon:Ja,label:t("system.projects","Projects"),value:c.database.projects}),s.jsx(mi,{icon:tl,label:t("system.smartPlugs","Smart Plugs"),value:c.database.smart_plugs})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[s.jsx(mi,{icon:Jn,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),s.jsx(mi,{icon:fo,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),s.jsxs(Fd,{title:t("system.connectedPrinters","Connected Printers"),icon:Ur,children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[s.jsx("div",{className:"text-3xl font-bold text-bambu-green",children:c.printers.connected}),s.jsx("div",{className:"text-bambu-gray",children:t("system.ofTotal","of {{total}} printers connected",{total:c.printers.total})})]}),c.printers.connected_list.length>0?s.jsx("div",{className:"space-y-2",children:c.printers.connected_list.map(T=>s.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green"}),s.jsx("span",{className:"font-medium text-white",children:T.name})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[s.jsx("span",{children:T.model}),s.jsx("span",{className:`px-2 py-0.5 rounded ${T.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":T.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:T.state})]})]},T.id))}):s.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),s.jsx(Fd,{title:t("system.storage","Storage"),icon:h2,children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:t("system.diskUsage","Disk Usage")}),s.jsxs("span",{className:"text-white",children:[c.storage.disk_used_formatted," / ",c.storage.disk_total_formatted]})]}),s.jsx(bq,{percent:c.storage.disk_percent_used,color:S}),s.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),"%)"]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(mi,{icon:fo,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),s.jsx(mi,{icon:Mu,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),x&&s.jsx(mi,{icon:Il,label:t("system.fileManagerStorage","File Manager"),value:bXe(x.total_size_bytes),subValue:`${x.total_files} files, ${x.total_folders} folders`})]})]})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsx(Fd,{title:t("system.memory","Memory"),icon:Rde,children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:t("system.memoryUsage","Memory Usage")}),s.jsxs("span",{className:"text-white",children:[c.memory.used_formatted," / ",c.memory.total_formatted]})]}),s.jsx(bq,{percent:c.memory.percent_used,color:M}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.memory.available_formatted," ",t("system.available","available")]})]})})}),s.jsx(Fd,{title:t("system.cpu","CPU"),icon:Dw,children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(mi,{icon:Dw,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),s.jsx(mi,{icon:Dw,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),s.jsx(Fd,{title:t("system.systemDetails","System Details"),icon:yf,children:s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(mi,{icon:yf,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),s.jsx(mi,{icon:Dw,label:t("system.architecture","Architecture"),value:c.system.architecture}),s.jsx(mi,{icon:yf,label:t("system.python","Python"),value:c.system.python_version}),s.jsx(mi,{icon:Jn,label:t("system.bootTime","Boot Time"),value:$g(c.system.boot_time,b)})]})})]})}function vXe(){const t=Mc(),{t:e}=$n(),{login:n}=Ai(),{showToast:r}=Hn(),{mode:i}=Oh(),[a,o]=_.useState(""),[l,c]=_.useState(""),[u,d]=_.useState(!1),f=mt({mutationFn:()=>n(a,l),onSuccess:()=>{r(e("login.loginSuccess")),t("/")},onError:m=>{r(m.message||e("login.loginFailed"),"error")}}),p=m=>{if(m.preventDefault(),!a||!l){r(e("login.enterCredentials"),"error");return}f.mutate()};return s.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:[s.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:[s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"flex items-center justify-center mb-6",children:s.jsx("img",{src:i==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),s.jsx("h2",{className:"text-3xl font-bold text-white",children:e("login.title")}),s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:e("login.subtitle")})]}),s.jsxs("form",{className:"mt-8 space-y-6",onSubmit:p,children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-white mb-2",children:e("login.username")}),s.jsx("input",{id:"username",type:"text",required:!0,value:a,onChange:m=>o(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:e("login.usernamePlaceholder"),autoComplete:"username"})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-white mb-2",children:e("login.password")}),s.jsx("input",{id:"password",type:"password",required:!0,value:l,onChange:m=>c(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:e("login.passwordPlaceholder"),autoComplete:"current-password"})]})]}),s.jsx("div",{children:s.jsx("button",{type:"submit",disabled:f.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:f.isPending?e("login.signingIn"):e("login.signIn")})}),s.jsx("div",{className:"text-center",children:s.jsx("button",{type:"button",onClick:()=>d(!0),className:"text-sm text-bambu-gray hover:text-bambu-green transition-colors",children:e("login.forgotPassword")})})]})]}),u&&s.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>d(!1),children:s.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:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(qce,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:e("login.forgotPasswordTitle")})]}),s.jsx("button",{onClick:()=>d(!1),className:"p-1 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-bambu-gray",children:e("login.forgotPasswordMessage")}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4 space-y-2",children:[s.jsx("p",{className:"text-sm text-white font-medium",children:e("login.howToReset")}),s.jsxs("ol",{className:"text-sm text-bambu-gray space-y-1 list-decimal list-inside",children:[s.jsx("li",{children:e("login.resetStep1")}),s.jsx("li",{children:e("login.resetStep2")}),s.jsx("li",{children:e("login.resetStep3")}),s.jsx("li",{children:e("login.resetStep4")})]})]}),s.jsx("button",{onClick:()=>d(!1),className:"w-full py-2 px-4 bg-bambu-dark-tertiary hover:bg-bambu-dark text-white rounded-lg transition-colors",children:e("login.gotIt")})]})]})})]})}function wXe(){const t=Mc(),{t:e}=$n(),{showToast:n}=Hn(),{mode:r}=Oh(),{refreshAuth:i}=Ai(),[a,o]=_.useState(!1),[l,c]=_.useState(""),[u,d]=_.useState(""),[f,p]=_.useState(""),m=mt({mutationFn:()=>ue.setupAuth({auth_enabled:a,admin_username:a?l:void 0,admin_password:a?u:void 0}),onSuccess:async b=>{await i(),b.auth_enabled?b.admin_created?(n(e("setup.toast.authEnabledAdminCreated")),t("/login")):(n(e("setup.toast.authEnabledExistingAdmins")),t("/login")):(n(e("setup.toast.setupCompleted")),t("/"))},onError:b=>{n(b.message,"error")}}),x=b=>{if(b.preventDefault(),a&&(l||u)){if(!l||!u){n(e("setup.toast.enterBothCredentials"),"error");return}if(u!==f){n(e("setup.toast.passwordsDoNotMatch"),"error");return}if(u.length<6){n(e("setup.toast.passwordTooShort"),"error");return}}m.mutate()};return s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:s.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:[s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"flex items-center justify-center mb-6",children:s.jsx("img",{src:r==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),s.jsx("h2",{className:"text-3xl font-bold text-white",children:e("setup.title")}),s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:e("setup.subtitle")})]}),s.jsxs("form",{className:"mt-8 space-y-6",onSubmit:x,children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center p-4 bg-bambu-dark-secondary/50 rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("input",{id:"auth-enabled",type:"checkbox",checked:a,onChange:b=>o(b.target.checked),className:"h-4 w-4 text-bambu-green focus:ring-bambu-green border-bambu-dark-tertiary rounded bg-bambu-dark-secondary"}),s.jsx("label",{htmlFor:"auth-enabled",className:"ml-3 block text-sm font-medium text-white",children:e("setup.enableAuth")})]}),a&&s.jsxs("div",{className:"space-y-4 mt-4",children:[s.jsx("div",{className:"p-3 bg-bambu-dark-secondary/50 border border-bambu-dark-tertiary rounded-lg",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Zo,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-sm text-bambu-gray",children:[s.jsx("p",{className:"text-white font-medium mb-1",children:e("setup.adminAccount")}),s.jsx("p",{children:e("setup.adminAccountDesc")})]})]})}),s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"admin-username",className:"block text-sm font-medium text-white mb-2",children:[e("setup.adminUsername")," ",s.jsx("span",{className:"text-bambu-gray text-xs",children:e("setup.optionalIfAdminExists")})]}),s.jsx("input",{id:"admin-username",type:"text",value:l,onChange:b=>c(b.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:e("setup.adminUsernamePlaceholder"),autoComplete:"username"})]}),s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"admin-password",className:"block text-sm font-medium text-white mb-2",children:[e("setup.adminPassword")," ",s.jsx("span",{className:"text-bambu-gray text-xs",children:e("setup.optionalIfAdminExists")})]}),s.jsx("input",{id:"admin-password",type:"password",value:u,onChange:b=>d(b.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:e("setup.adminPasswordPlaceholder"),minLength:6,autoComplete:"new-password"})]}),u&&s.jsxs("div",{children:[s.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium text-white mb-2",children:e("setup.confirmPassword")}),s.jsx("input",{id:"confirm-password",type:"password",value:f,onChange:b=>p(b.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:e("setup.confirmPasswordPlaceholder"),minLength:6,autoComplete:"new-password"})]})]})]}),s.jsx("div",{children:s.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?e("setup.settingUp"):e("setup.completeSetup")})})]})]})})}function _Xe(){const t=_.useRef(null),e=_.useRef(null),n=an(),[r,i]=_.useState(!1),a=_.useRef(new Set),o=_.useRef(null),l=_.useRef(new Map),c=_.useRef(null),u=_.useRef([]),d=_.useRef(!1),f=_.useRef(()=>{}),p=_.useCallback(()=>{if(d.current||u.current.length===0)return;d.current=!0;const S=()=>{const M=u.current.shift();M?requestAnimationFrame(()=>{f.current(M),u.current.length>0?setTimeout(S,16):d.current=!1}):d.current=!1};S()},[]),m=_.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const M=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,T=new WebSocket(M);let E=null;T.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),E=window.setInterval(()=>{T.readyState===WebSocket.OPEN&&T.send(JSON.stringify({type:"ping"}))},3e4)},T.onmessage=C=>{try{const k=JSON.parse(C.data);k.type==="printer_status"&&k.printer_id!==void 0&&k.data?f.current(k):(u.current.push(k),p())}catch{}},T.onclose=C=>{console.log("[WebSocket] Closed",C.code,C.reason),E&&(clearInterval(E),E=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{m()},3e3)},T.onerror=C=>{console.error("[WebSocket] Error",C),T.close()},t.current=T},[p]),x=_.useCallback((S,M)=>{const T=l.current.get(S)||{};l.current.set(S,{...T,...M}),c.current||(c.current=window.setTimeout(()=>{const E=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{E.forEach((C,k)=>{n.setQueryData(["printerStatus",k],R=>{const A={...R,...C};return A.wifi_signal==null&&R?.wifi_signal!=null&&(A.wifi_signal=R.wifi_signal),A})})})},100))},[n]),b=_.useCallback(S=>{a.current.add(S),o.current&&clearTimeout(o.current),o.current=window.setTimeout(()=>{const M=Array.from(a.current);a.current.clear(),o.current=null;let T=0;M.forEach(E=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[E]})})},T),T+=500})},3e3)},[n]),y=_.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]);_.useEffect(()=>{f.current=y},[y]),_.useEffect(()=>(m(),()=>{e.current&&clearTimeout(e.current),o.current&&clearTimeout(o.current),c.current&&clearTimeout(c.current),t.current&&t.current.close()}),[m]);const v=_.useCallback(S=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(S))},[]);return{isConnected:r,sendMessage:v}}const SXe=new Gle({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function NXe({children:t}){return _Xe(),s.jsx(s.Fragment,{children:t})}function MXe({children:t}){const{authEnabled:e,loading:n,user:r}=Ai();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e&&!r?s.jsx(Fg,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function EXe({children:t}){const{authEnabled:e,loading:n,user:r,isAdmin:i}=Ai();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?r?i?s.jsx(s.Fragment,{children:t}):s.jsx(Fg,{to:"/",replace:!0}):s.jsx(Fg,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function kXe({children:t}){const{authEnabled:e,loading:n}=Ai();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?s.jsx(Fg,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function TXe(){return s.jsx(yfe,{children:s.jsx(kfe,{children:s.jsx(qle,{client:SXe,children:s.jsx(Nfe,{children:s.jsx(hle,{children:s.jsxs(Boe,{children:[s.jsx(Li,{path:"/setup",element:s.jsx(kXe,{children:s.jsx(wXe,{})})}),s.jsx(Li,{path:"/login",element:s.jsx(vXe,{})}),s.jsx(Li,{path:"/camera/:printerId",element:s.jsx(lXe,{})}),s.jsx(Li,{path:"/overlay/:printerId",element:s.jsx(mXe,{})}),s.jsxs(Li,{element:s.jsx(MXe,{children:s.jsx(NXe,{children:s.jsx(jfe,{})})}),children:[s.jsx(Li,{index:!0,element:s.jsx(fje,{})}),s.jsx(Li,{path:"archives",element:s.jsx(nqe,{})}),s.jsx(Li,{path:"queue",element:s.jsx(BWe,{})}),s.jsx(Li,{path:"stats",element:s.jsx(tKe,{})}),s.jsx(Li,{path:"profiles",element:s.jsx(LKe,{})}),s.jsx(Li,{path:"maintenance",element:s.jsx(BKe,{})}),s.jsx(Li,{path:"projects",element:s.jsx(HKe,{})}),s.jsx(Li,{path:"projects/:id",element:s.jsx(YKe,{})}),s.jsx(Li,{path:"files",element:s.jsx(iXe,{})}),s.jsx(Li,{path:"settings",element:s.jsx(EXe,{children:s.jsx(MKe,{})})}),s.jsx(Li,{path:"users",element:s.jsx(Fg,{to:"/settings?tab=users",replace:!0})}),s.jsx(Li,{path:"groups",element:s.jsx(Fg,{to:"/settings?tab=users",replace:!0})}),s.jsx(Li,{path:"system",element:s.jsx(yXe,{})}),s.jsx(Li,{path:"external/:id",element:s.jsx(pXe,{})})]})]})})})})})})}Uae.createRoot(document.getElementById("root")).render(s.jsx(_.StrictMode,{children:s.jsx(TXe,{})}));